~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/libdrizzle.c

MergedĀ fromĀ Patrick.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2004 MySQL AB
 
1
/* Copyright (C) 2000-2004 DRIZZLE AB
2
2
 
3
3
   This program is free software; you can redistribute it and/or modify
4
4
   it under the terms of the GNU General Public License as published by
31
31
#include <sys/stat.h>
32
32
#include <signal.h>
33
33
#include <time.h>
34
 
#ifdef   HAVE_PWD_H
 
34
#ifdef   HAVE_PWD_H
35
35
#include <pwd.h>
36
36
#endif
37
37
 
52
52
#ifdef HAVE_SYS_UN_H
53
53
#include <sys/un.h>
54
54
#endif
55
 
#include <my_pthread.h>                         /* because of signal()  */
 
55
#include <my_pthread.h>        /* because of signal()  */
56
56
#ifndef INADDR_NONE
57
 
#define INADDR_NONE     -1
 
57
#define INADDR_NONE  -1
58
58
#endif
59
59
 
60
60
#include <sql_common.h>
63
63
#undef net_buffer_length
64
64
#undef max_allowed_packet
65
65
 
66
 
uint32_t                net_buffer_length= 8192;
67
 
uint32_t                max_allowed_packet= 1024L*1024L*1024L;
 
66
uint32_t     net_buffer_length= 8192;
 
67
uint32_t    max_allowed_packet= 1024L*1024L*1024L;
68
68
 
69
69
#include <errno.h>
70
70
#define SOCKET_ERROR -1
79
79
static void append_wild(char *to,char *end,const char *wild);
80
80
 
81
81
 
82
 
 
83
 
static MYSQL_PARAMETERS mysql_internal_parameters=
 
82
static DRIZZLE_PARAMETERS drizzle_internal_parameters=
84
83
{&max_allowed_packet, &net_buffer_length, 0};
85
84
 
86
 
MYSQL_PARAMETERS *STDCALL mysql_get_parameters(void)
 
85
DRIZZLE_PARAMETERS *STDCALL drizzle_get_parameters(void)
87
86
{
88
 
  return &mysql_internal_parameters;
 
87
  return &drizzle_internal_parameters;
89
88
}
90
89
 
91
 
my_bool STDCALL mysql_thread_init()
 
90
my_bool STDCALL drizzle_thread_init()
92
91
{
93
92
  return my_thread_init();
94
93
}
95
94
 
96
 
void STDCALL mysql_thread_end()
 
95
void STDCALL drizzle_thread_end()
97
96
{
98
97
  my_thread_end();
99
98
}
106
105
static void
107
106
append_wild(char *to, char *end, const char *wild)
108
107
{
109
 
  end-=5;                                       /* Some extra */
 
108
  end-=5;          /* Some extra */
110
109
  if (wild && wild[0])
111
110
  {
112
111
    to=strmov(to," like '");
113
112
    while (*wild && to < end)
114
113
    {
115
114
      if (*wild == '\\' || *wild == '\'')
116
 
        *to++='\\';
 
115
  *to++='\\';
117
116
      *to++= *wild++;
118
117
    }
119
 
    if (*wild)                                  /* Too small buffer */
120
 
      *to++='%';                                /* Nicer this way */
 
118
    if (*wild)          /* Too small buffer */
 
119
      *to++='%';        /* Nicer this way */
121
120
    to[0]='\'';
122
121
    to[1]=0;
123
122
  }
143
142
**************************************************************************/
144
143
 
145
144
#ifdef USE_OLD_FUNCTIONS
146
 
MYSQL * STDCALL
147
 
mysql_connect(MYSQL *mysql,const char *host,
148
 
              const char *user, const char *passwd)
 
145
DRIZZLE * STDCALL
 
146
drizzle_connect(DRIZZLE *drizzle,const char *host,
 
147
        const char *user, const char *passwd)
149
148
{
150
 
  MYSQL *res;
151
 
  mysql=mysql_init(mysql);                      /* Make it thread safe */
 
149
  DRIZZLE *res;
 
150
  drizzle=drizzle_init(drizzle);      /* Make it thread safe */
152
151
  {
153
 
    if (!(res=mysql_real_connect(mysql,host,user,passwd,NullS,0,NullS,0)))
 
152
    if (!(res=drizzle_connect(drizzle,host,user,passwd,NullS,0,NullS,0)))
154
153
    {
155
 
      if (mysql->free_me)
156
 
        my_free((uchar*) mysql,MYF(0));
 
154
      if (drizzle->free_me)
 
155
  my_free((uchar*) drizzle,MYF(0));
157
156
    }
158
 
    mysql->reconnect= 1;
 
157
    drizzle->reconnect= 1;
159
158
    return(res);
160
159
  }
161
160
}
166
165
  Change user and database
167
166
**************************************************************************/
168
167
 
169
 
int cli_read_change_user_result(MYSQL *mysql, char *buff, const char *passwd)
 
168
int cli_read_change_user_result(DRIZZLE *drizzle, char *buff, const char *passwd)
170
169
{
171
170
  (void)buff;
172
171
  (void)passwd;
173
172
  ulong pkt_length;
174
173
 
175
 
  pkt_length= cli_safe_read(mysql);
 
174
  pkt_length= cli_safe_read(drizzle);
176
175
  
177
176
  if (pkt_length == packet_error)
178
177
    return 1;
180
179
  return 0;
181
180
}
182
181
 
183
 
my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
184
 
                                  const char *passwd, const char *db)
 
182
my_bool  STDCALL drizzle_change_user(DRIZZLE *drizzle, const char *user,
 
183
          const char *passwd, const char *db)
185
184
{
186
185
  char buff[USERNAME_LENGTH+SCRAMBLED_PASSWORD_CHAR_LENGTH+NAME_LEN+2];
187
186
  char *end= buff;
188
187
  int rc;
189
 
  CHARSET_INFO *saved_cs= mysql->charset;
 
188
  CHARSET_INFO *saved_cs= drizzle->charset;
190
189
 
191
190
  /* Get the connection-default character set. */
192
191
 
193
 
  if (mysql_init_character_set(mysql))
 
192
  if (drizzle_init_character_set(drizzle))
194
193
  {
195
 
    mysql->charset= saved_cs;
 
194
    drizzle->charset= saved_cs;
196
195
    return(true);
197
196
  }
198
197
 
211
210
  {
212
211
    {
213
212
      *end++= SCRAMBLE_LENGTH;
214
 
      scramble(end, mysql->scramble, passwd);
 
213
      scramble(end, drizzle->scramble, passwd);
215
214
      end+= SCRAMBLE_LENGTH;
216
215
    }
217
216
  }
222
221
 
223
222
  /* Add character set number. */
224
223
 
225
 
  if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION)
 
224
  if (drizzle->server_capabilities & CLIENT_SECURE_CONNECTION)
226
225
  {
227
 
    int2store(end, (ushort) mysql->charset->number);
 
226
    int2store(end, (ushort) drizzle->charset->number);
228
227
    end+= 2;
229
228
  }
230
229
 
231
230
  /* Write authentication package */
232
 
  (void)simple_command(mysql,COM_CHANGE_USER, (uchar*) buff, (ulong) (end-buff), 1);
 
231
  (void)simple_command(drizzle,COM_CHANGE_USER, (uchar*) buff, (ulong) (end-buff), 1);
233
232
 
234
 
  rc= (*mysql->methods->read_change_user_result)(mysql, buff, passwd);
 
233
  rc= (*drizzle->methods->read_change_user_result)(drizzle, buff, passwd);
235
234
 
236
235
  if (rc == 0)
237
236
  {
238
237
    /* Free old connect information */
239
 
    my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR));
240
 
    my_free(mysql->passwd,MYF(MY_ALLOW_ZERO_PTR));
241
 
    my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR));
 
238
    my_free(drizzle->user,MYF(MY_ALLOW_ZERO_PTR));
 
239
    my_free(drizzle->passwd,MYF(MY_ALLOW_ZERO_PTR));
 
240
    my_free(drizzle->db,MYF(MY_ALLOW_ZERO_PTR));
242
241
 
243
242
    /* alloc new connect information */
244
 
    mysql->user=  my_strdup(user,MYF(MY_WME));
245
 
    mysql->passwd=my_strdup(passwd,MYF(MY_WME));
246
 
    mysql->db=    db ? my_strdup(db,MYF(MY_WME)) : 0;
 
243
    drizzle->user=  my_strdup(user,MYF(MY_WME));
 
244
    drizzle->passwd=my_strdup(passwd,MYF(MY_WME));
 
245
    drizzle->db=    db ? my_strdup(db,MYF(MY_WME)) : 0;
247
246
  }
248
247
  else
249
248
  {
250
 
    mysql->charset= saved_cs;
 
249
    drizzle->charset= saved_cs;
251
250
  }
252
251
 
253
252
  return(rc);
261
260
void read_user_name(char *name)
262
261
{
263
262
  if (geteuid() == 0)
264
 
    (void) strmov(name,"root");         /* allow use of surun */
 
263
    (void) strmov(name,"root");    /* allow use of surun */
265
264
  else
266
265
  {
267
266
#ifdef HAVE_GETPWUID
270
269
    if ((str=getlogin()) == NULL)
271
270
    {
272
271
      if ((skr=getpwuid(geteuid())) != NULL)
273
 
        str=skr->pw_name;
 
272
  str=skr->pw_name;
274
273
      else if (!(str=getenv("USER")) && !(str=getenv("LOGNAME")) &&
275
 
               !(str=getenv("LOGIN")))
276
 
        str="UNKNOWN_USER";
 
274
         !(str=getenv("LOGIN")))
 
275
  str="UNKNOWN_USER";
277
276
    }
278
277
    (void) strmake(name,str,USERNAME_LENGTH);
279
278
#elif HAVE_CUSERID
285
284
  return;
286
285
}
287
286
 
288
 
my_bool handle_local_infile(MYSQL *mysql, const char *net_filename)
 
287
my_bool handle_local_infile(DRIZZLE *drizzle, const char *net_filename)
289
288
{
290
289
  my_bool result= 1;
291
 
  uint packet_length=MY_ALIGN(mysql->net.max_packet-16,IO_SIZE);
292
 
  NET *net= &mysql->net;
 
290
  uint packet_length=MY_ALIGN(drizzle->net.max_packet-16,IO_SIZE);
 
291
  NET *net= &drizzle->net;
293
292
  int readcount;
294
293
  void *li_ptr;          /* pass state to local_infile functions */
295
 
  char *buf;            /* buffer to be filled by local_infile_read */
296
 
  struct st_mysql_options *options= &mysql->options;
 
294
  char *buf;    /* buffer to be filled by local_infile_read */
 
295
  struct st_drizzle_options *options= &drizzle->options;
297
296
 
298
297
  /* check that we've got valid callback functions */
299
298
  if (!(options->local_infile_init &&
300
 
        options->local_infile_read &&
301
 
        options->local_infile_end &&
302
 
        options->local_infile_error))
 
299
  options->local_infile_read &&
 
300
  options->local_infile_end &&
 
301
  options->local_infile_error))
303
302
  {
304
303
    /* if any of the functions is invalid, set the default */
305
 
    mysql_set_local_infile_default(mysql);
 
304
    drizzle_set_local_infile_default(drizzle);
306
305
  }
307
306
 
308
307
  /* copy filename into local memory and allocate read buffer */
309
308
  if (!(buf=my_malloc(packet_length, MYF(0))))
310
309
  {
311
 
    set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
 
310
    set_drizzle_error(drizzle, CR_OUT_OF_MEMORY, unknown_sqlstate);
312
311
    return(1);
313
312
  }
314
313
 
328
327
 
329
328
  /* read blocks of data from local infile callback */
330
329
  while ((readcount =
331
 
          (*options->local_infile_read)(li_ptr, buf,
332
 
                                        packet_length)) > 0)
 
330
    (*options->local_infile_read)(li_ptr, buf,
 
331
          packet_length)) > 0)
333
332
  {
334
333
    if (my_net_write(net, (uchar*) buf, readcount))
335
334
    {
340
339
  /* Send empty packet to mark end of file */
341
340
  if (my_net_write(net, (const uchar*) "", 0) || net_flush(net))
342
341
  {
343
 
    set_mysql_error(mysql, CR_SERVER_LOST, unknown_sqlstate);
 
342
    set_drizzle_error(drizzle, CR_SERVER_LOST, unknown_sqlstate);
344
343
    goto err;
345
344
  }
346
345
 
353
352
    goto err;
354
353
  }
355
354
 
356
 
  result=0;                                     /* Ok */
 
355
  result=0;          /* Ok */
357
356
 
358
357
err:
359
358
  /* free up memory allocated with _init, usually */
381
380
 
382
381
  SYNOPSIS
383
382
    default_local_infile_init()
384
 
    ptr                 Store pointer to internal data here
385
 
    filename            File name to open. This may be in unix format !
 
383
    ptr      Store pointer to internal data here
 
384
    filename    File name to open. This may be in unix format !
386
385
 
387
386
 
388
387
  NOTES
390
389
    guarantees that default_local_infile_end() is called.
391
390
 
392
391
  RETURN
393
 
    0   ok
394
 
    1   error
 
392
    0  ok
 
393
    1  error
395
394
*/
396
395
 
397
396
static int default_local_infile_init(void **ptr, const char *filename,
401
400
  char tmp_name[FN_REFLEN];
402
401
 
403
402
  if (!(*ptr= data= ((default_local_infile_data *)
404
 
                     my_malloc(sizeof(default_local_infile_data),  MYF(0)))))
 
403
         my_malloc(sizeof(default_local_infile_data),  MYF(0)))))
405
404
    return 1; /* out of memory */
406
405
 
407
406
  data->error_msg[0]= 0;
425
424
 
426
425
  SYNOPSIS
427
426
    default_local_infile_read()
428
 
    ptr                 Points to handle allocated by _init
429
 
    buf                 Read data here
430
 
    buf_len             Ammount of data to read
 
427
    ptr      Points to handle allocated by _init
 
428
    buf      Read data here
 
429
    buf_len    Ammount of data to read
431
430
 
432
431
  RETURN
433
 
    > 0         number of bytes read
434
 
    == 0        End of data
435
 
    < 0         Error
 
432
    > 0    number of bytes read
 
433
    == 0  End of data
 
434
    < 0    Error
436
435
*/
437
436
 
438
437
static int default_local_infile_read(void *ptr, char *buf, uint buf_len)
456
455
 
457
456
  SYNOPSIS
458
457
    default_local_infile_end()
459
 
    ptr                 Points to handle allocated by _init
460
 
                        May be NULL if _init failed!
 
458
    ptr      Points to handle allocated by _init
 
459
      May be NULL if _init failed!
461
460
 
462
461
  RETURN
463
462
*/
465
464
static void default_local_infile_end(void *ptr)
466
465
{
467
466
  default_local_infile_data *data= (default_local_infile_data *) ptr;
468
 
  if (data)                                     /* If not error on open */
 
467
  if (data)          /* If not error on open */
469
468
  {
470
469
    if (data->fd >= 0)
471
470
      my_close(data->fd, MYF(MY_WME));
479
478
 
480
479
  SYNOPSIS
481
480
    default_local_infile_end()
482
 
    ptr                 Points to handle allocated by _init
483
 
                        May be NULL if _init failed!
484
 
    error_msg           Store error text here
485
 
    error_msg_len       Max lenght of error_msg
 
481
    ptr      Points to handle allocated by _init
 
482
      May be NULL if _init failed!
 
483
    error_msg    Store error text here
 
484
    error_msg_len  Max lenght of error_msg
486
485
 
487
486
  RETURN
488
487
    error message number
492
491
default_local_infile_error(void *ptr, char *error_msg, uint error_msg_len)
493
492
{
494
493
  default_local_infile_data *data = (default_local_infile_data *) ptr;
495
 
  if (data)                                     /* If not error on open */
 
494
  if (data)          /* If not error on open */
496
495
  {
497
496
    strmake(error_msg, data->error_msg, error_msg_len);
498
497
    return data->error_num;
504
503
 
505
504
 
506
505
void
507
 
mysql_set_local_infile_handler(MYSQL *mysql,
 
506
drizzle_set_local_infile_handler(DRIZZLE *drizzle,
508
507
                               int (*local_infile_init)(void **, const char *,
509
508
                               void *),
510
509
                               int (*local_infile_read)(void *, char *, uint),
512
511
                               int (*local_infile_error)(void *, char *, uint),
513
512
                               void *userdata)
514
513
{
515
 
  mysql->options.local_infile_init=  local_infile_init;
516
 
  mysql->options.local_infile_read=  local_infile_read;
517
 
  mysql->options.local_infile_end=   local_infile_end;
518
 
  mysql->options.local_infile_error= local_infile_error;
519
 
  mysql->options.local_infile_userdata = userdata;
 
514
  drizzle->options.local_infile_init=  local_infile_init;
 
515
  drizzle->options.local_infile_read=  local_infile_read;
 
516
  drizzle->options.local_infile_end=   local_infile_end;
 
517
  drizzle->options.local_infile_error= local_infile_error;
 
518
  drizzle->options.local_infile_userdata = userdata;
520
519
}
521
520
 
522
521
 
523
 
void mysql_set_local_infile_default(MYSQL *mysql)
 
522
void drizzle_set_local_infile_default(DRIZZLE *drizzle)
524
523
{
525
 
  mysql->options.local_infile_init=  default_local_infile_init;
526
 
  mysql->options.local_infile_read=  default_local_infile_read;
527
 
  mysql->options.local_infile_end=   default_local_infile_end;
528
 
  mysql->options.local_infile_error= default_local_infile_error;
 
524
  drizzle->options.local_infile_init=  default_local_infile_init;
 
525
  drizzle->options.local_infile_read=  default_local_infile_read;
 
526
  drizzle->options.local_infile_end=   default_local_infile_end;
 
527
  drizzle->options.local_infile_error= default_local_infile_error;
529
528
}
530
529
 
531
530
 
532
531
/**************************************************************************
533
532
  Do a query. If query returned rows, free old rows.
534
 
  Read data by mysql_store_result or by repeat call of mysql_fetch_row
 
533
  Read data by drizzle_store_result or by repeat call of drizzle_fetch_row
535
534
**************************************************************************/
536
535
 
537
536
int STDCALL
538
 
mysql_query(MYSQL *mysql, const char *query)
 
537
drizzle_query(DRIZZLE *drizzle, const char *query)
539
538
{
540
 
  return mysql_real_query(mysql,query, (uint) strlen(query));
 
539
  return drizzle_real_query(drizzle,query, (uint) strlen(query));
541
540
}
542
541
 
543
542
 
545
544
  Return next field of the query results
546
545
**************************************************************************/
547
546
 
548
 
MYSQL_FIELD * STDCALL
549
 
mysql_fetch_field(MYSQL_RES *result)
 
547
DRIZZLE_FIELD * STDCALL
 
548
drizzle_fetch_field(DRIZZLE_RES *result)
550
549
{
551
550
  if (result->current_field >= result->field_count)
552
551
    return(NULL);
559
558
**************************************************************************/
560
559
 
561
560
void STDCALL
562
 
mysql_data_seek(MYSQL_RES *result, uint64_t row)
 
561
drizzle_data_seek(DRIZZLE_RES *result, uint64_t row)
563
562
{
564
 
  MYSQL_ROWS    *tmp=0;
 
563
  DRIZZLE_ROWS  *tmp=0;
565
564
  if (result->data)
566
565
    for (tmp=result->data->data; row-- && tmp ; tmp = tmp->next) ;
567
566
  result->current_row=0;
570
569
 
571
570
 
572
571
/*************************************************************************
573
 
  put the row or field cursor one a position one got from mysql_row_tell()
574
 
  This doesn't restore any data. The next mysql_fetch_row or
575
 
  mysql_fetch_field will return the next row or field after the last used
 
572
  put the row or field cursor one a position one got from DRIZZLE_ROW_tell()
 
573
  This doesn't restore any data. The next drizzle_fetch_row or
 
574
  drizzle_fetch_field will return the next row or field after the last used
576
575
*************************************************************************/
577
576
 
578
 
MYSQL_ROW_OFFSET STDCALL
579
 
mysql_row_seek(MYSQL_RES *result, MYSQL_ROW_OFFSET row)
 
577
DRIZZLE_ROW_OFFSET STDCALL
 
578
drizzle_row_seek(DRIZZLE_RES *result, DRIZZLE_ROW_OFFSET row)
580
579
{
581
 
  MYSQL_ROW_OFFSET return_value=result->data_cursor;
 
580
  DRIZZLE_ROW_OFFSET return_value=result->data_cursor;
582
581
  result->current_row= 0;
583
582
  result->data_cursor= row;
584
583
  return return_value;
585
584
}
586
585
 
587
586
 
588
 
MYSQL_FIELD_OFFSET STDCALL
589
 
mysql_field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET field_offset)
 
587
DRIZZLE_FIELD_OFFSET STDCALL
 
588
drizzle_field_seek(DRIZZLE_RES *result, DRIZZLE_FIELD_OFFSET field_offset)
590
589
{
591
 
  MYSQL_FIELD_OFFSET return_value=result->current_field;
 
590
  DRIZZLE_FIELD_OFFSET return_value=result->current_field;
592
591
  result->current_field=field_offset;
593
592
  return return_value;
594
593
}
598
597
  List all databases
599
598
*****************************************************************************/
600
599
 
601
 
MYSQL_RES * STDCALL
602
 
mysql_list_dbs(MYSQL *mysql, const char *wild)
 
600
DRIZZLE_RES * STDCALL
 
601
drizzle_list_dbs(DRIZZLE *drizzle, const char *wild)
603
602
{
604
603
  char buff[255];
605
604
 
606
605
  append_wild(strmov(buff,"show databases"),buff+sizeof(buff),wild);
607
 
  if (mysql_query(mysql,buff))
 
606
  if (drizzle_query(drizzle,buff))
608
607
    return(0);
609
 
  return (mysql_store_result(mysql));
 
608
  return (drizzle_store_result(drizzle));
610
609
}
611
610
 
612
611
 
615
614
  If wild is given then only the tables matching wild is returned
616
615
*****************************************************************************/
617
616
 
618
 
MYSQL_RES * STDCALL
619
 
mysql_list_tables(MYSQL *mysql, const char *wild)
 
617
DRIZZLE_RES * STDCALL
 
618
drizzle_list_tables(DRIZZLE *drizzle, const char *wild)
620
619
{
621
620
  char buff[255];
622
621
 
623
622
  append_wild(strmov(buff,"show tables"),buff+sizeof(buff),wild);
624
 
  if (mysql_query(mysql,buff))
 
623
  if (drizzle_query(drizzle,buff))
625
624
    return(0);
626
 
  return (mysql_store_result(mysql));
 
625
  return (drizzle_store_result(drizzle));
627
626
}
628
627
 
629
628
 
630
 
MYSQL_FIELD *cli_list_fields(MYSQL *mysql)
 
629
DRIZZLE_FIELD *cli_list_fields(DRIZZLE *drizzle)
631
630
{
632
 
  MYSQL_DATA *query;
633
 
  if (!(query= cli_read_rows(mysql,(MYSQL_FIELD*) 0, 
634
 
                             protocol_41(mysql) ? 8 : 6)))
 
631
  DRIZZLE_DATA *query;
 
632
  if (!(query= cli_read_rows(drizzle,(DRIZZLE_FIELD*) 0, 
 
633
           protocol_41(drizzle) ? 8 : 6)))
635
634
    return NULL;
636
635
 
637
 
  mysql->field_count= (uint) query->rows;
638
 
  return unpack_fields(query,&mysql->field_alloc,
639
 
                       mysql->field_count, 1, mysql->server_capabilities);
 
636
  drizzle->field_count= (uint) query->rows;
 
637
  return unpack_fields(query,&drizzle->field_alloc,
 
638
           drizzle->field_count, 1, drizzle->server_capabilities);
640
639
}
641
640
 
642
641
 
647
646
  show fields in 'table' like "wild"
648
647
**************************************************************************/
649
648
 
650
 
MYSQL_RES * STDCALL
651
 
mysql_list_fields(MYSQL *mysql, const char *table, const char *wild)
 
649
DRIZZLE_RES * STDCALL
 
650
drizzle_list_fields(DRIZZLE *drizzle, const char *table, const char *wild)
652
651
{
653
 
  MYSQL_RES   *result;
654
 
  MYSQL_FIELD *fields;
655
 
  char       buff[257],*end;
 
652
  DRIZZLE_RES   *result;
 
653
  DRIZZLE_FIELD *fields;
 
654
  char       buff[257],*end;
656
655
 
657
656
  end=strmake(strmake(buff, table,128)+1,wild ? wild : "",128);
658
 
  free_old_query(mysql);
659
 
  if (simple_command(mysql, COM_FIELD_LIST, (uchar*) buff,
 
657
  free_old_query(drizzle);
 
658
  if (simple_command(drizzle, COM_FIELD_LIST, (uchar*) buff,
660
659
                     (ulong) (end-buff), 1) ||
661
 
      !(fields= (*mysql->methods->list_fields)(mysql)))
662
 
    return(NULL);
663
 
 
664
 
  if (!(result = (MYSQL_RES *) my_malloc(sizeof(MYSQL_RES),
665
 
                                         MYF(MY_WME | MY_ZEROFILL))))
666
 
    return(NULL);
667
 
 
668
 
  result->methods= mysql->methods;
669
 
  result->field_alloc=mysql->field_alloc;
670
 
  mysql->fields=0;
671
 
  result->field_count = mysql->field_count;
 
660
      !(fields= (*drizzle->methods->list_fields)(drizzle)))
 
661
    return(NULL);
 
662
 
 
663
  if (!(result = (DRIZZLE_RES *) my_malloc(sizeof(DRIZZLE_RES),
 
664
           MYF(MY_WME | MY_ZEROFILL))))
 
665
    return(NULL);
 
666
 
 
667
  result->methods= drizzle->methods;
 
668
  result->field_alloc=drizzle->field_alloc;
 
669
  drizzle->fields=0;
 
670
  result->field_count = drizzle->field_count;
672
671
  result->fields= fields;
673
672
  result->eof=1;
674
673
  return(result);
676
675
 
677
676
/* List all running processes (threads) in server */
678
677
 
679
 
MYSQL_RES * STDCALL
680
 
mysql_list_processes(MYSQL *mysql)
 
678
DRIZZLE_RES * STDCALL
 
679
drizzle_list_processes(DRIZZLE *drizzle)
681
680
{
682
 
  MYSQL_DATA *fields;
 
681
  DRIZZLE_DATA *fields;
683
682
  uint field_count;
684
683
  uchar *pos;
685
684
 
686
 
  if (simple_command(mysql,COM_PROCESS_INFO,0,0,0))
 
685
  if (simple_command(drizzle,COM_PROCESS_INFO,0,0,0))
687
686
    return(0);
688
 
  free_old_query(mysql);
689
 
  pos=(uchar*) mysql->net.read_pos;
 
687
  free_old_query(drizzle);
 
688
  pos=(uchar*) drizzle->net.read_pos;
690
689
  field_count=(uint) net_field_length(&pos);
691
 
  if (!(fields = (*mysql->methods->read_rows)(mysql,(MYSQL_FIELD*) 0,
692
 
                                              protocol_41(mysql) ? 7 : 5)))
 
690
  if (!(fields = (*drizzle->methods->read_rows)(drizzle,(DRIZZLE_FIELD*) 0,
 
691
                protocol_41(drizzle) ? 7 : 5)))
693
692
    return(NULL);
694
 
  if (!(mysql->fields=unpack_fields(fields,&mysql->field_alloc,field_count,0,
695
 
                                    mysql->server_capabilities)))
 
693
  if (!(drizzle->fields=unpack_fields(fields,&drizzle->field_alloc,field_count,0,
 
694
            drizzle->server_capabilities)))
696
695
    return(0);
697
 
  mysql->status=MYSQL_STATUS_GET_RESULT;
698
 
  mysql->field_count=field_count;
699
 
  return(mysql_store_result(mysql));
 
696
  drizzle->status=DRIZZLE_STATUS_GET_RESULT;
 
697
  drizzle->field_count=field_count;
 
698
  return(drizzle_store_result(drizzle));
700
699
}
701
700
 
702
701
 
703
702
#ifdef USE_OLD_FUNCTIONS
704
703
int  STDCALL
705
 
mysql_create_db(MYSQL *mysql, const char *db)
 
704
drizzle_create_db(DRIZZLE *drizzle, const char *db)
706
705
{
707
 
  return(simple_command(mysql,COM_CREATE_DB,db, (ulong) strlen(db),0));
 
706
  return(simple_command(drizzle,COM_CREATE_DB,db, (ulong) strlen(db),0));
708
707
}
709
708
 
710
709
 
711
710
int  STDCALL
712
 
mysql_drop_db(MYSQL *mysql, const char *db)
 
711
drizzle_drop_db(DRIZZLE *drizzle, const char *db)
713
712
{
714
 
  return(simple_command(mysql,COM_DROP_DB,db,(ulong) strlen(db),0));
 
713
  return(simple_command(drizzle,COM_DROP_DB,db,(ulong) strlen(db),0));
715
714
}
716
715
#endif
717
716
 
718
717
 
719
718
int STDCALL
720
 
mysql_shutdown(MYSQL *mysql, enum mysql_enum_shutdown_level shutdown_level)
 
719
drizzle_shutdown(DRIZZLE *drizzle, enum drizzle_enum_shutdown_level shutdown_level)
721
720
{
722
721
  uchar level[1];
723
722
  level[0]= (uchar) shutdown_level;
724
 
  return(simple_command(mysql, COM_SHUTDOWN, level, 1, 0));
 
723
  return(simple_command(drizzle, COM_SHUTDOWN, level, 1, 0));
725
724
}
726
725
 
727
726
 
728
727
int STDCALL
729
 
mysql_refresh(MYSQL *mysql,uint options)
 
728
drizzle_refresh(DRIZZLE *drizzle,uint options)
730
729
{
731
730
  uchar bits[1];
732
731
  bits[0]= (uchar) options;
733
 
  return(simple_command(mysql, COM_REFRESH, bits, 1, 0));
 
732
  return(simple_command(drizzle, COM_REFRESH, bits, 1, 0));
734
733
}
735
734
 
736
735
 
737
736
int32_t STDCALL
738
 
mysql_kill(MYSQL *mysql, uint32_t pid)
 
737
drizzle_kill(DRIZZLE *drizzle, uint32_t pid)
739
738
{
740
739
  uchar buff[4];
741
740
  int4store(buff,pid);
742
 
  return(simple_command(mysql,COM_PROCESS_KILL,buff,sizeof(buff),0));
 
741
  return(simple_command(drizzle,COM_PROCESS_KILL,buff,sizeof(buff),0));
743
742
}
744
743
 
745
744
 
746
745
int STDCALL
747
 
mysql_set_server_option(MYSQL *mysql, enum enum_mysql_set_option option)
 
746
drizzle_set_server_option(DRIZZLE *drizzle, enum enum_drizzle_set_option option)
748
747
{
749
748
  uchar buff[2];
750
749
  int2store(buff, (uint) option);
751
 
  return(simple_command(mysql, COM_SET_OPTION, buff, sizeof(buff), 0));
 
750
  return(simple_command(drizzle, COM_SET_OPTION, buff, sizeof(buff), 0));
752
751
}
753
752
 
754
753
 
755
 
const char *cli_read_statistics(MYSQL *mysql)
 
754
const char *cli_read_statistics(DRIZZLE *drizzle)
756
755
{
757
 
  mysql->net.read_pos[mysql->packet_length]=0;  /* End of stat string */
758
 
  if (!mysql->net.read_pos[0])
 
756
  drizzle->net.read_pos[drizzle->packet_length]=0;  /* End of stat string */
 
757
  if (!drizzle->net.read_pos[0])
759
758
  {
760
 
    set_mysql_error(mysql, CR_WRONG_HOST_INFO, unknown_sqlstate);
761
 
    return mysql->net.last_error;
 
759
    set_drizzle_error(drizzle, CR_WRONG_HOST_INFO, unknown_sqlstate);
 
760
    return drizzle->net.last_error;
762
761
  }
763
 
  return (char*) mysql->net.read_pos;
 
762
  return (char*) drizzle->net.read_pos;
764
763
}
765
764
 
766
765
 
767
766
const char * STDCALL
768
 
mysql_stat(MYSQL *mysql)
 
767
drizzle_stat(DRIZZLE *drizzle)
769
768
{
770
 
  if (simple_command(mysql,COM_STATISTICS,0,0,0))
771
 
    return(mysql->net.last_error);
772
 
  return((*mysql->methods->read_statistics)(mysql));
 
769
  if (simple_command(drizzle,COM_STATISTICS,0,0,0))
 
770
    return(drizzle->net.last_error);
 
771
  return((*drizzle->methods->read_statistics)(drizzle));
773
772
}
774
773
 
775
774
 
776
775
int STDCALL
777
 
mysql_ping(MYSQL *mysql)
 
776
drizzle_ping(DRIZZLE *drizzle)
778
777
{
779
778
  int res;
780
 
  res= simple_command(mysql,COM_PING,0,0,0);
781
 
  if (res == CR_SERVER_LOST && mysql->reconnect)
782
 
    res= simple_command(mysql,COM_PING,0,0,0);
 
779
  res= simple_command(drizzle,COM_PING,0,0,0);
 
780
  if (res == CR_SERVER_LOST && drizzle->reconnect)
 
781
    res= simple_command(drizzle,COM_PING,0,0,0);
783
782
  return(res);
784
783
}
785
784
 
786
785
 
787
786
const char * STDCALL
788
 
mysql_get_server_info(MYSQL *mysql)
 
787
drizzle_get_server_info(DRIZZLE *drizzle)
789
788
{
790
 
  return((char*) mysql->server_version);
 
789
  return((char*) drizzle->server_version);
791
790
}
792
791
 
793
792
 
794
793
const char * STDCALL
795
 
mysql_get_host_info(MYSQL *mysql)
 
794
drizzle_get_host_info(DRIZZLE *drizzle)
796
795
{
797
 
  return(mysql->host_info);
 
796
  return(drizzle->host_info);
798
797
}
799
798
 
800
799
 
801
800
uint STDCALL
802
 
mysql_get_proto_info(MYSQL *mysql)
 
801
drizzle_get_proto_info(DRIZZLE *drizzle)
803
802
{
804
 
  return (mysql->protocol_version);
 
803
  return (drizzle->protocol_version);
805
804
}
806
805
 
807
806
const char * STDCALL
808
 
mysql_get_client_info(void)
 
807
drizzle_get_client_info(void)
809
808
{
810
809
  return (char*) MYSQL_SERVER_VERSION;
811
810
}
812
811
 
813
 
uint32_t STDCALL mysql_get_client_version(void)
 
812
uint32_t STDCALL drizzle_get_client_version(void)
814
813
{
815
814
  return MYSQL_VERSION_ID;
816
815
}
817
816
 
818
 
my_bool STDCALL mysql_eof(MYSQL_RES *res)
 
817
my_bool STDCALL drizzle_eof(DRIZZLE_RES *res)
819
818
{
820
819
  return res->eof;
821
820
}
822
821
 
823
 
MYSQL_FIELD * STDCALL mysql_fetch_field_direct(MYSQL_RES *res,uint fieldnr)
 
822
DRIZZLE_FIELD * STDCALL drizzle_fetch_field_direct(DRIZZLE_RES *res,uint fieldnr)
824
823
{
825
824
  return &(res)->fields[fieldnr];
826
825
}
827
826
 
828
 
MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res)
 
827
DRIZZLE_FIELD * STDCALL drizzle_fetch_fields(DRIZZLE_RES *res)
829
828
{
830
829
  return (res)->fields;
831
830
}
832
831
 
833
 
MYSQL_ROW_OFFSET STDCALL mysql_row_tell(MYSQL_RES *res)
 
832
DRIZZLE_ROW_OFFSET STDCALL DRIZZLE_ROW_tell(DRIZZLE_RES *res)
834
833
{
835
834
  return res->data_cursor;
836
835
}
837
836
 
838
 
MYSQL_FIELD_OFFSET STDCALL mysql_field_tell(MYSQL_RES *res)
 
837
DRIZZLE_FIELD_OFFSET STDCALL drizzle_field_tell(DRIZZLE_RES *res)
839
838
{
840
839
  return (res)->current_field;
841
840
}
842
841
 
843
 
/* MYSQL */
844
 
 
845
 
unsigned int STDCALL mysql_field_count(MYSQL *mysql)
846
 
{
847
 
  return mysql->field_count;
848
 
}
849
 
 
850
 
uint64_t STDCALL mysql_affected_rows(MYSQL *mysql)
851
 
{
852
 
  return mysql->affected_rows;
853
 
}
854
 
 
855
 
uint64_t STDCALL mysql_insert_id(MYSQL *mysql)
856
 
{
857
 
  return mysql->insert_id;
858
 
}
859
 
 
860
 
const char *STDCALL mysql_sqlstate(MYSQL *mysql)
861
 
{
862
 
  return mysql ? mysql->net.sqlstate : cant_connect_sqlstate;
863
 
}
864
 
 
865
 
uint32_t STDCALL mysql_warning_count(MYSQL *mysql)
866
 
{
867
 
  return mysql->warning_count;
868
 
}
869
 
 
870
 
const char *STDCALL mysql_info(MYSQL *mysql)
871
 
{
872
 
  return mysql->info;
873
 
}
874
 
 
875
 
uint32_t STDCALL mysql_thread_id(MYSQL *mysql)
876
 
{
877
 
  return (mysql)->thread_id;
878
 
}
879
 
 
880
 
const char * STDCALL mysql_character_set_name(MYSQL *mysql)
881
 
{
882
 
  return mysql->charset->csname;
883
 
}
884
 
 
885
 
void STDCALL mysql_get_character_set_info(MYSQL *mysql, MY_CHARSET_INFO *csinfo)
886
 
{
887
 
  csinfo->number   = mysql->charset->number;
888
 
  csinfo->state    = mysql->charset->state;
889
 
  csinfo->csname   = mysql->charset->csname;
890
 
  csinfo->name     = mysql->charset->name;
891
 
  csinfo->comment  = mysql->charset->comment;
892
 
  csinfo->mbminlen = mysql->charset->mbminlen;
893
 
  csinfo->mbmaxlen = mysql->charset->mbmaxlen;
894
 
 
895
 
  if (mysql->options.charset_dir)
896
 
    csinfo->dir = mysql->options.charset_dir;
 
842
/* DRIZZLE */
 
843
 
 
844
unsigned int STDCALL drizzle_field_count(DRIZZLE *drizzle)
 
845
{
 
846
  return drizzle->field_count;
 
847
}
 
848
 
 
849
uint64_t STDCALL drizzle_affected_rows(DRIZZLE *drizzle)
 
850
{
 
851
  return drizzle->affected_rows;
 
852
}
 
853
 
 
854
uint64_t STDCALL drizzle_insert_id(DRIZZLE *drizzle)
 
855
{
 
856
  return drizzle->insert_id;
 
857
}
 
858
 
 
859
const char *STDCALL drizzle_sqlstate(DRIZZLE *drizzle)
 
860
{
 
861
  return drizzle ? drizzle->net.sqlstate : cant_connect_sqlstate;
 
862
}
 
863
 
 
864
uint32_t STDCALL drizzle_warning_count(DRIZZLE *drizzle)
 
865
{
 
866
  return drizzle->warning_count;
 
867
}
 
868
 
 
869
const char *STDCALL drizzle_info(DRIZZLE *drizzle)
 
870
{
 
871
  return drizzle->info;
 
872
}
 
873
 
 
874
uint32_t STDCALL drizzle_thread_id(DRIZZLE *drizzle)
 
875
{
 
876
  return (drizzle)->thread_id;
 
877
}
 
878
 
 
879
const char * STDCALL drizzle_character_set_name(DRIZZLE *drizzle)
 
880
{
 
881
  return drizzle->charset->csname;
 
882
}
 
883
 
 
884
void STDCALL drizzle_get_character_set_info(DRIZZLE *drizzle, MY_CHARSET_INFO *csinfo)
 
885
{
 
886
  csinfo->number   = drizzle->charset->number;
 
887
  csinfo->state    = drizzle->charset->state;
 
888
  csinfo->csname   = drizzle->charset->csname;
 
889
  csinfo->name     = drizzle->charset->name;
 
890
  csinfo->comment  = drizzle->charset->comment;
 
891
  csinfo->mbminlen = drizzle->charset->mbminlen;
 
892
  csinfo->mbmaxlen = drizzle->charset->mbmaxlen;
 
893
 
 
894
  if (drizzle->options.charset_dir)
 
895
    csinfo->dir = drizzle->options.charset_dir;
897
896
  else
898
897
    csinfo->dir = charsets_dir;
899
898
}
900
899
 
901
 
uint STDCALL mysql_thread_safe(void)
 
900
uint STDCALL drizzle_thread_safe(void)
902
901
{
903
902
  return 1;
904
903
}
905
904
 
906
905
 
907
 
my_bool STDCALL mysql_embedded(void)
 
906
my_bool STDCALL drizzle_embedded(void)
908
907
{
909
908
#ifdef EMBEDDED_LIBRARY
910
909
  return 1;
933
932
/*
934
933
  This function is used to create HEX string that you
935
934
  can use in a SQL statement in of the either ways:
936
 
    INSERT INTO blob_column VALUES (0xAABBCC);  (any MySQL version)
 
935
    INSERT INTO blob_column VALUES (0xAABBCC);  (any DRIZZLE version)
937
936
    INSERT INTO blob_column VALUES (X'AABBCC'); (4.1 and higher)
938
937
  
939
938
  The string in "from" is encoded to a HEX string.
942
941
  The string pointed to by "from" must be "length" bytes long.
943
942
  You must allocate the "to" buffer to be at least length*2+1 bytes long.
944
943
  Each character needs two bytes, and you need room for the terminating
945
 
  null byte. When mysql_hex_string() returns, the contents of "to" will
 
944
  null byte. When drizzle_hex_string() returns, the contents of "to" will
946
945
  be a null-terminated string. The return value is the length of the
947
946
  encoded string, not including the terminating null character.
948
947
 
951
950
*/
952
951
 
953
952
uint32_t STDCALL
954
 
mysql_hex_string(char *to, const char *from, uint32_t length)
 
953
drizzle_hex_string(char *to, const char *from, uint32_t length)
955
954
{
956
955
  char *to0= to;
957
956
  const char *end;
972
971
*/
973
972
 
974
973
uint32_t STDCALL
975
 
mysql_escape_string(char *to,const char *from, uint32_t length)
 
974
drizzle_escape_string(char *to,const char *from, uint32_t length)
976
975
{
977
976
  return escape_string_for_mysql(default_charset_info, to, 0, from, length);
978
977
}
979
978
 
980
979
uint32_t STDCALL
981
 
mysql_real_escape_string(MYSQL *mysql, char *to,const char *from,
982
 
                         uint32_t length)
 
980
drizzle_real_escape_string(DRIZZLE *drizzle, char *to,const char *from,
 
981
       uint32_t length)
983
982
{
984
 
  if (mysql->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)
985
 
    return escape_quotes_for_mysql(mysql->charset, to, 0, from, length);
986
 
  return escape_string_for_mysql(mysql->charset, to, 0, from, length);
 
983
  if (drizzle->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)
 
984
    return escape_quotes_for_mysql(drizzle->charset, to, 0, from, length);
 
985
  return escape_string_for_mysql(drizzle->charset, to, 0, from, length);
987
986
}
988
987
 
989
988
void STDCALL
990
 
myodbc_remove_escape(MYSQL *mysql,char *name)
 
989
myodbc_remove_escape(DRIZZLE *drizzle,char *name)
991
990
{
992
991
  char *to;
993
992
#ifdef USE_MB
994
 
  my_bool use_mb_flag=use_mb(mysql->charset);
 
993
  my_bool use_mb_flag=use_mb(drizzle->charset);
995
994
  char *end=NULL;
996
995
  if (use_mb_flag)
997
996
    for (end=name; *end ; end++) ;
1001
1000
  {
1002
1001
#ifdef USE_MB
1003
1002
    int l;
1004
 
    if (use_mb_flag && (l = my_ismbchar( mysql->charset, name , end ) ) )
 
1003
    if (use_mb_flag && (l = my_ismbchar( drizzle->charset, name , end ) ) )
1005
1004
    {
1006
1005
      while (l--)
1007
 
        *to++ = *name++;
 
1006
  *to++ = *name++;
1008
1007
      name--;
1009
1008
      continue;
1010
1009
    }
1016
1015
  *to=0;
1017
1016
}
1018
1017
 
1019
 
int cli_unbuffered_fetch(MYSQL *mysql, char **row)
 
1018
int cli_unbuffered_fetch(DRIZZLE *drizzle, char **row)
1020
1019
{
1021
 
  if (packet_error == cli_safe_read(mysql))
 
1020
  if (packet_error == cli_safe_read(drizzle))
1022
1021
    return 1;
1023
1022
 
1024
 
  *row= ((mysql->net.read_pos[0] == 254) ? NULL :
1025
 
         (char*) (mysql->net.read_pos+1));
 
1023
  *row= ((drizzle->net.read_pos[0] == 254) ? NULL :
 
1024
   (char*) (drizzle->net.read_pos+1));
1026
1025
  return 0;
1027
1026
}
1028
1027
 
1034
1033
  Commit the current transaction
1035
1034
*/
1036
1035
 
1037
 
my_bool STDCALL mysql_commit(MYSQL * mysql)
 
1036
my_bool STDCALL drizzle_commit(DRIZZLE *drizzle)
1038
1037
{
1039
 
  return((my_bool) mysql_real_query(mysql, "commit", 6));
 
1038
  return((my_bool) drizzle_real_query(drizzle, "commit", 6));
1040
1039
}
1041
1040
 
1042
1041
/*
1043
1042
  Rollback the current transaction
1044
1043
*/
1045
1044
 
1046
 
my_bool STDCALL mysql_rollback(MYSQL * mysql)
 
1045
my_bool STDCALL drizzle_rollback(DRIZZLE *drizzle)
1047
1046
{
1048
 
  return((my_bool) mysql_real_query(mysql, "rollback", 8));
 
1047
  return((my_bool) drizzle_real_query(drizzle, "rollback", 8));
1049
1048
}
1050
1049
 
1051
1050
 
1053
1052
  Set autocommit to either true or false
1054
1053
*/
1055
1054
 
1056
 
my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode)
 
1055
my_bool STDCALL drizzle_autocommit(DRIZZLE *drizzle, my_bool auto_mode)
1057
1056
{
1058
 
  return((my_bool) mysql_real_query(mysql, auto_mode ?
 
1057
  return((my_bool) drizzle_real_query(drizzle, auto_mode ?
1059
1058
                                         "set autocommit=1":"set autocommit=0",
1060
1059
                                         16));
1061
1060
}
1067
1066
 
1068
1067
/*
1069
1068
  Returns true/false to indicate whether any more query results exist
1070
 
  to be read using mysql_next_result()
 
1069
  to be read using drizzle_next_result()
1071
1070
*/
1072
1071
 
1073
 
my_bool STDCALL mysql_more_results(MYSQL *mysql)
 
1072
my_bool STDCALL drizzle_more_results(DRIZZLE *drizzle)
1074
1073
{
1075
1074
  my_bool res;
1076
1075
 
1077
 
  res= ((mysql->server_status & SERVER_MORE_RESULTS_EXISTS) ? 1: 0);
 
1076
  res= ((drizzle->server_status & SERVER_MORE_RESULTS_EXISTS) ? 1: 0);
1078
1077
  return(res);
1079
1078
}
1080
1079
 
1082
1081
/*
1083
1082
  Reads and returns the next query results
1084
1083
*/
1085
 
int STDCALL mysql_next_result(MYSQL *mysql)
 
1084
int STDCALL drizzle_next_result(DRIZZLE *drizzle)
1086
1085
{
1087
 
  if (mysql->status != MYSQL_STATUS_READY)
 
1086
  if (drizzle->status != DRIZZLE_STATUS_READY)
1088
1087
  {
1089
 
    set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
 
1088
    set_drizzle_error(drizzle, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
1090
1089
    return(1);
1091
1090
  }
1092
1091
 
1093
 
  net_clear_error(&mysql->net);
1094
 
  mysql->affected_rows= ~(uint64_t) 0;
1095
 
 
1096
 
  if (mysql->server_status & SERVER_MORE_RESULTS_EXISTS)
1097
 
    return((*mysql->methods->next_result)(mysql));
1098
 
 
1099
 
  return(-1);                           /* No more results */
1100
 
}
1101
 
 
1102
 
 
1103
 
MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql)
1104
 
{
1105
 
  return (*mysql->methods->use_result)(mysql);
1106
 
}
1107
 
 
1108
 
my_bool STDCALL mysql_read_query_result(MYSQL *mysql)
1109
 
{
1110
 
  return (*mysql->methods->read_query_result)(mysql);
 
1092
  net_clear_error(&drizzle->net);
 
1093
  drizzle->affected_rows= ~(uint64_t) 0;
 
1094
 
 
1095
  if (drizzle->server_status & SERVER_MORE_RESULTS_EXISTS)
 
1096
    return((*drizzle->methods->next_result)(drizzle));
 
1097
 
 
1098
  return(-1);        /* No more results */
 
1099
}
 
1100
 
 
1101
 
 
1102
DRIZZLE_RES * STDCALL drizzle_use_result(DRIZZLE *drizzle)
 
1103
{
 
1104
  return (*drizzle->methods->use_result)(drizzle);
 
1105
}
 
1106
 
 
1107
my_bool STDCALL drizzle_read_query_result(DRIZZLE *drizzle)
 
1108
{
 
1109
  return (*drizzle->methods->read_query_result)(drizzle);
1111
1110
}
1112
1111