apr_dbd.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  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. */
  130. APU_DECLARE(apr_status_t) apr_dbd_open_ex(const apr_dbd_driver_t *driver,
  131. apr_pool_t *pool, const char *params,
  132. apr_dbd_t **handle,
  133. const char **error);
  134. /** apr_dbd_open: open a connection to a backend
  135. *
  136. * @param driver - driver struct.
  137. * @param pool - working pool
  138. * @param params - arguments to driver (implementation-dependent)
  139. * @param handle - pointer to handle to return
  140. * @return APR_SUCCESS for success
  141. * @return APR_EGENERAL if driver exists but connection failed
  142. * @see apr_dbd_open_ex
  143. */
  144. APU_DECLARE(apr_status_t) apr_dbd_open(const apr_dbd_driver_t *driver,
  145. apr_pool_t *pool, const char *params,
  146. apr_dbd_t **handle);
  147. /** apr_dbd_close: close a connection to a backend
  148. *
  149. * @param driver - driver struct.
  150. * @param handle - handle to close
  151. * @return APR_SUCCESS for success or error status
  152. */
  153. APU_DECLARE(apr_status_t) apr_dbd_close(const apr_dbd_driver_t *driver,
  154. apr_dbd_t *handle);
  155. /* apr-function-shaped versions of things */
  156. /** apr_dbd_name: get the name of the driver
  157. *
  158. * @param driver - the driver
  159. * @return - name
  160. */
  161. APU_DECLARE(const char*) apr_dbd_name(const apr_dbd_driver_t *driver);
  162. /** apr_dbd_native_handle: get native database handle of the underlying db
  163. *
  164. * @param driver - the driver
  165. * @param handle - apr_dbd handle
  166. * @return - native handle
  167. */
  168. APU_DECLARE(void*) apr_dbd_native_handle(const apr_dbd_driver_t *driver,
  169. apr_dbd_t *handle);
  170. /** check_conn: check status of a database connection
  171. *
  172. * @param driver - the driver
  173. * @param pool - working pool
  174. * @param handle - the connection to check
  175. * @return APR_SUCCESS or error
  176. */
  177. APU_DECLARE(int) apr_dbd_check_conn(const apr_dbd_driver_t *driver, apr_pool_t *pool,
  178. apr_dbd_t *handle);
  179. /** apr_dbd_set_dbname: select database name. May be a no-op if not supported.
  180. *
  181. * @param driver - the driver
  182. * @param pool - working pool
  183. * @param handle - the connection
  184. * @param name - the database to select
  185. * @return 0 for success or error code
  186. */
  187. APU_DECLARE(int) apr_dbd_set_dbname(const apr_dbd_driver_t *driver, apr_pool_t *pool,
  188. apr_dbd_t *handle, const char *name);
  189. /** apr_dbd_transaction_start: start a transaction. May be a no-op.
  190. *
  191. * @param driver - the driver
  192. * @param pool - a pool to use for error messages (if any).
  193. * @param handle - the db connection
  194. * @param trans - ptr to a transaction. May be null on entry
  195. * @return 0 for success or error code
  196. * @remarks Note that transaction modes, set by calling
  197. * apr_dbd_transaction_mode_set(), will affect all query/select calls within
  198. * a transaction. By default, any error in query/select during a transaction
  199. * will cause the transaction to inherit the error code and any further
  200. * query/select calls will fail immediately. Put transaction in "ignore
  201. * errors" mode to avoid that. Use "rollback" mode to do explicit rollback.
  202. */
  203. APU_DECLARE(int) apr_dbd_transaction_start(const apr_dbd_driver_t *driver,
  204. apr_pool_t *pool,
  205. apr_dbd_t *handle,
  206. apr_dbd_transaction_t **trans);
  207. /** apr_dbd_transaction_end: end a transaction
  208. * (commit on success, rollback on error).
  209. * May be a no-op.
  210. *
  211. * @param driver - the driver
  212. * @param handle - the db connection
  213. * @param trans - the transaction.
  214. * @return 0 for success or error code
  215. */
  216. APU_DECLARE(int) apr_dbd_transaction_end(const apr_dbd_driver_t *driver,
  217. apr_pool_t *pool,
  218. apr_dbd_transaction_t *trans);
  219. #define APR_DBD_TRANSACTION_COMMIT 0x00 /**< commit the transaction */
  220. #define APR_DBD_TRANSACTION_ROLLBACK 0x01 /**< rollback the transaction */
  221. #define APR_DBD_TRANSACTION_IGNORE_ERRORS 0x02 /**< ignore transaction errors */
  222. /** apr_dbd_transaction_mode_get: get the mode of transaction
  223. *
  224. * @param driver - the driver
  225. * @param trans - the transaction
  226. * @return mode of transaction
  227. */
  228. APU_DECLARE(int) apr_dbd_transaction_mode_get(const apr_dbd_driver_t *driver,
  229. apr_dbd_transaction_t *trans);
  230. /** apr_dbd_transaction_mode_set: set the mode of transaction
  231. *
  232. * @param driver - the driver
  233. * @param trans - the transaction
  234. * @param mode - new mode of the transaction
  235. * @return the mode of transaction in force after the call
  236. */
  237. APU_DECLARE(int) apr_dbd_transaction_mode_set(const apr_dbd_driver_t *driver,
  238. apr_dbd_transaction_t *trans,
  239. int mode);
  240. /** apr_dbd_query: execute an SQL query that doesn't return a result set
  241. *
  242. * @param driver - the driver
  243. * @param handle - the connection
  244. * @param nrows - number of rows affected.
  245. * @param statement - the SQL statement to execute
  246. * @return 0 for success or error code
  247. */
  248. APU_DECLARE(int) apr_dbd_query(const apr_dbd_driver_t *driver, apr_dbd_t *handle,
  249. int *nrows, const char *statement);
  250. /** apr_dbd_select: execute an SQL query that returns a result set
  251. *
  252. * @param driver - the driver
  253. * @param pool - pool to allocate the result set
  254. * @param handle - the connection
  255. * @param res - pointer to result set pointer. May point to NULL on entry
  256. * @param statement - the SQL statement to execute
  257. * @param random - 1 to support random access to results (seek any row);
  258. * 0 to support only looping through results in order
  259. * (async access - faster)
  260. * @return 0 for success or error code
  261. */
  262. APU_DECLARE(int) apr_dbd_select(const apr_dbd_driver_t *driver, apr_pool_t *pool,
  263. apr_dbd_t *handle, apr_dbd_results_t **res,
  264. const char *statement, int random);
  265. /** apr_dbd_num_cols: get the number of columns in a results set
  266. *
  267. * @param driver - the driver
  268. * @param res - result set.
  269. * @return number of columns
  270. */
  271. APU_DECLARE(int) apr_dbd_num_cols(const apr_dbd_driver_t *driver,
  272. apr_dbd_results_t *res);
  273. /** apr_dbd_num_tuples: get the number of rows in a results set
  274. * of a synchronous select
  275. *
  276. * @param driver - the driver
  277. * @param res - result set.
  278. * @return number of rows, or -1 if the results are asynchronous
  279. */
  280. APU_DECLARE(int) apr_dbd_num_tuples(const apr_dbd_driver_t *driver,
  281. apr_dbd_results_t *res);
  282. /** apr_dbd_get_row: get a row from a result set
  283. *
  284. * @param driver - the driver
  285. * @param pool - pool to allocate the row
  286. * @param res - result set pointer
  287. * @param row - pointer to row pointer. May point to NULL on entry
  288. * @param rownum - row number (counting from 1), or -1 for "next row".
  289. * Ignored if random access is not supported.
  290. * @return 0 for success, -1 for rownum out of range or data finished
  291. */
  292. APU_DECLARE(int) apr_dbd_get_row(const apr_dbd_driver_t *driver, apr_pool_t *pool,
  293. apr_dbd_results_t *res, apr_dbd_row_t **row,
  294. int rownum);
  295. /** apr_dbd_get_entry: get an entry from a row
  296. *
  297. * @param driver - the driver
  298. * @param row - row pointer
  299. * @param col - entry number
  300. * @return value from the row, or NULL if col is out of bounds.
  301. */
  302. APU_DECLARE(const char*) apr_dbd_get_entry(const apr_dbd_driver_t *driver,
  303. apr_dbd_row_t *row, int col);
  304. /** apr_dbd_get_name: get an entry name from a result set
  305. *
  306. * @param driver - the driver
  307. * @param res - result set pointer
  308. * @param col - entry number
  309. * @return name of the entry, or NULL if col is out of bounds.
  310. */
  311. APU_DECLARE(const char*) apr_dbd_get_name(const apr_dbd_driver_t *driver,
  312. apr_dbd_results_t *res, int col);
  313. /** apr_dbd_error: get current error message (if any)
  314. *
  315. * @param driver - the driver
  316. * @param handle - the connection
  317. * @param errnum - error code from operation that returned an error
  318. * @return the database current error message, or message for errnum
  319. * (implementation-dependent whether errnum is ignored)
  320. */
  321. APU_DECLARE(const char*) apr_dbd_error(const apr_dbd_driver_t *driver,
  322. apr_dbd_t *handle, int errnum);
  323. /** apr_dbd_escape: escape a string so it is safe for use in query/select
  324. *
  325. * @param driver - the driver
  326. * @param pool - pool to alloc the result from
  327. * @param string - the string to escape
  328. * @param handle - the connection
  329. * @return the escaped, safe string
  330. */
  331. APU_DECLARE(const char*) apr_dbd_escape(const apr_dbd_driver_t *driver,
  332. apr_pool_t *pool, const char *string,
  333. apr_dbd_t *handle);
  334. /** apr_dbd_prepare: prepare a statement
  335. *
  336. * @param driver - the driver
  337. * @param pool - pool to alloc the result from
  338. * @param handle - the connection
  339. * @param query - the SQL query
  340. * @param label - A label for the prepared statement.
  341. * use NULL for temporary prepared statements
  342. * (eg within a Request in httpd)
  343. * @param statement - statement to prepare. May point to null on entry.
  344. * @return 0 for success or error code
  345. * @remarks To specify parameters of the prepared query, use \%s, \%d etc.
  346. * (see below for full list) in place of database specific parameter syntax
  347. * (e.g. for PostgreSQL, this would be $1, $2, for SQLite3 this would be ?
  348. * etc.). For instance: "SELECT name FROM customers WHERE name=%s" would be
  349. * a query that this function understands.
  350. * @remarks Here is the full list of format specifiers that this function
  351. * understands and what they map to in SQL: \%hhd (TINY INT), \%hhu (UNSIGNED
  352. * TINY INT), \%hd (SHORT), \%hu (UNSIGNED SHORT), \%d (INT), \%u (UNSIGNED
  353. * INT), \%ld (LONG), \%lu (UNSIGNED LONG), \%lld (LONG LONG), \%llu
  354. * (UNSIGNED LONG LONG), \%f (FLOAT, REAL), \%lf (DOUBLE PRECISION), \%s
  355. * (VARCHAR), \%pDt (TEXT), \%pDi (TIME), \%pDd (DATE), \%pDa (DATETIME),
  356. * \%pDs (TIMESTAMP), \%pDz (TIMESTAMP WITH TIME ZONE), \%pDb (BLOB), \%pDc
  357. * (CLOB) and \%pDn (NULL). Not all databases have support for all these
  358. * types, so the underlying driver will attempt the "best match" where
  359. * possible. A \% followed by any letter not in the above list will be
  360. * interpreted as VARCHAR (i.e. \%s).
  361. */
  362. APU_DECLARE(int) apr_dbd_prepare(const apr_dbd_driver_t *driver, apr_pool_t *pool,
  363. apr_dbd_t *handle, const char *query,
  364. const char *label,
  365. apr_dbd_prepared_t **statement);
  366. /** apr_dbd_pquery: query using a prepared statement + args
  367. *
  368. * @param driver - the driver
  369. * @param pool - working pool
  370. * @param handle - the connection
  371. * @param nrows - number of rows affected.
  372. * @param statement - the prepared statement to execute
  373. * @param nargs - ignored (for backward compatibility only)
  374. * @param args - args to prepared statement
  375. * @return 0 for success or error code
  376. */
  377. APU_DECLARE(int) apr_dbd_pquery(const apr_dbd_driver_t *driver, apr_pool_t *pool,
  378. apr_dbd_t *handle, int *nrows,
  379. apr_dbd_prepared_t *statement, int nargs,
  380. const char **args);
  381. /** apr_dbd_pselect: select using a prepared statement + args
  382. *
  383. * @param driver - the driver
  384. * @param pool - working pool
  385. * @param handle - the connection
  386. * @param res - pointer to query results. May point to NULL on entry
  387. * @param statement - the prepared statement to execute
  388. * @param random - Whether to support random-access to results
  389. * @param nargs - ignored (for backward compatibility only)
  390. * @param args - args to prepared statement
  391. * @return 0 for success or error code
  392. */
  393. APU_DECLARE(int) apr_dbd_pselect(const apr_dbd_driver_t *driver, apr_pool_t *pool,
  394. apr_dbd_t *handle, apr_dbd_results_t **res,
  395. apr_dbd_prepared_t *statement, int random,
  396. int nargs, const char **args);
  397. /** apr_dbd_pvquery: query using a prepared statement + args
  398. *
  399. * @param driver - the driver
  400. * @param pool - working pool
  401. * @param handle - the connection
  402. * @param nrows - number of rows affected.
  403. * @param statement - the prepared statement to execute
  404. * @param ... - varargs list
  405. * @return 0 for success or error code
  406. */
  407. APU_DECLARE_NONSTD(int) apr_dbd_pvquery(const apr_dbd_driver_t *driver,
  408. apr_pool_t *pool,
  409. apr_dbd_t *handle, int *nrows,
  410. apr_dbd_prepared_t *statement, ...);
  411. /** apr_dbd_pvselect: select using a prepared statement + args
  412. *
  413. * @param driver - the driver
  414. * @param pool - working pool
  415. * @param handle - the connection
  416. * @param res - pointer to query results. May point to NULL on entry
  417. * @param statement - the prepared statement to execute
  418. * @param random - Whether to support random-access to results
  419. * @param ... - varargs list
  420. * @return 0 for success or error code
  421. */
  422. APU_DECLARE_NONSTD(int) apr_dbd_pvselect(const apr_dbd_driver_t *driver,
  423. apr_pool_t *pool, apr_dbd_t *handle,
  424. apr_dbd_results_t **res,
  425. apr_dbd_prepared_t *statement,
  426. int random, ...);
  427. /** apr_dbd_pbquery: query using a prepared statement + binary args
  428. *
  429. * @param driver - the driver
  430. * @param pool - working pool
  431. * @param handle - the connection
  432. * @param nrows - number of rows affected.
  433. * @param statement - the prepared statement to execute
  434. * @param args - binary args to prepared statement
  435. * @return 0 for success or error code
  436. */
  437. APU_DECLARE(int) apr_dbd_pbquery(const apr_dbd_driver_t *driver,
  438. apr_pool_t *pool, apr_dbd_t *handle,
  439. int *nrows, apr_dbd_prepared_t *statement,
  440. const void **args);
  441. /** apr_dbd_pbselect: select using a prepared statement + binary args
  442. *
  443. * @param driver - the driver
  444. * @param pool - working pool
  445. * @param handle - the connection
  446. * @param res - pointer to query results. May point to NULL on entry
  447. * @param statement - the prepared statement to execute
  448. * @param random - Whether to support random-access to results
  449. * @param args - binary args to prepared statement
  450. * @return 0 for success or error code
  451. */
  452. APU_DECLARE(int) apr_dbd_pbselect(const apr_dbd_driver_t *driver,
  453. apr_pool_t *pool,
  454. apr_dbd_t *handle, apr_dbd_results_t **res,
  455. apr_dbd_prepared_t *statement, int random,
  456. const void **args);
  457. /** apr_dbd_pvbquery: query using a prepared statement + binary args
  458. *
  459. * @param driver - the driver
  460. * @param pool - working pool
  461. * @param handle - the connection
  462. * @param nrows - number of rows affected.
  463. * @param statement - the prepared statement to execute
  464. * @param ... - varargs list of binary args
  465. * @return 0 for success or error code
  466. */
  467. APU_DECLARE_NONSTD(int) apr_dbd_pvbquery(const apr_dbd_driver_t *driver,
  468. apr_pool_t *pool,
  469. apr_dbd_t *handle, int *nrows,
  470. apr_dbd_prepared_t *statement, ...);
  471. /** apr_dbd_pvbselect: select using a prepared statement + binary args
  472. *
  473. * @param driver - the driver
  474. * @param pool - working pool
  475. * @param handle - the connection
  476. * @param res - pointer to query results. May point to NULL on entry
  477. * @param statement - the prepared statement to execute
  478. * @param random - Whether to support random-access to results
  479. * @param ... - varargs list of binary args
  480. * @return 0 for success or error code
  481. */
  482. APU_DECLARE_NONSTD(int) apr_dbd_pvbselect(const apr_dbd_driver_t *driver,
  483. apr_pool_t *pool, apr_dbd_t *handle,
  484. apr_dbd_results_t **res,
  485. apr_dbd_prepared_t *statement,
  486. int random, ...);
  487. /** apr_dbd_datum_get: get a binary entry from a row
  488. *
  489. * @param driver - the driver
  490. * @param row - row pointer
  491. * @param col - entry number
  492. * @param type - type of data to get
  493. * @param data - pointer to data, allocated by the caller
  494. * @return APR_SUCCESS on success, APR_ENOENT if data is NULL or APR_EGENERAL
  495. */
  496. APU_DECLARE(apr_status_t) apr_dbd_datum_get(const apr_dbd_driver_t *driver,
  497. apr_dbd_row_t *row, int col,
  498. apr_dbd_type_e type, void *data);
  499. /** @} */
  500. #ifdef __cplusplus
  501. }
  502. #endif
  503. #endif