Switching between terminals - Mailing list pgsql-hackers

From cinu
Subject Switching between terminals
Date
Msg-id 31174.66139.qm@web7904.mail.in.yahoo.com
Whole thread Raw
Responses Re: Switching between terminals  (Csaba Nagy <nagy@ecircle-ag.com>)
Re: Switching between terminals  (Gregory Stark <stark@enterprisedb.com>)
List pgsql-hackers
<table border="0" cellpadding="0" cellspacing="0"><tr><td style="font: inherit;" valign="top"><p>Hi All, <p><p>I am
havingan issue with a deadlock scenario in PostgreSQL 8.3.1<p>I have the following database postgres, what I do is
createtwo tables t1 and t2 in this database and I have the following fileds <p><p>t1(a_id smallint, fn character(20),
lncharacter(20), rt smallint)<p>t2( c_id smallint, c_name character(20));<p><p>The connection to the "postgres"
databaseis established through two terminals;<p><p><font color="#0000ff">From the 1st terminal I give the following
command</font><p><fontcolor="#0000ff">1) begin transaction; update t2 set c_name = 'lock' where c_id =
1;</font><p><fontcolor="#0000ff"></font><p><font color="#0000ff">From the 2nd terminal I give the following
command</font><p><fontcolor="#0000ff">2) begin transaction; update t1 set ln = 'lock' where a_id = 1;</font><p><font
color="#0000ff"></font><p><fontcolor="#0000ff">Then I come back to the 1st terminal and execute the
following</font><p><fontcolor="#0000ff">3) update t1 set ln = 'lock' where a_id = 1;</font><p><font
color="#0000ff"></font><p><fontcolor="#0000ff">Then I come to 2nd Terminal and execute the following </font><p><font
color="#0000ff">4)update t2 set c_name = 'lock' where c_id = 1;</font><p><p>When I come out I get the following error
message <p><fontcolor="#ff0000">ERROR: deadlock detected<br />DETAIL: Process 15171 waits for ShareLock on transaction
12738;blocked by process 15183.<br />Process 15183 waits for ShareLock on transaction 12739; blocked by process
15171.</font><p><fontcolor="#ff0000"></font><p>This is perfectly fine, but what i am trying to acheive is that I am
puttingthe above four queries in 4 different .sql files and executing it in the same way as displayed above by using
twodifferent terminals, please refer below the sequence which I am using.<p><p><font color="#0000ff">From the 1st
terminalI give the following command</font><p><font color="#0000ff">1) psql -f dl11.sql -U postgres -d
postgres</font><p><fontcolor="#0000ff"></font><p><font color="#0000ff">From the 2nd terminal I give the following
command</font><p><fontcolor="#0000ff">2) </font><font color="#0000ff">psql -f dl21.</font><font color="#0000ff">sql -U
postgres-d postgres</font><p><font color="#0000ff"></font><p><font color="#0000ff">Then I come back to the 1st terminal
andexecute the following</font><p><font color="#0000ff">3) </font><font color="#0000ff">psql -f dl12</font><font
color="#0000ff">.sql-U postgres -d postgres</font><p><font color="#0000ff"></font><p><font color="#0000ff">Then I come
to2nd Terminal and execute the following</font><p><font color="#0000ff">4) </font><font color="#0000ff">psql -f
dl22</font><fontcolor="#0000ff">.sql -U postgres -d postgres</font><p><p>I should be getting the same message about
deadlockdetection, but I am unable to get that.<p><p>Could anyone please tell me where I am going wrong and if there is
away I can get the same behaviour that I am getting while I am executing the through psql prompt.<p><p>Thanks in
advance<p><p>Waitingfor reply<p>Regards<p>Cinu<p><p><p><font color="#ff0000"><br /><br /></font></td></tr></table><br
/><hrsize="1" /> From Chandigarh to Chennai - find friends all over India. <a
href="http://in.rd.yahoo.com/tagline_groups_10/*http://in.promos.yahoo.com/groups/citygroups/">Click here.</a> 

pgsql-hackers by date:

Previous
From: Bernd Helmle
Date:
Subject: Re: Adding variables for segment_size, wal_segment_size and block sizes
Next
From: Csaba Nagy
Date:
Subject: Re: Switching between terminals