Report error position in partition bound check
Alexandra Wang <lewang@pivotal.io>
From: Alexandra Wang <lewang@pivotal.io>
To: PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Cc: Ashwin Agrawal <aagrawal@pivotal.io>
Date: 2020-04-09T00:15:57Z
Lists: pgsql-hackers
Attachments
- 0001-Report-error-position-in-partition-bound-check.patch (text/x-patch) patch 0001
Hi,
I'm playing with partitioned tables and found a minor thing with the
error reporting of bounds checking when create partitions.
In function check_new_partition_bound(), there are three places where
we call ereport() with a parser_errposition(pstate, spec->location)
argument. However, that pstate is a dummy ParseState made from NULL,
so the error message never reports the position of the error in the
source query line.
I have attached a patch to pass in a ParseState to
check_new_partition_bound() to enable the reporting of the error
position. Below is what the error message looks like before and after
applying the patch.
-- Create parent table
create table foo (a int, b date) partition by range (b);
-- Before:
create table foo_part_1 partition of foo for values from (date
'2007-01-01') to (date '2006-01-01');
ERROR: empty range bound specified for partition "foo_part_1"
DETAIL: Specified lower bound ('2007-01-01') is greater than or equal to
upper bound ('2006-01-01').
-- After:
create table foo_part_1 partition of foo for values from (date
'2007-01-01') to (date '2006-01-01');
ERROR: empty range bound specified for partition "foo_part_1"
LINE 1: ...eate table foo_part_1 partition of foo for values from (date...
^
DETAIL: Specified lower bound ('2007-01-01') is greater than or equal to
upper bound ('2006-01-01').
Another option is to not pass the parser_errposition() argument at all
to ereport() in this function, since the query is relatively short and
the error message is already descriptive enough.
Alex and Ashwin
Commits
-
Improve error cursor positions for problems with partition bounds.
- 6b2c4e59d016 14.0 landed