PageRenderTime 801ms CodeModel.GetById 317ms RepoModel.GetById 1ms app.codeStats 1ms

/addons/sourcemod/scripting/include/dbi.inc

https://bitbucket.org/kimoto/sushi
Pascal | 681 lines | 608 code | 41 blank | 32 comment | 30 complexity | 1399280ecb4bfeed954b507d4da78d17 MD5 | raw file
  1. /**
  2. * vim: set ts=4 :
  3. * =============================================================================
  4. * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
  5. * =============================================================================
  6. *
  7. * This file is part of the SourceMod/SourcePawn SDK.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it under
  10. * the terms of the GNU General Public License, version 3.0, as published by the
  11. * Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  15. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU General Public License along with
  19. * this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. * As a special exception, AlliedModders LLC gives you permission to link the
  22. * code of this program (as well as its derivative works) to "Half-Life 2," the
  23. * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
  24. * by the Valve Corporation. You must obey the GNU General Public License in
  25. * all respects for all other code used. Additionally, AlliedModders LLC grants
  26. * this exception to all derivative works. AlliedModders LLC defines further
  27. * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
  28. * or <http://www.sourcemod.net/license.php>.
  29. *
  30. * Version: $Id$
  31. */
  32. #if defined _dbi_included
  33. #endinput
  34. #endif
  35. #define _dbi_included
  36. /**
  37. * @handle Driver
  38. *
  39. * Contains information about an SQL driver.
  40. */
  41. /**
  42. * @handle Database
  43. *
  44. * Contains information about a database connection.
  45. */
  46. /**
  47. * @handle Query
  48. *
  49. * Contains information about an active query and its
  50. * result sets.
  51. */
  52. /**
  53. * @handle Statement : Query
  54. *
  55. * Extends a Query Handle and can be used as a Query Handle.
  56. * Statement Handles are for prepared queries and contain
  57. * their own function for binding parameters. Statement
  58. * Handles can be used instead of database Handles in a few
  59. * select functions.
  60. */
  61. /**
  62. * Describes a database field fetch status.
  63. */
  64. enum DBResult
  65. {
  66. DBVal_Error = 0, /**< Column number/field is invalid. */
  67. DBVal_TypeMismatch = 1, /**< You cannot retrieve this data with this type. */
  68. DBVal_Null = 2, /**< Field has no data (NULL) */
  69. DBVal_Data = 3, /**< Field has data */
  70. };
  71. /**
  72. * Describes binding types.
  73. */
  74. enum DBBindType
  75. {
  76. DBBind_Int = 0, /**< Bind an integer. */
  77. DBBind_Float = 1, /**< Bind a float. */
  78. DBBind_String = 2, /**< Bind a string. */
  79. };
  80. /**
  81. * Threading priority level.
  82. */
  83. enum DBPriority
  84. {
  85. DBPrio_High = 0, /**< High priority. */
  86. DBPrio_Normal = 1, /**< Normal priority. */
  87. DBPrio_Low = 2, /**< Low priority. */
  88. };
  89. /**
  90. * Creates an SQL connection from a named configuration.
  91. *
  92. * @param confname Named configuration.
  93. * @param persistent True to re-use a previous persistent connection if
  94. * possible, false otherwise.
  95. * @param error Error buffer.
  96. * @param maxlength Maximum length of the error buffer.
  97. * @return A database connection Handle, or INVALID_HANDLE on failure.
  98. */
  99. native Handle:SQL_Connect(const String:confname[], bool:persistent, String:error[], maxlength);
  100. /**
  101. * Creates a default SQL connection.
  102. *
  103. * @param error Error buffer.
  104. * @param maxlength Maximum length of the error buffer.
  105. * @param persistent True to re-use a previous persistent connection
  106. * if possible, false otherwise.
  107. * @return A database connection Handle, or INVALID_HANDLE on failure.
  108. * On failure the error buffer will be filled with a message.
  109. */
  110. stock Handle:SQL_DefConnect(String:error[], maxlength, bool:persistent=true)
  111. {
  112. return SQL_Connect("default", persistent, error, maxlength);
  113. }
  114. /**
  115. * Connects to a database using key value pairs containing the database info.
  116. * The key/value pairs should match what would be in databases.cfg.
  117. *
  118. * I.e. "driver" should be "default" or a driver name (or ommitted for
  119. * the default). For SQLite, only the "database" parameter is needed in addition.
  120. * For drivers which require external connections, more of the parameters may be
  121. * needed.
  122. *
  123. * In general it is discouraged to use this function. Connections should go through
  124. * databases.cfg for greatest flexibility on behalf of users.
  125. *
  126. * @param keyvalues Key/value pairs from a KeyValues handle, describing the connection.
  127. * @param error Error buffer.
  128. * @param maxlength Maximum length of the error buffer.
  129. * @return A database connection Handle, or INVALID_HANDLE on failure.
  130. * On failure the error buffer will be filled with a message.
  131. * @error Invalid KeyValues handle.
  132. */
  133. native Handle:SQL_ConnectCustom(Handle:keyvalues,
  134. String:error[],
  135. maxlength,
  136. bool:persistent);
  137. /**
  138. * Grabs a handle to an SQLite database, creating one if it does not exist.
  139. *
  140. * Unless there are extenuating circumstances, you should consider using "sourcemod-local" as the
  141. * database name. This provides some unification between plugins on behalf of users.
  142. *
  143. * As a precaution, you should always create some sort of unique prefix to your table names so
  144. * there are no conflicts, and you should never drop or modify tables that you do not own.
  145. *
  146. * @param database Database name.
  147. * @param error Error buffer.
  148. * @param maxlength Maximum length of the error buffer.
  149. * @return A database connection Handle, or INVALID_HANDLE on failure.
  150. * On failure the error buffer will be filled with a message.
  151. */
  152. stock Handle:SQLite_UseDatabase(const String:database[],
  153. String:error[],
  154. maxlength)
  155. {
  156. new Handle:kv, Handle:db;
  157. kv = CreateKeyValues("");
  158. KvSetString(kv, "driver", "sqlite");
  159. KvSetString(kv, "database", database);
  160. db = SQL_ConnectCustom(kv, error, maxlength, false);
  161. CloseHandle(kv);
  162. return db;
  163. }
  164. /**
  165. * This function is deprecated. Use SQL_ConnectCustom or SQLite_UseDatabase instead.
  166. */
  167. #pragma deprecated Use SQL_ConnectCustom instead.
  168. native Handle:SQL_ConnectEx(Handle:driver,
  169. const String:host[],
  170. const String:user[],
  171. const String:pass[],
  172. const String:database[],
  173. String:error[],
  174. maxlength,
  175. bool:persistent=true,
  176. port=0,
  177. maxTimeout=0);
  178. /**
  179. * Returns if a named configuration is present in databases.cfg.
  180. *
  181. * @param name Configuration name.
  182. * @return True if it exists, false otherwise.
  183. */
  184. native bool:SQL_CheckConfig(const String:name[]);
  185. /**
  186. * Returns a driver Handle from a name string.
  187. *
  188. * If the driver is not found, SourceMod will attempt
  189. * to load an extension named dbi.<name>.ext.[dll|so].
  190. *
  191. * @param name Driver identification string, or an empty
  192. * string to return the default driver.
  193. * @return Driver Handle, or INVALID_HANDLE on failure.
  194. */
  195. native Handle:SQL_GetDriver(const String:name[]="");
  196. /**
  197. * Reads the driver of an opened database.
  198. *
  199. * @param database Database Handle.
  200. * @param ident Option buffer to store the identification string.
  201. * @param ident_length Maximum length of the buffer.
  202. * @return Driver Handle.
  203. */
  204. native Handle:SQL_ReadDriver(Handle:database, String:ident[]="", ident_length=0);
  205. /**
  206. * Retrieves a driver's identification string.
  207. *
  208. * Example: "mysql", "sqlite"
  209. *
  210. * @param driver Driver Handle, or INVALID_HANDLE for the default driver.
  211. * @param ident Identification string buffer.
  212. * @param maxlength Maximum length of the buffer.
  213. * @noreturn
  214. * @error Invalid Handle other than INVALID_HANDLE.
  215. */
  216. native SQL_GetDriverIdent(Handle:driver, String:ident[], maxlength);
  217. /**
  218. * Retrieves a driver's product string.
  219. *
  220. * Example: "MySQL", "SQLite"
  221. *
  222. * @param driver Driver Handle, or INVALID_HANDLE for the default driver.
  223. * @param product Product string buffer.
  224. * @param maxlength Maximum length of the buffer.
  225. * @noreturn
  226. * @error Invalid Handle other than INVALID_HANDLE.
  227. */
  228. native SQL_GetDriverProduct(Handle:driver, String:product[], maxlength);
  229. /**
  230. * Returns the number of affected rows from the last query.
  231. *
  232. * @param hndl A database OR statement Handle.
  233. * @return Number of rows affected by the last query.
  234. * @error Invalid database or statement Handle.
  235. */
  236. native SQL_GetAffectedRows(Handle:hndl);
  237. /**
  238. * Returns the last query's insertion id.
  239. *
  240. * @param hndl A database, query, OR statement Handle.
  241. * @return Last query's insertion id.
  242. * @error Invalid database, query, or statement Handle.
  243. */
  244. native SQL_GetInsertId(Handle:hndl);
  245. /**
  246. * Returns the error reported by the last query.
  247. *
  248. * @param hndl A database, query, OR statement Handle.
  249. * @param error Error buffer.
  250. * @param maxlength Maximum length of the buffer.
  251. * @return True if there was an error, false otherwise.
  252. * @error Invalid database, query, or statement Handle.
  253. */
  254. native bool:SQL_GetError(Handle:hndl, String:error[], maxlength);
  255. /**
  256. * Escapes a database string for literal insertion. This is not needed
  257. * for binding strings in prepared statements.
  258. *
  259. * Generally, database strings are inserted into queries enclosed in
  260. * single quotes ('). If user input has a single quote in it, the
  261. * quote needs to be escaped. This function ensures that any unsafe
  262. * characters are safely escaped according to the database engine and
  263. * the database's character set.
  264. *
  265. * NOTE: SourceMod only guarantees properly escaped strings when the query
  266. * encloses the string in ''. While drivers tend to allow " instead, the string
  267. * may be not be escaped (for example, on SQLite)!
  268. *
  269. * @param hndl A database Handle.
  270. * @param string String to quote.
  271. * @param buffer Buffer to store quoted string in.
  272. * @param maxlength Maximum length of the buffer.
  273. * @param written Optionally returns the number of bytes written.
  274. * @return True on success, false if buffer is not big enough.
  275. * The buffer must be at least 2*strlen(string)+1.
  276. * @error Invalid database or statement Handle.
  277. */
  278. native bool:SQL_EscapeString(Handle:database,
  279. const String:string[],
  280. String:buffer[],
  281. maxlength,
  282. &written=0);
  283. /**
  284. * This is a backwards compatibility stock. You should use SQL_EscapeString()
  285. * instead, as this function will probably be deprecated in SourceMod 1.1.
  286. */
  287. stock bool:SQL_QuoteString(Handle:database,
  288. const String:string[],
  289. String:buffer[],
  290. maxlength,
  291. &written=0)
  292. {
  293. return SQL_EscapeString(database, string, buffer, maxlength, written);
  294. }
  295. /**
  296. * Executes a query and ignores the result set.
  297. *
  298. * @param database A database Handle.
  299. * @param query Query string.
  300. * @param len Optional parameter to specify the query length, in
  301. * bytes. This can be used to send binary queries that
  302. * have a premature terminator.
  303. * @return True if query succeeded, false otherwise. Use
  304. * SQL_GetError to find the last error.
  305. * @error Invalid database Handle.
  306. */
  307. native bool:SQL_FastQuery(Handle:database, const String:query[], len=-1);
  308. /**
  309. * Executes a simple query and returns a new query Handle for
  310. * receiving the results.
  311. *
  312. * @param database A database Handle.
  313. * @param query Query string.
  314. * @param len Optional parameter to specify the query length, in
  315. * bytes. This can be used to send binary queries that
  316. * have a premature terminator.
  317. * @return A new Query Handle on success, INVALID_HANDLE
  318. * otherwise. The Handle must be freed with CloseHandle().
  319. * @error Invalid database Handle.
  320. */
  321. native Handle:SQL_Query(Handle:database, const String:query[], len=-1);
  322. /**
  323. * Creates a new prepared statement query. Prepared statements can
  324. * be executed any number of times. They can also have placeholder
  325. * parameters, similar to variables, which can be bound safely and
  326. * securely (for example, you do not need to quote bound strings).
  327. *
  328. * Statement handles will work in any function that accepts a Query handle.
  329. *
  330. * @param database A database Handle.
  331. * @param query Query string.
  332. * @param error Error buffer.
  333. * @param maxlength Maximum size of the error buffer.
  334. * @return A new statement Handle on success, INVALID_HANDLE
  335. * otherwise. The Handle must be freed with CloseHandle().
  336. * @error Invalid database Handle.
  337. */
  338. native Handle:SQL_PrepareQuery(Handle:database, const String:query[], String:error[], maxlength);
  339. /**
  340. * Advances to the next set of results.
  341. *
  342. * In some SQL implementations, multiple result sets can exist on one query.
  343. * This is possible in MySQL with simple queries when executing a CALL
  344. * query. If this is the case, all result sets must be processed before
  345. * another query is made.
  346. *
  347. * @param query A query Handle.
  348. * @return True if there was another result set, false otherwise.
  349. * @error Invalid query Handle.
  350. */
  351. native bool:SQL_FetchMoreResults(Handle:query);
  352. /**
  353. * Returns whether or not a result set exists. This will
  354. * return true even if 0 results were returned, but false
  355. * on queries like UPDATE, INSERT, or DELETE.
  356. *
  357. * @param query A query (or statement) Handle.
  358. * @return True if there is a result set, false otherwise.
  359. * @error Invalid query Handle.
  360. */
  361. native bool:SQL_HasResultSet(Handle:query);
  362. /**
  363. * Retrieves the number of rows in the last result set.
  364. *
  365. * @param query A query (or statement) Handle.
  366. * @return Number of rows in the current result set.
  367. * @error Invalid query Handle.
  368. */
  369. native SQL_GetRowCount(Handle:query);
  370. /**
  371. * Retrieves the number of fields in the last result set.
  372. *
  373. * @param query A query (or statement) Handle.
  374. * @return Number of fields in the current result set.
  375. * @error Invalid query Handle.
  376. */
  377. native SQL_GetFieldCount(Handle:query);
  378. /**
  379. * Retrieves the name of a field by index.
  380. *
  381. * @param query A query (or statement) Handle.
  382. * @param field Field number (starting from 0).
  383. * @param name Name buffer.
  384. * @param maxlength Maximum length of the name buffer.
  385. * @noreturn
  386. * @error Invalid query Handle, invalid field index, or
  387. * no current result set.
  388. */
  389. native SQL_FieldNumToName(Handle:query, field, String:name[], maxlength);
  390. /**
  391. * Retrieves a field index by name.
  392. *
  393. * @param query A query (or statement) Handle.
  394. * @param name Name of the field (case sensitive).
  395. * @param field Variable to store field index in.
  396. * @return True if found, false if not found.
  397. * @error Invalid query Handle or no current result set.
  398. */
  399. native bool:SQL_FieldNameToNum(Handle:query, const String:name[], &field);
  400. /**
  401. * Fetches a row from the current result set. This must be
  402. * successfully called before any results are fetched.
  403. *
  404. * If this function fails, SQL_MoreResults() can be used to
  405. * tell if there was an error or the result set is finished.
  406. *
  407. * @param query A query (or statement) Handle.
  408. * @return True if a row was fetched, false otherwise.
  409. * @error Invalid query Handle.
  410. */
  411. native bool:SQL_FetchRow(Handle:query);
  412. /**
  413. * Returns if there are more rows.
  414. *
  415. * @param query A query (or statement) Handle.
  416. * @return True if there are more rows, false otherwise.
  417. * @error Invalid query Handle.
  418. */
  419. native bool:SQL_MoreRows(Handle:query);
  420. /**
  421. * Rewinds a result set back to the first result.
  422. *
  423. * @param query A query (or statement) Handle.
  424. * @return True on success, false otherwise.
  425. * @error Invalid query Handle or no current result set.
  426. */
  427. native bool:SQL_Rewind(Handle:query);
  428. /**
  429. * Fetches a string from a field in the current row of a result set.
  430. * If the result is NULL, an empty string will be returned. A NULL
  431. * check can be done with the result parameter, or SQL_IsFieldNull().
  432. *
  433. * @param query A query (or statement) Handle.
  434. * @param field The field index (starting from 0).
  435. * @param buffer String buffer.
  436. * @param maxlength Maximum size of the string buffer.
  437. * @param result Optional variable to store the status of the return value.
  438. * @return Number of bytes written.
  439. * @error Invalid query Handle or field index, invalid
  440. * type conversion requested from the database,
  441. * or no current result set.
  442. */
  443. native SQL_FetchString(Handle:query, field, String:buffer[], maxlength, &DBResult:result=DBVal_Error);
  444. /**
  445. * Fetches a float from a field in the current row of a result set.
  446. * If the result is NULL, a value of 0.0 will be returned. A NULL
  447. * check can be done with the result parameter, or SQL_IsFieldNull().
  448. *
  449. * @param query A query (or statement) Handle.
  450. * @param field The field index (starting from 0).
  451. * @param result Optional variable to store the status of the return value.
  452. * @return A float value.
  453. * @error Invalid query Handle or field index, invalid
  454. * type conversion requested from the database,
  455. * or no current result set.
  456. */
  457. native Float:SQL_FetchFloat(Handle:query, field, &DBResult:result=DBVal_Error);
  458. /**
  459. * Fetches an integer from a field in the current row of a result set.
  460. * If the result is NULL, a value of 0 will be returned. A NULL
  461. * check can be done with the result parameter, or SQL_IsFieldNull().
  462. *
  463. * @param query A query (or statement) Handle.
  464. * @param field The field index (starting from 0).
  465. * @param result Optional variable to store the status of the return value.
  466. * @return An integer value.
  467. * @error Invalid query Handle or field index, invalid
  468. * type conversion requested from the database,
  469. * or no current result set.
  470. */
  471. native SQL_FetchInt(Handle:query, field, &DBResult:result=DBVal_Error);
  472. /**
  473. * Returns whether a field's data in the current row of a result set is
  474. * NULL or not. NULL is an SQL type which means "no data."
  475. *
  476. * @param query A query (or statement) Handle.
  477. * @param field The field index (starting from 0).
  478. * @return True if data is NULL, false otherwise.
  479. * @error Invalid query Handle or field index, or no
  480. * current result set.
  481. */
  482. native bool:SQL_IsFieldNull(Handle:query, field);
  483. /**
  484. * Returns the length of a field's data in the current row of a result
  485. * set. This only needs to be called for strings to determine how many
  486. * bytes to use. Note that the return value does not include the null
  487. * terminator.
  488. *
  489. * @param query A query (or statement) Handle.
  490. * @param field The field index (starting from 0).
  491. * @return Number of bytes for the field's data size.
  492. * @error Invalid query Handle or field index or no
  493. * current result set.
  494. */
  495. native SQL_FetchSize(Handle:query, field);
  496. /**
  497. * Binds a parameter in a prepared statement to a given integer value.
  498. *
  499. * @param statement A statement (prepared query) Handle.
  500. * @param param The parameter index (starting from 0).
  501. * @param number The number to bind.
  502. * @param signed True to bind the number as signed, false to
  503. * bind it as unsigned.
  504. * @noreturn
  505. * @error Invalid statement Handle or parameter index, or
  506. * SQL error.
  507. */
  508. native SQL_BindParamInt(Handle:statement, param, number, bool:signed=true);
  509. /**
  510. * Binds a parameter in a prepared statement to a given float value.
  511. *
  512. * @param statement A statement (prepared query) Handle.
  513. * @param param The parameter index (starting from 0).
  514. * @param float The float number to bind.
  515. * @noreturn
  516. * @error Invalid statement Handle or parameter index, or
  517. * SQL error.
  518. */
  519. native SQL_BindParamFloat(Handle:statement, param, Float:value);
  520. /**
  521. * Binds a parameter in a prepared statement to a given string value.
  522. *
  523. * @param statement A statement (prepared query) Handle.
  524. * @param param The parameter index (starting from 0).
  525. * @param value The string to bind.
  526. * @param copy Whether or not SourceMod should copy the value
  527. * locally if necessary. If the string contents
  528. * won't change before calling SQL_Execute(), this
  529. * can be set to false for optimization.
  530. * @noreturn
  531. * @error Invalid statement Handle or parameter index, or
  532. * SQL error.
  533. */
  534. native SQL_BindParamString(Handle:statement, param, const String:value[], bool:copy);
  535. /**
  536. * Executes a prepared statement. All parameters must be bound beforehand.
  537. *
  538. * @param statement A statement (prepared query) Handle.
  539. * @return True on success, false on failure.
  540. * @error Invalid statement Handle.
  541. */
  542. native bool:SQL_Execute(Handle:statement);
  543. /**
  544. * Locks a database so threading operations will not interrupt.
  545. *
  546. * If you are using a database Handle for both threading and non-threading,
  547. * this MUST be called before doing any set of non-threading DB operations.
  548. * Otherwise you risk corrupting the database driver's memory or network
  549. * connection.
  550. *
  551. * Leaving a lock on a database and then executing a threaded query results
  552. * in a dead lock! Make sure to call SQL_UnlockDatabase()!
  553. *
  554. * If the lock cannot be acquired, the main thread will pause until the
  555. * threaded operation has concluded.
  556. *
  557. * @param database A database Handle.
  558. * @noreturn
  559. * @error Invalid database Handle.
  560. */
  561. native SQL_LockDatabase(Handle:database);
  562. /**
  563. * Unlocks a database so threading operations may continue.
  564. *
  565. * @param database A database Handle.
  566. * @noreturn
  567. * @error Invalid database Handle.
  568. */
  569. native SQL_UnlockDatabase(Handle:database);
  570. /**
  571. * General callback for threaded SQL stuff.
  572. *
  573. * @param db Parent object of the Handle (or INVALID_HANDLE if none).
  574. * @param hndl Handle to the child object (or INVALID_HANDLE if none).
  575. * @param error Error string if there was an error. The error could be
  576. * empty even if an error condition exists, so it is important
  577. * to check the actual Handle value instead.
  578. * @param data Data passed in via the original threaded invocation.
  579. * @param
  580. */
  581. functag public SQLTCallback(Handle:owner, Handle:hndl, const String:error[], any:data);
  582. /**
  583. * Tells whether two database handles both point to the same database
  584. * connection.
  585. *
  586. * @param hndl1 First database Handle.
  587. * @param hndl2 Second database Handle.
  588. * @return True if the Handles point to the same
  589. * connection, false otherwise.
  590. * @error Invalid Handle.
  591. */
  592. native bool:SQL_IsSameConnection(Handle:hndl1, Handle:hndl2);
  593. /**
  594. * Connects to a database via a thread. This can be used instead of
  595. * SQL_Connect() if you wish for non-blocking functionality.
  596. *
  597. * It is not necessary to use this to use threaded queries. However, if you
  598. * don't (or you mix threaded/non-threaded queries), you should see
  599. * SQL_LockDatabase().
  600. *
  601. * @param callback Callback; new Handle will be in hndl, owner is the driver.
  602. * If no driver was found, the owner is INVALID_HANDLE.
  603. * @param name Database name.
  604. * @noreturn
  605. */
  606. native SQL_TConnect(SQLTCallback:callback, const String:name[]="default", any:data=0);
  607. /**
  608. * Executes a simple query via a thread. The query Handle is passed through
  609. * the callback.
  610. *
  611. * The database Handle returned through the callback is always a new Handle,
  612. * and if necessary, SQL_IsSameConnection() should be used to test against
  613. * other conenctions.
  614. *
  615. * The query Handle returned through the callback is temporary and destroyed
  616. * at the end of the callback. If you need to hold onto it, use CloneHandle().
  617. *
  618. * @param database A database Handle.
  619. * @param callback Callback; database is in "owner" and the query Handle
  620. * is passed in "hndl".
  621. * @param query Query string.
  622. * @param data Extra data value to pass to the callback.
  623. * @param prio Priority queue to use.
  624. * @noreturn
  625. * @error Invalid database Handle.
  626. */
  627. native SQL_TQuery(Handle:database, SQLTCallback:callback, const String:query[], any:data=0, DBPriority:prio=DBPrio_Normal);