From: | Jeff Boes <jeff(at)endpoint(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | CREATE TABLE AS SELECT |
Date: | 2005-07-29 17:09:48 |
Message-ID: | 42EA62DC.4060205@endpoint.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Offered up because I have no explanation, and curiosity overwhelms me:
I was attempting to create a table from a SELECT statement against
another table:
create table foo
as select
a,
f(b)
from xxx;
The function f() attempts to make a unique value based on its argument
(it's actually a "username" constructor, making "jboes" out of "Jeff
Boes"). The odd thing is that function f() also looks into the table
"foo" to see if the value it's constructing is truly unique; if it is
not, it tacks on a "1", "2", etc. until it gets a unique value.
The odd behavior is as follows: with a "CREATE TABLE ... AS SELECT"
statement, the function never found duplicate values, so I ended up with
f(a) = f(a') = f(a''), etc. I tried defining the function as STABLE,
then VOLATILE, without success. But if I changed to create the table
first, and then do "INSERT INTO ... SELECT", the function worked properly.
From | Date | Subject | |
---|---|---|---|
Next Message | daq | 2005-07-29 18:53:21 | Re: CREATE TABLE AS SELECT |
Previous Message | gherzig | 2005-07-29 15:59:28 | Re: calling EXECUTE on any exception |