434
434
my_bool STDCALL mysql_read_query_result(MYSQL *mysql);
438
The following definitions are added for the enhanced
439
client-server protocol
442
/* statement state */
443
enum enum_mysql_stmt_state
445
MYSQL_STMT_INIT_DONE= 1, MYSQL_STMT_PREPARE_DONE, MYSQL_STMT_EXECUTE_DONE,
446
MYSQL_STMT_FETCH_DONE
450
/* statement handler */
451
typedef struct st_mysql_stmt
453
MEM_ROOT mem_root; /* root allocations */
454
LIST list; /* list to keep track of all stmts */
455
MYSQL *mysql; /* connection handle */
456
MYSQL_FIELD *fields; /* result set metadata */
457
MYSQL_DATA result; /* cached result set */
458
MYSQL_ROWS *data_cursor; /* current row in cached result */
460
mysql_stmt_fetch() calls this function to fetch one row (it's different
461
for buffered, unbuffered and cursor fetch).
463
int (*read_row_func)(struct st_mysql_stmt *stmt,
464
unsigned char **row);
465
/* copy of mysql->affected_rows after statement execution */
466
my_ulonglong affected_rows;
467
my_ulonglong insert_id; /* copy of mysql->insert_id */
468
unsigned long stmt_id; /* Id for prepared statement */
469
unsigned long flags; /* i.e. type of cursor to open */
470
unsigned long prefetch_rows; /* number of rows per one COM_FETCH */
472
Copied from mysql->server_status after execute/fetch to know
473
server-side cursor status for this statement.
475
unsigned int server_status;
476
unsigned int last_errno; /* error code */
477
unsigned int param_count; /* input parameter count */
478
unsigned int field_count; /* number of columns in result set */
479
enum enum_mysql_stmt_state state; /* statement state */
480
char last_error[MYSQL_ERRMSG_SIZE]; /* error message */
481
char sqlstate[SQLSTATE_LENGTH+1];
482
/* Types of input parameters should be sent to server */
483
my_bool send_types_to_server;
484
my_bool bind_param_done; /* input buffers were supplied */
485
unsigned char bind_result_done; /* output buffers were supplied */
486
/* mysql_stmt_close() had to cancel this result */
487
my_bool unbuffered_fetch_cancelled;
489
Is set to true if we need to calculate field->max_length for
490
metadata fields when doing mysql_stmt_store_result.
492
my_bool update_max_length;
496
enum enum_stmt_attr_type
499
When doing mysql_stmt_store_result calculate max_length attribute
500
of statement metadata. This is to be consistent with the old API,
501
where this was done automatically.
502
In the new API we do that only by request because it slows down
503
mysql_stmt_store_result sufficiently.
505
STMT_ATTR_UPDATE_MAX_LENGTH,
507
unsigned long with combination of cursor flags (read only, for update,
510
STMT_ATTR_CURSOR_TYPE,
512
Amount of rows to retrieve from server per one fetch if using cursors.
513
Accepts unsigned long attribute in the range 1 - ulong_max
515
STMT_ATTR_PREFETCH_ROWS
519
438
typedef struct st_mysql_methods
544
MYSQL_STMT * STDCALL mysql_stmt_init(MYSQL *mysql);
545
int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query,
546
unsigned long length);
547
int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt);
548
int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt);
549
int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt);
550
unsigned long STDCALL mysql_stmt_param_count(MYSQL_STMT * stmt);
551
my_bool STDCALL mysql_stmt_attr_set(MYSQL_STMT *stmt,
552
enum enum_stmt_attr_type attr_type,
554
my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt,
555
enum enum_stmt_attr_type attr_type,
557
my_bool STDCALL mysql_stmt_close(MYSQL_STMT * stmt);
558
my_bool STDCALL mysql_stmt_reset(MYSQL_STMT * stmt);
559
my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt);
560
my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt,
561
unsigned int param_number,
563
unsigned long length);
564
MYSQL_RES *STDCALL mysql_stmt_result_metadata(MYSQL_STMT *stmt);
565
MYSQL_RES *STDCALL mysql_stmt_param_metadata(MYSQL_STMT *stmt);
566
unsigned int STDCALL mysql_stmt_errno(MYSQL_STMT * stmt);
567
const char *STDCALL mysql_stmt_error(MYSQL_STMT * stmt);
568
const char *STDCALL mysql_stmt_sqlstate(MYSQL_STMT * stmt);
569
MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(MYSQL_STMT *stmt,
570
MYSQL_ROW_OFFSET offset);
571
MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(MYSQL_STMT *stmt);
572
void STDCALL mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong offset);
573
my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt);
574
my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt);
575
my_ulonglong STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt);
576
unsigned int STDCALL mysql_stmt_field_count(MYSQL_STMT *stmt);
578
462
my_bool STDCALL mysql_commit(MYSQL * mysql);
579
463
my_bool STDCALL mysql_rollback(MYSQL * mysql);
580
464
my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode);
605
489
#define simple_command(mysql, command, arg, length, skip_check) \
606
490
(*(mysql)->methods->advanced_command)(mysql, command, 0, \
607
0, arg, length, skip_check, NULL)
608
#define stmt_command(mysql, command, arg, length, stmt) \
609
(*(mysql)->methods->advanced_command)(mysql, command, 0, \
610
0, arg, length, 1, stmt)
491
0, arg, length, skip_check)
612
493
#ifdef __cplusplus