Re: Assertion failure on UNLOGGED VIEW and SEQUENCE - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Assertion failure on UNLOGGED VIEW and SEQUENCE
Date
Msg-id AANLkTik=ER4L5xuAxM8rahacFNm1Gn6tbSZ7DnAGutLN@mail.gmail.com
Whole thread Raw
In response to Assertion failure on UNLOGGED VIEW and SEQUENCE  (Itagaki Takahiro <itagaki.takahiro@gmail.com>)
Responses Re: Assertion failure on UNLOGGED VIEW and SEQUENCE  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Fri, Feb 18, 2011 at 6:42 AM, Itagaki Takahiro
<itagaki.takahiro@gmail.com> wrote:
> UNLOGGED is defigned in OptTemp in gram.y, so the parser accepts
> CREATE UNLOGGED VIEW and CREATE UNLOGGED SEQUENCE, but they are
> actually not supported.
>
> =# CREATE UNLOGGED VIEW uv AS SELECT 1;
> TRAP: FailedAssertion("!(relkind == 'r' || relkind == 't')", File:
> "heap.c", Line: 1246)
>
> =# CREATE UNLOGGED SEQUENCE us;
> TRAP: FailedAssertion("!(relkind == 'r' || relkind == 't')", File:
> "heap.c", Line: 1246)
>
> The most easiest fix would be preventing them in parser level.

Well, that sucks.  I had intended for that to be disallowed at the
parser level, but obviously I fail.  It seems that disallowing this in
the parser will require duplicating the OptTemp production.  Or
alternatively we can just add an error check to the CREATE VIEW and
CREATE SEQUENCE productions, i.e.

if ($4 == RELPERSISTENCE_UNLOGGED)   ereport(ERROR, ...);

I am somewhat leaning toward the latter option, to avoid unnecessarily
bloating the size of the parser tables, but I can do it the other way
if people prefer.

In scrutinizing this code again, I notice that I accidentally added
the ability to create an unlogged table using SELECT INTO, as in
"SELECT 1 INTO UNLOGGED foo", just as you can also do "SELECT 1 INTO
TEMP foo".  I don't see any particular reason to disallow that, but I
should probably update the documentation.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: WIP - Add ability to constrain backend temporary file space
Next
From: Simon Riggs
Date:
Subject: Re: [COMMITTERS] pgsql: Separate messages for standby replies and hot standby feedback.