23#define TEST(msg,func) \
24 printf("======== %s ========\n", msg); \
25 rv = func(pool, sql, driver); \
27 printf("Error in %s: rc=%d\n\n", msg, rv); \
30 printf("%s test successful\n\n", msg); \
39 const char *
statement =
"CREATE TABLE apr_dbd_test ("
40 "col1 varchar(40) not null,"
51 const char *
statement =
"DROP TABLE apr_dbd_test" ;
63 "INSERT into apr_dbd_test (col1) values ('foo');"
64 "INSERT into apr_dbd_test values ('wibble', 'other', 5);"
65 "INSERT into apr_dbd_test values ('wibble', 'nothing', 5);"
66 "INSERT into apr_dbd_test values ('qwerty', 'foo', 0);"
67 "INSERT into apr_dbd_test values ('asdfgh', 'bar', 1);"
71 const char*
stmt[] = {
72 "INSERT into apr_dbd_test (col1) values ('foo');",
73 "INSERT into apr_dbd_test values ('wibble', 'other', 5);",
74 "INSERT into apr_dbd_test values ('wibble', 'nothing', 5);",
75 "INSERT into apr_dbd_test values ('qwerty', 'foo', 0);",
76 "INSERT into apr_dbd_test values ('asdfgh', 'bar', 1);",
79 printf(
"Compound insert failed; trying statements one-by-one\n") ;
98 const char *
statement =
"INSERT into apr_dbd_test1 (col2) values ('foo')" ;
100 printf(
"invalid op returned %d (should be nonzero). Error msg follows\n", rv);
102 statement =
"INSERT into apr_dbd_test (col1, col2) values ('bar', 'foo')" ;
104 printf(
"valid op returned %d (should be zero; error shouldn't affect subsequent ops)\n", rv);
114 const char*
statement =
"SELECT * FROM apr_dbd_test ORDER BY col1, col2";
137 return (rv == -1) ? 0 : 1;
145 const char*
statement =
"SELECT * FROM apr_dbd_test ORDER BY col1, col2";
187 printf(
"Oops! get_row out of range but thinks it succeeded!\n%s\n",
204 printf(
"Transaction 1\n");
207 printf(
"Start transaction failed!\n%s\n",
211 statement =
"UPDATE apr_dbd_test SET col2 = 'failed'";
220 statement =
"INSERT INTO apr_dbd_test1 (col3) values (3)";
223 printf(
"Oops, invalid op succeeded but shouldn't!\n");
225 statement =
"INSERT INTO apr_dbd_test values ('zzz', 'aaa', 3)";
227 printf(
"Valid insert returned %d. Should be nonzero (fail) because transaction is bad\n", rv) ;
231 printf(
"End transaction failed!\n%s\n",
235 printf(
"Transaction ended (should be rollback) - viewing table\n"
236 "A column of \"failed\" indicates transaction failed (no rollback)\n");
240 printf(
"Transaction 2\n");
243 printf(
"Start transaction failed!\n%s\n",
247 statement =
"UPDATE apr_dbd_test SET col2 = 'success'";
255 statement =
"INSERT INTO apr_dbd_test values ('aaa', 'zzz', 3)";
257 printf(
"Valid insert returned %d. Should be zero (OK)\n", rv) ;
260 printf(
"End transaction failed!\n%s\n",
264 printf(
"Transaction ended (should be commit) - viewing table\n");
274 "SELECT * FROM apr_dbd_test WHERE col3 <= %s or col1 = 'bar'" ;
275 const char *
label =
"lowvalues";
279 const char *entry =
NULL;
283 printf(
"Prepare statement failed!\n%s\n",
289 printf(
"Exec of prepared statement failed!\n%s\n",
294 printf(
"Selecting rows where col3 <= 3 and bar row where it's unset.\nShould show four rows.\n");
310 return (rv == -1) ? 0 : 1;
316 const char *
query =
"INSERT INTO apr_dbd_test VALUES (%s, %s, %d)";
318 const char *
label =
"testpquery";
325 printf(
"Prepare statement failed!\n%s\n",
331 "prepared",
"insert",
"2",
NULL);
334 printf(
"Exec of prepared statement failed!\n%s\n",
338 printf(
"Showing table (should now contain row \"prepared insert 2\")\n");
365 printf(
"Failed to load driver file apr_dbd_%s.so\n",
name);
368 printf(
"Failed to load driver apr_dbd_%s_driver.\n",
name);
371 printf(
"No driver available for %s.\n",
name);
static int test_transactions(apr_pool_t *pool, apr_dbd_t *handle, const apr_dbd_driver_t *driver)
static int select_sequential(apr_pool_t *pool, apr_dbd_t *handle, const apr_dbd_driver_t *driver)
static int select_random(apr_pool_t *pool, apr_dbd_t *handle, const apr_dbd_driver_t *driver)
static int insert_rows(apr_pool_t *pool, apr_dbd_t *handle, const apr_dbd_driver_t *driver)
static int test_pquery(apr_pool_t *pool, apr_dbd_t *handle, const apr_dbd_driver_t *driver)
static int drop_table(apr_pool_t *pool, apr_dbd_t *handle, const apr_dbd_driver_t *driver)
static int test_pselect(apr_pool_t *pool, apr_dbd_t *handle, const apr_dbd_driver_t *driver)
static int invalid_op(apr_pool_t *pool, apr_dbd_t *handle, const apr_dbd_driver_t *driver)
static int create_table(apr_pool_t *pool, apr_dbd_t *handle, const apr_dbd_driver_t *driver)
apr_pool_t apr_dbd_t const char * query
const char const apr_dbd_driver_t ** driver
struct apr_dbd_prepared_t apr_dbd_prepared_t
apr_pool_t apr_dbd_t const char const char * label
apr_pool_t apr_dbd_t apr_dbd_results_t ** res
struct apr_dbd_t apr_dbd_t
apr_dbd_t int const char * statement
struct apr_dbd_results_t apr_dbd_results_t
apr_pool_t const char apr_dbd_t ** handle
struct apr_dbd_transaction_t apr_dbd_transaction_t
apr_pool_t apr_dbd_results_t apr_dbd_row_t ** row
apr_pool_t const char * params
struct apr_dbd_row_t apr_dbd_row_t
const char int apr_pool_t * pool
#define apr_pool_create(newpool, parent)
static const char *const trans[040]