3
{$undef use_mysql_321} { if undefined, use mysql 3.23 interface }
5
{ updated to match version 3.23 header files of mysql by Bernhard Steffen
6
(bernhard.steffen@gmx.net)
15
Const mysqllib = 'libmysql';
17
Const mysqllib = 'mysqlclient';
23
{$linklib mysqlclient}
29
Common definition between mysql server & client
33
{ Extra types introduced for pascal }
36
pcardinal = ^cardinal;
41
NAME_LEN = 64 ; { Field/table name length }
42
LOCAL_HOST : pchar = 'localhost' ;
44
MYSQL_PORT = 3306; { Alloced by ISI for MySQL }
45
MYSQL_UNIX_ADDR : pchar = '/tmp/mysql.sock';
48
enum_server_command = ( COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
49
COM_FIELD_LIST,COM_CREATE_DB,COM_DROP_DB,COM_REFRESH,
50
COM_SHUTDOWN,COM_STATISTICS,
51
COM_PROCESS_INFO,COM_CONNECT,COM_PROCESS_KILL,
55
NOT_NULL_FLAG = 1; { Field can't be NULL }
56
PRI_KEY_FLAG = 2; { Field is part of a primary key }
57
UNIQUE_KEY_FLAG = 4; { Field is part of a unique key }
58
MULTIPLE_KEY_FLAG = 8; { Field is part of a key }
59
BLOB_FLAG = 16; { Field is a blob }
60
UNSIGNED_FLAG = 32; { Field is unsigned }
61
ZEROFILL_FLAG = 64; { Field is zerofill }
63
{ The following are only sent to new clients }
64
ENUM_FLAG = 256; { field is an enum }
65
AUTO_INCREMENT_FLAG = 512; { field is a autoincrement field }
66
TIMESTAMP_FLAG = 1024; { Field is a timestamp }
67
PART_KEY_FLAG = 16384; { Intern; Part of some key }
68
GROUP_FLAG = 32768; { Intern group field }
69
{$ifndef use_mysql_321}
70
UNIQUE_FLAG = 65536; { Intern: Used by sql_yacc }
73
REFRESH_GRANT = 1; { Refresh grant tables }
74
REFRESH_LOG = 2; { Start on new log file }
75
REFRESH_TABLES = 4; { close all tables }
76
{$ifndef use_mysql_321}
77
REFRESH_HOSTS = 8; { Flush host cache }
78
REFRESH_STATUS = 16; { Flush status variables }
79
REFRESH_THREADS = 32; { Flush status variables }
80
REFRESH_SLAVE = 64; { Reset master info and restart slave
82
REFRESH_MASTER = 128; { Remove all bin logs in the index
83
and truncate the index }
86
{$ifndef use_mysql_321}
87
{ The following can't be set with mysql_refresh() }
88
REFRESH_READ_LOCK = 16384; { Lock tables for read }
89
REFRESH_FAST = 32768; { Intern flag }
92
CLIENT_LONG_PASSWORD = 1; { new more secure passwords }
93
CLIENT_FOUND_ROWS = 2; { Found instead of affected rows }
94
CLIENT_LONG_FLAG = 4; { Get all column flags }
95
{$ifndef use_mysql_321}
96
CLIENT_CONNECT_WITH_DB = 8; { One can specify db on connect }
97
CLIENT_NO_SCHEMA = 16; { Don't allow database.table.column }
98
CLIENT_COMPRESS = 32; { Can use compression protocol }
99
CLIENT_ODBC = 64; { Odbc client }
100
CLIENT_LOCAL_FILES = 128; { Can use LOAD DATA LOCAL }
101
CLIENT_IGNORE_SPACE = 256; { Ignore spaces before '(' }
102
CLIENT_CHANGE_USER = 512; { Support the mysql_change_user() }
103
CLIENT_INTERACTIVE = 1024; { This is an interactive client }
104
CLIENT_SSL = 2048; { Switch to SSL after handshake }
105
CLIENT_IGNORE_SIGPIPE = 4096; { IGNORE sigpipes }
106
CLIENT_TRANSACTIONS = 8192; { Client knows about transactions }
108
SERVER_STATUS_IN_TRANS = 1; { Transaction has started }
109
SERVER_STATUS_AUTOCOMMIT = 2; { Server in auto_commit mode }
112
MYSQL_ERRMSG_SIZE = 200;
113
NET_READ_TIMEOUT = 30; { Timeout on read }
114
NET_WRITE_TIMEOUT = 60; { Timeout on write }
115
NET_WAIT_TIMEOUT = 8*60*60; { Wait for new query }
118
pst_used_mem = ^st_used_mem;
119
st_used_mem = record { struct for once_alloc }
120
next : pst_used_mem; { Next block in use }
121
left : cardinal; { memory left in block }
122
size : cardinal; { size of block }
125
TUSED_MEM = st_used_mem;
126
PUSED_MEM = ^TUSED_MEM;
128
TError_handler = Procedure;
133
{$ifndef use_mysql_321}
134
pre_alloc: PUSED_MEM;
135
{$endif use_mysql_321}
136
min_malloc : cardinal;
137
block_size : cardinal;
138
error_handler : TERROR_Handler;
140
TMEM_ROOT = st_mem_root;
141
PMEM_ROOT = ^TMEM_ROOT;
144
net_type = (NET_TYPE_TCPIP, NET_TYPE_SOCKET, NETTYPE_NAMEDPIPE);
146
nettype : net_type; //DT
149
buff,buff_end,write_pos,read_pos : Pchar;//DT
150
last_error : array [0..MYSQL_ERRMSG_SIZE-1] of char;
151
last_errno,max_packet,timeout,pkt_nr : Cardinal;
152
error,return_errno : my_bool;
153
compress : my_bool; //DT
154
{$ifndef use_mysql_321}
155
no_send_ok : my_bool;
157
remain_in_buf,r_length, buf_length, where_b : cardinal; //DT
158
{$ifndef use_mysql_321}
159
return_status : ^Cardinal;
160
reading_or_writing : my_bool;
164
save_char : char; //DT
170
packet_error : longint = -1;
173
enum_field_types = ( FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY,
174
FIELD_TYPE_SHORT, FIELD_TYPE_LONG,
175
FIELD_TYPE_FLOAT, FIELD_TYPE_DOUBLE,
176
FIELD_TYPE_NULL, FIELD_TYPE_TIMESTAMP,
177
FIELD_TYPE_LONGLONG,FIELD_TYPE_INT24,
178
FIELD_TYPE_DATE, FIELD_TYPE_TIME,
180
{$ifndef use_mysql_321}
184
FIELD_TYPE_ENUM := 247,
185
FIELD_TYPE_SET := 248,
186
FIELD_TYPE_TINY_BLOB := 249,
187
FIELD_TYPE_MEDIUM_BLOB := 250,
188
FIELD_TYPE_LONG_BLOB :=251,
189
FIELD_TYPE_BLOB :=252,
190
FIELD_TYPE_VAR_STRING :=253,
191
FIELD_TYPE_STRING:=254);
194
FIELD_TYPE_CHAR = FIELD_TYPE_TINY; { For compability }
195
FIELD_TYPE_INTERVAL = FIELD_TYPE_ENUM; { For compability }
197
Procedure sql_free (root : PMEM_ROOT);stdcall;
198
Procedure init_alloc_root (root: PMEM_ROOT;block_size : Cardinal);stdcall;
199
Function sql_alloc_first_block(root : PMEM_ROOT) : my_bool;stdcall;
200
Function sql_alloc_root(mem_root : PMEM_ROOT;len : Cardinal) : longint;stdcall;
201
Function sql_strdup_root(root : PMEM_ROOT;st : pchar) : pchar;stdcall;
202
Function sql_memdup_root(root: PMEM_ROOT;st : pchar; len : Cardinal): longint;stdcall;
205
extern unsigned long max_allowed_packet;
206
extern unsigned long net_buffer_length;
210
#define net_new_transaction(net) ((net)->pkt_nr=0)
213
Function my_net_init(net :PNET; fd : Socket) : Longint;stdcall;
214
procedure net_end(net : PNET);stdcall;
215
Procedure net_clear(net : PNET);stdcall;
216
Function net_flush(net : PNET) : longint;stdcall;
217
Function my_net_write(net : PNET;packet : pbyte;len : cardinal) : longint;stdcall;
218
Function net_write_command(net : PNET; command : char;packet : pbyte;len : cardinal) : longint;stdcall;
219
Function net_real_write(net : PNET;packet : pbyte; len : Cardinal) : longint;stdcall;
220
Function my_net_read(net : PNET) : Cardinal;stdcall;
223
TRand_struct = record
224
seed,seed2,max_value : Cardinal;
225
max_value_dbl : double;
227
PRand_struct = ^TRand_struct;
229
{ The following is for user defined functions }
231
Item_result = (STRING_RESULT,REAL_RESULT,INT_RESULT);
234
arg_count : cardinal; { Number of arguments }
235
arg_type : ^Item_result; { Pointer to item_results }
236
args : ppchar; { Pointer to argument }
237
lengths : PCardinal; { Length of string arguments }
239
TUDF_ARGS = st_udf_args;
240
PUDPF_ARGS = ^TUDF_ARGS;
242
{ This holds information about the result }
245
maybe_null : my_bool; { 1 if function can return NULL }
246
decimals : cardinal; { for real functions }
247
max_length : Cardinal; { For string functions }
248
ptr : PChar; { free pointer for function data }
250
TUDF_INIT = st_udf_init;
251
PUDF_INIT = TUDF_INIT;
253
{ Prototypes to password functions }
255
procedure randominit(rand : Prand_struct; seed1,seed2 : Cardinal);stdcall;
256
Function rnd(rand : Prand_struct) : double;stdcall;
257
procedure make_scrambled_password(toarg, passwd : Pchar);stdcall;
258
procedure get_salt_from_password(res : pcardinal; password : pchar);stdcall;
259
procedure scramble(toarg,message,password : pchar; old_ver : my_bool);stdcall;
260
function check_scramble(scramble,message : pchar; salt : cardinal;old_ver:my_bool) : my_bool;stdcall;
261
function get_tty_password(opt_message: pchar) : pchar;stdcall;
264
#define NULL_LENGTH ((unsigned long) ~0) { For net_store_length }
269
Procedure sql_free (root : PMEM_ROOT);stdcall;external;
270
Procedure init_alloc_root (root: PMEM_ROOT;block_size : Cardinal);stdcall;external;
271
Function sql_alloc_first_block(root : PMEM_ROOT) : my_bool;stdcall;external;
272
Function sql_alloc_root(mem_root : PMEM_ROOT;len : Cardinal) : longint;stdcall;external;
273
Function sql_strdup_root(root : PMEM_ROOT;st : pchar) : pchar;stdcall;external;
274
Function sql_memdup_root(root: PMEM_ROOT;st : pchar; len : Cardinal) : longint;stdcall;external;
275
Function my_net_init(net :PNET; fd : Socket) : Longint;stdcall;external;
276
procedure net_end(net : PNET);stdcall;external;
277
Procedure net_clear(net : PNET);stdcall;external;
278
Function net_flush(net : PNET) : longint;stdcall;external;
279
Function my_net_write(net : PNET;packet : pbyte;len : cardinal) : longint;stdcall;external;
280
Function net_write_command(net : PNET; command : char;packet : pbyte;len : cardinal) : longint;stdcall;external;
281
Function net_real_write(net : PNET;packet : pbyte; len : Cardinal) : longint;stdcall;external;
282
Function my_net_read(net : PNET) : Cardinal;stdcall;external;
283
procedure randominit(rand : Prand_struct; seed1,seed2 : Cardinal);stdcall;external;
284
Function rnd(rand : Prand_struct) : double;stdcall;external;
285
procedure make_scrambled_password(toarg, passwd : Pchar);stdcall;external;
286
procedure get_salt_from_password(res : pcardinal; password : pchar);stdcall;external;
287
procedure scramble(toarg,message,password : pchar; old_ver : my_bool);stdcall;external;
288
function check_scramble(scramble,message : pchar; salt : cardinal;old_ver:my_bool) : my_bool;stdcall;external;
289
function get_tty_password(opt_message: pchar) : pchar;stdcall;external;