-db tests pass again

This commit is contained in:
Christian Grothoff 2022-11-27 21:43:55 +01:00
parent cf2e37cd87
commit c86c92200c
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
6 changed files with 74 additions and 73 deletions

View File

@ -404,22 +404,22 @@ INSERT INTO exchange_tables
,'exchange-0002' ,'exchange-0002'
,'create' ,'create'
,TRUE ,TRUE
,FALSE), ,TRUE),
('deposits_by_ready' ('deposits_by_ready'
,'exchange-0002' ,'exchange-0002'
,'constrain' ,'constrain'
,TRUE ,TRUE
,FALSE), ,TRUE),
('deposits_for_matching' ('deposits_for_matching'
,'exchange-0002' ,'exchange-0002'
,'create' ,'create'
,TRUE ,TRUE
,FALSE), ,TRUE),
('deposits_for_matching' ('deposits_for_matching'
,'exchange-0002' ,'exchange-0002'
,'constrain' ,'constrain'
,TRUE ,TRUE
,FALSE), ,TRUE),
('deposits' ('deposits'
,'exchange-0002' ,'exchange-0002'
,'master' ,'master'

View File

@ -132,14 +132,25 @@ BEGIN
,table_name ,table_name
,partition_suffix ,partition_suffix
); );
END $$;
CREATE FUNCTION constrain_table_reserves_out_by_reserve(
IN partition_suffix VARCHAR DEFAULT NULL
)
RETURNS VOID
LANGUAGE plpgsql
AS $$
DECLARE
table_name VARCHAR DEFAULT 'reserves_out_by_reserve';
BEGIN
table_name = concat_ws('_', table_name, partition_suffix); table_name = concat_ws('_', table_name, partition_suffix);
EXECUTE FORMAT ( EXECUTE FORMAT (
'CREATE INDEX ' || table_name || '_main_index ' 'CREATE INDEX ' || table_name || '_main_index '
'ON ' || table_name || ' ' 'ON ' || table_name || ' '
'(reserve_uuid);' '(reserve_uuid);'
); );
END END $$;
$$;
CREATE FUNCTION reserves_out_by_reserve_insert_trigger() CREATE FUNCTION reserves_out_by_reserve_insert_trigger()
@ -217,6 +228,11 @@ INSERT INTO exchange_tables
,'create' ,'create'
,TRUE ,TRUE
,FALSE), ,FALSE),
('reserves_out_by_reserve'
,'exchange-0002'
,'constrain'
,TRUE
,FALSE),
('reserves_out' ('reserves_out'
,'exchange-0002' ,'exchange-0002'
,'master' ,'master'

View File

@ -177,7 +177,7 @@ BEGIN
'SELECT exchange.%s_table_%s (%s)'::text 'SELECT exchange.%s_table_%s (%s)'::text
,rec.action ,rec.action
,rec.name ,rec.name
,0 ,quote_literal('0')
); );
IF (rec.by_range OR IF (rec.by_range OR
(num_partitions = 0)) (num_partitions = 0))
@ -189,7 +189,7 @@ BEGIN
EXECUTE FORMAT( EXECUTE FORMAT(
'CREATE TABLE exchange.%s_default' 'CREATE TABLE exchange.%s_default'
' PARTITION OF %s' ' PARTITION OF %s'
' FOR DEFAULT' ' DEFAULT'
,rec.name ,rec.name
,rec.name ,rec.name
); );
@ -238,14 +238,15 @@ BEGIN
,rec.name ,rec.name
); );
ELSE ELSE
IF (num_partitions = 0) IF ( (num_partitions = 0) OR
(rec.by_range) )
THEN THEN
-- Constrain default table -- Constrain default table
EXECUTE FORMAT( EXECUTE FORMAT(
'SELECT exchange.%s_table_%s (%s)'::text 'SELECT exchange.%s_table_%s (%s)'::text
,rec.action ,rec.action
,rec.name ,rec.name
,'default' ,quote_literal('default')
); );
ELSE ELSE
-- Constrain each partition -- Constrain each partition
@ -254,7 +255,7 @@ BEGIN
'SELECT exchange.%s_table_%s (%s)'::text 'SELECT exchange.%s_table_%s (%s)'::text
,rec.action ,rec.action
,rec.name ,rec.name
,i ,quote_literal(i)
); );
END LOOP; END LOOP;
END IF; END IF;

View File

@ -83,21 +83,14 @@ run (void *cls)
} }
(void) plugin->drop_tables (plugin->cls); (void) plugin->drop_tables (plugin->cls);
if (GNUNET_OK != if (GNUNET_OK !=
plugin->create_tables (plugin->cls)) plugin->create_tables (plugin->cls,
true,
num_partitions))
{ {
GNUNET_break (0); GNUNET_break (0);
result = 77; result = 77;
goto cleanup; goto cleanup;
} }
if (GNUNET_OK !=
plugin->setup_partitions (plugin->cls,
num_partitions))
{
GNUNET_break (0);
result = 77;
goto cleanup;
}
for (unsigned int i = 0; i< 8; i++) for (unsigned int i = 0; i< 8; i++)
{ {
static unsigned int batches[] = {1, 1, 0, 2, 4, 16, 64, 256}; static unsigned int batches[] = {1, 1, 0, 2, 4, 16, 64, 256};
@ -114,23 +107,23 @@ run (void *cls)
&value)); &value));
now = GNUNET_TIME_absolute_get (); now = GNUNET_TIME_absolute_get ();
ts = GNUNET_TIME_timestamp_get (); ts = GNUNET_TIME_timestamp_get ();
for (unsigned int r=0;r<10;r++) for (unsigned int r = 0; r<10; r++)
{ {
plugin->start (plugin->cls, plugin->start (plugin->cls,
"test_by_exchange_j"); "test_by_exchange_j");
for (unsigned int k = 0; k<batch_size; k++) for (unsigned int k = 0; k<batch_size; k++)
{ {
RND_BLK (&reserve_pub); RND_BLK (&reserve_pub);
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->reserves_in_insert (plugin->cls, plugin->reserves_in_insert (plugin->cls,
&reserve_pub, &reserve_pub,
&value, &value,
ts, ts,
sndr, sndr,
"section", "section",
4)); 4));
} }
plugin->commit (plugin->cls); plugin->commit (plugin->cls);
} }
duration = GNUNET_TIME_absolute_get_duration (now); duration = GNUNET_TIME_absolute_get_duration (now);
fprintf (stdout, fprintf (stdout,
@ -196,4 +189,5 @@ main (int argc,
return result; return result;
} }
/* end of test_exchangedb_by_j.c */ /* end of test_exchangedb_by_j.c */

View File

@ -1245,13 +1245,9 @@ run (void *cls)
} }
(void) plugin->drop_tables (plugin->cls); (void) plugin->drop_tables (plugin->cls);
if (GNUNET_OK != if (GNUNET_OK !=
plugin->create_tables (plugin->cls)) plugin->create_tables (plugin->cls,
{ true,
result = 77; num_partitions))
goto cleanup;
}
if (GNUNET_OK !=
plugin->setup_partitions (plugin->cls, num_partitions))
{ {
result = 77; result = 77;
goto cleanup; goto cleanup;

View File

@ -33,7 +33,7 @@ static int result;
*/ */
#define FAILIF(cond) \ #define FAILIF(cond) \
do { \ do { \
if (! (cond)) {break;} \ if (! (cond)) {break;} \
GNUNET_break (0); \ GNUNET_break (0); \
goto drop; \ goto drop; \
} while (0) } while (0)
@ -83,21 +83,14 @@ run (void *cls)
} }
(void) plugin->drop_tables (plugin->cls); (void) plugin->drop_tables (plugin->cls);
if (GNUNET_OK != if (GNUNET_OK !=
plugin->create_tables (plugin->cls)) plugin->create_tables (plugin->cls,
true,
num_partitions))
{ {
GNUNET_break (0); GNUNET_break (0);
result = 77; result = 77;
goto cleanup; goto cleanup;
} }
if (GNUNET_OK !=
plugin->setup_partitions (plugin->cls,
num_partitions))
{
GNUNET_break (0);
result = 77;
goto cleanup;
}
for (unsigned int i = 0; i< 7; i++) for (unsigned int i = 0; i< 7; i++)
{ {
static unsigned int batches[] = {1, 1, 2, 4, 16, 64, 256}; static unsigned int batches[] = {1, 1, 2, 4, 16, 64, 256};
@ -114,28 +107,28 @@ run (void *cls)
&value)); &value));
now = GNUNET_TIME_absolute_get (); now = GNUNET_TIME_absolute_get ();
ts = GNUNET_TIME_timestamp_get (); ts = GNUNET_TIME_timestamp_get ();
for (unsigned int r=0;r<10;r++) for (unsigned int r = 0; r<10; r++)
{ {
plugin->start_read_committed (plugin->cls, plugin->start_read_committed (plugin->cls,
"test_by_j"); "test_by_j");
for (unsigned int k = 0; k<batch_size; k++) for (unsigned int k = 0; k<batch_size; k++)
{ {
RND_BLK (&reserves[k].reserve_pub); RND_BLK (&reserves[k].reserve_pub);
reserves[k].balance = value; reserves[k].balance = value;
reserves[k].execution_time = ts; reserves[k].execution_time = ts;
reserves[k].sender_account_details = sndr; reserves[k].sender_account_details = sndr;
reserves[k].exchange_account_name = "name"; reserves[k].exchange_account_name = "name";
reserves[k].wire_reference = k; reserves[k].wire_reference = k;
} }
FAILIF (batch_size != FAILIF (batch_size !=
plugin->batch_reserves_in_insert (plugin->cls, plugin->batch_reserves_in_insert (plugin->cls,
reserves, reserves,
batch_size, batch_size,
results)); results));
plugin->commit (plugin->cls); plugin->commit (plugin->cls);
} }
duration = GNUNET_TIME_absolute_get_duration (now); duration = GNUNET_TIME_absolute_get_duration (now);
fprintf (stdout, fprintf (stdout,
@ -201,4 +194,5 @@ main (int argc,
return result; return result;
} }
/* end of test_exchangedb_by_j.c */ /* end of test_exchangedb_by_j.c */