Change ereport level for QueuePartitionConstraintValidation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
28 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Change ereport level for QueuePartitionConstraintValidation

Sergei Kornilov
Hello

I noticed appveyor build on windows is not happy:

> perl buildsetup.pl
> Could not determine contrib module type for alter_table
>  at buildsetup.pl line 38.

But I have no idea why. I can't check on windows. Possible I miss some change while adding new module to tree. Will check. Please let me know if root of such error is known.

https://ci.appveyor.com/project/postgresql-cfbot/postgresql/builds/26831382
https://ci.appveyor.com/project/postgresql-cfbot/postgresql/build/1.0.53294

regards, Sergei


Reply | Threaded
Open this post in threaded view
|

Re: Change ereport level for QueuePartitionConstraintValidation

Tom Lane-2
Sergei Kornilov <[hidden email]> writes:
> I noticed appveyor build on windows is not happy:
>> perl buildsetup.pl
>> Could not determine contrib module type for alter_table
>> at buildsetup.pl line 38.

> But I have no idea why. I can't check on windows. Possible I miss some change while adding new module to tree. Will check. Please let me know if root of such error is known.

> https://ci.appveyor.com/project/postgresql-cfbot/postgresql/builds/26831382
> https://ci.appveyor.com/project/postgresql-cfbot/postgresql/build/1.0.53294

grep is your friend: that message is coming out of Mkvcbuild.pm's
AddContrib.  (No idea why perl is fingering someplace else.)  Apparently
you need to have one of MODULE_big, MODULES, or PROGRAM defined, unless
you add the module to @contrib_excludes to keep it from being built.

                        regards, tom lane


Reply | Threaded
Open this post in threaded view
|

Re: Change ereport level for QueuePartitionConstraintValidation

Sergei Kornilov
Hello

Thank you! It seems the most appropriate option for this test is to change @contrib_excludes
Done in attached patch, will check appveyor reaction.

regards, Sergei

v2_0002_alter_table_tap_test.patch (18K) Download Attachment
v2_0001_lowering_partition_constraint_check_ereport_level.patch (10K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Change ereport level for QueuePartitionConstraintValidation

Tom Lane-2
Sergei Kornilov <[hidden email]> writes:
> Thank you! It seems the most appropriate option for this test is to change @contrib_excludes
> Done in attached patch, will check appveyor reaction.

Appveyor seems happy, so I took a look through this.  There's little
to say about 0001: if we're going to drop the elevel, that's what
results.  0002 is slightly more interesting.  I did not like calling
the module "alter_table": we should encourage any future similar needs
to add more tests in this same directory, not invent whole new ones.
I went with "test_misc", but that's still open for bikeshedding of course.
I did a minor amount of cleanup in the test script, including running
it through pgperltidy, but no substantive changes.  Also added a README.

I think there are basically two objections that might be raised to
committing this:

1. Making this a src/test/modules/ subdirectory, when there is no
actual extension module in it, is a triumph of expediency over
good file-tree structure.  If there were no other constraints
I'd want to call it src/test/misc/ or src/test/tap/ or something
like that.  The expediency angle is that if we do that, the
buildfarm client script will need changes to know about it.
Is it better to go with the long-term view and accept that we
won't have full buildfarm coverage right away?

2. It seems kind of expensive and redundant to duplicate all these
test cases from the core tests.  On my machine the new test script
took close to 2.5 seconds as-submitted.  I was able to knock that
down to 2.1 by the expedient of combining adjacent psql invocations
that we didn't need to examine the results of.  But it still is
adding a noticeable amount of time to check-world, which takes only
circa 100s overall (with parallelism).  Should we think about
deleting some of these test cases from the core tests?

(An argument not to do so is that the test conditions are a bit
different: since the TAP test starts a new session for each
query, it fails to exercise carry-over of relcache entries,
which might possibly be interesting in this area.)

Or, of course, we could forget the whole thing and switch the output
level for these messages to NOTICE instead.  I'm not for that, but
now that we see what it'll cost us to have them better hidden, we can
at least have an informed debate.

Thoughts?

                        regards, tom lane


diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index cceefbd..30f8d53 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -15402,11 +15402,11 @@ QueuePartitionConstraintValidation(List **wqueue, Relation scanrel,
  if (PartConstraintImpliedByRelConstraint(scanrel, partConstraint))
  {
  if (!validate_default)
- ereport(INFO,
+ ereport(DEBUG1,
  (errmsg("partition constraint for table \"%s\" is implied by existing constraints",
  RelationGetRelationName(scanrel))));
  else
- ereport(INFO,
+ ereport(DEBUG1,
  (errmsg("updated partition constraint for default partition \"%s\" is implied by existing constraints",
  RelationGetRelationName(scanrel))));
  return;
diff --git a/src/backend/partitioning/partbounds.c b/src/backend/partitioning/partbounds.c
index 46d03f3..318d8ec 100644
--- a/src/backend/partitioning/partbounds.c
+++ b/src/backend/partitioning/partbounds.c
@@ -1253,7 +1253,7 @@ check_default_partition_contents(Relation parent, Relation default_rel,
  */
  if (PartConstraintImpliedByRelConstraint(default_rel, def_part_constraints))
  {
- ereport(INFO,
+ ereport(DEBUG1,
  (errmsg("updated partition constraint for default partition \"%s\" is implied by existing constraints",
  RelationGetRelationName(default_rel))));
  return;
@@ -1304,7 +1304,7 @@ check_default_partition_contents(Relation parent, Relation default_rel,
  if (PartConstraintImpliedByRelConstraint(part_rel,
  def_part_constraints))
  {
- ereport(INFO,
+ ereport(DEBUG1,
  (errmsg("updated partition constraint for default partition \"%s\" is implied by existing constraints",
  RelationGetRelationName(part_rel))));
 
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index e5407bb..23d4265 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -3633,11 +3633,9 @@ ALTER TABLE list_parted2 ATTACH PARTITION part_3_4 FOR VALUES IN (3, 4);
 ALTER TABLE list_parted2 DETACH PARTITION part_3_4;
 ALTER TABLE part_3_4 ALTER a SET NOT NULL;
 ALTER TABLE list_parted2 ATTACH PARTITION part_3_4 FOR VALUES IN (3, 4);
-INFO:  partition constraint for table "part_3_4" is implied by existing constraints
 -- check if default partition scan skipped
 ALTER TABLE list_parted2_def ADD CONSTRAINT check_a CHECK (a IN (5, 6));
 CREATE TABLE part_55_66 PARTITION OF list_parted2 FOR VALUES IN (55, 66);
-INFO:  updated partition constraint for default partition "list_parted2_def" is implied by existing constraints
 -- check validation when attaching range partitions
 CREATE TABLE range_parted (
  a int,
@@ -3662,7 +3660,6 @@ CREATE TABLE part2 (
  b int NOT NULL CHECK (b >= 10 AND b < 18)
 );
 ALTER TABLE range_parted ATTACH PARTITION part2 FOR VALUES FROM (1, 10) TO (1, 20);
-INFO:  partition constraint for table "part2" is implied by existing constraints
 -- Create default partition
 CREATE TABLE partr_def1 PARTITION OF range_parted DEFAULT;
 -- Only one default partition is allowed, hence, following should give error
@@ -3690,13 +3687,11 @@ ERROR:  partition constraint is violated by some row
 DELETE FROM part_5_a WHERE a NOT IN (3);
 ALTER TABLE part_5 ADD CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 5);
 ALTER TABLE list_parted2 ATTACH PARTITION part_5 FOR VALUES IN (5);
-INFO:  partition constraint for table "part_5" is implied by existing constraints
 ALTER TABLE list_parted2 DETACH PARTITION part_5;
 ALTER TABLE part_5 DROP CONSTRAINT check_a;
 -- scan should again be skipped, even though NOT NULL is now a column property
 ALTER TABLE part_5 ADD CONSTRAINT check_a CHECK (a IN (5)), ALTER a SET NOT NULL;
 ALTER TABLE list_parted2 ATTACH PARTITION part_5 FOR VALUES IN (5);
-INFO:  partition constraint for table "part_5" is implied by existing constraints
 -- Check the case where attnos of the partitioning columns in the table being
 -- attached differs from the parent.  It should not affect the constraint-
 -- checking logic that allows to skip the scan.
@@ -3707,7 +3702,6 @@ CREATE TABLE part_6 (
 );
 ALTER TABLE part_6 DROP c;
 ALTER TABLE list_parted2 ATTACH PARTITION part_6 FOR VALUES IN (6);
-INFO:  partition constraint for table "part_6" is implied by existing constraints
 -- Similar to above, but the table being attached is a partitioned table
 -- whose partition has still different attnos for the root partitioning
 -- columns.
@@ -3725,10 +3719,7 @@ CREATE TABLE part_7_a_null (
 );
 ALTER TABLE part_7_a_null DROP c, DROP d, DROP e;
 ALTER TABLE part_7 ATTACH PARTITION part_7_a_null FOR VALUES IN ('a', null);
-INFO:  partition constraint for table "part_7_a_null" is implied by existing constraints
 ALTER TABLE list_parted2 ATTACH PARTITION part_7 FOR VALUES IN (7);
-INFO:  partition constraint for table "part_7" is implied by existing constraints
-INFO:  updated partition constraint for default partition "list_parted2_def" is implied by existing constraints
 -- Same example, but check this time that the constraint correctly detects
 -- violating rows
 ALTER TABLE list_parted2 DETACH PARTITION part_7;
@@ -3742,7 +3733,6 @@ SELECT tableoid::regclass, a, b FROM part_7 order by a;
 (2 rows)
 
 ALTER TABLE list_parted2 ATTACH PARTITION part_7 FOR VALUES IN (7);
-INFO:  updated partition constraint for default partition "list_parted2_def" is implied by existing constraints
 ERROR:  partition constraint is violated by some row
 -- check that leaf partitions of default partition are scanned when
 -- attaching a partitioned table.
@@ -3779,12 +3769,10 @@ CREATE TABLE quuux1 (a int, b text);
 ALTER TABLE quuux ATTACH PARTITION quuux1 FOR VALUES IN (1); -- validate!
 CREATE TABLE quuux2 (a int, b text);
 ALTER TABLE quuux ATTACH PARTITION quuux2 FOR VALUES IN (2); -- skip validation
-INFO:  updated partition constraint for default partition "quuux_default1" is implied by existing constraints
 DROP TABLE quuux1, quuux2;
 -- should validate for quuux1, but not for quuux2
 CREATE TABLE quuux1 PARTITION OF quuux FOR VALUES IN (1);
 CREATE TABLE quuux2 PARTITION OF quuux FOR VALUES IN (2);
-INFO:  updated partition constraint for default partition "quuux_default1" is implied by existing constraints
 DROP TABLE quuux;
 -- check validation when attaching hash partitions
 -- Use hand-rolled hash functions and operator class to get predictable result
@@ -4019,7 +4007,6 @@ delete from defpart_attach_test_d where a = 1;
 alter table defpart_attach_test_d add check (a > 1);
 -- should be attached successfully and without needing to be scanned
 alter table defpart_attach_test attach partition defpart_attach_test_d default;
-INFO:  partition constraint for table "defpart_attach_test_d" is implied by existing constraints
 -- check that attaching a partition correctly reports any rows in the default
 -- partition that should not be there for the new partition to be attached
 -- successfully
diff --git a/src/test/regress/expected/create_table.out b/src/test/regress/expected/create_table.out
index 3c30271..ce2484f 100644
--- a/src/test/regress/expected/create_table.out
+++ b/src/test/regress/expected/create_table.out
@@ -1163,7 +1163,6 @@ alter table defcheck_def drop c;
 alter table defcheck attach partition defcheck_def default;
 alter table defcheck_def add check (b <= 0 and b is not null);
 create table defcheck_1 partition of defcheck for values in (1, null);
-INFO:  updated partition constraint for default partition "defcheck_def" is implied by existing constraints
 -- test that complex default partition constraints are enforced correctly
 insert into defcheck_def values (0, 0);
 create table defcheck_0 partition of defcheck for values in (0);

diff --git a/src/test/modules/Makefile b/src/test/modules/Makefile
index 953905d..0e4e53d 100644
--- a/src/test/modules/Makefile
+++ b/src/test/modules/Makefile
@@ -14,6 +14,7 @@ SUBDIRS = \
   test_extensions \
   test_ginpostinglist \
   test_integerset \
+  test_misc \
   test_parser \
   test_pg_dump \
   test_predtest \
diff --git a/src/test/modules/test_misc/.gitignore b/src/test/modules/test_misc/.gitignore
new file mode 100644
index 0000000..5dcb3ff
--- /dev/null
+++ b/src/test/modules/test_misc/.gitignore
@@ -0,0 +1,4 @@
+# Generated subdirectories
+/log/
+/results/
+/tmp_check/
diff --git a/src/test/modules/test_misc/Makefile b/src/test/modules/test_misc/Makefile
new file mode 100644
index 0000000..39c6c20
--- /dev/null
+++ b/src/test/modules/test_misc/Makefile
@@ -0,0 +1,14 @@
+# src/test/modules/test_misc/Makefile
+
+TAP_TESTS = 1
+
+ifdef USE_PGXS
+PG_CONFIG = pg_config
+PGXS := $(shell $(PG_CONFIG) --pgxs)
+include $(PGXS)
+else
+subdir = src/test/modules/test_misc
+top_builddir = ../../../..
+include $(top_builddir)/src/Makefile.global
+include $(top_srcdir)/contrib/contrib-global.mk
+endif
diff --git a/src/test/modules/test_misc/README b/src/test/modules/test_misc/README
new file mode 100644
index 0000000..4876733
--- /dev/null
+++ b/src/test/modules/test_misc/README
@@ -0,0 +1,4 @@
+This directory doesn't actually contain any extension module.
+
+What it is is a home for otherwise-unclassified TAP tests that exercise core
+server features.  We might equally well have called it, say, src/test/misc.
diff --git a/src/test/modules/test_misc/t/001_constraint_validation.pl b/src/test/modules/test_misc/t/001_constraint_validation.pl
new file mode 100644
index 0000000..f762bc2
--- /dev/null
+++ b/src/test/modules/test_misc/t/001_constraint_validation.pl
@@ -0,0 +1,310 @@
+# Verify that ALTER TABLE optimizes certain operations as expected
+
+use strict;
+use warnings;
+use PostgresNode;
+use TestLib;
+use Test::More tests => 42;
+
+# Initialize a test cluster
+my $node = get_new_node('master');
+$node->init();
+# Turn message level up to DEBUG1 so that we get the messages we want to see
+$node->append_conf('postgresql.conf', 'client_min_messages = DEBUG1');
+$node->start;
+
+# Run a SQL command and return psql's stderr (including debug messages)
+sub run_sql_command
+{
+ my $sql = shift;
+ my $stderr;
+
+ $node->psql(
+ 'postgres',
+ $sql,
+ stderr        => \$stderr,
+ on_error_die  => 1,
+ on_error_stop => 1);
+ return $stderr;
+}
+
+# Check whether result of run_sql_command shows that we did a verify pass
+sub is_table_verified
+{
+ my $output = shift;
+ return index($output, 'DEBUG:  verifying table') != -1;
+}
+
+my $output;
+
+note "test alter table set not null";
+
+run_sql_command(
+ 'create table atacc1 (test_a int, test_b int);
+ insert into atacc1 values (1, 2);');
+
+$output = run_sql_command('alter table atacc1 alter test_a set not null;');
+ok(is_table_verified($output),
+ 'column test_a without constraint will scan table');
+
+run_sql_command(
+ 'alter table atacc1 alter test_a drop not null;
+ alter table atacc1 add constraint atacc1_constr_a_valid
+ check(test_a is not null);');
+
+# normal run will verify table data
+$output = run_sql_command('alter table atacc1 alter test_a set not null;');
+ok(!is_table_verified($output), 'with constraint will not scan table');
+ok( $output =~
+  m/existing constraints on column "atacc1"."test_a" are sufficient to prove that it does not contain nulls/,
+ 'test_a proved by constraints');
+
+run_sql_command('alter table atacc1 alter test_a drop not null;');
+
+# we have check only for test_a column, so we need verify table for test_b
+$output = run_sql_command(
+ 'alter table atacc1 alter test_b set not null, alter test_a set not null;'
+);
+ok(is_table_verified($output), 'table was scanned');
+# we may miss debug message for test_a constraint because we need verify table due test_b
+ok( !(  $output =~
+ m/existing constraints on column "atacc1"."test_b" are sufficient to prove that it does not contain nulls/
+ ),
+ 'test_b not proved by wrong constraints');
+run_sql_command(
+ 'alter table atacc1 alter test_a drop not null, alter test_b drop not null;'
+);
+
+# test with both columns having check constraints
+run_sql_command(
+ 'alter table atacc1 add constraint atacc1_constr_b_valid check(test_b is not null);'
+);
+$output = run_sql_command(
+ 'alter table atacc1 alter test_b set not null, alter test_a set not null;'
+);
+ok(!is_table_verified($output), 'table was not scanned for both columns');
+ok( $output =~
+  m/existing constraints on column "atacc1"."test_a" are sufficient to prove that it does not contain nulls/,
+ 'test_a proved by constraints');
+ok( $output =~
+  m/existing constraints on column "atacc1"."test_b" are sufficient to prove that it does not contain nulls/,
+ 'test_b proved by constraints');
+run_sql_command('drop table atacc1;');
+
+note "test alter table attach partition";
+
+run_sql_command(
+ 'CREATE TABLE list_parted2 (
+ a int,
+ b char
+ ) PARTITION BY LIST (a);
+ CREATE TABLE part_3_4 (
+ LIKE list_parted2,
+ CONSTRAINT check_a CHECK (a IN (3)));');
+
+# need NOT NULL to skip table scan
+$output = run_sql_command(
+ 'ALTER TABLE list_parted2 ATTACH PARTITION part_3_4 FOR VALUES IN (3, 4);'
+);
+ok(is_table_verified($output), 'table part_3_4 scanned');
+
+run_sql_command(
+ 'ALTER TABLE list_parted2 DETACH PARTITION part_3_4;
+ ALTER TABLE part_3_4 ALTER a SET NOT NULL;');
+
+$output = run_sql_command(
+ 'ALTER TABLE list_parted2 ATTACH PARTITION part_3_4 FOR VALUES IN (3, 4);'
+);
+ok(!is_table_verified($output), 'table part_3_4 not scanned');
+ok( $output =~
+  m/partition constraint for table "part_3_4" is implied by existing constraints/,
+ 'part_3_4 verified by existing constraints');
+
+# test attach default partition
+run_sql_command(
+ 'CREATE TABLE list_parted2_def (
+ LIKE list_parted2,
+ CONSTRAINT check_a CHECK (a IN (5, 6)));');
+$output = run_sql_command(
+ 'ALTER TABLE list_parted2 ATTACH PARTITION list_parted2_def default;');
+ok(!is_table_verified($output), 'table list_parted2_def not scanned');
+ok( $output =~
+  m/partition constraint for table "list_parted2_def" is implied by existing constraints/,
+ 'list_parted2_def verified by existing constraints');
+
+$output = run_sql_command(
+ 'CREATE TABLE part_55_66 PARTITION OF list_parted2 FOR VALUES IN (55, 66);'
+);
+ok(!is_table_verified($output), 'table list_parted2_def not scanned');
+ok( $output =~
+  m/updated partition constraint for default partition "list_parted2_def" is implied by existing constraints/,
+ 'updated partition constraint for default partition list_parted2_def');
+
+# test attach another partitioned table
+run_sql_command(
+ 'CREATE TABLE part_5 (
+ LIKE list_parted2
+ ) PARTITION BY LIST (b);
+ CREATE TABLE part_5_a PARTITION OF part_5 FOR VALUES IN (\'a\');
+ ALTER TABLE part_5 ADD CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 5);'
+);
+$output = run_sql_command(
+ 'ALTER TABLE list_parted2 ATTACH PARTITION part_5 FOR VALUES IN (5);');
+ok(!($output =~ m/verifying table "part_5"/), 'table part_5 not scanned');
+ok($output =~ m/verifying table "list_parted2_def"/,
+ 'list_parted2_def scanned');
+ok( $output =~
+  m/partition constraint for table "part_5" is implied by existing constraints/,
+ 'part_5 verified by existing constraints');
+
+run_sql_command(
+ 'ALTER TABLE list_parted2 DETACH PARTITION part_5;
+ ALTER TABLE part_5 DROP CONSTRAINT check_a;');
+
+# scan should again be skipped, even though NOT NULL is now a column property
+run_sql_command(
+ 'ALTER TABLE part_5 ADD CONSTRAINT check_a CHECK (a IN (5)),
+ ALTER a SET NOT NULL;'
+);
+$output = run_sql_command(
+ 'ALTER TABLE list_parted2 ATTACH PARTITION part_5 FOR VALUES IN (5);');
+ok(!($output =~ m/verifying table "part_5"/), 'table part_5 not scanned');
+ok($output =~ m/verifying table "list_parted2_def"/,
+ 'list_parted2_def scanned');
+ok( $output =~
+  m/partition constraint for table "part_5" is implied by existing constraints/,
+ 'part_5 verified by existing constraints');
+
+# Check the case where attnos of the partitioning columns in the table being
+# attached differs from the parent.  It should not affect the constraint-
+# checking logic that allows to skip the scan.
+run_sql_command(
+ 'CREATE TABLE part_6 (
+ c int,
+ LIKE list_parted2,
+ CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 6)
+ );
+ ALTER TABLE part_6 DROP c;');
+$output = run_sql_command(
+ 'ALTER TABLE list_parted2 ATTACH PARTITION part_6 FOR VALUES IN (6);');
+ok(!($output =~ m/verifying table "part_6"/), 'table part_6 not scanned');
+ok($output =~ m/verifying table "list_parted2_def"/,
+ 'list_parted2_def scanned');
+ok( $output =~
+  m/partition constraint for table "part_6" is implied by existing constraints/,
+ 'part_6 verified by existing constraints');
+
+# Similar to above, but the table being attached is a partitioned table
+# whose partition has still different attnos for the root partitioning
+# columns.
+run_sql_command(
+ 'CREATE TABLE part_7 (
+ LIKE list_parted2,
+ CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 7)
+ ) PARTITION BY LIST (b);
+ CREATE TABLE part_7_a_null (
+ c int,
+ d int,
+ e int,
+ LIKE list_parted2,  -- a will have attnum = 4
+ CONSTRAINT check_b CHECK (b IS NULL OR b = \'a\'),
+ CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 7)
+ );
+ ALTER TABLE part_7_a_null DROP c, DROP d, DROP e;');
+
+$output = run_sql_command(
+ 'ALTER TABLE part_7 ATTACH PARTITION part_7_a_null FOR VALUES IN (\'a\', null);'
+);
+ok(!is_table_verified($output), 'table not scanned');
+ok( $output =~
+  m/partition constraint for table "part_7_a_null" is implied by existing constraints/,
+ 'part_7_a_null verified by existing constraints');
+$output = run_sql_command(
+ 'ALTER TABLE list_parted2 ATTACH PARTITION part_7 FOR VALUES IN (7);');
+ok(!is_table_verified($output), 'tables not scanned');
+ok( $output =~
+  m/partition constraint for table "part_7" is implied by existing constraints/,
+ 'part_7 verified by existing constraints');
+ok( $output =~
+  m/updated partition constraint for default partition "list_parted2_def" is implied by existing constraints/,
+ 'updated partition constraint for default partition list_parted2_def');
+
+run_sql_command(
+ 'CREATE TABLE range_parted (
+ a int,
+ b int
+ ) PARTITION BY RANGE (a, b);
+ CREATE TABLE range_part1 (
+ a int NOT NULL CHECK (a = 1),
+ b int NOT NULL);');
+
+$output = run_sql_command(
+ 'ALTER TABLE range_parted ATTACH PARTITION range_part1 FOR VALUES FROM (1, 1) TO (1, 10);'
+);
+ok(is_table_verified($output), 'table range_part1 scanned');
+ok( !(  $output =~
+ m/partition constraint for table "range_part1" is implied by existing constraints/
+ ),
+ 'range_part1 not verified by existing constraints');
+
+run_sql_command(
+ 'CREATE TABLE range_part2 (
+ a int NOT NULL CHECK (a = 1),
+ b int NOT NULL CHECK (b >= 10 and b < 18)
+);');
+$output = run_sql_command(
+ 'ALTER TABLE range_parted ATTACH PARTITION range_part2 FOR VALUES FROM (1, 10) TO (1, 20);'
+);
+ok(!is_table_verified($output), 'table range_part2 not scanned');
+ok( $output =~
+  m/partition constraint for table "range_part2" is implied by existing constraints/,
+ 'range_part2 verified by existing constraints');
+
+# If a partitioned table being created or an existing table being attached
+# as a partition does not have a constraint that would allow validation scan
+# to be skipped, but an individual partition does, then the partition's
+# validation scan is skipped.
+run_sql_command(
+ 'CREATE TABLE quuux (a int, b text) PARTITION BY LIST (a);
+ CREATE TABLE quuux_default PARTITION OF quuux DEFAULT PARTITION BY LIST (b);
+ CREATE TABLE quuux_default1 PARTITION OF quuux_default (
+ CONSTRAINT check_1 CHECK (a IS NOT NULL AND a = 1)
+ ) FOR VALUES IN (\'b\');
+ CREATE TABLE quuux1 (a int, b text);');
+
+$output = run_sql_command(
+ 'ALTER TABLE quuux ATTACH PARTITION quuux1 FOR VALUES IN (1);');
+ok(is_table_verified($output), 'quuux1 table scanned');
+ok( !(  $output =~
+ m/partition constraint for table "quuux1" is implied by existing constraints/
+ ),
+ 'quuux1 verified by existing constraints');
+
+run_sql_command('CREATE TABLE quuux2 (a int, b text);');
+$output = run_sql_command(
+ 'ALTER TABLE quuux ATTACH PARTITION quuux2 FOR VALUES IN (2);');
+ok(!($output =~ m/verifying table "quuux_default1"/),
+ 'quuux_default1 not scanned');
+ok($output =~ m/verifying table "quuux2"/, 'quuux2 scanned');
+ok( $output =~
+  m/updated partition constraint for default partition "quuux_default1" is implied by existing constraints/,
+ 'updated partition constraint for default partition quuux_default1');
+run_sql_command('DROP TABLE quuux1, quuux2;');
+
+# should validate for quuux1, but not for quuux2
+$output = run_sql_command(
+ 'CREATE TABLE quuux1 PARTITION OF quuux FOR VALUES IN (1);');
+ok(!is_table_verified($output), 'tables not scanned');
+ok( !(  $output =~
+ m/partition constraint for table "quuux1" is implied by existing constraints/
+ ),
+ 'quuux1 verified by existing constraints');
+$output = run_sql_command(
+ 'CREATE TABLE quuux2 PARTITION OF quuux FOR VALUES IN (2);');
+ok(!is_table_verified($output), 'tables not scanned');
+ok( $output =~
+  m/updated partition constraint for default partition "quuux_default1" is implied by existing constraints/,
+ 'updated partition constraint for default partition quuux_default1');
+run_sql_command('DROP TABLE quuux;');
+
+$node->stop('fast');
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 2eab635..a09263d 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -47,8 +47,9 @@ my @contrib_excludes = (
  'jsonb_plperl',     'jsonb_plpython',
  'ltree_plpython',   'pgcrypto',
  'sepgsql',          'brin',
- 'test_extensions',  'test_pg_dump',
- 'snapshot_too_old', 'unsafe_tests');
+ 'test_extensions',  'test_misc',
+ 'test_pg_dump',     'snapshot_too_old',
+ 'unsafe_tests');
 
 # Set of variables for frontend modules
 my $frontend_defines = { 'initdb' => 'FRONTEND' };
Reply | Threaded
Open this post in threaded view
|

Re: Change ereport level for QueuePartitionConstraintValidation

Tom Lane-2
I wrote:
> Or, of course, we could forget the whole thing and switch the output
> level for these messages to NOTICE instead.  I'm not for that, but
> now that we see what it'll cost us to have them better hidden, we can
> at least have an informed debate.
> Thoughts?

Hearing no comments, I've pushed that patch, and marked the v12
open item closed.

                        regards, tom lane


Reply | Threaded
Open this post in threaded view
|

Re: Change ereport level for QueuePartitionConstraintValidation

Álvaro Herrera
On 2019-Sep-07, Tom Lane wrote:

> I wrote:
> > Or, of course, we could forget the whole thing and switch the output
> > level for these messages to NOTICE instead.  I'm not for that, but
> > now that we see what it'll cost us to have them better hidden, we can
> > at least have an informed debate.
> > Thoughts?
>
> Hearing no comments, I've pushed that patch, and marked the v12
> open item closed.

I've marked https://commitfest.postgresql.org/24/2076/ committed also.

Thanks,

--
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


Reply | Threaded
Open this post in threaded view
|

Re: Change ereport level for QueuePartitionConstraintValidation

Tom Lane-2
Alvaro Herrera from 2ndQuadrant <[hidden email]> writes:
> I've marked https://commitfest.postgresql.org/24/2076/ committed also.

Yeah, I just remembered about doing that, and saw you'd beat me to it.

                        regards, tom lane


Reply | Threaded
Open this post in threaded view
|

Re: Change ereport level for QueuePartitionConstraintValidation

Sergei Kornilov
In reply to this post by Tom Lane-2
Hello

> Hearing no comments, I've pushed that patch, and marked the v12
> open item closed.

Thank you!

regards, Sergei


12