apr_dbd.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. /* Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* Overview of what this is and does:
  17. * http://www.apache.org/~niq/dbd.html
  18. */
  19. #ifndef APR_DBD_H
  20. #define APR_DBD_H
  21. #include "apu.h"
  22. #include "apr_pools.h"
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /**
  27. * @file apr_dbd.h
  28. * @brief APR-UTIL DBD library
  29. */
  30. /**
  31. * @defgroup APR_Util_DBD DBD routines
  32. * @ingroup APR_Util
  33. * @{
  34. */
  35. /**
  36. * Mapping of C to SQL types, used for prepared statements.
  37. * @remarks
  38. * For apr_dbd_p[v]query/select functions, in and out parameters are always
  39. * const char * (i.e. regular nul terminated strings). LOB types are passed
  40. * with four (4) arguments: payload, length, table and column, all as const
  41. * char *, where table and column are reserved for future use by Oracle.
  42. * @remarks
  43. * For apr_dbd_p[v]bquery/select functions, in and out parameters are
  44. * described next to each enumeration constant and are generally native binary
  45. * types or some APR data type. LOB types are passed with four (4) arguments:
  46. * payload (char*), length (apr_size_t*), table (char*) and column (char*).
  47. * Table and column are reserved for future use by Oracle.
  48. */
  49. typedef enum {
  50. APR_DBD_TYPE_NONE,
  51. APR_DBD_TYPE_TINY, /**< \%hhd : in, out: char* */
  52. APR_DBD_TYPE_UTINY, /**< \%hhu : in, out: unsigned char* */
  53. APR_DBD_TYPE_SHORT, /**< \%hd : in, out: short* */
  54. APR_DBD_TYPE_USHORT, /**< \%hu : in, out: unsigned short* */
  55. APR_DBD_TYPE_INT, /**< \%d : in, out: int* */
  56. APR_DBD_TYPE_UINT, /**< \%u : in, out: unsigned int* */
  57. APR_DBD_TYPE_LONG, /**< \%ld : in, out: long* */
  58. APR_DBD_TYPE_ULONG, /**< \%lu : in, out: unsigned long* */
  59. APR_DBD_TYPE_LONGLONG, /**< \%lld : in, out: apr_int64_t* */
  60. APR_DBD_TYPE_ULONGLONG, /**< \%llu : in, out: apr_uint64_t* */
  61. APR_DBD_TYPE_FLOAT, /**< \%f : in, out: float* */
  62. APR_DBD_TYPE_DOUBLE, /**< \%lf : in, out: double* */
  63. APR_DBD_TYPE_STRING, /**< \%s : in: char*, out: char** */
  64. APR_DBD_TYPE_TEXT, /**< \%pDt : in: char*, out: char** */
  65. APR_DBD_TYPE_TIME, /**< \%pDi : in: char*, out: char** */
  66. APR_DBD_TYPE_DATE, /**< \%pDd : in: char*, out: char** */
  67. APR_DBD_TYPE_DATETIME, /**< \%pDa : in: char*, out: char** */
  68. APR_DBD_TYPE_TIMESTAMP, /**< \%pDs : in: char*, out: char** */
  69. APR_DBD_TYPE_ZTIMESTAMP, /**< \%pDz : in: char*, out: char** */
  70. APR_DBD_TYPE_BLOB, /**< \%pDb : in: char* apr_size_t* char* char*, out: apr_bucket_brigade* */
  71. APR_DBD_TYPE_CLOB, /**< \%pDc : in: char* apr_size_t* char* char*, out: apr_bucket_brigade* */
  72. APR_DBD_TYPE_NULL /**< \%pDn : in: void*, out: void** */
  73. } apr_dbd_type_e;
  74. /* These are opaque structs. Instantiation is up to each backend */
  75. typedef struct apr_dbd_driver_t apr_dbd_driver_t;
  76. typedef struct apr_dbd_t apr_dbd_t;
  77. typedef struct apr_dbd_transaction_t apr_dbd_transaction_t;
  78. typedef struct apr_dbd_results_t apr_dbd_results_t;
  79. typedef struct apr_dbd_row_t apr_dbd_row_t;
  80. typedef struct apr_dbd_prepared_t apr_dbd_prepared_t;
  81. /** apr_dbd_init: perform once-only initialisation. Call once only.
  82. *
  83. * @param pool - pool to register any shutdown cleanups, etc
  84. */
  85. APU_DECLARE(apr_status_t) apr_dbd_init(apr_pool_t *pool);
  86. /** apr_dbd_get_driver: get the driver struct for a name
  87. *
  88. * @param pool - (process) pool to register cleanup
  89. * @param name - driver name
  90. * @param driver - pointer to driver struct.
  91. * @return APR_SUCCESS for success
  92. * @return APR_ENOTIMPL for no driver (when DSO not enabled)
  93. * @return APR_EDSOOPEN if DSO driver file can't be opened
  94. * @return APR_ESYMNOTFOUND if the driver file doesn't contain a driver
  95. */
  96. APU_DECLARE(apr_status_t) apr_dbd_get_driver(apr_pool_t *pool, const char *name,
  97. const apr_dbd_driver_t **driver);
  98. /** apr_dbd_open_ex: open a connection to a backend
  99. *
  100. * @param driver - driver struct.
  101. * @param pool - working pool
  102. * @param params - arguments to driver (implementation-dependent)
  103. * @param handle - pointer to handle to return
  104. * @param error - descriptive error.
  105. * @return APR_SUCCESS for success
  106. * @return APR_EGENERAL if driver exists but connection failed
  107. * @remarks PostgreSQL: the params is passed directly to the PQconnectdb()
  108. * function (check PostgreSQL documentation for more details on the syntax).
  109. * @remarks SQLite2: the params is split on a colon, with the first part used
  110. * as the filename and second part converted to an integer and used as file
  111. * mode.
  112. * @remarks SQLite3: the params is passed directly to the sqlite3_open()
  113. * function as a filename to be opened (check SQLite3 documentation for more
  114. * details).
  115. * @remarks Oracle: the params can have "user", "pass", "dbname" and "server"
  116. * keys, each followed by an equal sign and a value. Such key/value pairs can
  117. * be delimited by space, CR, LF, tab, semicolon, vertical bar or comma.
  118. * @remarks MySQL: the params can have "host", "port", "user", "pass",
  119. * "dbname", "sock", "flags" "fldsz", "group" and "reconnect" keys, each
  120. * followed by an equal sign and a value. Such key/value pairs can be
  121. * delimited by space, CR, LF, tab, semicolon, vertical bar or comma. For
  122. * now, "flags" can only recognise CLIENT_FOUND_ROWS (check MySQL manual for
  123. * details). The value associated with "fldsz" determines maximum amount of
  124. * memory (in bytes) for each of the fields in the result set of prepared
  125. * statements. By default, this value is 1 MB. The value associated with
  126. * "group" determines which group from configuration file to use (see
  127. * MYSQL_READ_DEFAULT_GROUP option of mysql_options() in MySQL manual).
  128. * Reconnect is set to 1 by default (i.e. true).
  129. * @remarks FreeTDS: the params can have "username", "password", "appname",
  130. * "dbname", "host", "charset", "lang" and "server" keys, each followed by an
  131. * equal sign and a value.
  132. */
  133. APU_DECLARE(apr_status_t) apr_dbd_open_ex(const apr_dbd_driver_t *driver,
  134. apr_pool_t *pool, const char *params,
  135. apr_dbd_t **handle,
  136. const char **error);
  137. /** apr_dbd_open: open a connection to a backend
  138. *
  139. * @param driver - driver struct.
  140. * @param pool - working pool
  141. * @param params - arguments to driver (implementation-dependent)
  142. * @param handle - pointer to handle to return
  143. * @return APR_SUCCESS for success
  144. * @return APR_EGENERAL if driver exists but connection failed
  145. * @see apr_dbd_open_ex
  146. */
  147. APU_DECLARE(apr_status_t) apr_dbd_open(const apr_dbd_driver_t *driver,
  148. apr_pool_t *pool, const char *params,
  149. apr_dbd_t **handle);
  150. /** apr_dbd_close: close a connection to a backend
  151. *
  152. * @param driver - driver struct.
  153. * @param handle - handle to close
  154. * @return APR_SUCCESS for success or error status
  155. */
  156. APU_DECLARE(apr_status_t) apr_dbd_close(const apr_dbd_driver_t *driver,
  157. apr_dbd_t *handle);
  158. /* apr-function-shaped versions of things */
  159. /** apr_dbd_name: get the name of the driver
  160. *
  161. * @param driver - the driver
  162. * @return - name
  163. */
  164. APU_DECLARE(const char*) apr_dbd_name(const apr_dbd_driver_t *driver);
  165. /** apr_dbd_native_handle: get native database handle of the underlying db
  166. *
  167. * @param driver - the driver
  168. * @param handle - apr_dbd handle
  169. * @return - native handle
  170. */
  171. APU_DECLARE(void*) apr_dbd_native_handle(const apr_dbd_driver_t *driver,
  172. apr_dbd_t *handle);
  173. /** check_conn: check status of a database connection
  174. *
  175. * @param driver - the driver
  176. * @param pool - working pool
  177. * @param handle - the connection to check
  178. * @return APR_SUCCESS or error
  179. */
  180. APU_DECLARE(int) apr_dbd_check_conn(const apr_dbd_driver_t *driver, apr_pool_t *pool,
  181. apr_dbd_t *handle);
  182. /** apr_dbd_set_dbname: select database name. May be a no-op if not supported.
  183. *
  184. * @param driver - the driver
  185. * @param pool - working pool
  186. * @param handle - the connection
  187. * @param name - the database to select
  188. * @return 0 for success or error code
  189. */
  190. APU_DECLARE(int) apr_dbd_set_dbname(const apr_dbd_driver_t *driver, apr_pool_t *pool,
  191. apr_dbd_t *handle, const char *name);
  192. /** apr_dbd_transaction_start: start a transaction. May be a no-op.
  193. *
  194. * @param driver - the driver
  195. * @param pool - a pool to use for error messages (if any).
  196. * @param handle - the db connection
  197. * @param trans - ptr to a transaction. May be null on entry
  198. * @return 0 for success or error code
  199. * @remarks Note that transaction modes, set by calling
  200. * apr_dbd_transaction_mode_set(), will affect all query/select calls within
  201. * a transaction. By default, any error in query/select during a transaction
  202. * will cause the transaction to inherit the error code and any further
  203. * query/select calls will fail immediately. Put transaction in "ignore
  204. * errors" mode to avoid that. Use "rollback" mode to do explicit rollback.
  205. */
  206. APU_DECLARE(int) apr_dbd_transaction_start(const apr_dbd_driver_t *driver,
  207. apr_pool_t *pool,
  208. apr_dbd_t *handle,
  209. apr_dbd_transaction_t **trans);
  210. /** apr_dbd_transaction_end: end a transaction
  211. * (commit on success, rollback on error).
  212. * May be a no-op.
  213. *
  214. * @param driver - the driver
  215. * @param handle - the db connection
  216. * @param trans - the transaction.
  217. * @return 0 for success or error code
  218. */
  219. APU_DECLARE(int) apr_dbd_transaction_end(const apr_dbd_driver_t *driver,
  220. apr_pool_t *pool,
  221. apr_dbd_transaction_t *trans);
  222. #define APR_DBD_TRANSACTION_COMMIT 0x00 /**< commit the transaction */
  223. #define APR_DBD_TRANSACTION_ROLLBACK 0x01 /**< rollback the transaction */
  224. #define APR_DBD_TRANSACTION_IGNORE_ERRORS 0x02 /**< ignore transaction errors */
  225. /** apr_dbd_transaction_mode_get: get the mode of transaction
  226. *
  227. * @param driver - the driver
  228. * @param trans - the transaction
  229. * @return mode of transaction
  230. */
  231. APU_DECLARE(int) apr_dbd_transaction_mode_get(const apr_dbd_driver_t *driver,
  232. apr_dbd_transaction_t *trans);
  233. /** apr_dbd_transaction_mode_set: set the mode of transaction
  234. *
  235. * @param driver - the driver
  236. * @param trans - the transaction
  237. * @param mode - new mode of the transaction
  238. * @return the mode of transaction in force after the call
  239. */
  240. APU_DECLARE(int) apr_dbd_transaction_mode_set(const apr_dbd_driver_t *driver,
  241. apr_dbd_transaction_t *trans,
  242. int mode);
  243. /** apr_dbd_query: execute an SQL query that doesn't return a result set
  244. *
  245. * @param driver - the driver
  246. * @param handle - the connection
  247. * @param nrows - number of rows affected.
  248. * @param statement - the SQL statement to execute
  249. * @return 0 for success or error code
  250. */
  251. APU_DECLARE(int) apr_dbd_query(const apr_dbd_driver_t *driver, apr_dbd_t *handle,
  252. int *nrows, const char *statement);
  253. /** apr_dbd_select: execute an SQL query that returns a result set
  254. *
  255. * @param driver - the driver
  256. * @param pool - pool to allocate the result set
  257. * @param handle - the connection
  258. * @param res - pointer to result set pointer. May point to NULL on entry
  259. * @param statement - the SQL statement to execute
  260. * @param random - 1 to support random access to results (seek any row);
  261. * 0 to support only looping through results in order
  262. * (async access - faster)
  263. * @return 0 for success or error code
  264. */
  265. APU_DECLARE(int) apr_dbd_select(const apr_dbd_driver_t *driver, apr_pool_t *pool,
  266. apr_dbd_t *handle, apr_dbd_results_t **res,
  267. const char *statement, int random);
  268. /** apr_dbd_num_cols: get the number of columns in a results set
  269. *
  270. * @param driver - the driver
  271. * @param res - result set.
  272. * @return number of columns
  273. */
  274. APU_DECLARE(int) apr_dbd_num_cols(const apr_dbd_driver_t *driver,
  275. apr_dbd_results_t *res);
  276. /** apr_dbd_num_tuples: get the number of rows in a results set
  277. * of a synchronous select
  278. *
  279. * @param driver - the driver
  280. * @param res - result set.
  281. * @return number of rows, or -1 if the results are asynchronous
  282. */
  283. APU_DECLARE(int) apr_dbd_num_tuples(const apr_dbd_driver_t *driver,
  284. apr_dbd_results_t *res);
  285. /** apr_dbd_get_row: get a row from a result set
  286. *
  287. * @param driver - the driver
  288. * @param pool - pool to allocate the row
  289. * @param res - result set pointer
  290. * @param row - pointer to row pointer. May point to NULL on entry
  291. * @param rownum - row number (counting from 1), or -1 for "next row".
  292. * Ignored if random access is not supported.
  293. * @return 0 for success, -1 for rownum out of range or data finished
  294. */
  295. APU_DECLARE(int) apr_dbd_get_row(const apr_dbd_driver_t *driver, apr_pool_t *pool,
  296. apr_dbd_results_t *res, apr_dbd_row_t **row,
  297. int rownum);
  298. /** apr_dbd_get_entry: get an entry from a row
  299. *
  300. * @param driver - the driver
  301. * @param row - row pointer
  302. * @param col - entry number
  303. * @return value from the row, or NULL if col is out of bounds.
  304. */
  305. APU_DECLARE(const char*) apr_dbd_get_entry(const apr_dbd_driver_t *driver,
  306. apr_dbd_row_t *row, int col);
  307. /** apr_dbd_get_name: get an entry name from a result set
  308. *
  309. * @param driver - the driver
  310. * @param res - result set pointer
  311. * @param col - entry number
  312. * @return name of the entry, or NULL if col is out of bounds.
  313. */
  314. APU_DECLARE(const char*) apr_dbd_get_name(const apr_dbd_driver_t *driver,
  315. apr_dbd_results_t *res, int col);
  316. /** apr_dbd_error: get current error message (if any)
  317. *
  318. * @param driver - the driver
  319. * @param handle - the connection
  320. * @param errnum - error code from operation that returned an error
  321. * @return the database current error message, or message for errnum
  322. * (implementation-dependent whether errnum is ignored)
  323. */
  324. APU_DECLARE(const char*) apr_dbd_error(const apr_dbd_driver_t *driver,
  325. apr_dbd_t *handle, int errnum);
  326. /** apr_dbd_escape: escape a string so it is safe for use in query/select
  327. *
  328. * @param driver - the driver
  329. * @param pool - pool to alloc the result from
  330. * @param string - the string to escape
  331. * @param handle - the connection
  332. * @return the escaped, safe string
  333. */
  334. APU_DECLARE(const char*) apr_dbd_escape(const apr_dbd_driver_t *driver,
  335. apr_pool_t *pool, const char *string,
  336. apr_dbd_t *handle);
  337. /** apr_dbd_prepare: prepare a statement
  338. *
  339. * @param driver - the driver
  340. * @param pool - pool to alloc the result from
  341. * @param handle - the connection
  342. * @param query - the SQL query
  343. * @param label - A label for the prepared statement.
  344. * use NULL for temporary prepared statements
  345. * (eg within a Request in httpd)
  346. * @param statement - statement to prepare. May point to null on entry.
  347. * @return 0 for success or error code
  348. * @remarks To specify parameters of the prepared query, use \%s, \%d etc.
  349. * (see below for full list) in place of database specific parameter syntax
  350. * (e.g. for PostgreSQL, this would be $1, $2, for SQLite3 this would be ?
  351. * etc.). For instance: "SELECT name FROM customers WHERE name=%s" would be
  352. * a query that this function understands.
  353. * @remarks Here is the full list of format specifiers that this function
  354. * understands and what they map to in SQL: \%hhd (TINY INT), \%hhu (UNSIGNED
  355. * TINY INT), \%hd (SHORT), \%hu (UNSIGNED SHORT), \%d (INT), \%u (UNSIGNED
  356. * INT), \%ld (LONG), \%lu (UNSIGNED LONG), \%lld (LONG LONG), \%llu
  357. * (UNSIGNED LONG LONG), \%f (FLOAT, REAL), \%lf (DOUBLE PRECISION), \%s
  358. * (VARCHAR), \%pDt (TEXT), \%pDi (TIME), \%pDd (DATE), \%pDa (DATETIME),
  359. * \%pDs (TIMESTAMP), \%pDz (TIMESTAMP WITH TIME ZONE), \%pDb (BLOB), \%pDc
  360. * (CLOB) and \%pDn (NULL). Not all databases have support for all these
  361. * types, so the underlying driver will attempt the "best match" where
  362. * possible. A \% followed by any letter not in the above list will be
  363. * interpreted as VARCHAR (i.e. \%s).
  364. */
  365. APU_DECLARE(int) apr_dbd_prepare(const apr_dbd_driver_t *driver, apr_pool_t *pool,
  366. apr_dbd_t *handle, const char *query,
  367. const char *label,
  368. apr_dbd_prepared_t **statement);
  369. /** apr_dbd_pquery: query using a prepared statement + args
  370. *
  371. * @param driver - the driver
  372. * @param pool - working pool
  373. * @param handle - the connection
  374. * @param nrows - number of rows affected.
  375. * @param statement - the prepared statement to execute
  376. * @param nargs - ignored (for backward compatibility only)
  377. * @param args - args to prepared statement
  378. * @return 0 for success or error code
  379. */
  380. APU_DECLARE(int) apr_dbd_pquery(const apr_dbd_driver_t *driver, apr_pool_t *pool,
  381. apr_dbd_t *handle, int *nrows,
  382. apr_dbd_prepared_t *statement, int nargs,
  383. const char **args);
  384. /** apr_dbd_pselect: select using a prepared statement + args
  385. *
  386. * @param driver - the driver
  387. * @param pool - working pool
  388. * @param handle - the connection
  389. * @param res - pointer to query results. May point to NULL on entry
  390. * @param statement - the prepared statement to execute
  391. * @param random - Whether to support random-access to results
  392. * @param nargs - ignored (for backward compatibility only)
  393. * @param args - args to prepared statement
  394. * @return 0 for success or error code
  395. */
  396. APU_DECLARE(int) apr_dbd_pselect(const apr_dbd_driver_t *driver, apr_pool_t *pool,
  397. apr_dbd_t *handle, apr_dbd_results_t **res,
  398. apr_dbd_prepared_t *statement, int random,
  399. int nargs, const char **args);
  400. /** apr_dbd_pvquery: query using a prepared statement + args
  401. *
  402. * @param driver - the driver
  403. * @param pool - working pool
  404. * @param handle - the connection
  405. * @param nrows - number of rows affected.
  406. * @param statement - the prepared statement to execute
  407. * @param ... - varargs list
  408. * @return 0 for success or error code
  409. */
  410. APU_DECLARE_NONSTD(int) apr_dbd_pvquery(const apr_dbd_driver_t *driver,
  411. apr_pool_t *pool,
  412. apr_dbd_t *handle, int *nrows,
  413. apr_dbd_prepared_t *statement, ...);
  414. /** apr_dbd_pvselect: select using a prepared statement + args
  415. *
  416. * @param driver - the driver
  417. * @param pool - working pool
  418. * @param handle - the connection
  419. * @param res - pointer to query results. May point to NULL on entry
  420. * @param statement - the prepared statement to execute
  421. * @param random - Whether to support random-access to results
  422. * @param ... - varargs list
  423. * @return 0 for success or error code
  424. */
  425. APU_DECLARE_NONSTD(int) apr_dbd_pvselect(const apr_dbd_driver_t *driver,
  426. apr_pool_t *pool, apr_dbd_t *handle,
  427. apr_dbd_results_t **res,
  428. apr_dbd_prepared_t *statement,
  429. int random, ...);
  430. /** apr_dbd_pbquery: query using a prepared statement + binary args
  431. *
  432. * @param driver - the driver
  433. * @param pool - working pool
  434. * @param handle - the connection
  435. * @param nrows - number of rows affected.
  436. * @param statement - the prepared statement to execute
  437. * @param args - binary args to prepared statement
  438. * @return 0 for success or error code
  439. */
  440. APU_DECLARE(int) apr_dbd_pbquery(const apr_dbd_driver_t *driver,
  441. apr_pool_t *pool, apr_dbd_t *handle,
  442. int *nrows, apr_dbd_prepared_t *statement,
  443. const void **args);
  444. /** apr_dbd_pbselect: select using a prepared statement + binary args
  445. *
  446. * @param driver - the driver
  447. * @param pool - working pool
  448. * @param handle - the connection
  449. * @param res - pointer to query results. May point to NULL on entry
  450. * @param statement - the prepared statement to execute
  451. * @param random - Whether to support random-access to results
  452. * @param args - binary args to prepared statement
  453. * @return 0 for success or error code
  454. */
  455. APU_DECLARE(int) apr_dbd_pbselect(const apr_dbd_driver_t *driver,
  456. apr_pool_t *pool,
  457. apr_dbd_t *handle, apr_dbd_results_t **res,
  458. apr_dbd_prepared_t *statement, int random,
  459. const void **args);
  460. /** apr_dbd_pvbquery: query using a prepared statement + binary args
  461. *
  462. * @param driver - the driver
  463. * @param pool - working pool
  464. * @param handle - the connection
  465. * @param nrows - number of rows affected.
  466. * @param statement - the prepared statement to execute
  467. * @param ... - varargs list of binary args
  468. * @return 0 for success or error code
  469. */
  470. APU_DECLARE_NONSTD(int) apr_dbd_pvbquery(const apr_dbd_driver_t *driver,
  471. apr_pool_t *pool,
  472. apr_dbd_t *handle, int *nrows,
  473. apr_dbd_prepared_t *statement, ...);
  474. /** apr_dbd_pvbselect: select using a prepared statement + binary args
  475. *
  476. * @param driver - the driver
  477. * @param pool - working pool
  478. * @param handle - the connection
  479. * @param res - pointer to query results. May point to NULL on entry
  480. * @param statement - the prepared statement to execute
  481. * @param random - Whether to support random-access to results
  482. * @param ... - varargs list of binary args
  483. * @return 0 for success or error code
  484. */
  485. APU_DECLARE_NONSTD(int) apr_dbd_pvbselect(const apr_dbd_driver_t *driver,
  486. apr_pool_t *pool, apr_dbd_t *handle,
  487. apr_dbd_results_t **res,
  488. apr_dbd_prepared_t *statement,
  489. int random, ...);
  490. /** apr_dbd_datum_get: get a binary entry from a row
  491. *
  492. * @param driver - the driver
  493. * @param row - row pointer
  494. * @param col - entry number
  495. * @param type - type of data to get
  496. * @param data - pointer to data, allocated by the caller
  497. * @return APR_SUCCESS on success, APR_ENOENT if data is NULL or APR_EGENERAL
  498. */
  499. APU_DECLARE(apr_status_t) apr_dbd_datum_get(const apr_dbd_driver_t *driver,
  500. apr_dbd_row_t *row, int col,
  501. apr_dbd_type_e type, void *data);
  502. /** @} */
  503. #ifdef __cplusplus
  504. }
  505. #endif
  506. #endif