commit 79069d3d316a1d1aeb220292ff6b4a38292ec7d3
parent 435277f50a8b2b84dfb4dc5f0a0e59f075437384
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 16 Jun 2026 10:01:06 +0200
fix pq test
Diffstat:
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/src/lib/pq/test_pq.c b/src/lib/pq/test_pq.c
@@ -1648,7 +1648,7 @@ main (int argc,
{
struct GNUNET_PQ_ExecuteStatement es[] = {
GNUNET_PQ_make_execute (
- "CREATE TEMPORARY TABLE IF NOT EXISTS test_pq ("
+ "CREATE TABLE IF NOT EXISTS test_pq ("
" pub BYTEA NOT NULL"
",sig BYTEA NOT NULL"
",abs_time INT8 NOT NULL"
@@ -1670,7 +1670,7 @@ main (int argc,
",arr_timestamp INT8[]"
");"),
GNUNET_PQ_make_execute (
- "CREATE TEMPORARY TABLE IF NOT EXISTS test_pq_array_nulls ("
+ "CREATE TABLE IF NOT EXISTS test_pq_array_nulls ("
" id INT4 PRIMARY KEY"
",arr_bool BOOL[]"
",arr_int2 INT2[]"
@@ -1683,7 +1683,7 @@ main (int argc,
");"),
/* Create table for time arrays test, including NULL */
GNUNET_PQ_make_execute (
- "CREATE TEMPORARY TABLE IF NOT EXISTS test_pq_time_arrays ("
+ "CREATE TABLE IF NOT EXISTS test_pq_time_arrays ("
" id INTEGER PRIMARY KEY"
",arr_abs_time INT8[]"
",arr_rel_time INT8[]"
@@ -1691,29 +1691,40 @@ main (int argc,
");"),
/* Create table for struct arrays test, including NULL*/
GNUNET_PQ_make_execute (
- "CREATE TEMPORARY TABLE IF NOT EXISTS test_pq_struct_arrays ("
+ "CREATE TABLE IF NOT EXISTS test_pq_struct_arrays ("
" id INTEGER PRIMARY KEY"
",arr_fixed_bytes BYTEA[]"
",arr_var_bytes BYTEA[]"
")"),
GNUNET_PQ_EXECUTE_STATEMENT_END
};
+ struct GNUNET_CONFIGURATION_Handle *cfg;
(void) argc;
(void) argv;
GNUNET_log_setup ("test-pq",
"INFO",
NULL);
- db = GNUNET_PQ_connect ("postgres:///gnunetcheck",
- NULL,
- es,
- NULL);
+ cfg = GNUNET_CONFIGURATION_create (GNUNET_OS_project_data_gnunet ());
+ GNUNET_CONFIGURATION_set_value_string (
+ cfg,
+ "test-pq",
+ "CONFIG",
+ "postgres:///gnunetcheck");
+ db = GNUNET_PQ_init (cfg,
+ "test-pq",
+ NULL,
+ NULL);
+ GNUNET_CONFIGURATION_destroy (cfg);
if (NULL == db)
{
fprintf (stderr,
"Cannot run test, database connection failed\n");
return 77;
}
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_PQ_exec_statements (db,
+ es));
if (CONNECTION_OK != PQstatus (db->conn))
{
fprintf (stderr,
@@ -1783,7 +1794,8 @@ main (int argc,
return 77; /* signal test was skipped */
}
- PQexec (db->conn, "CREATE TYPE foo AS (foo int, bar int);");
+ PQexec (db->conn,
+ "CREATE TYPE foo AS (foo int, bar int);");
lret = GNUNET_PQ_get_oid_by_name (db, "foo", &oid);
if (GNUNET_OK != lret)
@@ -1808,15 +1820,6 @@ main (int argc,
GNUNET_PQ_disconnect (db);
return global_ret;
}
-#if TEST_RESTART
- fprintf (stderr, "Please restart Postgres database now!\n");
- sleep (60);
- global_ret |= run_queries (db);
- fprintf (stderr, "Result: %d (expect: 1 -- if you restarted the DB)\n",
- global_ret);
- global_ret |= run_queries (db);
- fprintf (stderr, "Result: %d (expect: 0)\n", global_ret);
-#endif
{
struct GNUNET_PQ_ExecuteStatement es_tmp[] = {
GNUNET_PQ_make_execute ("DROP TABLE test_pq"),