Re: CREATE TABLE AS SELECT

From: daq <daq(at)ugyvitelszolgaltato(dot)hu>
To: Jeff Boes <jeff(at)endpoint(dot)com>
Cc: Pgsql-sql(at)postgresql(dot)org
Subject: Re: CREATE TABLE AS SELECT
Date: 2005-07-29 18:53:21
Message-ID: 49272002437.20050729205321@ugyvitelszolgaltato.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


JB> Offered up because I have no explanation, and curiosity overwhelms me:

JB> I was attempting to create a table from a SELECT statement against
JB> another table:

JB> create table foo
JB> as select
JB> a,
JB> f(b)
JB> from xxx;

In this command table foo populated after the select statement
sucessfully finished. The function always runs on an empty foo table.

JB> The function f() attempts to make a unique value based on its argument
JB> (it's actually a "username" constructor, making "jboes" out of "Jeff
JB> Boes"). The odd thing is that function f() also looks into the table
JB> "foo" to see if the value it's constructing is truly unique; if it is
JB> not, it tacks on a "1", "2", etc. until it gets a unique value.

JB> The odd behavior is as follows: with a "CREATE TABLE ... AS SELECT"
JB> statement, the function never found duplicate values, so I ended up with
JB> f(a) = f(a') = f(a''), etc. I tried defining the function as STABLE,
JB> then VOLATILE, without success. But if I changed to create the table
JB> first, and then do "INSERT INTO ... SELECT", the function worked properly.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Matthew Schumacher 2005-07-29 23:39:12 How to loop though an array plpgsql?
Previous Message Jeff Boes 2005-07-29 17:09:48 CREATE TABLE AS SELECT