Add 'extension' field to all client library structures to make them extensible

Reorder structure elements to make structures smaller and faster on 64 bit systems
This is a first step in cleaning up the client include files (but should be enough to allow us to do future fixes without breaking the library)
This change is part of WL#2872,  Make client library extensible.
parent dd81895e
...@@ -16,7 +16,7 @@ AM_CONFIG_HEADER(config.h) ...@@ -16,7 +16,7 @@ AM_CONFIG_HEADER(config.h)
PROTOCOL_VERSION=10 PROTOCOL_VERSION=10
DOT_FRM_VERSION=6 DOT_FRM_VERSION=6
# See the libtool docs for information on how to do shared lib versions. # See the libtool docs for information on how to do shared lib versions.
SHARED_LIB_MAJOR_VERSION=15 SHARED_LIB_MAJOR_VERSION=16
SHARED_LIB_VERSION=$SHARED_LIB_MAJOR_VERSION:0:0 SHARED_LIB_VERSION=$SHARED_LIB_MAJOR_VERSION:0:0
NDB_SHARED_LIB_MAJOR_VERSION=3 NDB_SHARED_LIB_MAJOR_VERSION=3
NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0 NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0
...@@ -1920,8 +1920,9 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \ ...@@ -1920,8 +1920,9 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \
chsize cuserid fchmod fcntl \ chsize cuserid fchmod fcntl \
fconvert fdatasync finite fpresetsticky fpsetmask fsync ftruncate \ fconvert fdatasync finite fpresetsticky fpsetmask fsync ftruncate \
getcwd gethostbyaddr_r gethostbyname_r getpass getpassphrase getpwnam \ getcwd gethostbyaddr_r gethostbyname_r getpass getpassphrase getpwnam \
getpwuid getrlimit getrusage getwd gmtime_r index initgroups isnan \ getpwuid getrlimit getrusage getwd index initgroups isnan \
localtime_r locking longjmp lrand48 madvise mallinfo memcpy memmove \ localtime_r gethrtime gmtime_r \
locking longjmp lrand48 madvise mallinfo memcpy memmove \
mkstemp mlockall perror poll pread pthread_attr_create mmap mmap64 getpagesize \ mkstemp mlockall perror poll pread pthread_attr_create mmap mmap64 getpagesize \
pthread_attr_getstacksize pthread_attr_setprio pthread_attr_setschedparam \ pthread_attr_getstacksize pthread_attr_setprio pthread_attr_setschedparam \
pthread_attr_setstacksize pthread_condattr_create pthread_getsequence_np \ pthread_attr_setstacksize pthread_condattr_create pthread_getsequence_np \
......
...@@ -109,6 +109,7 @@ typedef struct st_mysql_field { ...@@ -109,6 +109,7 @@ typedef struct st_mysql_field {
unsigned int decimals; /* Number of decimals in field */ unsigned int decimals; /* Number of decimals in field */
unsigned int charsetnr; /* Character set */ unsigned int charsetnr; /* Character set */
enum enum_field_types type; /* Type of field. See mysql_com.h for types */ enum enum_field_types type; /* Type of field. See mysql_com.h for types */
void *extension;
} MYSQL_FIELD; } MYSQL_FIELD;
typedef char **MYSQL_ROW; /* return data as array of strings */ typedef char **MYSQL_ROW; /* return data as array of strings */
...@@ -143,12 +144,13 @@ typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */ ...@@ -143,12 +144,13 @@ typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */
typedef struct embedded_query_result EMBEDDED_QUERY_RESULT; typedef struct embedded_query_result EMBEDDED_QUERY_RESULT;
typedef struct st_mysql_data { typedef struct st_mysql_data {
my_ulonglong rows;
unsigned int fields;
MYSQL_ROWS *data; MYSQL_ROWS *data;
struct embedded_query_result *embedded_info;
MEM_ROOT alloc; MEM_ROOT alloc;
my_ulonglong rows;
unsigned int fields;
/* extra info for embedded library */ /* extra info for embedded library */
struct embedded_query_result *embedded_info; void *extension;
} MYSQL_DATA; } MYSQL_DATA;
enum mysql_option enum mysql_option
...@@ -211,6 +213,7 @@ struct st_mysql_options { ...@@ -211,6 +213,7 @@ struct st_mysql_options {
void (*local_infile_end)(void *); void (*local_infile_end)(void *);
int (*local_infile_error)(void *, char *, unsigned int); int (*local_infile_error)(void *, char *, unsigned int);
void *local_infile_userdata; void *local_infile_userdata;
void *extension;
}; };
enum mysql_status enum mysql_status
...@@ -300,27 +303,28 @@ typedef struct st_mysql ...@@ -300,27 +303,28 @@ typedef struct st_mysql
from mysql_stmt_close if close had to cancel result set of this object. from mysql_stmt_close if close had to cancel result set of this object.
*/ */
my_bool *unbuffered_fetch_owner; my_bool *unbuffered_fetch_owner;
#if defined(EMBEDDED_LIBRARY) || defined(EMBEDDED_LIBRARY_COMPATIBLE) || MYSQL_VERSION_ID >= 50100
/* needed for embedded server - no net buffer to store the 'info' */ /* needed for embedded server - no net buffer to store the 'info' */
char *info_buffer; char *info_buffer;
#endif void *extension;
} MYSQL; } MYSQL;
typedef struct st_mysql_res { typedef struct st_mysql_res {
my_ulonglong row_count; my_ulonglong row_count;
MYSQL_FIELD *fields; MYSQL_FIELD *fields;
MYSQL_DATA *data; MYSQL_DATA *data;
MYSQL_ROWS *data_cursor; MYSQL_ROWS *data_cursor;
unsigned long *lengths; /* column lengths of current row */ unsigned long *lengths; /* column lengths of current row */
MYSQL *handle; /* for unbuffered reads */ MYSQL *handle; /* for unbuffered reads */
MEM_ROOT field_alloc; const struct st_mysql_methods *methods;
unsigned int field_count, current_field;
MYSQL_ROW row; /* If unbuffered read */ MYSQL_ROW row; /* If unbuffered read */
MYSQL_ROW current_row; /* buffer to current row */ MYSQL_ROW current_row; /* buffer to current row */
MEM_ROOT field_alloc;
unsigned int field_count, current_field;
my_bool eof; /* Used by mysql_fetch_row */ my_bool eof; /* Used by mysql_fetch_row */
/* mysql_stmt_close() had to cancel this result */ /* mysql_stmt_close() had to cancel this result */
my_bool unbuffered_fetch_cancelled; my_bool unbuffered_fetch_cancelled;
const struct st_mysql_methods *methods; void *extension;
} MYSQL_RES; } MYSQL_RES;
#define MAX_MYSQL_MANAGER_ERR 256 #define MAX_MYSQL_MANAGER_ERR 256
...@@ -340,21 +344,23 @@ typedef struct st_mysql_res { ...@@ -340,21 +344,23 @@ typedef struct st_mysql_res {
typedef struct st_mysql_manager typedef struct st_mysql_manager
{ {
NET net; NET net;
char *host,*user,*passwd; char *host, *user, *passwd;
char *net_buf, *net_buf_pos, *net_data_end;
unsigned int port; unsigned int port;
my_bool free_me;
my_bool eof;
int cmd_status; int cmd_status;
int last_errno; int last_errno;
char* net_buf,*net_buf_pos,*net_data_end;
int net_buf_size; int net_buf_size;
my_bool free_me;
my_bool eof;
char last_error[MAX_MYSQL_MANAGER_ERR]; char last_error[MAX_MYSQL_MANAGER_ERR];
void *extension;
} MYSQL_MANAGER; } MYSQL_MANAGER;
typedef struct st_mysql_parameters typedef struct st_mysql_parameters
{ {
unsigned long *p_max_allowed_packet; unsigned long *p_max_allowed_packet;
unsigned long *p_net_buffer_length; unsigned long *p_net_buffer_length;
void *extension;
} MYSQL_PARAMETERS; } MYSQL_PARAMETERS;
#if !defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY) #if !defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY)
...@@ -369,6 +375,7 @@ typedef struct st_mysql_parameters ...@@ -369,6 +375,7 @@ typedef struct st_mysql_parameters
*/ */
int STDCALL mysql_server_init(int argc, char **argv, char **groups); int STDCALL mysql_server_init(int argc, char **argv, char **groups);
void STDCALL mysql_server_end(void); void STDCALL mysql_server_end(void);
/* /*
mysql_server_init/end need to be called when using libmysqld or mysql_server_init/end need to be called when using libmysqld or
libmysqlclient (exactly, mysql_server_init() is called by mysql_init() so libmysqlclient (exactly, mysql_server_init() is called by mysql_init() so
...@@ -657,23 +664,24 @@ typedef struct st_mysql_bind ...@@ -657,23 +664,24 @@ typedef struct st_mysql_bind
void *buffer; /* buffer to get/put data */ void *buffer; /* buffer to get/put data */
/* set this if you want to track data truncations happened during fetch */ /* set this if you want to track data truncations happened during fetch */
my_bool *error; my_bool *error;
enum enum_field_types buffer_type; /* buffer type */ unsigned char *row_ptr; /* for the current data position */
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);
/* output buffer length, must be set when fetching str/binary */ /* output buffer length, must be set when fetching str/binary */
unsigned long buffer_length; unsigned long buffer_length;
unsigned char *row_ptr; /* for the current data position */
unsigned long offset; /* offset position for char/binary fetch */ unsigned long offset; /* offset position for char/binary fetch */
unsigned long length_value; /* Used if length is 0 */ unsigned long length_value; /* Used if length is 0 */
unsigned int param_number; /* For null count and error messages */ unsigned int param_number; /* For null count and error messages */
unsigned int pack_length; /* Internal length for packed data */ unsigned int pack_length; /* Internal length for packed data */
enum enum_field_types buffer_type; /* buffer type */
my_bool error_value; /* used if error is 0 */ my_bool error_value; /* used if error is 0 */
my_bool is_unsigned; /* set if integer type is unsigned */ my_bool is_unsigned; /* set if integer type is unsigned */
my_bool long_data_used; /* If used with mysql_send_long_data */ my_bool long_data_used; /* If used with mysql_send_long_data */
my_bool is_null_value; /* Used if is_null is 0 */ my_bool is_null_value; /* Used if is_null is 0 */
void (*store_param_func)(NET *net, struct st_mysql_bind *param); void *extension;
void (*fetch_result)(struct st_mysql_bind *, MYSQL_FIELD *,
unsigned char **row);
void (*skip_result)(struct st_mysql_bind *, MYSQL_FIELD *,
unsigned char **row);
} MYSQL_BIND; } MYSQL_BIND;
...@@ -688,15 +696,15 @@ typedef struct st_mysql_stmt ...@@ -688,15 +696,15 @@ typedef struct st_mysql_stmt
MYSQL_FIELD *fields; /* result set metadata */ MYSQL_FIELD *fields; /* result set metadata */
MYSQL_DATA result; /* cached result set */ MYSQL_DATA result; /* cached result set */
MYSQL_ROWS *data_cursor; /* current row in cached result */ MYSQL_ROWS *data_cursor; /* current row in cached result */
/* copy of mysql->affected_rows after statement execution */
my_ulonglong affected_rows;
my_ulonglong insert_id; /* copy of mysql->insert_id */
/* /*
mysql_stmt_fetch() calls this function to fetch one row (it's different mysql_stmt_fetch() calls this function to fetch one row (it's different
for buffered, unbuffered and cursor fetch). for buffered, unbuffered and cursor fetch).
*/ */
int (*read_row_func)(struct st_mysql_stmt *stmt, int (*read_row_func)(struct st_mysql_stmt *stmt,
unsigned char **row); unsigned char **row);
/* copy of mysql->affected_rows after statement execution */
my_ulonglong affected_rows;
my_ulonglong insert_id; /* copy of mysql->insert_id */
unsigned long stmt_id; /* Id for prepared statement */ unsigned long stmt_id; /* Id for prepared statement */
unsigned long flags; /* i.e. type of cursor to open */ unsigned long flags; /* i.e. type of cursor to open */
unsigned long prefetch_rows; /* number of rows per one COM_FETCH */ unsigned long prefetch_rows; /* number of rows per one COM_FETCH */
...@@ -722,6 +730,7 @@ typedef struct st_mysql_stmt ...@@ -722,6 +730,7 @@ typedef struct st_mysql_stmt
metadata fields when doing mysql_stmt_store_result. metadata fields when doing mysql_stmt_store_result.
*/ */
my_bool update_max_length; my_bool update_max_length;
void *extension;
} MYSQL_STMT; } MYSQL_STMT;
enum enum_stmt_attr_type enum enum_stmt_attr_type
......
...@@ -186,25 +186,25 @@ typedef struct st_vio Vio; ...@@ -186,25 +186,25 @@ typedef struct st_vio Vio;
typedef struct st_net { typedef struct st_net {
#if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY) #if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY)
Vio* vio; Vio *vio;
unsigned char *buff,*buff_end,*write_pos,*read_pos; unsigned char *buff,*buff_end,*write_pos,*read_pos;
my_socket fd; /* For Perl DBI/dbd */ my_socket fd; /* For Perl DBI/dbd */
unsigned long max_packet,max_packet_size;
unsigned int pkt_nr,compress_pkt_nr;
unsigned int write_timeout, read_timeout, retry_count;
int fcntl;
my_bool compress;
/* /*
The following variable is set if we are doing several queries in one The following variable is set if we are doing several queries in one
command ( as in LOAD TABLE ... FROM MASTER ), command ( as in LOAD TABLE ... FROM MASTER ),
and do not want to confuse the client with OK at the wrong time and do not want to confuse the client with OK at the wrong time
*/ */
unsigned long remain_in_buf,length, buf_length, where_b; 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 int *return_status;
unsigned char reading_or_writing; unsigned char reading_or_writing;
char save_char; char save_char;
my_bool no_send_ok; /* For SPs and other things that do multiple stmts */ my_bool no_send_ok; /* For SPs and other things that do multiple stmts */
my_bool no_send_eof; /* For SPs' first version read-only cursors */ my_bool no_send_eof; /* For SPs' first version read-only cursors */
my_bool compress;
/* /*
Set if OK packet is already sent, and we do not need to send error Set if OK packet is already sent, and we do not need to send error
messages messages
...@@ -215,20 +215,20 @@ typedef struct st_net { ...@@ -215,20 +215,20 @@ typedef struct st_net {
queries in cache that have not stored its results yet queries in cache that have not stored its results yet
*/ */
#endif #endif
char last_error[MYSQL_ERRMSG_SIZE], sqlstate[SQLSTATE_LENGTH+1];
unsigned int last_errno;
unsigned char error;
/* /*
'query_cache_query' should be accessed only via query cache 'query_cache_query' should be accessed only via query cache
functions and methods to maintain proper locking. functions and methods to maintain proper locking.
*/ */
unsigned char *query_cache_query; unsigned char *query_cache_query;
unsigned int last_errno;
unsigned char error;
my_bool report_error; /* We should report error (we have unreported error) */ my_bool report_error; /* We should report error (we have unreported error) */
my_bool return_errno; my_bool return_errno;
char last_error[MYSQL_ERRMSG_SIZE], sqlstate[SQLSTATE_LENGTH+1];
void *extension;
} NET; } NET;
#define packet_error (~(unsigned long) 0) #define packet_error (~(unsigned long) 0)
enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
...@@ -389,6 +389,7 @@ typedef struct st_udf_args ...@@ -389,6 +389,7 @@ typedef struct st_udf_args
char *maybe_null; /* Set to 1 for all maybe_null args */ char *maybe_null; /* Set to 1 for all maybe_null args */
char **attributes; /* Pointer to attribute name */ char **attributes; /* Pointer to attribute name */
unsigned long *attribute_lengths; /* Length of attribute arguments */ unsigned long *attribute_lengths; /* Length of attribute arguments */
void *extension;
} UDF_ARGS; } UDF_ARGS;
/* This holds information about the result */ /* This holds information about the result */
...@@ -399,7 +400,9 @@ typedef struct st_udf_init ...@@ -399,7 +400,9 @@ typedef struct st_udf_init
unsigned int decimals; /* for real functions */ unsigned int decimals; /* for real functions */
unsigned long max_length; /* For string functions */ unsigned long max_length; /* For string functions */
char *ptr; /* free pointer for function data */ char *ptr; /* free pointer for function data */
my_bool const_item; /* 0 if result is independent of arguments */ /* 0 if result is independent of arguments */
my_bool const_item;
void *extension;
} UDF_INIT; } UDF_INIT;
/* Constants when using compression */ /* Constants when using compression */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment