Re: LOCK TABLE HELP

From: luca(dot)ciciriello(at)email(dot)it
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: LOCK TABLE HELP
Date: 2008-03-14 15:20:52
Message-ID: cbb469eb01d4190428c680bc639a1289@85.18.140.153
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sorry for the bad text format. Below the right (I hope...) &nbsp;text:
Hi All.I&#39;m using for the first time the postgres lock utilities, but
brobably I&#39;m doing something of not legal.My action are:void
*Execute(void *pParam){&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
........................................&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
........................................&nbsp;&nbsp; &nbsp; &nbsp;
&nbsp;string tableLock = &quot;BEGIN WORK;&quot;;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp; &nbsp;tableLock.append(&quot; LOCK TABLE &quot;);&nbsp;&nbsp;&nbsp;
&nbsp; &nbsp; &nbsp;tableLock.append(actorTable);&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp; &nbsp;tableLock.append(&quot; IN ACCESS EXCLUSIVE
MODE;&quot;);&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;res = PQexec(connection,
tableLock.c_str());&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
........................................&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
........................................&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
pObj-&gt;ReturnNotification(static_cast&lt;string&gt;(notify-&gt;relname),connection);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
.........................................&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
.........................................&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CleanUpBeforeStop(void *pParam);}void CleanUpBeforeStop(void
*pParam){&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
.........................................&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
.........................................&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
res = PQexec(pPti-&gt;conn, &quot;COMMIT WORK;&quot;);}Well, the function
Execute is the detached procedure of a thread. In here I execute the LOCK
command on the table &quot;actorTable&quot;. Then, in the method
ReturnNotification I read the locked table. At last, calling the function
CleanUpBeforeStop, I execute the COMMIT command.Well, all this doesn&#39;t
work (the connection is the always the same in all methods and functions).
Have I to Lock the table, perform some operation on this table, and unlock
the table all in the same function scope?&nbsp;Any Idea?Thanks in
advance.Luca--------- Original Message --------Da: &quot;Richard
Huxton&quot; &lt;dev(at)archonet(dot)com&gt;To: Cc:
pgsql-general(at)postgresql(dot)orgOggetto: Re: [GENERAL] LOCK TABLE HELPData:
14/03/08 16:35luca(dot)ciciriello(at)email(dot)it wrote:&gt; Hi All.&gt; &gt;
I&amp;#39;m using for the first time the postgres lock utilities, but
brobably&gt; I&amp;#39;m doing something of not legal.My action are:void
*Execute(void&gt; *pParam){ ........................................
........................................&amp;nbsp;&amp;nbsp;&gt; &amp;nbsp;
&amp;nbsp; &amp;nbsp;string tableLock = &amp;quot;BEGIN&gt;
WORK;&amp;quot;;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;
&amp;nbsp;tableLock.append(&amp;quot;&gt; LOCK TABLE &amp;quot;);&amp;nbsp;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;Could you repost your message
without all the &amp;nbsp stuff? There&#39;s probably a &quot;plain
text&quot; option in your email package you need to turn on.-- Richard
HuxtonArchonet Ltd-- Sent via pgsql-general mailing list
(pgsql-general(at)postgresql(dot)org)To make changes to your
subscription:http://www.postgresql.org/mailpref/pgsql-general
--
Email.it, the professional e-mail, gratis per te: http://www.email.it/f

Sponsor:
Scopri le tue passioni con Leonardo.it!

Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7615&d=20080314

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Micah Yoder 2008-03-14 15:22:57 Re: PG secure for financial applications ...
Previous Message paul rivers 2008-03-14 15:17:16 Re: postgre vs MySQL