From: | Alexandra Wang <lewang(at)pivotal(dot)io> |
---|---|
To: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Cc: | Ashwin Agrawal <aagrawal(at)pivotal(dot)io> |
Subject: | Report error position in partition bound check |
Date: | 2020-04-09 00:15:57 |
Message-ID: | CACiyaSopZoqssfMzgHk6fAkp01cL6vnqBdmTw2C5_KJaFR_aMg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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
Attachment | Content-Type | Size |
---|---|---|
0001-Report-error-position-in-partition-bound-check.patch | text/x-patch | 4.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2020-04-09 00:31:56 | Re: Improving connection scalability: GetSnapshotData() |
Previous Message | Mark Dilger | 2020-04-08 22:51:11 | Perl modules for testing/viewing/corrupting/repairing your heap files |