|From:||Michael Paquier <michael(dot)paquier(at)gmail(dot)com>|
|Cc:||PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>|
|Subject:||Re: BUG #14866: The generated constraint in the typed table causes the server to crash|
|Views:||Raw Message | Whole Thread | Download mbox|
On Mon, Oct 23, 2017 at 11:09 PM, Michael Paquier
> On Mon, Oct 23, 2017 at 4:44 PM, <gomer94(at)yandex(dot)ru> wrote:
>> This sql code crashes the server:
>> CREATE TYPE comp AS (f1 integer, f2 text, f3 bigint);
>> CREATE TABLE typed_table OF comp (
>> f1 WITH OPTIONS GENERATED ALWAYS AS IDENTITY);
> Thanks for the report. I can reproduce the crasher here. The problem
> happens when doing a type name lookup when transforming the CREATE
> clause in the parser. Looking into it now.
Looking at the grammar of CREATE TABLE, child partitions crash as well
for the same reasons:
CREATE TABLE itest_parent (f1 date NOT NULL, f2 int) PARTITION BY RANGE (f1);
CREATE TABLE itest_child PARTITION OF itest_parent (
f2 WITH OPTIONS GENERATED ALWAYS AS IDENTITY
) FOR VALUES FROM ('2016-07-01') TO ('2016-08-01');
Attached is a patch to address the problem. There are a couple of
things to consider:
- transformColumnDefinition is missing the fact that a type may not be
set for a column defined, and as far as I can see the type name is
needed beforehand to allow the generation of all the serial commands.
This can happen when using CREATE TABLE OF, as you reported, for which
the data type can be found in the type defined. But this can happen as
well when declaring a child partition.
- MergeAttributes() needs to copy the identity field from the origin
to the target ColumnDef for both things.
As both MergeAttributes() and transformColumnDefinition() are linked
with each other, I went to the most straight-forward, less ugly
solution as child should not inherit identity constraints by default
from the parent. Comments are welcome.
I am adding Peter E in CC, who is the author and committer of the
feature. I am adding an entry in the CF as well.
|Next Message||tschimail1||2017-10-24 09:20:10||BUG #14868: Postgres as Windows Service doesn't shutdown properly|
|Previous Message||Chris Hanks||2017-10-23 17:39:26||Re: Connections hang indefinitely while taking a LWLockTranche buffer_content lock.|