Re: LOCK TABLE HELP

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

luca(dot)ciciriello(at)email(dot)it wrote:
> 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

Nope, sorry. Still full of HTML stuff. Hang on, I'll see if I can fix it.

Luca's message below:
=====================

I'm using for the first time the postgres lock utilities, but brobably
I'm doing something of not legal.

My action are:

void *Execute(void *pParam)
{
........................................
........................................

& nbsp; string tableLock = "BEGIN WORK;";
tableLock.append(" LOCK TABLE ");
tableLock.append(actorTable);
tableLock.append(" IN ACCESS EXCLUSIVE MODE;");
res = PQexec(connection, tableLock.c_str());

........................................
........................................


pObj->ReturnNotification(static_cast<string>(notify->relname),connection);

.........................................
.........................................

CleanUpBeforeStop(void *pParam);
}

void CleanUpBeforeStop(void *pParam)
{
.........................................
.........................................
res = PQexec(pPti->conn, "COMMIT WORK;");
}

Well, the function Execute is the detached procedure of a thread. In
here I execute the LOCK command on the table "actorTable". 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't work (the connection is th e 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?

Any Idea?

Thanks in advance.

Luca

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marko Kreen 2008-03-14 15:36:20 Re: Trigger to run @ connection time?
Previous Message Greg Smith 2008-03-14 15:24:12 Re: pgbench not setting scale size correctly?