mysql.inc 100 KB

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