mysql.inc 98 KB

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