X-Original-To: pgsql-odbc-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id F1FB19FA5FE for ; Tue, 29 Aug 2006 20:58:24 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 94272-01-5 for ; Tue, 29 Aug 2006 20:58:14 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sd.tpf.co.jp (sd.tpf.co.jp [210.161.239.34]) by postgresql.org (Postfix) with SMTP id 9D2129F9DC0 for ; Tue, 29 Aug 2006 20:39:57 -0300 (ADT) Received: (qmail 5434 invoked from network); 30 Aug 2006 08:39:54 +0900 Received: from unknown (HELO ?100.0.32.123?) (100.0.32.123) by sd2.tpf-fw-c.co.jp with SMTP; 30 Aug 2006 08:39:54 +0900 Message-ID: <44F4D02F.3080406@tpf.co.jp> Date: Wed, 30 Aug 2006 08:39:27 +0900 From: Hiroshi Inoue User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: anomatos@freemail.gr CC: pgsql-odbc@postgresql.org Subject: Re: Record locking issue using ODBC from .NET References: <44f3fe8e70f865.32121596@freemail.gr> In-Reply-To: <44f3fe8e70f865.32121596@freemail.gr> Content-Type: text/plain; charset=ISO-8859-7; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.506 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200608/136 X-Sequence-Number: 8100 Hi Antonis, Which version of driver are you using ? regards, Hiroshi Inoue anomatos@freemail.gr wrote: > I want to have exclusive read access to a table row, so that if a client has access to that row, any other client should either wait or get an error of the type "could not obtain lock on row in relation 'customers'", depending on the semantics used in the query string(nowait) > > Both clients execute: > > ... > OdbcTransaction ^ transaction = connection->BeginTransaction(); > String ^ query = "select * from customers where id = 3 for update nowait"; > OdbcCommand ^ cmd = (gcnew OdbcCommand(query, connection, transaction)); > reader = cmd->ExecuteReader(); > ... > > After the first client locks the record and before he ends the transaction, the second tries to acquire the lock. As expected an exception is raised, BUT: > > One would expect that this exception is of type OdbcException explaining that "the lock cannot be aquired". Instead of this I get a System::InvalidOperationException which disables my connection for some reason. However the above exception hosts an inner exception of the desired type(OdbcException). > > Does anybody have any idea why I get this type of behaviour, why is my connection closed? > > Thanks a lot in advance, > Antonis