mysql_com.pp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. unit mysql_com;
  2. interface
  3. {
  4. Automatically converted by H2Pas 0.99.15 from mysql_com.ph
  5. The following command line parameters were used:
  6. -p
  7. -D
  8. -l
  9. mysqlclient
  10. mysql_com.ph
  11. }
  12. const
  13. External_library='mysqlclient'; {Setup as you need}
  14. { Pointers to basic pascal types, inserted by h2pas conversion program.}
  15. Type
  16. PLongint = ^Longint;
  17. PSmallInt = ^SmallInt;
  18. PByte = ^Byte;
  19. PWord = ^Word;
  20. PDWord = ^DWord;
  21. PDouble = ^Double;
  22. { Extra manually added types }
  23. PVIO = Pointer;
  24. My_socket = longint;
  25. my_bool = byte;
  26. pppchar = ^PPChar;
  27. gptr = Pointer;
  28. {$PACKRECORDS C}
  29. { Copyright (C) 2000 MySQL AB
  30. This program is free software; you can redistribute it and/or modify
  31. it under the terms of the GNU General Public License as published by
  32. the Free Software Foundation; either version 2 of the License, or
  33. (at your option) any later version.
  34. This program is distributed in the hope that it will be useful,
  35. but WITHOUT ANY WARRANTY; without even the implied warranty of
  36. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  37. GNU General Public License for more details.
  38. You should have received a copy of the GNU General Public License
  39. along with this program; if not, write to the Free Software
  40. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA }
  41. {
  42. Common definition between mysql server & client
  43. }
  44. { Field/table name length }
  45. const
  46. NAME_LEN = 64;
  47. HOSTNAME_LENGTH = 60;
  48. USERNAME_LENGTH = 16;
  49. SERVER_VERSION_LENGTH = 60;
  50. LOCAL_HOST = 'localhost';
  51. LOCAL_HOST_NAMEDPIPE = '.';
  52. type
  53. enum_server_command = (COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
  54. COM_FIELD_LIST,COM_CREATE_DB,COM_DROP_DB,
  55. COM_REFRESH,COM_SHUTDOWN,COM_STATISTICS,
  56. COM_PROCESS_INFO,COM_CONNECT,COM_PROCESS_KILL,
  57. COM_DEBUG,COM_PING,COM_TIME,COM_DELAYED_INSERT,
  58. COM_CHANGE_USER,COM_BINLOG_DUMP,COM_TABLE_DUMP,
  59. COM_CONNECT_OUT,COM_REGISTER_SLAVE);
  60. { Field can't be NULL }
  61. const
  62. NOT_NULL_FLAG = 1;
  63. { Field is part of a primary key }
  64. PRI_KEY_FLAG = 2;
  65. { Field is part of a unique key }
  66. UNIQUE_KEY_FLAG = 4;
  67. { Field is part of a key }
  68. MULTIPLE_KEY_FLAG = 8;
  69. { Field is a blob }
  70. BLOB_FLAG = 16;
  71. { Field is unsigned }
  72. UNSIGNED_FLAG = 32;
  73. { Field is zerofill }
  74. ZEROFILL_FLAG = 64;
  75. BINARY_FLAG = 128;
  76. { The following are only sent to new clients }
  77. { field is an enum }
  78. ENUM_FLAG = 256;
  79. { field is a autoincrement field }
  80. AUTO_INCREMENT_FLAG = 512;
  81. { Field is a timestamp }
  82. TIMESTAMP_FLAG = 1024;
  83. { field is a set }
  84. SET_FLAG = 2048;
  85. { Field is num (for clients) }
  86. NUM_FLAG = 32768;
  87. { Intern; Part of some key }
  88. PART_KEY_FLAG = 16384;
  89. { Intern: Group field }
  90. GROUP_FLAG = 32768;
  91. { Intern: Used by sql_yacc }
  92. UNIQUE_FLAG = 65536;
  93. { Refresh grant tables }
  94. REFRESH_GRANT = 1;
  95. { Start on new log file }
  96. REFRESH_LOG = 2;
  97. { close all tables }
  98. REFRESH_TABLES = 4;
  99. { Flush host cache }
  100. REFRESH_HOSTS = 8;
  101. { Flush status variables }
  102. REFRESH_STATUS = 16;
  103. { Flush status variables }
  104. REFRESH_THREADS = 32;
  105. { Reset master info and restart slave
  106. thread }
  107. REFRESH_SLAVE = 64;
  108. { Remove all bin logs in the index
  109. and truncate the index }
  110. REFRESH_MASTER = 128;
  111. { The following can't be set with mysql_refresh() }
  112. { Lock tables for read }
  113. REFRESH_READ_LOCK = 16384;
  114. { Intern flag }
  115. REFRESH_FAST = 32768;
  116. { RESET (remove all queries) from query cache }
  117. REFRESH_QUERY_CACHE = 65536;
  118. { pack query cache }
  119. REFRESH_QUERY_CACHE_FREE = $20000;
  120. REFRESH_DES_KEY_FILE = $40000;
  121. { new more secure passwords }
  122. CLIENT_LONG_PASSWORD = 1;
  123. { Found instead of affected rows }
  124. CLIENT_FOUND_ROWS = 2;
  125. { Get all column flags }
  126. CLIENT_LONG_FLAG = 4;
  127. { One can specify db on connect }
  128. CLIENT_CONNECT_WITH_DB = 8;
  129. { Don't allow database.table.column }
  130. CLIENT_NO_SCHEMA = 16;
  131. { Can use compression protocol }
  132. CLIENT_COMPRESS = 32;
  133. { Odbc client }
  134. CLIENT_ODBC = 64;
  135. { Can use LOAD DATA LOCAL }
  136. CLIENT_LOCAL_FILES = 128;
  137. { Ignore spaces before '(' }
  138. CLIENT_IGNORE_SPACE = 256;
  139. { Support the mysql_change_user() }
  140. CLIENT_CHANGE_USER = 512;
  141. { This is an interactive client }
  142. CLIENT_INTERACTIVE = 1024;
  143. { Switch to SSL after handshake }
  144. CLIENT_SSL = 2048;
  145. { IGNORE sigpipes }
  146. CLIENT_IGNORE_SIGPIPE = 4096;
  147. { Client knows about transactions }
  148. CLIENT_TRANSACTIONS = 8192;
  149. { Transaction has started }
  150. SERVER_STATUS_IN_TRANS = 1;
  151. { Server in auto_commit mode }
  152. SERVER_STATUS_AUTOCOMMIT = 2;
  153. MYSQL_ERRMSG_SIZE = 200;
  154. { Timeout on read }
  155. NET_READ_TIMEOUT = 30;
  156. { Timeout on write }
  157. NET_WRITE_TIMEOUT = 60;
  158. {
  159. #define NET_WAIT_TIMEOUT (8 60 60)
  160. }
  161. { Wait for new query }
  162. {
  163. struct st_vio; // Only C
  164. typedef struct st_vio Vio;
  165. }
  166. { Default width for blob }
  167. MAX_BLOB_WIDTH = 8192;
  168. { For Perl DBI/dbd }
  169. {
  170. The following variable is set if we are doing several queries in one
  171. command ( as in LOAD TABLE ... FROM MASTER ),
  172. and do not want to confuse the client with OK at the wrong time
  173. }
  174. type
  175. Pst_net = ^st_net;
  176. st_net = record
  177. vio : PVio;
  178. buff : Pbyte;
  179. buff_end : Pbyte;
  180. write_pos : Pbyte;
  181. read_pos : Pbyte;
  182. fd : my_socket;
  183. max_packet : dword;
  184. fcntl : longint;
  185. last_errno : dword;
  186. timeout : dword;
  187. pkt_nr : dword;
  188. compress_pkt_nr : dword;
  189. last_error : array[0..(MYSQL_ERRMSG_SIZE)-1] of char;
  190. error : byte;
  191. return_errno : my_bool;
  192. compress : my_bool;
  193. remain_in_buf : dword;
  194. length : dword;
  195. buf_length : dword;
  196. where_b : dword;
  197. return_status : Pdword;
  198. reading_or_writing : byte;
  199. save_char : char;
  200. no_send_ok : my_bool;
  201. query_cache_query : gptr;
  202. end;
  203. NET = st_net;
  204. PNET = ^NET;
  205. { was #define dname def_expr }
  206. function packet_error : longint;
  207. { return type might be wrong }
  208. type
  209. enum_field_types = (FIELD_TYPE_DECIMAL,FIELD_TYPE_TINY,FIELD_TYPE_SHORT,
  210. FIELD_TYPE_LONG,FIELD_TYPE_FLOAT,FIELD_TYPE_DOUBLE,
  211. FIELD_TYPE_NULL,FIELD_TYPE_TIMESTAMP,
  212. FIELD_TYPE_LONGLONG,FIELD_TYPE_INT24,
  213. FIELD_TYPE_DATE,FIELD_TYPE_TIME,FIELD_TYPE_DATETIME,
  214. FIELD_TYPE_YEAR,FIELD_TYPE_NEWDATE,FIELD_TYPE_ENUM := 247,
  215. FIELD_TYPE_SET := 248,FIELD_TYPE_TINY_BLOB := 249,
  216. FIELD_TYPE_MEDIUM_BLOB := 250,FIELD_TYPE_LONG_BLOB := 251,
  217. FIELD_TYPE_BLOB := 252,FIELD_TYPE_VAR_STRING := 253,
  218. FIELD_TYPE_STRING := 254);
  219. { For compability }
  220. const
  221. FIELD_TYPE_CHAR = FIELD_TYPE_TINY;
  222. { For compability }
  223. FIELD_TYPE_INTERVAL = FIELD_TYPE_ENUM;
  224. {
  225. #define net_new_transaction(net) ((net)->pkt_nr=0)
  226. }
  227. var
  228. max_allowed_packet : dword;cvar;external;
  229. net_buffer_length : dword;cvar;external;
  230. function my_net_init(net:PNET; vio:PVio):longint;cdecl;external External_library name 'my_net_init';
  231. procedure net_end(net:PNET);cdecl;external External_library name 'net_end';
  232. procedure net_clear(net:PNET);cdecl;external External_library name 'net_clear';
  233. function net_flush(net:PNET):longint;cdecl;external External_library name 'net_flush';
  234. (* Const before type ignored *)
  235. function my_net_write(net:PNET; packet:Pchar; len:dword):longint;cdecl;external External_library name 'my_net_write';
  236. (* Const before type ignored *)
  237. function net_write_command(net:PNET; command:byte; packet:Pchar; len:dword):longint;cdecl;external External_library name 'net_write_command';
  238. (* Const before type ignored *)
  239. function net_real_write(net:PNET; packet:Pchar; len:dword):longint;cdecl;external External_library name 'net_real_write';
  240. function my_net_read(net:PNET):dword;cdecl;external External_library name 'my_net_read';
  241. { The following function is not meant for normal usage }
  242. {
  243. struct sockaddr;
  244. int my_connect(my_socket s, const struct sockaddr name, unsigned int namelen,
  245. unsigned int timeout);
  246. }
  247. type
  248. Prand_struct = ^rand_struct;
  249. rand_struct = record
  250. seed1 : dword;
  251. seed2 : dword;
  252. max_value : dword;
  253. max_value_dbl : double;
  254. end;
  255. { The following is for user defined functions }
  256. Item_result = (STRING_RESULT,REAL_RESULT,INT_RESULT
  257. );
  258. pitem_result = ^item_result;
  259. { Number of arguments }
  260. { Pointer to item_results }
  261. { Pointer to argument }
  262. { Length of string arguments }
  263. { Set to 1 for all maybe_null args }
  264. Pst_udf_args = ^st_udf_args;
  265. st_udf_args = record
  266. arg_count : dword;
  267. arg_type : PItem_result;
  268. args : ^Pchar;
  269. lengths : Pdword;
  270. maybe_null : Pchar;
  271. end;
  272. UDF_ARGS = st_udf_args;
  273. PUDF_ARGS = ^UDF_ARGS;
  274. { This holds information about the result }
  275. { 1 if function can return NULL }
  276. { for real functions }
  277. { For string functions }
  278. { free pointer for function data }
  279. { 0 if result is independent of arguments }
  280. Pst_udf_init = ^st_udf_init;
  281. st_udf_init = record
  282. maybe_null : my_bool;
  283. decimals : dword;
  284. max_length : dword;
  285. ptr : Pchar;
  286. const_item : my_bool;
  287. end;
  288. UDF_INIT = st_udf_init;
  289. PUDF_INIT = ^UDF_INIT;
  290. { Constants when using compression }
  291. { standard header size }
  292. const
  293. NET_HEADER_SIZE = 4;
  294. { compression header extra size }
  295. COMP_HEADER_SIZE = 3;
  296. { Prototypes to password functions }
  297. procedure randominit(_para1:Prand_struct; seed1:dword; seed2:dword);cdecl;external External_library name 'randominit';
  298. function rnd(_para1:Prand_struct):double;cdecl;external External_library name 'rnd';
  299. (* Const before type ignored *)
  300. procedure make_scrambled_password(_to:Pchar; password:Pchar);cdecl;external External_library name 'make_scrambled_password';
  301. (* Const before type ignored *)
  302. procedure get_salt_from_password(res:Pdword; password:Pchar);cdecl;external External_library name 'get_salt_from_password';
  303. procedure make_password_from_salt(_to:Pchar; hash_res:Pdword);cdecl;external External_library name 'make_password_from_salt';
  304. (* Const before type ignored *)
  305. (* Const before type ignored *)
  306. function scramble(_to:Pchar; message:Pchar; password:Pchar; old_ver:my_bool):Pchar;cdecl;external External_library name 'scramble';
  307. (* Const before type ignored *)
  308. (* Const before type ignored *)
  309. function check_scramble(_para1:Pchar; message:Pchar; salt:Pdword; old_ver:my_bool):my_bool;cdecl;external External_library name 'check_scramble';
  310. function get_tty_password(opt_message:Pchar):Pchar;cdecl;external External_library name 'get_tty_password';
  311. (* Const before type ignored *)
  312. procedure hash_password(result:Pdword; password:Pchar);cdecl;external External_library name 'hash_password';
  313. { Some other useful functions }
  314. procedure my_init;cdecl;external External_library name 'my_init';
  315. (* Const before type ignored *)
  316. (* Const before type ignored *)
  317. procedure load_defaults(conf_file:Pchar; groups:PPchar; argc:Plongint; argv:PPPchar);cdecl;external External_library name 'load_defaults';
  318. function my_thread_init:my_bool;cdecl;external External_library name 'my_thread_init';
  319. procedure my_thread_end;cdecl;external External_library name 'my_thread_end';
  320. { For net_store_length }
  321. { was #define dname def_expr }
  322. function NULL_LENGTH : dword;
  323. implementation
  324. { was #define dname def_expr }
  325. function packet_error : longint;
  326. { return type might be wrong }
  327. begin
  328. packet_error:= not (dword(0));
  329. end;
  330. { was #define dname def_expr }
  331. function NULL_LENGTH : dword;
  332. begin
  333. NULL_LENGTH:=dword( not (0));
  334. end;
  335. end.