~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to fpcsrc/packages/base/mysql/ver323/mysql_com.pp

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
unit mysql_com;
 
2
 
 
3
{$undef use_mysql_321} { if undefined, use mysql 3.23 interface }
 
4
 
 
5
{ updated to match version 3.23 header files of mysql by Bernhard Steffen
 
6
  (bernhard.steffen@gmx.net)
 
7
}
 
8
 
 
9
interface
 
10
 
 
11
uses
 
12
  mysql_version;
 
13
 
 
14
{$ifdef win32}
 
15
Const mysqllib = 'libmysql';
 
16
{$else}
 
17
Const mysqllib = 'mysqlclient';
 
18
{$endif}
 
19
 
 
20
{$ifndef win32}
 
21
{$linklib c}
 
22
{$linklib m}
 
23
{$linklib mysqlclient}
 
24
{$endif}
 
25
{$r+,i+,o+}
 
26
 
 
27
 
 
28
{
 
29
 Common definition between mysql server & client
 
30
}
 
31
 
 
32
{$packrecords 4}
 
33
{ Extra types introduced for pascal }
 
34
Type
 
35
  pbyte = ^byte;
 
36
  pcardinal = ^cardinal;
 
37
  Socket = longint;
 
38
  my_bool = byte;
 
39
 
 
40
Const
 
41
 NAME_LEN  = 64 ;               { Field/table name length }
 
42
 LOCAL_HOST : pchar = 'localhost' ;
 
43
 
 
44
 MYSQL_PORT = 3306;             { Alloced by ISI for MySQL }
 
45
 MYSQL_UNIX_ADDR  : pchar = '/tmp/mysql.sock';
 
46
 
 
47
Type
 
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,
 
52
                          COM_DEBUG);
 
53
 
 
54
Const
 
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 }
 
62
 BINARY_FLAG         = 128;
 
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 }
 
71
{$endif}
 
72
 
 
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
 
81
                                           thread }
 
82
 REFRESH_MASTER          = 128;     { Remove all bin logs in the index
 
83
                                           and truncate the index }
 
84
{$endif}
 
85
 
 
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 }
 
90
{$endif}
 
91
 
 
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 }
 
107
 
 
108
 SERVER_STATUS_IN_TRANS  = 1;   { Transaction has started }
 
109
 SERVER_STATUS_AUTOCOMMIT = 2;  { Server in auto_commit mode }
 
110
{$endif}
 
111
 
 
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 }
 
116
 
 
117
Type
 
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 }
 
123
end;
 
124
 
 
125
TUSED_MEM = st_used_mem;
 
126
PUSED_MEM = ^TUSED_MEM;
 
127
 
 
128
TError_handler = Procedure;
 
129
 
 
130
st_mem_root =  record
 
131
  free : PUSED_MEM;
 
132
  used : PUSED_MEM;
 
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;
 
139
end;
 
140
TMEM_ROOT = st_mem_root;
 
141
PMEM_ROOT = ^TMEM_ROOT;
 
142
 
 
143
Type
 
144
net_type = (NET_TYPE_TCPIP, NET_TYPE_SOCKET, NETTYPE_NAMEDPIPE);
 
145
st_net  = record
 
146
  nettype : net_type; //DT
 
147
  fd : Socket;
 
148
  fcntl : Longint;
 
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;
 
156
{$endif}
 
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;
 
161
{$else}
 
162
  more : my_bool;//DT
 
163
{$endif}
 
164
  save_char : char; //DT
 
165
end;
 
166
TNET = st_net;
 
167
PNET = ^TNET;
 
168
 
 
169
Const
 
170
  packet_error : longint = -1;
 
171
 
 
172
Type
 
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,
 
179
                        FIELD_TYPE_DATETIME,
 
180
{$ifndef use_mysql_321}
 
181
                        FIELD_TYPE_YEAR,
 
182
                        FIELD_TYPE_NEWDATE,
 
183
{$endif}
 
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);
 
192
 
 
193
Const
 
194
FIELD_TYPE_CHAR = FIELD_TYPE_TINY;              { For compability }
 
195
FIELD_TYPE_INTERVAL = FIELD_TYPE_ENUM;          { For compability }
 
196
 
 
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;
 
203
 
 
204
{
 
205
extern unsigned long max_allowed_packet;
 
206
extern unsigned long net_buffer_length;
 
207
}
 
208
 
 
209
{
 
210
#define net_new_transaction(net) ((net)->pkt_nr=0)
 
211
}
 
212
 
 
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;
 
221
 
 
222
Type
 
223
TRand_struct  = record
 
224
  seed,seed2,max_value : Cardinal;
 
225
  max_value_dbl : double;
 
226
end;
 
227
PRand_struct = ^TRand_struct;
 
228
 
 
229
{ The following is for user defined functions }
 
230
 
 
231
Item_result = (STRING_RESULT,REAL_RESULT,INT_RESULT);
 
232
 
 
233
st_udf_args = record
 
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 }
 
238
end;
 
239
TUDF_ARGS = st_udf_args;
 
240
PUDPF_ARGS = ^TUDF_ARGS;
 
241
 
 
242
  { This holds information about the result }
 
243
 
 
244
st_udf_init = record
 
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 }
 
249
end;
 
250
TUDF_INIT = st_udf_init;
 
251
PUDF_INIT = TUDF_INIT;
 
252
 
 
253
  { Prototypes to password functions }
 
254
 
 
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;
 
262
 
 
263
{
 
264
#define NULL_LENGTH ((unsigned long) ~0) { For net_store_length }
 
265
}
 
266
 
 
267
implementation
 
268
 
 
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;
 
290
 
 
291
end.