X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2F2BF52816 for ; Fri, 29 Jul 2005 14:10:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 94777-01 for ; Fri, 29 Jul 2005 17:10:39 +0000 (GMT) Received: from qtm.net (mummra.qtm.net [216.163.32.14]) by svr1.postgresql.org (Postfix) with SMTP id 5D24D5282C for ; Fri, 29 Jul 2005 14:10:38 -0300 (ADT) Received: (qmail 33180 invoked from network); 29 Jul 2005 17:10:36 -0000 Received: from unknown (HELO ?192.168.0.110?) (mur@216.163.42.222) by mummra.qtm.net with SMTP; 29 Jul 2005 17:10:36 -0000 Message-ID: <42EA62DC.4060205@endpoint.com> Date: Fri, 29 Jul 2005 13:09:48 -0400 From: Jeff Boes Organization: End Point User-Agent: Mozilla Thunderbird 1.0.5 (Windows/20050711) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: CREATE TABLE AS SELECT X-Enigmail-Version: 0.92.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.182 tagged_above=0 required=5 tests=AWL, SUBJ_ALL_CAPS X-Spam-Level: X-Archive-Number: 200507/245 X-Sequence-Number: 22223 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.