Re: [GSoC2014] Patch ALTER TABLE ... SET LOGGED - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: [GSoC2014] Patch ALTER TABLE ... SET LOGGED
Date
Msg-id 53F6402F.7000901@vmware.com
Whole thread Raw
In response to Re: [GSoC2014] Patch ALTER TABLE ... SET LOGGED  (Thom Brown <thom@linux.com>)
Responses Re: [GSoC2014] Patch ALTER TABLE ... SET LOGGED
List pgsql-hackers
On 08/21/2014 05:04 PM, Thom Brown wrote:
> On 21 August 2014 14:45, Fabrízio de Royes Mello <fabriziomello@gmail.com>
> wrote:
>
>> On Thu, Aug 21, 2014 at 5:23 AM, Christoph Berg <cb@df7cb.de> wrote:
>>>
>>> Re: Thom Brown 2014-08-20 <CAA-aLv7TeF8iM=
>> 7U7TsgL4S5Jh1a+shQ_Ny7gOrZc_g_YJ7uKA@mail.gmail.com>
>>>> "ERROR:  table test is not permanent"
>>>>
>>>> Perhaps this would be better as "table test is unlogged" as "permanent"
>>>> doesn't match the term used in the DDL syntax.
>>>
>>> I was also wondering that, but then figured that when ALTER TABLE SET
>>> UNLOGGED is invoked on temp tables, the error message "is not
>>> permanent" was correct while the apparent opposite "is unlogged" is
>>> wrong.
>>
>> Thom,
>>
>> Christoph is right... make no sense the message... see the example:
>>
>> fabrizio=# create temp table foo();
>> CREATE TABLE
>> fabrizio=# alter table foo set unlogged;
>> ERROR:  table foo is unlogged
>>
>> The previous message is better:
>>
>> fabrizio=# create temp table foo();
>> CREATE TABLE
>> fabrizio=# alter table foo set unlogged;
>> ERROR:  table foo is not permanent
>> fabrizio=#
>> fabrizio=# create unlogged table foo2();
>> CREATE TABLE
>> fabrizio=# alter table foo2 set unlogged;
>> ERROR:  table foo2 is not permanent
>>
>
> To me, that's even more confusing:
>
> CREATE TEMP TABLE test();
> CREATE UNLOGGED TABLE test2();
>
> # ALTER TABLE test SET LOGGED;
> ERROR:  table test is not unlogged
>
> # ALTER TABLE test SET UNLOGGED;
> ERROR:  table test is not permanent
>
> # ALTER TABLE test2 SET UNLOGGED;
> ERROR:  table test2 is not permanent
>
> They're being rejected for different reasons but the error message is
> identical.  Permanent suggests the opposite of temporary, and unlogged
> tables aren't temporary.

In Postgres internals slang, non-permanent means temporary or unlogged. 
But I agree we shouldn't expose users to that term; we use it in the 
docs, and it's not used in command names either.

I wonder if throwing an error is correct behavior anyway. Other ALTER 
TABLE commands just silently do nothing in similar situations, e.g:

lowerdb=# CREATE TABLE foo () WITH OIDS;
CREATE TABLE
lowerdb=# ALTER TABLE foo SET WITH OIDS;
ALTER TABLE

But if we want to throw an error anyway, I'd suggest phrasing it "table 
foo is already unlogged"

- Heikki




pgsql-hackers by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: WIP Patch for GROUPING SETS phase 1
Next
From: Bruce Momjian
Date:
Subject: Re: Hardening pg_upgrade