-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,
GNUNET_break (0);
result = 77;
goto cleanup;
}
if (GNUNET_OK !=
plugin->setup_partitions (plugin->cls,
num_partitions)) num_partitions))
{ {
GNUNET_break (0); GNUNET_break (0);
result = 77; result = 77;
goto cleanup; 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};
@ -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

@ -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,
GNUNET_break (0);
result = 77;
goto cleanup;
}
if (GNUNET_OK !=
plugin->setup_partitions (plugin->cls,
num_partitions)) num_partitions))
{ {
GNUNET_break (0); GNUNET_break (0);
result = 77; result = 77;
goto cleanup; 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};
@ -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 */