=?iso-8859-1?q?Erik=20Ronstr=F6m?= <kvarken@yahoo.com> writes:
> I just discovered an interesting thing: the problem comes from this
> code:
> EXECUTE ''ALTER TABLE '' || dv || '' ADD CONSTRAINT idfk FOREIGN KEY
> (_id) REFERENCES dt_'' || a_table;
You're going to need to provide a self-contained example, or else a
stack trace. This simple experiment didn't reproduce it:
regression=# create function doit(text) returns int as '
regression'# begin
regression'# execute $1;
regression'# return 1;
regression'# end' language plpgsql;
CREATE FUNCTION
regression=# create table ff1 (f1 int primary key);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'ff1_pkey' for table 'ff1'
CREATE TABLE
regression=# create table ff2 (f1 int);
CREATE TABLE
regression=# select doit('alter table ff2 add constraint idfk foreign key(f1)
regression'# references ff1');
NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
doit
------
1
(1 row)
regards, tom lane