Re: ERROR: column "id" inherits conflicting default values

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Scott Ribe <scott_ribe(at)killerbytes(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ERROR: column "id" inherits conflicting default values
Date: 2009-10-05 02:30:54
Message-ID: 17543.1254709854@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Scott Ribe <scott_ribe(at)killerbytes(dot)com> writes:
>> Can you show an actual test case?

> create sequence "DbRowIds";

> create table "PatientRelated" (id int8 not null default
> nextval('"DbRowIds"'));

> create table "Document" (id int8 not null default nextval('"DbRowIds"'));

> create table "PatientDocument" () inherits ("PatientRelated", "Document");

Huh, so it turns out it depends on the exact length of the commands :-(

The code is comparing strings like this:

(gdb) p def->cooked_default
$3 = 0x4015c7a0 "{FUNCEXPR :funcid 1574 :funcresulttype 20 :funcretset false :funcformat 0 :args ({CONST :consttype 2205 :consttypmod -1 :constlen 4 :constbyval true :constisnull false :location 64 :constvalue 4 [ 0 2 108 85 ]}) :location 56}"
(gdb) p this_default
$4 = 0x40125ae0 "{FUNCEXPR :funcid 1574 :funcresulttype 20 :funcretset false :funcformat 0 :args ({CONST :consttype 2205 :consttypmod -1 :constlen 4 :constbyval true :constisnull false :location 59 :constvalue 4 [ 0 2 108 85 ]}) :location 51}"

The location fields shouldn't be considered relevant, but since it's a
plain strcmp() they matter. This used to work as expected, and got
broken by the addition of more syntax location tracking support in 8.4.

I guess we're going to have to rewrite that code to not store the cooked
defaults in string form. If they were node trees then equal() would do
the right thing.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christophe Pettus 2009-10-05 02:34:13 Re: How useful is the money datatype?
Previous Message Guy Rouillier 2009-10-05 02:09:15 Re: How useful is the money datatype?