9
3

sql_common.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #ifndef SQL_COMMON_INCLUDED
  2. #define SQL_COMMON_INCLUDED
  3. /* Copyright (c) 2003, 2012, Oracle and/or its affiliates.
  4. Copyright (c) 2010, 2012, Monty Program Ab
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; version 2 of the License.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include <mysql.h>
  19. #include <hash.h>
  20. extern const char *unknown_sqlstate;
  21. extern const char *cant_connect_sqlstate;
  22. extern const char *not_error_sqlstate;
  23. struct mysql_async_context;
  24. struct st_mysql_options_extention {
  25. char *plugin_dir;
  26. char *default_auth;
  27. char *ssl_crl; /* PEM CRL file */
  28. char *ssl_crlpath; /* PEM directory of CRL-s? */
  29. void (*report_progress)(const MYSQL *mysql,
  30. unsigned int stage,
  31. unsigned int max_stage,
  32. double progress,
  33. const char *proc_info,
  34. uint proc_info_length);
  35. struct mysql_async_context *async_context;
  36. HASH connection_attributes;
  37. size_t connection_attributes_length;
  38. };
  39. typedef struct st_mysql_methods
  40. {
  41. my_bool (*read_query_result)(MYSQL *mysql);
  42. my_bool (*advanced_command)(MYSQL *mysql,
  43. enum enum_server_command command,
  44. const unsigned char *header,
  45. unsigned long header_length,
  46. const unsigned char *arg,
  47. unsigned long arg_length,
  48. my_bool skip_check,
  49. MYSQL_STMT *stmt);
  50. MYSQL_DATA *(*read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
  51. unsigned int fields);
  52. MYSQL_RES * (*use_result)(MYSQL *mysql);
  53. void (*fetch_lengths)(unsigned long *to,
  54. MYSQL_ROW column, unsigned int field_count);
  55. void (*flush_use_result)(MYSQL *mysql, my_bool flush_all_results);
  56. int (*read_change_user_result)(MYSQL *mysql);
  57. #if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY)
  58. MYSQL_FIELD * (*list_fields)(MYSQL *mysql);
  59. my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
  60. int (*stmt_execute)(MYSQL_STMT *stmt);
  61. int (*read_binary_rows)(MYSQL_STMT *stmt);
  62. int (*unbuffered_fetch)(MYSQL *mysql, char **row);
  63. void (*free_embedded_thd)(MYSQL *mysql);
  64. const char *(*read_statistics)(MYSQL *mysql);
  65. my_bool (*next_result)(MYSQL *mysql);
  66. int (*read_rows_from_cursor)(MYSQL_STMT *stmt);
  67. #endif
  68. } MYSQL_METHODS;
  69. #define simple_command(mysql, command, arg, length, skip_check) \
  70. (*(mysql)->methods->advanced_command)(mysql, command, 0, \
  71. 0, arg, length, skip_check, NULL)
  72. #define stmt_command(mysql, command, arg, length, stmt) \
  73. (*(mysql)->methods->advanced_command)(mysql, command, 0, \
  74. 0, arg, length, 1, stmt)
  75. extern CHARSET_INFO *default_client_charset_info;
  76. MYSQL_FIELD *unpack_fields(MYSQL *mysql, MYSQL_DATA *data,MEM_ROOT *alloc,
  77. uint fields, my_bool default_value,
  78. uint server_capabilities);
  79. void free_rows(MYSQL_DATA *cur);
  80. void free_old_query(MYSQL *mysql);
  81. void end_server(MYSQL *mysql);
  82. my_bool mysql_reconnect(MYSQL *mysql);
  83. void mysql_read_default_options(struct st_mysql_options *options,
  84. const char *filename,const char *group);
  85. my_bool
  86. cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
  87. const unsigned char *header, ulong header_length,
  88. const unsigned char *arg, ulong arg_length,
  89. my_bool skip_check, MYSQL_STMT *stmt);
  90. unsigned long cli_safe_read(MYSQL *mysql);
  91. void net_clear_error(NET *net);
  92. void set_stmt_errmsg(MYSQL_STMT *stmt, NET *net);
  93. void set_stmt_error(MYSQL_STMT *stmt, int errcode, const char *sqlstate,
  94. const char *err);
  95. void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate);
  96. void set_mysql_extended_error(MYSQL *mysql, int errcode, const char *sqlstate,
  97. const char *format, ...);
  98. /* client side of the pluggable authentication */
  99. struct st_plugin_vio_info;
  100. void mpvio_info(Vio *vio, struct st_plugin_vio_info *info);
  101. int run_plugin_auth(MYSQL *mysql, char *data, uint data_len,
  102. const char *data_plugin, const char *db);
  103. int mysql_client_plugin_init();
  104. void mysql_client_plugin_deinit();
  105. struct st_mysql_client_plugin;
  106. extern struct st_mysql_client_plugin *mysql_client_builtins[];
  107. uchar * send_client_connect_attrs(MYSQL *mysql, uchar *buf);
  108. /* Non-blocking client API. */
  109. void my_context_install_suspend_resume_hook(struct mysql_async_context *b,
  110. void (*)(my_bool, void *), void *);
  111. #ifdef __cplusplus
  112. }
  113. #endif
  114. #define protocol_41(A) ((A)->server_capabilities & CLIENT_PROTOCOL_41)
  115. #endif /* SQL_COMMON_INCLUDED */