mysql_com.pp 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. unit mysql_com;
  2. interface
  3. {$linklib mysqlclient}
  4. {$linklib m}
  5. {$linklib c}
  6. {
  7. Common definition between mysql server & client
  8. }
  9. {$packrecords 4}
  10. { Extra types introduced for pascal }
  11. Type
  12. pbyte = ^byte;
  13. pcardinal = ^cardinal;
  14. Socket = longint;
  15. my_bool = byte;
  16. Const
  17. NAME_LEN = 64 ; { Field/table name length }
  18. LOCAL_HOST : pchar = 'localhost' ;
  19. MYSQL_PORT = 3306; { Alloced by ISI for MySQL }
  20. MYSQL_UNIX_ADDR : pchar = '/tmp/mysql.sock';
  21. Type
  22. enum_server_command = ( COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
  23. COM_FIELD_LIST,COM_CREATE_DB,COM_DROP_DB,COM_REFRESH,
  24. COM_SHUTDOWN,COM_STATISTICS,
  25. COM_PROCESS_INFO,COM_CONNECT,COM_PROCESS_KILL,
  26. COM_DEBUG);
  27. Const
  28. NOT_NULL_FLAG = 1; { Field can't be NULL }
  29. PRI_KEY_FLAG = 2; { Field is part of a primary key }
  30. UNIQUE_KEY_FLAG = 4; { Field is part of a unique key }
  31. MULTIPLE_KEY_FLAG = 8; { Field is part of a key }
  32. BLOB_FLAG = 16; { Field is a blob }
  33. UNSIGNED_FLAG = 32; { Field is unsigned }
  34. ZEROFILL_FLAG = 64; { Field is zerofill }
  35. BINARY_FLAG = 128;
  36. { The following are only sent to new clients }
  37. ENUM_FLAG = 256; { field is an enum }
  38. AUTO_INCREMENT_FLAG = 512; { field is a autoincrement field }
  39. TIMESTAMP_FLAG = 1024; { Field is a timestamp }
  40. PART_KEY_FLAG = 16384; { Intern; Part of some key }
  41. GROUP_FLAG = 32768; { Intern group field }
  42. REFRESH_GRANT = 1; { Refresh grant tables }
  43. REFRESH_LOG = 2; { Start on new log file }
  44. REFRESH_TABLES = 4; { close all tables }
  45. CLIENT_LONG_PASSWORD = 1; { new more secure passwords }
  46. CLIENT_FOUND_ROWS = 2; { Found instead of affected rows }
  47. CLIENT_LONG_FLAG = 4; { Get all column flags }
  48. Type
  49. pst_used_mem = ^st_used_mem;
  50. st_used_mem = record { struct for once_alloc }
  51. next : pst_used_mem; { Next block in use }
  52. left : cardinal; { memory left in block }
  53. size : cardinal; { size of block }
  54. end;
  55. TUSED_MEM = st_used_mem;
  56. PUSED_MEM = ^TUSED_MEM;
  57. TError_handler = Procedure;
  58. st_mem_root = record
  59. free : PUSED_MEM;
  60. used : PUSED_MEM;
  61. min_malloc : cardinal;
  62. block_size : cardinal;
  63. error_handler : TERROR_Handler;
  64. end;
  65. TMEM_ROOT = st_mem_root;
  66. PMEM_ROOT = ^TMEM_ROOT;
  67. Const
  68. MYSQL_ERRMSG_SIZE = 200;
  69. Type
  70. net_type = (NET_TYPE_TCPIP, NET_TYPE_SOCKET, NETTYPE_NAMEDPIPE);
  71. st_net = record
  72. nettype : net_type; //DT
  73. fd : Socket;
  74. fcntl : Longint;
  75. buff,buff_end,write_pos,read_pos : Pchar;//DT
  76. last_error : array [0..MYSQL_ERRMSG_SIZE-1] of char;
  77. last_errno,max_packet,timeout,pkt_nr : Cardinal;
  78. error,return_errno : my_bool;
  79. compress : my_bool; //DT
  80. remain_in_buf,r_length, buf_length, where_b : cardinal; //DT
  81. more : my_bool;//DT
  82. save_char : char; //DT
  83. end;
  84. TNET = st_net;
  85. PNET = ^TNET;
  86. Const
  87. packet_error : longint = -1;
  88. Type
  89. enum_field_types = ( FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY,
  90. FIELD_TYPE_SHORT, FIELD_TYPE_LONG,
  91. FIELD_TYPE_FLOAT, FIELD_TYPE_DOUBLE,
  92. FIELD_TYPE_NULL, FIELD_TYPE_TIMESTAMP,
  93. FIELD_TYPE_LONGLONG,FIELD_TYPE_INT24,
  94. FIELD_TYPE_DATE, FIELD_TYPE_TIME,
  95. FIELD_TYPE_DATETIME,
  96. FIELD_TYPE_ENUM := 247,
  97. FIELD_TYPE_SET := 248,
  98. FIELD_TYPE_TINY_BLOB := 249,
  99. FIELD_TYPE_MEDIUM_BLOB := 250,
  100. FIELD_TYPE_LONG_BLOB :=251,
  101. FIELD_TYPE_BLOB :=252,
  102. FIELD_TYPE_VAR_STRING :=253,
  103. FIELD_TYPE_STRING:=254);
  104. Const
  105. FIELD_TYPE_CHAR = FIELD_TYPE_TINY; { For compability }
  106. FIELD_TYPE_INTERVAL = FIELD_TYPE_ENUM; { For compability }
  107. Procedure sql_free (root : PMEM_ROOT);{$ifdef win32} stdcall {$else} cdecl {$endif};
  108. Procedure init_alloc_root (root: PMEM_ROOT;block_size : Cardinal);{$ifdef win32} stdcall {$else} cdecl {$endif};
  109. Function sql_alloc_first_block(root : PMEM_ROOT) : my_bool;{$ifdef win32} stdcall {$else} cdecl {$endif};
  110. Function sql_alloc_root(mem_root : PMEM_ROOT;len : Cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
  111. Function sql_strdup_root(root : PMEM_ROOT;st : pchar) : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif};
  112. Function sql_memdup_root(root: PMEM_ROOT;st : pchar; len : Cardinal): longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
  113. {
  114. extern unsigned long max_allowed_packet;
  115. extern unsigned long net_buffer_length;
  116. }
  117. {
  118. #define net_new_transaction(net) ((net)->pkt_nr=0)
  119. }
  120. Function my_net_init(net :PNET; fd : Socket) : Longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
  121. procedure net_end(net : PNET);{$ifdef win32} stdcall {$else} cdecl {$endif};
  122. Procedure net_clear(net : PNET);{$ifdef win32} stdcall {$else} cdecl {$endif};
  123. Function net_flush(net : PNET) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
  124. Function my_net_write(net : PNET;packet : pbyte;len : cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
  125. Function net_write_command(net : PNET; command : char;packet : pbyte;len : cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
  126. Function net_real_write(net : PNET;packet : pbyte; len : Cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
  127. Function my_net_read(net : PNET) : Cardinal;{$ifdef win32} stdcall {$else} cdecl {$endif};
  128. Type
  129. TRand_struct = record
  130. seed,seed2,max_value : Cardinal;
  131. max_value_dbl : double;
  132. end;
  133. PRand_struct = ^TRand_struct;
  134. { The following is for user defined functions }
  135. Item_result = (STRING_RESULT,REAL_RESULT,INT_RESULT);
  136. st_udf_args = record
  137. arg_count : cardinal; { Number of arguments }
  138. arg_type : ^Item_result; { Pointer to item_results }
  139. args : ppchar; { Pointer to argument }
  140. lengths : PCardinal; { Length of string arguments }
  141. end;
  142. TUDF_ARGS = st_udf_args;
  143. PUDPF_ARGS = ^TUDF_ARGS;
  144. { This holds information about the result }
  145. st_udf_init = record
  146. maybe_null : my_bool; { 1 if function can return NULL }
  147. decimals : cardinal; { for real functions }
  148. max_length : Cardinal; { For string functions }
  149. ptr : PChar; { free pointer for function data }
  150. end;
  151. TUDF_INIT = st_udf_init;
  152. PUDF_INIT = TUDF_INIT;
  153. { Prototypes to password functions }
  154. procedure randominit(rand : Prand_struct; seed1,seed2 : Cardinal);{$ifdef win32} stdcall {$else} cdecl {$endif};
  155. Function rnd(rand : Prand_struct) : double;{$ifdef win32} stdcall {$else} cdecl {$endif};
  156. procedure make_scrambled_password(toarg, passwd : Pchar);{$ifdef win32} stdcall {$else} cdecl {$endif};
  157. procedure get_salt_from_password(res : pcardinal; password : pchar);{$ifdef win32} stdcall {$else} cdecl {$endif};
  158. procedure scramble(toarg,message,password : pchar; old_ver : my_bool);{$ifdef win32} stdcall {$else} cdecl {$endif};
  159. function check_scramble(scramble,message : pchar; salt : cardinal;old_ver:my_bool) : my_bool;{$ifdef win32} stdcall {$else} cdecl {$endif};
  160. function get_tty_password(opt_message: pchar) : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif};
  161. {
  162. #define NULL_LENGTH ((unsigned long) ~0) { For net_store_length }
  163. }
  164. implementation
  165. Procedure sql_free (root : PMEM_ROOT);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  166. Procedure init_alloc_root (root: PMEM_ROOT;block_size : Cardinal);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  167. Function sql_alloc_first_block(root : PMEM_ROOT) : my_bool;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  168. Function sql_alloc_root(mem_root : PMEM_ROOT;len : Cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  169. Function sql_strdup_root(root : PMEM_ROOT;st : pchar) : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  170. Function sql_memdup_root(root: PMEM_ROOT;st : pchar; len : Cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  171. Function my_net_init(net :PNET; fd : Socket) : Longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  172. procedure net_end(net : PNET);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  173. Procedure net_clear(net : PNET);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  174. Function net_flush(net : PNET) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  175. Function my_net_write(net : PNET;packet : pbyte;len : cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  176. Function net_write_command(net : PNET; command : char;packet : pbyte;len : cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  177. Function net_real_write(net : PNET;packet : pbyte; len : Cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  178. Function my_net_read(net : PNET) : Cardinal;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  179. procedure randominit(rand : Prand_struct; seed1,seed2 : Cardinal);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  180. Function rnd(rand : Prand_struct) : double;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  181. procedure make_scrambled_password(toarg, passwd : Pchar);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  182. procedure get_salt_from_password(res : pcardinal; password : pchar);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  183. procedure scramble(toarg,message,password : pchar; old_ver : my_bool);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  184. function check_scramble(scramble,message : pchar; salt : cardinal;old_ver:my_bool) : my_bool;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  185. function get_tty_password(opt_message: pchar) : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
  186. end.
  187. $Log$
  188. Revision 1.4 2001-03-13 08:50:38 michael
  189. + merged Fixed calling convention for win32
  190. Revision 1.3 2000/12/02 15:24:37 michael
  191. + Merged changes from fixbranch
  192. Revision 1.2 2000/07/13 11:33:26 michael
  193. + removed logs
  194. }