From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Christian Ullrich <chris@chrullrich.net>
To: pgsql-odbc@postgresql.org
Subject: Re: Bugs related to getting @@identity
Date: Sat, 01 Aug 2015 00:33:15 +0300
Message-ID: <55BBE99B.7050609@iki.fi> (raw)
In-Reply-To: <mpgesq$18t$1@ger.gmane.org>
References: <mpgesq$18t$1@ger.gmane.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-odbc>
On 07/31/2015 09:30 PM, Christian Ullrich wrote:
> Hello,
>
> as there have been ominous rumblings lately about making another
> release, I wanted to remind you that I reported two bugs on 23 April.
> One breaks @@identity entirely [1], the other makes it unreliable with
> INSERTs into schema-qualified tables [2].
>
> I provided a patch for the second, but there has been no feedback at
> all, and it is possible that the first bug is not real but a mistake I
> made in building the driver from source.
>
> [1] http://www.postgresql.org/message-id/mhaknj$e4g$1@ger.gmane.org
> [2] http://www.postgresql.org/message-id/mhalik$s8k$1@ger.gmane.org
How do you use @@identity? I don't know what the idiomatic way to use it is.
I wrote a little test case for it, see attached patch. But it runs OK
with a fresh git checkout. Could you modify/expand this test case to
tickle the bugs you're seeing?
- Heikki
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbcAttachments:identity-test.patch (application/x-patch, 2.3K) downloaddiff --git a/test/expected/identity.out b/test/expected/identity.outnew file mode 100644index 0000000..71d3e2d--- /dev/null+++ b/test/expected/identity.out@@ -0,0 +1,7 @@+connected+# of rows inserted: 1+Result set:+1+Result set:+1 foobar+disconnectingdiff --git a/test/src/identity-test.c b/test/src/identity-test.cnew file mode 100644index 0000000..cc79e29--- /dev/null+++ b/test/src/identity-test.c@@ -0,0 +1,61 @@+/*+ * Test @@identity+ */+#include <stdio.h>+#include <stdlib.h>++#include "common.h"++int main(int argc, char **argv)+{+ SQLRETURN rc;+ HSTMT hstmt = SQL_NULL_HSTMT;+ char param1[100];+ SQLLEN cbParam1;+ SQLCHAR *sql;+ int i;+ SQLLEN rowcount;++ test_connect();++ rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt);+ if (!SQL_SUCCEEDED(rc))+ {+ print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn);+ exit(1);+ }++ /* Prepare a test table */+ sql = "CREATE TEMPORARY TABLE tmptable (i serial primary key, t text)";+ rc = SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS);+ CHECK_STMT_RESULT(rc, "SQLExecDirect failed while creating temp table", hstmt);++ /* Insert some rows, using a prepared statement */+ rc = SQLExecDirect(hstmt, (SQLCHAR *) "INSERT INTO tmptable (t) VALUES ('foobar'); ",+ SQL_NTS);+ CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt);++ rc = SQLRowCount(hstmt, &rowcount);+ CHECK_STMT_RESULT(rc, "SQLRowCount failed", hstmt);+ printf("# of rows inserted: %d\n", (int) rowcount);++ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT @@IDENTITY AS last_insert", SQL_NTS);+ CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt);++ /* Fetch result */+ print_result(hstmt);++ rc = SQLFreeStmt(hstmt, SQL_CLOSE);+ CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);++ /* Print the contents of the table after the updates to verify */++ rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT * FROM tmptable", SQL_NTS);+ CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt);+ print_result(hstmt);++ /* Clean up */+ test_disconnect();++ return 0;+}diff --git a/test/tests b/test/testsindex e908771..d00c7f3 100644--- a/test/tests+++ b/test/tests@@ -24,6 +24,7 @@ TESTBINS = src/connect-test \
src/notice-test \
src/arraybinding-test \
src/insertreturning-test \
+ src/identity-test \
src/dataatexecution-test \
src/boolsaschar-test \
src/cvtnulldate-test \
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: hlinnaka@iki.fi, chris@chrullrich.net
Subject: Re: Bugs related to getting @@identity
In-Reply-To: <55BBE99B.7050609@iki.fi>
References: <mpgesq$18t$1@ger.gmane.org> <55BBE99B.7050609@iki.fi>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox