Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 84CC22E0045 for ; Wed, 16 Jan 2008 03:41:36 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 16908-08 for ; Wed, 16 Jan 2008 03:41:29 -0400 (AST) Received: from bay0-omc3-s18.bay0.hotmail.com (bay0-omc3-s18.bay0.hotmail.com [65.54.246.218]) by postgresql.org (Postfix) with ESMTP id DCC5D2E156A for ; Wed, 16 Jan 2008 03:41:29 -0400 (AST) Received: from BAY137-W28 ([64.4.48.63]) by bay0-omc3-s18.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 15 Jan 2008 23:41:27 -0800 Message-ID: X-Originating-IP: [220.253.65.99] From: Dennis Wang To: Tom Lane CC: Postgresql Help Subject: Re: URGENET: ALTER statement exectuation hangs when it is executed multiple time on a t Date: Wed, 16 Jan 2008 18:11:27 +1030 Importance: Normal Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginalArrivalTime: 16 Jan 2008 07:41:27.0984 (UTC) FILETIME=[33FC1300:01C85813] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/6 X-Sequence-Number: 6684 Hi Tom Thank you very much for the help. > To: dennis_02_2002@hotmail.com > CC: pgsql-interfaces@postgresql.org > Subject: Re: [INTERFACES] URGENET: ALTER statement exectuation hangs when= it is executed multiple time on a table > Date: Thu, 10 Jan 2008 20:09:58 -0500 > From: tgl@sss.pgh.pa.us > > Dennis Wang writes: >> The actual PostgreSQL commands are: >> ALTER TABLE warngrid ALTER COLUMN id SET DEFAULT (nextval('warngrid_seq'= )* 10)+1; >> COPY warngrid FROM 'warngrid.csv' CSV HEADER; >> ALTER TABLE warngrid ALTER COLUMN id DROP DEFAULT; > >> For the first time, these operation execute fine. Then I do these steps: >> 4. delete all the records in the table >> 5. rerun the shell script to copy records. > >> Then, the ALTER statement in step 1 hanging there. > Did you do all this in one database session, or more than one? If the > latter, maybe you haven't committed the transaction that did the DELETE? I delete the records by login the database with 'psql' command, the ALTER s= tatement is running by another process. So I guess the DELETE and ALTER are= in two different session. However, the DELETE statement is a one shot comm= and, it should commit immediately if I did not put it in a "BEGIN ... COMMI= T" block.=20 I will try that again by issue COMMIT right after the DELETE to see any dif= ference. >> I did check the lock state of the warngrid table, it says the process cr= eated by the ALTER statement hold an 'AccessExclusiveLock' on the table. > > Did it actually *have* that lock, or was it waiting for it (granted =3D f > in pg_locks)? The process actually have the Lock. > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org Regard Dennis _________________________________________________________________ New music from the Rogue Traders - listen now! http://ninemsn.com.au/share/redir/adTrack.asp?mode=3Dclick&clientID=3D832&r= eferral=3DhotmailtaglineOct07&URL=3Dhttp://music.ninemsn.com.au/roguetrader= s=