mysql.inc 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719
  1. {
  2. This file is created by H2Pas, and thereafter heavily edited to make it
  3. readable and dynamically loadable.
  4. The goal was not to be complete, but to make it work and maintainable.
  5. The mysql_com.h, mysql.h and some other files are merged together into this
  6. one file.
  7. Automatically converted by H2Pas 1.0.0 from mysql_com.h / mysql.h
  8. The following command line parameters were used:
  9. -p
  10. -D
  11. -l
  12. mysqlclient
  13. mysql_com.h / mysql.h
  14. }
  15. {$MODE objfpc}
  16. {$MACRO on}
  17. interface
  18. uses
  19. {$IFDEF LinkDynamically}
  20. Dynlibs, sysutils,
  21. {$ENDIF}
  22. ctypes;
  23. {$IFDEF Unix}
  24. {$DEFINE extdecl:=cdecl}
  25. const
  26. mysqllib = 'libmysqlclient.so';
  27. {$IF DEFINED(mysql50)}
  28. mysqlvlib = 'libmysqlclient.so.15';
  29. {$ELSEIF DEFINED(mysql41)}
  30. mysqlvlib = 'libmysqlclient.so.14';
  31. {$ELSE}
  32. mysqlvlib = 'libmysqlclient.so.12';
  33. {$ENDIF}
  34. {$ENDIF}
  35. {$IFDEF Windows}
  36. {$DEFINE extdecl:=stdcall}
  37. const
  38. mysqllib = 'libmysql.dll';
  39. mysqlvlib = 'libmysql.dll';
  40. {$ENDIF}
  41. {$IFDEF mysql50}
  42. {$DEFINE mysql41}
  43. {$ENDIF mysql50}
  44. {$PACKRECORDS C}
  45. { Copyright (C) 2000-2003 MySQL AB
  46. This program is free software; you can redistribute it and/or modify
  47. it under the terms of the GNU General Public License as published by
  48. the Free Software Foundation; either version 2 of the License, or
  49. (at your option) any later version.
  50. This program is distributed in the hope that it will be useful,
  51. but WITHOUT ANY WARRANTY; without even the implied warranty of
  52. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  53. GNU General Public License for more details.
  54. You should have received a copy of the GNU General Public License
  55. along with this program; if not, write to the Free Software
  56. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA }
  57. type
  58. my_bool = cchar;
  59. Pmy_bool = ^my_bool;
  60. PVIO = Pointer;
  61. Pgptr = ^gptr;
  62. gptr = ^cchar;
  63. Pmy_socket = ^my_socket;
  64. my_socket = cint;
  65. pppchar = ^ppchar;
  66. PPByte = ^PByte;
  67. { ------------ Start of declaration in "mysql_com.h" --------------------- }
  68. {
  69. ** Common definition between mysql server & client
  70. }
  71. { Field/table name length }
  72. const
  73. NAME_LEN = 64;
  74. HOSTNAME_LENGTH = 60;
  75. USERNAME_LENGTH = 16;
  76. SERVER_VERSION_LENGTH = 60;
  77. SQLSTATE_LENGTH = 5;
  78. LOCAL_HOST = 'localhost';
  79. LOCAL_HOST_NAMEDPIPE = '.';
  80. const
  81. MYSQL_NAMEDPIPE = 'MySQL';
  82. MYSQL_SERVICENAME = 'MySQL';
  83. type
  84. enum_server_command = (COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
  85. COM_FIELD_LIST,COM_CREATE_DB,COM_DROP_DB,
  86. COM_REFRESH,COM_SHUTDOWN,COM_STATISTICS,
  87. COM_PROCESS_INFO,COM_CONNECT,COM_PROCESS_KILL,
  88. COM_DEBUG,COM_PING,COM_TIME,COM_DELAYED_INSERT,
  89. COM_CHANGE_USER,COM_BINLOG_DUMP,COM_TABLE_DUMP,
  90. COM_CONNECT_OUT,COM_REGISTER_SLAVE,
  91. {$IFDEF mysql50}
  92. COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE,
  93. COM_STMT_RESET, COM_SET_OPTION, COM_STMT_FETCH,
  94. {$ELSE}
  95. {$IFDEF mysql41}
  96. COM_PREPARE,COM_EXECUTE,COM_LONG_DATA,COM_CLOSE_STMT,
  97. COM_RESET_STMT,COM_SET_OPTION,
  98. {$ENDIF}
  99. {$ENDIF}
  100. COM_END
  101. );
  102. {
  103. Length of random string sent by server on handshake; this is also length of
  104. obfuscated password, recieved from client
  105. }
  106. const
  107. SCRAMBLE_LENGTH = 20;
  108. SCRAMBLE_LENGTH_323 = 8;
  109. { length of password stored in the db: new passwords are preceeded with '*' }
  110. SCRAMBLED_PASSWORD_CHAR_LENGTH = SCRAMBLE_LENGTH*2+1;
  111. SCRAMBLED_PASSWORD_CHAR_LENGTH_323 = SCRAMBLE_LENGTH_323*2;
  112. NOT_NULL_FLAG = 1; // Field can't be NULL
  113. PRI_KEY_FLAG = 2; // Field is part of a primary key
  114. UNIQUE_KEY_FLAG = 4; // Field is part of a unique key
  115. MULTIPLE_KEY_FLAG = 8; // Field is part of a key
  116. BLOB_FLAG = 16; // Field is a blob
  117. UNSIGNED_FLAG = 32; // Field is unsigned
  118. ZEROFILL_FLAG = 64; // Field is zerofill
  119. BINARY_FLAG = 128; // Field is binary
  120. { The following are only sent to new clients }
  121. ENUM_FLAG = 256; // field is an enum
  122. AUTO_INCREMENT_FLAG = 512; // field is a autoincrement field
  123. TIMESTAMP_FLAG = 1024; // Field is a timestamp
  124. SET_FLAG = 2048; // field is a set
  125. {$IFDEF mysql50}
  126. NO_DEFAULT_VALUE_FLAG=4096; // Field doesn't have default value
  127. {$ENDIF}
  128. NUM_FLAG = 32768; // Field is num (for clients)
  129. PART_KEY_FLAG = 16384; // Intern; Part of some key
  130. GROUP_FLAG = 32768; // Intern: Group field
  131. UNIQUE_FLAG = 65536; // Intern: Used by sql_yacc
  132. BINCMP_FLAG = 131072; // Intern: Used by sql_yacc
  133. REFRESH_GRANT = 1; // Refresh grant tables
  134. REFRESH_LOG = 2; // Start on new log file
  135. REFRESH_TABLES = 4; // close all tables
  136. REFRESH_HOSTS = 8; // Flush host cache
  137. REFRESH_STATUS = 16; // Flush status variables
  138. REFRESH_THREADS = 32; // Flush thread cache
  139. REFRESH_SLAVE = 64; // Reset master info and restart slave thread
  140. REFRESH_MASTER = 128; // Remove all bin logs in the index and truncate the index
  141. { The following can't be set with mysql_refresh() }
  142. REFRESH_READ_LOCK = 16384; // Lock tables for read
  143. REFRESH_FAST = 32768; // Intern flag
  144. REFRESH_QUERY_CACHE = 65536; // RESET (remove all queries) from query cache
  145. REFRESH_QUERY_CACHE_FREE = $20000; // pack query cache
  146. REFRESH_DES_KEY_FILE = $40000;
  147. REFRESH_USER_RESOURCES = $80000;
  148. CLIENT_LONG_PASSWORD = 1; // new more secure passwords
  149. CLIENT_FOUND_ROWS = 2; // Found instead of affected rows
  150. CLIENT_LONG_FLAG = 4; // Get all column flags
  151. CLIENT_CONNECT_WITH_DB = 8; // One can specify db on connect
  152. CLIENT_NO_SCHEMA = 16; // Don't allow database.table.column
  153. CLIENT_COMPRESS = 32; // Can use compression protocol
  154. CLIENT_ODBC = 64; // Odbc client
  155. CLIENT_LOCAL_FILES = 128; // Can use LOAD DATA LOCAL
  156. CLIENT_IGNORE_SPACE = 256; // Ignore spaces before '('
  157. CLIENT_PROTOCOL_41 = 512; // New 4.1 protocol
  158. CLIENT_INTERACTIVE = 1024; // This is an interactive client
  159. CLIENT_SSL = 2048; // Switch to SSL after handshake
  160. CLIENT_IGNORE_SIGPIPE = 4096; // IGNORE sigpipes
  161. CLIENT_TRANSACTIONS = 8192; // Client knows about transactions
  162. CLIENT_RESERVED = 16384; // Old flag for 4.1 protocol
  163. CLIENT_SECURE_CONNECTION = 32768; // New 4.1 authentication
  164. CLIENT_MULTI_STATEMENTS = 65536; // Enable/disable multi-stmt support
  165. CLIENT_MULTI_RESULTS = 131072; // Enable/disable multi-results
  166. CLIENT_REMEMBER_OPTIONS : cardinal = 1 shl 31;
  167. SERVER_STATUS_IN_TRANS = 1; // Transaction has started
  168. SERVER_STATUS_AUTOCOMMIT = 2; // Server in auto_commit mode
  169. SERVER_STATUS_MORE_RESULTS = 4; // More results on server
  170. SERVER_MORE_RESULTS_EXISTS = 8; // Multi query - next query exists
  171. SERVER_QUERY_NO_GOOD_INDEX_USED = 16;
  172. SERVER_QUERY_NO_INDEX_USED = 32;
  173. {$IFDEF mysql50}
  174. { The server was able to fulfill the clients request and opened a
  175. read-only non-scrollable cursor for a query. This flag comes
  176. in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands. }
  177. SERVER_STATUS_CURSOR_EXISTS = 64;
  178. { This flag is sent when a read-only cursor is exhausted, in reply to
  179. COM_STMT_FETCH command. }
  180. SERVER_STATUS_LAST_ROW_SENT = 128;
  181. {$ENDIF}
  182. SERVER_STATUS_DB_DROPPED = 256; // A database was dropped
  183. {$IFDEF mysql50}
  184. SERVER_STATUS_NO_BACKSLASH_ESCAPES = 512;
  185. {$ENDIF}
  186. {$IFDEF mysql41}
  187. MYSQL_ERRMSG_SIZE = 512;
  188. {$ELSE}
  189. MYSQL_ERRMSG_SIZE = 200;
  190. {$ENDIF}
  191. NET_READ_TIMEOUT = 30; // Timeout on read
  192. NET_WRITE_TIMEOUT = 60; // Timeout on write
  193. NET_WAIT_TIMEOUT = 8*60*60; // Wait for new query
  194. {$IFDEF mysql50}
  195. ONLY_KILL_QUERY = 1;
  196. {$ENDIF}
  197. const
  198. MAX_TINYINT_WIDTH = 3; // Max width for a TINY w.o. sign
  199. MAX_SMALLINT_WIDTH = 5; // Max width for a SHORT w.o. sign
  200. MAX_MEDIUMINT_WIDTH = 8; // Max width for a INT24 w.o. sign
  201. MAX_INT_WIDTH = 10; // Max width for a LONG w.o. sign
  202. MAX_BIGINT_WIDTH = 20; // Max width for a LONGLONG
  203. MAX_CHAR_WIDTH = 255; // Max length for a CHAR colum
  204. MAX_BLOB_WIDTH = 8192; // Default width for blob
  205. type
  206. Pst_net = ^st_net;
  207. st_net = record
  208. { $if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY)}
  209. vio : PVio;
  210. buff : pcuchar;
  211. buff_end : pcuchar;
  212. write_pos : pcuchar;
  213. read_pos : pcuchar;
  214. fd : my_socket; // For Perl DBI/dbd
  215. max_packet : culong;
  216. max_packet_size : culong;
  217. {$IFNDEF mysql41}
  218. last_errno : cuint;
  219. {$ENDIF}
  220. pkt_nr : cuint;
  221. compress_pkt_nr : cuint;
  222. write_timeout : cuint;
  223. read_timeout : cuint;
  224. retry_count : cuint;
  225. fcntl : cint;
  226. {$IFNDEF mysql41}
  227. last_error : array[0..(MYSQL_ERRMSG_SIZE)-1] of char;
  228. error : cuchar;
  229. return_errno : my_bool;
  230. {$ENDIF}
  231. compress : my_bool;
  232. { The following variable is set if we are doing several queries in one
  233. command ( as in LOAD TABLE ... FROM MASTER ),
  234. and do not want to confuse the client with OK at the wrong time }
  235. remain_in_buf : culong;
  236. length : culong;
  237. buf_length : culong;
  238. where_b : culong;
  239. return_status : pcint;
  240. reading_or_writing : cuchar;
  241. save_char : cchar;
  242. no_send_ok : my_bool; // For SPs and other things that do multiple stmts
  243. {$IFDEF mysql50}
  244. no_send_eof : my_bool; // For SPs' first version read-only cursors
  245. no_send_error : my_bool; // Set if OK packet is already sent, and
  246. // we do not need to send error messages
  247. {$ENDIF}
  248. { Pointer to query object in query cache, do not equal NULL (0) for
  249. queries in cache that have not stored its results yet }
  250. { $endif}
  251. {$IFDEF mysql41}
  252. last_error : array[0..(MYSQL_ERRMSG_SIZE)-1] of char;
  253. sqlstate : array[0..(SQLSTATE_LENGTH+1)-1] of char;
  254. last_errno : cuint;
  255. error : cuchar;
  256. {$ENDIF}
  257. query_cache_query : gptr;
  258. {$IFDEF mysql41}
  259. report_error : my_bool; // We should report error (we have unreported error)
  260. return_errno : my_bool;
  261. {$ENDIF}
  262. end;
  263. NET = st_net;
  264. PNET = ^NET;
  265. const
  266. packet_error : culong = culong(not(0));
  267. type
  268. enum_field_types = (MYSQL_TYPE_DECIMAL,MYSQL_TYPE_TINY,
  269. MYSQL_TYPE_SHORT,MYSQL_TYPE_LONG,MYSQL_TYPE_FLOAT,
  270. MYSQL_TYPE_DOUBLE,MYSQL_TYPE_NULL,
  271. MYSQL_TYPE_TIMESTAMP,MYSQL_TYPE_LONGLONG,
  272. MYSQL_TYPE_INT24,MYSQL_TYPE_DATE,MYSQL_TYPE_TIME,
  273. MYSQL_TYPE_DATETIME,MYSQL_TYPE_YEAR,
  274. MYSQL_TYPE_NEWDATE,
  275. {$IFDEF mysql50}
  276. MYSQL_TYPE_VARCHAR, MYSQL_TYPE_BIT, MYSQL_TYPE_NEWDECIMAL=246,
  277. {$ENDIF}
  278. MYSQL_TYPE_ENUM := 247,
  279. MYSQL_TYPE_SET := 248,MYSQL_TYPE_TINY_BLOB := 249,
  280. MYSQL_TYPE_MEDIUM_BLOB := 250,MYSQL_TYPE_LONG_BLOB := 251,
  281. MYSQL_TYPE_BLOB := 252,MYSQL_TYPE_VAR_STRING := 253,
  282. MYSQL_TYPE_STRING := 254,MYSQL_TYPE_GEOMETRY := 255
  283. );
  284. { For backward compatibility }
  285. const
  286. CLIENT_MULTI_QUERIES = CLIENT_MULTI_STATEMENTS;
  287. FIELD_TYPE_DECIMAL = MYSQL_TYPE_DECIMAL;
  288. {$IFDEF mysql50}
  289. FIELD_TYPE_NEWDECIMAL = MYSQL_TYPE_NEWDECIMAL;
  290. {$ENDIF}
  291. FIELD_TYPE_TINY = MYSQL_TYPE_TINY;
  292. FIELD_TYPE_SHORT = MYSQL_TYPE_SHORT;
  293. FIELD_TYPE_LONG = MYSQL_TYPE_LONG;
  294. FIELD_TYPE_FLOAT = MYSQL_TYPE_FLOAT;
  295. FIELD_TYPE_DOUBLE = MYSQL_TYPE_DOUBLE;
  296. FIELD_TYPE_NULL = MYSQL_TYPE_NULL;
  297. FIELD_TYPE_TIMESTAMP = MYSQL_TYPE_TIMESTAMP;
  298. FIELD_TYPE_LONGLONG = MYSQL_TYPE_LONGLONG;
  299. FIELD_TYPE_INT24 = MYSQL_TYPE_INT24;
  300. FIELD_TYPE_DATE = MYSQL_TYPE_DATE;
  301. FIELD_TYPE_TIME = MYSQL_TYPE_TIME;
  302. FIELD_TYPE_DATETIME = MYSQL_TYPE_DATETIME;
  303. FIELD_TYPE_YEAR = MYSQL_TYPE_YEAR;
  304. FIELD_TYPE_NEWDATE = MYSQL_TYPE_NEWDATE;
  305. FIELD_TYPE_ENUM = MYSQL_TYPE_ENUM;
  306. FIELD_TYPE_SET = MYSQL_TYPE_SET;
  307. FIELD_TYPE_TINY_BLOB = MYSQL_TYPE_TINY_BLOB;
  308. FIELD_TYPE_MEDIUM_BLOB = MYSQL_TYPE_MEDIUM_BLOB;
  309. FIELD_TYPE_LONG_BLOB = MYSQL_TYPE_LONG_BLOB;
  310. FIELD_TYPE_BLOB = MYSQL_TYPE_BLOB;
  311. FIELD_TYPE_VAR_STRING = MYSQL_TYPE_VAR_STRING;
  312. FIELD_TYPE_STRING = MYSQL_TYPE_STRING;
  313. FIELD_TYPE_CHAR = MYSQL_TYPE_TINY;
  314. FIELD_TYPE_INTERVAL = MYSQL_TYPE_ENUM;
  315. FIELD_TYPE_GEOMETRY = MYSQL_TYPE_GEOMETRY;
  316. {$IFDEF mysql50}
  317. FIELD_TYPE_BIT = MYSQL_TYPE_BIT;
  318. {$ENDIF}
  319. { Shutdown/kill enums and constants }
  320. { Bits for THD::killable. }
  321. MYSQL_SHUTDOWN_KILLABLE_CONNECT : cuchar = 1 shl 0;
  322. MYSQL_SHUTDOWN_KILLABLE_TRANS : cuchar = 1 shl 1;
  323. MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE : cuchar = 1 shl 2;
  324. MYSQL_SHUTDOWN_KILLABLE_UPDATE : cuchar = 1 shl 3;
  325. { We want levels to be in growing order of hardness (because we use number
  326. comparisons). Note that DEFAULT does not respect the growing property, but
  327. it's ok. }
  328. type
  329. mysql_enum_shutdown_level = (SHUTDOWN_DEFAULT := 0,
  330. SHUTDOWN_WAIT_CONNECTIONS := 1, //MYSQL_SHUTDOWN_KILLABLE_CONNECT, // wait for existing connections to finish
  331. SHUTDOWN_WAIT_TRANSACTIONS := 2, //MYSQL_SHUTDOWN_KILLABLE_TRANS, // wait for existing trans to finish
  332. SHUTDOWN_WAIT_UPDATES := 8, //MYSQL_SHUTDOWN_KILLABLE_UPDATE, // wait for existing updates to finish (=> no partial MyISAM update)
  333. SHUTDOWN_WAIT_ALL_BUFFERS := 16, //MYSQL_SHUTDOWN_KILLABLE_UPDATE shl 1,// flush InnoDB buffers and other storage engines' buffers
  334. SHUTDOWN_WAIT_CRITICAL_BUFFERS := 17, //(MYSQL_SHUTDOWN_KILLABLE_UPDATE shl 1)+1, // don't flush InnoDB buffers, flush other storage engines' buffers
  335. { Now the 2 levels of the KILL command }
  336. { $if MYSQL_VERSION_ID >= 50000}
  337. KILL_QUERY := 254,
  338. { $endif}
  339. KILL_CONNECTION := 255
  340. );
  341. {$IFDEF mysql50}
  342. enum_cursor_type = (CURSOR_TYPE_NO_CURSOR := 0,CURSOR_TYPE_READ_ONLY := 1,
  343. CURSOR_TYPE_FOR_UPDATE := 2,CURSOR_TYPE_SCROLLABLE := 4
  344. );
  345. {$ENDIF}
  346. { options for mysql_set_option }
  347. enum_mysql_set_option = (MYSQL_OPTION_MULTI_STATEMENTS_ON,
  348. MYSQL_OPTION_MULTI_STATEMENTS_OFF
  349. );
  350. function net_new_transaction(net : st_net) : st_net;
  351. {$IFNDEF LinkDynamically}
  352. function my_net_init(net:PNET; vio:PVio):my_bool;cdecl;external mysqllib name 'my_net_init';
  353. procedure my_net_local_init(net:PNET);cdecl;external mysqllib name 'my_net_local_init';
  354. procedure net_end(net:PNET);cdecl;external mysqllib name 'net_end';
  355. procedure net_clear(net:PNET);cdecl;external mysqllib name 'net_clear';
  356. function net_realloc(net:PNET; length:culong):my_bool;cdecl;external mysqllib name 'net_realloc';
  357. function net_flush(net:PNET):my_bool;cdecl;external mysqllib name 'net_flush';
  358. function my_net_write(net:PNET; packet:Pchar; len:culong):my_bool;cdecl;external mysqllib name 'my_net_write';
  359. function net_write_command(net:PNET; command:cuchar; header:Pchar; head_len:culong; packet:Pchar;
  360. len:culong):my_bool;cdecl;external mysqllib name 'net_write_command';
  361. function net_real_write(net:PNET; packet:Pchar; len:culong):cint;cdecl;external mysqllib name 'net_real_write';
  362. function my_net_read(net:PNET):culong;cdecl;external mysqllib name 'my_net_read';
  363. {$ENDIF}
  364. { The following function is not meant for normal usage
  365. Currently it's used internally by manager.c }
  366. type
  367. Psockaddr = ^sockaddr;
  368. sockaddr = record
  369. // undefined structure
  370. end;
  371. {$IFNDEF LinkDynamically}
  372. function my_connect(s:my_socket; name:Psockaddr; namelen:cuint; timeout:cuint):cint;cdecl;external mysqllib name 'my_connect';
  373. {$ENDIF}
  374. type
  375. Prand_struct = ^rand_struct;
  376. rand_struct = record
  377. seed1 : culong;
  378. seed2 : culong;
  379. max_value : culong;
  380. max_value_dbl : cdouble;
  381. end;
  382. { The following is for user defined functions }
  383. {$IFDEF mysql50}
  384. Item_result = (STRING_RESULT,REAL_RESULT,INT_RESULT,
  385. ROW_RESULT);
  386. {$ELSE}
  387. Item_result = (STRING_RESULT := 0,REAL_RESULT,INT_RESULT,
  388. ROW_RESULT,DECIMAL_RESULT);
  389. {$ENDIF}
  390. PItem_result = ^Item_result;
  391. Pst_udf_args = ^st_udf_args;
  392. st_udf_args = record
  393. arg_count : cuint; // Number of arguments
  394. arg_type : PItem_result; // Pointer to item_results
  395. args : PPChar; // Pointer to item_results
  396. lengths : pculong; // Length of string arguments
  397. maybe_null : Pchar; // Length of string arguments
  398. {$IFDEF mysql50}
  399. attributes : PPChar; // Pointer to attribute name
  400. attribute_lengths : pculong; // Length of attribute arguments
  401. {$ENDIF}
  402. end;
  403. UDF_ARGS = st_udf_args;
  404. PUDF_ARGS = ^UDF_ARGS;
  405. { This holds information about the result }
  406. Pst_udf_init = ^st_udf_init;
  407. st_udf_init = record
  408. maybe_null : my_bool; // 1 if function can return NULL
  409. decimals : cuint; // for real functions
  410. max_length : culong; // For string functions
  411. ptr : Pchar; // free pointer for function data
  412. const_item : my_bool; // free pointer for function data
  413. end;
  414. UDF_INIT = st_udf_init;
  415. PUDF_INIT = ^UDF_INIT;
  416. { Constants when using compression }
  417. const
  418. NET_HEADER_SIZE = 4; // standard header size
  419. COMP_HEADER_SIZE = 3; // compression header extra size
  420. { Prototypes to password functions }
  421. { These functions are used for authentication by client and server and
  422. implemented in sql/password.c }
  423. {$IFNDEF LinkDynamically}
  424. procedure randominit(_para1:Prand_struct; seed1:culong; seed2:culong);cdecl;external mysqllib name 'randominit';
  425. function my_rnd(_para1:Prand_struct):cdouble;cdecl;external mysqllib name 'my_rnd';
  426. procedure create_random_string(fto:Pchar; length:cuint; rand_st:Prand_struct);cdecl;external mysqllib name 'create_random_string';
  427. procedure hash_password(fto:culong; password:Pchar; password_len:cuint);cdecl;external mysqllib name 'hash_password';
  428. procedure make_scrambled_password_323(fto:Pchar; password:Pchar);cdecl;external mysqllib name 'make_scrambled_password_323';
  429. procedure scramble_323(fto:Pchar; message:Pchar; password:Pchar);cdecl;external mysqllib name 'scramble_323';
  430. function check_scramble_323(_para1:Pchar; message:Pchar; salt:culong):my_bool;cdecl;external mysqllib name 'check_scramble_323';
  431. procedure get_salt_from_password_323(res:pculong; password:Pchar);cdecl;external mysqllib name 'get_salt_from_password_323';
  432. procedure make_password_from_salt_323(fto:Pchar; salt:pculong);cdecl;external mysqllib name 'make_password_from_salt_323';
  433. {$IFDEF mysql50}
  434. function octet2hex(fto:Pchar; str:Pchar; len:cuint):pchar;cdecl;external mysqllib name 'octet2hex';
  435. {$ENDIF}
  436. procedure make_scrambled_password(fto:Pchar; password:Pchar);cdecl;external mysqllib name 'make_scrambled_password';
  437. procedure scramble(fto:Pchar; message:Pchar; password:Pchar);cdecl;external mysqllib name 'scramble';
  438. function check_scramble(reply:Pchar; message:Pchar; hash_stage2:Pbyte):my_bool;cdecl;external mysqllib name 'check_scramble';
  439. procedure get_salt_from_password(res:Pbyte; password:Pchar);cdecl;external mysqllib name 'get_salt_from_password';
  440. procedure make_password_from_salt(fto:Pchar; hash_stage2:Pbyte);cdecl;external mysqllib name 'make_password_from_salt';
  441. { end of password.c }
  442. function get_tty_password(opt_message:Pchar):Pchar;cdecl;external mysqllib name 'get_tty_password';
  443. function mysql_errno_to_sqlstate(mysql_errno:cuint):Pchar;cdecl;external mysqllib name 'mysql_errno_to_sqlstate';
  444. { Some other useful functions }
  445. {$IFDEF mysql50}
  446. function modify_defaults_file(file_location:Pchar; option:Pchar; option_value:Pchar; section_name:Pchar; remove_option:cint):cint;cdecl;external mysqllib name 'load_defaults';
  447. {$ENDIF}
  448. function load_defaults(conf_file:Pchar; groups:PPchar; argc:pcint; argv:PPPchar):cint;cdecl;external mysqllib name 'load_defaults';
  449. function my_init:my_bool;cdecl;external mysqllib name 'my_init';
  450. function my_thread_init:my_bool;cdecl;external mysqllib name 'my_thread_init';
  451. procedure my_thread_end;cdecl;external mysqllib name 'my_thread_end';
  452. {$ELSE}
  453. var
  454. my_init : function :my_bool;cdecl;
  455. my_thread_init : function :my_bool;cdecl;
  456. my_thread_end : procedure ;cdecl;
  457. {$ENDIF}
  458. {$ifdef _global_h}
  459. {$IFNDEF LinkDynamically}
  460. function net_field_length(packet:PPuchar):culong;extdecl;external mysqllib name 'net_field_length_ll';
  461. function net_field_length_ll(packet:PPuchar):my_ulonglong;cdecl;external mysqllib name 'net_field_length_ll';
  462. function net_store_length(pkg:Pchar; length:ulonglong):Pchar;cdecl;external mysqllib name 'net_store_length';
  463. {$ENDIF}
  464. {$endif}
  465. const
  466. NULL_LENGTH : culong = culong(not(0)); // For net_store_length
  467. const
  468. MYSQL_STMT_HEADER = 4;
  469. MYSQL_LONG_DATA_HEADER = 6;
  470. { ------------ Stop of declaration in "mysql_com.h" ----------------------- }
  471. { $include "mysql_time.h"}
  472. { $include "mysql_version.h"}
  473. { $include "typelib.h"}
  474. { $include "my_list.h" /* for LISTs used in 'MYSQL' and 'MYSQL_STMT' */}
  475. {$IFNDEF LinkDynamically}
  476. var
  477. mysql_port : cuint;cvar;external;
  478. mysql_unix_port : Pchar;cvar;external;
  479. {$ENDIF}
  480. const
  481. CLIENT_NET_READ_TIMEOUT = 365*24*3600; // Timeout on read
  482. CLIENT_NET_WRITE_TIMEOUT = 365*24*3600; // Timeout on write
  483. {$ifdef NETWARE}
  484. (** unsupported pragma#pragma pack(push, 8) /* 8 byte alignment */*)
  485. {$endif}
  486. type
  487. Pst_mysql_field = ^st_mysql_field;
  488. st_mysql_field = record
  489. name : Pchar; // Name of column
  490. {$IFDEF mysql41}
  491. org_name : Pchar; // Original column name, if an alias
  492. {$ENDIF}
  493. table : Pchar; // Table of column if column was a field
  494. org_table : Pchar; // Org table name, if table was an alias
  495. db : Pchar; // Database for table
  496. {$IFDEF mysql41}
  497. catalog : Pchar; // Catalog for table
  498. {$ENDIF}
  499. def : Pchar; // Default value (set by mysql_list_fields)
  500. length : culong; // Width of column (create length)
  501. max_length : culong; // Max width for selected set
  502. {$IFDEF mysql41}
  503. name_length : cuint;
  504. org_name_length : cuint;
  505. table_length : cuint;
  506. org_table_length : cuint;
  507. db_length : cuint;
  508. catalog_length : cuint;
  509. def_length : cuint;
  510. {$ENDIF}
  511. flags : cuint; // Div flags
  512. decimals : cuint; // Number of decimals in field
  513. {$IFDEF mysql41}
  514. charsetnr : cuint; // Character set
  515. {$ENDIF}
  516. ftype : enum_field_types; // Type of field. See mysql_com.h for types
  517. end;
  518. MYSQL_FIELD = st_mysql_field;
  519. PMYSQL_FIELD = ^MYSQL_FIELD;
  520. PMYSQL_ROW = ^MYSQL_ROW; // return data as array of strings
  521. MYSQL_ROW = ppchar;
  522. PMYSQL_FIELD_OFFSET = ^MYSQL_FIELD_OFFSET; // offset to current field
  523. MYSQL_FIELD_OFFSET = cuint;
  524. function IS_PRI_KEY(n : longint) : boolean;
  525. function IS_NOT_NULL(n : longint) : boolean;
  526. function IS_BLOB(n : longint) : boolean;
  527. function IS_NUM(t : enum_field_types) : boolean;
  528. function INTERNAL_NUM_FIELD(f : Pst_mysql_field) : boolean;
  529. function IS_NUM_FIELD(f : Pst_mysql_field) : boolean;
  530. type
  531. {$if defined(NO_CLIENT_LONG_LONG)}
  532. my_ulonglong = culong;
  533. {$elseif defined(mswindows)}
  534. my_ulonglong = cint64;
  535. {$else}
  536. my_ulonglong = culonglong;
  537. {$endif}
  538. Pmy_ulonglong = ^my_ulonglong;
  539. const
  540. MYSQL_COUNT_ERROR = not (my_ulonglong(0));
  541. type
  542. Pst_mysql_rows = ^st_mysql_rows;
  543. st_mysql_rows = record
  544. next : Pst_mysql_rows; // list of rows
  545. data : MYSQL_ROW;
  546. {$IFDEF mysql41}
  547. length : culong;
  548. {$ENDIF}
  549. end;
  550. MYSQL_ROWS = st_mysql_rows;
  551. PMYSQL_ROWS = ^MYSQL_ROWS;
  552. PMYSQL_ROW_OFFSET = ^MYSQL_ROW_OFFSET; // offset to current row
  553. MYSQL_ROW_OFFSET = MYSQL_ROWS;
  554. { ------------ Start of declaration in "my_alloc.h" -------------------- }
  555. { $include "my_alloc.h"}
  556. const
  557. ALLOC_MAX_BLOCK_TO_DROP = 4096;
  558. ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP = 10;
  559. { struct for once_alloc (block) }
  560. type
  561. Pst_used_mem = ^st_used_mem;
  562. st_used_mem = record
  563. next : Pst_used_mem; // Next block in use
  564. left : cuint; // memory left in block
  565. size : cuint; // size of block
  566. end;
  567. USED_MEM = st_used_mem;
  568. PUSED_MEM = ^USED_MEM;
  569. Pst_mem_root = ^st_mem_root;
  570. st_mem_root = record
  571. free : PUSED_MEM; // blocks with free memory in it
  572. used : PUSED_MEM; // blocks almost without free memory
  573. pre_alloc : PUSED_MEM; // preallocated block
  574. min_malloc : cuint; // if block have less memory it will be put in 'used' list
  575. block_size : cuint; // initial block size
  576. block_num : cuint; // allocated blocks counter
  577. { first free block in queue test counter (if it exceed
  578. MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list) }
  579. first_block_usage : cuint;
  580. error_handler : procedure ;cdecl;
  581. end;
  582. MEM_ROOT = st_mem_root;
  583. PMEM_ROOT = ^MEM_ROOT;
  584. { ------------ Stop of declaration in "my_alloc.h" ---------------------- }
  585. type
  586. Pst_mysql_data = ^st_mysql_data;
  587. st_mysql_data = record
  588. rows : my_ulonglong;
  589. fields : cuint;
  590. data : PMYSQL_ROWS;
  591. alloc : MEM_ROOT;
  592. { $if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY)}
  593. {$IFDEF mysql41}
  594. prev_ptr : ^PMYSQL_ROWS;
  595. {$ENDIF}
  596. { $endif}
  597. end;
  598. MYSQL_DATA = st_mysql_data;
  599. PMYSQL_DATA = ^MYSQL_DATA;
  600. mysql_option = (MYSQL_OPT_CONNECT_TIMEOUT,MYSQL_OPT_COMPRESS,
  601. MYSQL_OPT_NAMED_PIPE,MYSQL_INIT_COMMAND,
  602. MYSQL_READ_DEFAULT_FILE,MYSQL_READ_DEFAULT_GROUP,
  603. MYSQL_SET_CHARSET_DIR,MYSQL_SET_CHARSET_NAME,
  604. MYSQL_OPT_LOCAL_INFILE,MYSQL_OPT_PROTOCOL,
  605. MYSQL_SHARED_MEMORY_BASE_NAME,MYSQL_OPT_READ_TIMEOUT,
  606. MYSQL_OPT_WRITE_TIMEOUT,MYSQL_OPT_USE_RESULT,
  607. MYSQL_OPT_USE_REMOTE_CONNECTION,MYSQL_OPT_USE_EMBEDDED_CONNECTION,
  608. MYSQL_OPT_GUESS_CONNECTION,MYSQL_SET_CLIENT_IP,
  609. MYSQL_SECURE_AUTH
  610. {$IFDEF MYSQL50}
  611. ,MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT
  612. {$ENDIF}
  613. );
  614. const
  615. MAX_MYSQL_MANAGER_ERR = 256;
  616. MAX_MYSQL_MANAGER_MSG = 256;
  617. MANAGER_OK = 200;
  618. MANAGER_INFO = 250;
  619. MANAGER_ACCESS = 401;
  620. MANAGER_CLIENT_ERR = 450;
  621. MANAGER_INTERNAL_ERR = 500;
  622. type
  623. st_dynamic_array = record
  624. buffer : ^char;
  625. elements : cuint;
  626. max_element : cuint;
  627. alloc_increment : cuint;
  628. size_of_element : cuint;
  629. end;
  630. DYNAMIC_ARRAY = st_dynamic_array;
  631. Pst_dynamic_array = ^st_dynamic_array;
  632. Pst_mysql_options = ^st_mysql_options;
  633. st_mysql_options = record
  634. connect_timeout : cuint;
  635. {$IFNDEF mysql41}
  636. client_flag : cuint;
  637. port : cuint;
  638. {$ELSE}
  639. read_timeout : cuint;
  640. write_timeout : cuint;
  641. {$ENDIF}
  642. {$IFDEF mysql41}
  643. port : cuint;
  644. protocol : cuint;
  645. client_flag : culong;
  646. {$ENDIF}
  647. host : Pchar;
  648. {$IFNDEF mysql41}
  649. init_command: Pchar;
  650. {$ENDIF}
  651. user : Pchar;
  652. password : Pchar;
  653. unix_socket : Pchar;
  654. db : Pchar;
  655. {$IFDEF mysql41}
  656. init_commands : Pst_dynamic_array;
  657. {$ENDIF}
  658. my_cnf_file : Pchar;
  659. my_cnf_group : Pchar;
  660. charset_dir : Pchar;
  661. charset_name : Pchar;
  662. ssl_key : Pchar; // PEM key file
  663. ssl_cert : Pchar; // PEM cert file
  664. ssl_ca : Pchar; // PEM CA file
  665. ssl_capath : Pchar; // PEM directory of CA-s?
  666. ssl_cipher : Pchar; // cipher to use
  667. {$IFDEF mysql41}
  668. shared_memory_base_name : Pchar;
  669. {$ENDIF}
  670. max_allowed_packet : culong;
  671. use_ssl : my_bool; // if to use SSL or not
  672. compress : my_bool;
  673. named_pipe : my_bool;
  674. { On connect, find out the replication role of the server, and
  675. establish connections to all the peers }
  676. rpl_probe : my_bool;
  677. { Each call to mysql_real_query() will parse it to tell if it is a read
  678. or a write, and direct it to the slave or the master }
  679. rpl_parse : my_bool;
  680. { If set, never read from a master, only from slave, when doing
  681. a read that is replication-aware }
  682. no_master_reads : my_bool;
  683. { $if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY)}
  684. {$IFDEF mysql41}
  685. separate_thread : my_bool;
  686. { $endif}
  687. methods_to_use : mysql_option;
  688. client_ip : Pchar;
  689. secure_auth : my_bool; // Refuse client connecting to server if it uses old (pre-4.1.1) protocol
  690. {$IFDEF mysql50}
  691. report_data_truncation : my_bool;// 0 - never report, 1 - always report (default)
  692. {$ENDIF}
  693. { function pointers for local infile support }
  694. local_infile_init : function (_para1:Ppointer; _para2:Pchar; _para3:pointer):cint;cdecl;
  695. local_infile_read : function (_para1:pointer; _para2:Pchar; _para3:cuint):cint;
  696. local_infile_end : procedure (_para1:pointer);
  697. local_infile_error : function (_para1:pointer; _para2:Pchar; _para3:cuint):cint;
  698. local_infile_userdata : pointer;
  699. {$ENDIF}
  700. end;
  701. mysql_status = (MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,
  702. MYSQL_STATUS_USE_RESULT);
  703. mysql_protocol_type = (MYSQL_PROTOCOL_DEFAULT,MYSQL_PROTOCOL_TCP,
  704. MYSQL_PROTOCOL_SOCKET,MYSQL_PROTOCOL_PIPE,
  705. MYSQL_PROTOCOL_MEMORY);
  706. { There are three types of queries - the ones that have to go to
  707. the master, the ones that go to a slave, and the adminstrative
  708. type which must happen on the pivot connectioin }
  709. mysql_rpl_type = (MYSQL_RPL_MASTER,MYSQL_RPL_SLAVE,MYSQL_RPL_ADMIN
  710. );
  711. charset_info_st = record
  712. number : cuint;
  713. primary_number : cuint;
  714. binary_number : cuint;
  715. state : cuint;
  716. csname : ^char;
  717. name : ^char;
  718. comment : ^char;
  719. tailoring : ^char;
  720. ftype : ^cuchar;
  721. to_lower : ^cuchar;
  722. to_upper : ^cuchar;
  723. sort_order : ^cuchar;
  724. contractions : ^cuint16;
  725. sort_order_big : ^pword;
  726. tab_to_uni : ^cuint16;
  727. tab_from_uni : pointer; // was ^MY_UNI_IDX
  728. state_map : ^cuchar;
  729. ident_map : ^cuchar;
  730. strxfrm_multiply : cuint;
  731. mbminlen : cuint;
  732. mbmaxlen : cuint;
  733. min_sort_char : cuint16;
  734. max_sort_char : cuint16;
  735. escape_with_backslash_is_dangerous : my_bool;
  736. cset : pointer; // was ^MY_CHARSET_HANDLER
  737. coll : pointer; // was ^MY_COLLATION_HANDLER;
  738. end;
  739. CHARSET_INFO = charset_info_st;
  740. Pcharset_info_st = ^charset_info_st;
  741. {$IFDEF mysql50}
  742. Pcharacter_set = ^character_set;
  743. character_set = record
  744. number : cuint;
  745. state : cuint;
  746. csname : Pchar;
  747. name : Pchar;
  748. comment : Pchar;
  749. dir : Pchar;
  750. mbminlen : cuint;
  751. mbmaxlen : cuint;
  752. end;
  753. MY_CHARSET_INFO = character_set;
  754. PMY_CHARSET_INFO = ^MY_CHARSET_INFO;
  755. {$ENDIF}
  756. Pst_mysql_methods = ^st_mysql_methods;
  757. Pst_mysql = ^st_mysql;
  758. st_mysql = record
  759. net : NET; // Communication parameters
  760. connector_fd : gptr; // ConnectorFd for SSL
  761. host : Pchar;
  762. user : Pchar;
  763. passwd : Pchar;
  764. unix_socket : Pchar;
  765. server_version : Pchar;
  766. host_info : Pchar;
  767. info : Pchar;
  768. db : Pchar;
  769. charset : Pcharset_info_st;
  770. fields : PMYSQL_FIELD;
  771. field_alloc : MEM_ROOT;
  772. affected_rows : my_ulonglong;
  773. insert_id : my_ulonglong; // id if insert on table with NEXTNR
  774. extra_info : my_ulonglong; // Used by mysqlshow, not used by mysql 5.0 and up
  775. thread_id : culong; // Id for connection in server
  776. packet_length : culong;
  777. port : cuint;
  778. client_flag : culong;
  779. server_capabilities : culong;
  780. protocol_version : cuint;
  781. field_count : cuint;
  782. server_status : cuint;
  783. server_language : cuint;
  784. warning_count : cuint;
  785. options : st_mysql_options;
  786. status : mysql_status;
  787. free_me : my_bool; // If free in mysql_close
  788. reconnect : my_bool; // set to 1 if automatic reconnect
  789. scramble : array[0..(SCRAMBLE_LENGTH+1)-1] of char; // session-wide random string
  790. { Set if this is the original connection, not a master or a slave we have
  791. added though mysql_rpl_probe() or mysql_set_master()/ mysql_add_slave() }
  792. rpl_pivot : my_bool;
  793. { Pointers to the master, and the next slave connections, points to
  794. itself if lone connection. }
  795. master : Pst_mysql;
  796. next_slave : Pst_mysql;
  797. last_used_slave : Pst_mysql; // needed for round-robin slave pick
  798. last_used_con : Pst_mysql; // needed for send/read/store/use result to work correctly with replication
  799. {$IFDEF mysql41}
  800. stmts : Pointer; // was PList, list of all statements
  801. methods : Pst_mysql_methods;
  802. thd : pointer;
  803. { Points to boolean flag in MYSQL_RES or MYSQL_STMT. We set this flag
  804. from mysql_stmt_close if close had to cancel result set of this object. }
  805. unbuffered_fetch_owner : Pmy_bool;
  806. {$ENDIF}
  807. end;
  808. MYSQL = st_mysql;
  809. PMYSQL = ^MYSQL;
  810. Pst_mysql_res = ^st_mysql_res;
  811. st_mysql_res = record
  812. row_count : my_ulonglong;
  813. fields : PMYSQL_FIELD;
  814. data : PMYSQL_DATA;
  815. data_cursor : PMYSQL_ROWS;
  816. lengths : pculong; // column lengths of current row
  817. handle : PMYSQL; // for unbuffered reads
  818. field_alloc : MEM_ROOT;
  819. field_count : cuint;
  820. current_field : cuint;
  821. row : MYSQL_ROW; // If unbuffered read
  822. current_row : MYSQL_ROW; // buffer to current row
  823. eof : my_bool; // Used by mysql_fetch_row
  824. {$IFDEF mysql41}
  825. unbuffered_fetch_cancelled : my_bool; // mysql_stmt_close() had to cancel this result
  826. methods : Pst_mysql_methods;
  827. {$ENDIF}
  828. end;
  829. MYSQL_RES = st_mysql_res;
  830. PMYSQL_RES = ^MYSQL_RES;
  831. Pst_mysql_stmt = ^st_mysql_stmt;
  832. PMYSQL_STMT = ^MYSQL_STMT;
  833. st_mysql_methods = record
  834. read_query_result : function (mysql:PMYSQL):my_bool;cdecl;
  835. advanced_command : function (mysql:PMYSQL; command:enum_server_command; header:Pchar; header_length:culong; arg:Pchar;
  836. arg_length:culong; skip_check:my_bool):my_bool;
  837. read_rows : function (mysql:PMYSQL; mysql_fields:PMYSQL_FIELD; fields:cuint):PMYSQL_DATA;
  838. use_result : function (mysql:PMYSQL):PMYSQL_RES;
  839. fetch_lengths : procedure (fto:pculong; column:MYSQL_ROW; field_count:cuint);
  840. flush_use_result : procedure (mysql:PMYSQL);
  841. { $if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY)}
  842. list_fields : function (mysql:PMYSQL):PMYSQL_FIELD;
  843. read_prepare_result : function (mysql:PMYSQL; stmt:PMYSQL_STMT):my_bool;
  844. stmt_execute : function (stmt:PMYSQL_STMT):cint;
  845. read_binary_rows : function (stmt:PMYSQL_STMT):cint;
  846. unbuffered_fetch : function (mysql:PMYSQL; row:PPchar):cint;
  847. free_embedded_thd : procedure (mysql:PMYSQL);
  848. read_statistics : function (mysql:PMYSQL):Pchar;
  849. next_result : function (mysql:PMYSQL):my_bool;
  850. read_change_user_result : function (mysql:PMYSQL; buff:Pchar; passwd:Pchar):cint;
  851. {$IFDEF mysql50}
  852. read_rowsfrom_cursor : function (stmt:PMYSQL_STMT):cint;
  853. {$ENDIF mysql50}
  854. { $endif}
  855. end;
  856. MYSQL_METHODS = st_mysql_methods;
  857. PMYSQL_METHODS = ^MYSQL_METHODS;
  858. Pst_mysql_manager = ^st_mysql_manager;
  859. st_mysql_manager = record
  860. net : NET;
  861. host : Pchar;
  862. user : Pchar;
  863. passwd : Pchar;
  864. port : cuint;
  865. free_me : my_bool;
  866. eof : my_bool;
  867. cmd_status : cint;
  868. last_errno : cint;
  869. net_buf : Pchar;
  870. net_buf_pos : Pchar;
  871. net_data_end : Pchar;
  872. net_buf_size : cint;
  873. last_error : array[0..(MAX_MYSQL_MANAGER_ERR)-1] of char;
  874. end;
  875. MYSQL_MANAGER = st_mysql_manager;
  876. PMYSQL_MANAGER = ^MYSQL_MANAGER;
  877. Pst_mysql_parameters = ^st_mysql_parameters;
  878. st_mysql_parameters = record
  879. p_max_allowed_packet : pculong;
  880. p_net_buffer_length : pculong;
  881. end;
  882. MYSQL_PARAMETERS = st_mysql_parameters;
  883. PMYSQL_PARAMETERS = ^MYSQL_PARAMETERS;
  884. { The following definitions are added for the enhanced
  885. client-server protocol }
  886. { statement state }
  887. enum_mysql_stmt_state = (MYSQL_STMT_INIT_DONE := 1,MYSQL_STMT_PREPARE_DONE,
  888. MYSQL_STMT_EXECUTE_DONE,MYSQL_STMT_FETCH_DONE
  889. );
  890. {
  891. Note: this info is from the mysql-5.0 version:
  892. This structure is used to define bind information, and
  893. internally by the client library.
  894. Public members with their descriptions are listed below
  895. (conventionally `On input' refers to the binds given to
  896. mysql_stmt_bind_param, `On output' refers to the binds given
  897. to mysql_stmt_bind_result):
  898. buffer_type - One of the MYSQL_* types, used to describe
  899. the host language type of buffer.
  900. On output: if column type is different from
  901. buffer_type, column value is automatically converted
  902. to buffer_type before it is stored in the buffer.
  903. buffer - On input: points to the buffer with input data.
  904. On output: points to the buffer capable to store
  905. output data.
  906. The type of memory pointed by buffer must correspond
  907. to buffer_type. See the correspondence table in
  908. the comment to mysql_stmt_bind_param.
  909. The two above members are mandatory for any kind of bind.
  910. buffer_length - the length of the buffer. You don't have to set
  911. it for any fixed length buffer: float, double,
  912. int, etc. It must be set however for variable-length
  913. types, such as BLOBs or STRINGs.
  914. length - On input: in case when lengths of input values
  915. are different for each execute, you can set this to
  916. point at a variable containining value length. This
  917. way the value length can be different in each execute.
  918. If length is not NULL, buffer_length is not used.
  919. Note, length can even point at buffer_length if
  920. you keep bind structures around while fetching:
  921. this way you can change buffer_length before
  922. each execution, everything will work ok.
  923. On output: if length is set, mysql_stmt_fetch will
  924. write column length into it.
  925. is_null - On input: points to a boolean variable that should
  926. be set to TRUE for NULL values.
  927. This member is useful only if your data may be
  928. NULL in some but not all cases.
  929. If your data is never NULL, is_null should be set to 0.
  930. If your data is always NULL, set buffer_type
  931. to MYSQL_TYPE_NULL, and is_null will not be used.
  932. is_unsigned - On input: used to signify that values provided for one
  933. of numeric types are unsigned.
  934. On output describes signedness of the output buffer.
  935. If, taking into account is_unsigned flag, column data
  936. is out of range of the output buffer, data for this column
  937. is regarded truncated. Note that this has no correspondence
  938. to the sign of result set column, if you need to find it out
  939. use mysql_stmt_result_metadata.
  940. error - where to write a truncation error if it is present.
  941. possible error value is:
  942. 0 no truncation
  943. 1 value is out of range or buffer is too small
  944. Please note that MYSQL_BIND also has internals members.
  945. }
  946. Pst_mysql_bind = ^st_mysql_bind;
  947. st_mysql_bind = record
  948. length : culong; // output length pointer
  949. is_null : Pmy_bool; // Pointer to null indicator
  950. buffer : pointer; // buffer to get/put data
  951. {$IFDEF mysql50}
  952. error: pmy_bool; // set this if you want to track data truncations happened during fetch
  953. {$ENDIF}
  954. buffer_type : enum_field_types; // buffer type
  955. buffer_length : culong; // buffer length, must be set for str/binary
  956. { Following are for internal use. Set by mysql_stmt_bind_param }
  957. {$IFNDEF mysql50}
  958. inter_buffer : Pbyte; // for the current data position
  959. {$ELSE}
  960. row_ptr : PByte; // for the current data position
  961. {$ENDIF}
  962. offset : culong; // offset position for char/binary fetch
  963. {$IFNDEF mysql50}
  964. internal_length : culong; // Used if length is 0
  965. {$ELSE}
  966. length_value : culong; // Used if length is 0
  967. {$ENDIF}
  968. param_number : cuint; // For null count and error messages
  969. pack_length : cuint; // Internal length for packed data
  970. {$IFDEF mysql50}
  971. error_value : my_bool; // used if error is 0
  972. {$ENDIF}
  973. is_unsigned : my_bool; // set if integer type is unsigned
  974. long_data_used : my_bool; // If used with mysql_send_long_data
  975. {$IFNDEF mysql50}
  976. internal_is_null : my_bool; // Used if is_null is 0
  977. {$ELSE}
  978. is_null_value : my_bool; // Used if is_null is 0
  979. {$ENDIF}
  980. store_param_func : procedure (net:PNET; param:Pst_mysql_bind);cdecl;
  981. fetch_result : procedure (_para1:Pst_mysql_bind; _para2:PMYSQL_FIELD; row:PPbyte);
  982. skip_result : procedure (_para1:Pst_mysql_bind; _para2:PMYSQL_FIELD; row:PPbyte);
  983. end;
  984. MYSQL_BIND = st_mysql_bind;
  985. PMYSQL_BIND = ^MYSQL_BIND;
  986. { statement handler }
  987. st_mysql_stmt = record
  988. mem_root : MEM_ROOT; // root allocations
  989. // list : LIST; // list to keep track of all stmts
  990. mysql : PMYSQL; // connection handle
  991. params : PMYSQL_BIND; // input parameters
  992. bind : PMYSQL_BIND; // input parameters
  993. fields : PMYSQL_FIELD; // result set metadata
  994. result : MYSQL_DATA; // cached result set
  995. data_cursor : PMYSQL_ROWS; // current row in cached result
  996. affected_rows : my_ulonglong; // copy of mysql->affected_rows after statement execution
  997. insert_id : my_ulonglong; // copy of mysql->insert_id
  998. { mysql_stmt_fetch() calls this function to fetch one row (it's different
  999. for buffered, unbuffered and cursor fetch). }
  1000. read_row_func : function (stmt:Pst_mysql_stmt; row:PPbyte):cint;cdecl;
  1001. stmt_id : culong; // Id for prepared statement
  1002. {$IFDEF mysql50}
  1003. flags : culong; // i.e. type of cursor to open
  1004. prefetch_rows : culong; // number of rows per one COM_FETCH
  1005. server_status : cuint; // Copied from mysql->server_status after execute/fetch to know
  1006. // server-side cursor status for this statement.
  1007. {$ENDIF}
  1008. last_errno : cuint; // error code
  1009. param_count : cuint; // input parameter count
  1010. field_count : cuint; // number of columns in result set
  1011. state : enum_mysql_stmt_state; // statement state
  1012. last_error : array[0..(MYSQL_ERRMSG_SIZE)-1] of char; // error message
  1013. sqlstate : array[0..(SQLSTATE_LENGTH+1)-1] of char;
  1014. send_types_to_server : my_bool; // Types of input parameters should be sent to server
  1015. bind_param_done : my_bool; // input buffers were supplied
  1016. {$IFNDEF mysql50}
  1017. bind_result_done : my_bool; // output buffers were supplied
  1018. {$ELSE}
  1019. bind_result_done : cuchar; // output buffers were supplied
  1020. {$ENDIF}
  1021. unbuffered_fetch_cancelled : my_bool; // mysql_stmt_close() had to cancel this result
  1022. { Is set to true if we need to calculate field->max_length for
  1023. metadata fields when doing mysql_stmt_store_result. }
  1024. update_max_length : my_bool;
  1025. end;
  1026. MYSQL_STMT = st_mysql_stmt;
  1027. { When doing mysql_stmt_store_result calculate max_length attribute
  1028. of statement metadata. This is to be consistent with the old API,
  1029. where this was done automatically.
  1030. In the new API we do that only by request because it slows down
  1031. mysql_stmt_store_result sufficiently. }
  1032. enum_stmt_attr_type = (STMT_ATTR_UPDATE_MAX_LENGTH
  1033. {$IFDEF mysql50}
  1034. ,STMT_ATTR_CURSOR_TYPE, // unsigned long with combination of cursor flags (read only, for update, etc)
  1035. STMT_ATTR_PREFETCH_ROWS // Amount of rows to retrieve from server per one fetch if using cursors.
  1036. // Accepts unsigned long attribute in the range 1 - ulong_max
  1037. {$ENDIF}
  1038. );
  1039. //#define max_allowed_packet (*mysql_get_parameters()->p_max_allowed_packet)
  1040. //#define net_buffer_length (*mysql_get_parameters()->p_net_buffer_length)
  1041. {$IFNDEF LinkDynamically}
  1042. { Set up and bring down the server; to ensure that applications will
  1043. work when linked against either the standard client library or the
  1044. embedded server library, these functions should be called. }
  1045. function mysql_server_init(argc:cint; argv:PPchar; groups:PPchar):cint;cdecl;external mysqllib name 'mysql_server_init';
  1046. procedure mysql_server_end;cdecl;external mysqllib name 'mysql_server_end';
  1047. { mysql_server_init/end need to be called when using libmysqld or
  1048. libmysqlclient (exactly, mysql_server_init() is called by mysql_init() so
  1049. you don't need to call it explicitely; but you need to call
  1050. mysql_server_end() to free memory). The names are a bit misleading
  1051. (mysql_SERVER* to be used when using libmysqlCLIENT). So we add more general
  1052. names which suit well whether you're using libmysqld or libmysqlclient. We
  1053. intend to promote these aliases over the mysql_server* ones. }
  1054. function mysql_library_init(argc:cint; argv:PPchar; groups:PPchar):cint;cdecl;external mysqllib name 'mysql_server_init';
  1055. procedure mysql_library_end;cdecl;external mysqllib name 'mysql_server_end';
  1056. function mysql_get_parameters:PMYSQL_PARAMETERS;extdecl;external mysqllib name 'mysql_get_parameters';
  1057. { Set up and bring down a thread; these function should be called
  1058. for each thread in an application which opens at least one MySQL
  1059. connection. All uses of the connection(s) should be between these
  1060. function calls. }
  1061. function mysql_thread_init:my_bool;extdecl;external mysqllib name 'mysql_thread_init';
  1062. procedure mysql_thread_end;extdecl;external mysqllib name 'mysql_thread_end';
  1063. { Functions to get information from the MYSQL and MYSQL_RES structures
  1064. Should definitely be used if one uses shared libraries. }
  1065. function mysql_num_rows(res:PMYSQL_RES):my_ulonglong;extdecl;external mysqllib name 'mysql_num_rows';
  1066. function mysql_num_fields(res:PMYSQL_RES):cuint;extdecl;external mysqllib name 'mysql_num_fields';
  1067. function mysql_eof(res:PMYSQL_RES):my_bool;extdecl;external mysqllib name 'mysql_eof';
  1068. function mysql_fetch_field_direct(res:PMYSQL_RES; fieldnr:cuint):PMYSQL_FIELD;extdecl;external mysqllib name 'mysql_fetch_field_direct';
  1069. function mysql_fetch_fields(res:PMYSQL_RES):PMYSQL_FIELD;extdecl;external mysqllib name 'mysql_fetch_fields';
  1070. function mysql_row_tell(res:PMYSQL_RES):MYSQL_ROW_OFFSET;extdecl;external mysqllib name 'mysql_row_tell';
  1071. function mysql_field_tell(res:PMYSQL_RES):MYSQL_FIELD_OFFSET;extdecl;external mysqllib name 'mysql_field_tell';
  1072. function mysql_field_count(mysql:PMYSQL):cuint;extdecl;external mysqllib name 'mysql_field_count';
  1073. function mysql_affected_rows(mysql:PMYSQL):my_ulonglong;extdecl;external mysqllib name 'mysql_affected_rows';
  1074. function mysql_insert_id(mysql:PMYSQL):my_ulonglong;extdecl;external mysqllib name 'mysql_insert_id';
  1075. function mysql_errno(mysql:PMYSQL):cuint;extdecl;external mysqllib name 'mysql_errno';
  1076. function mysql_error(mysql:PMYSQL):Pchar;extdecl;external mysqllib name 'mysql_error';
  1077. function mysql_sqlstate(mysql:PMYSQL):Pchar;extdecl;external mysqllib name 'mysql_sqlstate';
  1078. function mysql_warning_count(mysql:PMYSQL):cuint;extdecl;external mysqllib name 'mysql_warning_count';
  1079. function mysql_info(mysql:PMYSQL):Pchar;extdecl;external mysqllib name 'mysql_info';
  1080. function mysql_thread_id(mysql:PMYSQL):culong;extdecl;external mysqllib name 'mysql_thread_id';
  1081. function mysql_character_set_name(mysql:PMYSQL):Pchar;extdecl;external mysqllib name 'mysql_character_set_name';
  1082. function mysql_set_character_set(mysql:PMYSQL; csname:Pchar):longint;extdecl;external mysqllib name 'mysql_set_character_set';
  1083. function mysql_init(mysql:PMYSQL):PMYSQL;extdecl;external mysqllib name 'mysql_init';
  1084. function mysql_ssl_set(mysql:PMYSQL; key:Pchar; cert:Pchar; ca:Pchar; capath:Pchar;
  1085. cipher:Pchar):my_bool;extdecl;external mysqllib name 'mysql_ssl_set';
  1086. function mysql_change_user(mysql:PMYSQL; user:Pchar; passwd:Pchar; db:Pchar):my_bool;extdecl;external mysqllib name 'mysql_change_user';
  1087. function mysql_real_connect(mysql:PMYSQL; host:Pchar; user:Pchar; passwd:Pchar; db:Pchar;
  1088. port:cuint; unix_socket:Pchar; clientflag:culong):PMYSQL;extdecl;external mysqllib name 'mysql_real_connect';
  1089. function mysql_select_db(mysql:PMYSQL; db:Pchar):cint;extdecl;external mysqllib name 'mysql_select_db';
  1090. function mysql_query(mysql:PMYSQL; q:Pchar):cint;extdecl;external mysqllib name 'mysql_query';
  1091. function mysql_send_query(mysql:PMYSQL; q:Pchar; length:culong):cint;extdecl;external mysqllib name 'mysql_send_query';
  1092. function mysql_real_query(mysql:PMYSQL; q:Pchar; length:culong):cint;extdecl;external mysqllib name 'mysql_real_query';
  1093. function mysql_store_result(mysql:PMYSQL):PMYSQL_RES;extdecl;external mysqllib name 'mysql_store_result';
  1094. function mysql_use_result(mysql:PMYSQL):PMYSQL_RES;extdecl;external mysqllib name 'mysql_use_result';
  1095. {$ELSE}
  1096. var
  1097. mysql_server_init: function (argc:cint; argv:PPchar; groups:PPchar):cint;cdecl;
  1098. mysql_server_end: procedure ;cdecl;
  1099. mysql_library_init: function (argc:cint; argv:PPchar; groups:PPchar):cint;cdecl;
  1100. mysql_library_end: procedure ;cdecl;
  1101. mysql_num_rows: function (res:PMYSQL_RES):my_ulonglong;extdecl;
  1102. mysql_num_fields: function (res:PMYSQL_RES):cuint;extdecl;
  1103. mysql_eof: function (res:PMYSQL_RES):my_bool;extdecl;
  1104. mysql_fetch_field_direct: function (res:PMYSQL_RES; fieldnr:cuint):PMYSQL_FIELD;extdecl;
  1105. mysql_fetch_fields: function (res:PMYSQL_RES):PMYSQL_FIELD;extdecl;
  1106. mysql_row_tell: function (res:PMYSQL_RES):MYSQL_ROW_OFFSET;extdecl;
  1107. mysql_field_tell: function (res:PMYSQL_RES):MYSQL_FIELD_OFFSET;extdecl;
  1108. mysql_field_count: function (mysql:PMYSQL):cuint;extdecl;
  1109. mysql_affected_rows: function (mysql:PMYSQL):my_ulonglong;extdecl;
  1110. mysql_insert_id: function (mysql:PMYSQL):my_ulonglong;extdecl;
  1111. mysql_errno: function (mysql:PMYSQL):cuint;extdecl;
  1112. mysql_error: function (mysql:PMYSQL):Pchar;extdecl;
  1113. mysql_sqlstate: function (mysql:PMYSQL):Pchar;extdecl;
  1114. mysql_warning_count: function (mysql:PMYSQL):cuint;extdecl;
  1115. mysql_info: function (mysql:PMYSQL):Pchar;extdecl;
  1116. mysql_thread_id: function (mysql:PMYSQL):culong;extdecl;
  1117. mysql_character_set_name: function (mysql:PMYSQL):Pchar;extdecl;
  1118. mysql_set_character_set: function (mysql:PMYSQL; csname:Pchar):cint;extdecl;
  1119. mysql_init: function (mysql:PMYSQL):PMYSQL;extdecl;
  1120. mysql_ssl_set: function (mysql:PMYSQL; key:Pchar; cert:Pchar; ca:Pchar; capath:Pchar;
  1121. cipher:Pchar):my_bool;extdecl;
  1122. mysql_change_user: function (mysql:PMYSQL; user:Pchar; passwd:Pchar; db:Pchar):my_bool;extdecl;
  1123. mysql_real_connect: function (mysql:PMYSQL; host:Pchar; user:Pchar; passwd:Pchar; db:Pchar;
  1124. port:cuint; unix_socket:Pchar; clientflag:culong):PMYSQL;extdecl;
  1125. mysql_select_db: function (mysql:PMYSQL; db:Pchar):cint;extdecl;
  1126. mysql_query: function (mysql:PMYSQL; q:Pchar):cint;extdecl;
  1127. mysql_send_query: function (mysql:PMYSQL; q:Pchar; length:culong):cint;extdecl;
  1128. mysql_real_query: function (mysql:PMYSQL; q:Pchar; length:culong):cint;extdecl;
  1129. mysql_store_result: function (mysql:PMYSQL):PMYSQL_RES;extdecl;
  1130. mysql_use_result: function (mysql:PMYSQL):PMYSQL_RES;extdecl;
  1131. {$ENDIF}
  1132. {$IFNDEF LinkDynamically}
  1133. { perform query on master }
  1134. function mysql_master_query(mysql:PMYSQL; q:Pchar; length:culong):my_bool;extdecl;external mysqllib name 'mysql_master_query';
  1135. function mysql_master_send_query(mysql:PMYSQL; q:Pchar; length:culong):my_bool;extdecl;external mysqllib name 'mysql_master_send_query';
  1136. { perform query on slave }
  1137. function mysql_slave_query(mysql:PMYSQL; q:Pchar; length:culong):my_bool;extdecl;external mysqllib name 'mysql_slave_query';
  1138. function mysql_slave_send_query(mysql:PMYSQL; q:Pchar; length:culong):my_bool;extdecl;external mysqllib name 'mysql_slave_send_query';
  1139. {$IFDEF mysql50}
  1140. procedure mysql_get_character_set_info(mysql : PMYSQL; charset : PMY_CHARSET_INFO);extdecl;external mysqllib name 'mysql_get_character_set_info';
  1141. {$ENDIF}
  1142. {$ENDIF}
  1143. { local infile support }
  1144. const
  1145. LOCAL_INFILE_ERROR_LEN = 512;
  1146. {$IFNDEF LinkDynamically}
  1147. { procedure mysql_set_local_infile_handler(mysql:PMYSQL; local_infile_init:function (_para1:Ppointer; _para2:Pchar; _para3:pointer):longint; local_infile_read:function (_para1:pointer; _para2:Pchar; _para3:dword):longint; local_infile_end:procedure (_pa
  1148. _para6:pointer);cdecl;external mysqllib name 'mysql_set_local_infile_handler';}
  1149. procedure mysql_set_local_infile_default(mysql:PMYSQL);cdecl;external mysqllib name 'mysql_set_local_infile_default';
  1150. { enable/disable parsing of all queries to decide if they go on master or
  1151. slave }
  1152. procedure mysql_enable_rpl_parse(mysql:PMYSQL);extdecl;external mysqllib name 'mysql_enable_rpl_parse';
  1153. procedure mysql_disable_rpl_parse(mysql:PMYSQL);extdecl;external mysqllib name 'mysql_disable_rpl_parse';
  1154. { get the value of the parse flag }
  1155. function mysql_rpl_parse_enabled(mysql:PMYSQL):cint;extdecl;external mysqllib name 'mysql_rpl_parse_enabled';
  1156. { enable/disable reads from master }
  1157. procedure mysql_enable_reads_from_master(mysql:PMYSQL);extdecl;external mysqllib name 'mysql_enable_reads_from_master';
  1158. procedure mysql_disable_reads_from_master(mysql:PMYSQL);extdecl;external mysqllib name 'mysql_disable_reads_from_master';
  1159. { get the value of the master read flag }
  1160. function mysql_reads_from_master_enabled(mysql:PMYSQL):my_bool;extdecl;external mysqllib name 'mysql_reads_from_master_enabled';
  1161. function mysql_rpl_query_type(q : pchar;len : cint):mysql_rpl_type;extdecl;external mysqllib name 'mysql_rpl_query_type';
  1162. { discover the master and its slaves }
  1163. function mysql_rpl_probe(mysql:PMYSQL):my_bool;extdecl;external mysqllib name 'mysql_rpl_probe';
  1164. { set the master, close/free the old one, if it is not a pivot }
  1165. function mysql_set_master(mysql:PMYSQL; host:Pchar; port:cuint; user:Pchar; passwd:Pchar):cint;extdecl;external mysqllib name 'mysql_set_master';
  1166. function mysql_add_slave(mysql:PMYSQL; host:Pchar; port:cuint; user:Pchar; passwd:Pchar):cint;extdecl;external mysqllib name 'mysql_add_slave';
  1167. function mysql_shutdown(mysql:PMYSQL; shutdown_level:mysql_enum_shutdown_level):cint;extdecl;external mysqllib name 'mysql_shutdown';
  1168. function mysql_dump_debug_info(mysql:PMYSQL):cint;extdecl;external mysqllib name 'mysql_dump_debug_info';
  1169. function mysql_refresh(mysql:PMYSQL; refresh_options:cuint):cint;extdecl;external mysqllib name 'mysql_refresh';
  1170. function mysql_kill(mysql:PMYSQL; pid:culong):cint;extdecl;external mysqllib name 'mysql_kill';
  1171. function mysql_set_server_option(mysql:PMYSQL; option:enum_mysql_set_option):cint;extdecl;external mysqllib name 'mysql_set_server_option';
  1172. function mysql_ping(mysql:PMYSQL):cint;extdecl;external mysqllib name 'mysql_ping';
  1173. function mysql_stat(mysql:PMYSQL):Pchar;extdecl;external mysqllib name 'mysql_stat';
  1174. function mysql_get_server_info(mysql:PMYSQL):Pchar;extdecl;external mysqllib name 'mysql_get_server_info';
  1175. function mysql_get_client_info:Pchar;extdecl;external mysqllib name 'mysql_get_client_info';
  1176. function mysql_get_client_version:culong;extdecl;external mysqllib name 'mysql_get_client_version';
  1177. function mysql_get_host_info(mysql:PMYSQL):Pchar;extdecl;external mysqllib name 'mysql_get_host_info';
  1178. function mysql_get_server_version(mysql:PMYSQL):culong;extdecl;external mysqllib name 'mysql_get_server_version';
  1179. function mysql_get_proto_info(mysql:PMYSQL):cuint;extdecl;external mysqllib name 'mysql_get_proto_info';
  1180. function mysql_list_dbs(mysql:PMYSQL; wild:Pchar):PMYSQL_RES;extdecl;external mysqllib name 'mysql_list_dbs';
  1181. function mysql_list_tables(mysql:PMYSQL; wild:Pchar):PMYSQL_RES;extdecl;external mysqllib name 'mysql_list_tables';
  1182. function mysql_list_processes(mysql:PMYSQL):PMYSQL_RES;extdecl;external mysqllib name 'mysql_list_processes';
  1183. function mysql_options(mysql:PMYSQL; option:mysql_option; arg:Pchar):cint;extdecl;external mysqllib name 'mysql_options';
  1184. procedure mysql_free_result(result:PMYSQL_RES);extdecl;external mysqllib name 'mysql_free_result';
  1185. procedure mysql_data_seek(result:PMYSQL_RES; offset:my_ulonglong);extdecl;external mysqllib name 'mysql_data_seek';
  1186. function mysql_row_seek(result:PMYSQL_RES; offset:MYSQL_ROW_OFFSET):MYSQL_ROW_OFFSET;extdecl;external mysqllib name 'mysql_row_seek';
  1187. function mysql_field_seek(result:PMYSQL_RES; offset:MYSQL_FIELD_OFFSET):MYSQL_FIELD_OFFSET;extdecl;external mysqllib name 'mysql_field_seek';
  1188. function mysql_fetch_row(result:PMYSQL_RES):MYSQL_ROW;extdecl;external mysqllib name 'mysql_fetch_row';
  1189. function mysql_fetch_lengths(result:PMYSQL_RES):pculong;extdecl;external mysqllib name 'mysql_fetch_lengths';
  1190. function mysql_fetch_field(result:PMYSQL_RES):PMYSQL_FIELD;extdecl;external mysqllib name 'mysql_fetch_field';
  1191. function mysql_list_fields(mysql:PMYSQL; table:Pchar; wild:Pchar):PMYSQL_RES;extdecl;external mysqllib name 'mysql_list_fields';
  1192. function mysql_escape_string(fto:Pchar; from:Pchar; from_length:culong):culong;extdecl;external mysqllib name 'mysql_escape_string';
  1193. function mysql_hex_string(fto:Pchar; from:Pchar; from_length:culong):culong;extdecl;external mysqllib name 'mysql_hex_string';
  1194. function mysql_real_escape_string(mysql:PMYSQL; fto:Pchar; from:Pchar; length:culong):culong;extdecl;external mysqllib name 'mysql_real_escape_string';
  1195. procedure mysql_debug(debug:Pchar);extdecl;external mysqllib name 'mysql_debug';
  1196. { function mysql_odbc_escape_string(mysql:PMYSQL; fto:Pchar; to_length:dword; from:Pchar; from_length:dword;
  1197. param:pointer; extend_buffer:function (_para1:pointer; to:Pchar; length:Pdword):Pchar):Pchar;extdecl;external mysqllib name 'mysql_odbc_escape_string';}
  1198. procedure myodbc_remove_escape(mysql:PMYSQL; name:Pchar);extdecl;external mysqllib name 'myodbc_remove_escape';
  1199. function mysql_thread_safe:cuint;extdecl;external mysqllib name 'mysql_thread_safe';
  1200. function mysql_embedded:my_bool;extdecl;external mysqllib name 'mysql_embedded';
  1201. function mysql_manager_init(con:PMYSQL_MANAGER):PMYSQL_MANAGER;extdecl;external mysqllib name 'mysql_manager_init';
  1202. function mysql_manager_connect(con:PMYSQL_MANAGER; host:Pchar; user:Pchar; passwd:Pchar; port:cuint):PMYSQL_MANAGER;extdecl;external mysqllib name 'mysql_manager_connect';
  1203. procedure mysql_manager_close(con:PMYSQL_MANAGER);extdecl;external mysqllib name 'mysql_manager_close';
  1204. function mysql_manager_command(con:PMYSQL_MANAGER; cmd:Pchar; cmd_len:cint):cint;extdecl;external mysqllib name 'mysql_manager_command';
  1205. function mysql_manager_fetch_line(con:PMYSQL_MANAGER; res_buf:Pchar; res_buf_size:cint):cint;extdecl;external mysqllib name 'mysql_manager_fetch_line';
  1206. function mysql_read_query_result(mysql:PMYSQL):my_bool;extdecl;external mysqllib name 'mysql_read_query_result';
  1207. function mysql_stmt_init(mysql:PMYSQL):PMYSQL_STMT;extdecl;external mysqllib name 'mysql_stmt_init';
  1208. function mysql_stmt_prepare(stmt:PMYSQL_STMT; query:Pchar; length:culong):cint;extdecl;external mysqllib name 'mysql_stmt_prepare';
  1209. function mysql_stmt_execute(stmt:PMYSQL_STMT):cint;extdecl;external mysqllib name 'mysql_stmt_execute';
  1210. function mysql_stmt_fetch(stmt:PMYSQL_STMT):cint;extdecl;external mysqllib name 'mysql_stmt_fetch';
  1211. function mysql_stmt_fetch_column(stmt:PMYSQL_STMT; bind:PMYSQL_BIND; column:cuint; offset:culong):cint;extdecl;external mysqllib name 'mysql_stmt_fetch_column';
  1212. function mysql_stmt_store_result(stmt:PMYSQL_STMT):cint;extdecl;external mysqllib name 'mysql_stmt_store_result';
  1213. function mysql_stmt_param_count(stmt:PMYSQL_STMT):culong;extdecl;external mysqllib name 'mysql_stmt_param_count';
  1214. function mysql_stmt_attr_set(stmt:PMYSQL_STMT; attr_type:enum_stmt_attr_type; attr:pointer):my_bool;extdecl;external mysqllib name 'mysql_stmt_attr_set';
  1215. function mysql_stmt_attr_get(stmt:PMYSQL_STMT; attr_type:enum_stmt_attr_type; attr:pointer):my_bool;extdecl;external mysqllib name 'mysql_stmt_attr_get';
  1216. function mysql_stmt_bind_param(stmt:PMYSQL_STMT; bnd:PMYSQL_BIND):my_bool;extdecl;external mysqllib name 'mysql_stmt_bind_param';
  1217. function mysql_stmt_bind_result(stmt:PMYSQL_STMT; bnd:PMYSQL_BIND):my_bool;extdecl;external mysqllib name 'mysql_stmt_bind_result';
  1218. function mysql_stmt_close(stmt:PMYSQL_STMT):my_bool;extdecl;external mysqllib name 'mysql_stmt_close';
  1219. function mysql_stmt_reset(stmt:PMYSQL_STMT):my_bool;extdecl;external mysqllib name 'mysql_stmt_reset';
  1220. function mysql_stmt_free_result(stmt:PMYSQL_STMT):my_bool;extdecl;external mysqllib name 'mysql_stmt_free_result';
  1221. function mysql_stmt_send_long_data(stmt:PMYSQL_STMT; param_number:cuint; data:Pchar; length:culong):my_bool;extdecl;external mysqllib name 'mysql_stmt_send_long_data';
  1222. function mysql_stmt_result_metadata(stmt:PMYSQL_STMT):PMYSQL_RES;extdecl;external mysqllib name 'mysql_stmt_result_metadata';
  1223. function mysql_stmt_param_metadata(stmt:PMYSQL_STMT):PMYSQL_RES;extdecl;external mysqllib name 'mysql_stmt_param_metadata';
  1224. function mysql_stmt_errno(stmt:PMYSQL_STMT):cuint;extdecl;external mysqllib name 'mysql_stmt_errno';
  1225. function mysql_stmt_error(stmt:PMYSQL_STMT):Pchar;extdecl;external mysqllib name 'mysql_stmt_error';
  1226. function mysql_stmt_sqlstate(stmt:PMYSQL_STMT):Pchar;extdecl;external mysqllib name 'mysql_stmt_sqlstate';
  1227. function mysql_stmt_row_seek(stmt:PMYSQL_STMT; offset:MYSQL_ROW_OFFSET):MYSQL_ROW_OFFSET;extdecl;external mysqllib name 'mysql_stmt_row_seek';
  1228. function mysql_stmt_row_tell(stmt:PMYSQL_STMT):MYSQL_ROW_OFFSET;extdecl;external mysqllib name 'mysql_stmt_row_tell';
  1229. procedure mysql_stmt_data_seek(stmt:PMYSQL_STMT; offset:my_ulonglong);extdecl;external mysqllib name 'mysql_stmt_data_seek';
  1230. function mysql_stmt_num_rows(stmt:PMYSQL_STMT):my_ulonglong;extdecl;external mysqllib name 'mysql_stmt_num_rows';
  1231. function mysql_stmt_affected_rows(stmt:PMYSQL_STMT):my_ulonglong;extdecl;external mysqllib name 'mysql_stmt_affected_rows';
  1232. function mysql_stmt_insert_id(stmt:PMYSQL_STMT):my_ulonglong;extdecl;external mysqllib name 'mysql_stmt_insert_id';
  1233. function mysql_stmt_field_count(stmt:PMYSQL_STMT):cuint;extdecl;external mysqllib name 'mysql_stmt_field_count';
  1234. function mysql_commit(mysql:PMYSQL):my_bool;extdecl;external mysqllib name 'mysql_commit';
  1235. function mysql_rollback(mysql:PMYSQL):my_bool;extdecl;external mysqllib name 'mysql_rollback';
  1236. function mysql_autocommit(mysql:PMYSQL; auto_mode:my_bool):my_bool;extdecl;external mysqllib name 'mysql_autocommit';
  1237. function mysql_more_results(mysql:PMYSQL):my_bool;extdecl;external mysqllib name 'mysql_more_results';
  1238. function mysql_next_result(mysql:PMYSQL):cint;extdecl;external mysqllib name 'mysql_next_result';
  1239. procedure mysql_close(sock:PMYSQL);extdecl;external mysqllib name 'mysql_close';
  1240. {$ELSE}
  1241. var
  1242. mysql_shutdown: function (mysql:PMYSQL; shutdown_level:mysql_enum_shutdown_level):cint;extdecl;
  1243. mysql_dump_debug_info: function (mysql:PMYSQL):cint;extdecl;
  1244. mysql_refresh: function (mysql:PMYSQL; refresh_options:cuint):cint;extdecl;
  1245. mysql_kill: function (mysql:PMYSQL; pid:culong):cint;extdecl;
  1246. mysql_set_server_option: function (mysql:PMYSQL; option:enum_mysql_set_option):cint;extdecl;
  1247. mysql_ping: function (mysql:PMYSQL):cint;extdecl;
  1248. mysql_stat: function (mysql:PMYSQL):Pchar;extdecl;
  1249. mysql_get_server_info: function (mysql:PMYSQL):Pchar;extdecl;
  1250. mysql_get_client_info: function :Pchar;extdecl;
  1251. mysql_get_client_version: function :culong;extdecl;
  1252. mysql_get_host_info: function (mysql:PMYSQL):Pchar;extdecl;
  1253. mysql_get_server_version: function (mysql:PMYSQL):culong;extdecl;
  1254. mysql_get_proto_info: function (mysql:PMYSQL):cuint;extdecl;
  1255. mysql_list_dbs: function (mysql:PMYSQL; wild:Pchar):PMYSQL_RES;extdecl;
  1256. mysql_list_tables: function (mysql:PMYSQL; wild:Pchar):PMYSQL_RES;extdecl;
  1257. mysql_list_processes: function (mysql:PMYSQL):PMYSQL_RES;extdecl;
  1258. mysql_options: function (mysql:PMYSQL; option:mysql_option; arg:Pchar):cint;extdecl;
  1259. mysql_free_result: procedure (result:PMYSQL_RES);extdecl;
  1260. mysql_data_seek: procedure (result:PMYSQL_RES; offset:my_ulonglong);extdecl;
  1261. mysql_row_seek: function (result:PMYSQL_RES; offset:MYSQL_ROW_OFFSET):MYSQL_ROW_OFFSET;extdecl;
  1262. mysql_field_seek: function (result:PMYSQL_RES; offset:MYSQL_FIELD_OFFSET):MYSQL_FIELD_OFFSET;extdecl;
  1263. mysql_fetch_row: function (result:PMYSQL_RES):MYSQL_ROW;extdecl;
  1264. mysql_fetch_lengths: function (result:PMYSQL_RES):pculong;extdecl;
  1265. mysql_fetch_field: function (result:PMYSQL_RES):PMYSQL_FIELD;extdecl;
  1266. mysql_list_fields: function (mysql:PMYSQL; table:Pchar; wild:Pchar):PMYSQL_RES;extdecl;
  1267. mysql_escape_string: function (fto:Pchar; from:Pchar; from_length:culong):culong;extdecl;
  1268. mysql_hex_string: function (fto:Pchar; from:Pchar; from_length:culong):culong;extdecl;
  1269. mysql_real_escape_string: function (mysql:PMYSQL; fto:Pchar; from:Pchar; length:culong):culong;extdecl;
  1270. mysql_debug: procedure (debug:Pchar);extdecl;
  1271. mysql_rollback: function (mysql:PMYSQL):my_bool;extdecl;
  1272. mysql_autocommit: function (mysql:PMYSQL; auto_mode:my_bool):my_bool;extdecl;
  1273. mysql_commit: function (mysql:PMYSQL):my_bool;extdecl;
  1274. mysql_more_results: function (mysql:PMYSQL):my_bool;extdecl;
  1275. mysql_next_result: function (mysql:PMYSQL):cint;extdecl;
  1276. mysql_close: procedure (sock:PMYSQL);extdecl;
  1277. mysql_stmt_init: function (mysql:PMYSQL):PMYSQL_STMT;extdecl;
  1278. mysql_stmt_prepare: function (stmt:PMYSQL_STMT; query:Pchar; length:culong):cint;extdecl;
  1279. mysql_stmt_execute: function (stmt:PMYSQL_STMT):cint;extdecl;
  1280. mysql_stmt_fetch: function (stmt:PMYSQL_STMT):cint;extdecl;
  1281. mysql_stmt_fetch_column: function (stmt:PMYSQL_STMT; bind:PMYSQL_BIND; column:cuint; offset:culong):cint;extdecl;
  1282. mysql_stmt_store_result: function (stmt:PMYSQL_STMT):cint;extdecl;
  1283. mysql_stmt_param_count: function (stmt:PMYSQL_STMT):culong;extdecl;
  1284. mysql_stmt_attr_set: function (stmt:PMYSQL_STMT; attr_type:enum_stmt_attr_type; attr:pointer):my_bool;extdecl;
  1285. mysql_stmt_attr_get: function (stmt:PMYSQL_STMT; attr_type:enum_stmt_attr_type; attr:pointer):my_bool;extdecl;
  1286. mysql_stmt_bind_param: function (stmt:PMYSQL_STMT; bnd:PMYSQL_BIND):my_bool;extdecl;
  1287. mysql_stmt_bind_result: function (stmt:PMYSQL_STMT; bnd:PMYSQL_BIND):my_bool;extdecl;
  1288. mysql_stmt_close: function (stmt:PMYSQL_STMT):my_bool;extdecl;
  1289. mysql_stmt_reset: function (stmt:PMYSQL_STMT):my_bool;extdecl;
  1290. mysql_stmt_free_result: function (stmt:PMYSQL_STMT):my_bool;extdecl;
  1291. mysql_stmt_send_long_data: function (stmt:PMYSQL_STMT; param_number:cuint; data:Pchar; length:culong):my_bool;extdecl;
  1292. mysql_stmt_result_metadata: function (stmt:PMYSQL_STMT):PMYSQL_RES;extdecl;
  1293. mysql_stmt_param_metadata: function (stmt:PMYSQL_STMT):PMYSQL_RES;extdecl;
  1294. mysql_stmt_errno: function (stmt:PMYSQL_STMT):cuint;extdecl;
  1295. mysql_stmt_error: function (stmt:PMYSQL_STMT):Pchar;extdecl;
  1296. mysql_stmt_sqlstate: function (stmt:PMYSQL_STMT):Pchar;extdecl;
  1297. mysql_stmt_row_seek: function (stmt:PMYSQL_STMT; offset:MYSQL_ROW_OFFSET):MYSQL_ROW_OFFSET;extdecl;
  1298. mysql_stmt_row_tell: function (stmt:PMYSQL_STMT):MYSQL_ROW_OFFSET;extdecl;
  1299. mysql_stmt_data_seek: procedure (stmt:PMYSQL_STMT; offset:my_ulonglong);extdecl;
  1300. mysql_stmt_num_rows: function (stmt:PMYSQL_STMT):my_ulonglong;extdecl;
  1301. mysql_stmt_affected_rows: function (stmt:PMYSQL_STMT):my_ulonglong;extdecl;
  1302. mysql_stmt_insert_id: function (stmt:PMYSQL_STMT):my_ulonglong;extdecl;
  1303. mysql_stmt_field_count: function (stmt:PMYSQL_STMT):cuint;extdecl;
  1304. {$ENDIF}
  1305. { status return codes }
  1306. const
  1307. MYSQL_NO_DATA = 100;
  1308. MYSQL_DATA_TRUNCATED = 101;
  1309. function mysql_reload(mysql : PMySQL) : cint;
  1310. {$IFNDEF LinkDynamically}
  1311. {$ifdef USE_OLD_FUNCTIONS}
  1312. function mysql_connect(mysql:PMYSQL; host:Pchar; user:Pchar; passwd:Pchar):PMYSQL;extdecl;external External_library name 'mysql_connect';
  1313. function mysql_create_db(mysql:PMYSQL; DB:Pchar):cint;extdecl;external External_library name 'mysql_create_db';
  1314. function mysql_drop_db(mysql:PMYSQL; DB:Pchar):cint;extdecl;external External_library name 'mysql_drop_db';
  1315. function mysql_reload(mysql : PMySQL) : cint;
  1316. {$endif}
  1317. {$endif}
  1318. {$define HAVE_MYSQL_REAL_CONNECT}
  1319. { The following functions are mainly exported because of mysqlbinlog;
  1320. They are not for general usage }
  1321. function simple_command(mysql,command,arg,length,skip_check : cint) : cint;
  1322. {$IFNDEF LinkDynamically}
  1323. function net_safe_read(mysql:PMYSQL):cuint;cdecl;external mysqllib name 'net_safe_read';
  1324. {$ENDIF}
  1325. {$ifdef NETWARE}
  1326. (** unsupported pragma#pragma pack(pop) /* restore alignment */*)
  1327. {$endif}
  1328. {$IFDEF LinkDynamically}
  1329. Function InitialiseMysql(Const LibraryName : String) : Integer;
  1330. Function InitialiseMysql : Integer;
  1331. Procedure ReleaseMysql;
  1332. var MysqlLibraryHandle : TLibHandle;
  1333. {$ENDIF}
  1334. implementation
  1335. {$IFDEF LinkDynamically}
  1336. ResourceString
  1337. SErrAlreadyLoaded = 'MySQL interface already initialized from library %s.';
  1338. SErrLoadFailed = 'Can not load MySQL library "%s". Please check your installation.';
  1339. SErrDefaultsFailed = 'Can not load default MySQL library ("%s" or "%s"). Check your installation.';
  1340. var
  1341. RefCount : integer;
  1342. LoadedLibrary : String;
  1343. Function TryInitialiseMysql(Const LibraryName : String) : Integer;
  1344. begin
  1345. Result := 0;
  1346. if (RefCount=0) then
  1347. begin
  1348. MysqlLibraryHandle := loadlibrary(LibraryName);
  1349. if (MysqlLibraryHandle=nilhandle) then
  1350. Exit;
  1351. Inc(RefCount);
  1352. LoadedLibrary:=LibraryName;
  1353. // Only the procedure that are given in the c-library documentation are loaded, to
  1354. // avoid problems with 'incomplete' libraries
  1355. pointer(my_init) := GetProcedureAddress(MysqlLibraryHandle,'my_init');
  1356. pointer(my_thread_init) := GetProcedureAddress(MysqlLibraryHandle,'my_thread_init');
  1357. pointer(my_thread_end) := GetProcedureAddress(MysqlLibraryHandle,'my_thread_end');
  1358. pointer(mysql_affected_rows) := GetProcedureAddress(MysqlLibraryHandle,'mysql_affected_rows');
  1359. pointer(mysql_autocommit) := GetProcedureAddress(MysqlLibraryHandle,'mysql_autocommit');
  1360. pointer(mysql_change_user) := GetProcedureAddress(MysqlLibraryHandle,'mysql_change_user');
  1361. // pointer(mysql_charset_name) := GetProcedureAddress(MysqlLibraryHandle,'mysql_charset_name');
  1362. pointer(mysql_close) := GetProcedureAddress(MysqlLibraryHandle,'mysql_close');
  1363. pointer(mysql_commit) := GetProcedureAddress(MysqlLibraryHandle,'mysql_commit');
  1364. // pointer(mysql_connect) := GetProcedureAddress(MysqlLibraryHandle,'mysql_connect');
  1365. // pointer(mysql_create_db) := GetProcedureAddress(MysqlLibraryHandle,'mysql_create_db');
  1366. pointer(mysql_data_seek) := GetProcedureAddress(MysqlLibraryHandle,'mysql_data_seek');
  1367. // pointer(mysql_drop_db) := GetProcedureAddress(MysqlLibraryHandle,'mysql_drop_db');
  1368. pointer(mysql_debug) := GetProcedureAddress(MysqlLibraryHandle,'mysql_debug');
  1369. pointer(mysql_dump_debug_info) := GetProcedureAddress(MysqlLibraryHandle,'mysql_dump_debug_info');
  1370. pointer(mysql_eof) := GetProcedureAddress(MysqlLibraryHandle,'mysql_eof');
  1371. pointer(mysql_errno) := GetProcedureAddress(MysqlLibraryHandle,'mysql_errno');
  1372. pointer(mysql_error) := GetProcedureAddress(MysqlLibraryHandle,'mysql_error');
  1373. pointer(mysql_escape_string) := GetProcedureAddress(MysqlLibraryHandle,'mysql_escape_string');
  1374. pointer(mysql_fetch_field) := GetProcedureAddress(MysqlLibraryHandle,'mysql_fetch_field');
  1375. pointer(mysql_fetch_field_direct) := GetProcedureAddress(MysqlLibraryHandle,'mysql_fetch_field_direct');
  1376. pointer(mysql_fetch_fields) := GetProcedureAddress(MysqlLibraryHandle,'mysql_fetch_fields');
  1377. pointer(mysql_fetch_lengths) := GetProcedureAddress(MysqlLibraryHandle,'mysql_fetch_lengths');
  1378. pointer(mysql_fetch_row) := GetProcedureAddress(MysqlLibraryHandle,'mysql_fetch_row');
  1379. pointer(mysql_field_seek) := GetProcedureAddress(MysqlLibraryHandle,'mysql_field_seek');
  1380. pointer(mysql_field_count) := GetProcedureAddress(MysqlLibraryHandle,'mysql_field_count');
  1381. pointer(mysql_field_tell) := GetProcedureAddress(MysqlLibraryHandle,'mysql_field_tell');
  1382. pointer(mysql_free_result) := GetProcedureAddress(MysqlLibraryHandle,'mysql_free_result');
  1383. pointer(mysql_get_client_info) := GetProcedureAddress(MysqlLibraryHandle,'mysql_get_client_info');
  1384. pointer(mysql_get_client_version) := GetProcedureAddress(MysqlLibraryHandle,'mysql_get_client_version');
  1385. pointer(mysql_get_host_info) := GetProcedureAddress(MysqlLibraryHandle,'mysql_get_host_info');
  1386. pointer(mysql_get_server_version) := GetProcedureAddress(MysqlLibraryHandle,'mysql_get_server_version');
  1387. pointer(mysql_get_proto_info) := GetProcedureAddress(MysqlLibraryHandle,'mysql_get_proto_info');
  1388. pointer(mysql_get_server_info) := GetProcedureAddress(MysqlLibraryHandle,'mysql_get_server_info');
  1389. pointer(mysql_info) := GetProcedureAddress(MysqlLibraryHandle,'mysql_info');
  1390. pointer(mysql_init) := GetProcedureAddress(MysqlLibraryHandle,'mysql_init');
  1391. pointer(mysql_insert_id) := GetProcedureAddress(MysqlLibraryHandle,'mysql_insert_id');
  1392. pointer(mysql_kill) := GetProcedureAddress(MysqlLibraryHandle,'mysql_kill');
  1393. pointer(mysql_library_end) := GetProcedureAddress(MysqlLibraryHandle,'mysql_server_end');
  1394. pointer(mysql_library_init) := GetProcedureAddress(MysqlLibraryHandle,'mysql_server_init');
  1395. pointer(mysql_list_dbs) := GetProcedureAddress(MysqlLibraryHandle,'mysql_list_dbs');
  1396. pointer(mysql_list_fields) := GetProcedureAddress(MysqlLibraryHandle,'mysql_list_fields');
  1397. pointer(mysql_list_processes) := GetProcedureAddress(MysqlLibraryHandle,'mysql_list_processes');
  1398. pointer(mysql_list_tables) := GetProcedureAddress(MysqlLibraryHandle,'mysql_list_tables');
  1399. pointer(mysql_more_results) := GetProcedureAddress(MysqlLibraryHandle,'mysql_more_results');
  1400. pointer(mysql_next_result) := GetProcedureAddress(MysqlLibraryHandle,'mysql_next_result');
  1401. pointer(mysql_num_fields) := GetProcedureAddress(MysqlLibraryHandle,'mysql_num_fields');
  1402. pointer(mysql_num_rows) := GetProcedureAddress(MysqlLibraryHandle,'mysql_num_rows');
  1403. pointer(mysql_options) := GetProcedureAddress(MysqlLibraryHandle,'mysql_options');
  1404. pointer(mysql_ping) := GetProcedureAddress(MysqlLibraryHandle,'mysql_ping');
  1405. pointer(mysql_query) := GetProcedureAddress(MysqlLibraryHandle,'mysql_query');
  1406. pointer(mysql_real_connect) := GetProcedureAddress(MysqlLibraryHandle,'mysql_real_connect');
  1407. pointer(mysql_real_escape_string) := GetProcedureAddress(MysqlLibraryHandle,'mysql_real_escape_string');
  1408. pointer(mysql_real_query) := GetProcedureAddress(MysqlLibraryHandle,'mysql_real_query');
  1409. pointer(mysql_refresh) := GetProcedureAddress(MysqlLibraryHandle,'mysql_refresh');
  1410. // pointer(mysql_reload) := GetProcedureAddress(MysqlLibraryHandle,'mysql_reload');
  1411. pointer(mysql_rollback) := GetProcedureAddress(MysqlLibraryHandle,'mysql_rollback');
  1412. pointer(mysql_row_seek) := GetProcedureAddress(MysqlLibraryHandle,'mysql_row_seek');
  1413. pointer(mysql_row_tell) := GetProcedureAddress(MysqlLibraryHandle,'mysql_row_tell');
  1414. pointer(mysql_select_db) := GetProcedureAddress(MysqlLibraryHandle,'mysql_select_db');
  1415. pointer(mysql_server_end) := GetProcedureAddress(MysqlLibraryHandle,'mysql_server_end');
  1416. pointer(mysql_server_init) := GetProcedureAddress(MysqlLibraryHandle,'mysql_server_init');
  1417. pointer(mysql_set_server_option) := GetProcedureAddress(MysqlLibraryHandle,'mysql_set_server_option');
  1418. pointer(mysql_sqlstate) := GetProcedureAddress(MysqlLibraryHandle,'mysql_sqlstate');
  1419. pointer(mysql_shutdown) := GetProcedureAddress(MysqlLibraryHandle,'mysql_shutdown');
  1420. pointer(mysql_stat) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stat');
  1421. pointer(mysql_store_result) := GetProcedureAddress(MysqlLibraryHandle,'mysql_store_result');
  1422. pointer(mysql_thread_id) := GetProcedureAddress(MysqlLibraryHandle,'mysql_thread_id');
  1423. // pointer(mysql_thread_save) := GetProcedureAddress(MysqlLibraryHandle,'mysql_thread_save');
  1424. pointer(mysql_use_result) := GetProcedureAddress(MysqlLibraryHandle,'mysql_use_result');
  1425. pointer(mysql_warning_count) := GetProcedureAddress(MysqlLibraryHandle,'mysql_warning_count');
  1426. pointer(mysql_stmt_init) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_init');
  1427. pointer(mysql_stmt_prepare) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_prepare');
  1428. pointer(mysql_stmt_execute) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_execute');
  1429. pointer(mysql_stmt_fetch) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_fetch');
  1430. pointer(mysql_stmt_fetch_column) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_fetch_column');
  1431. pointer(mysql_stmt_store_result) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_store_result');
  1432. pointer(mysql_stmt_param_count) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_param_count');
  1433. pointer(mysql_stmt_attr_set) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_attr_set');
  1434. pointer(mysql_stmt_attr_get) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_attr_get');
  1435. pointer(mysql_stmt_bind_param) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_bind_param');
  1436. pointer(mysql_stmt_bind_result) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_bind_result');
  1437. pointer(mysql_stmt_close) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_close');
  1438. pointer(mysql_stmt_reset) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_reset');
  1439. pointer(mysql_stmt_free_result) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_free_result');
  1440. pointer(mysql_stmt_send_long_data) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_send_long_data');
  1441. pointer(mysql_stmt_result_metadata) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_result_metadata');
  1442. pointer(mysql_stmt_param_metadata) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_param_metadata');
  1443. pointer(mysql_stmt_errno) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_errno');
  1444. pointer(mysql_stmt_error) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_error');
  1445. pointer(mysql_stmt_sqlstate) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_sqlstate');
  1446. pointer(mysql_stmt_row_seek) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_row_seek');
  1447. pointer(mysql_stmt_row_tell) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_row_tell');
  1448. pointer(mysql_stmt_data_seek) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_data_seek');
  1449. pointer(mysql_stmt_num_rows) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_num_rows');
  1450. pointer(mysql_stmt_affected_rows) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_affected_rows');
  1451. pointer(mysql_stmt_insert_id) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_insert_id');
  1452. pointer(mysql_stmt_field_count) := GetProcedureAddress(MysqlLibraryHandle,'mysql_stmt_field_count');
  1453. end
  1454. else
  1455. inc(RefCount);
  1456. Result:=RefCount;
  1457. end;
  1458. Function InitialiseMysql : Integer;
  1459. begin
  1460. Result := 0;
  1461. If (TryInitialiseMysql(mysqlvlib) = 0) and
  1462. (TryInitialiseMysql(mysqllib) = 0) then
  1463. Raise EInOutError.CreateFmt(SErrDefaultsFailed,[mysqlvlib,mysqllib]);
  1464. Result := RefCount;
  1465. end;
  1466. Function InitialiseMysql(Const LibraryName : String) : Integer;
  1467. begin
  1468. Result := TryInitialiseMysql(LibraryName);
  1469. If Result = 0 then
  1470. Raise EInOutError.CreateFmt(SErrLoadFailed,[LibraryName])
  1471. else If (LibraryName<>LoadedLibrary) then
  1472. begin
  1473. Dec(RefCount);
  1474. Result := RefCount;
  1475. Raise EInOUtError.CreateFmt(SErrAlreadyLoaded,[LoadedLibrary]);
  1476. end;
  1477. end;
  1478. Procedure ReleaseMysql;
  1479. begin
  1480. if RefCount> 1 then
  1481. Dec(RefCount)
  1482. else if UnloadLibrary(MysqlLibraryHandle) then
  1483. begin
  1484. Dec(RefCount);
  1485. MysqlLibraryHandle := NilHandle;
  1486. LoadedLibrary:='';
  1487. end;
  1488. end;
  1489. {$ENDIF}
  1490. function net_new_transaction(net : st_net) : st_net;
  1491. begin
  1492. net.pkt_nr := 0;
  1493. result := net;
  1494. end;
  1495. function IS_PRI_KEY(n : longint) : boolean;
  1496. begin
  1497. IS_PRI_KEY:=(n and PRI_KEY_FLAG)<>0;
  1498. end;
  1499. function IS_NOT_NULL(n : longint) : boolean;
  1500. begin
  1501. IS_NOT_NULL:=(n and NOT_NULL_FLAG)<>0;
  1502. end;
  1503. function IS_BLOB(n : longint) : boolean;
  1504. begin
  1505. IS_BLOB:=(n and BLOB_FLAG)<>0;
  1506. end;
  1507. function IS_NUM_FIELD(f : pst_mysql_field) : boolean;
  1508. begin
  1509. IS_NUM_FIELD:=((f^.flags) and NUM_FLAG)<>0;
  1510. end;
  1511. function IS_NUM(t : enum_field_types) : boolean;
  1512. begin
  1513. {$IFDEF mysql50}
  1514. IS_NUM := (t <= FIELD_TYPE_INT24) or (t=FIELD_TYPE_YEAR) or (t=FIELD_TYPE_NEWDECIMAL);
  1515. {$ELSE}
  1516. IS_NUM := (t <= FIELD_TYPE_INT24) or (t=FIELD_TYPE_YEAR);
  1517. {$ENDIF}
  1518. end;
  1519. function INTERNAL_NUM_FIELD(f : Pst_mysql_field) : boolean;
  1520. begin
  1521. INTERNAL_NUM_FIELD := (f^.ftype <= FIELD_TYPE_INT24) and ((f^.ftype <> FIELD_TYPE_TIMESTAMP)
  1522. or (f^.length = 14) or (f^.length=8)) or (f^.ftype=FIELD_TYPE_YEAR);
  1523. end;
  1524. function mysql_reload(mysql : PMySQL) : cint;
  1525. begin
  1526. mysql_reload:=mysql_refresh(mysql,REFRESH_GRANT);
  1527. end;
  1528. function simple_command(mysql,command,arg,length,skip_check : longint) : longint;
  1529. begin
  1530. //simple_command:=mysql^.(methods^.advanced_command)(mysqlcommandNullS0arglengthskip_check);
  1531. result := -1;
  1532. end;
  1533. end.