static void test_dbd_generic(abts_case *tc, apr_dbd_t* handle, const apr_dbd_driver_t* driver) { void* native; apr_pool_t *pool = p; apr_status_t rv; native = apr_dbd_native_handle(driver, handle); ABTS_PTR_NOTNULL(tc, native); rv = apr_dbd_check_conn(driver, pool, handle); create_table(tc, handle, driver); select_rows(tc, handle, driver, 0); insert_data(tc, handle, driver, 5); select_rows(tc, handle, driver, 5); delete_rows(tc, handle, driver); select_rows(tc, handle, driver, 0); drop_table(tc, handle, driver); test_escape(tc, handle, driver); rv = apr_dbd_close(driver, handle); ABTS_ASSERT(tc, "failed to close database", rv == APR_SUCCESS); }
APU_DECLARE(apr_status_t) apr_dbd_open(const apr_dbd_driver_t *driver, apr_pool_t *pool, const char *params, apr_dbd_t **handle) { apr_status_t rv; *handle = driver->open(pool, params); if (*handle == NULL) { return APR_EGENERAL; } rv = apr_dbd_check_conn(driver, pool, *handle); if ((rv != APR_SUCCESS) && (rv != APR_ENOTIMPL)) { apr_dbd_close(driver, *handle); return APR_EGENERAL; } return APR_SUCCESS; }
/* ============================================================================= db:active(): Returns true if the connection to the db is still active. ============================================================================= */ int lua_db_active(lua_State *L) { /*~~~~~~~~~~~~~~~~~~~~*/ lua_db_handle *db = 0; apr_status_t rc = 0; /*~~~~~~~~~~~~~~~~~~~~*/ db = lua_get_db_handle(L); if (db && db->alive) { rc = apr_dbd_check_conn(db->driver, db->pool, db->handle); if (rc == APR_SUCCESS) { lua_pushboolean(L, 1); return 1; } } lua_pushboolean(L, 0); return 1; }
APU_DECLARE(apr_status_t) apr_dbd_open_ex(const apr_dbd_driver_t *driver, apr_pool_t *pool, const char *params, apr_dbd_t **handle, const char **error) { apr_status_t rv; *handle = (driver->open)(pool, params, error); if (*handle == NULL) { return APR_EGENERAL; } rv = apr_dbd_check_conn(driver, pool, *handle); if ((rv != APR_SUCCESS) && (rv != APR_ENOTIMPL)) { /* XXX: rv is APR error code, but apr_dbd_error() takes int! */ if (error) { *error = apr_dbd_error(driver, *handle, rv); } apr_dbd_close(driver, *handle); return APR_EGENERAL; } return APR_SUCCESS; }