ERROR: column "id" inherits conflicting default values
In 8.4.1, trying to load a dump from 8.3.5, I get that error from this
statement:
CREATE TABLE "PatientDocument" (
)
INHERITS ("PatientRelated", "Document");
But I do not see any conflict:
# \d "PatientRelated"
Table "v2.PatientRelated"
Column | Type | Modifiers
-------+--------+---------------------------------------------------------
id | bigint | not null default nextval(('"DbRowIds"'::text)::regclass)
...
# \d "Document"
Table "v2.Document"
Column | Type | Modifiers
-------+--------+---------------------------------------------------------
id | bigint | not null default nextval(('"DbRowIds"'::text)::regclass)
...
Should I really have to re-specify the default in this case???
--
Scott Ribe
scott_ribe@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice
Scott Ribe <scott_ribe@killerbytes.com> writes:
Should I really have to re-specify the default in this case???
Works for me:
regression=# create sequence s1;
CREATE SEQUENCE
regression=# create table t1 (f1 bigint default nextval('s1'::text::regclass));
CREATE TABLE
regression=# create table t2 (f1 bigint default nextval('s1'::text::regclass));
CREATE TABLE
regression=# create table t3 (f2 int) inherits(t1,t2);
NOTICE: merging multiple inherited definitions of column "f1"
CREATE TABLE
regression=# \d t3
Table "public.t3"
Column | Type | Modifiers
--------+---------+-----------------------------------------
f1 | bigint | default nextval(('s1'::text)::regclass)
f2 | integer |
Inherits: t1,
t2
Can you show an actual test case?
regards, tom lane
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");
--
Scott Ribe
scott_ribe@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice
Scott Ribe <scott_ribe@killerbytes.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