You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
Added support for connection attributes
This commit is contained in:
390
include/mysql.h
390
include/mysql.h
@@ -54,29 +54,31 @@ typedef int my_socket;
|
||||
#include "mysql_version.h"
|
||||
#include "my_list.h"
|
||||
#include "m_ctype.h"
|
||||
#include "my_sys.h"
|
||||
#include "hash.h"
|
||||
|
||||
#ifndef ST_USED_MEM_DEFINED
|
||||
#define ST_USED_MEM_DEFINED
|
||||
typedef struct st_used_mem { /* struct for once_alloc */
|
||||
struct st_used_mem *next; /* Next block in use */
|
||||
size_t left; /* memory left in block */
|
||||
size_t size; /* Size of block */
|
||||
} USED_MEM;
|
||||
typedef struct st_used_mem { /* struct for once_alloc */
|
||||
struct st_used_mem *next; /* Next block in use */
|
||||
size_t left; /* memory left in block */
|
||||
size_t size; /* Size of block */
|
||||
} 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_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;
|
||||
#endif
|
||||
|
||||
extern unsigned int mysql_port;
|
||||
extern char *mysql_unix_port;
|
||||
extern unsigned int mysql_port;
|
||||
extern char *mysql_unix_port;
|
||||
|
||||
#define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG)
|
||||
#define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG)
|
||||
@@ -85,203 +87,207 @@ extern char *mysql_unix_port;
|
||||
#define IS_NUM_FIELD(f) ((f)->flags & NUM_FLAG)
|
||||
#define INTERNAL_NUM_FIELD(f) (((f)->type <= MYSQL_TYPE_INT24 && ((f)->type != MYSQL_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == MYSQL_TYPE_YEAR)
|
||||
|
||||
typedef struct st_mysql_field {
|
||||
char *name; /* Name of column */
|
||||
char *org_name; /* Name of original column (added after 3.23.58) */
|
||||
char *table; /* Table of column if column was a field */
|
||||
char *org_table; /* Name of original table (added after 3.23.58 */
|
||||
char *db; /* table schema (added after 3.23.58) */
|
||||
char *catalog; /* table catalog (added after 3.23.58) */
|
||||
char *def; /* Default value (set by mysql_list_fields) */
|
||||
unsigned long length; /* Width of column */
|
||||
unsigned long max_length; /* Max width of selected set */
|
||||
/* added after 3.23.58 */
|
||||
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; /* Div flags */
|
||||
unsigned int decimals; /* Number of decimals in field */
|
||||
unsigned int charsetnr; /* char set number (added in 4.1) */
|
||||
enum enum_field_types type; /* Type of field. Se mysql_com.h for types */
|
||||
void *extension; /* added in 4.1 */
|
||||
} MYSQL_FIELD;
|
||||
typedef struct st_mysql_field {
|
||||
char *name; /* Name of column */
|
||||
char *org_name; /* Name of original column (added after 3.23.58) */
|
||||
char *table; /* Table of column if column was a field */
|
||||
char *org_table; /* Name of original table (added after 3.23.58 */
|
||||
char *db; /* table schema (added after 3.23.58) */
|
||||
char *catalog; /* table catalog (added after 3.23.58) */
|
||||
char *def; /* Default value (set by mysql_list_fields) */
|
||||
unsigned long length; /* Width of column */
|
||||
unsigned long max_length; /* Max width of selected set */
|
||||
/* added after 3.23.58 */
|
||||
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; /* Div flags */
|
||||
unsigned int decimals; /* Number of decimals in field */
|
||||
unsigned int charsetnr; /* char set number (added in 4.1) */
|
||||
enum enum_field_types type; /* Type of field. Se mysql_com.h for types */
|
||||
void *extension; /* added in 4.1 */
|
||||
} MYSQL_FIELD;
|
||||
|
||||
typedef char **MYSQL_ROW; /* return data as array of strings */
|
||||
typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */
|
||||
typedef char **MYSQL_ROW; /* return data as array of strings */
|
||||
typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */
|
||||
|
||||
#if defined(NO_CLIENT_LONG_LONG)
|
||||
typedef unsigned long my_ulonglong;
|
||||
typedef unsigned long my_ulonglong;
|
||||
#elif defined (_WIN32)
|
||||
typedef unsigned __int64 my_ulonglong;
|
||||
typedef unsigned __int64 my_ulonglong;
|
||||
#else
|
||||
typedef unsigned long long my_ulonglong;
|
||||
typedef unsigned long long my_ulonglong;
|
||||
#endif
|
||||
|
||||
|
||||
#define SET_CLIENT_ERROR(a, b, c, d) \
|
||||
{ \
|
||||
(a)->net.last_errno= (b);\
|
||||
strncpy((a)->net.sqlstate, (c), sizeof((a)->net.sqlstate));\
|
||||
strncpy((a)->net.last_error, (d) ? (d) : ER((b)), sizeof((a)->net.last_error));\
|
||||
}
|
||||
{ \
|
||||
(a)->net.last_errno= (b);\
|
||||
strncpy((a)->net.sqlstate, (c), sizeof((a)->net.sqlstate));\
|
||||
strncpy((a)->net.last_error, (d) ? (d) : ER((b)), sizeof((a)->net.last_error));\
|
||||
}
|
||||
|
||||
#define CLEAR_CLIENT_ERROR(a) \
|
||||
{ \
|
||||
(a)->net.last_errno= 0;\
|
||||
strcpy((a)->net.sqlstate, "00000");\
|
||||
(a)->net.last_error[0]= '\0';\
|
||||
}
|
||||
{ \
|
||||
(a)->net.last_errno= 0;\
|
||||
strcpy((a)->net.sqlstate, "00000");\
|
||||
(a)->net.last_error[0]= '\0';\
|
||||
}
|
||||
|
||||
#define MYSQL_COUNT_ERROR (~(my_ulonglong) 0)
|
||||
|
||||
|
||||
typedef struct st_mysql_rows {
|
||||
struct st_mysql_rows *next; /* list of rows */
|
||||
MYSQL_ROW data;
|
||||
unsigned long length;
|
||||
} MYSQL_ROWS;
|
||||
typedef struct st_mysql_rows {
|
||||
struct st_mysql_rows *next; /* list of rows */
|
||||
MYSQL_ROW data;
|
||||
unsigned long length;
|
||||
} MYSQL_ROWS;
|
||||
|
||||
typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */
|
||||
typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */
|
||||
|
||||
typedef struct st_mysql_data {
|
||||
my_ulonglong rows;
|
||||
unsigned int fields;
|
||||
MYSQL_ROWS *data;
|
||||
MEM_ROOT alloc;
|
||||
} MYSQL_DATA;
|
||||
typedef struct st_mysql_data {
|
||||
my_ulonglong rows;
|
||||
unsigned int fields;
|
||||
MYSQL_ROWS *data;
|
||||
MEM_ROOT alloc;
|
||||
} 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,
|
||||
MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
|
||||
MYSQL_PLUGIN_DIR,
|
||||
MYSQL_DEFAULT_AUTH,
|
||||
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,
|
||||
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,
|
||||
MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
|
||||
MYSQL_PLUGIN_DIR,
|
||||
MYSQL_DEFAULT_AUTH,
|
||||
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,
|
||||
/* Connection attribute options */
|
||||
MYSQL_OPT_CONNECT_ATTR_RESET,
|
||||
MYSQL_OPT_CONNECT_ATTR_ADD,
|
||||
MYSQL_OPT_CONNECT_ATTR_DELETE,
|
||||
|
||||
/* MariaDB specific */
|
||||
MYSQL_PROGRESS_CALLBACK=5999,
|
||||
MYSQL_DATABASE_DRIVER=7000
|
||||
};
|
||||
/* MariaDB specific */
|
||||
MYSQL_PROGRESS_CALLBACK=5999,
|
||||
MYSQL_DATABASE_DRIVER=7000
|
||||
};
|
||||
|
||||
enum mysql_status { MYSQL_STATUS_READY,
|
||||
MYSQL_STATUS_GET_RESULT,
|
||||
MYSQL_STATUS_USE_RESULT,
|
||||
MYSQL_STATUS_QUERY_SENT,
|
||||
MYSQL_STATUS_SENDING_LOAD_DATA,
|
||||
MYSQL_STATUS_FETCHING_DATA,
|
||||
MYSQL_STATUS_NEXT_RESULT_PENDING,
|
||||
MYSQL_STATUS_QUIT_SENT, /* object is "destroyed" at this stage */
|
||||
};
|
||||
enum mysql_status { MYSQL_STATUS_READY,
|
||||
MYSQL_STATUS_GET_RESULT,
|
||||
MYSQL_STATUS_USE_RESULT,
|
||||
MYSQL_STATUS_QUERY_SENT,
|
||||
MYSQL_STATUS_SENDING_LOAD_DATA,
|
||||
MYSQL_STATUS_FETCHING_DATA,
|
||||
MYSQL_STATUS_NEXT_RESULT_PENDING,
|
||||
MYSQL_STATUS_QUIT_SENT, /* object is "destroyed" at this stage */
|
||||
};
|
||||
|
||||
enum mysql_protocol_type
|
||||
{
|
||||
MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
|
||||
MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
|
||||
};
|
||||
enum mysql_protocol_type
|
||||
{
|
||||
MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
|
||||
MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
|
||||
};
|
||||
|
||||
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_command;
|
||||
char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name;
|
||||
char *ssl_key; /* PEM key file */
|
||||
char *ssl_cert; /* PEM cert file */
|
||||
char *ssl_ca; /* PEM CA file */
|
||||
char *ssl_capath; /* PEM directory of CA-s? */
|
||||
char *ssl_cipher;
|
||||
char *shared_memory_base_name;
|
||||
unsigned long max_allowed_packet;
|
||||
my_bool use_ssl; /* if to use SSL or not */
|
||||
my_bool compress,named_pipe;
|
||||
my_bool unused_1, unused_2, unused_3, unused_4;
|
||||
enum mysql_option methods_to_use;
|
||||
char *client_ip;
|
||||
my_bool secure_auth;
|
||||
my_bool report_data_truncation;
|
||||
/* function pointers for local infile support */
|
||||
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;
|
||||
struct st_mysql_options_extention *extension;
|
||||
};
|
||||
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_command;
|
||||
char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name;
|
||||
char *ssl_key; /* PEM key file */
|
||||
char *ssl_cert; /* PEM cert file */
|
||||
char *ssl_ca; /* PEM CA file */
|
||||
char *ssl_capath; /* PEM directory of CA-s? */
|
||||
char *ssl_cipher;
|
||||
char *shared_memory_base_name;
|
||||
unsigned long max_allowed_packet;
|
||||
my_bool use_ssl; /* if to use SSL or not */
|
||||
my_bool compress,named_pipe;
|
||||
my_bool unused_1, unused_2, unused_3, unused_4;
|
||||
enum mysql_option methods_to_use;
|
||||
char *client_ip;
|
||||
my_bool secure_auth;
|
||||
my_bool report_data_truncation;
|
||||
/* function pointers for local infile support */
|
||||
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;
|
||||
struct st_mysql_options_extention *extension;
|
||||
};
|
||||
|
||||
typedef struct st_mariadb_db_driver
|
||||
{
|
||||
struct st_mariadb_client_plugin_DB *plugin;
|
||||
char *name;
|
||||
void *buffer;
|
||||
} MARIADB_DB_DRIVER;
|
||||
typedef struct st_mariadb_db_driver
|
||||
{
|
||||
struct st_mariadb_client_plugin_DB *plugin;
|
||||
char *name;
|
||||
void *buffer;
|
||||
} MARIADB_DB_DRIVER;
|
||||
|
||||
typedef struct st_mysql {
|
||||
NET net; /* Communication parameters */
|
||||
void *unused_0;
|
||||
char *host,*user,*passwd,*unix_socket,*server_version,*host_info;
|
||||
char *info,*db;
|
||||
const struct charset_info_st *charset; /* character set */
|
||||
MYSQL_FIELD *fields;
|
||||
MEM_ROOT field_alloc;
|
||||
my_ulonglong affected_rows;
|
||||
my_ulonglong insert_id; /* id if insert on table with NEXTNR */
|
||||
my_ulonglong extra_info; /* Used by mysqlshow */
|
||||
unsigned long thread_id; /* Id for connection in server */
|
||||
unsigned long packet_length;
|
||||
unsigned int port;
|
||||
unsigned long client_flag,server_capabilities; /* changed from int to long in 4.1 protocol */
|
||||
unsigned int protocol_version;
|
||||
unsigned int field_count;
|
||||
unsigned int server_status;
|
||||
unsigned int server_language;
|
||||
unsigned int warning_count; /* warning count, added in 4.1 protocol */
|
||||
struct st_mysql_options options;
|
||||
enum mysql_status status;
|
||||
my_bool free_me; /* If free in mysql_close */
|
||||
my_bool reconnect; /* set to 1 if automatic reconnect */
|
||||
char scramble_buff[20+ 1];
|
||||
/* madded after 3.23.58 */
|
||||
my_bool unused_1;
|
||||
void *unused_2, *unused_3, *unused_4, *unused_5;
|
||||
LIST *stmts;
|
||||
const struct st_mysql_methods *methods;
|
||||
void *thd;
|
||||
my_bool *unbuffered_fetch_owner;
|
||||
char *info_buffer;
|
||||
void *extension;
|
||||
typedef struct st_mysql {
|
||||
NET net; /* Communication parameters */
|
||||
void *unused_0;
|
||||
char *host,*user,*passwd,*unix_socket,*server_version,*host_info;
|
||||
char *info,*db;
|
||||
const struct charset_info_st *charset; /* character set */
|
||||
MYSQL_FIELD *fields;
|
||||
MEM_ROOT field_alloc;
|
||||
my_ulonglong affected_rows;
|
||||
my_ulonglong insert_id; /* id if insert on table with NEXTNR */
|
||||
my_ulonglong extra_info; /* Used by mysqlshow */
|
||||
unsigned long thread_id; /* Id for connection in server */
|
||||
unsigned long packet_length;
|
||||
unsigned int port;
|
||||
unsigned long client_flag,server_capabilities; /* changed from int to long in 4.1 protocol */
|
||||
unsigned int protocol_version;
|
||||
unsigned int field_count;
|
||||
unsigned int server_status;
|
||||
unsigned int server_language;
|
||||
unsigned int warning_count; /* warning count, added in 4.1 protocol */
|
||||
struct st_mysql_options options;
|
||||
enum mysql_status status;
|
||||
my_bool free_me; /* If free in mysql_close */
|
||||
my_bool reconnect; /* set to 1 if automatic reconnect */
|
||||
char scramble_buff[20+ 1];
|
||||
/* madded after 3.23.58 */
|
||||
my_bool unused_1;
|
||||
void *unused_2, *unused_3, *unused_4, *unused_5;
|
||||
LIST *stmts;
|
||||
const struct st_mysql_methods *methods;
|
||||
void *thd;
|
||||
my_bool *unbuffered_fetch_owner;
|
||||
char *info_buffer;
|
||||
void *extension;
|
||||
} MYSQL;
|
||||
|
||||
struct st_mysql_options_extention {
|
||||
@@ -290,6 +296,8 @@ struct st_mysql_options_extention {
|
||||
char *ssl_crl;
|
||||
char *ssl_crlpath;
|
||||
char *server_public_key_path;
|
||||
HASH connect_attrs;
|
||||
size_t connect_attrs_len;
|
||||
void (*report_progress)(const MYSQL *mysql,
|
||||
unsigned int stage,
|
||||
unsigned int max_stage,
|
||||
@@ -468,6 +476,8 @@ CHARSET_INFO * STDCALL mysql_get_charset_by_name(const char *csname);
|
||||
CHARSET_INFO * STDCALL mysql_get_charset_by_nr(uint csnr);
|
||||
size_t STDCALL mariadb_convert_string(const char *from, size_t *from_len, CHARSET_INFO *from_cs,
|
||||
char *to, size_t *to_len, CHARSET_INFO *to_cs, int *errorcode);
|
||||
int STDCALL mysql_options4(MYSQL *mysql,enum mysql_option option,
|
||||
const void *arg1, const void *arg2);
|
||||
|
||||
#include <my_stmt.h>
|
||||
|
||||
|
Reference in New Issue
Block a user