1
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
3
This library is free software; you can redistribute it and/or
4
modify it under the terms of the GNU Library General Public
5
License as published by the Free Software Foundation; either
6
version 2 of the License, or (at your option) any later version.
8
This library 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 GNU
11
Library General Public License for more details.
13
You should have received a copy of the GNU Library General Public
14
License along with this library; if not, write to the Free
15
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18
/* defines for the libmysql library */
29
#ifndef _global_h /* If not standard header */
30
#include <sys/types.h>
32
#if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__)
38
#define STDCALL __stdcall
42
#ifndef ST_USED_MEM_DEFINED
43
#define ST_USED_MEM_DEFINED
44
typedef struct st_used_mem { /* struct for once_alloc */
45
struct st_used_mem *next; /* Next block in use */
46
unsigned int left; /* memory left in block */
47
unsigned int size; /* size of block */
49
typedef struct st_mem_root {
52
unsigned int min_malloc;
53
unsigned int block_size;
54
void (*error_handler)(void);
58
#ifndef my_socket_defined
60
#define my_socket SOCKET
62
typedef int my_socket;
66
#include "mysql_com.h"
67
#include "mysql_version.h"
69
extern unsigned int mysql_port;
70
extern char *mysql_unix_port;
72
#define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG)
73
#define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG)
74
#define IS_BLOB(n) ((n) & BLOB_FLAG)
75
#define IS_NUM(t) ((t) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR)
77
typedef struct st_mysql_field {
78
char *name; /* Name of column */
79
char *table; /* Table of column if column was a field */
80
char *def; /* Default value (set by mysql_list_fields) */
81
enum enum_field_types type; /* Type of field. Se mysql_com.h for types */
82
unsigned int length; /* Width of column */
83
unsigned int max_length; /* Max width of selected set */
84
unsigned int flags; /* Div flags */
85
unsigned int decimals; /* Number of decimals in field */
88
typedef char **MYSQL_ROW; /* return data as array of strings */
89
typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */
91
#if defined(NO_CLIENT_LONG_LONG)
92
typedef unsigned long my_ulonglong;
93
#elif defined (__WIN__)
94
typedef unsigned __int64 my_ulonglong;
96
typedef unsigned long long my_ulonglong;
99
#define MYSQL_COUNT_ERROR (~(my_ulonglong) 0)
101
typedef struct st_mysql_rows {
102
struct st_mysql_rows *next; /* list of rows */
106
typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */
108
typedef struct st_mysql_data {
115
struct st_mysql_options {
116
unsigned int connect_timeout,client_flag;
117
my_bool compress,named_pipe;
119
char *host,*init_command,*user,*password,*unix_socket,*db;
120
char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name;
121
my_bool use_ssl; /* if to use SSL or not */
122
char *ssl_key; /* PEM key file */
123
char *ssl_cert; /* PEM cert file */
124
char *ssl_ca; /* PEM CA file */
125
char *ssl_capath; /* PEM directory of CA-s? */
128
enum mysql_option { MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS,
129
MYSQL_OPT_NAMED_PIPE, MYSQL_INIT_COMMAND,
130
MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP,
131
MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME};
133
enum mysql_status { MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,
134
MYSQL_STATUS_USE_RESULT};
136
typedef struct st_mysql {
137
NET net; /* Communication parameters */
138
gptr connector_fd; /* ConnectorFd for SSL */
139
char *host,*user,*passwd,*unix_socket,*server_version,*host_info,
141
unsigned int port,client_flag,server_capabilities;
142
unsigned int protocol_version;
143
unsigned int field_count;
144
unsigned int server_status;
145
unsigned long thread_id; /* Id for connection in server */
146
my_ulonglong affected_rows;
147
my_ulonglong insert_id; /* id if insert on table with NEXTNR */
148
my_ulonglong extra_info; /* Used by mysqlshow */
149
unsigned long packet_length;
150
enum mysql_status status;
152
MEM_ROOT field_alloc;
153
my_bool free_me; /* If free in mysql_close */
154
my_bool reconnect; /* set to 1 if automatic reconnect */
155
struct st_mysql_options options;
156
char scramble_buff[9];
157
struct charset_info_st *charset;
158
unsigned int server_language;
162
typedef struct st_mysql_res {
163
my_ulonglong row_count;
164
unsigned int field_count, current_field;
167
MYSQL_ROWS *data_cursor;
168
MEM_ROOT field_alloc;
169
MYSQL_ROW row; /* If unbuffered read */
170
MYSQL_ROW current_row; /* buffer to current row */
171
unsigned long *lengths; /* column lengths of current row */
172
MYSQL *handle; /* for unbuffered reads */
173
my_bool eof; /* Used my mysql_fetch_row */
176
/* Functions to get information from the MYSQL and MYSQL_RES structures */
177
/* Should definitely be used if one uses shared libraries */
179
my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res);
180
unsigned int STDCALL mysql_num_fields(MYSQL_RES *res);
181
my_bool STDCALL mysql_eof(MYSQL_RES *res);
182
MYSQL_FIELD *STDCALL mysql_fetch_field_direct(MYSQL_RES *res,
183
unsigned int fieldnr);
184
MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res);
185
MYSQL_ROWS * STDCALL mysql_row_tell(MYSQL_RES *res);
186
unsigned int STDCALL mysql_field_tell(MYSQL_RES *res);
188
unsigned int STDCALL mysql_field_count(MYSQL *mysql);
189
my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql);
190
my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql);
191
unsigned int STDCALL mysql_errno(MYSQL *mysql);
192
char * STDCALL mysql_error(MYSQL *mysql);
193
char * STDCALL mysql_info(MYSQL *mysql);
194
unsigned long STDCALL mysql_thread_id(MYSQL *mysql);
195
const char * STDCALL mysql_character_set_name(MYSQL *mysql);
197
MYSQL * STDCALL mysql_init(MYSQL *mysql);
199
int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key,
200
const char *cert, const char *ca,
202
char * STDCALL mysql_ssl_cipher(MYSQL *mysql);
203
int STDCALL mysql_ssl_clear(MYSQL *mysql);
204
#endif /* HAVE_OPENSSL */
205
MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host,
206
const char *user, const char *passwd);
207
my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
208
const char *passwd, const char *db);
209
#if MYSQL_VERSION_ID >= 32200
210
MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
215
const char *unix_socket,
216
unsigned int clientflag);
218
MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
222
const char *unix_socket,
223
unsigned int clientflag);
225
void STDCALL mysql_close(MYSQL *sock);
226
int STDCALL mysql_select_db(MYSQL *mysql, const char *db);
227
int STDCALL mysql_query(MYSQL *mysql, const char *q);
228
int STDCALL mysql_real_query(MYSQL *mysql, const char *q,
229
unsigned int length);
230
int STDCALL mysql_create_db(MYSQL *mysql, const char *DB);
231
int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
232
int STDCALL mysql_shutdown(MYSQL *mysql);
233
int STDCALL mysql_dump_debug_info(MYSQL *mysql);
234
int STDCALL mysql_refresh(MYSQL *mysql,
235
unsigned int refresh_options);
236
int STDCALL mysql_kill(MYSQL *mysql,unsigned long pid);
237
int STDCALL mysql_ping(MYSQL *mysql);
238
char * STDCALL mysql_stat(MYSQL *mysql);
239
char * STDCALL mysql_get_server_info(MYSQL *mysql);
240
char * STDCALL mysql_get_client_info(void);
241
char * STDCALL mysql_get_host_info(MYSQL *mysql);
242
unsigned int STDCALL mysql_get_proto_info(MYSQL *mysql);
243
MYSQL_RES * STDCALL mysql_list_dbs(MYSQL *mysql,const char *wild);
244
MYSQL_RES * STDCALL mysql_list_tables(MYSQL *mysql,const char *wild);
245
MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
247
MYSQL_RES * STDCALL mysql_list_processes(MYSQL *mysql);
248
MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql);
249
MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql);
250
int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option,
252
void STDCALL mysql_free_result(MYSQL_RES *result);
253
void STDCALL mysql_data_seek(MYSQL_RES *result,
254
my_ulonglong offset);
255
MYSQL_ROW_OFFSET STDCALL mysql_row_seek(MYSQL_RES *result, MYSQL_ROW_OFFSET);
256
MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result,
257
MYSQL_FIELD_OFFSET offset);
258
MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result);
259
unsigned long * STDCALL mysql_fetch_lengths(MYSQL_RES *result);
260
MYSQL_FIELD * STDCALL mysql_fetch_field(MYSQL_RES *result);
261
unsigned long STDCALL mysql_escape_string(char *to,const char *from,
262
unsigned long from_length);
263
unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql,
264
char *to,const char *from,
265
unsigned long length);
266
void STDCALL mysql_debug(const char *debug);
267
char * STDCALL mysql_odbc_escape_string(MYSQL *mysql,
269
unsigned long to_length,
271
unsigned long from_length,
276
unsigned long *length));
277
void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
278
unsigned int STDCALL mysql_thread_safe(void);
281
#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
283
/* new api functions */
285
#define HAVE_MYSQL_REAL_CONNECT