#include <my_global.h>#include <my_sys.h>#include <my_time.h>#include <mysys_err.h>#include <m_string.h>#include <m_ctype.h>#include "mysql.h"#include "mysql_version.h"#include "mysqld_error.h"#include "errmsg.h"#include <violite.h>#include <sys/stat.h>#include <signal.h>#include <time.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <netdb.h>#include <sql_common.h>#include "client_settings.h"#include <errno.h>Include dependency graph for libmysql.c:

Go to the source code of this file.
| #define BIND_RESULT_DONE 1 |
| #define DEFAULT_PREFETCH_ROWS (ulong) 1 |
Definition at line 1702 of file libmysql.c.
Referenced by mysql_stmt_attr_set(), and mysql_stmt_init().
| #define INADDR_NONE -1 |
Definition at line 59 of file libmysql.c.
| #define IS_TRUNCATED | ( | value, | |||
| is_unsigned, | |||||
| min, | |||||
| max, | |||||
| umax | ) |
Value:
((is_unsigned) ? (((value) > (umax) || (value) < 0) ? 1 : 0) : \ (((value) > (max) || (value) < (min)) ? 1 : 0))
Definition at line 1757 of file libmysql.c.
Referenced by fetch_long_with_conversion(), and fetch_string_with_conversion().
| #define MAX_DATE_REP_LENGTH 5 |
| #define MAX_DATETIME_REP_LENGTH 12 |
Definition at line 1751 of file libmysql.c.
Referenced by mysql_stmt_bind_param(), and net_store_datetime().
| #define MAX_DOUBLE_STRING_REP_LENGTH 331 |
Definition at line 1753 of file libmysql.c.
Referenced by fetch_float_with_conversion(), and setup_one_fetch_function().
| #define MAX_LONG_DATA_LENGTH 8192 |
Definition at line 91 of file libmysql.c.
| #define MAX_TIME_REP_LENGTH 13 |
Definition at line 1745 of file libmysql.c.
Referenced by mysql_stmt_bind_param(), and store_param_time().
| #define NOT_FIXED_DEC 31 |
| #define REPORT_DATA_TRUNCATION 2 |
Definition at line 1767 of file libmysql.c.
Referenced by mysql_stmt_bind_result(), and stmt_fetch_row().
| #define RESET_LONG_DATA 2 |
Definition at line 1728 of file libmysql.c.
Referenced by mysql_stmt_free_result(), mysql_stmt_prepare(), mysql_stmt_reset(), and reset_stmt_handle().
| #define RESET_SERVER_SIDE 1 |
Definition at line 1727 of file libmysql.c.
Referenced by mysql_stmt_reset(), and reset_stmt_handle().
| #define RESET_STORE_RESULT 4 |
Definition at line 1729 of file libmysql.c.
Referenced by mysql_stmt_execute(), mysql_stmt_free_result(), mysql_stmt_prepare(), and reset_stmt_handle().
| #define SOCKET_ERROR -1 |
Definition at line 84 of file libmysql.c.
Definition at line 92 of file libmysql.c.
| typedef struct st_default_local_infile default_local_infile_data |
| static unsigned int alloc_stmt_fields | ( | MYSQL_STMT * | stmt | ) | [static] |
Definition at line 2108 of file libmysql.c.
References alloc_root(), st_mysql_stmt::bind, st_mysql_field::charsetnr, st_mysql_field::db, st_mysql_field::decimals, st_mysql_field::def, st_mysql::field_count, st_mysql_stmt::field_count, st_mysql::fields, st_mysql_stmt::fields, st_mysql_field::flags, st_mysql::last_used_con, st_mysql_field::length, st_mysql_field::max_length, st_mysql_stmt::mem_root, st_mysql_stmt::mysql, mysql, st_mysql_field::name, st_mysql_field::org_name, st_mysql_field::org_table, strdup_root(), st_mysql_field::table, and st_mysql_field::type.
Referenced by mysql_stmt_execute().
02109 { 02110 MYSQL_FIELD *fields, *field, *end; 02111 MEM_ROOT *alloc= &stmt->mem_root; 02112 MYSQL *mysql= stmt->mysql->last_used_con; 02113 02114 stmt->field_count= mysql->field_count; 02115 02116 /* 02117 Get the field information for non-select statements 02118 like SHOW and DESCRIBE commands 02119 */ 02120 if (!(stmt->fields= (MYSQL_FIELD *) alloc_root(alloc, 02121 sizeof(MYSQL_FIELD) * 02122 stmt->field_count)) || 02123 !(stmt->bind= (MYSQL_BIND *) alloc_root(alloc, 02124 sizeof(MYSQL_BIND) * 02125 stmt->field_count))) 02126 return 0; 02127 02128 for (fields= mysql->fields, end= fields+stmt->field_count, 02129 field= stmt->fields; 02130 field && fields < end; fields++, field++) 02131 { 02132 field->db = strdup_root(alloc,fields->db); 02133 field->table = strdup_root(alloc,fields->table); 02134 field->org_table= strdup_root(alloc,fields->org_table); 02135 field->name = strdup_root(alloc,fields->name); 02136 field->org_name = strdup_root(alloc,fields->org_name); 02137 field->charsetnr= fields->charsetnr; 02138 field->length = fields->length; 02139 field->type = fields->type; 02140 field->flags = fields->flags; 02141 field->decimals = fields->decimals; 02142 field->def = fields->def ? strdup_root(alloc,fields->def): 0; 02143 field->max_length= 0; 02144 } 02145 return stmt->field_count; 02146 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void append_wild | ( | char * | to, | |
| char * | end, | |||
| const char * | wild | |||
| ) | [static] |
Definition at line 240 of file libmysql.c.
References strmov().
Referenced by mysql_list_dbs(), and mysql_list_tables().
00241 { 00242 end-=5; /* Some extra */ 00243 if (wild && wild[0]) 00244 { 00245 to=strmov(to," like '"); 00246 while (*wild && to < end) 00247 { 00248 if (*wild == '\\' || *wild == '\'') 00249 *to++='\\'; 00250 *to++= *wild++; 00251 } 00252 if (*wild) /* Too small buffer */ 00253 *to++='%'; /* Nicer this way */ 00254 to[0]='\''; 00255 to[1]=0; 00256 } 00257 }
Here is the call graph for this function:

Here is the caller graph for this function:

| MYSQL_FIELD* cli_list_fields | ( | MYSQL * | mysql | ) |
Definition at line 1197 of file libmysql.c.
01198 { 01199 MYSQL_DATA *query; 01200 if (!(query= cli_read_rows(mysql,(MYSQL_FIELD*) 0, 01201 protocol_41(mysql) ? 8 : 6))) 01202 return NULL; 01203 01204 mysql->field_count= (uint) query->rows; 01205 return unpack_fields(query,&mysql->field_alloc, 01206 mysql->field_count, 1, mysql->server_capabilities); 01207 }
| int cli_read_binary_rows | ( | MYSQL_STMT * | stmt | ) |
Definition at line 4628 of file libmysql.c.
04629 { 04630 ulong pkt_len; 04631 uchar *cp; 04632 MYSQL *mysql= stmt->mysql; 04633 MYSQL_DATA *result= &stmt->result; 04634 MYSQL_ROWS *cur, **prev_ptr= &result->data; 04635 NET *net = &mysql->net; 04636 DBUG_ENTER("cli_read_binary_rows"); 04637 04638 mysql= mysql->last_used_con; 04639 04640 while ((pkt_len= cli_safe_read(mysql)) != packet_error) 04641 { 04642 cp= net->read_pos; 04643 if (cp[0] != 254 || pkt_len >= 8) 04644 { 04645 if (!(cur= (MYSQL_ROWS*) alloc_root(&result->alloc, 04646 sizeof(MYSQL_ROWS) + pkt_len - 1))) 04647 { 04648 set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate); 04649 goto err; 04650 } 04651 cur->data= (MYSQL_ROW) (cur+1); 04652 *prev_ptr= cur; 04653 prev_ptr= &cur->next; 04654 memcpy((char *) cur->data, (char *) cp+1, pkt_len-1); 04655 cur->length= pkt_len; /* To allow us to do sanity checks */ 04656 result->rows++; 04657 } 04658 else 04659 { 04660 /* end of data */ 04661 *prev_ptr= 0; 04662 mysql->warning_count= uint2korr(cp+1); 04663 mysql->server_status= uint2korr(cp+3); 04664 DBUG_PRINT("info",("status: %u warning_count: %u", 04665 mysql->server_status, mysql->warning_count)); 04666 DBUG_RETURN(0); 04667 } 04668 } 04669 set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); 04670 04671 err: 04672 DBUG_RETURN(1); 04673 }
| int cli_read_change_user_result | ( | MYSQL * | mysql, | |
| char * | buff, | |||
| const char * | passwd | |||
| ) |
Definition at line 637 of file libmysql.c.
00638 { 00639 NET *net= &mysql->net; 00640 ulong pkt_length; 00641 00642 pkt_length= cli_safe_read(mysql); 00643 00644 if (pkt_length == packet_error) 00645 return 1; 00646 00647 if (pkt_length == 1 && net->read_pos[0] == 254 && 00648 mysql->server_capabilities & CLIENT_SECURE_CONNECTION) 00649 { 00650 /* 00651 By sending this very specific reply server asks us to send scrambled 00652 password in old format. The reply contains scramble_323. 00653 */ 00654 scramble_323(buff, mysql->scramble, passwd); 00655 if (my_net_write(net, buff, SCRAMBLE_LENGTH_323 + 1) || net_flush(net)) 00656 { 00657 net->last_errno= CR_SERVER_LOST; 00658 strmov(net->sqlstate, unknown_sqlstate); 00659 strmov(net->last_error,ER(net->last_errno)); 00660 return 1; 00661 } 00662 /* Read what server thinks about out new auth message report */ 00663 if (cli_safe_read(mysql) == packet_error) 00664 return 1; 00665 } 00666 return 0; 00667 }
| my_bool cli_read_prepare_result | ( | MYSQL * | mysql, | |
| MYSQL_STMT * | stmt | |||
| ) |
Definition at line 1875 of file libmysql.c.
01876 { 01877 uchar *pos; 01878 uint field_count, param_count; 01879 ulong packet_length; 01880 MYSQL_DATA *fields_data; 01881 DBUG_ENTER("cli_read_prepare_result"); 01882 01883 mysql= mysql->last_used_con; 01884 if ((packet_length= cli_safe_read(mysql)) == packet_error) 01885 DBUG_RETURN(1); 01886 mysql->warning_count= 0; 01887 01888 pos= (uchar*) mysql->net.read_pos; 01889 stmt->stmt_id= uint4korr(pos+1); pos+= 5; 01890 /* Number of columns in result set */ 01891 field_count= uint2korr(pos); pos+= 2; 01892 /* Number of placeholders in the statement */ 01893 param_count= uint2korr(pos); pos+= 2; 01894 if (packet_length >= 12) 01895 mysql->warning_count= uint2korr(pos+1); 01896 01897 if (param_count != 0) 01898 { 01899 MYSQL_DATA *param_data; 01900 01901 /* skip parameters data: we don't support it yet */ 01902 if (!(param_data= (*mysql->methods->read_rows)(mysql, (MYSQL_FIELD*)0, 7))) 01903 DBUG_RETURN(1); 01904 free_rows(param_data); 01905 } 01906 01907 if (field_count != 0) 01908 { 01909 if (!(mysql->server_status & SERVER_STATUS_AUTOCOMMIT)) 01910 mysql->server_status|= SERVER_STATUS_IN_TRANS; 01911 01912 if (!(fields_data= (*mysql->methods->read_rows)(mysql,(MYSQL_FIELD*)0,7))) 01913 DBUG_RETURN(1); 01914 if (!(stmt->fields= unpack_fields(fields_data,&stmt->mem_root, 01915 field_count,0, 01916 mysql->server_capabilities))) 01917 DBUG_RETURN(1); 01918 } 01919 stmt->field_count= field_count; 01920 stmt->param_count= (ulong) param_count; 01921 DBUG_PRINT("exit",("field_count: %u param_count: %u warning_count: %u", 01922 field_count, param_count, (uint) mysql->warning_count)); 01923 01924 DBUG_RETURN(0); 01925 }
| const char* cli_read_statistics | ( | MYSQL * | mysql | ) |
Definition at line 1341 of file libmysql.c.
01342 { 01343 mysql->net.read_pos[mysql->packet_length]=0; /* End of stat string */ 01344 if (!mysql->net.read_pos[0]) 01345 { 01346 strmov(mysql->net.sqlstate, unknown_sqlstate); 01347 mysql->net.last_errno=CR_WRONG_HOST_INFO; 01348 strmov(mysql->net.last_error, ER(mysql->net.last_errno)); 01349 return mysql->net.last_error; 01350 } 01351 return (char*) mysql->net.read_pos; 01352 }
| int cli_stmt_execute | ( | MYSQL_STMT * | stmt | ) |
Definition at line 2496 of file libmysql.c.
02497 { 02498 DBUG_ENTER("cli_stmt_execute"); 02499 02500 if (stmt->param_count) 02501 { 02502 MYSQL *mysql= stmt->mysql; 02503 NET *net= &mysql->net; 02504 MYSQL_BIND *param, *param_end; 02505 char *param_data; 02506 ulong length; 02507 uint null_count; 02508 my_bool result; 02509 02510 if (!stmt->bind_param_done) 02511 { 02512 set_stmt_error(stmt, CR_PARAMS_NOT_BOUND, unknown_sqlstate); 02513 DBUG_RETURN(1); 02514 } 02515 if (mysql->status != MYSQL_STATUS_READY || 02516 mysql->server_status & SERVER_MORE_RESULTS_EXISTS) 02517 { 02518 set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); 02519 DBUG_RETURN(1); 02520 } 02521 02522 net_clear(net); /* Sets net->write_pos */ 02523 /* Reserve place for null-marker bytes */ 02524 null_count= (stmt->param_count+7) /8; 02525 if (my_realloc_str(net, null_count + 1)) 02526 { 02527 set_stmt_error(stmt, net->last_errno, unknown_sqlstate); 02528 DBUG_RETURN(1); 02529 } 02530 bzero((char*) net->write_pos, null_count); 02531 net->write_pos+= null_count; 02532 param_end= stmt->params + stmt->param_count; 02533 02534 /* In case if buffers (type) altered, indicate to server */ 02535 *(net->write_pos)++= (uchar) stmt->send_types_to_server; 02536 if (stmt->send_types_to_server) 02537 { 02538 if (my_realloc_str(net, 2 * stmt->param_count)) 02539 { 02540 set_stmt_error(stmt, net->last_errno, unknown_sqlstate); 02541 DBUG_RETURN(1); 02542 } 02543 /* 02544 Store types of parameters in first in first package 02545 that is sent to the server. 02546 */ 02547 for (param= stmt->params; param < param_end ; param++) 02548 store_param_type((char**) &net->write_pos, param); 02549 } 02550 02551 for (param= stmt->params; param < param_end; param++) 02552 { 02553 /* check if mysql_stmt_send_long_data() was used */ 02554 if (param->long_data_used) 02555 param->long_data_used= 0; /* Clear for next execute call */ 02556 else if (store_param(stmt, param)) 02557 DBUG_RETURN(1); 02558 } 02559 length= (ulong) (net->write_pos - net->buff); 02560 /* TODO: Look into avoding the following memdup */ 02561 if (!(param_data= my_memdup((const char*) net->buff, length, MYF(0)))) 02562 { 02563 set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate); 02564 DBUG_RETURN(1); 02565 } 02566 result= execute(stmt, param_data, length); 02567 stmt->send_types_to_server=0; 02568 my_free(param_data, MYF(MY_WME)); 02569 DBUG_RETURN(result); 02570 } 02571 DBUG_RETURN((int) execute(stmt,0,0)); 02572 }
| int cli_unbuffered_fetch | ( | MYSQL * | mysql, | |
| char ** | row | |||
| ) |
Definition at line 4529 of file libmysql.c.
04530 { 04531 if (packet_error == cli_safe_read(mysql)) 04532 return 1; 04533 04534 *row= ((mysql->net.read_pos[0] == 254) ? NULL : 04535 (char*) (mysql->net.read_pos+1)); 04536 return 0; 04537 }
| static void default_local_infile_end | ( | void * | ptr | ) | [static] |
Definition at line 967 of file libmysql.c.
References data, my_close(), my_free, MY_WME, and MYF.
Referenced by mysql_set_local_infile_default().
00968 { 00969 default_local_infile_data *data= (default_local_infile_data *) ptr; 00970 if (data) /* If not error on open */ 00971 { 00972 if (data->fd >= 0) 00973 my_close(data->fd, MYF(MY_WME)); 00974 my_free(ptr, MYF(MY_WME)); 00975 } 00976 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int default_local_infile_error | ( | void * | ptr, | |
| char * | error_msg, | |||
| uint | error_msg_len | |||
| ) | [static] |
Definition at line 994 of file libmysql.c.
References CR_OUT_OF_MEMORY, data, ER, strmake(), and strmov().
Referenced by mysql_set_local_infile_default().
00995 { 00996 default_local_infile_data *data = (default_local_infile_data *) ptr; 00997 if (data) /* If not error on open */ 00998 { 00999 strmake(error_msg, data->error_msg, error_msg_len); 01000 return data->error_num; 01001 } 01002 /* This can only happen if we got error on malloc of handle */ 01003 strmov(error_msg, ER(CR_OUT_OF_MEMORY)); 01004 return CR_OUT_OF_MEMORY; 01005 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int default_local_infile_init | ( | void ** | ptr, | |
| const char * | filename, | |||
| void *userdata | __attribute__((unused)) | |||
| ) | [static] |
Definition at line 899 of file libmysql.c.
References data, EE, EE_FILENOTFOUND, fn_format(), FN_REFLEN, my_errno, my_malloc(), my_open(), my_snprintf(), MY_UNPACK_FILENAME, and MYF.
Referenced by mysql_set_local_infile_default().
00901 { 00902 default_local_infile_data *data; 00903 char tmp_name[FN_REFLEN]; 00904 00905 if (!(*ptr= data= ((default_local_infile_data *) 00906 my_malloc(sizeof(default_local_infile_data), MYF(0))))) 00907 return 1; /* out of memory */ 00908 00909 data->error_msg[0]= 0; 00910 data->error_num= 0; 00911 data->filename= filename; 00912 00913 fn_format(tmp_name, filename, "", "", MY_UNPACK_FILENAME); 00914 if ((data->fd = my_open(tmp_name, O_RDONLY, MYF(0))) < 0) 00915 { 00916 data->error_num= my_errno; 00917 my_snprintf(data->error_msg, sizeof(data->error_msg)-1, 00918 EE(EE_FILENOTFOUND), tmp_name, data->error_num); 00919 return 1; 00920 } 00921 return 0; /* ok */ 00922 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int default_local_infile_read | ( | void * | ptr, | |
| char * | buf, | |||
| uint | buf_len | |||
| ) | [static] |
Definition at line 940 of file libmysql.c.
References count, data, EE, EE_READ, my_errno, my_read, my_snprintf(), and MYF.
Referenced by mysql_set_local_infile_default().
00941 { 00942 int count; 00943 default_local_infile_data*data = (default_local_infile_data *) ptr; 00944 00945 if ((count= (int) my_read(data->fd, (byte *) buf, buf_len, MYF(0))) < 0) 00946 { 00947 data->error_num= EE_READ; /* the errmsg for not entire file read */ 00948 my_snprintf(data->error_msg, sizeof(data->error_msg)-1, 00949 EE(EE_READ), 00950 data->filename, my_errno); 00951 } 00952 return count; 00953 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static my_bool execute | ( | MYSQL_STMT * | stmt, | |
| char * | packet, | |||
| ulong | length | |||
| ) | [static] |
Definition at line 2469 of file libmysql.c.
References st_mysql::affected_rows, st_mysql_stmt::affected_rows, cli_advanced_command(), COM_STMT_EXECUTE, DBUG_DUMP, DBUG_ENTER, DBUG_RETURN, st_mysql_stmt::flags, st_mysql::insert_id, st_mysql_stmt::insert_id, int4store, st_net::last_errno, st_net::last_error, st_mysql::last_used_con, st_mysql::methods, st_mysql_stmt::mysql, mysql, st_mysql::net, NULL, st_mysql_methods::read_query_result, st_mysql::server_status, st_mysql_stmt::server_status, set_stmt_errmsg(), st_net::sqlstate, and st_mysql_stmt::stmt_id.
Referenced by cli_stmt_execute(), and TransporterRegistry::unpack().
02470 { 02471 MYSQL *mysql= stmt->mysql; 02472 NET *net= &mysql->net; 02473 char buff[4 /* size of stmt id */ + 02474 5 /* execution flags */]; 02475 DBUG_ENTER("execute"); 02476 DBUG_DUMP("packet", packet, length); 02477 02478 mysql->last_used_con= mysql; 02479 int4store(buff, stmt->stmt_id); /* Send stmt id to server */ 02480 buff[4]= (char) stmt->flags; 02481 int4store(buff+5, 1); /* iteration count */ 02482 if (cli_advanced_command(mysql, COM_STMT_EXECUTE, buff, sizeof(buff), 02483 packet, length, 1, NULL) || 02484 (*mysql->methods->read_query_result)(mysql)) 02485 { 02486 set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); 02487 DBUG_RETURN(1); 02488 } 02489 stmt->affected_rows= mysql->affected_rows; 02490 stmt->server_status= mysql->server_status; 02491 stmt->insert_id= mysql->insert_id; 02492 DBUG_RETURN(0); 02493 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void expand_error | ( | MYSQL * | mysql, | |
| int | error | |||
| ) | [static] |
Definition at line 407 of file libmysql.c.
References ER, st_net::last_errno, st_net::last_error, mysql, MYSQL_ERRMSG_SIZE, st_mysql::net, p, and strmake().
Referenced by get_slaves_from_master(), and mysql_rpl_probe().
00408 { 00409 char tmp[MYSQL_ERRMSG_SIZE]; 00410 char *p; 00411 uint err_length; 00412 strmake(tmp, mysql->net.last_error, MYSQL_ERRMSG_SIZE-1); 00413 p = strmake(mysql->net.last_error, ER(error), MYSQL_ERRMSG_SIZE-1); 00414 err_length= (uint) (p - mysql->net.last_error); 00415 strmake(p, tmp, MYSQL_ERRMSG_SIZE-1 - err_length); 00416 mysql->net.last_errno = error; 00417 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void fetch_datetime_with_conversion | ( | MYSQL_BIND * | param, | |
| MYSQL_FIELD * | field, | |||
| MYSQL_TIME * | time | |||
| ) | [static] |
Definition at line 3841 of file libmysql.c.
References st_mysql_bind::buffer, st_mysql_bind::buffer_type, st_mysql_bind::error, fetch_float_with_conversion(), fetch_long_with_conversion(), fetch_string_with_conversion(), MAX_DATE_STRING_REP_LENGTH, my_TIME_to_str(), MYSQL_TIMESTAMP_DATE, MYSQL_TIMESTAMP_TIME, MYSQL_TYPE_DATE, MYSQL_TYPE_DATETIME, MYSQL_TYPE_DOUBLE, MYSQL_TYPE_FLOAT, MYSQL_TYPE_INT24, MYSQL_TYPE_LONG, MYSQL_TYPE_LONGLONG, MYSQL_TYPE_NULL, MYSQL_TYPE_SHORT, MYSQL_TYPE_TIME, MYSQL_TYPE_TIMESTAMP, MYSQL_TYPE_TINY, MYSQL_TYPE_YEAR, shortstore, TIME_to_ulonglong(), st_mysql_time::time_type, TRUE, ulonglong2double, value, and st_mysql_time::year.
Referenced by fetch_result_with_conversion().
03844 { 03845 switch (param->buffer_type) { 03846 case MYSQL_TYPE_NULL: /* do nothing */ 03847 break; 03848 case MYSQL_TYPE_DATE: 03849 *(MYSQL_TIME *)(param->buffer)= *time; 03850 *param->error= time->time_type != MYSQL_TIMESTAMP_DATE; 03851 break; 03852 case MYSQL_TYPE_TIME: 03853 *(MYSQL_TIME *)(param->buffer)= *time; 03854 *param->error= time->time_type != MYSQL_TIMESTAMP_TIME; 03855 break; 03856 case MYSQL_TYPE_DATETIME: 03857 case MYSQL_TYPE_TIMESTAMP: 03858 *(MYSQL_TIME *)(param->buffer)= *time; 03859 /* No error: time and date are compatible with datetime */ 03860 break; 03861 case MYSQL_TYPE_YEAR: 03862 shortstore(param->buffer, time->year); 03863 *param->error= 1; 03864 break; 03865 case MYSQL_TYPE_FLOAT: 03866 case MYSQL_TYPE_DOUBLE: 03867 { 03868 ulonglong value= TIME_to_ulonglong(time); 03869 fetch_float_with_conversion(param, field, 03870 ulonglong2double(value), DBL_DIG); 03871 break; 03872 } 03873 case MYSQL_TYPE_TINY: 03874 case MYSQL_TYPE_SHORT: 03875 case MYSQL_TYPE_INT24: 03876 case MYSQL_TYPE_LONG: 03877 case MYSQL_TYPE_LONGLONG: 03878 { 03879 longlong value= (longlong) TIME_to_ulonglong(time); 03880 fetch_long_with_conversion(param, field, value, TRUE); 03881 break; 03882 } 03883 default: 03884 { 03885 /* 03886 Convert time value to string and delegate the rest to 03887 fetch_string_with_conversion: 03888 */ 03889 char buff[MAX_DATE_STRING_REP_LENGTH]; 03890 uint length= my_TIME_to_str(time, buff); 03891 /* Resort to string conversion */ 03892 fetch_string_with_conversion(param, (char *)buff, length); 03893 break; 03894 } 03895 } 03896 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void fetch_float_with_conversion | ( | MYSQL_BIND * | param, | |
| MYSQL_FIELD * | field, | |||
| double | value, | |||
| int | width | |||
| ) | [static] |
Definition at line 3718 of file libmysql.c.
References st_mysql_bind::buffer, buffer, st_mysql_bind::buffer_length, st_mysql_bind::buffer_type, data, st_mysql_field::decimals, doublestore, st_mysql_bind::error, fetch_string_with_conversion(), floatstore, st_mysql_bind::is_unsigned, longlongstore, longstore, MAX_DOUBLE_STRING_REP_LENGTH, min, MYSQL_TYPE_DOUBLE, MYSQL_TYPE_FLOAT, MYSQL_TYPE_LONG, MYSQL_TYPE_LONGLONG, MYSQL_TYPE_NULL, MYSQL_TYPE_SHORT, MYSQL_TYPE_TINY, NOT_FIXED_DEC, shortstore, strcend(), strend(), and ulonglong2double.
Referenced by fetch_datetime_with_conversion(), and fetch_result_with_conversion().
03720 { 03721 char *buffer= (char *)param->buffer; 03722 double val64 = (value < 0 ? -floor(-value) : floor(value)); 03723 03724 switch (param->buffer_type) { 03725 case MYSQL_TYPE_NULL: /* do nothing */ 03726 break; 03727 case MYSQL_TYPE_TINY: 03728 /* 03729 We need to _store_ data in the buffer before the truncation check to 03730 workaround Intel FPU executive precision feature. 03731 (See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323 for details) 03732 Sic: AFAIU it does not guarantee to work. 03733 */ 03734 if (param->is_unsigned) 03735 *buffer= (uint8) value; 03736 else 03737 *buffer= (int8) value; 03738 *param->error= val64 != (param->is_unsigned ? (double)((uint8) *buffer) : 03739 (double)((int8) *buffer)); 03740 break; 03741 case MYSQL_TYPE_SHORT: 03742 if (param->is_unsigned) 03743 { 03744 ushort data= (ushort) value; 03745 shortstore(buffer, data); 03746 } 03747 else 03748 { 03749 short data= (short) value; 03750 shortstore(buffer, data); 03751 } 03752 *param->error= val64 != (param->is_unsigned ? (double) (*(ushort*) buffer): 03753 (double) (*(short*) buffer)); 03754 break; 03755 case MYSQL_TYPE_LONG: 03756 if (param->is_unsigned) 03757 { 03758 uint32 data= (uint32) value; 03759 longstore(buffer, data); 03760 } 03761 else 03762 { 03763 int32 data= (int32) value; 03764 longstore(buffer, data); 03765 } 03766 *param->error= val64 != (param->is_unsigned ? (double) (*(uint32*) buffer): 03767 (double) (*(int32*) buffer)); 03768 break; 03769 case MYSQL_TYPE_LONGLONG: 03770 if (param->is_unsigned) 03771 { 03772 ulonglong data= (ulonglong) value; 03773 longlongstore(buffer, data); 03774 } 03775 else 03776 { 03777 longlong data= (longlong) value; 03778 longlongstore(buffer, data); 03779 } 03780 *param->error= val64 != (param->is_unsigned ? 03781 ulonglong2double(*(ulonglong*) buffer) : 03782 (double) (*(longlong*) buffer)); 03783 break; 03784 case MYSQL_TYPE_FLOAT: 03785 { 03786 float data= (float) value; 03787 floatstore(buffer, data); 03788 *param->error= (*(float*) buffer) != value; 03789 break; 03790 } 03791 case MYSQL_TYPE_DOUBLE: 03792 { 03793 doublestore(buffer, value); 03794 break; 03795 } 03796 default: 03797 { 03798 /* 03799 Resort to fetch_string_with_conversion: this should handle 03800 floating point -> string conversion nicely, honor all typecodes 03801 and param->offset possibly set in mysql_stmt_fetch_column 03802 */ 03803 char buff[MAX_DOUBLE_STRING_REP_LENGTH]; 03804 char *end; 03805 /* TODO: move this to a header shared between client and server. */ 03806 #define NOT_FIXED_DEC 31 03807 if (field->decimals >= NOT_FIXED_DEC) 03808 #undef NOT_FIXED_DEC 03809 { 03810 /* 03811 The 14 below is to ensure that the server and client has the same 03812 precisions. This will ensure that on the same machine you get the 03813 same value as a string independent of the protocol you use. 03814 */ 03815 sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1, 03816 param->buffer_length), 03817 min(14,width), value); 03818 end= strcend(buff, ' '); 03819 *end= 0; 03820 } 03821 else 03822 { 03823 sprintf(buff, "%.*f", (int) field->decimals, value); 03824 end= strend(buff); 03825 } 03826 fetch_string_with_conversion(param, buff, (uint) (end - buff)); 03827 break; 03828 } 03829 } 03830 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void fetch_long_with_conversion | ( | MYSQL_BIND * | param, | |
| MYSQL_FIELD * | field, | |||
| longlong | value, | |||
| my_bool | is_unsigned | |||
| ) | [static] |
Definition at line 3616 of file libmysql.c.
References bfill, bmove_upp(), st_mysql_bind::buffer, buffer, st_mysql_bind::buffer_type, data, doublestore, error, st_mysql_bind::error, fetch_string_with_conversion(), st_mysql_field::flags, floatstore, INT_MAX16, INT_MAX32, INT_MAX8, INT_MIN16, INT_MIN32, INT_MIN8, IS_TRUNCATED, st_mysql_bind::is_unsigned, st_mysql_field::length, longlong10_to_str, longlongstore, longstore, MYSQL_TYPE_DATE, MYSQL_TYPE_DATETIME, MYSQL_TYPE_DOUBLE, MYSQL_TYPE_FLOAT, MYSQL_TYPE_LONG, MYSQL_TYPE_LONGLONG, MYSQL_TYPE_NULL, MYSQL_TYPE_SHORT, MYSQL_TYPE_TIME, MYSQL_TYPE_TIMESTAMP, MYSQL_TYPE_TINY, number_to_datetime(), shortstore, test, TIME_FUZZY_DATE, UINT_MAX16, UINT_MAX32, UINT_MAX8, ulonglong2double, and ZEROFILL_FLAG.
Referenced by fetch_datetime_with_conversion(), and fetch_result_with_conversion().
03618 { 03619 char *buffer= (char *)param->buffer; 03620 03621 switch (param->buffer_type) { 03622 case MYSQL_TYPE_NULL: /* do nothing */ 03623 break; 03624 case MYSQL_TYPE_TINY: 03625 *param->error= IS_TRUNCATED(value, param->is_unsigned, 03626 INT_MIN8, INT_MAX8, UINT_MAX8); 03627 *(uchar *)param->buffer= (uchar) value; 03628 break; 03629 case MYSQL_TYPE_SHORT: 03630 *param->error= IS_TRUNCATED(value, param->is_unsigned, 03631 INT_MIN16, INT_MAX16, UINT_MAX16); 03632 shortstore(buffer, (short) value); 03633 break; 03634 case MYSQL_TYPE_LONG: 03635 *param->error= IS_TRUNCATED(value, param->is_unsigned, 03636 INT_MIN32, INT_MAX32, UINT_MAX32); 03637 longstore(buffer, (int32) value); 03638 break; 03639 case MYSQL_TYPE_LONGLONG: 03640 longlongstore(buffer, value); 03641 *param->error= param->is_unsigned != is_unsigned && value < 0; 03642 break; 03643 case MYSQL_TYPE_FLOAT: 03644 { 03645 /* 03646 We need to store data in the buffer before the truncation check to 03647 workaround Intel FPU executive precision feature. 03648 (See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323 for details) 03649 AFAIU it does not guarantee to work. 03650 */ 03651 float data; 03652 if (is_unsigned) 03653 data= (float) ulonglong2double(value); 03654 else 03655 data= (float) value; 03656 floatstore(buffer, data); 03657 *param->error= is_unsigned ? 03658 ((ulonglong) value) != ((ulonglong) (*(float*) buffer)) : 03659 ((longlong) value) != ((longlong) (*(float*) buffer)); 03660 break; 03661 } 03662 case MYSQL_TYPE_DOUBLE: 03663 { 03664 double data; 03665 if (is_unsigned) 03666 data= ulonglong2double(value); 03667 else 03668 data= (double)value; 03669 doublestore(buffer, data); 03670 *param->error= is_unsigned ? 03671 ((ulonglong) value) != ((ulonglong) (*(double*) buffer)) : 03672 ((longlong) value) != ((longlong) (*(double*) buffer)); 03673 break; 03674 } 03675 case MYSQL_TYPE_TIME: 03676 case MYSQL_TYPE_DATE: 03677 case MYSQL_TYPE_TIMESTAMP: 03678 case MYSQL_TYPE_DATETIME: 03679 { 03680 int error; 03681 value= number_to_datetime(value, (MYSQL_TIME *) buffer, TIME_FUZZY_DATE, 03682 &error); 03683 *param->error= test(error); 03684 break; 03685 } 03686 default: 03687 { 03688 char buff[22]; /* Enough for longlong */ 03689 char *end= longlong10_to_str(value, buff, is_unsigned ? 10: -10); 03690 /* Resort to string conversion which supports all typecodes */ 03691 uint length= (uint) (end-buff); 03692 03693 if (field->flags & ZEROFILL_FLAG && length < field->length && 03694 field->length < 21) 03695 { 03696 bmove_upp((char*) buff+field->length,buff+length, length); 03697 bfill((char*) buff, field->length - length,'0'); 03698 length= field->length; 03699 } 03700 fetch_string_with_conversion(param, buff, length); 03701 break; 03702 } 03703 } 03704 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void fetch_result_bin | ( | MYSQL_BIND * | param, | |
| MYSQL_FIELD *field | __attribute__((unused)), | |||
| uchar ** | row | |||
| ) | [static] |
Definition at line 4117 of file libmysql.c.
References st_mysql_bind::buffer, st_mysql_bind::buffer_length, st_mysql_bind::error, st_mysql_bind::length, memcpy, min, and net_field_length().
Referenced by setup_one_fetch_function().
04120 { 04121 ulong length= net_field_length(row); 04122 ulong copy_length= min(length, param->buffer_length); 04123 memcpy(param->buffer, (char *)*row, copy_length); 04124 *param->length= length; 04125 *param->error= copy_length < length; 04126 *row+= length; 04127 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void fetch_result_date | ( | MYSQL_BIND * | param, | |
| MYSQL_FIELD *field | __attribute__((unused)), | |||
| uchar ** | row | |||
| ) | [static] |
Definition at line 4101 of file libmysql.c.
References st_mysql_bind::buffer, and read_binary_date().
Referenced by setup_one_fetch_function().
04104 { 04105 MYSQL_TIME *tm= (MYSQL_TIME *)param->buffer; 04106 read_binary_date(tm, row); 04107 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void fetch_result_datetime | ( | MYSQL_BIND * | param, | |
| MYSQL_FIELD *field | __attribute__((unused)), | |||
| uchar ** | row | |||
| ) | [static] |
Definition at line 4109 of file libmysql.c.
References st_mysql_bind::buffer, and read_binary_datetime().
Referenced by setup_one_fetch_function().
04112 { 04113 MYSQL_TIME *tm= (MYSQL_TIME *)param->buffer; 04114 read_binary_datetime(tm, row); 04115 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void fetch_result_double | ( | MYSQL_BIND * | param, | |
| MYSQL_FIELD *field | __attribute__((unused)), | |||
| uchar ** | row | |||
| ) | [static] |
Definition at line 4083 of file libmysql.c.
References st_mysql_bind::buffer, doublestore, float8get, and value.
Referenced by setup_one_fetch_function().
04086 { 04087 double value; 04088 float8get(value,*row); 04089 doublestore(param->buffer, value); 04090 *row+= 8; 04091 }
Here is the caller graph for this function:

| static void fetch_result_float | ( | MYSQL_BIND * | param, | |
| MYSQL_FIELD *field | __attribute__((unused)), | |||
| uchar ** | row | |||
| ) | [static] |
Definition at line 4073 of file libmysql.c.
References st_mysql_bind::buffer, float4get, floatstore, and value.
Referenced by setup_one_fetch_function().
04076 { 04077 float value; 04078 float4get(value,*row); 04079 floatstore(param->buffer, value); 04080 *row+= 4; 04081 }
Here is the caller graph for this function:

| static void fetch_result_int32 | ( | MYSQL_BIND * | param, | |
| MYSQL_FIELD *field | __attribute__((unused)), | |||
| uchar ** | row | |||
| ) | [static] |
Definition at line 4051 of file libmysql.c.
References st_mysql_bind::buffer, data, st_mysql_bind::error, INT_MAX32, st_mysql_bind::is_unsigned, longstore, sint4korr, test, and UNSIGNED_FLAG.
Referenced by setup_one_fetch_function().
04054 { 04055 my_bool field_is_unsigned= test(field->flags & UNSIGNED_FLAG); 04056 uint32 data= (uint32) sint4korr(*row); 04057 longstore(param->buffer, data); 04058 *param->error= param->is_unsigned != field_is_unsigned && data > INT_MAX32; 04059 *row+= 4; 04060 }
Here is the caller graph for this function:

| static void fetch_result_int64 | ( | MYSQL_BIND * | param, | |
| MYSQL_FIELD *field | __attribute__((unused)), | |||
| uchar ** | row | |||
| ) | [static] |
Definition at line 4062 of file libmysql.c.
References st_mysql_bind::buffer, data, st_mysql_bind::error, st_mysql_bind::is_unsigned, LONGLONG_MAX, longlongstore, sint8korr, test, and UNSIGNED_FLAG.
Referenced by setup_one_fetch_function().
04065 { 04066 my_bool field_is_unsigned= test(field->flags & UNSIGNED_FLAG); 04067 ulonglong data= (ulonglong) sint8korr(*row); 04068 *param->error= param->is_unsigned != field_is_unsigned && data > LONGLONG_MAX; 04069 longlongstore(param->buffer, data); 04070 *row+= 8; 04071 }
Here is the caller graph for this function:

| static void fetch_result_short | ( | MYSQL_BIND * | param, | |
| MYSQL_FIELD * | field, | |||
| uchar ** | row | |||
| ) | [static] |
Definition at line 4041 of file libmysql.c.
References st_mysql_bind::buffer, data, st_mysql_bind::error, st_mysql_field::flags, INT_MAX16, st_mysql_bind::is_unsigned, shortstore, sint2korr, test, and UNSIGNED_FLAG.
Referenced by setup_one_fetch_function().
04043 { 04044 my_bool field_is_unsigned= test(field->flags & UNSIGNED_FLAG); 04045 ushort data= (ushort) sint2korr(*row); 04046 shortstore(param->buffer, data); 04047 *param->error= param->is_unsigned != field_is_unsigned && data > INT_MAX16; 04048 *row+= 2; 04049 }
Here is the caller graph for this function:

| static void fetch_result_str | ( | MYSQL_BIND * | param, | |
| MYSQL_FIELD *field | __attribute__((unused)), | |||
| uchar ** | row | |||
| ) | [static] |
Definition at line 4129 of file libmysql.c.
References st_mysql_bind::buffer, st_mysql_bind::buffer_length, st_mysql_bind::error, st_mysql_bind::length, memcpy, min, and net_field_length().
Referenced by setup_one_fetch_function().
04132 { 04133 ulong length= net_field_length(row); 04134 ulong copy_length= min(length, param->buffer_length); 04135 memcpy(param->buffer, (char *)*row, copy_length); 04136 /* Add an end null if there is room in the buffer */ 04137 if (copy_length != param->buffer_length) 04138 ((uchar *)param->buffer)[copy_length]= '\0'; 04139 *param->length= length; /* return total length */ 04140 *param->error= copy_length < length; 04141 *row+= length; 04142 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void fetch_result_time | ( | MYSQL_BIND * | param, | |
| MYSQL_FIELD *field | __attribute__((unused)), | |||
| uchar ** | row | |||
| ) | [static] |
Definition at line 4093 of file libmysql.c.
References st_mysql_bind::buffer, and read_binary_time().
Referenced by setup_one_fetch_function().
04096 { 04097 MYSQL_TIME *tm= (MYSQL_TIME *)param->buffer; 04098 read_binary_time(tm, row); 04099 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void fetch_result_tinyint | ( | MYSQL_BIND * | param, | |
| MYSQL_FIELD * | field, | |||
| uchar ** | row | |||
| ) | [static] |
Definition at line 4031 of file libmysql.c.
References st_mysql_bind::buffer, data, st_mysql_bind::error, st_mysql_field::flags, INT_MAX8, st_mysql_bind::is_unsigned, test, and UNSIGNED_FLAG.
Referenced by setup_one_fetch_function().
04033 { 04034 my_bool field_is_unsigned= test(field->flags & UNSIGNED_FLAG); 04035 uchar data= **row; 04036 *(uchar *)param->buffer= data; 04037 *param->error= param->is_unsigned != field_is_unsigned && data > INT_MAX8; 04038 (*row)++; 04039 }
Here is the caller graph for this function:

| static void fetch_result_with_conversion | ( | MYSQL_BIND * | param, | |
| MYSQL_FIELD * | field, | |||
| uchar ** | row | |||
| ) | [static] |
Definition at line 3915 of file libmysql.c.
References data, fetch_datetime_with_conversion(), fetch_float_with_conversion(), fetch_long_with_conversion(), fetch_string_with_conversion(), st_mysql_field::flags, float4get, float8get, MYSQL_TYPE_DATE, MYSQL_TYPE_DATETIME, MYSQL_TYPE_DOUBLE, MYSQL_TYPE_FLOAT, MYSQL_TYPE_INT24, MYSQL_TYPE_LONG, MYSQL_TYPE_LONGLONG, MYSQL_TYPE_SHORT, MYSQL_TYPE_TIME, MYSQL_TYPE_TIMESTAMP, MYSQL_TYPE_TINY, MYSQL_TYPE_YEAR, net_field_length(), read_binary_date(), read_binary_datetime(), read_binary_time(), sint2korr, sint4korr, sint8korr, st_mysql_field::type, UNSIGNED_FLAG, and value.
Referenced by mysql_stmt_fetch_column(), and setup_one_fetch_function().
03917 { 03918 enum enum_field_types field_type= field->type; 03919 uint field_is_unsigned= field->flags & UNSIGNED_FLAG; 03920 03921 switch (field_type) { 03922 case MYSQL_TYPE_TINY: 03923 { 03924 uchar value= **row; 03925 /* sic: we need to cast to 'signed char' as 'char' may be unsigned */ 03926 longlong data= field_is_unsigned ? (longlong) value : 03927 (longlong) (signed char) value; 03928 fetch_long_with_conversion(param, field, data, 0); 03929 *row+= 1; 03930 break; 03931 } 03932 case MYSQL_TYPE_SHORT: 03933 case MYSQL_TYPE_YEAR: 03934 { 03935 short value= sint2korr(*row); 03936 longlong data= field_is_unsigned ? (longlong) (unsigned short) value : 03937 (longlong) value; 03938 fetch_long_with_conversion(param, field, data, 0); 03939 *row+= 2; 03940 break; 03941 } 03942 case MYSQL_TYPE_INT24: /* mediumint is sent as 4 bytes int */ 03943 case MYSQL_TYPE_LONG: 03944 { 03945 int32 value= sint4korr(*row); 03946 longlong data= field_is_unsigned ? (longlong) (uint32) value : 03947 (longlong) value; 03948 fetch_long_with_conversion(param, field, data, 0); 03949 *row+= 4; 03950 break; 03951 } 03952 case MYSQL_TYPE_LONGLONG: 03953 { 03954 longlong value= (longlong)sint8korr(*row); 03955 fetch_long_with_conversion(param, field, value, 03956 field->flags & UNSIGNED_FLAG); 03957 *row+= 8; 03958 break; 03959 } 03960 case MYSQL_TYPE_FLOAT: 03961 { 03962 float value; 03963 float4get(value,*row); 03964 fetch_float_with_conversion(param, field, value, FLT_DIG); 03965 *row+= 4; 03966 break; 03967 } 03968 case MYSQL_TYPE_DOUBLE: 03969 { 03970 double value; 03971 float8get(value,*row); 03972 fetch_float_with_conversion(param, field, value, DBL_DIG); 03973 *row+= 8; 03974 break; 03975 } 03976 case MYSQL_TYPE_DATE: 03977 { 03978 MYSQL_TIME tm; 03979 03980 read_binary_date(&tm, row); 03981 fetch_datetime_with_conversion(param, field, &tm); 03982 break; 03983 } 03984 case MYSQL_TYPE_TIME: 03985 { 03986 MYSQL_TIME tm; 03987 03988 read_binary_time(&tm, row); 03989 fetch_datetime_with_conversion(param, field, &tm); 03990 break; 03991 } 03992 case MYSQL_TYPE_DATETIME: 03993 case MYSQL_TYPE_TIMESTAMP: 03994 { 03995 MYSQL_TIME tm; 03996 03997 read_binary_datetime(&tm, row); 03998 fetch_datetime_with_conversion(param, field, &tm); 03999 break; 04000 } 04001 default: 04002 { 04003 ulong length= net_field_length(row); 04004 fetch_string_with_conversion(param, (char*) *row, length); 04005 *row+= length; 04006 break; 04007 } 04008 } 04009 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void fetch_string_with_conversion | ( | MYSQL_BIND * | param, | |
| char * | value, | |||
| uint | length | |||
| ) | [static] |
Definition at line 3490 of file libmysql.c.
References st_mysql_bind::buffer, buffer, st_mysql_bind::buffer_length, st_mysql_bind::buffer_type, data, doublestore, endptr, err, st_mysql_bind::error, floatstore, INT_MAX16, INT_MAX32, INT_MAX8, INT_MIN16, INT_MIN32, INT_MIN8, IS_TRUNCATED, st_mysql_bind::is_unsigned, st_mysql_bind::length, longlongstore, longstore, memcpy, min, my_charset_latin1, my_strntod, my_strtoll10(), MYSQL_TIMESTAMP_DATE, MYSQL_TYPE_BLOB, MYSQL_TYPE_DATE, MYSQL_TYPE_DATETIME, MYSQL_TYPE_DECIMAL, MYSQL_TYPE_DOUBLE, MYSQL_TYPE_FLOAT, MYSQL_TYPE_LONG, MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONGLONG, MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_NULL, MYSQL_TYPE_SHORT, MYSQL_TYPE_TIME, MYSQL_TYPE_TIMESTAMP, MYSQL_TYPE_TINY, MYSQL_TYPE_TINY_BLOB, st_mysql_bind::offset, shortstore, start(), str_to_datetime(), str_to_time(), test, TIME_FUZZY_DATE, st_mysql_time::time_type, UINT_MAX16, UINT_MAX32, and UINT_MAX8.
Referenced by fetch_datetime_with_conversion(), fetch_float_with_conversion(), fetch_long_with_conversion(), and fetch_result_with_conversion().
03492 { 03493 char *buffer= (char *)param->buffer; 03494 int err= 0; 03495 char *endptr= value + length; 03496 03497 /* 03498 This function should support all target buffer types: the rest 03499 of conversion functions can delegate conversion to it. 03500 */ 03501 switch(param->buffer_type) { 03502 case MYSQL_TYPE_NULL: /* do nothing */ 03503 break; 03504 case MYSQL_TYPE_TINY: 03505 { 03506 longlong data= my_strtoll10(value, &endptr, &err); 03507 *param->error= (IS_TRUNCATED(data, param->is_unsigned, 03508 INT_MIN8, INT_MAX8, UINT_MAX8) || err > 0); 03509 *buffer= (uchar) data; 03510 break; 03511 } 03512 case MYSQL_TYPE_SHORT: 03513 { 03514 longlong data= my_strtoll10(value, &endptr, &err); 03515 *param->error= (IS_TRUNCATED(data, param->is_unsigned, 03516 INT_MIN16, INT_MAX16, UINT_MAX16) || err > 0); 03517 shortstore(buffer, (short) data); 03518 break; 03519 } 03520 case MYSQL_TYPE_LONG: 03521 { 03522 longlong data= my_strtoll10(value, &endptr, &err); 03523 *param->error= (IS_TRUNCATED(data, param->is_unsigned, 03524 INT_MIN32, INT_MAX32, UINT_MAX32) || err > 0); 03525 longstore(buffer, (int32) data); 03526 break; 03527 } 03528 case MYSQL_TYPE_LONGLONG: 03529 { 03530 longlong data= my_strtoll10(value, &endptr, &err); 03531 *param->error= param->is_unsigned ? err != 0 : 03532 (err > 0 || (err == 0 && data < 0)); 03533 longlongstore(buffer, data); 03534 break; 03535 } 03536 case MYSQL_TYPE_FLOAT: 03537 { 03538 double data= my_strntod(&my_charset_latin1, value, length, &endptr, &err); 03539 float fdata= (float) data; 03540 *param->error= (fdata != data) | test(err); 03541 floatstore(buffer, fdata); 03542 break; 03543 } 03544 case MYSQL_TYPE_DOUBLE: 03545 { 03546 double data= my_strntod(&my_charset_latin1, value, length, &endptr, &err); 03547 *param->error= test(err); 03548 doublestore(buffer, data); 03549 break; 03550 } 03551 case MYSQL_TYPE_TIME: 03552 { 03553 MYSQL_TIME *tm= (MYSQL_TIME *)buffer; 03554 str_to_time(value, length, tm, &err); 03555 *param->error= test(err); 03556 break; 03557 } 03558 case MYSQL_TYPE_DATE: 03559 case MYSQL_TYPE_DATETIME: 03560 case MYSQL_TYPE_TIMESTAMP: 03561 { 03562 MYSQL_TIME *tm= (MYSQL_TIME *)buffer; 03563 (void) str_to_datetime(value, length, tm, TIME_FUZZY_DATE, &err); 03564 *param->error= test(err) && (param->buffer_type == MYSQL_TYPE_DATE && 03565 tm->time_type != MYSQL_TIMESTAMP_DATE); 03566 break; 03567 } 03568 case MYSQL_TYPE_TINY_BLOB: 03569 case MYSQL_TYPE_MEDIUM_BLOB: 03570 case MYSQL_TYPE_LONG_BLOB: 03571 case MYSQL_TYPE_BLOB: 03572 case MYSQL_TYPE_DECIMAL: 03573 case MYSQL_TYPE_NEWDECIMAL: 03574 default: 03575 { 03576 /* 03577 Copy column data to the buffer taking into account offset, 03578 data length and buffer length. 03579 */ 03580 char *start= value + param->offset; 03581 char *end= value + length; 03582 ulong copy_length; 03583 if (start < end) 03584 { 03585 copy_length= end - start; 03586 /* We've got some data beyond offset: copy up to buffer_length bytes */ 03587 if (param->buffer_length) 03588 memcpy(buffer, start, min(copy_length, param->buffer_length)); 03589 } 03590 else 03591 copy_length= 0; 03592 if (copy_length < param->buffer_length) 03593 buffer[copy_length]= '\0'; 03594 *param->error= copy_length > param->buffer_length; 03595 /* 03596 param->length will always contain length of entire column; 03597 number of copied bytes may be way different: 03598 */ 03599 *param->length= length; 03600 break; 03601 } 03602 } 03603 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 424 of file libmysql.c.
References atoi(), DBUG_ENTER, DBUG_RETURN, st_mysql::master, mysql, mysql_num_fields(), and spawn_init().
Referenced by mysql_rpl_probe().
00425 { 00426 MYSQL* master; 00427 DBUG_ENTER("get_master"); 00428 if (mysql_num_fields(res) < 3) 00429 DBUG_RETURN(1); /* safety */ 00430 00431 /* use the same username and password as the original connection */ 00432 if (!(master = spawn_init(mysql, row[0], atoi(row[2]), 0, 0))) 00433 DBUG_RETURN(1); 00434 mysql->master = master; 00435 DBUG_RETURN(0); 00436 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 444 of file libmysql.c.
References atoi(), CR_PROBE_MASTER_CONNECT, CR_PROBE_SLAVE_HOSTS, DBUG_ENTER, DBUG_RETURN, err, error, expand_error(), mysql, mysql_fetch_row(), mysql_free_result(), mysql_num_fields(), mysql_query(), mysql_real_connect(), mysql_store_result(), st_mysql::net, st_mysql::next_slave, st_mysql::passwd, st_mysql::reconnect, spawn_init(), st_mysql::user, and st_net::vio.
Referenced by mysql_rpl_probe().
00445 { 00446 MYSQL_RES* res = 0; 00447 MYSQL_ROW row; 00448 my_bool error = 1; 00449 int has_auth_info; 00450 int port_ind; 00451 DBUG_ENTER("get_slaves_from_master"); 00452 00453 if (!mysql->net.vio && !mysql_real_connect(mysql,0,0,0,0,0,0,0)) 00454 { 00455 expand_error(mysql, CR_PROBE_MASTER_CONNECT); 00456 DBUG_RETURN(1); 00457 } 00458 mysql->reconnect= 1; 00459 00460 if (mysql_query(mysql, "SHOW SLAVE HOSTS") || 00461 !(res = mysql_store_result(mysql))) 00462 { 00463 expand_error(mysql, CR_PROBE_SLAVE_HOSTS); 00464 DBUG_RETURN(1); 00465 } 00466 00467 switch (mysql_num_fields(res)) { 00468 case 5: 00469 has_auth_info = 0; 00470 port_ind=2; 00471 break; 00472 case 7: 00473 has_auth_info = 1; 00474 port_ind=4; 00475 break; 00476 default: 00477 goto err; 00478 } 00479 00480 while ((row = mysql_fetch_row(res))) 00481 { 00482 MYSQL* slave; 00483 const char* tmp_user, *tmp_pass; 00484 00485 if (has_auth_info) 00486 { 00487 tmp_user = row[2]; 00488 tmp_pass = row[3]; 00489 } 00490 else 00491 { 00492 tmp_user = mysql->user; 00493 tmp_pass = mysql->passwd; 00494 } 00495 00496 if (!(slave = spawn_init(mysql, row[1], atoi(row[port_ind]), 00497 tmp_user, tmp_pass))) 00498 goto err; 00499 00500 /* Now add slave into the circular linked list */ 00501 slave->next_slave = mysql->next_slave; 00502 mysql->next_slave = slave; 00503 } 00504 error = 0; 00505 err: 00506 if (res) 00507 mysql_free_result(res); 00508 DBUG_RETURN(error); 00509 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 783 of file libmysql.c.
00784 { 00785 my_bool result= 1; 00786 uint packet_length=MY_ALIGN(mysql->net.max_packet-16,IO_SIZE); 00787 NET *net= &mysql->net; 00788 int readcount; 00789 void *li_ptr; /* pass state to local_infile functions */ 00790 char *buf; /* buffer to be filled by local_infile_read */ 00791 struct st_mysql_options *options= &mysql->options; 00792 DBUG_ENTER("handle_local_infile"); 00793 00794 /* check that we've got valid callback functions */ 00795 if (!(options->local_infile_init && 00796 options->local_infile_read && 00797 options->local_infile_end && 00798 options->local_infile_error)) 00799 { 00800 /* if any of the functions is invalid, set the default */ 00801 mysql_set_local_infile_default(mysql); 00802 } 00803 00804 /* copy filename into local memory and allocate read buffer */ 00805 if (!(buf=my_malloc(packet_length, MYF(0)))) 00806 { 00807 strmov(net->sqlstate, unknown_sqlstate); 00808 strmov(net->last_error, ER(net->last_errno=CR_OUT_OF_MEMORY)); 00809 DBUG_RETURN(1); 00810 } 00811 00812 /* initialize local infile (open file, usually) */ 00813 if ((*options->local_infile_init)(&li_ptr, net_filename, 00814 options->local_infile_userdata)) 00815 { 00816 VOID(my_net_write(net,"",0)); /* Server needs one packet */ 00817 net_flush(net); 00818 strmov(net->sqlstate, unknown_sqlstate); 00819 net->last_errno= (*options->local_infile_error)(li_ptr, 00820 net->last_error, 00821 sizeof(net->last_error)-1); 00822 goto err; 00823 } 00824 00825 /* read blocks of data from local infile callback */ 00826 while ((readcount = 00827 (*options->local_infile_read)(li_ptr, buf, 00828 packet_length)) > 0) 00829 { 00830 if (my_net_write(net,buf,readcount)) 00831 { 00832 DBUG_PRINT("error", 00833 ("Lost connection to MySQL server during LOAD DATA of local file")); 00834 strmov(net->sqlstate, unknown_sqlstate); 00835 net->last_errno=CR_SERVER_LOST; 00836 strmov(net->last_error,ER(net->last_errno)); 00837 goto err; 00838 } 00839 } 00840 00841 /* Send empty packet to mark end of file */ 00842 if (my_net_write(net,"",0) || net_flush(net)) 00843 { 00844 strmov(net->sqlstate, unknown_sqlstate); 00845 net->last_errno=CR_SERVER_LOST; 00846 sprintf(net->last_error,ER(net->last_errno),errno); 00847 goto err; 00848 } 00849 00850 if (readcount < 0) 00851 { 00852 net->last_errno= (*options->local_infile_error)(li_ptr, 00853 net->last_error, 00854 sizeof(net->last_error)-1); 00855 goto err; 00856 } 00857 00858 result=0; /* Ok */ 00859 00860 err: 00861 /* free up memory allocated with _init, usually */ 00862 (*options->local_infile_end)(li_ptr); 00863 my_free(buf, MYF(0)); 00864 DBUG_RETURN(result); 00865 }
| static my_bool is_binary_compatible | ( | enum enum_field_types | type1, | |
| enum enum_field_types | type2 | |||
| ) | [static] |
Definition at line 4195 of file libmysql.c.
References FALSE, MYSQL_TYPE_BLOB, MYSQL_TYPE_DATETIME, MYSQL_TYPE_DECIMAL, MYSQL_TYPE_ENUM, MYSQL_TYPE_GEOMETRY, MYSQL_TYPE_INT24, MYSQL_TYPE_LONG, MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_NULL, MYSQL_TYPE_SET, MYSQL_TYPE_SHORT, MYSQL_TYPE_STRING, MYSQL_TYPE_TIMESTAMP, MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_VAR_STRING, MYSQL_TYPE_YEAR, and TRUE.
Referenced by setup_one_fetch_function().
04197 { 04198 static const enum enum_field_types 04199 range1[]= { MYSQL_TYPE_SHORT, MYSQL_TYPE_YEAR, MYSQL_TYPE_NULL }, 04200 range2[]= { MYSQL_TYPE_INT24, MYSQL_TYPE_LONG, MYSQL_TYPE_NULL }, 04201 range3[]= { MYSQL_TYPE_DATETIME, MYSQL_TYPE_TIMESTAMP, MYSQL_TYPE_NULL }, 04202 range4[]= { MYSQL_TYPE_ENUM, MYSQL_TYPE_SET, MYSQL_TYPE_TINY_BLOB, 04203 MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_BLOB, 04204 MYSQL_TYPE_VAR_STRING, MYSQL_TYPE_STRING, MYSQL_TYPE_GEOMETRY, 04205 MYSQL_TYPE_DECIMAL, MYSQL_TYPE_NULL }; 04206 static const enum enum_field_types 04207 *range_list[]= { range1, range2, range3, range4 }, 04208 **range_list_end= range_list + sizeof(range_list)/sizeof(*range_list); 04209 const enum enum_field_types **range, *type; 04210 04211 if (type1 == type2) 04212 return TRUE; 04213 for (range= range_list; range != range_list_end; ++range) 04214 { 04215 /* check that both type1 and type2 are in the same range */ 04216 bool type1_found= FALSE, type2_found= FALSE; 04217 for (type= *range; *type != MYSQL_TYPE_NULL; type++) 04218 { 04219 type1_found|= type1 == *type; 04220 type2_found|= type2 == *type; 04221 } 04222 if (type1_found || type2_found) 04223 return type1_found && type2_found; 04224 } 04225 return FALSE; 04226 }
Here is the caller graph for this function:

| void my_net_local_init | ( | NET * | net | ) |
Definition at line 1518 of file libmysql.c.
References max, max_allowed_packet, st_net::max_packet, st_net::max_packet_size, net_read_timeout, net_write_timeout, st_net::read_timeout, st_net::retry_count, and st_net::write_timeout.
01519 { 01520 net->max_packet= (uint) net_buffer_length; 01521 net->read_timeout= (uint) net_read_timeout; 01522 net->write_timeout=(uint) net_write_timeout; 01523 net->retry_count= 1; 01524 net->max_packet_size= max(net_buffer_length, max_allowed_packet); 01525 }
| sig_handler my_pipe_sig_handler | ( | int sig | __attribute__((unused)) | ) |
Definition at line 300 of file libmysql.c.
References DBUG_PRINT, my_pipe_sig_handler(), sig(), and SIGPIPE.
00301 { 00302 DBUG_PRINT("info",("Hit by signal %d",sig)); 00303 #ifdef DONT_REMEMBER_SIGNAL 00304 (void) signal(SIGPIPE, my_pipe_sig_handler); 00305 #endif 00306 }
Here is the call graph for this function:

| sig_handler my_pipe_sig_handler | ( | int | sig | ) |
Definition at line 1786 of file libmysql.c.
References st_net::buff, DBUG_ENTER, DBUG_RETURN, st_net::max_packet, net_realloc(), and st_net::write_pos.
Referenced by cli_stmt_execute(), and store_param().
01787 { 01788 ulong buf_length= (ulong) (net->write_pos - net->buff); 01789 my_bool res=0; 01790 DBUG_ENTER("my_realloc_str"); 01791 if (buf_length + length > net->max_packet) 01792 { 01793 res= net_realloc(net, buf_length + length); 01794 net->write_pos= net->buff+ buf_length; 01795 } 01796 DBUG_RETURN(res); 01797 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void STDCALL myodbc_remove_escape | ( | MYSQL * | mysql, | |
| char * | name | |||
| ) |
Definition at line 1656 of file libmysql.c.
References st_mysql::charset, LINT_INIT, my_ismbchar, mysql, USE_MB, and use_mb.
01657 { 01658 char *to; 01659 #ifdef USE_MB 01660 my_bool use_mb_flag=use_mb(mysql->charset); 01661 char *end; 01662 LINT_INIT(end); 01663 if (use_mb_flag) 01664 for (end=name; *end ; end++) ; 01665 #endif 01666 01667 for (to=name ; *name ; name++) 01668 { 01669 #ifdef USE_MB 01670 int l; 01671 if (use_mb_flag && (l = my_ismbchar( mysql->charset, name , end ) ) ) 01672 { 01673 while (l--) 01674 *to++ = *name++; 01675 name--; 01676 continue; 01677 } 01678 #endif 01679 if (*name == '\\' && name[1]) 01680 name++; 01681 *to++= *name; 01682 } 01683 *to=0; 01684 }
| int STDCALL mysql_add_slave | ( | MYSQL * | mysql, | |
| const char * | host, | |||
| unsigned int | port, | |||
| const char * | user, | |||
| const char * | passwd | |||
| ) |
Definition at line 1095 of file libmysql.c.
References mysql, st_mysql::next_slave, and spawn_init().
01099 { 01100 MYSQL* slave; 01101 if (!(slave = spawn_init(mysql, host, port, user, passwd))) 01102 return 1; 01103 slave->next_slave = mysql->next_slave; 01104 mysql->next_slave = slave; 01105 return 0; 01106 }
Here is the call graph for this function:

| my_ulonglong STDCALL mysql_affected_rows | ( | MYSQL * | mysql | ) |
Definition at line 1440 of file libmysql.c.
References st_mysql::affected_rows, st_mysql::last_used_con, and mysql.
01441 { 01442 return mysql->last_used_con->affected_rows; 01443 }
Definition at line 5109 of file libmysql.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, mysql, and mysql_real_query().
05110 { 05111 DBUG_ENTER("mysql_autocommit"); 05112 DBUG_PRINT("enter", ("mode : %d", auto_mode)); 05113 05114 DBUG_RETURN((my_bool) mysql_real_query(mysql, auto_mode ? 05115 "set autocommit=1":"set autocommit=0", 05116 16)); 05117 }
Here is the call graph for this function:

| my_bool STDCALL mysql_change_user | ( | MYSQL * | mysql, | |
| const char * | user, | |||
| const char * | passwd, | |||
| const char * | db | |||
| ) |
Definition at line 670 of file libmysql.c.
References CLIENT_SECURE_CONNECTION, COM_CHANGE_USER, st_mysql::db, DBUG_ENTER, DBUG_RETURN, st_mysql::methods, MY_ALLOW_ZERO_PTR, my_free, my_strdup(), MY_WME, MYF, mysql, mysql_detach_stmt_list(), st_mysql::passwd, st_mysql_methods::read_change_user_result, st_mysql::scramble, scramble(), scramble_323(), SCRAMBLE_LENGTH, SCRAMBLE_LENGTH_323, st_mysql::server_capabilities, simple_command, st_mysql::stmts, strmov(), and st_mysql::user.
00672 { 00673 char buff[512],*end=buff; 00674 int rc; 00675 DBUG_ENTER("mysql_change_user"); 00676 00677 if (!user) 00678 user=""; 00679 if (!passwd) 00680 passwd=""; 00681 00682 /* Store user into the buffer */ 00683 end=strmov(end,user)+1; 00684 00685 /* write scrambled password according to server capabilities */ 00686 if (passwd[0]) 00687 { 00688 if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION) 00689 { 00690 *end++= SCRAMBLE_LENGTH; 00691 scramble(end, mysql->scramble, passwd); 00692 end+= SCRAMBLE_LENGTH; 00693 } 00694 else 00695 { 00696 scramble_323(end, mysql->scramble, passwd); 00697 end+= SCRAMBLE_LENGTH_323 + 1; 00698 } 00699 } 00700 else 00701 *end++= '\0'; /* empty password */ 00702 /* Add database if needed */ 00703 end= strmov(end, db ? db : "") + 1; 00704 00705 /* Write authentication package */ 00706 simple_command(mysql,COM_CHANGE_USER, buff,(ulong) (end-buff),1); 00707 00708 rc= (*mysql->methods->read_change_user_result)(mysql, buff, passwd); 00709 00710 /* 00711 The server will close all statements no matter was the attempt 00712 to change user successful or not. 00713 */ 00714 mysql_detach_stmt_list(&mysql->stmts); 00715 if (rc == 0) 00716 { 00717 /* Free old connect information */ 00718 my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR)); 00719 my_free(mysql->passwd,MYF(MY_ALLOW_ZERO_PTR)); 00720 my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR)); 00721 00722 /* alloc new connect information */ 00723 mysql->user= my_strdup(user,MYF(MY_WME)); 00724 mysql->passwd=my_strdup(passwd,MYF(MY_WME)); 00725 mysql->db= db ? my_strdup(db,MYF(MY_WME)) : 0; 00726 } 00727 DBUG_RETURN(rc); 00728 }
Here is the call graph for this function:

| const char* STDCALL mysql_character_set_name | ( | MYSQL * | mysql | ) |
Definition at line 1470 of file libmysql.c.
References st_mysql::charset, charset_info_st::csname, and mysql.
Definition at line 5088 of file libmysql.c.
References DBUG_ENTER, DBUG_RETURN, mysql, and mysql_real_query().
05089 { 05090 DBUG_ENTER("mysql_commit"); 05091 DBUG_RETURN((my_bool) mysql_real_query(mysql, "commit", 6)); 05092 }
Here is the call graph for this function:

| void STDCALL mysql_data_seek | ( | MYSQL_RES * | result, | |
| my_ulonglong | row | |||
| ) |
Definition at line 1126 of file libmysql.c.
References st_mysql_res::current_row, st_mysql_data::data, st_mysql_res::data, st_mysql_res::data_cursor, DBUG_PRINT, and st_mysql_rows::next.
01127 { 01128 MYSQL_ROWS *tmp=0; 01129 DBUG_PRINT("info",("mysql_data_seek(%ld)",(long) row)); 01130 if (result->data) 01131 for (tmp=result->data->data; row-- && tmp ; tmp = tmp->next) ; 01132 result->current_row=0; 01133 result->data_cursor = tmp; 01134 }
| void STDCALL mysql_debug | ( | const char *debug | __attribute__((unused)) | ) |
Definition at line 265 of file libmysql.c.
References DBUG_PUSH, debug, getenv(), NullS, and strxnmov().
00266 { 00267 #ifndef DBUG_OFF 00268 char *env; 00269 if (debug) 00270 { 00271 DBUG_PUSH(debug); 00272 } 00273 else if ((env = getenv("MYSQL_DEBUG"))) 00274 { 00275 DBUG_PUSH(env); 00276 #if !defined(_WINVER) && !defined(WINVER) 00277 puts("\n-------------------------------------------------------"); 00278 puts("MYSQL_DEBUG found. libmysql started with the following:"); 00279 puts(env); 00280 puts("-------------------------------------------------------\n"); 00281 #else 00282 { 00283 char buff[80]; 00284 buff[sizeof(buff)-1]= 0; 00285 strxnmov(buff,sizeof(buff)-1,"libmysql: ", env, NullS); 00286 MessageBox((HWND) 0,"Debugging variable MYSQL_DEBUG used",buff,MB_OK); 00287 } 00288 #endif 00289 } 00290 #endif 00291 }
Here is the call graph for this function:

| void STDCALL mysql_disable_reads_from_master | ( | MYSQL * | mysql | ) |
Definition at line 389 of file libmysql.c.
References mysql, st_mysql_options::no_master_reads, and st_mysql::options.
00390 { 00391 mysql->options.no_master_reads = 1; 00392 }
| void STDCALL mysql_disable_rpl_parse | ( | MYSQL * | mysql | ) |
Definition at line 372 of file libmysql.c.
References mysql, st_mysql::options, and st_mysql_options::rpl_parse.
| int STDCALL mysql_dump_debug_info | ( | MYSQL * | mysql | ) |
Definition at line 1334 of file libmysql.c.
References COM_DEBUG, DBUG_ENTER, DBUG_RETURN, mysql, and simple_command.
01335 { 01336 DBUG_ENTER("mysql_dump_debug_info"); 01337 DBUG_RETURN(simple_command(mysql,COM_DEBUG,0,0,0)); 01338 }
| my_bool STDCALL mysql_embedded | ( | void | ) |
Definition at line 1501 of file libmysql.c.
01502 { 01503 #ifdef EMBEDDED_LIBRARY 01504 return 1; 01505 #else 01506 return 0; 01507 #endif 01508 }
| void STDCALL mysql_enable_reads_from_master | ( | MYSQL * | mysql | ) |
Definition at line 384 of file libmysql.c.
References mysql, st_mysql_options::no_master_reads, and st_mysql::options.
00385 { 00386 mysql->options.no_master_reads = 0; 00387 }
| void STDCALL mysql_enable_rpl_parse | ( | MYSQL * | mysql | ) |
Definition at line 367 of file libmysql.c.
References mysql, st_mysql::options, and st_mysql_options::rpl_parse.
Definition at line 1408 of file libmysql.c.
References st_mysql_res::eof.
01409 { 01410 return res->eof; 01411 }
Definition at line 1569 of file libmysql.c.
References default_charset_info, and escape_string_for_mysql().
01570 { 01571 return escape_string_for_mysql(default_charset_info, to, 0, from, length); 01572 }
Here is the call graph for this function:

| MYSQL_FIELD* STDCALL mysql_fetch_field | ( | MYSQL_RES * | result | ) |
Definition at line 1113 of file libmysql.c.
References st_mysql_res::current_field, st_mysql_res::field_count, st_mysql_res::fields, and NULL.
01114 { 01115 if (result->current_field >= result->field_count) 01116 return(NULL); 01117 return &result->fields[result->current_field++]; 01118 }
| MYSQL_FIELD* STDCALL mysql_fetch_field_direct | ( | MYSQL_RES * | res, | |
| uint | fieldnr | |||
| ) |
| MYSQL_FIELD* STDCALL mysql_fetch_fields | ( | MYSQL_RES * | res | ) |
| unsigned int STDCALL mysql_field_count | ( | MYSQL * | mysql | ) |
Definition at line 1435 of file libmysql.c.
References st_mysql::field_count, st_mysql::last_used_con, and mysql.
01436 { 01437 return mysql->last_used_con->field_count; 01438 }
| MYSQL_FIELD_OFFSET STDCALL mysql_field_seek | ( | MYSQL_RES * | result, | |
| MYSQL_FIELD_OFFSET | field_offset | |||
| ) |
Definition at line 1154 of file libmysql.c.
References st_mysql_res::current_field.
01155 { 01156 MYSQL_FIELD_OFFSET return_value=result->current_field; 01157 result->current_field=field_offset; 01158 return return_value; 01159 }
| MYSQL_FIELD_OFFSET STDCALL mysql_field_tell | ( | MYSQL_RES * | res | ) |
| void STDCALL mysql_get_character_set_info | ( | MYSQL * | mysql, | |
| MY_CHARSET_INFO * | csinfo | |||
| ) |
Definition at line 1475 of file libmysql.c.
References st_mysql::charset, st_mysql_options::charset_dir, charsets_dir, charset_info_st::comment, character_set::comment, charset_info_st::csname, character_set::csname, character_set::dir, charset_info_st::mbmaxlen, character_set::mbmaxlen, charset_info_st::mbminlen, character_set::mbminlen, mysql, charset_info_st::name, character_set::name, charset_info_st::number, character_set::number, st_mysql::options, charset_info_st::state, and character_set::state.
01476 { 01477 csinfo->number = mysql->charset->number; 01478 csinfo->state = mysql->charset->state; 01479 csinfo->csname = mysql->charset->csname; 01480 csinfo->name = mysql->charset->name; 01481 csinfo->comment = mysql->charset->comment; 01482 csinfo->mbminlen = mysql->charset->mbminlen; 01483 csinfo->mbmaxlen = mysql->charset->mbmaxlen; 01484 01485 if (mysql->options.charset_dir) 01486 csinfo->dir = mysql->options.charset_dir; 01487 else 01488 csinfo->dir = charsets_dir; 01489 }
| const char* STDCALL mysql_get_client_info | ( | void | ) |
Definition at line 1398 of file libmysql.c.
References MYSQL_SERVER_VERSION.
01399 { 01400 return (char*) MYSQL_SERVER_VERSION; 01401 }
| ulong STDCALL mysql_get_client_version | ( | void | ) |
Definition at line 1403 of file libmysql.c.
References MYSQL_VERSION_ID.
01404 { 01405 return MYSQL_VERSION_ID; 01406 }
| const char* STDCALL mysql_get_host_info | ( | MYSQL * | mysql | ) |
| MYSQL_PARAMETERS* STDCALL mysql_get_parameters | ( | void | ) |
Definition at line 203 of file libmysql.c.
References mysql_internal_parameters.
00204 { 00205 return &mysql_internal_parameters; 00206 }
Definition at line 1392 of file libmysql.c.
References mysql, and st_mysql::protocol_version.
01393 { 01394 return (mysql->protocol_version); 01395 }
| const char* STDCALL mysql_get_server_info | ( | MYSQL * | mysql | ) |
Definition at line 1378 of file libmysql.c.
References mysql, and st_mysql::server_version.
01379 { 01380 return((char*) mysql->server_version); 01381 }
Definition at line 1548 of file libmysql.c.
References _dig_vec_upper.
01549 { 01550 char *to0= to; 01551 const char *end; 01552 01553 for (end= from + length; from < end; from++) 01554 { 01555 *to++= _dig_vec_upper[((unsigned char) *from) >> 4]; 01556 *to++= _dig_vec_upper[((unsigned char) *from) & 0x0F]; 01557 } 01558 *to= '\0'; 01559 return (ulong) (to-to0); 01560 }
| const char* STDCALL mysql_info | ( | MYSQL * | mysql | ) |
| my_ulonglong STDCALL mysql_insert_id | ( | MYSQL * | mysql | ) |
Definition at line 1445 of file libmysql.c.
References st_mysql::insert_id, st_mysql::last_used_con, and mysql.
01446 { 01447 return mysql->last_used_con->insert_id; 01448 }
Definition at line 1314 of file libmysql.c.
References COM_PROCESS_KILL, DBUG_ENTER, DBUG_RETURN, int4store, mysql, and simple_command.
01315 { 01316 char buff[4]; 01317 DBUG_ENTER("mysql_kill"); 01318 int4store(buff,pid); 01319 DBUG_RETURN(simple_command(mysql,COM_PROCESS_KILL,buff,sizeof(buff),0)); 01320 }
Definition at line 1167 of file libmysql.c.
References append_wild(), DBUG_ENTER, DBUG_RETURN, mysql, mysql_query(), mysql_store_result(), and strmov().
01168 { 01169 char buff[255]; 01170 DBUG_ENTER("mysql_list_dbs"); 01171 01172 append_wild(strmov(buff,"show databases"),buff+sizeof(buff),wild); 01173 if (mysql_query(mysql,buff)) 01174 DBUG_RETURN(0); 01175 DBUG_RETURN (mysql_store_result(mysql)); 01176 }
Here is the call graph for this function:

Definition at line 1218 of file libmysql.c.
References COM_FIELD_LIST, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_mysql_res::eof, st_mysql::field_alloc, st_mysql_res::field_alloc, st_mysql::field_count, st_mysql_res::field_count, st_mysql_res::fields, st_mysql::fields, free_old_query(), st_mysql_methods::list_fields, st_mysql_res::methods, st_mysql::methods, my_malloc(), MY_WME, MY_ZEROFILL, MYF, mysql, NULL, simple_command, and strmake().
01219 { 01220 MYSQL_RES *result; 01221 MYSQL_FIELD *fields; 01222 char buff[257],*end; 01223 DBUG_ENTER("mysql_list_fields"); 01224 DBUG_PRINT("enter",("table: '%s' wild: '%s'",table,wild ? wild : "")); 01225 01226 end=strmake(strmake(buff, table,128)+1,wild ? wild : "",128); 01227 free_old_query(mysql); 01228 if (simple_command(mysql,COM_FIELD_LIST,buff,(ulong) (end-buff),1) || 01229 !(fields= (*mysql->methods->list_fields)(mysql))) 01230 DBUG_RETURN(NULL); 01231 01232 if (!(result = (MYSQL_RES *) my_malloc(sizeof(MYSQL_RES), 01233 MYF(MY_WME | MY_ZEROFILL)))) 01234 DBUG_RETURN(NULL); 01235 01236 result->methods= mysql->methods; 01237 result->field_alloc=mysql->field_alloc; 01238 mysql->fields=0; 01239 result->field_count = mysql->field_count; 01240 result->fields= fields; 01241 result->eof=1; 01242 DBUG_RETURN(result); 01243 }
Here is the call graph for this function:

Definition at line 1248 of file libmysql.c.
References COM_PROCESS_INFO, DBUG_ENTER, DBUG_RETURN, st_mysql::field_alloc, st_mysql::field_count, st_mysql::fields, free_old_query(), LINT_INIT, st_mysql::methods, mysql, MYSQL_STATUS_GET_RESULT, mysql_store_result(), st_mysql::net, net_field_length(), NULL, pos(), protocol_41, st_net::read_pos, st_mysql_methods::read_rows, st_mysql::server_capabilities, simple_command, st_mysql::status, and unpack_fields().
01249 { 01250 MYSQL_DATA *fields; 01251 uint field_count; 01252 uchar *pos; 01253 DBUG_ENTER("mysql_list_processes"); 01254 01255 LINT_INIT(fields); 01256 if (simple_command(mysql,COM_PROCESS_INFO,0,0,0)) 01257 DBUG_RETURN(0); 01258 free_old_query(mysql); 01259 pos=(uchar*) mysql->net.read_pos; 01260 field_count=(uint) net_field_length(&pos); 01261 if (!(fields = (*mysql->methods->read_rows)(mysql,(MYSQL_FIELD*) 0, 01262 protocol_41(mysql) ? 7 : 5))) 01263 DBUG_RETURN(NULL); 01264 if (!(mysql->fields=unpack_fields(fields,&mysql->field_alloc,field_count,0, 01265 mysql->server_capabilities))) 01266 DBUG_RETURN(0); 01267 mysql->status=MYSQL_STATUS_GET_RESULT; 01268 mysql->field_count=field_count; 01269 DBUG_RETURN(mysql_store_result(mysql)); 01270 }
Here is the call graph for this function:

Definition at line 1185 of file libmysql.c.
References append_wild(), DBUG_ENTER, DBUG_RETURN, mysql, mysql_query(), mysql_store_result(), and strmov().
01186 { 01187 char buff[255]; 01188 DBUG_ENTER("mysql_list_tables"); 01189 01190 append_wild(strmov(buff,"show tables"),buff+sizeof(buff),wild); 01191 if (mysql_query(mysql,buff)) 01192 DBUG_RETURN(0); 01193 DBUG_RETURN (mysql_store_result(mysql)); 01194 }
Here is the call graph for this function:

Definition at line 309 of file libmysql.c.
References DBUG_ENTER, DBUG_RETURN, st_mysql::methods, mysql, mysql_master_send_query, and st_mysql_methods::read_query_result.
00311 { 00312 DBUG_ENTER("mysql_master_query"); 00313 if (mysql_master_send_query(mysql, q, length)) 00314 DBUG_RETURN(1); 00315 DBUG_RETURN((*mysql->methods->read_query_result)(mysql)); 00316 }
Definition at line 318 of file libmysql.c.
References COM_QUERY, DBUG_ENTER, DBUG_RETURN, st_mysql::last_used_con, st_mysql::master, mysql, mysql_real_connect(), st_mysql::net, st_mysql::reconnect, simple_command, and st_net::vio.
00320 { 00321 MYSQL *master = mysql->master; 00322 DBUG_ENTER("mysql_master_send_query"); 00323 if (!master->net.vio && !mysql_real_connect(master,0,0,0,0,0,0,0)) 00324 DBUG_RETURN(1); 00325 master->reconnect= 1; 00326 mysql->last_used_con = master; 00327 DBUG_RETURN(simple_command(master, COM_QUERY, q, length, 1)); 00328 }
Here is the call graph for this function:

Definition at line 5129 of file libmysql.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_mysql::last_used_con, mysql, SERVER_MORE_RESULTS_EXISTS, and st_mysql::server_status.
05130 { 05131 my_bool res; 05132 DBUG_ENTER("mysql_more_results"); 05133 05134 res= ((mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS) ? 05135 1: 0); 05136 DBUG_PRINT("exit",("More results exists ? %d", res)); 05137 DBUG_RETURN(res); 05138 }
| int STDCALL mysql_next_result | ( | MYSQL * | mysql | ) |
Definition at line 5144 of file libmysql.c.
References st_mysql::affected_rows, CR_COMMANDS_OUT_OF_SYNC, DBUG_ENTER, DBUG_RETURN, ER, st_net::last_errno, st_net::last_error, st_mysql::last_used_con, st_mysql::methods, mysql, MYSQL_STATUS_READY, st_mysql::net, st_mysql_methods::next_result, not_error_sqlstate, SERVER_MORE_RESULTS_EXISTS, st_mysql::server_status, st_net::sqlstate, st_mysql::status, strmov(), and unknown_sqlstate.
05145 { 05146 DBUG_ENTER("mysql_next_result"); 05147 05148 if (mysql->status != MYSQL_STATUS_READY) 05149 { 05150 strmov(mysql->net.sqlstate, unknown_sqlstate); 05151 strmov(mysql->net.last_error, 05152 ER(mysql->net.last_errno=CR_COMMANDS_OUT_OF_SYNC)); 05153 DBUG_RETURN(1); 05154 } 05155 05156 mysql->net.last_error[0]= 0; 05157 mysql->net.last_errno= 0; 05158 strmov(mysql->net.sqlstate, not_error_sqlstate); 05159 mysql->affected_rows= ~(my_ulonglong) 0; 05160 05161 if (mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS) 05162 DBUG_RETURN((*mysql->methods->next_result)(mysql)); 05163 05164 DBUG_RETURN(-1); /* No more results */ 05165 }
Here is the call graph for this function:

| char* STDCALL mysql_odbc_escape_string | ( | MYSQL * | mysql, | |
| char * | to, | |||
| ulong | to_length, | |||
| const char * | from, | |||
| ulong | from_length, | |||
| void * | param, | |||
| char *(*)(void *, char *, ulong *) | extend_buffer | |||
| ) |
Definition at line 1585 of file libmysql.c.
References st_mysql::charset, my_ismbchar, mysql, and use_mb.
01591 { 01592 char *to_end=to+to_length-5; 01593 const char *end; 01594 #ifdef USE_MB 01595 my_bool use_mb_flag=use_mb(mysql->charset); 01596 #endif 01597 01598 for (end=from+from_length; from != end ; from++) 01599 { 01600 if (to >= to_end) 01601 { 01602 to_length = (ulong) (end-from)+512; /* We want this much more */ 01603 if (!(to=(*extend_buffer)(param, to, &to_length))) 01604 return to; 01605 to_end=to+to_length-5; 01606 } 01607 #ifdef USE_MB 01608 { 01609 int l; 01610 if (use_mb_flag && (l = my_ismbchar(mysql->charset, from, end))) 01611 { 01612 while (l--) 01613 *to++ = *from++; 01614 from--; 01615 continue; 01616 } 01617 } 01618 #endif 01619 switch (*from) { 01620 case 0: /* Must be escaped for 'mysql' */ 01621 *to++= '\\'; 01622 *to++= '0'; 01623 break; 01624 case '\n': /* Must be escaped for logs */ 01625 *to++= '\\'; 01626 *to++= 'n'; 01627 break; 01628 case '\r': 01629 *to++= '\\'; 01630 *to++= 'r'; 01631 break; 01632 case '\\': 01633 *to++= '\\'; 01634 *to++= '\\'; 01635 break; 01636 case '\'': 01637 *to++= '\\'; 01638 *to++= '\''; 01639 break; 01640 case '"': /* Better safe than sorry */ 01641 *to++= '\\'; 01642 *to++= '"'; 01643 break; 01644 case '\032': /* This gives problems on Win32 */ 01645 *to++= '\\'; 01646 *to++= 'Z'; 01647 break; 01648 default: 01649 *to++= *from; 01650 } 01651 } 01652 return to; 01653 }
| int STDCALL mysql_ping | ( | MYSQL * | mysql | ) |
Definition at line 1366 of file libmysql.c.
References COM_PING, CR_SERVER_LOST, DBUG_ENTER, DBUG_RETURN, mysql, st_mysql::reconnect, and simple_command.
01367 { 01368 int res; 01369 DBUG_ENTER("mysql_ping"); 01370 res= simple_command(mysql,COM_PING,0,0,0); 01371 if (res == CR_SERVER_LOST && mysql->reconnect) 01372 res= simple_command(mysql,COM_PING,0,0,0); 01373 DBUG_RETURN(res); 01374 }
| int STDCALL mysql_query | ( | MYSQL * | mysql, | |
| const char * | query | |||
| ) |
Definition at line 1040 of file libmysql.c.
References mysql, mysql_real_query(), and strlen().
Here is the call graph for this function:

Definition at line 5173 of file libmysql.c.
References st_mysql::methods, mysql, and st_mysql_methods::read_query_result.
05174 { 05175 return (*mysql->methods->read_query_result)(mysql); 05176 }
Definition at line 395 of file libmysql.c.
References mysql, st_mysql_options::no_master_reads, and st_mysql::options.
00396 { 00397 return !(mysql->options.no_master_reads); 00398 }
| ulong STDCALL mysql_real_escape_string | ( | MYSQL * | mysql, | |
| char * | to, | |||
| const char * | from, | |||
| ulong | length | |||
| ) |
Definition at line 1575 of file libmysql.c.
References st_mysql::charset, escape_quotes_for_mysql(), escape_string_for_mysql(), mysql, st_mysql::server_status, and SERVER_STATUS_NO_BACKSLASH_ESCAPES.
01577 { 01578 if (mysql->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES) 01579 return escape_quotes_for_mysql(mysql->charset, to, 0, from, length); 01580 return escape_string_for_mysql(mysql->charset, to, 0, from, length); 01581 }
Here is the call graph for this function:

Definition at line 1304 of file libmysql.c.
References COM_REFRESH, DBUG_ENTER, DBUG_RETURN, mysql, and simple_command.
01305 { 01306 uchar bits[1]; 01307 DBUG_ENTER("mysql_refresh"); 01308 bits[0]= (uchar) options; 01309 DBUG_RETURN(simple_command(mysql,COM_REFRESH,(char*) bits,1,0)); 01310 }
Definition at line 5098 of file libmysql.c.
References DBUG_ENTER, DBUG_RETURN, mysql, and mysql_real_query().
05099 { 05100 DBUG_ENTER("mysql_rollback"); 05101 DBUG_RETURN((my_bool) mysql_real_query(mysql, "rollback", 8)); 05102 }
Here is the call graph for this function:

| MYSQL_ROW_OFFSET STDCALL mysql_row_seek | ( | MYSQL_RES * | result, | |
| MYSQL_ROW_OFFSET | row | |||
| ) |
Definition at line 1144 of file libmysql.c.
References st_mysql_res::current_row, and st_mysql_res::data_cursor.
01145 { 01146 MYSQL_ROW_OFFSET return_value=result->data_cursor; 01147 result->current_row= 0; 01148 result->data_cursor= row; 01149 return return_value; 01150 }
| MYSQL_ROW_OFFSET STDCALL mysql_row_tell | ( | MYSQL_RES * | res | ) |
Definition at line 1423 of file libmysql.c.
References st_mysql_res::data_cursor.
01424 { 01425 return res->data_cursor; 01426 }
| int STDCALL mysql_rpl_parse_enabled | ( | MYSQL * | mysql | ) |
Definition at line 378 of file libmysql.c.
References mysql, st_mysql::options, and st_mysql_options::rpl_parse.
Definition at line 512 of file libmysql.c.
References CR_PROBE_SLAVE_STATUS, DBUG_ENTER, DBUG_RETURN, err, error, expand_error(), get_master(), get_slaves_from_master(), st_mysql::master, mysql, mysql_fetch_row(), mysql_free_result(), mysql_query(), and mysql_store_result().
00513 { 00514 MYSQL_RES *res= 0; 00515 MYSQL_ROW row; 00516 my_bool error= 1; 00517 DBUG_ENTER("mysql_rpl_probe"); 00518 00519 /* 00520 First determine the replication role of the server we connected to 00521 the most reliable way to do this is to run SHOW SLAVE STATUS and see 00522 if we have a non-empty master host. This is still not fool-proof - 00523 it is not a sin to have a master that has a dormant slave thread with 00524 a non-empty master host. However, it is more reliable to check 00525 for empty master than whether the slave thread is actually running 00526 */ 00527 if (mysql_query(mysql, "SHOW SLAVE STATUS") || 00528 !(res = mysql_store_result(mysql))) 00529 { 00530 expand_error(mysql, CR_PROBE_SLAVE_STATUS); 00531 DBUG_RETURN(1); 00532 } 00533 00534 row= mysql_fetch_row(res); 00535 /* 00536 Check master host for emptiness/NULL 00537 For MySQL 4.0 it's enough to check for row[0] 00538 */ 00539 if (row && row[0] && *(row[0])) 00540 { 00541 /* this is a slave, ask it for the master */ 00542 if (get_master(mysql, res, row) || get_slaves_from_master(mysql)) 00543 goto err; 00544 } 00545 else 00546 { 00547 mysql->master = mysql; 00548 if (get_slaves_from_master(mysql)) 00549 goto err; 00550 } 00551 00552 error = 0; 00553 err: 00554 if (res) 00555 mysql_free_result(res); 00556 DBUG_RETURN(error); 00557 }
Here is the call graph for this function:

| enum mysql_rpl_type STDCALL mysql_rpl_query_type | ( | const char * | q, | |
| int | len | |||
| ) |
Definition at line 573 of file libmysql.c.
References my_charset_latin1, my_isalpha, my_tolower, MYSQL_RPL_ADMIN, MYSQL_RPL_MASTER, and MYSQL_RPL_SLAVE.
00574 { 00575 const char *q_end= q + len; 00576 for (; q < q_end; ++q) 00577 { 00578 char c; 00579 if (my_isalpha(&my_charset_latin1, (c= *q))) 00580 { 00581 switch (my_tolower(&my_charset_latin1,c)) { 00582 case 'i': /* insert */ 00583 case 'u': /* update or unlock tables */ 00584 case 'l': /* lock tables or load data infile */ 00585 case 'd': /* drop or delete */ 00586 case 'a': /* alter */ 00587 return MYSQL_RPL_MASTER; 00588 case 'c': /* create or check */ 00589 return my_tolower(&my_charset_latin1,q[1]) == 'h' ? MYSQL_RPL_ADMIN : 00590 MYSQL_RPL_MASTER; 00591 case 's': /* select or show */ 00592 return my_tolower(&my_charset_latin1,q[1]) == 'h' ? MYSQL_RPL_ADMIN : 00593 MYSQL_RPL_SLAVE; 00594 case 'f': /* flush */ 00595 case 'r': /* repair */ 00596 case 'g': /* grant */ 00597 return MYSQL_RPL_ADMIN; 00598 default: 00599 return MYSQL_RPL_SLAVE; 00600 } 00601 } 00602 } 00603 return MYSQL_RPL_MASTER; /* By default, send to master */ 00604 }
| void STDCALL mysql_server_end | ( | void | ) |
Definition at line 173 of file libmysql.c.
References DBUG_POP, finish_client_errs(), free_charsets(), MY_DONT_FREE_DBUG, my_end(), mysql_client_init, mysql_thread_end(), org_my_init_done, stderror_file, and vio_end().
00174 { 00175 #ifdef EMBEDDED_LIBRARY 00176 end_embedded_server(); 00177 #endif 00178 /* If library called my_init(), free memory allocated by it */ 00179 if (!org_my_init_done) 00180 { 00181 my_end(MY_DONT_FREE_DBUG); 00182 /* Remove TRACING, if enabled by mysql_debug() */ 00183 DBUG_POP(); 00184 } 00185 else 00186 mysql_thread_end(); 00187 finish_client_errs(); 00188 free_charsets(); 00189 vio_end(); 00190 mysql_client_init= org_my_init_done= 0; 00191 #ifdef EMBEDDED_SERVER 00192 if (stderror_file) 00193 { 00194 fclose(stderror_file); 00195 stderror_file= 0; 00196 } 00197 #endif 00198 }
Here is the call graph for this function:

| int STDCALL mysql_server_init | ( | int argc | __attribute__((unused)), | |
| char **argv | __attribute__((unused)), | |||
| char **groups | __attribute__((unused)) | |||
| ) |
Definition at line 119 of file libmysql.c.
References atoi(), getenv(), init_client_errs(), int(), my_init(), my_init_done, my_thread_init(), mysql_client_init, mysql_debug(), MYSQL_PORT, mysql_port, MYSQL_UNIX_ADDR, mysql_unix_port, NullS, org_my_init_done, and SIGPIPE.
00122 { 00123 int result= 0; 00124 if (!mysql_client_init) 00125 { 00126 mysql_client_init=1; 00127 org_my_init_done=my_init_done; 00128 if (my_init()) /* Will init threads */ 00129 return 1; 00130 init_client_errs(); 00131 if (!mysql_port) 00132 { 00133 mysql_port = MYSQL_PORT; 00134 #ifndef MSDOS 00135 { 00136 struct servent *serv_ptr; 00137 char *env; 00138 if ((serv_ptr = getservbyname("mysql", "tcp"))) 00139 mysql_port = (uint) ntohs((ushort) serv_ptr->s_port); 00140 if ((env = getenv("MYSQL_TCP_PORT"))) 00141 mysql_port =(uint) atoi(env); 00142 } 00143 #endif 00144 } 00145 if (!mysql_unix_port) 00146 { 00147 char *env; 00148 #ifdef __WIN__ 00149 mysql_unix_port = (char*) MYSQL_NAMEDPIPE; 00150 #else 00151 mysql_unix_port = (char*) MYSQL_UNIX_ADDR; 00152 #endif 00153 if ((env = getenv("MYSQL_UNIX_PORT"))) 00154 mysql_unix_port = env; 00155 } 00156 mysql_debug(NullS); 00157 #if defined(SIGPIPE) && !defined(__WIN__) && !defined(__NETWARE__) 00158 (void) signal(SIGPIPE, SIG_IGN); 00159 #endif 00160 #ifdef EMBEDDED_LIBRARY 00161 if (argc > -1) 00162 result= init_embedded_server(argc, argv, groups); 00163 #endif 00164 } 00165 #ifdef THREAD 00166 else 00167 result= (int)my_thread_init(); /* Init if new thread */ 00168 #endif 00169 return result; 00170 }
Here is the call graph for this function:

| void mysql_set_local_infile_default | ( | MYSQL * | mysql | ) |
Definition at line 1025 of file libmysql.c.
References default_local_infile_end(), default_local_infile_error(), default_local_infile_init(), default_local_infile_read(), st_mysql_options::local_infile_end, st_mysql_options::local_infile_error, st_mysql_options::local_infile_init, st_mysql_options::local_infile_read, mysql, and st_mysql::options.
01026 { 01027 mysql->options.local_infile_init= default_local_infile_init; 01028 mysql->options.local_infile_read= default_local_infile_read; 01029 mysql->options.local_infile_end= default_local_infile_end; 01030 mysql->options.local_infile_error= default_local_infile_error; 01031 }
Here is the call graph for this function:

| void mysql_set_local_infile_handler | ( | MYSQL * | mysql, | |
| int(*)(void **, const char *, void *) | local_infile_init, | |||
| int(*)(void *, char *, uint) | local_infile_read, | |||
| void(*)(void *) | local_infile_end, | |||
| int(*)(void *, char *, uint) | local_infile_error, | |||
| void * | userdata | |||
| ) |
Definition at line 1009 of file libmysql.c.
References st_mysql_options::local_infile_end, st_mysql_options::local_infile_error, st_mysql_options::local_infile_init, st_mysql_options::local_infile_read, st_mysql_options::local_infile_userdata, mysql, and st_mysql::options.
01016 { 01017 mysql->options.local_infile_init= local_infile_init; 01018 mysql->options.local_infile_read= local_infile_read; 01019 mysql->options.local_infile_end= local_infile_end; 01020 mysql->options.local_infile_error= local_infile_error; 01021 mysql->options.local_infile_userdata = userdata; 01022 }
| int STDCALL mysql_set_master | ( | MYSQL * | mysql, | |
| const char * | host, | |||
| unsigned int | port, | |||
| const char * | user, | |||
| const char * | passwd | |||
| ) |
Definition at line 1082 of file libmysql.c.
References st_mysql::master, mysql, mysql_close(), st_mysql::rpl_pivot, and spawn_init().
01085 { 01086 if (mysql->master != mysql && !mysql->master->rpl_pivot) 01087 mysql_close(mysql->master); 01088 if (!(mysql->master = spawn_init(mysql, host, port, user, passwd))) 01089 return 1; 01090 return 0; 01091 }
Here is the call graph for this function:

| int STDCALL mysql_set_server_option | ( | MYSQL * | mysql, | |
| enum enum_mysql_set_option | option | |||
| ) |
Definition at line 1324 of file libmysql.c.
References COM_SET_OPTION, DBUG_ENTER, DBUG_RETURN, int2store, mysql, and simple_command.
01325 { 01326 char buff[2]; 01327 DBUG_ENTER("mysql_set_server_option"); 01328 int2store(buff, (uint) option); 01329 DBUG_RETURN(simple_command(mysql, COM_SET_OPTION, buff, sizeof(buff), 0)); 01330 }
| int STDCALL mysql_shutdown | ( | MYSQL * | mysql, | |
| enum mysql_enum_shutdown_level | shutdown_level | |||
| ) |
Definition at line 1294 of file libmysql.c.
References COM_SHUTDOWN, DBUG_ENTER, DBUG_RETURN, mysql, and simple_command.
01295 { 01296 uchar level[1]; 01297 DBUG_ENTER("mysql_shutdown"); 01298 level[0]= (uchar) shutdown_level; 01299 DBUG_RETURN(simple_command(mysql, COM_SHUTDOWN, (char *)level, 1, 0)); 01300 }
Definition at line 332 of file libmysql.c.
References DBUG_ENTER, DBUG_RETURN, st_mysql::methods, mysql, mysql_slave_send_query, and st_mysql_methods::read_query_result.
00334 { 00335 DBUG_ENTER("mysql_slave_query"); 00336 if (mysql_slave_send_query(mysql, q, length)) 00337 DBUG_RETURN(1); 00338 DBUG_RETURN((*mysql->methods->read_query_result)(mysql)); 00339 }
Definition at line 342 of file libmysql.c.
References COM_QUERY, DBUG_ENTER, DBUG_RETURN, st_mysql::last_used_con, st_mysql::last_used_slave, mysql, mysql_real_connect(), st_mysql::net, st_mysql::next_slave, st_mysql::reconnect, simple_command, and st_net::vio.
00344 { 00345 MYSQL* last_used_slave, *slave_to_use = 0; 00346 DBUG_ENTER("mysql_slave_send_query"); 00347 00348 if ((last_used_slave = mysql->last_used_slave)) 00349 slave_to_use = last_used_slave->next_slave; 00350 else 00351 slave_to_use = mysql->next_slave; 00352 /* 00353 Next_slave is always safe to use - we have a circular list of slaves 00354 if there are no slaves, mysql->next_slave == mysql 00355 */ 00356 mysql->last_used_con = mysql->last_used_slave = slave_to_use; 00357 if (!slave_to_use->net.vio && !mysql_real_connect(slave_to_use, 0,0,0, 00358 0,0,0,0)) 00359 DBUG_RETURN(1); 00360 slave_to_use->reconnect= 1; 00361 DBUG_RETURN(simple_command(slave_to_use, COM_QUERY, q, length, 1)); 00362 }
Here is the call graph for this function:

| const char* STDCALL mysql_sqlstate | ( | MYSQL * | mysql | ) |
| const char* STDCALL mysql_stat | ( | MYSQL * | mysql | ) |
Definition at line 1356 of file libmysql.c.
References COM_STATISTICS, DBUG_ENTER, DBUG_RETURN, st_net::last_error, st_mysql::methods, mysql, st_mysql::net, st_mysql_methods::read_statistics, and simple_command.
01357 { 01358 DBUG_ENTER("mysql_stat"); 01359 if (simple_command(mysql,COM_STATISTICS,0,0,0)) 01360 return mysql->net.last_error; 01361 DBUG_RETURN((*mysql->methods->read_statistics)(mysql)); 01362 }
| my_ulonglong STDCALL mysql_stmt_affected_rows | ( | MYSQL_STMT * | stmt | ) |
Definition at line 2946 of file libmysql.c.
References st_mysql_stmt::affected_rows.
02947 { 02948 return stmt->affected_rows; 02949 }
| my_bool STDCALL mysql_stmt_attr_get | ( | MYSQL_STMT * | stmt, | |
| enum enum_stmt_attr_type | attr_type, | |||
| void * | value | |||
| ) |
Definition at line 2787 of file libmysql.c.
References FALSE, st_mysql_stmt::flags, st_mysql_stmt::prefetch_rows, STMT_ATTR_CURSOR_TYPE, STMT_ATTR_PREFETCH_ROWS, STMT_ATTR_UPDATE_MAX_LENGTH, TRUE, and st_mysql_stmt::update_max_length.
02790 { 02791 switch (attr_type) { 02792 case STMT_ATTR_UPDATE_MAX_LENGTH: 02793 *(my_bool*) value= stmt->update_max_length; 02794 break; 02795 case STMT_ATTR_CURSOR_TYPE: 02796 *(ulong*) value= stmt->flags; 02797 break; 02798 case STMT_ATTR_PREFETCH_ROWS: 02799 *(ulong*) value= stmt->prefetch_rows; 02800 break; 02801 default: 02802 return TRUE; 02803 } 02804 return FALSE; 02805 }
| my_bool STDCALL mysql_stmt_attr_set | ( | MYSQL_STMT * | stmt, | |
| enum enum_stmt_attr_type | attr_type, | |||
| const void * | value | |||
| ) |
Definition at line 2752 of file libmysql.c.
References CR_NOT_IMPLEMENTED, CURSOR_TYPE_READ_ONLY, DEFAULT_PREFETCH_ROWS, FALSE, st_mysql_stmt::flags, st_mysql_stmt::prefetch_rows, set_stmt_error(), STMT_ATTR_CURSOR_TYPE, STMT_ATTR_PREFETCH_ROWS, STMT_ATTR_UPDATE_MAX_LENGTH, TRUE, unknown_sqlstate, and st_mysql_stmt::update_max_length.
02755 { 02756 switch (attr_type) { 02757 case STMT_ATTR_UPDATE_MAX_LENGTH: 02758 stmt->update_max_length= value ? *(const my_bool*) value : 0; 02759 break; 02760 case STMT_ATTR_CURSOR_TYPE: 02761 { 02762 ulong cursor_type; 02763 cursor_type= value ? *(ulong*) value : 0UL; 02764 if (cursor_type > (ulong) CURSOR_TYPE_READ_ONLY) 02765 goto err_not_implemented; 02766 stmt->flags= cursor_type; 02767 break; 02768 } 02769 case STMT_ATTR_PREFETCH_ROWS: 02770 { 02771 ulong prefetch_rows= value ? *(ulong*) value : DEFAULT_PREFETCH_ROWS; 02772 if (value == 0) 02773 return TRUE; 02774 stmt->prefetch_rows= prefetch_rows; 02775 break; 02776 } 02777 default: 02778 goto err_not_implemented; 02779 } 02780 return FALSE; 02781 err_not_implemented: 02782 set_stmt_error(stmt, CR_NOT_IMPLEMENTED, unknown_sqlstate); 02783 return TRUE; 02784 }
Here is the call graph for this function:

| my_bool STDCALL mysql_stmt_bind_param | ( | MYSQL_STMT * | stmt, | |
| MYSQL_BIND * | bind | |||
| ) |
Definition at line 3156 of file libmysql.c.
References st_mysql_stmt::bind_param_done, st_mysql_bind::buffer_length, st_mysql_bind::buffer_type, count, CR_NO_PREPARE_STMT, CR_UNSUPPORTED_PARAM_TYPE, DBUG_ENTER, DBUG_RETURN, ER, st_mysql_bind::is_null, st_mysql_stmt::last_errno, st_mysql_stmt::last_error, st_mysql_bind::length, st_mysql_bind::long_data_used, MAX_DATE_REP_LENGTH, MAX_DATETIME_REP_LENGTH, MAX_TIME_REP_LENGTH, memcpy, MYSQL_STMT_PREPARE_DONE, MYSQL_TYPE_BLOB, MYSQL_TYPE_DATE, MYSQL_TYPE_DATETIME, MYSQL_TYPE_DECIMAL, MYSQL_TYPE_DOUBLE, MYSQL_TYPE_FLOAT, MYSQL_TYPE_LONG, MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONGLONG, MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_NULL, MYSQL_TYPE_SHORT, MYSQL_TYPE_STRING, MYSQL_TYPE_TIME, MYSQL_TYPE_TIMESTAMP, MYSQL_TYPE_TINY, MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_VAR_STRING, MYSQL_TYPE_VARCHAR, st_mysql_stmt::param_count, st_mysql_bind::param_number, st_mysql_stmt::params, st_mysql_stmt::send_types_to_server, set_stmt_error(), st_mysql_stmt::sqlstate, st_mysql_stmt::state, store_param_date(), store_param_datetime(), store_param_double(), store_param_float(), st_mysql_bind::store_param_func, store_param_int32(), store_param_int64(), store_param_short(), store_param_str(), store_param_time(), store_param_tinyint(), strmov(), TRUE, and unknown_sqlstate.
03157 { 03158 uint count=0; 03159 MYSQL_BIND *param, *end; 03160 DBUG_ENTER("mysql_stmt_bind_param"); 03161 03162 if (!stmt->param_count) 03163 { 03164 if ((int) stmt->state < (int) MYSQL_STMT_PREPARE_DONE) 03165 { 03166 set_stmt_error(stmt, CR_NO_PREPARE_STMT, unknown_sqlstate); 03167 DBUG_RETURN(1); 03168 } 03169 DBUG_RETURN(0); 03170 } 03171 03172 /* Allocated on prepare */ 03173 memcpy((char*) stmt->params, (char*) bind, 03174 sizeof(MYSQL_BIND) * stmt->param_count); 03175 03176 for (param= stmt->params, end= param+stmt->param_count; 03177 param < end ; 03178 param++) 03179 { 03180 param->param_number= count++; 03181 param->long_data_used= 0; 03182 03183 /* If param->is_null is not set, then the value can never be NULL */ 03184 if (!param->is_null) 03185 param->is_null= &int_is_null_false; 03186 03187 /* Setup data copy functions for the different supported types */ 03188 switch (param->buffer_type) { 03189 case MYSQL_TYPE_NULL: 03190 param->is_null= &int_is_null_true; 03191 break; 03192 case MYSQL_TYPE_TINY: 03193 /* Force param->length as this is fixed for this type */ 03194 param->length= ¶m->buffer_length; 03195 param->buffer_length= 1; 03196 param->store_param_func= store_param_tinyint; 03197 break; 03198 case MYSQL_TYPE_SHORT: 03199 param->length= ¶m->buffer_length; 03200 param->buffer_length= 2; 03201 param->store_param_func= store_param_short; 03202 break; 03203 case MYSQL_TYPE_LONG: 03204 param->length= ¶m->buffer_length; 03205 param->buffer_length= 4; 03206 param->store_param_func= store_param_int32; 03207 break; 03208 case MYSQL_TYPE_LONGLONG: 03209 param->length= ¶m->buffer_length; 03210 param->buffer_length= 8; 03211 param->store_param_func= store_param_int64; 03212 break; 03213 case MYSQL_TYPE_FLOAT: 03214 param->length= ¶m->buffer_length; 03215 param->buffer_length= 4; 03216 param->store_param_func= store_param_float; 03217 break; 03218 case MYSQL_TYPE_DOUBLE: 03219 param->length= ¶m->buffer_length; 03220 param->buffer_length= 8; 03221 param->store_param_func= store_param_double; 03222 break; 03223 case MYSQL_TYPE_TIME: 03224 param->store_param_func= store_param_time; 03225 param->buffer_length= MAX_TIME_REP_LENGTH; 03226 break; 03227 case MYSQL_TYPE_DATE: 03228 param->store_param_func= store_param_date; 03229 param->buffer_length= MAX_DATE_REP_LENGTH; 03230 break; 03231 case MYSQL_TYPE_DATETIME: 03232 case MYSQL_TYPE_TIMESTAMP: 03233 param->store_param_func= store_param_datetime; 03234 param->buffer_length= MAX_DATETIME_REP_LENGTH; 03235 break; 03236 case MYSQL_TYPE_TINY_BLOB: 03237 case MYSQL_TYPE_MEDIUM_BLOB: 03238 case MYSQL_TYPE_LONG_BLOB: 03239 case MYSQL_TYPE_BLOB: 03240 case MYSQL_TYPE_VARCHAR: 03241 case MYSQL_TYPE_VAR_STRING: 03242 case MYSQL_TYPE_STRING: 03243 case MYSQL_TYPE_DECIMAL: 03244 case MYSQL_TYPE_NEWDECIMAL: 03245 param->store_param_func= store_param_str; 03246 /* 03247 For variable length types user must set either length or 03248 buffer_length. 03249 */ 03250 break; 03251 default: 03252 strmov(stmt->sqlstate, unknown_sqlstate); 03253 sprintf(stmt->last_error, 03254 ER(stmt->last_errno= CR_UNSUPPORTED_PARAM_TYPE), 03255 param->buffer_type, count); 03256 DBUG_RETURN(1); 03257 } 03258 /* 03259 If param->length is not given, change it to point to buffer_length. 03260 This way we can always use *param->length to get the length of data 03261 */ 03262 if (!param->length) 03263 param->length= ¶m->buffer_length; 03264 } 03265 /* We have to send/resend type information to MySQL */ 03266 stmt->send_types_to_server= TRUE; 03267 stmt->bind_param_done= TRUE; 03268 DBUG_RETURN(0); 03269 }
Here is the call graph for this function:

| my_bool STDCALL mysql_stmt_bind_result | ( | MYSQL_STMT * | stmt, | |
| MYSQL_BIND * | bind | |||
| ) |
Definition at line 4399 of file libmysql.c.
References st_mysql_stmt::bind, BIND_RESULT_DONE, st_mysql_stmt::bind_result_done, st_mysql_bind::buffer_type, CR_NO_PREPARE_STMT, CR_NO_STMT_METADATA, CR_UNSUPPORTED_PARAM_TYPE, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, ER, st_mysql_bind::error, st_mysql_bind::error_value, st_mysql_stmt::field_count, st_mysql_stmt::fields, int(), st_mysql_bind::is_null, st_mysql_bind::is_null_value, st_mysql_stmt::last_errno, st_mysql_stmt::last_error, st_mysql_bind::length, st_mysql_bind::length_value, memcpy, st_mysql_stmt::mysql, MYSQL_STMT_PREPARE_DONE, st_mysql_bind::offset, st_mysql::options, st_mysql_bind::param_number, REPORT_DATA_TRUNCATION, st_mysql_options::report_data_truncation, set_stmt_error(), setup_one_fetch_function(), st_mysql_stmt::sqlstate, st_mysql_stmt::state, strmov(), st_mysql_field::type, and unknown_sqlstate.
04400 { 04401 MYSQL_BIND *param, *end; 04402 MYSQL_FIELD *field; 04403 ulong bind_count= stmt->field_count; 04404 uint param_count= 0; 04405 DBUG_ENTER("mysql_stmt_bind_result"); 04406 DBUG_PRINT("enter",("field_count: %d", bind_count)); 04407 04408 if (!bind_count) 04409 { 04410 int errorcode= (int) stmt->state < (int) MYSQL_STMT_PREPARE_DONE ? 04411 CR_NO_PREPARE_STMT : CR_NO_STMT_METADATA; 04412 set_stmt_error(stmt, errorcode, unknown_sqlstate); 04413 DBUG_RETURN(1); 04414 } 04415 04416 /* 04417 We only need to check that stmt->field_count - if it is not null 04418 stmt->bind was initialized in mysql_stmt_prepare 04419 stmt->bind overlaps with bind if mysql_stmt_bind_param 04420 is called from mysql_stmt_store_result. 04421 */ 04422 04423 if (stmt->bind != bind) 04424 memcpy((char*) stmt->bind, (char*) bind, sizeof(MYSQL_BIND) * bind_count); 04425 04426 for (param= stmt->bind, end= param + bind_count, field= stmt->fields ; 04427 param < end ; 04428 param++, field++) 04429 { 04430 DBUG_PRINT("info",("buffer_type: %u field_type: %u", 04431 (uint) param->buffer_type, (uint) field->type)); 04432 /* 04433 Set param->is_null to point to a dummy variable if it's not set. 04434 This is to make the execute code easier 04435 */ 04436 if (!param->is_null) 04437 param->is_null= ¶m->is_null_value; 04438 04439 if (!param->length) 04440 param->length= ¶m->length_value; 04441 04442 if (!param->error) 04443 param->error= ¶m->error_value; 04444 04445 param->param_number= param_count++; 04446 param->offset= 0; 04447 04448 if (setup_one_fetch_function(param, field)) 04449 { 04450 strmov(stmt->sqlstate, unknown_sqlstate); 04451 sprintf(stmt->last_error, 04452 ER(stmt->last_errno= CR_UNSUPPORTED_PARAM_TYPE), 04453 field->type, param_count); 04454 DBUG_RETURN(1); 04455 } 04456 } 04457 stmt->bind_result_done= BIND_RESULT_DONE; 04458 if (stmt->mysql->options.report_data_truncation) 04459 stmt->bind_result_done|= REPORT_DATA_TRUNCATION; 04460 04461 DBUG_RETURN(0); 04462 }
Here is the call graph for this function:

| my_bool STDCALL mysql_stmt_close | ( | MYSQL_STMT * | stmt | ) |
Definition at line 4987 of file libmysql.c.
References st_mysql_data::alloc, COM_STMT_CLOSE, DBUG_ENTER, DBUG_RETURN, st_mysql_methods::flush_use_result, free_root(), int4store, st_net::last_errno, st_net::last_error, st_mysql_stmt::list, list_delete(), st_mysql_stmt::mem_root, st_mysql::methods, my_free, MY_WME, MYF, st_mysql_stmt::mysql, mysql, MYSQL_STATUS_READY, MYSQL_STMT_HEADER, MYSQL_STMT_INIT_DONE, st_mysql::net, net_clear_error(), st_mysql_stmt::result, set_stmt_errmsg(), st_net::sqlstate, st_mysql_stmt::state, st_mysql::status, stmt_command, st_mysql_stmt::stmt_id, st_mysql::stmts, test, TRUE, st_mysql_stmt::unbuffered_fetch_cancelled, and st_mysql::unbuffered_fetch_owner.
04988 { 04989 MYSQL *mysql= stmt->mysql; 04990 int rc= 0; 04991 DBUG_ENTER("mysql_stmt_close"); 04992 04993 free_root(&stmt->result.alloc, MYF(0)); 04994 free_root(&stmt->mem_root, MYF(0)); 04995 04996 if (mysql) 04997 { 04998 mysql->stmts= list_delete(mysql->stmts, &stmt->list); 04999 /* 05000 Clear NET error state: if the following commands come through 05001 successfully, connection will still be usable for other commands. 05002 */ 05003 net_clear_error(&mysql->net); 05004 if ((int) stmt->state > (int) MYSQL_STMT_INIT_DONE) 05005 { 05006 char buff[MYSQL_STMT_HEADER]; /* 4 bytes - stmt id */ 05007 05008 if (mysql->unbuffered_fetch_owner == &stmt->unbuffered_fetch_cancelled) 05009 mysql->unbuffered_fetch_owner= 0; 05010 if (mysql->status != MYSQL_STATUS_READY) 05011 { 05012 /* 05013 Flush result set of the connection. If it does not belong 05014 to this statement, set a warning. 05015 */ 05016 (*mysql->methods->flush_use_result)(mysql); 05017 if (mysql->unbuffered_fetch_owner) 05018 *mysql->unbuffered_fetch_owner= TRUE; 05019 mysql->status= MYSQL_STATUS_READY; 05020 } 05021 int4store(buff, stmt->stmt_id); 05022 if ((rc= stmt_command(mysql, COM_STMT_CLOSE, buff, 4, stmt))) 05023 { 05024 set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, 05025 mysql->net.sqlstate); 05026 } 05027 } 05028 } 05029 05030 my_free((gptr) stmt, MYF(MY_WME)); 05031 05032 DBUG_RETURN(test(rc)); 05033 }
Here is the call graph for this function:

| void STDCALL mysql_stmt_data_seek | ( | MYSQL_STMT * | stmt, | |
| my_ulonglong | row | |||
| ) |
Definition at line 4859 of file libmysql.c.
References st_mysql_data::data, st_mysql_stmt::data_cursor, DBUG_ENTER, DBUG_PRINT, DBUG_VOID_RETURN, MYSQL_STMT_EXECUTE_DONE, st_mysql_rows::next, st_mysql_stmt::read_row_func, st_mysql_stmt::result, st_mysql_stmt::state, and stmt_read_row_buffered().
04860 { 04861 MYSQL_ROWS *tmp= stmt->result.data; 04862 DBUG_ENTER("mysql_stmt_data_seek"); 04863 DBUG_PRINT("enter",("row id to seek: %ld",(long) row)); 04864 04865 for (; tmp && row; --row, tmp= tmp->next) 04866 ; 04867 stmt->data_cursor= tmp; 04868 if (!row && tmp) 04869 { 04870 /* Rewind the counter */ 04871 stmt->read_row_func= stmt_read_row_buffered; 04872 stmt->state= MYSQL_STMT_EXECUTE_DONE; 04873 } 04874 DBUG_VOID_RETURN; 04875 }
Here is the call graph for this function:

| uint STDCALL mysql_stmt_errno | ( | MYSQL_STMT * | stmt | ) |
Definition at line 5057 of file libmysql.c.
References DBUG_ENTER, DBUG_RETURN, and st_mysql_stmt::last_errno.
05058 { 05059 DBUG_ENTER("mysql_stmt_errno"); 05060 DBUG_RETURN(stmt->last_errno); 05061 }
| const char* STDCALL mysql_stmt_error | ( | MYSQL_STMT * | stmt | ) |
Definition at line 5073 of file libmysql.c.
References DBUG_ENTER, DBUG_RETURN, and st_mysql_stmt::last_error.
05074 { 05075 DBUG_ENTER("mysql_stmt_error"); 05076 DBUG_RETURN(stmt->last_error); 05077 }
| int STDCALL mysql_stmt_execute | ( | MYSQL_STMT * | stmt | ) |
Definition at line 2852 of file libmysql.c.
References alloc_stmt_fields(), CR_SERVER_LOST, CURSOR_TYPE_READ_ONLY, DBUG_ENTER, DBUG_RETURN, FALSE, st_mysql_stmt::field_count, st_mysql::field_count, st_mysql_stmt::flags, st_mysql::methods, st_mysql_stmt::mysql, mysql, MYSQL_STATUS_READY, MYSQL_STMT_EXECUTE_DONE, mysql_stmt_store_result(), st_mysql_stmt::read_row_func, reset_stmt_handle(), RESET_STORE_RESULT, st_mysql_stmt::server_status, SERVER_STATUS_CURSOR_EXISTS, set_stmt_error(), st_mysql_stmt::state, st_mysql::status, st_mysql_methods::stmt_execute, stmt_read_row_from_cursor(), stmt_read_row_unbuffered(), st_mysql_stmt::unbuffered_fetch_cancelled, st_mysql::unbuffered_fetch_owner, unknown_sqlstate, and update_stmt_fields().
02853 { 02854 MYSQL *mysql= stmt->mysql; 02855 DBUG_ENTER("mysql_stmt_execute"); 02856 02857 if (!mysql) 02858 { 02859 set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate); 02860 DBUG_RETURN(1); 02861 } 02862 02863 if (reset_stmt_handle(stmt, RESET_STORE_RESULT)) 02864 DBUG_RETURN(1); 02865 /* 02866 No need to check for stmt->state: if the statement wasn't 02867 prepared we'll get 'unknown statement handler' error from server. 02868 */ 02869 if (mysql->methods->stmt_execute(stmt)) 02870 DBUG_RETURN(1); 02871 if (mysql->field_count) 02872 { 02873 /* Server has sent result set metadata */ 02874 if (stmt->field_count == 0) 02875 { 02876 /* 02877 This is 'SHOW'/'EXPLAIN'-like query. Current implementation of 02878 prepared statements can't send result set metadata for these queries 02879 on prepare stage. Read it now. 02880 */ 02881 alloc_stmt_fields(stmt); 02882 } 02883 else 02884 { 02885 /* 02886 Update result set metadata if it for some reason changed between 02887 prepare and execute, i.e.: 02888 - in case of 'SELECT ?' we don't know column type unless data was 02889 supplied to mysql_stmt_execute, so updated column type is sent 02890 now. 02891 - if data dictionary changed between prepare and execute, for 02892 example a table used in the query was altered. 02893 Note, that now (4.1.3) we always send metadata in reply to 02894 COM_STMT_EXECUTE (even if it is not necessary), so either this or 02895 previous branch always works. 02896 TODO: send metadata only when it's really necessary and add a warning 02897 'Metadata changed' when it's sent twice. 02898 */ 02899 update_stmt_fields(stmt); 02900 } 02901 } 02902 stmt->state= MYSQL_STMT_EXECUTE_DONE; 02903 if (stmt->field_count) 02904 { 02905 if (stmt->server_status & SERVER_STATUS_CURSOR_EXISTS) 02906 { 02907 mysql->status= MYSQL_STATUS_READY; 02908 stmt->read_row_func= stmt_read_row_from_cursor; 02909 } 02910 else if (stmt->flags & CURSOR_TYPE_READ_ONLY) 02911 { 02912 /* 02913 This is a single-row result set, a result set with no rows, EXPLAIN, 02914 SHOW VARIABLES, or some other command which either a) bypasses the 02915 cursors framework in the server and writes rows directly to the 02916 network or b) is more efficient if all (few) result set rows are 02917 precached on client and server's resources are freed. 02918 */ 02919 DBUG_RETURN(mysql_stmt_store_result(stmt)); 02920 } 02921 else 02922 { 02923 stmt->mysql->unbuffered_fetch_owner= &stmt->unbuffered_fetch_cancelled; 02924 stmt->unbuffered_fetch_cancelled= FALSE; 02925 stmt->read_row_func= stmt_read_row_unbuffered; 02926 } 02927 } 02928 DBUG_RETURN(0); 02929 }
Here is the call graph for this function:

| int STDCALL mysql_stmt_fetch | ( | MYSQL_STMT * | stmt | ) |
Definition at line 4544 of file libmysql.c.
References DBUG_ENTER, DBUG_RETURN, MYSQL_DATA_TRUNCATED, MYSQL_NO_DATA, MYSQL_STMT_FETCH_DONE, MYSQL_STMT_PREPARE_DONE, st_mysql_stmt::read_row_func, st_mysql_stmt::state, stmt_fetch_row(), stmt_read_row_no_data(), and stmt_read_row_no_result_set().
04545 { 04546 int rc; 04547 uchar *row; 04548 DBUG_ENTER("mysql_stmt_fetch"); 04549 04550 if ((rc= (*stmt->read_row_func)(stmt, &row)) || 04551 ((rc= stmt_fetch_row(stmt, row)) && rc != MYSQL_DATA_TRUNCATED)) 04552 { 04553 stmt->state= MYSQL_STMT_PREPARE_DONE; /* XXX: this is buggy */ 04554 stmt->read_row_func= (rc == MYSQL_NO_DATA) ? 04555 stmt_read_row_no_data : stmt_read_row_no_result_set; 04556 } 04557 else 04558 { 04559 /* This is to know in mysql_stmt_fetch_column that data was fetched */ 04560 stmt->state= MYSQL_STMT_FETCH_DONE; 04561 } 04562 DBUG_RETURN(rc); 04563 }
Here is the call graph for this function:

| int STDCALL mysql_stmt_fetch_column | ( | MYSQL_STMT * | stmt, | |
| MYSQL_BIND * | bind, | |||
| uint | column, | |||
| ulong | offset | |||
| ) |
Definition at line 4582 of file libmysql.c.
References st_mysql_stmt::bind, CR_INVALID_PARAMETER_NO, CR_NO_DATA, DBUG_ENTER, DBUG_RETURN, st_mysql_bind::error, st_mysql_bind::error_value, fetch_result_with_conversion(), st_mysql_stmt::field_count, st_mysql_stmt::fields, st_mysql_bind::is_null, st_mysql_bind::length, st_mysql_bind::length_value, MYSQL_STMT_FETCH_DONE, st_mysql_bind::offset, st_mysql_bind::row_ptr, set_stmt_error(), st_mysql_stmt::state, and unknown_sqlstate.
04584 { 04585 MYSQL_BIND *param= stmt->bind+column; 04586 DBUG_ENTER("mysql_stmt_fetch_column"); 04587 04588 if ((int) stmt->state < (int) MYSQL_STMT_FETCH_DONE) 04589 { 04590 set_stmt_error(stmt, CR_NO_DATA, unknown_sqlstate); 04591 return 1; 04592 } 04593 if (column >= stmt->field_count) 04594 { 04595 set_stmt_error(stmt, CR_INVALID_PARAMETER_NO, unknown_sqlstate); 04596 DBUG_RETURN(1); 04597 } 04598 04599 if (!bind->error) 04600 bind->error= &bind->error_value; 04601 *bind->error= 0; 04602 if (param->row_ptr) 04603 { 04604 MYSQL_FIELD *field= stmt->fields+column; 04605 uchar *row= param->row_ptr; 04606 bind->offset= offset; 04607 if (bind->is_null) 04608 *bind->is_null= 0; 04609 if (bind->length) /* Set the length if non char/binary types */ 04610 *bind->length= *param->length; 04611 else 04612 bind->length= ¶m->length_value; /* Needed for fetch_result() */ 04613 fetch_result_with_conversion(bind, field, &row); 04614 } 04615 else 04616 { 04617 if (bind->is_null) 04618 *bind->is_null= 1; 04619 } 04620 DBUG_RETURN(0); 04621 }
Here is the call graph for this function:

| unsigned int STDCALL mysql_stmt_field_count | ( | MYSQL_STMT * | stmt | ) |
Definition at line 2957 of file libmysql.c.
References st_mysql_stmt::field_count.
02958 { 02959 return stmt->field_count; 02960 }
| my_bool STDCALL mysql_stmt_free_result | ( | MYSQL_STMT * | stmt | ) |
Definition at line 4963 of file libmysql.c.
References DBUG_ENTER, DBUG_RETURN, RESET_LONG_DATA, reset_stmt_handle(), and RESET_STORE_RESULT.
04964 { 04965 DBUG_ENTER("mysql_stmt_free_result"); 04966 04967 /* Free the client side and close the server side cursor if there is one */ 04968 DBUG_RETURN(reset_stmt_handle(stmt, RESET_LONG_DATA | RESET_STORE_RESULT)); 04969 }
Here is the call graph for this function:

| MYSQL_STMT* STDCALL mysql_stmt_init | ( | MYSQL * | mysql | ) |
Definition at line 1960 of file libmysql.c.
References st_mysql_data::alloc, CR_OUT_OF_MEMORY, st_list::data, DBUG_ENTER, DBUG_RETURN, DEFAULT_PREFETCH_ROWS, init_alloc_root(), st_mysql_stmt::list, list_add(), st_mysql_stmt::mem_root, st_mem_root::min_malloc, my_malloc(), MY_WME, MY_ZEROFILL, MYF, st_mysql_stmt::mysql, mysql, MYSQL_STMT_INIT_DONE, not_error_sqlstate, st_mysql_stmt::prefetch_rows, st_mysql_stmt::read_row_func, st_mysql_stmt::result, set_mysql_error(), st_mysql_stmt::sqlstate, st_mysql_stmt::state, stmt_read_row_no_result_set(), st_mysql::stmts, strmov(), and unknown_sqlstate.
01961 { 01962 MYSQL_STMT *stmt; 01963 DBUG_ENTER("mysql_stmt_init"); 01964 01965 if (!(stmt= (MYSQL_STMT *) my_malloc(sizeof(MYSQL_STMT), 01966 MYF(MY_WME | MY_ZEROFILL)))) 01967 { 01968 set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate); 01969 DBUG_RETURN(0); 01970 } 01971 01972 init_alloc_root(&stmt->mem_root, 2048, 2048); 01973 init_alloc_root(&stmt->result.alloc, 4096, 4096); 01974 stmt->result.alloc.min_malloc= sizeof(MYSQL_ROWS); 01975 mysql->stmts= list_add(mysql->stmts, &stmt->list); 01976 stmt->list.data= stmt; 01977 stmt->state= MYSQL_STMT_INIT_DONE; 01978 stmt->mysql= mysql; 01979 stmt->read_row_func= stmt_read_row_no_result_set; 01980 stmt->prefetch_rows= DEFAULT_PREFETCH_ROWS; 01981 strmov(stmt->sqlstate, not_error_sqlstate); 01982 /* The rest of statement members was bzeroed inside malloc */ 01983 01984 DBUG_RETURN(stmt); 01985 }
Here is the call graph for this function:

| my_ulonglong STDCALL mysql_stmt_insert_id | ( | MYSQL_STMT * | stmt | ) |
Definition at line 2978 of file libmysql.c.
References st_mysql_stmt::insert_id.
02979 { 02980 return stmt->insert_id; 02981 }
| my_ulonglong STDCALL mysql_stmt_num_rows | ( | MYSQL_STMT * | stmt | ) |
Definition at line 4882 of file libmysql.c.
References DBUG_ENTER, DBUG_RETURN, st_mysql_stmt::result, and st_mysql_data::rows.
04883 { 04884 DBUG_ENTER("mysql_stmt_num_rows"); 04885 04886 DBUG_RETURN(stmt->result.rows); 04887 }
| ulong STDCALL mysql_stmt_param_count | ( | MYSQL_STMT * | stmt | ) |
Definition at line 2936 of file libmysql.c.
References DBUG_ENTER, DBUG_RETURN, and st_mysql_stmt::param_count.
02937 { 02938 DBUG_ENTER("mysql_stmt_param_count"); 02939 DBUG_RETURN(stmt->param_count); 02940 }
| MYSQL_RES* STDCALL mysql_stmt_param_metadata | ( | MYSQL_STMT * | stmt | ) |
Definition at line 2254 of file libmysql.c.
References DBUG_ENTER, DBUG_RETURN, and st_mysql_stmt::param_count.
02255 { 02256 DBUG_ENTER("mysql_stmt_param_metadata"); 02257 02258 if (!stmt->param_count) 02259 DBUG_RETURN(0); 02260 02261 /* 02262 TODO: Fix this when server sends the information. 02263 Till then keep a dummy prototype. 02264 */ 02265 DBUG_RETURN(0); 02266 }
| int STDCALL mysql_stmt_prepare | ( | MYSQL_STMT * | stmt, | |
| const char * | query, | |||
| ulong | length | |||
| ) |
Definition at line 2023 of file libmysql.c.
References alloc_root(), st_mysql_stmt::bind, st_mysql_stmt::bind_param_done, st_mysql_stmt::bind_result_done, COM_STMT_CLOSE, COM_STMT_PREPARE, CR_OUT_OF_MEMORY, CR_SERVER_LOST, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, FALSE, st_mysql_stmt::field_count, free_root(), int4store, st_net::last_errno, st_mysql_stmt::last_errno, st_net::last_error, st_mysql_stmt::last_error, st_mysql_stmt::mem_root, st_mysql::methods, MY_KEEP_PREALLOC, MYF, st_mysql_stmt::mysql, mysql, MYSQL_STMT_HEADER, MYSQL_STMT_INIT_DONE, MYSQL_STMT_PREPARE_DONE, st_mysql::net, st_mysql_stmt::param_count, st_mysql_stmt::params, st_mysql_methods::read_prepare_result, RESET_LONG_DATA, reset_stmt_handle(), RESET_STORE_RESULT, set_stmt_errmsg(), set_stmt_error(), st_net::sqlstate, st_mysql_stmt::state, stmt_command, st_mysql_stmt::stmt_id, and unknown_sqlstate.
02024 { 02025 MYSQL *mysql= stmt->mysql; 02026 DBUG_ENTER("mysql_stmt_prepare"); 02027 02028 if (!mysql) 02029 { 02030 /* mysql can be reset in mysql_close called from mysql_reconnect */ 02031 set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate); 02032 DBUG_RETURN(1); 02033 } 02034 02035 if ((int) stmt->state > (int) MYSQL_STMT_INIT_DONE) 02036 { 02037 /* This is second prepare with another statement */ 02038 char buff[MYSQL_STMT_HEADER]; /* 4 bytes - stmt id */ 02039 02040 if (reset_stmt_handle(stmt, RESET_LONG_DATA | RESET_STORE_RESULT)) 02041 DBUG_RETURN(1); 02042 /* 02043 These members must be reset for API to 02044 function in case of error or misuse. 02045 */ 02046 stmt->bind_param_done= stmt->bind_result_done= FALSE; 02047 stmt->param_count= stmt->field_count= 0; 02048 stmt->last_errno= 0; 02049 stmt->last_error[0]= '\0'; 02050 free_root(&stmt->mem_root, MYF(MY_KEEP_PREALLOC)); 02051 02052 int4store(buff, stmt->stmt_id); 02053 /* 02054 If there was a 'use' result from another statement, or from 02055 mysql_use_result it won't be freed in mysql_stmt_free_result and 02056 we should get 'Commands out of sync' here. 02057 */ 02058 if (stmt_command(mysql, COM_STMT_CLOSE, buff, 4, stmt)) 02059 { 02060 set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, 02061 mysql->net.sqlstate); 02062 DBUG_RETURN(1); 02063 } 02064 stmt->state= MYSQL_STMT_INIT_DONE; 02065 } 02066 02067 if (stmt_command(mysql, COM_STMT_PREPARE, query, length, stmt)) 02068 { 02069 set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, 02070 mysql->net.sqlstate); 02071 DBUG_RETURN(1); 02072 } 02073 02074 if ((*mysql->methods->read_prepare_result)(mysql, stmt)) 02075 { 02076 set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, 02077 mysql->net.sqlstate); 02078 DBUG_RETURN(1); 02079 } 02080 02081 /* 02082 alloc_root will return valid address even in case when param_count 02083 and field_count are zero. Thus we should never rely on stmt->bind 02084 or stmt->params when checking for existence of placeholders or 02085 result set. 02086 */ 02087 if (!(stmt->params= (MYSQL_BIND *) alloc_root(&stmt->mem_root, 02088 sizeof(MYSQL_BIND)* 02089 (stmt->param_count + 02090 stmt->field_count)))) 02091 { 02092 set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate); 02093 DBUG_RETURN(1); 02094 } 02095 stmt->bind= stmt->params + stmt->param_count; 02096 stmt->state= MYSQL_STMT_PREPARE_DONE; 02097 DBUG_PRINT("info", ("Parameter count: %ld", stmt->param_count)); 02098 DBUG_RETURN(0); 02099 }
Here is the call graph for this function:

| my_bool STDCALL mysql_stmt_reset | ( | MYSQL_STMT * | stmt | ) |
Definition at line 5039 of file libmysql.c.
References CR_SERVER_LOST, DBUG_ASSERT, DBUG_ENTER, DBUG_RETURN, st_mysql_stmt::mysql, RESET_LONG_DATA, RESET_SERVER_SIDE, reset_stmt_handle(), set_stmt_error(), and unknown_sqlstate.
05040 { 05041 DBUG_ENTER("mysql_stmt_reset"); 05042 DBUG_ASSERT(stmt != 0); 05043 if (!stmt->mysql) 05044 { 05045 /* mysql can be reset in mysql_close called from mysql_reconnect */ 05046 set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate); 05047 DBUG_RETURN(1); 05048 } 05049 /* Reset the client and server sides of the prepared statement */ 05050 DBUG_RETURN(reset_stmt_handle(stmt, RESET_SERVER_SIDE | RESET_LONG_DATA)); 05051 }
Here is the call graph for this function:

| MYSQL_RES* STDCALL mysql_stmt_result_metadata | ( | MYSQL_STMT * | stmt | ) |
Definition at line 2207 of file libmysql.c.
References CR_OUT_OF_MEMORY, DBUG_ENTER, DBUG_RETURN, st_mysql_stmt::field_count, st_mysql_stmt::fields, st_mysql::methods, my_malloc(), MY_WME, MY_ZEROFILL, MYF, st_mysql_stmt::mysql, set_stmt_error(), and unknown_sqlstate.
02208 { 02209 MYSQL_RES *result; 02210 DBUG_ENTER("mysql_stmt_result_metadata"); 02211 02212 /* 02213 stmt->fields is only defined if stmt->field_count is not null; 02214 stmt->field_count is initialized in prepare. 02215 */ 02216 if (!stmt->field_count) 02217 DBUG_RETURN(0); 02218 02219 if (!(result=(MYSQL_RES*) my_malloc(sizeof(*result), 02220 MYF(MY_WME | MY_ZEROFILL)))) 02221 { 02222 set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate); 02223 DBUG_RETURN(0); 02224 } 02225 02226 result->methods= stmt->mysql->methods; 02227 result->eof= 1; /* Marker for buffered */ 02228 result->fields= stmt->fields; 02229 result->field_count= stmt->field_count; 02230 /* The rest of members of 'result' was bzeroed inside malloc */ 02231 DBUG_RETURN(result); 02232 }
Here is the call graph for this function:

| MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek | ( | MYSQL_STMT * | stmt, | |
| MYSQL_ROW_OFFSET | row | |||
| ) |
Definition at line 4831 of file libmysql.c.
References st_mysql_stmt::data_cursor, DBUG_ENTER, DBUG_RETURN, and offset.
04832 { 04833 MYSQL_ROW_OFFSET offset= stmt->data_cursor; 04834 DBUG_ENTER("mysql_stmt_row_seek"); 04835 04836 stmt->data_cursor= row; 04837 DBUG_RETURN(offset); 04838 }
| MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell | ( | MYSQL_STMT * | stmt | ) |
Definition at line 4846 of file libmysql.c.
References st_mysql_stmt::data_cursor, DBUG_ENTER, and DBUG_RETURN.
04847 { 04848 DBUG_ENTER("mysql_stmt_row_tell"); 04849 04850 DBUG_RETURN(stmt->data_cursor); 04851 }
| my_bool STDCALL mysql_stmt_send_long_data | ( | MYSQL_STMT * | stmt, | |
| uint | param_number, | |||
| const char * | data, | |||
| ulong | length | |||
| ) |
Definition at line 3316 of file libmysql.c.
References st_mysql_methods::advanced_command, st_mysql_bind::buffer_type, COM_STMT_SEND_LONG_DATA, CR_INVALID_BUFFER_USE, CR_INVALID_PARAMETER_NO, DBUG_ASSERT, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, ER, int2store, int4store, st_net::last_errno, st_mysql_stmt::last_errno, st_net::last_error, st_mysql_stmt::last_error, st_mysql_bind::long_data_used, st_mysql::methods, st_mysql_stmt::mysql, mysql, MYSQL_LONG_DATA_HEADER, MYSQL_TYPE_STRING, MYSQL_TYPE_TINY_BLOB, st_mysql::net, NULL, st_mysql_stmt::param_count, st_mysql_bind::param_number, st_mysql_stmt::params, set_stmt_errmsg(), set_stmt_error(), st_net::sqlstate, st_mysql_stmt::sqlstate, st_mysql_stmt::stmt_id, strmov(), and unknown_sqlstate.
03318 { 03319 MYSQL_BIND *param; 03320 DBUG_ENTER("mysql_stmt_send_long_data"); 03321 DBUG_ASSERT(stmt != 0); 03322 DBUG_PRINT("enter",("param no : %d, data : %lx, length : %ld", 03323 param_number, data, length)); 03324 03325 /* 03326 We only need to check for stmt->param_count, if it's not null 03327 prepare was done. 03328 */ 03329 if (param_number >= stmt->param_count) 03330 { 03331 set_stmt_error(stmt, CR_INVALID_PARAMETER_NO, unknown_sqlstate); 03332 DBUG_RETURN(1); 03333 } 03334 03335 param= stmt->params+param_number; 03336 if (param->buffer_type < MYSQL_TYPE_TINY_BLOB || 03337 param->buffer_type > MYSQL_TYPE_STRING) 03338 { 03339 /* Long data handling should be used only for string/binary types */ 03340 strmov(stmt->sqlstate, unknown_sqlstate); 03341 sprintf(stmt->last_error, ER(stmt->last_errno= CR_INVALID_BUFFER_USE), 03342 param->param_number); 03343 DBUG_RETURN(1); 03344 } 03345 03346 /* 03347 Send long data packet if there is data or we're sending long data 03348 for the first time. 03349 */ 03350 if (length || param->long_data_used == 0) 03351 { 03352 MYSQL *mysql= stmt->mysql; 03353 /* Packet header: stmt id (4 bytes), param no (2 bytes) */ 03354 char buff[MYSQL_LONG_DATA_HEADER]; 03355 03356 int4store(buff, stmt->stmt_id); 03357 int2store(buff + 4, param_number); 03358 param->long_data_used= 1; 03359 03360 /* 03361 Note that we don't get any ok packet from the server in this case 03362 This is intentional to save bandwidth. 03363 */ 03364 if ((*mysql->methods->advanced_command)(mysql, COM_STMT_SEND_LONG_DATA, 03365 buff, sizeof(buff), data, 03366 length, 1, NULL)) 03367 { 03368 set_stmt_errmsg(stmt, mysql->net.last_error, 03369 mysql->net.last_errno, mysql->net.sqlstate); 03370 DBUG_RETURN(1); 03371 } 03372 } 03373 DBUG_RETURN(0); 03374 }
Here is the call graph for this function:

| const char* STDCALL mysql_stmt_sqlstate | ( | MYSQL_STMT * | stmt | ) |
Definition at line 5063 of file libmysql.c.
References DBUG_ENTER, DBUG_RETURN, and st_mysql_stmt::sqlstate.
05064 { 05065 DBUG_ENTER("mysql_stmt_sqlstate"); 05066 DBUG_RETURN(stmt->sqlstate); 05067 }
| int STDCALL mysql_stmt_store_result | ( | MYSQL_STMT * | stmt | ) |
Definition at line 4723 of file libmysql.c.
References st_mysql_stmt::affected_rows, st_mysql::affected_rows, st_mysql_data::alloc, st_mysql_stmt::bind, st_mysql_stmt::bind_result_done, st_mysql_bind::buffer_length, st_mysql_bind::buffer_type, bzero, cli_advanced_command(), COM_STMT_FETCH, CR_COMMANDS_OUT_OF_SYNC, st_mysql_data::data, st_mysql_stmt::data_cursor, DBUG_ASSERT, DBUG_ENTER, DBUG_RETURN, st_mysql_stmt::field_count, st_mysql_stmt::fields, free_root(), int4store, st_net::last_errno, st_net::last_error, st_mysql::last_used_con, st_mysql::methods, MY_KEEP_PREALLOC, MYF, st_mysql_stmt::mysql, mysql, MYSQL_STATUS_GET_RESULT, MYSQL_STATUS_READY, mysql_stmt_bind_result(), MYSQL_STMT_EXECUTE_DONE, MYSQL_TYPE_NULL, st_mysql::net, st_mysql_rows::next, NULL, NullS, st_mysql_methods::read_binary_rows, st_mysql_stmt::read_row_func, st_mysql_stmt::result, st_mysql_data::rows, st_mysql::server_status, st_mysql_stmt::server_status, SERVER_STATUS_CURSOR_EXISTS, SERVER_STATUS_LAST_ROW_SENT, set_stmt_errmsg(), set_stmt_error(), st_net::sqlstate, st_mysql_stmt::state, st_mysql::status, st_mysql_stmt::stmt_id, stmt_read_row_buffered(), stmt_update_metadata(), st_mysql::unbuffered_fetch_owner, unknown_sqlstate, and st_mysql_stmt::update_max_length.
04724 { 04725 MYSQL *mysql= stmt->mysql; 04726 MYSQL_DATA *result= &stmt->result; 04727 DBUG_ENTER("mysql_stmt_store_result"); 04728 04729 mysql= mysql->last_used_con; 04730 04731 if (!stmt->field_count) 04732 DBUG_RETURN(0); 04733 04734 if ((int) stmt->state < (int) MYSQL_STMT_EXECUTE_DONE) 04735 { 04736 set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); 04737 DBUG_RETURN(1); 04738 } 04739 04740 if (mysql->status == MYSQL_STATUS_READY && 04741 stmt->server_status & SERVER_STATUS_CURSOR_EXISTS) 04742 { 04743 /* 04744 Server side cursor exist, tell server to start sending the rows 04745 */ 04746 NET *net= &mysql->net; 04747 char buff[4 /* statement id */ + 04748 4 /* number of rows to fetch */]; 04749 04750 /* Send row request to the server */ 04751 int4store(buff, stmt->stmt_id); 04752 int4store(buff + 4, (int)~0); /* number of rows to fetch */ 04753 if (cli_advanced_command(mysql, COM_STMT_FETCH, buff, sizeof(buff), 04754 NullS, 0, 1, NULL)) 04755 { 04756 set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); 04757 DBUG_RETURN(1); 04758 } 04759 } 04760 else if (mysql->status != MYSQL_STATUS_GET_RESULT) 04761 { 04762 set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); 04763 DBUG_RETURN(1); 04764 } 04765 04766 if (result->data) 04767 { 04768 free_root(&result->alloc, MYF(MY_KEEP_PREALLOC)); 04769 result->data= NULL; 04770 result->rows= 0; 04771 stmt->data_cursor= NULL; 04772 } 04773 04774 if (stmt->update_max_length && !stmt->bind_result_done) 04775 { 04776 /* 04777 We must initalize the bind structure to be able to calculate 04778 max_length 04779 */ 04780 MYSQL_BIND *bind, *end; 04781 MYSQL_FIELD *field; 04782 bzero((char*) stmt->bind, sizeof(*stmt->bind)* stmt->field_count); 04783 04784 for (bind= stmt->bind, end= bind + stmt->field_count, field= stmt->fields; 04785 bind < end ; 04786 bind++, field++) 04787 { 04788 bind->buffer_type= MYSQL_TYPE_NULL; 04789 bind->buffer_length=1; 04790 } 04791 04792 if (mysql_stmt_bind_result(stmt, stmt->bind)) 04793 DBUG_RETURN(1); 04794 stmt->bind_result_done= 0; /* No normal bind done */ 04795 } 04796 04797 if ((*mysql->methods->read_binary_rows)(stmt)) 04798 { 04799 free_root(&result->alloc, MYF(MY_KEEP_PREALLOC)); 04800 result->data= NULL; 04801 result->rows= 0; 04802 mysql->status= MYSQL_STATUS_READY; 04803 DBUG_RETURN(1); 04804 } 04805 04806 /* Assert that if there was a cursor, all rows have been fetched */ 04807 DBUG_ASSERT(mysql->status != MYSQL_STATUS_READY || 04808 (mysql->server_status & SERVER_STATUS_LAST_ROW_SENT)); 04809 04810 if (stmt->update_max_length) 04811 { 04812 MYSQL_ROWS *cur= result->data; 04813 for(; cur; cur=cur->next) 04814 stmt_update_metadata(stmt, cur); 04815 } 04816 04817 stmt->data_cursor= result->data; 04818 mysql->affected_rows= stmt->affected_rows= result->rows; 04819 stmt->read_row_func= stmt_read_row_buffered; 04820 mysql->unbuffered_fetch_owner= 0; /* set in stmt_execute */ 04821 mysql->status= MYSQL_STATUS_READY; /* server is ready */ 04822 DBUG_RETURN(0); /* Data buffered, must be fetched with mysql_stmt_fetch() */ 04823 }
Here is the call graph for this function:

| void STDCALL mysql_thread_end | ( | void | ) |
Definition at line 217 of file libmysql.c.
References my_thread_end().
00218 { 00219 #ifdef THREAD 00220 my_thread_end(); 00221 #endif 00222 }
Here is the call graph for this function:

Definition at line 1465 of file libmysql.c.
References mysql.
01466 { 01467 return (mysql)->thread_id; 01468 }
| my_bool STDCALL mysql_thread_init | ( | void | ) |
Definition at line 208 of file libmysql.c.
References my_thread_init().
00209 { 00210 #ifdef THREAD 00211 return my_thread_init(); 00212 #else 00213 return 0; 00214 #endif 00215 }
Here is the call graph for this function:

| uint STDCALL mysql_thread_safe | ( | void | ) |
Definition at line 5168 of file libmysql.c.
References st_mysql::methods, mysql, and st_mysql_methods::use_result.
05169 { 05170 return (*mysql->methods->use_result)(mysql); 05171 }
Definition at line 1455 of file libmysql.c.
References mysql, and st_mysql::warning_count.
01456 { 01457 return mysql->warning_count; 01458 }
| static void net_clear_error | ( | NET * | net | ) | [static] |
Definition at line 1802 of file libmysql.c.
References st_net::last_errno, st_net::last_error, not_error_sqlstate, st_net::sqlstate, and strmov().
Referenced by mysql_stmt_close().
01803 { 01804 if (net->last_errno) 01805 { 01806 net->last_errno= 0; 01807 net->last_error[0]= '\0'; 01808 strmov(net->sqlstate, not_error_sqlstate); 01809 } 01810 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void net_store_datetime | ( | NET * | net, | |
| MYSQL_TIME * | tm | |||
| ) | [static] |
Definition at line 2359 of file libmysql.c.
References st_mysql_time::day, st_mysql_time::hour, int2store, int4store, MAX_DATETIME_REP_LENGTH, memcpy, st_mysql_time::minute, st_mysql_time::month, pos(), st_mysql_time::second, st_mysql_time::second_part, st_net::write_pos, and st_mysql_time::year.
Referenced by store_param_date(), and store_param_datetime().
02360 { 02361 char buff[MAX_DATETIME_REP_LENGTH], *pos; 02362 uint length; 02363 02364 pos= buff+1; 02365 02366 int2store(pos, tm->year); 02367 pos[2]= (uchar) tm->month; 02368 pos[3]= (uchar) tm->day; 02369 pos[4]= (uchar) tm->hour; 02370 pos[5]= (uchar) tm->minute; 02371 pos[6]= (uchar) tm->second; 02372 int4store(pos+7, tm->second_part); 02373 if (tm->second_part) 02374 length= 11; 02375 else if (tm->hour || tm->minute || tm->second) 02376 length= 7; 02377 else if (tm->year || tm->month || tm->day) 02378 length= 4; 02379 else 02380 length= 0; 02381 buff[0]= (char) length++; 02382 memcpy((char *)net->write_pos, buff, length); 02383 net->write_pos+= length; 02384 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void read_binary_date | ( | MYSQL_TIME * | tm, | |
| uchar ** | pos | |||
| ) | [static] |
Definition at line 3457 of file libmysql.c.
References st_mysql_time::day, st_mysql_time::hour, st_mysql_time::minute, st_mysql_time::month, MYSQL_TIMESTAMP_DATE, st_mysql_time::neg, net_field_length(), st_mysql_time::second, st_mysql_time::second_part, set_zero_time(), sint2korr, st_mysql_time::time_type, to, and st_mysql_time::year.
Referenced by fetch_result_date(), and fetch_result_with_conversion().
03458 { 03459 uint length= net_field_length(pos); 03460 03461 if (length) 03462 { 03463 uchar *to= *pos; 03464 tm->year = (uint) sint2korr(to); 03465 tm->month= (uint) to[2]; 03466 tm->day= (uint) to[3]; 03467 03468 tm->hour= tm->minute= tm->second= 0; 03469 tm->second_part= 0; 03470 tm->neg= 0; 03471 tm->time_type= MYSQL_TIMESTAMP_DATE; 03472 03473 *pos+= length; 03474 } 03475 else 03476 set_zero_time(tm, MYSQL_TIMESTAMP_DATE); 03477 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void read_binary_datetime | ( | MYSQL_TIME * | tm, | |
| uchar ** | pos | |||
| ) | [static] |
Definition at line 3427 of file libmysql.c.
References st_mysql_time::day, st_mysql_time::hour, st_mysql_time::minute, st_mysql_time::month, MYSQL_TIMESTAMP_DATETIME, st_mysql_time::neg, net_field_length(), st_mysql_time::second, st_mysql_time::second_part, set_zero_time(), sint2korr, sint4korr, st_mysql_time::time_type, to, and st_mysql_time::year.
Referenced by fetch_result_datetime(), and fetch_result_with_conversion().
03428 { 03429 uint length= net_field_length(pos); 03430 03431 if (length) 03432 { 03433 uchar *to= *pos; 03434 03435 tm->neg= 0; 03436 tm->year= (uint) sint2korr(to); 03437 tm->month= (uint) to[2]; 03438 tm->day= (uint) to[3]; 03439 03440 if (length > 4) 03441 { 03442 tm->hour= (uint) to[4]; 03443 tm->minute= (uint) to[5]; 03444 tm->second= (uint) to[6]; 03445 } 03446 else 03447 tm->hour= tm->minute= tm->second= 0; 03448 tm->second_part= (length > 7) ? (ulong) sint4korr(to+7) : 0; 03449 tm->time_type= MYSQL_TIMESTAMP_DATETIME; 03450 03451 *pos+= length; 03452 } 03453 else 03454 set_zero_time(tm, MYSQL_TIMESTAMP_DATETIME); 03455 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void read_binary_time | ( | MYSQL_TIME * | tm, | |
| uchar ** | pos | |||
| ) | [static] |
Definition at line 3397 of file libmysql.c.
References bool, st_mysql_time::day, st_mysql_time::hour, st_mysql_time::minute, st_mysql_time::month, MYSQL_TIMESTAMP_TIME, st_mysql_time::neg, net_field_length(), st_mysql_time::second, st_mysql_time::second_part, set_zero_time(), sint4korr, st_mysql_time::time_type, to, and st_mysql_time::year.
Referenced by fetch_result_time(), and fetch_result_with_conversion().
03398 { 03399 /* net_field_length will set pos to the first byte of data */ 03400 uint length= net_field_length(pos); 03401 03402 if (length) 03403 { 03404 uchar *to= *pos; 03405 tm->neg= (bool) to[0]; 03406 03407 tm->day= (ulong) sint4korr(to+1); 03408 tm->hour= (uint) to[5]; 03409 tm->minute= (uint) to[6]; 03410 tm->second= (uint) to[7]; 03411 tm->second_part= (length > 8) ? (ulong) sint4korr(to+8) : 0; 03412 tm->year= tm->month= 0; 03413 if (tm->day) 03414 { 03415 /* Convert days to hours at once */ 03416 tm->hour+= tm->day*24; 03417 tm->day= 0; 03418 } 03419 tm->time_type= MYSQL_TIMESTAMP_TIME; 03420 03421 *pos+= length; 03422 } 03423 else 03424 set_zero_time(tm, MYSQL_TIMESTAMP_TIME); 03425 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void read_user_name | ( | char * | name | ) |
Definition at line 745 of file libmysql.c.
00746 { 00747 DBUG_ENTER("read_user_name"); 00748 if (geteuid() == 0) 00749 (void) strmov(name,"root"); /* allow use of surun */ 00750 else 00751 { 00752 #ifdef HAVE_GETPWUID 00753 struct passwd *skr; 00754 const char *str; 00755 if ((str=getlogin()) == NULL) 00756 { 00757 if ((skr=getpwuid(geteuid())) != NULL) 00758 str=skr->pw_name; 00759 else if (!(str=getenv("USER")) && !(str=getenv("LOGNAME")) && 00760 !(str=getenv("LOGIN"))) 00761 str="UNKNOWN_USER"; 00762 } 00763 (void) strmake(name,str,USERNAME_LENGTH); 00764 #elif HAVE_CUSERID 00765 (void) cuserid(name); 00766 #else 00767 strmov(name,"UNKNOWN_USER"); 00768 #endif 00769 } 00770 DBUG_VOID_RETURN; 00771 }
| static my_bool reset_stmt_handle | ( | MYSQL_STMT * | stmt, | |
| uint | flags | |||
| ) | [static] |
Definition at line 4896 of file libmysql.c.
References st_mysql_methods::advanced_command, st_mysql_data::alloc, COM_STMT_RESET, st_mysql_data::data, st_mysql_stmt::data_cursor, st_mysql_stmt::field_count, st_mysql_methods::flush_use_result, free_root(), int4store, st_net::last_errno, st_net::last_error, st_mysql_bind::long_data_used, st_mysql::methods, MY_KEEP_PREALLOC, MYF, st_mysql_stmt::mysql, mysql, MYSQL_STATUS_READY, MYSQL_STMT_HEADER, MYSQL_STMT_INIT_DONE, MYSQL_STMT_PREPARE_DONE, st_mysql::net, NULL, st_mysql_stmt::param_count, st_mysql_stmt::params, st_mysql_stmt::read_row_func, RESET_LONG_DATA, RESET_SERVER_SIDE, RESET_STORE_RESULT, st_mysql_stmt::result, st_mysql_data::rows, set_stmt_errmsg(), st_net::sqlstate, st_mysql_stmt::state, st_mysql::status, stmt_clear_error(), st_mysql_stmt::stmt_id, stmt_read_row_no_result_set(), TRUE, st_mysql_stmt::unbuffered_fetch_cancelled, and st_mysql::unbuffered_fetch_owner.
Referenced by mysql_stmt_execute(), mysql_stmt_free_result(), mysql_stmt_prepare(), and mysql_stmt_reset().
04897 { 04898 /* If statement hasn't been prepared there is nothing to reset */ 04899 if ((int) stmt->state > (int) MYSQL_STMT_INIT_DONE) 04900 { 04901 MYSQL *mysql= stmt->mysql; 04902 MYSQL_DATA *result= &stmt->result; 04903 04904 /* 04905 Reset stored result set if so was requested or it's a part 04906 of cursor fetch. 04907 */ 04908 if (result->data && (flags & RESET_STORE_RESULT)) 04909 { 04910 /* Result buffered */ 04911 free_root(&result->alloc, MYF(MY_KEEP_PREALLOC)); 04912 result->data= NULL; 04913 result->rows= 0; 04914 stmt->data_cursor= NULL; 04915 } 04916 if (flags & RESET_LONG_DATA) 04917 { 04918 MYSQL_BIND *param= stmt->params, *param_end= param + stmt->param_count; 04919 /* Clear long_data_used flags */ 04920 for (; param < param_end; param++) 04921 param->long_data_used= 0; 04922 } 04923 stmt->read_row_func= stmt_read_row_no_result_set; 04924 if (mysql) 04925 { 04926 if ((int) stmt->state > (int) MYSQL_STMT_PREPARE_DONE) 04927 { 04928 if (mysql->unbuffered_fetch_owner == &stmt->unbuffered_fetch_cancelled) 04929 mysql->unbuffered_fetch_owner= 0; 04930 if (stmt->field_count && mysql->status != MYSQL_STATUS_READY) 04931 { 04932 /* There is a result set and it belongs to this statement */ 04933 (*mysql->methods->flush_use_result)(mysql); 04934 if (mysql->unbuffered_fetch_owner) 04935 *mysql->unbuffered_fetch_owner= TRUE; 04936 mysql->status= MYSQL_STATUS_READY; 04937 } 04938 } 04939 if (flags & RESET_SERVER_SIDE) 04940 { 04941 /* 04942 Reset the server side statement and close the server side 04943 cursor if it exists. 04944 */ 04945 char buff[MYSQL_STMT_HEADER]; /* packet header: 4 bytes for stmt id */ 04946 int4store(buff, stmt->stmt_id); 04947 if ((*mysql->methods->advanced_command)(mysql, COM_STMT_RESET, buff, 04948 sizeof(buff), 0, 0, 0, NULL)) 04949 { 04950 set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, 04951 mysql->net.sqlstate); 04952 stmt->state= MYSQL_STMT_INIT_DONE; 04953 return 1; 04954 } 04955 stmt_clear_error(stmt); 04956 } 04957 } 04958 stmt->state= MYSQL_STMT_PREPARE_DONE; 04959 } 04960 return 0; 04961 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void set_stmt_errmsg | ( | MYSQL_STMT * | stmt, | |
| const char * | err, | |||
| int | errcode, | |||
| const char * | sqlstate | |||
| ) |
Definition at line 1846 of file libmysql.c.
References DBUG_ASSERT, DBUG_ENTER, DBUG_PRINT, DBUG_VOID_RETURN, st_mysql_stmt::last_errno, st_mysql_stmt::last_error, st_mysql_stmt::sqlstate, and strmov().
01848 { 01849 DBUG_ENTER("set_stmt_errmsg"); 01850 DBUG_PRINT("enter", ("error: %d/%s '%s'", errcode, sqlstate, err)); 01851 DBUG_ASSERT(stmt != 0); 01852 01853 stmt->last_errno= errcode; 01854 if (err && err[0]) 01855 strmov(stmt->last_error, err); 01856 strmov(stmt->sqlstate, sqlstate); 01857 01858 DBUG_VOID_RETURN; 01859 }
Here is the call graph for this function:

| static void set_stmt_error | ( | MYSQL_STMT * | stmt, | |
| int | errcode, | |||
| const char * | sqlstate | |||
| ) | [static] |
Definition at line 1827 of file libmysql.c.
References DBUG_ASSERT, DBUG_ENTER, DBUG_PRINT, DBUG_VOID_RETURN, ER, st_mysql_stmt::last_errno, st_mysql_stmt::last_error, st_mysql_stmt::sqlstate, and strmov().
Referenced by cli_read_binary_rows(), cli_stmt_execute(), mysql_stmt_attr_set(), mysql_stmt_bind_param(), mysql_stmt_bind_result(), mysql_stmt_execute(), mysql_stmt_fetch_column(), mysql_stmt_prepare(), mysql_stmt_reset(), mysql_stmt_result_metadata(), mysql_stmt_send_long_data(), mysql_stmt_store_result(), stmt_read_row_no_result_set(), stmt_read_row_unbuffered(), and store_param().
01829 { 01830 DBUG_ENTER("set_stmt_error"); 01831 DBUG_PRINT("enter", ("error: %d '%s'", errcode, ER(errcode))); 01832 DBUG_ASSERT(stmt != 0); 01833 01834 stmt->last_errno= errcode; 01835 strmov(stmt->last_error, ER(errcode)); 01836 strmov(stmt->sqlstate, sqlstate); 01837 01838 DBUG_VOID_RETURN; 01839 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static my_bool setup_one_fetch_function | ( | MYSQL_BIND * | bind, | |
| MYSQL_FIELD * | field | |||
| ) | [static] |
Definition at line 4254 of file libmysql.c.
References st_mysql_bind::buffer_length, st_mysql_bind::buffer_type, DBUG_ASSERT, FALSE, st_mysql_bind::fetch_result, fetch_result_bin(), fetch_result_date(), fetch_result_datetime(), fetch_result_double(), fetch_result_float(), fetch_result_int32(), fetch_result_int64(), fetch_result_short(), fetch_result_str(), fetch_result_time(), fetch_result_tinyint(), fetch_result_with_conversion(), is_binary_compatible(), st_mysql_bind::length, MAX_DATE_STRING_REP_LENGTH, MAX_DOUBLE_STRING_REP_LENGTH, st_mysql_field::max_length, MYSQL_TYPE_BIT, MYSQL_TYPE_BLOB, MYSQL_TYPE_DATE, MYSQL_TYPE_DATETIME, MYSQL_TYPE_DECIMAL, MYSQL_TYPE_DOUBLE, MYSQL_TYPE_ENUM, MYSQL_TYPE_FLOAT, MYSQL_TYPE_GEOMETRY, MYSQL_TYPE_INT24, MYSQL_TYPE_LONG, MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONGLONG, MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_NULL, MYSQL_TYPE_SET, MYSQL_TYPE_SHORT, MYSQL_TYPE_STRING, MYSQL_TYPE_TIME, MYSQL_TYPE_TIMESTAMP, MYSQL_TYPE_TINY, MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_VAR_STRING, MYSQL_TYPE_YEAR, st_mysql_bind::pack_length, st_mysql_bind::skip_result, skip_result_fixed(), skip_result_string(), skip_result_with_length(), TRUE, and st_mysql_field::type.
Referenced by mysql_stmt_bind_result(), and update_stmt_fields().
04255 { 04256 /* Setup data copy functions for the different supported types */ 04257 switch (param->buffer_type) { 04258 case MYSQL_TYPE_NULL: /* for dummy binds */ 04259 /* 04260 It's not binary compatible with anything the server can return: 04261 no need to setup fetch_result, as it'll be reset anyway 04262 */ 04263 *param->length= 0; 04264 break; 04265 case MYSQL_TYPE_TINY: 04266 param->fetch_result= fetch_result_tinyint; 04267 *param->length= 1; 04268 break; 04269 case MYSQL_TYPE_SHORT: 04270 case MYSQL_TYPE_YEAR: 04271 param->fetch_result= fetch_result_short; 04272 *param->length= 2; 04273 break; 04274 case MYSQL_TYPE_INT24: 04275 case MYSQL_TYPE_LONG: 04276 param->fetch_result= fetch_result_int32; 04277 *param->length= 4; 04278 break; 04279 case MYSQL_TYPE_LONGLONG: 04280 param->fetch_result= fetch_result_int64; 04281 *param->length= 8; 04282 break; 04283 case MYSQL_TYPE_FLOAT: 04284 param->fetch_result= fetch_result_float; 04285 *param->length= 4; 04286 break; 04287 case MYSQL_TYPE_DOUBLE: 04288 param->fetch_result= fetch_result_double; 04289 *param->length= 8; 04290 break; 04291 case MYSQL_TYPE_TIME: 04292 param->fetch_result= fetch_result_time; 04293 *param->length= sizeof(MYSQL_TIME); 04294 break; 04295 case MYSQL_TYPE_DATE: 04296 param->fetch_result= fetch_result_date; 04297 *param->length= sizeof(MYSQL_TIME); 04298 break; 04299 case MYSQL_TYPE_DATETIME: 04300 case MYSQL_TYPE_TIMESTAMP: 04301 param->fetch_result= fetch_result_datetime; 04302 *param->length= sizeof(MYSQL_TIME); 04303 break; 04304 case MYSQL_TYPE_TINY_BLOB: 04305 case MYSQL_TYPE_MEDIUM_BLOB: 04306 case MYSQL_TYPE_LONG_BLOB: 04307 case MYSQL_TYPE_BLOB: 04308 case MYSQL_TYPE_BIT: 04309 DBUG_ASSERT(param->buffer_length != 0); 04310 param->fetch_result= fetch_result_bin; 04311 break; 04312 case MYSQL_TYPE_VAR_STRING: 04313 case MYSQL_TYPE_STRING: 04314 case MYSQL_TYPE_DECIMAL: 04315 case MYSQL_TYPE_NEWDECIMAL: 04316 DBUG_ASSERT(param->buffer_length != 0); 04317 param->fetch_result= fetch_result_str; 04318 break; 04319 default: 04320 return TRUE; 04321 } 04322 if (! is_binary_compatible(param->buffer_type, field->type)) 04323 param->fetch_result= fetch_result_with_conversion; 04324 04325 /* Setup skip_result functions (to calculate max_length) */ 04326 param->skip_result= skip_result_fixed; 04327 switch (field->type) { 04328 case MYSQL_TYPE_NULL: /* for dummy binds */ 04329 param->pack_length= 0; 04330 field->max_length= 0; 04331 break; 04332 case MYSQL_TYPE_TINY: 04333 param->pack_length= 1; 04334 field->max_length= 4; /* as in '-127' */ 04335 break; 04336 case MYSQL_TYPE_YEAR: 04337 case MYSQL_TYPE_SHORT: 04338 param->pack_length= 2; 04339 field->max_length= 6; /* as in '-32767' */ 04340 break; 04341 case MYSQL_TYPE_INT24: 04342 field->max_length= 9; /* as in '16777216' or in '-8388607' */ 04343 param->pack_length= 4; 04344 break; 04345 case MYSQL_TYPE_LONG: 04346 field->max_length= 11; /* '-2147483647' */ 04347 param->pack_length= 4; 04348 break; 04349 case MYSQL_TYPE_LONGLONG: 04350 field->max_length= 21; /* '18446744073709551616' */ 04351 param->pack_length= 8; 04352 break; 04353 case MYSQL_TYPE_FLOAT: 04354 param->pack_length= 4; 04355 field->max_length= MAX_DOUBLE_STRING_REP_LENGTH; 04356 break; 04357 case MYSQL_TYPE_DOUBLE: 04358 param->pack_length= 8; 04359 field->max_length= MAX_DOUBLE_STRING_REP_LENGTH; 04360 break; 04361 case MYSQL_TYPE_TIME: 04362 field->max_length= 15; /* 19:23:48.123456 */ 04363 param->skip_result= skip_result_with_length; 04364 case MYSQL_TYPE_DATE: 04365 field->max_length= 10; /* 2003-11-11 */ 04366 param->skip_result= skip_result_with_length; 04367 break; 04368 break; 04369 case MYSQL_TYPE_DATETIME: 04370 case MYSQL_TYPE_TIMESTAMP: 04371 param->skip_result= skip_result_with_length; 04372 field->max_length= MAX_DATE_STRING_REP_LENGTH; 04373 break; 04374 case MYSQL_TYPE_DECIMAL: 04375 case MYSQL_TYPE_NEWDECIMAL: 04376 case MYSQL_TYPE_ENUM: 04377 case MYSQL_TYPE_SET: 04378 case MYSQL_TYPE_GEOMETRY: 04379 case MYSQL_TYPE_TINY_BLOB: 04380 case MYSQL_TYPE_MEDIUM_BLOB: 04381 case MYSQL_TYPE_LONG_BLOB: 04382 case MYSQL_TYPE_BLOB: 04383 case MYSQL_TYPE_VAR_STRING: 04384 case MYSQL_TYPE_STRING: 04385 case MYSQL_TYPE_BIT: 04386 param->skip_result= skip_result_string; 04387 break; 04388 default: 04389 return TRUE; 04390 } 04391 return FALSE; 04392 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void skip_result_fixed | ( | MYSQL_BIND * | param, | |
| MYSQL_FIELD *field | __attribute__((unused)), | |||
| uchar ** | row | |||
| ) | [static] |
Definition at line 4150 of file libmysql.c.
References st_mysql_bind::pack_length.
Referenced by setup_one_fetch_function().
04154 { 04155 (*row)+= param->pack_length; 04156 }
Here is the caller graph for this function:

| static void skip_result_string | ( | MYSQL_BIND *param | __attribute__((unused)), | |
| MYSQL_FIELD * | field, | |||
| uchar ** | row | |||
| ) | [static] |
Definition at line 4169 of file libmysql.c.
References st_mysql_field::max_length, and net_field_length().
Referenced by setup_one_fetch_function().
04173 { 04174 ulong length= net_field_length(row); 04175 (*row)+= length; 04176 if (field->max_length < length) 04177 field->max_length= length; 04178 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void skip_result_with_length | ( | MYSQL_BIND *param | __attribute__((unused)), | |
| MYSQL_FIELD *field | __attribute__((unused)), | |||
| uchar ** | row | |||
| ) | [static] |
Definition at line 4159 of file libmysql.c.
References net_field_length().
Referenced by setup_one_fetch_function().
04163 { 04164 ulong length= net_field_length(row); 04165 (*row)+= length; 04166 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static MYSQL * spawn_init | ( | MYSQL * | parent, | |
| const char * | host, | |||
| unsigned int | port, | |||
| const char * | user, | |||
| const char * | passwd | |||
| ) | [static] |
Definition at line 1046 of file libmysql.c.
References st_mysql_options::db, st_mysql::db, DBUG_ENTER, DBUG_RETURN, st_mysql::host, st_mysql_options::host, my_strdup(), MYF, mysql_init(), st_mysql::options, st_mysql::passwd, st_mysql_options::password, st_mysql_options::port, st_mysql::rpl_pivot, st_mysql::user, and st_mysql_options::user.
Referenced by get_master(), get_slaves_from_master(), mysql_add_slave(), and mysql_set_master().
01049 { 01050 MYSQL* child; 01051 DBUG_ENTER("spawn_init"); 01052 if (!(child= mysql_init(0))) 01053 DBUG_RETURN(0); 01054 01055 child->options.user= my_strdup((user) ? user : 01056 (parent->user ? parent->user : 01057 parent->options.user), MYF(0)); 01058 child->options.password= my_strdup((passwd) ? passwd : 01059 (parent->passwd ? 01060 parent->passwd : 01061 parent->options.password), MYF(0)); 01062 child->options.port= port; 01063 child->options.host= my_strdup((host) ? host : 01064 (parent->host ? 01065 parent->host : 01066 parent->options.host), MYF(0)); 01067 if (parent->db) 01068 child->options.db= my_strdup(parent->db, MYF(0)); 01069 else if (parent->options.db) 01070 child->options.db= my_strdup(parent->options.db, MYF(0)); 01071 01072 /* 01073 rpl_pivot is set to 1 in mysql_init(); Reset it as we are not doing 01074 replication here 01075 */ 01076 child->rpl_pivot= 0; 01077 DBUG_RETURN(child); 01078 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void stmt_clear_error | ( | MYSQL_STMT * | stmt | ) | [static] |
Definition at line 1812 of file libmysql.c.
References st_mysql_stmt::last_errno, st_mysql_stmt::last_error, not_error_sqlstate, st_mysql_stmt::sqlstate, and strmov().
Referenced by reset_stmt_handle().
01813 { 01814 if (stmt->last_errno) 01815 { 01816 stmt->last_errno= 0; 01817 stmt->last_error[0]= '\0'; 01818 strmov(stmt->sqlstate, not_error_sqlstate); 01819 } 01820 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int stmt_fetch_row | ( | MYSQL_STMT * | stmt, | |
| uchar * | row | |||
| ) | [static] |
Definition at line 4469 of file libmysql.c.
References st_mysql_stmt::bind, st_mysql_stmt::bind_result_done, DBUG_ASSERT, st_mysql_bind::error, st_mysql_bind::fetch_result, st_mysql_stmt::field_count, st_mysql_stmt::fields, st_mysql_bind::is_null, MYSQL_DATA_TRUNCATED, NULL, REPORT_DATA_TRUNCATION, and st_mysql_bind::row_ptr.
Referenced by mysql_stmt_fetch().
04470 { 04471 MYSQL_BIND *bind, *end; 04472 MYSQL_FIELD *field; 04473 uchar *null_ptr, bit; 04474 int truncation_count= 0; 04475 /* 04476 Precondition: if stmt->field_count is zero or row is NULL, read_row_* 04477 function must return no data. 04478 */ 04479 DBUG_ASSERT(stmt->field_count); 04480 DBUG_ASSERT(row); 04481 04482 if (!stmt->bind_result_done) 04483 { 04484 /* If output parameters were not bound we should just return success */ 04485 return 0; 04486 } 04487 04488 null_ptr= row; 04489 row+= (stmt->field_count+9)/8; /* skip null bits */ 04490 bit= 4; /* first 2 bits are reserved */ 04491 04492 /* Copy complete row to application buffers */ 04493 for (bind= stmt->bind, end= bind + stmt->field_count, field= stmt->fields ; 04494 bind < end ; 04495 bind++, field++) 04496 { 04497 *bind->error= 0; 04498 if (*null_ptr & bit) 04499 { 04500 /* 04501 We should set both row_ptr and is_null to be able to see 04502 nulls in mysql_stmt_fetch_column. This is because is_null may point 04503 to user data which can be overwritten between mysql_stmt_fetch and 04504 mysql_stmt_fetch_column, and in this case nullness of column will be 04505 lost. See mysql_stmt_fetch_column for details. 04506 */ 04507 bind->row_ptr= NULL; 04508 *bind->is_null= 1; 04509 } 04510 else 04511 { 04512 *bind->is_null= 0; 04513 bind->row_ptr= row; 04514 (*bind->fetch_result)(bind, field, &row); 04515 truncation_count+= *bind->error; 04516 } 04517 if (!((bit<<=1) & 255)) 04518 { 04519 bit= 1; /* To next byte */ 04520 null_ptr++; 04521 } 04522 } 04523 if (truncation_count && (stmt->bind_result_done & REPORT_DATA_TRUNCATION)) 04524 return MYSQL_DATA_TRUNCATED; 04525 return 0; 04526 }
Here is the caller graph for this function:

| static int stmt_read_row_buffered | ( | MYSQL_STMT * | stmt, | |
| unsigned char ** | row | |||
| ) | [static] |
Definition at line 2586 of file libmysql.c.
References st_mysql_rows::data, st_mysql_stmt::data_cursor, MYSQL_NO_DATA, and st_mysql_rows::next.
Referenced by mysql_stmt_data_seek(), mysql_stmt_store_result(), and stmt_read_row_from_cursor().
02587 { 02588 if (stmt->data_cursor) 02589 { 02590 *row= (uchar *) stmt->data_cursor->data; 02591 stmt->data_cursor= stmt->data_cursor->next; 02592 return 0; 02593 } 02594 *row= 0; 02595 return MYSQL_NO_DATA; 02596 }
Here is the caller graph for this function:

| static int stmt_read_row_from_cursor | ( | MYSQL_STMT * | stmt, | |
| unsigned char ** | row | |||
| ) | [static] |
Definition at line 2677 of file libmysql.c.
References st_mysql_methods::advanced_command, st_mysql_data::alloc, COM_STMT_FETCH, st_mysql_data::data, st_mysql_stmt::data_cursor, free_root(), int4store, st_net::last_errno, st_net::last_error, st_mysql::methods, MY_KEEP_PREALLOC, MYF, st_mysql_stmt::mysql, mysql, MYSQL_NO_DATA, st_mysql::net, NULL, NullS, st_mysql_stmt::prefetch_rows, st_mysql_methods::read_rows_from_cursor, st_mysql_stmt::result, st_mysql_data::rows, st_mysql::server_status, st_mysql_stmt::server_status, SERVER_STATUS_LAST_ROW_SENT, set_stmt_errmsg(), st_net::sqlstate, st_mysql_stmt::stmt_id, and stmt_read_row_buffered().
Referenced by mysql_stmt_execute().
02678 { 02679 if (stmt->data_cursor) 02680 return stmt_read_row_buffered(stmt, row); 02681 if (stmt->server_status & SERVER_STATUS_LAST_ROW_SENT) 02682 stmt->server_status &= ~SERVER_STATUS_LAST_ROW_SENT; 02683 else 02684 { 02685 MYSQL *mysql= stmt->mysql; 02686 NET *net= &mysql->net; 02687 MYSQL_DATA *result= &stmt->result; 02688 char buff[4 /* statement id */ + 02689 4 /* number of rows to fetch */]; 02690 02691 free_root(&result->alloc, MYF(MY_KEEP_PREALLOC)); 02692 result->data= NULL; 02693 result->rows= 0; 02694 /* Send row request to the server */ 02695 int4store(buff, stmt->stmt_id); 02696 int4store(buff + 4, stmt->prefetch_rows); /* number of rows to fetch */ 02697 if ((*mysql->methods->advanced_command)(mysql, COM_STMT_FETCH, 02698 buff, sizeof(buff), NullS, 0, 02699 1, NULL)) 02700 { 02701 set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); 02702 return 1; 02703 } 02704 if ((*mysql->methods->read_rows_from_cursor)(stmt)) 02705 return 1; 02706 stmt->server_status= mysql->server_status; 02707 02708 stmt->data_cursor= result->data; 02709 return stmt_read_row_buffered(stmt, row); 02710 } 02711 *row= 0; 02712 return MYSQL_NO_DATA; 02713 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int stmt_read_row_no_data | ( | MYSQL_STMT *stmt | __attribute__((unused)), | |
| unsigned char **row | __attribute__((unused)) | |||
| ) | [static] |
Definition at line 2722 of file libmysql.c.
References MYSQL_NO_DATA.
02724 { 02725 return MYSQL_NO_DATA; 02726 }
| static int stmt_read_row_no_data | ( | MYSQL_STMT * | stmt, | |
| unsigned char ** | row | |||
| ) | [static] |
| static int stmt_read_row_no_result_set | ( | MYSQL_STMT *stmt | __attribute__((unused)), | |
| unsigned char **row | __attribute__((unused)) | |||
| ) | [static] |
Definition at line 2729 of file libmysql.c.
References CR_NO_RESULT_SET, set_stmt_error(), and unknown_sqlstate.
02731 { 02732 set_stmt_error(stmt, CR_NO_RESULT_SET, unknown_sqlstate); 02733 return 1; 02734 }
Here is the call graph for this function:

| static int stmt_read_row_no_result_set | ( | MYSQL_STMT * | stmt, | |
| unsigned char ** | row | |||
| ) | [static] |
Referenced by mysql_stmt_fetch(), mysql_stmt_init(), and reset_stmt_handle().
Here is the caller graph for this function:

| static int stmt_read_row_unbuffered | ( | MYSQL_STMT * | stmt, | |
| unsigned char ** | row | |||
| ) | [static] |
Definition at line 2617 of file libmysql.c.
References CR_COMMANDS_OUT_OF_SYNC, CR_FETCH_CANCELED, CR_SERVER_LOST, error, st_net::last_errno, st_net::last_error, st_mysql::methods, st_mysql_stmt::mysql, mysql, MYSQL_NO_DATA, MYSQL_STATUS_GET_RESULT, MYSQL_STATUS_READY, st_mysql::net, set_stmt_errmsg(), set_stmt_error(), st_net::sqlstate, st_mysql::status, st_mysql_methods::unbuffered_fetch, st_mysql_stmt::unbuffered_fetch_cancelled, st_mysql::unbuffered_fetch_owner, and unknown_sqlstate.
Referenced by mysql_stmt_execute().
02618 { 02619 int rc= 1; 02620 MYSQL *mysql= stmt->mysql; 02621 /* 02622 This function won't be called if stmt->field_count is zero 02623 or execution wasn't done: this is ensured by mysql_stmt_execute. 02624 */ 02625 if (!mysql) 02626 { 02627 set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate); 02628 return 1; 02629 } 02630 if (mysql->status != MYSQL_STATUS_GET_RESULT) 02631 { 02632 set_stmt_error(stmt, stmt->unbuffered_fetch_cancelled ? 02633 CR_FETCH_CANCELED : CR_COMMANDS_OUT_OF_SYNC, 02634 unknown_sqlstate); 02635 goto error; 02636 } 02637 if ((*mysql->methods->unbuffered_fetch)(mysql, (char**) row)) 02638 { 02639 set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, 02640 mysql->net.sqlstate); 02641 /* 02642 If there was an error, there are no more pending rows: 02643 reset statement status to not hang up in following 02644 mysql_stmt_close (it will try to flush result set before 02645 closing the statement). 02646 */ 02647 mysql->status= MYSQL_STATUS_READY; 02648 goto error; 02649 } 02650 if (!*row) 02651 { 02652 mysql->status= MYSQL_STATUS_READY; 02653 rc= MYSQL_NO_DATA; 02654 goto error; 02655 } 02656 return 0; 02657 error: 02658 if (mysql->unbuffered_fetch_owner == &stmt->unbuffered_fetch_cancelled) 02659 mysql->unbuffered_fetch_owner= 0; 02660 return rc; 02661 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void stmt_update_metadata | ( | MYSQL_STMT * | stmt, | |
| MYSQL_ROWS * | data | |||
| ) | [static] |
Definition at line 4688 of file libmysql.c.
References st_mysql_stmt::bind, data, DBUG_ASSERT, DBUG_OFF, st_mysql_stmt::field_count, st_mysql_stmt::fields, and st_mysql_bind::skip_result.
Referenced by mysql_stmt_store_result().
04689 { 04690 MYSQL_BIND *bind, *end; 04691 MYSQL_FIELD *field; 04692 uchar *null_ptr, bit; 04693 uchar *row= (uchar*) data->data; 04694 #ifndef DBUG_OFF 04695 uchar *row_end= row + data->length; 04696 #endif 04697 04698 null_ptr= row; 04699 row+= (stmt->field_count+9)/8; /* skip null bits */ 04700 bit= 4; /* first 2 bits are reserved */ 04701 04702 /* Go through all fields and calculate metadata */ 04703 for (bind= stmt->bind, end= bind + stmt->field_count, field= stmt->fields ; 04704 bind < end ; 04705 bind++, field++) 04706 { 04707 if (!(*null_ptr & bit)) 04708 (*bind->skip_result)(bind, field, &row); 04709 DBUG_ASSERT(row <= row_end); 04710 if (!((bit<<=1) & 255)) 04711 { 04712 bit= 1; /* To next byte */ 04713 null_ptr++; 04714 } 04715 } 04716 }
Here is the caller graph for this function:

| static my_bool store_param | ( | MYSQL_STMT * | stmt, | |
| MYSQL_BIND * | param | |||
| ) | [static] |
Definition at line 2436 of file libmysql.c.
References st_mysql_bind::buffer, st_mysql_bind::buffer_type, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_mysql_bind::is_null, st_net::last_errno, st_mysql_bind::length, my_realloc_str(), st_mysql_stmt::mysql, st_mysql::net, set_stmt_error(), st_mysql_bind::store_param_func, store_param_null(), and unknown_sqlstate.
Referenced by cli_stmt_execute().
02437 { 02438 NET *net= &stmt->mysql->net; 02439 DBUG_ENTER("store_param"); 02440 DBUG_PRINT("enter",("type: %d, buffer:%lx, length: %lu is_null: %d", 02441 param->buffer_type, 02442 param->buffer ? param->buffer : "0", *param->length, 02443 *param->is_null)); 02444 02445 if (*param->is_null) 02446 store_param_null(net, param); 02447 else 02448 { 02449 /* 02450 Param->length should ALWAYS point to the correct length for the type 02451 Either to the length pointer given by the user or param->buffer_length 02452 */ 02453 if ((my_realloc_str(net, *param->length))) 02454 { 02455 set_stmt_error(stmt, net->last_errno, unknown_sqlstate); 02456 DBUG_RETURN(1); 02457 } 02458 (*param->store_param_func)(net, param); 02459 } 02460 DBUG_RETURN(0); 02461 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void store_param_date | ( | NET * | net, | |
| MYSQL_BIND * | param | |||
| ) | [static] |
Definition at line 2386 of file libmysql.c.
References st_mysql_bind::buffer, st_mysql_time::hour, st_mysql_time::minute, net_store_datetime(), st_mysql_time::second, and st_mysql_time::second_part.
Referenced by mysql_stmt_bind_param().
02387 { 02388 MYSQL_TIME tm= *((MYSQL_TIME *) param->buffer); 02389 tm.hour= tm.minute= tm.second= tm.second_part= 0; 02390 net_store_datetime(net, &tm); 02391 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void store_param_datetime | ( | NET * | net, | |
| MYSQL_BIND * | param | |||
| ) | [static] |
Definition at line 2393 of file libmysql.c.
References st_mysql_bind::buffer, and net_store_datetime().
Referenced by mysql_stmt_bind_param().
02394 { 02395 MYSQL_TIME *tm= (MYSQL_TIME *) param->buffer; 02396 net_store_datetime(net, tm); 02397 }
Here is the call graph for this function:

