Server does not reply to Alter Table

Started by Patrick Dunfordabout 24 years ago8 messagesgeneral
Jump to latest
#1Patrick Dunford
dunfordsoft@clear.net.nz

Using pgsql 7.1.3 I have found that on occasions, there is no reply to an
SQL statement like

ALTER TABLE x
ADD COLUMN y z

The table itself will be inaccessible for at least 10 minutes and/or error
messages will result. The column may or may not be added.

=================================
Patrick Dunford, Christchurch, NZ
http://pdunford.godzone.net.nz/
http://www.trainweb.org/ferrymead/

#2Yogesh Kansal
yogesh@davlin.co.in
In reply to: Patrick Dunford (#1)
Commit , Rollback

Hi List ,
Could any one of you help me in finding out a way by which
1)when i login to postgres "begin transaction " command automatically
executes .
2)i write commit it should commit as well as begin the new transaction .
3) similarly with rollback.

from
yogesh

#3Doug McNaught
doug@wireboard.com
In reply to: Patrick Dunford (#1)
Re: Commit , Rollback

"Yogesh Kansal" <yogesh@davlin.co.in> writes:

Hi List ,
Could any one of you help me in finding out a way by which
1)when i login to postgres "begin transaction " command automatically
executes .
2)i write commit it should commit as well as begin the new transaction .
3) similarly with rollback.

Do it at the application level.

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
--T. J. Jackson, 1863

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Patrick Dunford (#1)
Re: Server does not reply to Alter Table

Patrick Dunford <dunfordsoft@clear.net.nz> writes:

Using pgsql 7.1.3 I have found that on occasions, there is no reply to an
SQL statement like

ALTER TABLE x
ADD COLUMN y z

You sure it's not just waiting for some other transaction to give up a
lock on the table? ALTER TABLE ADD COLUMN should be essentially
instantaneous, since it doesn't touch the table data. But it needs to
get exclusive lock on the table first.

regards, tom lane

#5Yogesh Kansal
yogesh@davlin.co.in
In reply to: Doug McNaught (#3)
Re: Commit , Rollback

no i want this while quering on the prompt of psql ... actually i want a
precautionary measure while doing updates , inserts or delete to a table ..
i want this so that i can roll back the whole transaction if i make some
mistake ..
thanks for reply.
yogesh

"Yogesh Kansal" <yogesh@davlin.co.in> writes:

Hi List ,
Could any one of you help me in finding out a way by which
1)when i login to postgres "begin transaction " command automatically
executes .
2)i write commit it should commit as well as begin the new transaction .
3) similarly with rollback.

Do it at the application level.

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
--T. J. Jackson, 1863

--
Walking on water and developing software from a specification are easy if
both are frozen."
-- Edward V. Berard, "Life-Cycle Approaches"

#6Doug McNaught
doug@wireboard.com
In reply to: Doug McNaught (#3)
Re: Commit , Rollback

"Yogesh Kansal" <yogesh@davlin.co.in> writes:

no i want this while quering on the prompt of psql ... actually i want a
precautionary measure while doing updates , inserts or delete to a table ..
i want this so that i can roll back the whole transaction if i make some
mistake ..

Well, it can't be done without changing the code. So change the code,
or live with it and remember to type BEGIN before you start working.

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
--T. J. Jackson, 1863

#7Greg Sabino Mullane
greg@turnstep.com
In reply to: Doug McNaught (#6)
Re: Commit , Rollback

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

no i want this while quering on the prompt of psql ... actually i want a
precautionary measure while doing updates , inserts or delete to a table
..
i want this so that i can roll back the whole transaction if i make some
mistake ..
thanks for reply.
yogesh

I wrote a patch that does just this via a -b and \b option: anyone
is welcome to play with it:

http://www.gtsm.com/postgres.html

It is based on the latest cvs version of postgresql, so take care
if applying to an older version. If you have problems and need
a patch for an earlier version, let me know.

Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200202061602

-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iQA/AwUBPGGbY7ybkGcUlkrIEQK/EwCgx0gzPhAzaYH9EDXjvMzbkdSDGHQAn2sl
cUkRmHT9plAIuuk1blD7wU2z
=jU3I
-----END PGP SIGNATURE-----

#8Patrick Dunford
a47xxy@yahoo.co.nz
In reply to: Tom Lane (#4)
Re: Server does not reply to Alter Table

In article <25074.1012924704@sss.pgh.pa.us> in newsgroup
comp.databases.postgresql.general on Tue, 5 Feb 2002 16:10:06 +0000
(UTC), Tom Lane(tgl@sss.pgh.pa.us) said...

Patrick Dunford <dunfordsoft@clear.net.nz> writes:

Using pgsql 7.1.3 I have found that on occasions, there is no reply to an
SQL statement like

ALTER TABLE x
ADD COLUMN y z

You sure it's not just waiting for some other transaction to give up a
lock on the table? ALTER TABLE ADD COLUMN should be essentially
instantaneous, since it doesn't touch the table data. But it needs to
get exclusive lock on the table first.

Well if it doesn't send a message back to the client then there is no way
of knowing this.

I had it do the same thing on two Drop Table requests, eventually it came
back and said the relation does not exist so I knew then it had dropped
the table but not because it had replied to the first request.