Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 86299476053 for ; Thu, 15 Aug 2002 04:45:03 -0400 (EDT) Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by postgresql.org (Postfix) with ESMTP id 602A247605F for ; Thu, 15 Aug 2002 04:45:02 -0400 (EDT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-35.mail.demon.net with esmtp (Exim 3.36 #2) id 17fGFb-0005Lg-0U; Thu, 15 Aug 2002 09:45:03 +0100 Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id 1C842140BB; Thu, 15 Aug 2002 09:43:58 +0100 (BST) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: Andreas Tille , PostgreSQL SQL Subject: Re: Explicite typecasting of functions Date: Thu, 15 Aug 2002 09:43:53 +0100 User-Agent: KMail/1.4.1 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200208150943.54761.dev@archonet.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/245 X-Sequence-Number: 9091 On Thursday 15 Aug 2002 8:13 am, Andreas Tille wrote: > On Wed, 14 Aug 2002, Tom Lane wrote: > > CREATE TABLE without mentioning the default > > CREATE FUNCTION > > ALTER TABLE ... SET DEFAULT > > > > Note however that pg_dump is not bright enough to deduce that you did > > this. It will dump the table definition first, with the DEFAULT clause, > > and so you'll have to do manual surgery on the dump file if you ever > > need to reload. > > Hmmm, the original problem I wanted to solve using this function is that > pg_dump is not bright enough to store sequences. Eh? If you run a pg_dump on your database you should get something like: CREATE SEQUENCE "bar_a_seq" start 1 increment 1 maxvalue 922337203685477580= 7=20 minvalue 1 cache 1; CREATE TABLE "bar" ( "a" integer DEFAULT nextval('"bar_a_seq"'::text) NOT NULL, "b" integer ); ... data then follows... -- Name: bar_a_seq Type: SEQUENCE SET Owner: richardh SELECT setval ('"bar_a_seq"', 3, true); It's that last bit that sets the value of the sequence. Now AFAIK pg_dump's= =20 been like that pretty much forever. Note - if you only pg_dump the table, you won't get the sequence, you need = to=20 dump the whole DB and grep away the bits you don't want. - Richard Huxton