30 #include <standards.h>
45 #ifndef MY_GLOBAL_INCLUDED
46 #ifndef MYSQL_ABI_CHECK
47 #include <sys/types.h>
53 #if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__)
59 #define STDCALL __stdcall
62 #ifndef my_socket_defined
64 #define my_socket SOCKET
66 typedef int my_socket;
71 #include "mysql_version.h"
72 #include "mysql_com.h"
73 #include "mysql_time.h"
77 extern unsigned int mysql_port;
78 extern char *mysql_unix_port;
80 #define CLIENT_NET_READ_TIMEOUT 365*24*3600
81 #define CLIENT_NET_WRITE_TIMEOUT 365*24*3600
83 #define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG)
84 #define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG)
85 #define IS_BLOB(n) ((n) & BLOB_FLAG)
90 #define IS_NUM(t) (((t) <= MYSQL_TYPE_INT24 && (t) != MYSQL_TYPE_TIMESTAMP) || (t) == MYSQL_TYPE_YEAR || (t) == MYSQL_TYPE_NEWDECIMAL)
91 #define IS_LONGDATA(t) ((t) >= MYSQL_TYPE_TINY_BLOB && (t) <= MYSQL_TYPE_STRING)
102 unsigned long length;
103 unsigned long max_length;
104 unsigned int name_length;
105 unsigned int org_name_length;
106 unsigned int table_length;
107 unsigned int org_table_length;
108 unsigned int db_length;
109 unsigned int catalog_length;
110 unsigned int def_length;
112 unsigned int decimals;
113 unsigned int charsetnr;
114 enum enum_field_types type;
118 typedef char **MYSQL_ROW;
119 typedef unsigned int MYSQL_FIELD_OFFSET;
121 #ifndef MY_GLOBAL_INCLUDED
122 #if defined(NO_CLIENT_LONG_LONG)
123 typedef unsigned long my_ulonglong;
124 #elif defined (__WIN__)
125 typedef unsigned __int64 my_ulonglong;
127 typedef unsigned long long my_ulonglong;
133 #define MYSQL_COUNT_ERROR (~(my_ulonglong) 0)
136 #define ER_WARN_DATA_TRUNCATED WARN_DATA_TRUNCATED
141 unsigned long length;
146 #include "my_alloc.h"
161 MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE,
162 MYSQL_INIT_COMMAND, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP,
163 MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_OPT_LOCAL_INFILE,
164 MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT,
165 MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT,
166 MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION,
167 MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH,
168 MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT,
169 MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH,
171 MYSQL_OPT_SSL_KEY, MYSQL_OPT_SSL_CERT,
172 MYSQL_OPT_SSL_CA, MYSQL_OPT_SSL_CAPATH, MYSQL_OPT_SSL_CIPHER,
173 MYSQL_OPT_SSL_CRL, MYSQL_OPT_SSL_CRLPATH,
174 MYSQL_OPT_CONNECT_ATTR_RESET, MYSQL_OPT_CONNECT_ATTR_ADD,
175 MYSQL_OPT_CONNECT_ATTR_DELETE,
176 MYSQL_SERVER_PUBLIC_KEY,
177 MYSQL_ENABLE_CLEARTEXT_PLUGIN,
178 MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS
188 unsigned int connect_timeout, read_timeout, write_timeout;
189 unsigned int port, protocol;
190 unsigned long client_flag;
191 char *host,*user,*password,*unix_socket,*db;
193 char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name;
199 char *shared_memory_base_name;
200 unsigned long max_allowed_packet;
202 my_bool compress,named_pipe;
207 enum mysql_option methods_to_use;
225 my_bool report_data_truncation;
228 int (*local_infile_init)(
void **,
const char *,
void *);
229 int (*local_infile_read)(
void *,
char *,
unsigned int);
230 void (*local_infile_end)(
void *);
231 int (*local_infile_error)(
void *,
char *,
unsigned int);
232 void *local_infile_userdata;
238 MYSQL_STATUS_READY, MYSQL_STATUS_GET_RESULT, MYSQL_STATUS_USE_RESULT,
239 MYSQL_STATUS_STATEMENT_GET_RESULT
242 enum mysql_protocol_type
244 MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
245 MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
256 unsigned int mbminlen;
257 unsigned int mbmaxlen;
266 unsigned char *connector_fd;
267 char *host,*user,*passwd,*unix_socket,*server_version,*host_info;
272 my_ulonglong affected_rows;
273 my_ulonglong insert_id;
274 my_ulonglong extra_info;
275 unsigned long thread_id;
276 unsigned long packet_length;
278 unsigned long client_flag,server_capabilities;
279 unsigned int protocol_version;
280 unsigned int field_count;
281 unsigned int server_status;
282 unsigned int server_language;
283 unsigned int warning_count;
285 enum mysql_status status;
290 char scramble[SCRAMBLE_LENGTH+1];
292 void *unused2, *unused3, *unused4, *unused5;
301 my_bool *unbuffered_fetch_owner;
309 my_ulonglong row_count;
313 unsigned long *lengths;
317 MYSQL_ROW current_row;
319 unsigned int field_count, current_field;
322 my_bool unbuffered_fetch_cancelled;
327 #if !defined(MYSQL_SERVER) && !defined(MYSQL_CLIENT)
334 unsigned long *p_max_allowed_packet;
335 unsigned long *p_net_buffer_length;
339 #if !defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY)
340 #define max_allowed_packet (*mysql_get_parameters()->p_max_allowed_packet)
341 #define net_buffer_length (*mysql_get_parameters()->p_net_buffer_length)
349 int STDCALL mysql_server_init(
int argc,
char **argv,
char **groups);
350 void STDCALL mysql_server_end(
void);
361 #define mysql_library_init mysql_server_init
362 #define mysql_library_end mysql_server_end
372 my_bool STDCALL mysql_thread_init(
void);
373 void STDCALL mysql_thread_end(
void);
380 my_ulonglong STDCALL mysql_num_rows(
MYSQL_RES *res);
381 unsigned int STDCALL mysql_num_fields(
MYSQL_RES *res);
382 my_bool STDCALL mysql_eof(
MYSQL_RES *res);
384 unsigned int fieldnr);
386 MYSQL_ROW_OFFSET STDCALL mysql_row_tell(
MYSQL_RES *res);
387 MYSQL_FIELD_OFFSET STDCALL mysql_field_tell(
MYSQL_RES *res);
389 unsigned int STDCALL mysql_field_count(
MYSQL *mysql);
390 my_ulonglong STDCALL mysql_affected_rows(
MYSQL *mysql);
391 my_ulonglong STDCALL mysql_insert_id(
MYSQL *mysql);
392 unsigned int STDCALL mysql_errno(
MYSQL *mysql);
393 const char * STDCALL mysql_error(
MYSQL *mysql);
394 const char *STDCALL mysql_sqlstate(
MYSQL *mysql);
395 unsigned int STDCALL mysql_warning_count(
MYSQL *mysql);
396 const char * STDCALL mysql_info(
MYSQL *mysql);
397 unsigned long STDCALL mysql_thread_id(
MYSQL *mysql);
398 const char * STDCALL mysql_character_set_name(
MYSQL *mysql);
399 int STDCALL mysql_set_character_set(
MYSQL *mysql,
const char *csname);
402 my_bool STDCALL mysql_ssl_set(
MYSQL *mysql,
const char *key,
403 const char *cert,
const char *ca,
404 const char *capath,
const char *cipher);
405 const char * STDCALL mysql_get_ssl_cipher(
MYSQL *mysql);
406 my_bool STDCALL mysql_change_user(
MYSQL *mysql,
const char *user,
407 const char *passwd,
const char *db);
408 MYSQL * STDCALL mysql_real_connect(
MYSQL *mysql,
const char *host,
413 const char *unix_socket,
414 unsigned long clientflag);
415 int STDCALL mysql_select_db(
MYSQL *mysql,
const char *db);
416 int STDCALL mysql_query(
MYSQL *mysql,
const char *q);
417 int STDCALL mysql_send_query(
MYSQL *mysql,
const char *q,
418 unsigned long length);
419 int STDCALL mysql_real_query(
MYSQL *mysql,
const char *q,
420 unsigned long length);
424 void STDCALL mysql_get_character_set_info(
MYSQL *mysql,
429 #define LOCAL_INFILE_ERROR_LEN 512
432 mysql_set_local_infile_handler(
MYSQL *mysql,
433 int (*local_infile_init)(
void **,
const char *,
435 int (*local_infile_read)(
void *,
char *,
437 void (*local_infile_end)(
void *),
438 int (*local_infile_error)(
void *,
char*,
443 mysql_set_local_infile_default(
MYSQL *mysql);
445 int STDCALL mysql_shutdown(
MYSQL *mysql,
446 enum mysql_enum_shutdown_level
448 int STDCALL mysql_dump_debug_info(
MYSQL *mysql);
449 int STDCALL mysql_refresh(
MYSQL *mysql,
450 unsigned int refresh_options);
451 int STDCALL mysql_kill(
MYSQL *mysql,
unsigned long pid);
452 int STDCALL mysql_set_server_option(
MYSQL *mysql,
453 enum enum_mysql_set_option
455 int STDCALL mysql_ping(
MYSQL *mysql);
456 const char * STDCALL mysql_stat(
MYSQL *mysql);
457 const char * STDCALL mysql_get_server_info(
MYSQL *mysql);
458 const char * STDCALL mysql_get_client_info(
void);
459 unsigned long STDCALL mysql_get_client_version(
void);
460 const char * STDCALL mysql_get_host_info(
MYSQL *mysql);
461 unsigned long STDCALL mysql_get_server_version(
MYSQL *mysql);
462 unsigned int STDCALL mysql_get_proto_info(
MYSQL *mysql);
463 MYSQL_RES * STDCALL mysql_list_dbs(
MYSQL *mysql,
const char *wild);
464 MYSQL_RES * STDCALL mysql_list_tables(
MYSQL *mysql,
const char *wild);
466 int STDCALL mysql_options(
MYSQL *mysql,
enum mysql_option
option,
468 int STDCALL mysql_options4(
MYSQL *mysql,
enum mysql_option
option,
469 const void *arg1,
const void *arg2);
470 void STDCALL mysql_free_result(
MYSQL_RES *result);
471 void STDCALL mysql_data_seek(
MYSQL_RES *result,
473 MYSQL_ROW_OFFSET STDCALL mysql_row_seek(
MYSQL_RES *result,
475 MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(
MYSQL_RES *result,
476 MYSQL_FIELD_OFFSET
offset);
477 MYSQL_ROW STDCALL mysql_fetch_row(
MYSQL_RES *result);
478 unsigned long * STDCALL mysql_fetch_lengths(
MYSQL_RES *result);
482 unsigned long STDCALL mysql_escape_string(
char *
to,
const char *from,
483 unsigned long from_length);
484 unsigned long STDCALL mysql_hex_string(
char *
to,
const char *from,
485 unsigned long from_length);
486 unsigned long STDCALL mysql_real_escape_string(
MYSQL *mysql,
487 char *
to,
const char *from,
488 unsigned long length);
489 void STDCALL mysql_debug(
const char *debug);
490 void STDCALL myodbc_remove_escape(
MYSQL *mysql,
char *
name);
491 unsigned int STDCALL mysql_thread_safe(
void);
492 my_bool STDCALL mysql_embedded(
void);
493 my_bool STDCALL mysql_read_query_result(
MYSQL *mysql);
502 enum enum_mysql_stmt_state
504 MYSQL_STMT_INIT_DONE= 1, MYSQL_STMT_PREPARE_DONE, MYSQL_STMT_EXECUTE_DONE,
505 MYSQL_STMT_FETCH_DONE
574 unsigned long *length;
579 unsigned char *row_ptr;
582 unsigned char **row);
584 unsigned char **row);
586 unsigned long buffer_length;
587 unsigned long offset;
588 unsigned long length_value;
589 unsigned int param_number;
590 unsigned int pack_length;
591 enum enum_field_types buffer_type;
594 my_bool long_data_used;
595 my_bool is_null_value;
618 unsigned char **row);
620 my_ulonglong affected_rows;
621 my_ulonglong insert_id;
622 unsigned long stmt_id;
624 unsigned long prefetch_rows;
629 unsigned int server_status;
630 unsigned int last_errno;
631 unsigned int param_count;
632 unsigned int field_count;
633 enum enum_mysql_stmt_state state;
634 char last_error[MYSQL_ERRMSG_SIZE];
635 char sqlstate[SQLSTATE_LENGTH+1];
637 my_bool send_types_to_server;
638 my_bool bind_param_done;
639 unsigned char bind_result_done;
641 my_bool unbuffered_fetch_cancelled;
646 my_bool update_max_length;
650 enum enum_stmt_attr_type
659 STMT_ATTR_UPDATE_MAX_LENGTH,
664 STMT_ATTR_CURSOR_TYPE,
669 STMT_ATTR_PREFETCH_ROWS
675 unsigned long length);
676 int STDCALL mysql_stmt_execute(
MYSQL_STMT *stmt);
677 int STDCALL mysql_stmt_fetch(
MYSQL_STMT *stmt);
681 int STDCALL mysql_stmt_store_result(
MYSQL_STMT *stmt);
682 unsigned long STDCALL mysql_stmt_param_count(
MYSQL_STMT * stmt);
683 my_bool STDCALL mysql_stmt_attr_set(
MYSQL_STMT *stmt,
684 enum enum_stmt_attr_type attr_type,
686 my_bool STDCALL mysql_stmt_attr_get(
MYSQL_STMT *stmt,
687 enum enum_stmt_attr_type attr_type,
691 my_bool STDCALL mysql_stmt_close(
MYSQL_STMT * stmt);
692 my_bool STDCALL mysql_stmt_reset(
MYSQL_STMT * stmt);
693 my_bool STDCALL mysql_stmt_free_result(
MYSQL_STMT *stmt);
694 my_bool STDCALL mysql_stmt_send_long_data(
MYSQL_STMT *stmt,
695 unsigned int param_number,
697 unsigned long length);
700 unsigned int STDCALL mysql_stmt_errno(
MYSQL_STMT * stmt);
701 const char *STDCALL mysql_stmt_error(
MYSQL_STMT * stmt);
702 const char *STDCALL mysql_stmt_sqlstate(
MYSQL_STMT * stmt);
703 MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(
MYSQL_STMT *stmt,
705 MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(
MYSQL_STMT *stmt);
707 my_ulonglong STDCALL mysql_stmt_num_rows(
MYSQL_STMT *stmt);
708 my_ulonglong STDCALL mysql_stmt_affected_rows(
MYSQL_STMT *stmt);
709 my_ulonglong STDCALL mysql_stmt_insert_id(
MYSQL_STMT *stmt);
710 unsigned int STDCALL mysql_stmt_field_count(
MYSQL_STMT *stmt);
712 my_bool STDCALL mysql_commit(
MYSQL * mysql);
713 my_bool STDCALL mysql_rollback(
MYSQL * mysql);
714 my_bool STDCALL mysql_autocommit(
MYSQL * mysql, my_bool auto_mode);
715 my_bool STDCALL mysql_more_results(
MYSQL *mysql);
716 int STDCALL mysql_next_result(
MYSQL *mysql);
717 int STDCALL mysql_stmt_next_result(
MYSQL_STMT *stmt);
718 void STDCALL mysql_close(
MYSQL *sock);
722 #define MYSQL_NO_DATA 100
723 #define MYSQL_DATA_TRUNCATED 101
725 #define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
727 #ifdef USE_OLD_FUNCTIONS
728 MYSQL * STDCALL mysql_connect(
MYSQL *mysql,
const char *host,
729 const char *user,
const char *passwd);
730 int STDCALL mysql_create_db(
MYSQL *mysql,
const char *DB);
731 int STDCALL mysql_drop_db(
MYSQL *mysql,
const char *DB);
733 #define HAVE_MYSQL_REAL_CONNECT