From: | Dimitri Fontaine <dim(at)hi-media(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Andrew Dunstan <andrew(at)dunslane(dot)net>, Josh Berkus <josh(at)agliodbs(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: alter + preserving dependencies |
Date: | 2008-05-07 06:22:38 |
Message-ID: | A63068F5-0DE7-41D0-A766-59470BF849AF@hi-media.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Le 7 mai 08 à 07:52, Tom Lane a écrit :
> Dimitri Fontaine <dim(at)hi-media(dot)com> writes:
>> Could we consider ALTER VIEW ALTER COLUMN ... SET DEFAULT ...;?
>
> We could if we hadn't already done it five or so years ago.
> Or am I missing what you need here?
My 8.3.1 installation psql \h only gives me:
Syntax:
ALTER VIEW name RENAME TO newname
Ok, I've been quite bad at explaining the case, let's retry.
CREATE TABLE t(id serial, name text not null, a_count not null default
0, option);
CREATE VIEW v AS SELECT * FROM t;
Now we add a on INSERT RULE such as INSERT INTO v will insert to t.
And we want the RULE to be able to use the a_count DEFAULT when user
didn't give a_count column in its INSERT order:
INSERT INTO v(name) VALUES ('foo');
The RULE kicks in and rewrite the INSERT to target t, and a_count not
being given explicitely any value will get rewritten to NULL, not to
DEFAULT, and the INSERT subsequently fails.
In order to be able to avoid this, AFAIK, you need to poke into
catalogs to retrieve the DEFAULT value, at the RULE definition level...
>> Bonus question: why is the rewriter unable to distinguish whether
>> NULL
>> comes from the user or comes from the column was not part of the user
>> query?
>
> Not following this either ...
...and the RULE definition has no chance to figure out by itself if
the user omit to give any value for our not null column, or
explicitely gave a NULL, in which case we'd better not rewrite it to
DEFAULT...
Hope I made the case clear by now, thx for your interest,
--
dim
From | Date | Subject | |
---|---|---|---|
Next Message | Alex Hunsaker | 2008-05-07 06:41:34 | Re: [badalex@gmail.com: Re: [BUGS] Problem identifying constraints which should not be inherited] |
Previous Message | Alex Hunsaker | 2008-05-07 06:20:37 | Re: [badalex@gmail.com: Re: [BUGS] Problem identifying constraints which should not be inherited] |