2008-06-17 14:27:04 +02:00
|
|
|
typedef char my_bool;
|
|
|
|
typedef int my_socket;
|
|
|
|
enum enum_server_command
|
|
|
|
{
|
|
|
|
COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST,
|
|
|
|
COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS,
|
|
|
|
COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING,
|
|
|
|
COM_TIME, COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP,
|
|
|
|
COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE,
|
|
|
|
COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE,
|
|
|
|
COM_STMT_RESET, COM_SET_OPTION, COM_STMT_FETCH, COM_DAEMON,
|
2016-10-12 18:36:22 +02:00
|
|
|
COM_UNIMPLEMENTED,
|
|
|
|
COM_RESET_CONNECTION,
|
2015-11-26 11:21:56 +01:00
|
|
|
COM_MDB_GAP_BEG,
|
2016-08-29 12:10:17 +02:00
|
|
|
COM_MDB_GAP_END=250,
|
2016-06-29 20:03:06 +02:00
|
|
|
COM_SLAVE_WORKER=251,
|
|
|
|
COM_SLAVE_IO=252,
|
|
|
|
COM_SLAVE_SQL=253,
|
|
|
|
COM_MULTI=254,
|
|
|
|
COM_END=255
|
|
|
|
};
|
|
|
|
enum enum_indicator_type
|
|
|
|
{
|
|
|
|
STMT_INDICATOR_NONE= 0,
|
|
|
|
STMT_INDICATOR_NULL,
|
2016-11-26 17:23:24 +01:00
|
|
|
STMT_INDICATOR_DEFAULT,
|
|
|
|
STMT_INDICATOR_IGNORE
|
2008-06-17 14:27:04 +02:00
|
|
|
};
|
|
|
|
struct st_vio;
|
|
|
|
typedef struct st_vio Vio;
|
|
|
|
typedef struct st_net {
|
|
|
|
Vio *vio;
|
|
|
|
unsigned char *buff,*buff_end,*write_pos,*read_pos;
|
|
|
|
my_socket fd;
|
|
|
|
unsigned long remain_in_buf,length, buf_length, where_b;
|
|
|
|
unsigned long max_packet,max_packet_size;
|
|
|
|
unsigned int pkt_nr,compress_pkt_nr;
|
|
|
|
unsigned int write_timeout, read_timeout, retry_count;
|
|
|
|
int fcntl;
|
|
|
|
unsigned int *return_status;
|
|
|
|
unsigned char reading_or_writing;
|
|
|
|
char save_char;
|
2010-02-23 13:04:58 +01:00
|
|
|
char net_skip_rest_factor;
|
MDEV-4011 Added per thread memory counting and usage
Base code and idea from a patch from by plinux at Taobao.
The idea is that we mark all memory that are thread specific with MY_THREAD_SPECIFIC.
Memory counting is done per thread in the my_malloc_size_cb_func callback function from my_malloc().
There are plenty of new asserts to ensure that for a debug server the counting is correct.
Information_schema.processlist gets two new columns: MEMORY_USED and EXAMINED_ROWS.
- The later is there mainly to show how query is progressing.
The following changes in interfaces was needed to get this to work:
- init_alloc_root() amd init_sql_alloc() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- One now have to use alloc_root_set_min_malloc() to set min memory to be allocated by alloc_root()
- my_init_dynamic_array() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- my_net_init() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- Added flag for hash_init() so that one can mark hash table to be thread specific.
- Added flags to init_tree() so that one can mark tree to be thread specific.
- Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
- Added flag to Warning_info::Warning_info() if the structure should be fully initialized.
- String elements can now be marked as thread specific.
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Changed type of myf from int to ulong, as this is always a set of bit flags.
Other things:
- Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
- We now also show EXAMINED_ROWS in SHOW PROCESSLIST
- Added new variable 'memory_used'
- Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
- Removed calls to the obsoleted function init_dynamic_array()
- Use set_current_thd() instead of my_pthread_setspecific_ptr(THR_THD,...)
client/completion_hash.cc:
Updated call to init_alloc_root()
client/mysql.cc:
Updated call to init_alloc_root()
client/mysqlbinlog.cc:
init_dynamic_array() -> my_init_dynamic_array()
Updated call to init_alloc_root()
client/mysqlcheck.c:
Updated call to my_init_dynamic_array()
client/mysqldump.c:
Updated call to init_alloc_root()
client/mysqltest.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Fixed compiler warnings
extra/comp_err.c:
Updated call to my_init_dynamic_array()
extra/resolve_stack_dump.c:
Updated call to my_init_dynamic_array()
include/hash.h:
Added HASH_THREAD_SPECIFIC
include/heap.h:
Added flag is internal temporary table.
include/my_dir.h:
Safety fix: Ensure that MY_DONT_SORT and MY_WANT_STAT don't interfer with other mysys flags
include/my_global.h:
Changed type of myf from int to ulong, as this is always a set of bit flags.
include/my_sys.h:
Added MY_THREAD_SPECIFIC and MY_THREAD_MOVE
Added malloc_flags to DYNAMIC_ARRAY
Added extra mysys flag argument to my_init_dynamic_array()
Removed deprecated functions init_dynamic_array() and my_init_dynamic_array.._ci
Updated paramaters for init_alloc_root()
include/my_tree.h:
Added my_flags to allow one to use MY_THREAD_SPECIFIC with hash tables.
Removed with_delete. One should now instead use MY_TREE_WITH_DELETE_FLAG
Updated parameters to init_tree()
include/myisamchk.h:
Added malloc_flags to allow one to use MY_THREAD_SPECIFIC for checks.
include/mysql.h:
Added MYSQL_THREAD_SPECIFIC_MALLOC
Used 'unused1' to mark memory as thread specific.
include/mysql.h.pp:
Updated file
include/mysql_com.h:
Used 'unused1' to mark memory as thread specific.
Updated parameters for my_net_init()
libmysql/libmysql.c:
Updated call to init_alloc_root() to mark memory thread specific.
libmysqld/emb_qcache.cc:
Updated call to init_alloc_root()
libmysqld/lib_sql.cc:
Updated call to init_alloc_root()
mysql-test/r/create.result:
Updated results
mysql-test/r/user_var.result:
Updated results
mysql-test/suite/funcs_1/datadict/processlist_priv.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/datadict/processlist_val.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/is_columns_is.result:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result:
Updated results
mysql-test/suite/funcs_1/r/processlist_val_no_prot.result:
Updated results
mysql-test/t/show_explain.test:
Fixed usage of debug variable so that one can run test with --debug
mysql-test/t/user_var.test:
Added test of memory_usage variable.
mysys/array.c:
Added extra my_flags option to init_dynamic_array() and init_dynamic_array2() so that one can mark memory with MY_THREAD_SPECIFIC
All allocated memory is marked with the given my_flags.
Removed obsolete function init_dynamic_array()
mysys/default.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
mysys/hash.c:
Updated call to my_init_dynamic_array_ci().
Allocated memory is marked with MY_THREAD_SPECIFIC if HASH_THREAD_SPECIFIC is used.
mysys/ma_dyncol.c:
init_dynamic_array() -> my_init_dynamic_array()
Added #if to get rid of compiler warnings
mysys/mf_tempdir.c:
Updated call to my_init_dynamic_array()
mysys/my_alloc.c:
Added extra parameter to init_alloc_root() so that one can mark memory with MY_THREAD_SPECIFIC
Extend MEM_ROOT with a flag if memory is thread specific.
This is stored in block_size, to keep the size of the MEM_ROOT object identical as before.
Allocated memory is marked with MY_THREAD_SPECIFIC if used with init_alloc_root()
mysys/my_chmod.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_chsize.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_copy.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_create.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_delete.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_error.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fopen.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fstream.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_getwd.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_lib.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Updated DBUG_PRINT because of change of myf type
mysys/my_lock.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_malloc.c:
Store at start of each allocated memory block the size of the block and if the block is thread specific.
Call malloc_size_cb_func, if set, with the memory allocated/freed.
Updated DBUG_PRINT because of change of myf type
mysys/my_open.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_pread.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_read.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_redel.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_rename.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_seek.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_sync.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_thr_init.c:
Ensure that one can call my_thread_dbug_id() even if thread is not properly initialized.
mysys/my_write.c:
Updated DBUG_PRINT because of change of myf type
mysys/mysys_priv.h:
Updated parameters to sf_malloc and sf_realloc()
mysys/safemalloc.c:
Added checking that for memory marked with MY_THREAD_SPECIFIC that it's the same thread that is allocation and freeing the memory.
Added sf_malloc_dbug_id() to allow MariaDB to specify which THD is handling the memory.
Added my_flags arguments to sf_malloc() and sf_realloc() to be able to mark memory with MY_THREAD_SPECIFIC.
Added sf_report_leaked_memory() to get list of memory not freed by a thread.
mysys/tree.c:
Added flags to init_tree() so that one can mark tree to be thread specific.
Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
Updated call to init_alloc_root()
All allocated memory is marked with the given malloc flags
mysys/waiting_threads.c:
Updated call to my_init_dynamic_array()
sql-common/client.c:
Updated call to init_alloc_root() and my_net_init() to mark memory thread specific.
Updated call to my_init_dynamic_array().
Added MYSQL_THREAD_SPECIFIC_MALLOC so that client can mark memory as MY_THREAD_SPECIFIC.
sql-common/client_plugin.c:
Updated call to init_alloc_root()
sql/debug_sync.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/event_scheduler.cc:
Removed calls to net_end() as this is now done in ~THD()
Call set_current_thd() to ensure that memory is assigned to right thread.
sql/events.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/filesort.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/filesort_utils.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/ha_ndbcluster.cc:
Updated call to init_alloc_root()
Updated call to my_net_init()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_ndbcluster_binlog.cc:
Updated call to my_net_init()
Updated call to init_sql_alloc()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_partition.cc:
Updated call to init_alloc_root()
sql/handler.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
Added missing call to my_dir_end()
sql/item_func.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_subselect.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_sum.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/log.cc:
More DBUG
Updated call to init_alloc_root()
sql/mdl.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/mysqld.cc:
Added total_memory_used
Updated call to init_alloc_root()
Move mysql_cond_broadcast() before my_thread_end()
Added mariadb_dbug_id() to count memory per THD instead of per thread.
Added my_malloc_size_cb_func() callback function for my_malloc() to count memory.
Move initialization of mysqld_server_started and mysqld_server_initialized earlier.
Updated call to my_init_dynamic_array().
Updated call to my_net_init().
Call my_pthread_setspecific_ptr(THR_THD,...) to ensure that memory is assigned to right thread.
Added status variable 'memory_used'.
Updated call to init_alloc_root()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/mysqld.h:
Added set_current_thd()
sql/net_serv.cc:
Added new parameter to my_net_init() so that one can mark memory with MY_THREAD_SPECIFIC.
Store in net->thread_specific_malloc if memory is thread specific.
Mark memory to be thread specific if requested.
sql/opt_range.cc:
Updated call to my_init_dynamic_array()
Updated call to init_sql_alloc()
Added MY_THREAD_SPECIFIC to allocated memory.
sql/opt_subselect.cc:
Updated call to init_sql_alloc() to mark memory thread specific.
sql/protocol.cc:
Fixed compiler warning
sql/records.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/rpl_filter.cc:
Updated call to my_init_dynamic_array()
sql/rpl_handler.cc:
Updated call to my_init_dynamic_array2()
sql/rpl_handler.h:
Updated call to init_sql_alloc()
sql/rpl_mi.cc:
Updated call to my_init_dynamic_array()
sql/rpl_tblmap.cc:
Updated call to init_alloc_root()
sql/rpl_utility.cc:
Updated call to my_init_dynamic_array()
sql/slave.cc:
Initialize things properly before calling functions that allocate memory.
Removed calls to net_end() as this is now done in ~THD()
sql/sp_head.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
Added parameter to warning_info() that it should be fully initialized.
sql/sp_pcontext.cc:
Updated call to my_init_dynamic_array()
sql/sql_acl.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_admin.cc:
Added parameter to warning_info() that it should be fully initialized.
sql/sql_analyse.h:
Updated call to init_tree() to mark memory thread specific.
sql/sql_array.h:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_audit.cc:
Updated call to my_init_dynamic_array()
sql/sql_base.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_cache.cc:
Updated comment
sql/sql_class.cc:
Added parameter to warning_info() that not initialize it until THD is fully created.
Updated call to init_sql_alloc()
Mark THD::user_vars has to be thread specific.
Updated call to my_init_dynamic_array()
Ensure that memory allocated by THD is assigned to the THD.
More DBUG
Always acll net_end() in ~THD()
Assert that all memory signed to this THD is really deleted at ~THD.
Fixed set_status_var_init() to not reset memory_used.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_class.h:
Added MY_THREAD_SPECIFIC to allocated memory.
Added malloc_size to THD to record allocated memory per THD.
sql/sql_delete.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_error.cc:
Added 'initialize' parameter to Warning_info() to say if should allocate memory for it's structures.
This is used by THD::THD() to not allocate memory until THD is ready.
Added Warning_info::free_memory()
sql/sql_error.h:
Updated Warning_info() class.
sql/sql_handler.cc:
Updated call to init_alloc_root() to mark memory thread specific.
sql/sql_insert.cc:
More DBUG
sql/sql_join_cache.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_lex.cc:
Updated call to my_init_dynamic_array()
sql/sql_lex.h:
Updated call to my_init_dynamic_array()
sql/sql_load.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_parse.cc:
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
Ensure that examined_row_count() is reset before query.
Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Don't restore thd->status_var.memory_used when restoring thd->status_var
sql/sql_plugin.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Don't allocate THD on the stack, as this causes problems with valgrind when doing thd memory counting.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_prepare.cc:
Added parameter to warning_info() that it should be fully initialized.
Updated call to init_sql_alloc() to mark memory thread specific.
sql/sql_reload.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_select.cc:
Updated call to my_init_dynamic_array() and init_sql_alloc() to mark memory thread specific.
Added MY_THREAD_SPECIFIC to allocated memory.
More DBUG
sql/sql_servers.cc:
Updated call to init_sql_alloc() to mark memory some memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_show.cc:
Updated call to my_init_dynamic_array()
Mark my_dir() memory thread specific.
Use my_pthread_setspecific_ptr(THR_THD,...) to mark that allocated memory should be allocated to calling thread.
More DBUG.
Added malloc_size and examined_row_count to SHOW PROCESSLIST.
Added MY_THREAD_SPECIFIC to allocated memory.
Updated call to init_sql_alloc()
Added parameter to warning_info() that it should be fully initialized.
sql/sql_statistics.cc:
Fixed compiler warning
sql/sql_string.cc:
String elements can now be marked as thread specific.
sql/sql_string.h:
String elements can now be marked as thread specific.
sql/sql_table.cc:
Updated call to init_sql_alloc() and my_malloc() to mark memory thread specific
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Fixed compiler warning
sql/sql_test.cc:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_trigger.cc:
Updated call to init_sql_alloc()
sql/sql_udf.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_update.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/table.cc:
Updated call to init_sql_alloc().
Mark memory used by temporary tables, that are not for slave threads, as MY_THREAD_SPECIFIC
Updated call to init_sql_alloc()
sql/thr_malloc.cc:
Added my_flags argument to init_sql_alloc() to be able to mark memory as MY_THREAD_SPECIFIC.
sql/thr_malloc.h:
Updated prototype for init_sql_alloc()
sql/tztime.cc:
Updated call to init_sql_alloc()
Updated call to init_alloc_root() to mark memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/uniques.cc:
Updated calls to init_tree(), my_init_dynamic_array() and my_malloc() to mark memory thread specific.
sql/unireg.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/csv/ha_tina.cc:
Updated call to init_alloc_root()
storage/federated/ha_federated.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Ensure that memory allocated by fedarated is registered for the system, not for the thread.
storage/federatedx/federatedx_io_mysql.cc:
Updated call to my_init_dynamic_array()
storage/federatedx/ha_federatedx.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
storage/heap/ha_heap.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/heap/heapdef.h:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_block.c:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_create.c:
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Use MY_TREE_WITH_DELETE instead of removed option 'with_delete'.
storage/heap/hp_open.c:
Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
storage/heap/hp_write.c:
Added new parameter to hp_get_new_block()
storage/maria/ma_bitmap.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_blockrec.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_check.c:
Updated call to init_alloc_root()
storage/maria/ma_ft_boolean_search.c:
Updated calls to init_tree() and init_alloc_root()
storage/maria/ma_ft_nlq_search.c:
Updated call to init_tree()
storage/maria/ma_ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/maria/ma_loghandler.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_open.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_sort.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_write.c:
Updated calls to my_init_dynamic_array() and init_tree()
storage/maria/maria_pack.c:
Updated call to init_tree()
storage/maria/unittest/sequence_storage.c:
Updated call to my_init_dynamic_array()
storage/myisam/ft_boolean_search.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_nlq_search.c:
Updated call to init_tree()
storage/myisam/ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_stopwords.c:
Updated call to init_tree()
storage/myisam/mi_check.c:
Updated call to init_alloc_root()
storage/myisam/mi_write.c:
Updated call to my_init_dynamic_array()
Updated call to init_tree()
storage/myisam/myisamlog.c:
Updated call to init_tree()
storage/myisam/myisampack.c:
Updated call to init_tree()
storage/myisam/sort.c:
Updated call to my_init_dynamic_array()
storage/myisammrg/ha_myisammrg.cc:
Updated call to init_sql_alloc()
storage/perfschema/pfs_check.cc:
Rest current_thd
storage/perfschema/pfs_instr.cc:
Removed DBUG_ENTER/DBUG_VOID_RETURN as at this point my_thread_var is not allocated anymore, which can cause problems.
support-files/compiler_warnings.supp:
Disable compiler warning from offsetof macro.
2013-01-23 16:16:14 +01:00
|
|
|
my_bool thread_specific_malloc;
|
2016-08-21 19:38:47 +02:00
|
|
|
unsigned char compress;
|
2009-10-09 11:06:41 +02:00
|
|
|
my_bool unused3;
|
2015-08-31 11:57:46 +02:00
|
|
|
void *thd;
|
2008-06-17 14:27:04 +02:00
|
|
|
unsigned int last_errno;
|
|
|
|
unsigned char error;
|
2009-10-09 11:06:41 +02:00
|
|
|
my_bool unused4;
|
|
|
|
my_bool unused5;
|
2008-06-17 14:27:04 +02:00
|
|
|
char last_error[512];
|
|
|
|
char sqlstate[5 +1];
|
|
|
|
void *extension;
|
|
|
|
} NET;
|
|
|
|
enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
|
|
|
|
MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG,
|
|
|
|
MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
|
|
|
|
MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP,
|
|
|
|
MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24,
|
|
|
|
MYSQL_TYPE_DATE, MYSQL_TYPE_TIME,
|
|
|
|
MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
|
|
|
|
MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
|
|
|
|
MYSQL_TYPE_BIT,
|
2014-07-19 12:38:40 +02:00
|
|
|
MYSQL_TYPE_TIMESTAMP2,
|
|
|
|
MYSQL_TYPE_DATETIME2,
|
|
|
|
MYSQL_TYPE_TIME2,
|
2008-06-17 14:27:04 +02:00
|
|
|
MYSQL_TYPE_NEWDECIMAL=246,
|
|
|
|
MYSQL_TYPE_ENUM=247,
|
|
|
|
MYSQL_TYPE_SET=248,
|
|
|
|
MYSQL_TYPE_TINY_BLOB=249,
|
|
|
|
MYSQL_TYPE_MEDIUM_BLOB=250,
|
|
|
|
MYSQL_TYPE_LONG_BLOB=251,
|
|
|
|
MYSQL_TYPE_BLOB=252,
|
|
|
|
MYSQL_TYPE_VAR_STRING=253,
|
|
|
|
MYSQL_TYPE_STRING=254,
|
|
|
|
MYSQL_TYPE_GEOMETRY=255
|
|
|
|
};
|
|
|
|
enum mysql_enum_shutdown_level {
|
|
|
|
SHUTDOWN_DEFAULT = 0,
|
|
|
|
SHUTDOWN_WAIT_CONNECTIONS= (unsigned char)(1 << 0),
|
|
|
|
SHUTDOWN_WAIT_TRANSACTIONS= (unsigned char)(1 << 1),
|
|
|
|
SHUTDOWN_WAIT_UPDATES= (unsigned char)(1 << 3),
|
|
|
|
SHUTDOWN_WAIT_ALL_BUFFERS= ((unsigned char)(1 << 3) << 1),
|
2012-03-26 12:33:49 +02:00
|
|
|
SHUTDOWN_WAIT_CRITICAL_BUFFERS= ((unsigned char)(1 << 3) << 1) + 1
|
2008-06-17 14:27:04 +02:00
|
|
|
};
|
|
|
|
enum enum_cursor_type
|
|
|
|
{
|
|
|
|
CURSOR_TYPE_NO_CURSOR= 0,
|
|
|
|
CURSOR_TYPE_READ_ONLY= 1,
|
|
|
|
CURSOR_TYPE_FOR_UPDATE= 2,
|
|
|
|
CURSOR_TYPE_SCROLLABLE= 4
|
|
|
|
};
|
|
|
|
enum enum_mysql_set_option
|
|
|
|
{
|
|
|
|
MYSQL_OPTION_MULTI_STATEMENTS_ON,
|
|
|
|
MYSQL_OPTION_MULTI_STATEMENTS_OFF
|
|
|
|
};
|
2016-04-15 20:40:25 +02:00
|
|
|
enum enum_session_state_type
|
|
|
|
{
|
|
|
|
SESSION_TRACK_SYSTEM_VARIABLES,
|
|
|
|
SESSION_TRACK_SCHEMA,
|
|
|
|
SESSION_TRACK_STATE_CHANGE,
|
|
|
|
SESSION_TRACK_GTIDS,
|
|
|
|
SESSION_TRACK_TRANSACTION_CHARACTERISTICS,
|
2016-05-30 21:22:50 +02:00
|
|
|
SESSION_TRACK_TRANSACTION_STATE,
|
2016-08-09 15:49:30 +02:00
|
|
|
SESSION_TRACK_always_at_the_end
|
2016-04-15 20:40:25 +02:00
|
|
|
};
|
2015-08-31 11:57:46 +02:00
|
|
|
my_bool my_net_init(NET *net, Vio* vio, void *thd, unsigned int my_flags);
|
2008-06-17 14:27:04 +02:00
|
|
|
void my_net_local_init(NET *net);
|
|
|
|
void net_end(NET *net);
|
2013-04-17 22:37:06 +02:00
|
|
|
void net_clear(NET *net, my_bool clear_buffer);
|
2008-06-17 14:27:04 +02:00
|
|
|
my_bool net_realloc(NET *net, size_t length);
|
|
|
|
my_bool net_flush(NET *net);
|
|
|
|
my_bool my_net_write(NET *net,const unsigned char *packet, size_t len);
|
|
|
|
my_bool net_write_command(NET *net,unsigned char command,
|
|
|
|
const unsigned char *header, size_t head_len,
|
|
|
|
const unsigned char *packet, size_t len);
|
|
|
|
int net_real_write(NET *net,const unsigned char *packet, size_t len);
|
2014-07-19 12:38:40 +02:00
|
|
|
unsigned long my_net_read_packet(NET *net, my_bool read_from_server);
|
2016-10-31 07:35:02 +01:00
|
|
|
unsigned long my_net_read_packet_reallen(NET *net, my_bool read_from_server,
|
|
|
|
unsigned long* reallen);
|
2008-06-17 14:27:04 +02:00
|
|
|
struct sockaddr;
|
|
|
|
int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen,
|
|
|
|
unsigned int timeout);
|
2008-10-10 17:28:41 +02:00
|
|
|
struct my_rnd_struct;
|
|
|
|
enum Item_result
|
|
|
|
{
|
2011-05-28 04:11:32 +02:00
|
|
|
STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT, DECIMAL_RESULT,
|
2015-09-06 11:25:47 +02:00
|
|
|
TIME_RESULT
|
2008-06-17 14:27:04 +02:00
|
|
|
};
|
|
|
|
typedef struct st_udf_args
|
|
|
|
{
|
|
|
|
unsigned int arg_count;
|
|
|
|
enum Item_result *arg_type;
|
|
|
|
char **args;
|
|
|
|
unsigned long *lengths;
|
|
|
|
char *maybe_null;
|
|
|
|
char **attributes;
|
|
|
|
unsigned long *attribute_lengths;
|
|
|
|
void *extension;
|
|
|
|
} UDF_ARGS;
|
|
|
|
typedef struct st_udf_init
|
|
|
|
{
|
|
|
|
my_bool maybe_null;
|
|
|
|
unsigned int decimals;
|
|
|
|
unsigned long max_length;
|
|
|
|
char *ptr;
|
|
|
|
my_bool const_item;
|
|
|
|
void *extension;
|
|
|
|
} UDF_INIT;
|
2008-10-10 17:28:41 +02:00
|
|
|
void create_random_string(char *to, unsigned int length,
|
|
|
|
struct my_rnd_struct *rand_st);
|
2008-06-17 14:27:04 +02:00
|
|
|
void hash_password(unsigned long *to, const char *password, unsigned int password_len);
|
|
|
|
void make_scrambled_password_323(char *to, const char *password);
|
|
|
|
void scramble_323(char *to, const char *message, const char *password);
|
2010-03-29 17:13:53 +02:00
|
|
|
my_bool check_scramble_323(const unsigned char *reply, const char *message,
|
2008-06-17 14:27:04 +02:00
|
|
|
unsigned long *salt);
|
|
|
|
void get_salt_from_password_323(unsigned long *res, const char *password);
|
|
|
|
void make_scrambled_password(char *to, const char *password);
|
|
|
|
void scramble(char *to, const char *message, const char *password);
|
2010-03-29 17:13:53 +02:00
|
|
|
my_bool check_scramble(const unsigned char *reply, const char *message,
|
2008-06-17 14:27:04 +02:00
|
|
|
const unsigned char *hash_stage2);
|
|
|
|
void get_salt_from_password(unsigned char *res, const char *password);
|
|
|
|
char *octet2hex(char *to, const char *str, unsigned int len);
|
|
|
|
char *get_tty_password(const char *opt_message);
|
2011-12-02 16:26:43 +01:00
|
|
|
void get_tty_password_buff(const char *opt_message, char *to, size_t length);
|
2008-06-17 14:27:04 +02:00
|
|
|
const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
|
|
|
|
my_bool my_thread_init(void);
|
|
|
|
void my_thread_end(void);
|
2013-05-24 17:09:59 +02:00
|
|
|
typedef long my_time_t;
|
2008-06-17 14:27:04 +02:00
|
|
|
enum enum_mysql_timestamp_type
|
|
|
|
{
|
|
|
|
MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
|
|
|
|
MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
|
|
|
|
};
|
|
|
|
typedef struct st_mysql_time
|
|
|
|
{
|
|
|
|
unsigned int year, month, day, hour, minute, second;
|
|
|
|
unsigned long second_part;
|
|
|
|
my_bool neg;
|
|
|
|
enum enum_mysql_timestamp_type time_type;
|
|
|
|
} MYSQL_TIME;
|
|
|
|
typedef struct st_list {
|
|
|
|
struct st_list *prev,*next;
|
|
|
|
void *data;
|
|
|
|
} LIST;
|
|
|
|
typedef int (*list_walk_action)(void *,void *);
|
|
|
|
extern LIST *list_add(LIST *root,LIST *element);
|
|
|
|
extern LIST *list_delete(LIST *root,LIST *element);
|
|
|
|
extern LIST *list_cons(void *data,LIST *root);
|
|
|
|
extern LIST *list_reverse(LIST *root);
|
|
|
|
extern void list_free(LIST *root,unsigned int free_data);
|
|
|
|
extern unsigned int list_length(LIST *);
|
|
|
|
extern int list_walk(LIST *,list_walk_action action,unsigned char * argument);
|
2015-01-19 17:31:59 +01:00
|
|
|
extern unsigned int mariadb_deinitialize_ssl;
|
2008-06-17 14:27:04 +02:00
|
|
|
extern unsigned int mysql_port;
|
|
|
|
extern char *mysql_unix_port;
|
|
|
|
typedef struct st_mysql_field {
|
|
|
|
char *name;
|
|
|
|
char *org_name;
|
|
|
|
char *table;
|
|
|
|
char *org_table;
|
|
|
|
char *db;
|
|
|
|
char *catalog;
|
|
|
|
char *def;
|
|
|
|
unsigned long length;
|
|
|
|
unsigned long max_length;
|
|
|
|
unsigned int name_length;
|
|
|
|
unsigned int org_name_length;
|
|
|
|
unsigned int table_length;
|
|
|
|
unsigned int org_table_length;
|
|
|
|
unsigned int db_length;
|
|
|
|
unsigned int catalog_length;
|
|
|
|
unsigned int def_length;
|
|
|
|
unsigned int flags;
|
|
|
|
unsigned int decimals;
|
|
|
|
unsigned int charsetnr;
|
|
|
|
enum enum_field_types type;
|
|
|
|
void *extension;
|
|
|
|
} MYSQL_FIELD;
|
|
|
|
typedef char **MYSQL_ROW;
|
|
|
|
typedef unsigned int MYSQL_FIELD_OFFSET;
|
|
|
|
typedef unsigned long long my_ulonglong;
|
|
|
|
typedef struct st_used_mem
|
|
|
|
{
|
|
|
|
struct st_used_mem *next;
|
2008-10-10 17:28:41 +02:00
|
|
|
size_t left;
|
|
|
|
size_t size;
|
2008-06-17 14:27:04 +02:00
|
|
|
} USED_MEM;
|
|
|
|
typedef struct st_mem_root
|
|
|
|
{
|
|
|
|
USED_MEM *free;
|
|
|
|
USED_MEM *used;
|
|
|
|
USED_MEM *pre_alloc;
|
|
|
|
size_t min_malloc;
|
|
|
|
size_t block_size;
|
|
|
|
unsigned int block_num;
|
|
|
|
unsigned int first_block_usage;
|
|
|
|
void (*error_handler)(void);
|
|
|
|
} MEM_ROOT;
|
|
|
|
typedef struct st_typelib {
|
|
|
|
unsigned int count;
|
|
|
|
const char *name;
|
|
|
|
const char **type_names;
|
|
|
|
unsigned int *type_lengths;
|
|
|
|
} TYPELIB;
|
|
|
|
extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position);
|
2009-03-12 23:27:35 +01:00
|
|
|
extern int find_type_with_warning(const char *x, TYPELIB *typelib,
|
|
|
|
const char *option);
|
2008-06-17 14:27:04 +02:00
|
|
|
extern int find_type_or_exit(const char *x, TYPELIB *typelib,
|
|
|
|
const char *option);
|
Fix for BUG#59894
"set optimizer_switch to e or d causes invalid memory writes/valgrind warnings":
due to prefix support, the argument "e" was overwritten with its full value
"engine_condition_pushdown", which caused a buffer overrun.
This was wrong usage of find_type(); other wrong usages are fixed here too.
Please start reading with the comment of typelib.c.
client/mysqldump.c:
A bug: find_type() expects a bitmap as 3rd argument
(each bit is a flag controlling a behaviour of the function);
here it was instead passed the length of the string to search!
That could give random behaviour of find_type()
depending on the string.
We rather need to pass a correct flag to find_type().
The correct flag is FIND_TYPE_BASIC (0).
Flag 8 is not needed as buff cannot have a comma (see how buff is filled).
Flag 1 looks like a superfluous restriction.
Flag 4 is not user-friendly (why use
--compatible=2 rather than --compatible=mysql40 ?, and
we probably not commit to "2" always meaning "mysql40"
until the end of times).
include/mysql.h.pp:
This isn't a problematic API change as we go from char* to const char*:
existing code will run unchanged.
include/typelib.h:
named constants. Not an enum to not significantly change
the declaration of find_type() which would be an API change
(typelib.h is included in mysql.h).
mysql-test/r/mysqldump.result:
correct result (see the two requested modes in SQL_MODE)
mysql-test/suite/sys_vars/t/optimizer_switch_basic.test:
test for BUG#59894. The second SET used to crash.
mysql-test/t/mysqldump.test:
we had no test for multiple modes in --compatible, which is
supported according to --help
mysys/typelib.c:
Fix for BUG#59894. parse_name() is asked to match "e" with a row
of the TYPELIB (the TYPELIB lists permitted flags of optimizer_switch;
and comes from optimizer_switch_names[] of sys_vars.cc).
find_type() is capable of supporting prefixes, but if it is not
passed flag 2 in third argument, it will overwrite its first
argument (the string to search for) with the complete name,
here overwriting "e" with "engine_condition_pushdown". But
as this "e" was a buffer allocated in an Item, it was not big
enough to host the longer name, thus the crash.
We don't need to know the complete flag's name; the output used
from find_type() is just the flag's number (== function's return
code). So we can pass flag 2 to find_type() in parse_name().
After doing this fix and the other fixes in this patch, all usages
of find_type() were using flag 2; in most usages the string to search for,
is not guaranteed to be long enough to host the complete name
(it is either directly from argv, or from alloc_root/my_malloc
done in an earlier call).
Thus, flag 2 is here made implicit: callers need not pass it anymore,
it is always automatically turned on.
This allows to eliminate an oddity: parse_name() took a const char**,
and then removed "const" before calling find_type(), which could
theoretically modify the pointed data, thus lying on constness.
Last, constants for find_type() are now named.
sql-common/client.c:
Two bugs:
1) The enum was not in sync with the array (due to a bad porting of WL 1054;
the extra OPT_ values are about options present in 5.1 and deleted in 5.5);
added a compile_time_assert() to make sure this doesn't happen again
2) find_type() was writing past the end of opt_arg; as opt_arg was allocated
with alloc_root() with no extra space, this was an overrun; it could be seen
when
** building with -DWITH_VALGRIND -DHAVE_purify -DEXTRA_DEBUG
** making execution go through the faulty code; this faulty
code is executed only if the client asks to read a configuration
file like this:
mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, "/tmp/cnf.cnf");
so by adding such line to the start of mysql_client_test.c::client_connect(),
we could see the valgrind warning:
==30548== Invalid write of size 1
==30548== at 0x4C2624C: strcpy (mc_replace_strmem.c:303)
==30548== by 0x48DC29: find_type (typelib.c:120)
==30548== by 0x465686: mysql_read_default_options (client.c:1344)
==30548== by 0x46830F: mysql_real_connect (client.c:2971)
==30548== by 0x409339: client_connect (mysql_client_test.c:331)
==30548== by 0x463A7F: main (mysql_client_test.c:19902)
==30548== Address 0x61875ad is 0 bytes after a block of size 29 alloc'd
==30548== at 0x4C25153: malloc (vg_replace_malloc.c:195)
==30548== by 0x49BFF1: my_malloc (my_malloc.c:38)
==30548== by 0x49C65C: alloc_root (my_alloc.c:166)
==30548== by 0x48EF97: handle_default_option (default.c:381)
==30548== by 0x49068C: search_default_file_with_ext (default.c:992)
==30548== by 0x48F929: search_default_file (default.c:670)
==30548== by 0x48EDC4: my_search_option_files (default.c:312)
==30548== by 0x48F4B1: my_load_defaults (default.c:576)
==30548== by 0x46517A: mysql_read_default_options (client.c:1207)
==30548== by 0x46830F: mysql_real_connect (client.c:2971)
==30548== by 0x409339: client_connect (mysql_client_test.c:331)
==30548== by 0x463A7F: main (mysql_client_test.c:19902)
This is fixed by having find_type() not overwrite anymore.
sql/sql_help.cc:
cast not needed anymore.
sql/table.cc:
cast not needed anymore.
2011-02-11 15:00:09 +01:00
|
|
|
extern int find_type(const char *x, const TYPELIB *typelib, unsigned int flags);
|
2008-06-17 14:27:04 +02:00
|
|
|
extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
|
|
|
|
extern const char *get_type(TYPELIB *typelib,unsigned int nr);
|
|
|
|
extern TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from);
|
|
|
|
extern TYPELIB sql_protocol_typelib;
|
2010-07-05 23:00:56 +02:00
|
|
|
my_ulonglong find_set_from_flags(const TYPELIB *lib, unsigned int default_name,
|
2009-12-22 10:35:56 +01:00
|
|
|
my_ulonglong cur_set, my_ulonglong default_set,
|
2010-07-05 23:00:56 +02:00
|
|
|
const char *str, unsigned int length,
|
|
|
|
char **err_pos, unsigned int *err_len);
|
2008-06-17 14:27:04 +02:00
|
|
|
typedef struct st_mysql_rows {
|
|
|
|
struct st_mysql_rows *next;
|
|
|
|
MYSQL_ROW data;
|
|
|
|
unsigned long length;
|
|
|
|
} MYSQL_ROWS;
|
|
|
|
typedef MYSQL_ROWS *MYSQL_ROW_OFFSET;
|
|
|
|
typedef struct embedded_query_result EMBEDDED_QUERY_RESULT;
|
|
|
|
typedef struct st_mysql_data {
|
|
|
|
MYSQL_ROWS *data;
|
|
|
|
struct embedded_query_result *embedded_info;
|
|
|
|
MEM_ROOT alloc;
|
|
|
|
my_ulonglong rows;
|
|
|
|
unsigned int fields;
|
|
|
|
void *extension;
|
|
|
|
} MYSQL_DATA;
|
|
|
|
enum mysql_option
|
|
|
|
{
|
|
|
|
MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE,
|
|
|
|
MYSQL_INIT_COMMAND, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP,
|
|
|
|
MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_OPT_LOCAL_INFILE,
|
|
|
|
MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT,
|
|
|
|
MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT,
|
|
|
|
MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION,
|
|
|
|
MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH,
|
|
|
|
MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT,
|
2011-07-01 14:08:30 +02:00
|
|
|
MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH,
|
2012-08-14 16:23:34 +02:00
|
|
|
MYSQL_OPT_BIND,
|
|
|
|
MYSQL_OPT_SSL_KEY, MYSQL_OPT_SSL_CERT,
|
|
|
|
MYSQL_OPT_SSL_CA, MYSQL_OPT_SSL_CAPATH, MYSQL_OPT_SSL_CIPHER,
|
|
|
|
MYSQL_OPT_SSL_CRL, MYSQL_OPT_SSL_CRLPATH,
|
2013-07-18 16:46:57 +02:00
|
|
|
MYSQL_OPT_CONNECT_ATTR_RESET, MYSQL_OPT_CONNECT_ATTR_ADD,
|
|
|
|
MYSQL_OPT_CONNECT_ATTR_DELETE,
|
|
|
|
MYSQL_SERVER_PUBLIC_KEY,
|
2013-06-11 11:11:05 +02:00
|
|
|
MYSQL_ENABLE_CLEARTEXT_PLUGIN,
|
2013-07-18 16:46:57 +02:00
|
|
|
MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS,
|
2013-04-18 21:54:13 +02:00
|
|
|
MYSQL_PROGRESS_CALLBACK=5999,
|
|
|
|
MYSQL_OPT_NONBLOCK,
|
|
|
|
MYSQL_OPT_USE_THREAD_SPECIFIC_MEMORY
|
2008-06-17 14:27:04 +02:00
|
|
|
};
|
2010-03-29 17:13:53 +02:00
|
|
|
struct st_mysql_options_extention;
|
2008-06-17 14:27:04 +02:00
|
|
|
struct st_mysql_options {
|
|
|
|
unsigned int connect_timeout, read_timeout, write_timeout;
|
|
|
|
unsigned int port, protocol;
|
|
|
|
unsigned long client_flag;
|
|
|
|
char *host,*user,*password,*unix_socket,*db;
|
|
|
|
struct st_dynamic_array *init_commands;
|
|
|
|
char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name;
|
|
|
|
char *ssl_key;
|
|
|
|
char *ssl_cert;
|
|
|
|
char *ssl_ca;
|
|
|
|
char *ssl_capath;
|
|
|
|
char *ssl_cipher;
|
|
|
|
char *shared_memory_base_name;
|
|
|
|
unsigned long max_allowed_packet;
|
|
|
|
my_bool use_ssl;
|
|
|
|
my_bool compress,named_pipe;
|
2013-04-17 22:37:06 +02:00
|
|
|
my_bool use_thread_specific_memory;
|
2009-10-15 22:56:17 +02:00
|
|
|
my_bool unused2;
|
|
|
|
my_bool unused3;
|
|
|
|
my_bool unused4;
|
2008-06-17 14:27:04 +02:00
|
|
|
enum mysql_option methods_to_use;
|
|
|
|
char *client_ip;
|
|
|
|
my_bool secure_auth;
|
|
|
|
my_bool report_data_truncation;
|
|
|
|
int (*local_infile_init)(void **, const char *, void *);
|
|
|
|
int (*local_infile_read)(void *, char *, unsigned int);
|
|
|
|
void (*local_infile_end)(void *);
|
|
|
|
int (*local_infile_error)(void *, char *, unsigned int);
|
|
|
|
void *local_infile_userdata;
|
2010-03-29 17:13:53 +02:00
|
|
|
struct st_mysql_options_extention *extension;
|
2008-06-17 14:27:04 +02:00
|
|
|
};
|
|
|
|
enum mysql_status
|
|
|
|
{
|
2010-09-07 09:18:01 +02:00
|
|
|
MYSQL_STATUS_READY, MYSQL_STATUS_GET_RESULT, MYSQL_STATUS_USE_RESULT,
|
|
|
|
MYSQL_STATUS_STATEMENT_GET_RESULT
|
2008-06-17 14:27:04 +02:00
|
|
|
};
|
|
|
|
enum mysql_protocol_type
|
|
|
|
{
|
|
|
|
MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
|
|
|
|
MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
|
|
|
|
};
|
|
|
|
typedef struct character_set
|
|
|
|
{
|
|
|
|
unsigned int number;
|
|
|
|
unsigned int state;
|
|
|
|
const char *csname;
|
|
|
|
const char *name;
|
|
|
|
const char *comment;
|
|
|
|
const char *dir;
|
|
|
|
unsigned int mbminlen;
|
|
|
|
unsigned int mbmaxlen;
|
|
|
|
} MY_CHARSET_INFO;
|
|
|
|
struct st_mysql_methods;
|
|
|
|
struct st_mysql_stmt;
|
|
|
|
typedef struct st_mysql
|
|
|
|
{
|
|
|
|
NET net;
|
|
|
|
unsigned char *connector_fd;
|
|
|
|
char *host,*user,*passwd,*unix_socket,*server_version,*host_info;
|
|
|
|
char *info, *db;
|
2010-01-06 20:20:16 +01:00
|
|
|
const struct charset_info_st *charset;
|
2008-06-17 14:27:04 +02:00
|
|
|
MYSQL_FIELD *fields;
|
|
|
|
MEM_ROOT field_alloc;
|
|
|
|
my_ulonglong affected_rows;
|
|
|
|
my_ulonglong insert_id;
|
|
|
|
my_ulonglong extra_info;
|
|
|
|
unsigned long thread_id;
|
|
|
|
unsigned long packet_length;
|
|
|
|
unsigned int port;
|
|
|
|
unsigned long client_flag,server_capabilities;
|
|
|
|
unsigned int protocol_version;
|
|
|
|
unsigned int field_count;
|
|
|
|
unsigned int server_status;
|
|
|
|
unsigned int server_language;
|
|
|
|
unsigned int warning_count;
|
|
|
|
struct st_mysql_options options;
|
|
|
|
enum mysql_status status;
|
|
|
|
my_bool free_me;
|
|
|
|
my_bool reconnect;
|
|
|
|
char scramble[20 +1];
|
2009-10-15 22:56:17 +02:00
|
|
|
my_bool unused1;
|
|
|
|
void *unused2, *unused3, *unused4, *unused5;
|
2008-06-17 14:27:04 +02:00
|
|
|
LIST *stmts;
|
|
|
|
const struct st_mysql_methods *methods;
|
|
|
|
void *thd;
|
|
|
|
my_bool *unbuffered_fetch_owner;
|
|
|
|
char *info_buffer;
|
|
|
|
void *extension;
|
|
|
|
} MYSQL;
|
|
|
|
typedef struct st_mysql_res {
|
|
|
|
my_ulonglong row_count;
|
|
|
|
MYSQL_FIELD *fields;
|
|
|
|
MYSQL_DATA *data;
|
|
|
|
MYSQL_ROWS *data_cursor;
|
|
|
|
unsigned long *lengths;
|
|
|
|
MYSQL *handle;
|
|
|
|
const struct st_mysql_methods *methods;
|
|
|
|
MYSQL_ROW row;
|
|
|
|
MYSQL_ROW current_row;
|
|
|
|
MEM_ROOT field_alloc;
|
|
|
|
unsigned int field_count, current_field;
|
|
|
|
my_bool eof;
|
|
|
|
my_bool unbuffered_fetch_cancelled;
|
|
|
|
void *extension;
|
|
|
|
} MYSQL_RES;
|
|
|
|
typedef struct st_mysql_parameters
|
|
|
|
{
|
|
|
|
unsigned long *p_max_allowed_packet;
|
|
|
|
unsigned long *p_net_buffer_length;
|
|
|
|
void *extension;
|
|
|
|
} MYSQL_PARAMETERS;
|
|
|
|
int mysql_server_init(int argc, char **argv, char **groups);
|
|
|
|
void mysql_server_end(void);
|
|
|
|
MYSQL_PARAMETERS * mysql_get_parameters(void);
|
|
|
|
my_bool mysql_thread_init(void);
|
|
|
|
void mysql_thread_end(void);
|
|
|
|
my_ulonglong mysql_num_rows(MYSQL_RES *res);
|
|
|
|
unsigned int mysql_num_fields(MYSQL_RES *res);
|
|
|
|
my_bool mysql_eof(MYSQL_RES *res);
|
|
|
|
MYSQL_FIELD * mysql_fetch_field_direct(MYSQL_RES *res,
|
|
|
|
unsigned int fieldnr);
|
|
|
|
MYSQL_FIELD * mysql_fetch_fields(MYSQL_RES *res);
|
|
|
|
MYSQL_ROW_OFFSET mysql_row_tell(MYSQL_RES *res);
|
|
|
|
MYSQL_FIELD_OFFSET mysql_field_tell(MYSQL_RES *res);
|
|
|
|
unsigned int mysql_field_count(MYSQL *mysql);
|
|
|
|
my_ulonglong mysql_affected_rows(MYSQL *mysql);
|
|
|
|
my_ulonglong mysql_insert_id(MYSQL *mysql);
|
|
|
|
unsigned int mysql_errno(MYSQL *mysql);
|
|
|
|
const char * mysql_error(MYSQL *mysql);
|
|
|
|
const char * mysql_sqlstate(MYSQL *mysql);
|
|
|
|
unsigned int mysql_warning_count(MYSQL *mysql);
|
|
|
|
const char * mysql_info(MYSQL *mysql);
|
|
|
|
unsigned long mysql_thread_id(MYSQL *mysql);
|
|
|
|
const char * mysql_character_set_name(MYSQL *mysql);
|
|
|
|
int mysql_set_character_set(MYSQL *mysql, const char *csname);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_set_character_set_start(int *ret, MYSQL *mysql,
|
|
|
|
const char *csname);
|
|
|
|
int mysql_set_character_set_cont(int *ret, MYSQL *mysql,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
MYSQL * mysql_init(MYSQL *mysql);
|
|
|
|
my_bool mysql_ssl_set(MYSQL *mysql, const char *key,
|
|
|
|
const char *cert, const char *ca,
|
|
|
|
const char *capath, const char *cipher);
|
|
|
|
const char * mysql_get_ssl_cipher(MYSQL *mysql);
|
|
|
|
my_bool mysql_change_user(MYSQL *mysql, const char *user,
|
|
|
|
const char *passwd, const char *db);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_change_user_start(my_bool *ret, MYSQL *mysql,
|
|
|
|
const char *user,
|
|
|
|
const char *passwd,
|
|
|
|
const char *db);
|
|
|
|
int mysql_change_user_cont(my_bool *ret, MYSQL *mysql,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
MYSQL * mysql_real_connect(MYSQL *mysql, const char *host,
|
|
|
|
const char *user,
|
|
|
|
const char *passwd,
|
|
|
|
const char *db,
|
|
|
|
unsigned int port,
|
|
|
|
const char *unix_socket,
|
|
|
|
unsigned long clientflag);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_real_connect_start(MYSQL **ret, MYSQL *mysql,
|
|
|
|
const char *host,
|
|
|
|
const char *user,
|
|
|
|
const char *passwd,
|
|
|
|
const char *db,
|
|
|
|
unsigned int port,
|
|
|
|
const char *unix_socket,
|
|
|
|
unsigned long clientflag);
|
|
|
|
int mysql_real_connect_cont(MYSQL **ret, MYSQL *mysql,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
int mysql_select_db(MYSQL *mysql, const char *db);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_select_db_start(int *ret, MYSQL *mysql,
|
|
|
|
const char *db);
|
|
|
|
int mysql_select_db_cont(int *ret, MYSQL *mysql,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
int mysql_query(MYSQL *mysql, const char *q);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_query_start(int *ret, MYSQL *mysql,
|
|
|
|
const char *q);
|
|
|
|
int mysql_query_cont(int *ret, MYSQL *mysql,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
int mysql_send_query(MYSQL *mysql, const char *q,
|
|
|
|
unsigned long length);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_send_query_start(int *ret, MYSQL *mysql,
|
|
|
|
const char *q,
|
|
|
|
unsigned long length);
|
|
|
|
int mysql_send_query_cont(int *ret, MYSQL *mysql,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
int mysql_real_query(MYSQL *mysql, const char *q,
|
|
|
|
unsigned long length);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_real_query_start(int *ret, MYSQL *mysql,
|
|
|
|
const char *q,
|
|
|
|
unsigned long length);
|
|
|
|
int mysql_real_query_cont(int *ret, MYSQL *mysql,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
MYSQL_RES * mysql_store_result(MYSQL *mysql);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_store_result_start(MYSQL_RES **ret, MYSQL *mysql);
|
|
|
|
int mysql_store_result_cont(MYSQL_RES **ret, MYSQL *mysql,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
MYSQL_RES * mysql_use_result(MYSQL *mysql);
|
|
|
|
void mysql_get_character_set_info(MYSQL *mysql,
|
|
|
|
MY_CHARSET_INFO *charset);
|
|
|
|
void
|
|
|
|
mysql_set_local_infile_handler(MYSQL *mysql,
|
|
|
|
int (*local_infile_init)(void **, const char *,
|
|
|
|
void *),
|
|
|
|
int (*local_infile_read)(void *, char *,
|
|
|
|
unsigned int),
|
|
|
|
void (*local_infile_end)(void *),
|
|
|
|
int (*local_infile_error)(void *, char*,
|
|
|
|
unsigned int),
|
|
|
|
void *);
|
|
|
|
void
|
|
|
|
mysql_set_local_infile_default(MYSQL *mysql);
|
|
|
|
int mysql_shutdown(MYSQL *mysql,
|
|
|
|
enum mysql_enum_shutdown_level
|
|
|
|
shutdown_level);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_shutdown_start(int *ret, MYSQL *mysql,
|
|
|
|
enum mysql_enum_shutdown_level
|
|
|
|
shutdown_level);
|
|
|
|
int mysql_shutdown_cont(int *ret, MYSQL *mysql,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
int mysql_dump_debug_info(MYSQL *mysql);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_dump_debug_info_start(int *ret, MYSQL *mysql);
|
|
|
|
int mysql_dump_debug_info_cont(int *ret, MYSQL *mysql,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
int mysql_refresh(MYSQL *mysql,
|
|
|
|
unsigned int refresh_options);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_refresh_start(int *ret, MYSQL *mysql,
|
|
|
|
unsigned int refresh_options);
|
|
|
|
int mysql_refresh_cont(int *ret, MYSQL *mysql, int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
int mysql_kill(MYSQL *mysql,unsigned long pid);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_kill_start(int *ret, MYSQL *mysql,
|
|
|
|
unsigned long pid);
|
|
|
|
int mysql_kill_cont(int *ret, MYSQL *mysql, int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
int mysql_set_server_option(MYSQL *mysql,
|
|
|
|
enum enum_mysql_set_option
|
|
|
|
option);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_set_server_option_start(int *ret, MYSQL *mysql,
|
|
|
|
enum enum_mysql_set_option
|
|
|
|
option);
|
|
|
|
int mysql_set_server_option_cont(int *ret, MYSQL *mysql,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
int mysql_ping(MYSQL *mysql);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_ping_start(int *ret, MYSQL *mysql);
|
|
|
|
int mysql_ping_cont(int *ret, MYSQL *mysql, int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
const char * mysql_stat(MYSQL *mysql);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_stat_start(const char **ret, MYSQL *mysql);
|
|
|
|
int mysql_stat_cont(const char **ret, MYSQL *mysql,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
const char * mysql_get_server_info(MYSQL *mysql);
|
2009-10-02 12:36:28 +02:00
|
|
|
const char * mysql_get_server_name(MYSQL *mysql);
|
2008-06-17 14:27:04 +02:00
|
|
|
const char * mysql_get_client_info(void);
|
|
|
|
unsigned long mysql_get_client_version(void);
|
|
|
|
const char * mysql_get_host_info(MYSQL *mysql);
|
|
|
|
unsigned long mysql_get_server_version(MYSQL *mysql);
|
|
|
|
unsigned int mysql_get_proto_info(MYSQL *mysql);
|
|
|
|
MYSQL_RES * mysql_list_dbs(MYSQL *mysql,const char *wild);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_list_dbs_start(MYSQL_RES **ret, MYSQL *mysql,
|
|
|
|
const char *wild);
|
|
|
|
int mysql_list_dbs_cont(MYSQL_RES **ret, MYSQL *mysql,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
MYSQL_RES * mysql_list_tables(MYSQL *mysql,const char *wild);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_list_tables_start(MYSQL_RES **ret, MYSQL *mysql,
|
|
|
|
const char *wild);
|
|
|
|
int mysql_list_tables_cont(MYSQL_RES **ret, MYSQL *mysql,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
MYSQL_RES * mysql_list_processes(MYSQL *mysql);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_list_processes_start(MYSQL_RES **ret,
|
|
|
|
MYSQL *mysql);
|
|
|
|
int mysql_list_processes_cont(MYSQL_RES **ret, MYSQL *mysql,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
int mysql_options(MYSQL *mysql,enum mysql_option option,
|
|
|
|
const void *arg);
|
2013-10-03 17:00:44 +02:00
|
|
|
int mysql_options4(MYSQL *mysql,enum mysql_option option,
|
2014-07-19 12:38:40 +02:00
|
|
|
const void *arg1, const void *arg2);
|
2008-06-17 14:27:04 +02:00
|
|
|
void mysql_free_result(MYSQL_RES *result);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_free_result_start(MYSQL_RES *result);
|
|
|
|
int mysql_free_result_cont(MYSQL_RES *result, int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
void mysql_data_seek(MYSQL_RES *result,
|
|
|
|
my_ulonglong offset);
|
|
|
|
MYSQL_ROW_OFFSET mysql_row_seek(MYSQL_RES *result,
|
|
|
|
MYSQL_ROW_OFFSET offset);
|
|
|
|
MYSQL_FIELD_OFFSET mysql_field_seek(MYSQL_RES *result,
|
|
|
|
MYSQL_FIELD_OFFSET offset);
|
|
|
|
MYSQL_ROW mysql_fetch_row(MYSQL_RES *result);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_fetch_row_start(MYSQL_ROW *ret,
|
|
|
|
MYSQL_RES *result);
|
|
|
|
int mysql_fetch_row_cont(MYSQL_ROW *ret, MYSQL_RES *result,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
unsigned long * mysql_fetch_lengths(MYSQL_RES *result);
|
|
|
|
MYSQL_FIELD * mysql_fetch_field(MYSQL_RES *result);
|
|
|
|
MYSQL_RES * mysql_list_fields(MYSQL *mysql, const char *table,
|
|
|
|
const char *wild);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_list_fields_start(MYSQL_RES **ret, MYSQL *mysql,
|
|
|
|
const char *table,
|
|
|
|
const char *wild);
|
|
|
|
int mysql_list_fields_cont(MYSQL_RES **ret, MYSQL *mysql,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
unsigned long mysql_escape_string(char *to,const char *from,
|
|
|
|
unsigned long from_length);
|
|
|
|
unsigned long mysql_hex_string(char *to,const char *from,
|
|
|
|
unsigned long from_length);
|
|
|
|
unsigned long mysql_real_escape_string(MYSQL *mysql,
|
|
|
|
char *to,const char *from,
|
|
|
|
unsigned long length);
|
|
|
|
void mysql_debug(const char *debug);
|
|
|
|
void myodbc_remove_escape(MYSQL *mysql,char *name);
|
|
|
|
unsigned int mysql_thread_safe(void);
|
|
|
|
my_bool mysql_embedded(void);
|
2009-10-02 12:36:28 +02:00
|
|
|
my_bool mariadb_connection(MYSQL *mysql);
|
2008-06-17 14:27:04 +02:00
|
|
|
my_bool mysql_read_query_result(MYSQL *mysql);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_read_query_result_start(my_bool *ret,
|
|
|
|
MYSQL *mysql);
|
|
|
|
int mysql_read_query_result_cont(my_bool *ret,
|
|
|
|
MYSQL *mysql, int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
enum enum_mysql_stmt_state
|
|
|
|
{
|
|
|
|
MYSQL_STMT_INIT_DONE= 1, MYSQL_STMT_PREPARE_DONE, MYSQL_STMT_EXECUTE_DONE,
|
|
|
|
MYSQL_STMT_FETCH_DONE
|
|
|
|
};
|
|
|
|
typedef struct st_mysql_bind
|
|
|
|
{
|
|
|
|
unsigned long *length;
|
|
|
|
my_bool *is_null;
|
|
|
|
void *buffer;
|
|
|
|
my_bool *error;
|
|
|
|
unsigned char *row_ptr;
|
|
|
|
void (*store_param_func)(NET *net, struct st_mysql_bind *param);
|
|
|
|
void (*fetch_result)(struct st_mysql_bind *, MYSQL_FIELD *,
|
|
|
|
unsigned char **row);
|
|
|
|
void (*skip_result)(struct st_mysql_bind *, MYSQL_FIELD *,
|
|
|
|
unsigned char **row);
|
|
|
|
unsigned long buffer_length;
|
|
|
|
unsigned long offset;
|
|
|
|
unsigned long length_value;
|
|
|
|
unsigned int param_number;
|
|
|
|
unsigned int pack_length;
|
|
|
|
enum enum_field_types buffer_type;
|
|
|
|
my_bool error_value;
|
|
|
|
my_bool is_unsigned;
|
|
|
|
my_bool long_data_used;
|
|
|
|
my_bool is_null_value;
|
|
|
|
void *extension;
|
|
|
|
} MYSQL_BIND;
|
2011-05-06 15:39:20 +02:00
|
|
|
struct st_mysql_stmt_extension;
|
2008-06-17 14:27:04 +02:00
|
|
|
typedef struct st_mysql_stmt
|
|
|
|
{
|
|
|
|
MEM_ROOT mem_root;
|
|
|
|
LIST list;
|
|
|
|
MYSQL *mysql;
|
|
|
|
MYSQL_BIND *params;
|
|
|
|
MYSQL_BIND *bind;
|
|
|
|
MYSQL_FIELD *fields;
|
|
|
|
MYSQL_DATA result;
|
|
|
|
MYSQL_ROWS *data_cursor;
|
|
|
|
int (*read_row_func)(struct st_mysql_stmt *stmt,
|
|
|
|
unsigned char **row);
|
|
|
|
my_ulonglong affected_rows;
|
|
|
|
my_ulonglong insert_id;
|
|
|
|
unsigned long stmt_id;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned long prefetch_rows;
|
|
|
|
unsigned int server_status;
|
|
|
|
unsigned int last_errno;
|
|
|
|
unsigned int param_count;
|
|
|
|
unsigned int field_count;
|
|
|
|
enum enum_mysql_stmt_state state;
|
|
|
|
char last_error[512];
|
|
|
|
char sqlstate[5 +1];
|
|
|
|
my_bool send_types_to_server;
|
|
|
|
my_bool bind_param_done;
|
|
|
|
unsigned char bind_result_done;
|
|
|
|
my_bool unbuffered_fetch_cancelled;
|
|
|
|
my_bool update_max_length;
|
2011-05-06 15:39:20 +02:00
|
|
|
struct st_mysql_stmt_extension *extension;
|
2008-06-17 14:27:04 +02:00
|
|
|
} MYSQL_STMT;
|
|
|
|
enum enum_stmt_attr_type
|
|
|
|
{
|
|
|
|
STMT_ATTR_UPDATE_MAX_LENGTH,
|
|
|
|
STMT_ATTR_CURSOR_TYPE,
|
|
|
|
STMT_ATTR_PREFETCH_ROWS
|
|
|
|
};
|
|
|
|
MYSQL_STMT * mysql_stmt_init(MYSQL *mysql);
|
|
|
|
int mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query,
|
|
|
|
unsigned long length);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_stmt_prepare_start(int *ret, MYSQL_STMT *stmt,
|
|
|
|
const char *query, unsigned long length);
|
|
|
|
int mysql_stmt_prepare_cont(int *ret, MYSQL_STMT *stmt, int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
int mysql_stmt_execute(MYSQL_STMT *stmt);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_stmt_execute_start(int *ret, MYSQL_STMT *stmt);
|
|
|
|
int mysql_stmt_execute_cont(int *ret, MYSQL_STMT *stmt, int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
int mysql_stmt_fetch(MYSQL_STMT *stmt);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_stmt_fetch_start(int *ret, MYSQL_STMT *stmt);
|
|
|
|
int mysql_stmt_fetch_cont(int *ret, MYSQL_STMT *stmt, int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
int mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind_arg,
|
|
|
|
unsigned int column,
|
|
|
|
unsigned long offset);
|
|
|
|
int mysql_stmt_store_result(MYSQL_STMT *stmt);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_stmt_store_result_start(int *ret, MYSQL_STMT *stmt);
|
|
|
|
int mysql_stmt_store_result_cont(int *ret, MYSQL_STMT *stmt,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
unsigned long mysql_stmt_param_count(MYSQL_STMT * stmt);
|
|
|
|
my_bool mysql_stmt_attr_set(MYSQL_STMT *stmt,
|
|
|
|
enum enum_stmt_attr_type attr_type,
|
|
|
|
const void *attr);
|
|
|
|
my_bool mysql_stmt_attr_get(MYSQL_STMT *stmt,
|
|
|
|
enum enum_stmt_attr_type attr_type,
|
|
|
|
void *attr);
|
|
|
|
my_bool mysql_stmt_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
|
|
|
|
my_bool mysql_stmt_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
|
|
|
|
my_bool mysql_stmt_close(MYSQL_STMT * stmt);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_stmt_close_start(my_bool *ret, MYSQL_STMT *stmt);
|
|
|
|
int mysql_stmt_close_cont(my_bool *ret, MYSQL_STMT * stmt, int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
my_bool mysql_stmt_reset(MYSQL_STMT * stmt);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_stmt_reset_start(my_bool *ret, MYSQL_STMT * stmt);
|
|
|
|
int mysql_stmt_reset_cont(my_bool *ret, MYSQL_STMT *stmt, int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
my_bool mysql_stmt_free_result(MYSQL_STMT *stmt);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_stmt_free_result_start(my_bool *ret, MYSQL_STMT *stmt);
|
|
|
|
int mysql_stmt_free_result_cont(my_bool *ret, MYSQL_STMT *stmt,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
my_bool mysql_stmt_send_long_data(MYSQL_STMT *stmt,
|
|
|
|
unsigned int param_number,
|
|
|
|
const char *data,
|
|
|
|
unsigned long length);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_stmt_send_long_data_start(my_bool *ret, MYSQL_STMT *stmt,
|
|
|
|
unsigned int param_number,
|
|
|
|
const char *data,
|
|
|
|
unsigned long len);
|
|
|
|
int mysql_stmt_send_long_data_cont(my_bool *ret, MYSQL_STMT *stmt,
|
|
|
|
int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
MYSQL_RES * mysql_stmt_result_metadata(MYSQL_STMT *stmt);
|
|
|
|
MYSQL_RES * mysql_stmt_param_metadata(MYSQL_STMT *stmt);
|
|
|
|
unsigned int mysql_stmt_errno(MYSQL_STMT * stmt);
|
|
|
|
const char * mysql_stmt_error(MYSQL_STMT * stmt);
|
|
|
|
const char * mysql_stmt_sqlstate(MYSQL_STMT * stmt);
|
|
|
|
MYSQL_ROW_OFFSET mysql_stmt_row_seek(MYSQL_STMT *stmt,
|
|
|
|
MYSQL_ROW_OFFSET offset);
|
|
|
|
MYSQL_ROW_OFFSET mysql_stmt_row_tell(MYSQL_STMT *stmt);
|
|
|
|
void mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong offset);
|
|
|
|
my_ulonglong mysql_stmt_num_rows(MYSQL_STMT *stmt);
|
|
|
|
my_ulonglong mysql_stmt_affected_rows(MYSQL_STMT *stmt);
|
|
|
|
my_ulonglong mysql_stmt_insert_id(MYSQL_STMT *stmt);
|
|
|
|
unsigned int mysql_stmt_field_count(MYSQL_STMT *stmt);
|
|
|
|
my_bool mysql_commit(MYSQL * mysql);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_commit_start(my_bool *ret, MYSQL * mysql);
|
|
|
|
int mysql_commit_cont(my_bool *ret, MYSQL * mysql, int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
my_bool mysql_rollback(MYSQL * mysql);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_rollback_start(my_bool *ret, MYSQL * mysql);
|
|
|
|
int mysql_rollback_cont(my_bool *ret, MYSQL * mysql, int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
my_bool mysql_autocommit(MYSQL * mysql, my_bool auto_mode);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_autocommit_start(my_bool *ret, MYSQL * mysql,
|
|
|
|
my_bool auto_mode);
|
|
|
|
int mysql_autocommit_cont(my_bool *ret, MYSQL * mysql, int status);
|
2008-06-17 14:27:04 +02:00
|
|
|
my_bool mysql_more_results(MYSQL *mysql);
|
|
|
|
int mysql_next_result(MYSQL *mysql);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_next_result_start(int *ret, MYSQL *mysql);
|
|
|
|
int mysql_next_result_cont(int *ret, MYSQL *mysql, int status);
|
Backport of revno 2630.28.10, 2630.28.31, 2630.28.26, 2630.33.1,
2630.39.1, 2630.28.29, 2630.34.3, 2630.34.2, 2630.34.1, 2630.29.29,
2630.29.28, 2630.31.1, 2630.28.13, 2630.28.10, 2617.23.14 and
some other minor revisions.
This patch implements:
WL#4264 "Backup: Stabilize Service Interface" -- all the
server prerequisites except si_objects.{h,cc} themselves (they can
be just copied over, when needed).
WL#4435: Support OUT-parameters in prepared statements.
(and all issues in the initial patches for these two
tasks, that were discovered in pushbuild and during testing).
Bug#39519: mysql_stmt_close() should flush all data
associated with the statement.
After execution of a prepared statement, send OUT parameters of the invoked
stored procedure, if any, to the client.
When using the binary protocol, send the parameters in an additional result
set over the wire. When using the text protocol, assign out parameters to
the user variables from the CALL(@var1, @var2, ...) specification.
The following refactoring has been made:
- Protocol::send_fields() was renamed to Protocol::send_result_set_metadata();
- A new Protocol::send_result_set_row() was introduced to incapsulate
common functionality for sending row data.
- Signature of Protocol::prepare_for_send() was changed: this operation
does not need a list of items, the number of items is fully sufficient.
The following backward incompatible changes have been made:
- CLIENT_MULTI_RESULTS is now enabled by default in the client;
- CLIENT_PS_MULTI_RESUTLS is now enabled by default in the client.
include/mysql.h:
Add a new flag to MYSQL_METHODS::flush_use_result
function pointer. This flag determines if all results
should be flushed or only the first one:
- if flush_all_results is TRUE, then cli_flush_use_result()
will read/flush all pending results. I.e. it will read
all packets while server status attribute indicates that
there are more results. This is a new semantic, required
to fix the bug.
- if flush_all_results is FALSE, the old sematic
is preserved -- i.e. cli_flush_use_result() reads data
until first EOF-packet.
include/mysql.h.pp:
Update the ABI with new calls (compatible changes).
include/mysql_com.h:
Add CLIENT_PS_OUT_PARAMS -- a client capability indicating that the client supportsю
libmysql/libmysql.c:
Add mysql_stmt_next_result() -- analogue of mysql_next_result() for binary protocol.
Fix a minor bug in alloc_fields() -- not all members were copied over,
and some only shallow-copied (catalog).
Flush all results in mysql_stmt_close() (Bug#39519).
libmysqld/lib_sql.cc:
Rename send_fields() -> send_result_set_metadata().
Refactoring: change prepare_for_send() so that it accepts only
what it really needs -- a number of elements in the list.
mysql-test/r/ps.result:
Update results: WL#4435.
mysql-test/t/ps.test:
WL#4435: A test case for an SQL-part of the problem.
sql-common/client.c:
Bug#39519.
Implement new functionality in cli_flush_use_result():
if flush_all_delete is TRUE, then it should read/flush
all pending results.
sql/Makefile.am:
Add a new header sql_prepare.h to the list
of build headers.
sql/events.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/mysql_priv.h:
Move sql_prepare.cc-specific declarations to a new
header - sql_prepare.h.
sql/procedure.h:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/protocol.cc:
Move the logic responsible for sending of one result
set row to the Protocol class. Define a template
for end-of-statement action.
Refactoring: change prepare_for_send() so that it accepts
only what it really needs -- a number of elements in the list.
Rename send_fields() to send_result_set_metadata().
sql/protocol.h:
Update with new declarations (WL#4435).
Rename send_fields() -> send_result_set_metadata().
prepare_for_send() only needs the number of columns to send,
and doesn't use the item list - update signature to require
only what's needed.
Add a new protocol type -- Protocol_local.
sql/repl_failsafe.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/slave.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_acl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_base.cc:
Include sql_prepare.h (for Reprepare_observer).
sql/sql_cache.cc:
Extend the query cache flags block to be able
to store a numeric id for the result format,
not just a flag binary/non-binary.
sql/sql_class.cc:
Update to use the rename of Protocol::send_fields()
to Protocol::send_result_set_metadata().
Use Protocol::send_one_result_set_row().
sql/sql_class.h:
Move the declaration of Reprepare_observer to the
new header - sql_prepare.h.
Update to the new signature of class Protocol::send_fields().
sql/sql_connect.cc:
Use a protocol template method instead of
raw NET layer API at the end of a statement.
sql/sql_cursor.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_error.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
Use new method Protocol::send_one_result_set_row().
sql/sql_help.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_lex.cc:
Initialize multi_statements variable.
Add a handy constant for empty lex
string.
sql/sql_lex.h:
Add a separate member for a standalone
parsing option - multi-statements support.
sql/sql_list.cc:
sql_list.h is a standalone header now,
no need to include mysql_priv.h.
sql/sql_list.h:
Make sql_list.h a stand-alone header.
sql/sql_parse.cc:
Include sql_prepare.h for prepared
statements- related declarations.
Use a new Protocol template method to end
each statement (send OK, EOF or ERROR to
the client).
sql/sql_prepare.cc:
Implement Execute Direct API (WL#4264),
currently unused. It will be used by the service
interface (Backup).
Use a new header - sql_prepare.h.
Add support for OUT parameters in the
binary and text protocol (prepared statements
only).
sql/sql_prepare.h:
Add a new header to contain (for now)
all prepared statement- external
related declarations.
sql/sql_profile.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_repl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_select.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_show.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_string.h:
Add a way to convert a String to LEX_STRING.
sql/sql_table.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_update.cc:
Remove an extraneous my_error(). The error
is already reported in update_non_unique_table_error().
sql/sql_yacc.yy:
Support for multi-statements is an independent
property of parsing, not derived from
the protocol type.
tests/mysql_client_test.c:
Add tests for WL#4435 (binary protocol).
2009-10-21 22:02:06 +02:00
|
|
|
int mysql_stmt_next_result(MYSQL_STMT *stmt);
|
2012-02-21 22:15:44 +01:00
|
|
|
int mysql_stmt_next_result_start(int *ret, MYSQL_STMT *stmt);
|
|
|
|
int mysql_stmt_next_result_cont(int *ret, MYSQL_STMT *stmt, int status);
|
2012-01-06 12:43:18 +01:00
|
|
|
void mysql_close_slow_part(MYSQL *mysql);
|
2008-06-17 14:27:04 +02:00
|
|
|
void mysql_close(MYSQL *sock);
|
2011-09-20 12:49:25 +02:00
|
|
|
int mysql_close_start(MYSQL *sock);
|
|
|
|
int mysql_close_cont(MYSQL *sock, int status);
|
|
|
|
my_socket mysql_get_socket(const MYSQL *mysql);
|
|
|
|
unsigned int mysql_get_timeout_value(const MYSQL *mysql);
|
2012-10-12 11:00:01 +02:00
|
|
|
unsigned int mysql_get_timeout_value_ms(const MYSQL *mysql);
|
2015-02-13 12:57:11 +01:00
|
|
|
unsigned long mysql_net_read_packet(MYSQL *mysql);
|
|
|
|
unsigned long mysql_net_field_length(unsigned char **packet);
|