mysql.inc 84 KB

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