mysql.inc 90 KB

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