Different error messages executing CREATE TABLE or ALTER TABLE to create a column "xmin"

Lists: pgsql-bugspgsql-hackers
From: Giuseppe Sucameli <brush(dot)tyler(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Different error messages executing CREATE TABLE or ALTER TABLE to create a column "xmin"
Date: 2012-01-22 13:22:06
Message-ID: CAA6k8-LSvJ8jGpJd2gUr6W47KkCuvy23fo3bzqCsmFP0BMoAUA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Hi all,

trying to create a table with a column xmin I get the
following error message:

test=> create table lx (xmin int);
ERROR: column name "xmin" conflicts with a system
column name

Instead I get a different (and less understandable) error
message if I try to add a column named xmin to an
existent table:

test=> create table lx (i int);
CREATE TABLE
test=> alter table lx add xmin int;
ERROR: column "xmin" of relation "lx" already exists.

The same problem occurs using "xmax" as column name.

I'm on Ubuntu 11.04.
Tried on both PostgreSQL 8.4.10 and 9.1.2

Regards.

--
Giuseppe Sucameli


From: Marc Balmer <marc(at)msys(dot)ch>
To: pgsql-bugs(at)postgresql(dot)org, brush(dot)tyler(at)gmail(dot)com
Subject: Re: Different error messages executing CREATE TABLE or ALTER TABLE to create a column "xmin"
Date: 2012-01-23 10:25:01
Message-ID: 4F1D357D.5080407@msys.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Am 22.01.12 14:22, schrieb Giuseppe Sucameli:
> Hi all,
>
> trying to create a table with a column xmin I get the
> following error message:
>
> test=> create table lx (xmin int);
> ERROR: column name "xmin" conflicts with a system
> column name
>
> Instead I get a different (and less understandable) error
> message if I try to add a column named xmin to an
> existent table:
>
> test=> create table lx (i int);
> CREATE TABLE
> test=> alter table lx add xmin int;
> ERROR: column "xmin" of relation "lx" already exists.
>
> The same problem occurs using "xmax" as column name.
>
> I'm on Ubuntu 11.04.
> Tried on both PostgreSQL 8.4.10 and 9.1.2

That is not a bug, but a feature. See section 5.4 of the documentation
"System Columns":

"Every table has several system columns that are implicitly defined by
the system. Therefore, these names cannot be used as names of
user-defined columns. (Note that these restrictions are separate from
whether the name is a key word or not; quoting a name will not allow you
to escape these restrictions.) You do not really need to be concerned
about these columns; just know they exist."

and further down:

"xmin

The identity (transaction ID) of the inserting transaction for this row
version. (A row version is an individual state of a row; each update of
a row creates a new row version for the same logical row.)"


From: Vik Reykja <vikreykja(at)gmail(dot)com>
To: Marc Balmer <marc(at)msys(dot)ch>
Cc: pgsql-bugs(at)postgresql(dot)org, brush(dot)tyler(at)gmail(dot)com
Subject: Re: Different error messages executing CREATE TABLE or ALTER TABLE to create a column "xmin"
Date: 2012-01-23 14:04:27
Message-ID: CALDgxVv2CU4c2kpaRZmDTxfMT=HuyNLRYFGnnH13boPE4cw3Zg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Mon, Jan 23, 2012 at 11:25, Marc Balmer <marc(at)msys(dot)ch> wrote:

> Am 22.01.12 14:22, schrieb Giuseppe Sucameli:
> > test=> create table lx (xmin int);
> > ERROR: column name "xmin" conflicts with a system
> > column name
> >
> > test=> create table lx (i int);
> > CREATE TABLE
> > test=> alter table lx add xmin int;
> > ERROR: column "xmin" of relation "lx" already exists.
>
> That is not a bug, but a feature.
>

I see it as a message bug. Why wouldn't ALTER TABLE also tell us that xmin
is a system column? It makes things much more clear for newbies who don't
see the column yet are told it exists if they're also told it's a system
column.

I would try to cook up a patch but I have no skills :-(


From: Giuseppe Sucameli <brush(dot)tyler(at)gmail(dot)com>
To: Marc Balmer <marc(at)msys(dot)ch>
Cc: Vik Reykja <vikreykja(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Different error messages executing CREATE TABLE or ALTER TABLE to create a column "xmin"
Date: 2012-01-24 13:41:56
Message-ID: CAA6k8-LSMiYAQyUCNKs7MOSOOiLPFj4c9Ai2zFkCREROcK3oAQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Hi Marc,

On Mon, Jan 23, 2012 at 3:04 PM, Vik Reykja <vikreykja(at)gmail(dot)com> wrote:
> On Mon, Jan 23, 2012 at 11:25, Marc Balmer <marc(at)msys(dot)ch> wrote:
>>
>> Am 22.01.12 14:22, schrieb Giuseppe Sucameli:
>> > test=> create table lx (i int);
>> > CREATE TABLE
>> > test=> alter table lx add xmin int;
>> > ERROR:  column "xmin" of relation "lx" already exists.
>>
>> That is not a bug, but a feature.
>
> I see it as a message bug.  Why wouldn't ALTER TABLE also tell us that xmin
> is a system column?  It makes things much more clear for newbies who don't
> see the column yet are told it exists if they're also told it's a system
> column.

I agree with Vik, the CREATE TABLE tells "xmin" is a system column,
why wouldn't ALTER TABLE do the same?

This would be a feature if CREATE TABLE didn't tell us that
xmin is a system column, otherwise is a bug.

> I would try to cook up a patch but I have no skills :-(

I'm going to write a patch to fix this problem.
Regards.

--
Giuseppe Sucameli


From: Giuseppe Sucameli <brush(dot)tyler(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Different error messages executing CREATE TABLE or ALTER TABLE to create a column "xmin"
Date: 2012-01-24 14:10:48
Message-ID: CAA6k8-+E_0mAFqt82UrS4CJOW8s5=R5Jp6tKKb1a_-_nUtWgYg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Hi hackers,

the attached patch fixes the problem I explained in pgsql-bugs (forwarded).
It's a trivial problem, so no initial patch design was required.

Hope to see my patch applied.
Thanks for your work.

Regards.

---------- Forwarded message ----------
From: Giuseppe Sucameli <brush(dot)tyler(at)gmail(dot)com>
Date: Sun, Jan 22, 2012 at 2:22 PM
Subject: Different error messages executing CREATE TABLE or ALTER
TABLE to create a column "xmin"
To: pgsql-bugs(at)postgresql(dot)org

Hi all,

trying to create a table with a column xmin I get the
following error message:

test=> create table lx (xmin int);
ERROR:  column name "xmin" conflicts with a system
column name

Instead I get a different (and less understandable) error
message if I try to add a column named xmin to an
existent table:

test=> create table lx (i int);
CREATE TABLE
test=> alter table lx add xmin int;
ERROR:  column "xmin" of relation "lx" already exists.

The same problem occurs using "xmax" as column name.

I'm on Ubuntu 11.04.
Tried on both PostgreSQL 8.4.10 and 9.1.2

Regards.

--
Giuseppe Sucameli

--
Giuseppe Sucameli

Attachment Content-Type Size
postgresql_syscol_message.diff application/octet-stream 2.8 KB

From: Vik Reykja <vikreykja(at)gmail(dot)com>
To: Giuseppe Sucameli <brush(dot)tyler(at)gmail(dot)com>
Cc: Marc Balmer <marc(at)msys(dot)ch>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Different error messages executing CREATE TABLE or ALTER TABLE to create a column "xmin"
Date: 2012-01-24 23:28:14
Message-ID: CALDgxVvgPUk60YeKG8XvQiXoF-UGNChGozdYJ4gXNhbq8RG6NA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Tue, Jan 24, 2012 at 14:41, Giuseppe Sucameli <brush(dot)tyler(at)gmail(dot)com>wrote:

> > I would try to cook up a patch but I have no skills :-(
>
> I'm going to write a patch to fix this problem.

I managed to put something together and have posted it on hackers.


From: Giuseppe Sucameli <brush(dot)tyler(at)gmail(dot)com>
To: Vik Reykja <vikreykja(at)gmail(dot)com>
Cc: Marc Balmer <marc(at)msys(dot)ch>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Different error messages executing CREATE TABLE or ALTER TABLE to create a column "xmin"
Date: 2012-01-25 21:19:46
Message-ID: CAA6k8-LxrigeytUshvAw7eB84W386gGV-BuUZpFEGxxd3wbMmQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Hi Vik,

On Wed, Jan 25, 2012 at 12:28 AM, Vik Reykja <vikreykja(at)gmail(dot)com> wrote:
> On Tue, Jan 24, 2012 at 14:41, Giuseppe Sucameli <brush(dot)tyler(at)gmail(dot)com>
> wrote:
>>
>> > I would try to cook up a patch but I have no skills :-(
>>
>> I'm going to write a patch to fix this problem.
>
> I managed to put something together and have posted it on hackers.

thinking you have no skills, I wrote a patch too and posted it to
hackers ML about 2 days ago, but I didn't subscribe that list so
it is stalled, waiting for someone's approval.

For this reason my email is not displayed in the archives.
I'm so sorry both have wasted our time in writing 2 patches for
the same bug.

Regards.

--
Giuseppe Sucameli


From: Vik Reykja <vikreykja(at)gmail(dot)com>
To: Giuseppe Sucameli <brush(dot)tyler(at)gmail(dot)com>
Cc: Marc Balmer <marc(at)msys(dot)ch>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Different error messages executing CREATE TABLE or ALTER TABLE to create a column "xmin"
Date: 2012-01-26 10:43:40
Message-ID: CALDgxVtW5szGU9zmwBdPK3RFyHNz-J3V0zO8GZcSBAfEyO+EUQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Wed, Jan 25, 2012 at 22:19, Giuseppe Sucameli <brush(dot)tyler(at)gmail(dot)com>wrote:

> thinking you have no skills, I wrote a patch too and posted it to
> hackers ML about 2 days ago, but I didn't subscribe that list so
> it is stalled, waiting for someone's approval.
>
> For this reason my email is not displayed in the archives.
> I'm so sorry both have wasted our time in writing 2 patches for
> the same bug.
>

I think your patch is more complete than mine so it's definitely not
wasted. I spent several hours on mine and now I have a little bit of
skills :-)

Thank you for your effort; I'm sorry if you feel you have wasted your time.


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Vik Reykja <vikreykja(at)gmail(dot)com>
Cc: Giuseppe Sucameli <brush(dot)tyler(at)gmail(dot)com>, Marc Balmer <marc(at)msys(dot)ch>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Different error messages executing CREATE TABLE or ALTER TABLE to create a column "xmin"
Date: 2012-01-26 15:19:31
Message-ID: CA+TgmoagVmqkwcZc-Wb3M=o0OTRXORecs7S9oA-SA500ya0hsw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Thu, Jan 26, 2012 at 5:43 AM, Vik Reykja <vikreykja(at)gmail(dot)com> wrote:
> On Wed, Jan 25, 2012 at 22:19, Giuseppe Sucameli <brush(dot)tyler(at)gmail(dot)com>
> wrote:
>>
>> thinking you have no skills, I wrote a patch too and posted it to
>> hackers ML about 2 days ago, but I didn't subscribe that list so
>> it is stalled, waiting for someone's approval.
>>
>> For this reason my email is not displayed in the archives.
>> I'm so sorry both have wasted our time in writing 2 patches for
>> the same bug.
>
> I think your patch is more complete than mine so it's definitely not
> wasted.  I spent several hours on mine and now I have a little bit of skills
> :-)
>
> Thank you for your effort; I'm sorry if you feel you have wasted your time.

I think Vik's patch is better, because it doesn't rely as much on
things that happen to be true today - like which relkinds have system
columns associated with them. But I do agree we ought to handle both
the ADD COLUMN and RENAME COLUMN cases, and as such have posted an
update of Vik's patch on the other thread.

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