~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/libdrizzle.c

MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
#undef net_buffer_length
64
64
#undef max_allowed_packet
65
65
 
66
 
ulong           net_buffer_length=8192;
67
 
ulong           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
123
123
          if builder specifically requested a default port, use that
124
124
          (even if it coincides with our factory default).
125
125
          only if they didn't do we check /etc/services (and, failing
126
 
          on that, fall back to the factory default of 3306).
 
126
          on that, fall back to the factory default of 4427).
127
127
          either default can be overridden by the environment variable
128
128
          MYSQL_TCP_PORT, which in turn can be overridden with command
129
129
          line options.
323
323
 
324
324
int cli_read_change_user_result(MYSQL *mysql, char *buff, const char *passwd)
325
325
{
326
 
  NET *net= &mysql->net;
 
326
  (void)buff;
 
327
  (void)passwd;
327
328
  ulong pkt_length;
328
329
 
329
330
  pkt_length= cli_safe_read(mysql);
331
332
  if (pkt_length == packet_error)
332
333
    return 1;
333
334
 
334
 
  if (pkt_length == 1 && net->read_pos[0] == 254 &&
335
 
      mysql->server_capabilities & CLIENT_SECURE_CONNECTION)
336
 
  {
337
 
    /*
338
 
      By sending this very specific reply server asks us to send scrambled
339
 
      password in old format. The reply contains scramble_323.
340
 
    */
341
 
    scramble_323(buff, mysql->scramble, passwd);
342
 
    if (my_net_write(net, (uchar*) buff, SCRAMBLE_LENGTH_323 + 1) ||
343
 
        net_flush(net))
344
 
    {
345
 
      set_mysql_error(mysql, CR_SERVER_LOST, unknown_sqlstate);
346
 
      return 1;
347
 
    }
348
 
    /* Read what server thinks about out new auth message report */
349
 
    if (cli_safe_read(mysql) == packet_error)
350
 
      return 1;
351
 
  }
352
335
  return 0;
353
336
}
354
337
 
367
350
  if (mysql_init_character_set(mysql))
368
351
  {
369
352
    mysql->charset= saved_cs;
370
 
    DBUG_RETURN(TRUE);
 
353
    DBUG_RETURN(true);
371
354
  }
372
355
 
373
356
  /* Use an empty string instead of NULL. */
383
366
  /* write scrambled password according to server capabilities */
384
367
  if (passwd[0])
385
368
  {
386
 
    if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION)
387
369
    {
388
370
      *end++= SCRAMBLE_LENGTH;
389
371
      scramble(end, mysql->scramble, passwd);
390
372
      end+= SCRAMBLE_LENGTH;
391
373
    }
392
 
    else
393
 
    {
394
 
      scramble_323(end, mysql->scramble, passwd);
395
 
      end+= SCRAMBLE_LENGTH_323 + 1;
396
 
    }
397
374
  }
398
375
  else
399
376
    *end++= '\0';                               /* empty password */
409
386
  }
410
387
 
411
388
  /* Write authentication package */
412
 
  simple_command(mysql,COM_CHANGE_USER, (uchar*) buff, (ulong) (end-buff), 1);
 
389
  (void)simple_command(mysql,COM_CHANGE_USER, (uchar*) buff, (ulong) (end-buff), 1);
413
390
 
414
391
  rc= (*mysql->methods->read_change_user_result)(mysql, buff, passwd);
415
392
 
744
721
**************************************************************************/
745
722
 
746
723
void STDCALL
747
 
mysql_data_seek(MYSQL_RES *result, my_ulonglong row)
 
724
mysql_data_seek(MYSQL_RES *result, uint64_t row)
748
725
{
749
726
  MYSQL_ROWS    *tmp=0;
750
727
  DBUG_PRINT("info",("mysql_data_seek(%ld)",(long) row));
931
908
}
932
909
 
933
910
 
934
 
int STDCALL
935
 
mysql_kill(MYSQL *mysql,ulong pid)
 
911
int32_t STDCALL
 
912
mysql_kill(MYSQL *mysql, uint32_t pid)
936
913
{
937
914
  uchar buff[4];
938
915
  DBUG_ENTER("mysql_kill");
1019
996
  return (char*) MYSQL_SERVER_VERSION;
1020
997
}
1021
998
 
1022
 
ulong STDCALL mysql_get_client_version(void)
 
999
uint32_t STDCALL mysql_get_client_version(void)
1023
1000
{
1024
1001
  return MYSQL_VERSION_ID;
1025
1002
}
1056
1033
  return mysql->field_count;
1057
1034
}
1058
1035
 
1059
 
my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql)
 
1036
uint64_t STDCALL mysql_affected_rows(MYSQL *mysql)
1060
1037
{
1061
1038
  return mysql->affected_rows;
1062
1039
}
1063
1040
 
1064
 
my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql)
 
1041
uint64_t STDCALL mysql_insert_id(MYSQL *mysql)
1065
1042
{
1066
1043
  return mysql->insert_id;
1067
1044
}
1071
1048
  return mysql ? mysql->net.sqlstate : cant_connect_sqlstate;
1072
1049
}
1073
1050
 
1074
 
uint STDCALL mysql_warning_count(MYSQL *mysql)
 
1051
uint32_t STDCALL mysql_warning_count(MYSQL *mysql)
1075
1052
{
1076
1053
  return mysql->warning_count;
1077
1054
}
1081
1058
  return mysql->info;
1082
1059
}
1083
1060
 
1084
 
ulong STDCALL mysql_thread_id(MYSQL *mysql)
 
1061
uint32_t STDCALL mysql_thread_id(MYSQL *mysql)
1085
1062
{
1086
1063
  return (mysql)->thread_id;
1087
1064
}
1159
1136
  trailing '. The caller must supply whichever of those is desired.
1160
1137
*/
1161
1138
 
1162
 
ulong STDCALL
1163
 
mysql_hex_string(char *to, const char *from, ulong length)
 
1139
uint32_t STDCALL
 
1140
mysql_hex_string(char *to, const char *from, uint32_t length)
1164
1141
{
1165
1142
  char *to0= to;
1166
1143
  const char *end;
1171
1148
    *to++= _dig_vec_upper[((unsigned char) *from) & 0x0F];
1172
1149
  }
1173
1150
  *to= '\0';
1174
 
  return (ulong) (to-to0);
 
1151
  return (uint32_t) (to-to0);
1175
1152
}
1176
1153
 
1177
1154
/*
1180
1157
  Returns the length of the to string
1181
1158
*/
1182
1159
 
1183
 
ulong STDCALL
1184
 
mysql_escape_string(char *to,const char *from,ulong length)
 
1160
uint32_t STDCALL
 
1161
mysql_escape_string(char *to,const char *from, uint32_t length)
1185
1162
{
1186
1163
  return escape_string_for_mysql(default_charset_info, to, 0, from, length);
1187
1164
}
1188
1165
 
1189
 
ulong STDCALL
 
1166
uint32_t STDCALL
1190
1167
mysql_real_escape_string(MYSQL *mysql, char *to,const char *from,
1191
 
                         ulong length)
 
1168
                         uint32_t length)
1192
1169
{
1193
1170
  if (mysql->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)
1194
1171
    return escape_quotes_for_mysql(mysql->charset, to, 0, from, length);
1201
1178
  char *to;
1202
1179
#ifdef USE_MB
1203
1180
  my_bool use_mb_flag=use_mb(mysql->charset);
1204
 
  char *end;
 
1181
  char *end=NULL;
1205
1182
  if (use_mb_flag)
1206
1183
    for (end=name; *end ; end++) ;
1207
1184
#endif
1309
1286
  }
1310
1287
 
1311
1288
  net_clear_error(&mysql->net);
1312
 
  mysql->affected_rows= ~(my_ulonglong) 0;
 
1289
  mysql->affected_rows= ~(uint64_t) 0;
1313
1290
 
1314
1291
  if (mysql->server_status & SERVER_MORE_RESULTS_EXISTS)
1315
1292
    DBUG_RETURN((*mysql->methods->next_result)(mysql));