X-Original-To: pgsql-odbc-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id B22B29FB20B for ; Tue, 29 Aug 2006 06:10:04 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 92896-08 for ; Tue, 29 Aug 2006 09:09:53 +0000 (UTC) X-Greylist: delayed 00:24:46.962972 by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 8591B9FB209 for ; Tue, 29 Aug 2006 06:09:53 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from www.freemail.gr (www.freemail.gr [81.171.104.45]) by svr4.postgresql.org (Postfix) with ESMTP id 0226D5AF899 for ; Tue, 29 Aug 2006 08:45:04 +0000 (GMT) Received: from www.freemail.gr (www.freemail.gr [127.0.0.1]) by www.freemail.gr (8.12.11.20060308/8.12.11) with SMTP id k7T8j29M022269 for ; Tue, 29 Aug 2006 11:45:02 +0300 Reply-To: anomatos@freemail.gr From: anomatos@freemail.gr To: pgsql-odbc@postgresql.org Subject: Record locking issue using ODBC from .NET Date: Tue, 29 Aug 2006 11:45:02 +0300 Message-Id: <44f3fe8e70f865.32121596@freemail.gr> X-Authenticated-IP: ipa160.15.tellas.gr (84.254.15.160) X-Sender: anomatos@81.171.104.54 X-Mailer: FreeMail.gr 1.08 (http://www.freemail.gr/) X-Info-1: Report spam to abuse@freemail.gr MIME-version: 1.0 Content-type: text/plain; charset="iso-8859-7" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.345 tagged_above=0 required=5 tests=NO_REAL_NAME, SPF_SOFTFAIL X-Spam-Level: ** X-Archive-Number: 200608/124 X-Sequence-Number: 8088 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