407
406
cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
408
const uchar *header, ulong header_length,
409
const uchar *arg, ulong arg_length, my_bool skip_check)
407
const unsigned char *header, uint32_t header_length,
408
const unsigned char *arg, uint32_t arg_length, bool skip_check)
411
410
NET *net= &mysql->net;
412
411
my_bool result= 1;
413
412
init_sigpipe_variables
414
my_bool stmt_skip= FALSE;
413
my_bool stmt_skip= false;
415
414
DBUG_ENTER("cli_advanced_command");
417
416
/* Don't give sigpipe errors if the client doesn't want them */
553
552
(*mysql->methods->flush_use_result)(mysql);
554
553
mysql->status=MYSQL_STATUS_READY;
555
554
if (mysql->unbuffered_fetch_owner)
556
*mysql->unbuffered_fetch_owner= TRUE;
555
*mysql->unbuffered_fetch_owner= true;
559
558
free_rows(result->data);
758
757
options->client_flag|= CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS;
760
759
case 30: /* secure-auth */
761
options->secure_auth= TRUE;
760
options->secure_auth= true;
763
762
case 31: /* report-data-truncation */
764
763
options->report_data_truncation= opt_arg ? test(atoi(opt_arg)) : 1;
780
779
else the lengths are calculated from the offset between pointers.
781
780
**************************************************************************/
783
static void cli_fetch_lengths(ulong *to, MYSQL_ROW column,
784
unsigned int field_count)
782
static void cli_fetch_lengths(uint32_t *to, MYSQL_ROW column, uint32_t field_count)
784
uint32_t *prev_length;
814
812
MYSQL_FIELD *field,*result;
815
ulong lengths[9]; /* Max of fields */
813
uint32_t lengths[9]; /* Max of fields */
816
814
DBUG_ENTER("unpack_fields");
818
816
field= result= (MYSQL_FIELD*) alloc_root(alloc,
1020
read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths)
1018
read_one_row(MYSQL *mysql, uint32_t fields, MYSQL_ROW row, uint32_t *lengths)
1023
1021
ulong pkt_len,len;
1106
1104
mysql->options.methods_to_use= MYSQL_OPT_GUESS_CONNECTION;
1107
mysql->options.report_data_truncation= TRUE; /* default */
1105
mysql->options.report_data_truncation= true; /* default */
1110
1108
By default we don't reconnect because it could silently corrupt data (after
1135
1133
#define strdup_if_not_null(A) (A) == 0 ? 0 : my_strdup((A),MYF(MY_WME))
1138
mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
1139
const char *key __attribute__((unused)),
1140
const char *cert __attribute__((unused)),
1141
const char *ca __attribute__((unused)),
1142
const char *capath __attribute__((unused)),
1143
const char *cipher __attribute__((unused)))
1145
DBUG_ENTER("mysql_ssl_set");
1151
Free strings in the SSL structure and clear 'use_ssl' flag.
1152
NB! Errors are not reported until you do mysql_real_connect.
1156
Return the SSL cipher (if any) used for current
1157
connection to the server.
1160
mysql_get_ssl_cipher()
1161
mysql pointer to the mysql connection
1165
const char * STDCALL
1166
mysql_get_ssl_cipher(MYSQL *mysql __attribute__((unused)))
1168
DBUG_ENTER("mysql_get_ssl_cipher");
1174
Check the server's (subject) Common Name against the
1175
hostname we connected to
1178
ssl_verify_server_cert()
1179
vio pointer to a SSL connected vio
1180
server_hostname name of the server that we connected to
1184
1 Failed to validate server
1190
1136
Note that the mysql argument must be initialized with mysql_init()
1191
1137
before calling mysql_real_connect !
1194
static my_bool cli_read_query_result(MYSQL *mysql);
1140
static bool cli_read_query_result(MYSQL *mysql);
1195
1141
static MYSQL_RES *cli_use_result(MYSQL *mysql);
1197
1143
static MYSQL_METHODS client_methods=
1286
1232
MYSQL * STDCALL
1287
1233
CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
1288
1234
const char *passwd, const char *db,
1289
uint port, const char *unix_socket,ulong client_flag)
1235
uint32_t port, const char *unix_socket, uint32_t client_flag)
1291
1237
char buff[NAME_LEN+USERNAME_LENGTH+100];
1292
1238
char *end,*host_info=NULL;
1239
uint32_t pkt_length;
1294
1240
NET *net= &mysql->net;
1295
1241
struct sockaddr_un UNIXaddr;
1296
1242
init_sigpipe_variables
1526
1472
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
1529
vio_keepalive(net->vio,TRUE);
1475
vio_keepalive(net->vio,true);
1531
1477
/* If user set read_timeout, let it override the default */
1532
1478
if (mysql->options.read_timeout)
1689
1635
end= strend(end) + 1;
1692
if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION)
1694
1639
*end++= SCRAMBLE_LENGTH;
1695
1640
scramble(end, mysql->scramble, passwd);
1696
1641
end+= SCRAMBLE_LENGTH;
1700
scramble_323(end, mysql->scramble, passwd);
1701
end+= SCRAMBLE_LENGTH_323 + 1;
1705
1645
*end++= '\0'; /* empty password */
1739
if (pkt_length == 1 && net->read_pos[0] == 254 &&
1740
mysql->server_capabilities & CLIENT_SECURE_CONNECTION)
1743
By sending this very specific reply server asks us to send scrambled
1744
password in old format.
1746
scramble_323(buff, mysql->scramble, passwd);
1747
if (my_net_write(net, (uchar*) buff, SCRAMBLE_LENGTH_323 + 1) ||
1750
set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
1751
ER(CR_SERVER_LOST_EXTENDED),
1752
"sending password information",
1756
/* Read what server thinks about out new auth message report */
1757
if (cli_safe_read(mysql) == packet_error)
1759
if (mysql->net.last_errno == CR_SERVER_LOST)
1760
set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
1761
ER(CR_SERVER_LOST_EXTENDED),
1762
"reading final connect information",
1768
1679
if (client_flag & CLIENT_COMPRESS) /* We will use compression */
1769
1680
net->compress=1;
2051
1962
finish processing it.
2055
mysql_send_query(MYSQL* mysql, const char* query, ulong length)
1966
mysql_send_query(MYSQL* mysql, const char* query, uint32_t length)
2057
1968
DBUG_ENTER("mysql_send_query");
2058
1969
DBUG_RETURN(simple_command(mysql, COM_QUERY, (uchar*) query, length, 1));
2063
mysql_real_query(MYSQL *mysql, const char *query, ulong length)
1974
mysql_real_query(MYSQL *mysql, const char *query, uint32_t length)
2065
1976
DBUG_ENTER("mysql_real_query");
2066
DBUG_PRINT("enter",("handle: 0x%lx", (long) mysql));
1977
DBUG_PRINT("enter",("handle: 0x%lx", (int32_t) mysql));
2067
1978
DBUG_PRINT("query",("Query = '%-.4096s'",query));
2069
1980
if (mysql_send_query(mysql,query,length))
2099
2010
DBUG_RETURN(0);
2101
2012
result->methods= mysql->methods;
2102
result->eof=1; /* Marker for buffered */
2103
result->lengths=(ulong*) (result+1);
2013
result->eof= 1; /* Marker for buffered */
2014
result->lengths= (uint32_t*) (result+1);
2104
2015
if (!(result->data=
2105
2016
(*mysql->methods->read_rows)(mysql,mysql->fields,mysql->field_count)))
2147
2058
sizeof(ulong)*mysql->field_count,
2148
2059
MYF(MY_WME | MY_ZEROFILL))))
2149
2060
DBUG_RETURN(0);
2150
result->lengths=(ulong*) (result+1);
2061
result->lengths=(uint32_t*) (result+1);
2151
2062
result->methods= mysql->methods;
2152
2063
if (!(result->row=(MYSQL_ROW)
2153
2064
my_malloc(sizeof(result->row[0])*(mysql->field_count+1), MYF(MY_WME))))