|
4 | 4 | use warnings;
|
5 | 5 | use PostgresNode;
|
6 | 6 | use TestLib;
|
7 |
| -use Test::More tests => 3; |
| 7 | +use Test::More tests => 4; |
8 | 8 |
|
9 | 9 | # Initialize publisher node
|
10 | 10 | my $node_publisher = get_new_node('publisher');
|
|
90 | 90 | CREATE TABLE public.tst_hstore (
|
91 | 91 | a INTEGER PRIMARY KEY,
|
92 | 92 | b public.hstore
|
93 |
| - );); |
| 93 | + ); |
| 94 | +
|
| 95 | + SET check_function_bodies=off; |
| 96 | + CREATE FUNCTION public.monot_incr(int) RETURNS bool LANGUAGE sql |
| 97 | + AS ' select \$1 > max(a) from public.tst_dom_constr; '; |
| 98 | + CREATE DOMAIN monot_int AS int CHECK (monot_incr(VALUE)); |
| 99 | + CREATE TABLE public.tst_dom_constr (a monot_int);); |
94 | 100 |
|
95 | 101 | # Setup structure on both nodes
|
96 | 102 | $node_publisher->safe_psql('postgres', $ddl);
|
|
240 | 246 | (2, '"zzz"=>"foo"'),
|
241 | 247 | (3, '"123"=>"321"'),
|
242 | 248 | (4, '"yellow horse"=>"moaned"');
|
| 249 | +
|
| 250 | + -- tst_dom_constr |
| 251 | + INSERT INTO tst_dom_constr VALUES (10); |
243 | 252 | ));
|
244 | 253 |
|
245 | 254 | $node_publisher->wait_for_catchup($appname);
|
|
541 | 550 | 4|"yellow horse"=>"moaned"',
|
542 | 551 | 'check replicated deletes on subscriber');
|
543 | 552 |
|
| 553 | +# Test a domain with a constraint backed by a SQL-language function, |
| 554 | +# which needs an active snapshot in order to operate. |
| 555 | +$node_publisher->safe_psql('postgres', "INSERT INTO tst_dom_constr VALUES (11)"); |
| 556 | + |
| 557 | +$node_subscriber->poll_query_until('postgres', $synced_query) |
| 558 | + or die "Timed out while waiting for subscriber to synchronize data"; |
| 559 | + |
| 560 | +$result = |
| 561 | + $node_subscriber->safe_psql('postgres', "SELECT sum(a) FROM tst_dom_constr"); |
| 562 | +is($result, '21', 'sql-function constraint on domain'); |
| 563 | + |
544 | 564 | $node_subscriber->stop('fast');
|
545 | 565 | $node_publisher->stop('fast');
|
0 commit comments