mysql.inc 105 KB

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