pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feedSQL_DATA_AT_EXEC processing broken for large objects in nightly git
9+ messages / 3 participants
[nested] [flat]
* SQL_DATA_AT_EXEC processing broken for large objects in nightly git
@ 2015-10-15 12:00 Vadym Krevs <vkrevs@serena.com>
2015-11-04 07:48 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
0 siblings, 1 reply; 9+ messages in thread
From: Vadym Krevs @ 2015-10-15 12:00 UTC (permalink / raw)
To: pgsql-odbc
Hi,
the nightly git of the psqlODBC driver appears to no longer support
insertion into LO columns when using SQL_DATA_AT_EXEC mode. The latest
released driver version - psqlodbc-09.03.0400 - works. I've tested this
against both PostgreSQL 9.4.4 and 9.4.5 on openSUSE 13.2.
An adapted variant of the large-object-test.c program that uses
SQL_DATA_AT_EXEC mode is attached. When run as part of the regression
test suite against psqlodbc-09.03.0400, both the
large-object-data-at-exec-test.c test completes successfully, just like
large-object-test.c, and produces the following output in
test/results/large-object-data-at-exec.out:
\! "./src/large-object-data-at-exec-test"
connected
inserting large object...
reading it back...
hex: 0102030405060708
disconnecting
However, when run as part of the regression test suite against nightly
git build of psqlodbc, the large-object-data-at-exec-test.c test fails,
unlike large-object-test.c, and produces the following output in
test/results/large-object-data-at-exec.out:
connected
inserting large object...
SQLParamData failed (final call)
HY000=unexpected NULL parameter value
Regards,
Vadym
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
Attachments:
large-object-data-at-exec-test.c (text/x-csrc, 3.6K) download
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
static void
printhex(unsigned char *b, int len)
{
int i;
printf("hex: ");
for (i = 0; i < len; i++)
printf("%02X", b[i]);
}
#define CHECK_STMT_RESULT2(rc, msg, hstmt)\
if (SQL_SUCCESS != rc && SQL_SUCCESS_WITH_INFO != rc && SQL_NEED_DATA != rc) \
{ \
print_diag(msg, SQL_HANDLE_STMT, hstmt);\
exit(1);\
}
int main(int argc, char **argv)
{
int rc;
HSTMT hstmt = SQL_NULL_HSTMT;
char param1[20] = { 1, 2, 3, 4, 5, 6, 7, 8 };
SQLLEN cbParam1;
char buf[100];
SQLLEN ind;
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);
}
/**** Insert a Large Object */
printf("inserting large object...\n");
rc = SQLPrepare(hstmt, (SQLCHAR *) "INSERT INTO lo_test_tab VALUES (1, ?)", SQL_NTS);
CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt);
/* bind LO param as a data at execution parameter */
cbParam1 = SQL_DATA_AT_EXEC;
rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT,
SQL_C_BINARY, /* value type */
SQL_LONGVARBINARY, /* param type */
0, /* column size */
0, /* dec digits */
param1, /* param value ptr */
0, /* buffer len */
&cbParam1 /* StrLen_or_IndPtr */);
CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt);
/* Execute */
rc = SQLExecute(hstmt);
CHECK_STMT_RESULT2(rc, "SQLExecute failed", hstmt);
/* Check for data-at-execute parameters */
if (SQL_NEED_DATA == rc)
{
SQLLEN lobByteSize = 8; // sizeof param1
SQLLEN lobChunkSize = 4096;
SQLPOINTER pParamId = 0;
const char *what = 0;
/* Get the parameter that needs data */
what = "SQLParamData failed (first call)";
rc = SQLParamData(hstmt, &pParamId);
int error = SQL_SUCCESS != rc && SQL_SUCCESS_WITH_INFO != rc && SQL_NEED_DATA != rc;
if (SQL_NEED_DATA == rc)
{
/* Send parameter data in chunks */
what = "SQLPutData failed (next chunk)";
while (!error && lobByteSize > lobChunkSize)
{
rc = SQLPutData(hstmt, (SQLPOINTER)pParamId, lobChunkSize);
lobByteSize -= lobChunkSize;
error = SQL_SUCCESS != rc && SQL_SUCCESS_WITH_INFO != rc && SQL_NEED_DATA != rc;
}
/* Send final chunk */
if (!error)
{
what = "SQLPutData failed (final chunk)";
rc = SQLPutData(hstmt, (SQLPOINTER)pParamId, lobByteSize);
error = SQL_SUCCESS != rc && SQL_SUCCESS_WITH_INFO != rc && SQL_NEED_DATA != rc;
}
/* Make final call */
if (!error)
{
what = "SQLParamData failed (final call)";
rc = SQLParamData(hstmt, &pParamId);
error = SQL_SUCCESS != rc && SQL_SUCCESS_WITH_INFO != rc;
}
}
CHECK_STMT_RESULT(rc, (char*)what, hstmt);
}
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
/**** Read it back ****/
printf("reading it back...\n");
SQLExecDirect(hstmt, (SQLCHAR *) "SELECT id, large_data FROM lo_test_tab WHERE id = 1", SQL_NTS);
rc = SQLFetch(hstmt);
CHECK_STMT_RESULT(rc, "SQLFetch failed", hstmt);
rc = SQLGetData(hstmt, 2, SQL_C_BINARY, buf, sizeof(buf), &ind);
CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt);
printhex(buf, ind);
printf("\n");
/* Clean up */
test_disconnect();
return 0;
}
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git
2015-10-15 12:00 SQL_DATA_AT_EXEC processing broken for large objects in nightly git Vadym Krevs <vkrevs@serena.com>
@ 2015-11-04 07:48 ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2015-11-04 10:48 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Vadym Krevs <vkrevs@serena.com>
2015-11-04 11:04 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Heikki Linnakangas <hlinnaka@iki.fi>
0 siblings, 2 replies; 9+ messages in thread
From: Inoue, Hiroshi @ 2015-11-04 07:48 UTC (permalink / raw)
To: pgsql-odbc
Hi,
I was able to reproduce it here.
Because I can't understand the current code at once, please give me some
time
to solve the problem.
regards,
Hiroshi inoue
On 2015/10/15 21:00, Vadym Krevs wrote:
> Hi,
>
> the nightly git of the psqlODBC driver appears to no longer support
> insertion into LO columns when using SQL_DATA_AT_EXEC mode. The
> latest released driver version - psqlodbc-09.03.0400 - works. I've
> tested this against both PostgreSQL 9.4.4 and 9.4.5 on openSUSE 13.2.
>
> An adapted variant of the large-object-test.c program that uses
> SQL_DATA_AT_EXEC mode is attached. When run as part of the regression
> test suite against psqlodbc-09.03.0400, both the
> large-object-data-at-exec-test.c test completes successfully, just
> like large-object-test.c, and produces the following output in
> test/results/large-object-data-at-exec.out:
>
> \! "./src/large-object-data-at-exec-test"
> connected
> inserting large object...
> reading it back...
> hex: 0102030405060708
> disconnecting
>
> However, when run as part of the regression test suite against nightly
> git build of psqlodbc, the large-object-data-at-exec-test.c test
> fails, unlike large-object-test.c, and produces the following output
> in test/results/large-object-data-at-exec.out:
>
> connected
> inserting large object...
> SQLParamData failed (final call)
> HY000=unexpected NULL parameter value
>
> Regards,
> Vadym
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git
2015-10-15 12:00 SQL_DATA_AT_EXEC processing broken for large objects in nightly git Vadym Krevs <vkrevs@serena.com>
2015-11-04 07:48 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
@ 2015-11-04 10:48 ` Vadym Krevs <vkrevs@serena.com>
1 sibling, 0 replies; 9+ messages in thread
From: Vadym Krevs @ 2015-11-04 10:48 UTC (permalink / raw)
To: pgsql-odbc
Thank you - much appreciated.
Regards,
Vadym
On 04/11/15 07:48, Inoue, Hiroshi wrote:
> Hi,
>
> I was able to reproduce it here.
> Because I can't understand the current code at once, please give me
> some time
> to solve the problem.
>
> regards,
> Hiroshi inoue
>
> On 2015/10/15 21:00, Vadym Krevs wrote:
>> Hi,
>>
>> the nightly git of the psqlODBC driver appears to no longer support
>> insertion into LO columns when using SQL_DATA_AT_EXEC mode. The
>> latest released driver version - psqlodbc-09.03.0400 - works. I've
>> tested this against both PostgreSQL 9.4.4 and 9.4.5 on openSUSE 13.2.
>>
>> An adapted variant of the large-object-test.c program that uses
>> SQL_DATA_AT_EXEC mode is attached. When run as part of the regression
>> test suite against psqlodbc-09.03.0400, both the
>> large-object-data-at-exec-test.c test completes successfully, just
>> like large-object-test.c, and produces the following output in
>> test/results/large-object-data-at-exec.out:
>>
>> \! "./src/large-object-data-at-exec-test"
>> connected
>> inserting large object...
>> reading it back...
>> hex: 0102030405060708
>> disconnecting
>>
>> However, when run as part of the regression test suite against
>> nightly git build of psqlodbc, the large-object-data-at-exec-test.c
>> test fails, unlike large-object-test.c, and produces the following
>> output in test/results/large-object-data-at-exec.out:
>>
>> connected
>> inserting large object...
>> SQLParamData failed (final call)
>> HY000=unexpected NULL parameter value
>>
>> Regards,
>> Vadym
>
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git
2015-10-15 12:00 SQL_DATA_AT_EXEC processing broken for large objects in nightly git Vadym Krevs <vkrevs@serena.com>
2015-11-04 07:48 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
@ 2015-11-04 11:04 ` Heikki Linnakangas <hlinnaka@iki.fi>
2015-11-04 14:26 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
1 sibling, 1 reply; 9+ messages in thread
From: Heikki Linnakangas @ 2015-11-04 11:04 UTC (permalink / raw)
To: Inoue, Hiroshi <h-inoue@dream.email.ne.jp>; pgsql-odbc
On 11/04/2015 09:48 AM, Inoue, Hiroshi wrote:
> Hi,
>
> I was able to reproduce it here.
> Because I can't understand the current code at once, please give me some
> time
> to solve the problem.
I also started looking at this last week, and came up with a patch that
I think fixes it, but I got distracted before completing it and replying
here. So here's what I came up with...
- Heikki
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
Attachments:
large-object-data-at-exec-fix.patch (binary/octet-stream, 5.7K) download
diff --git a/convert.c b/convert.c
index 8802e6e..99ec4e5 100644
--- a/convert.c
+++ b/convert.c
@@ -4116,14 +4116,11 @@ inolog("ipara=%p paramType=%d %d proc_return=%d\n", ipara, ipara ? ipara->paramT
}
else if (!handling_large_object)
{
- CVT_APPEND_CHAR(qb, '?');
- return SQL_SUCCESS;
+ /* shouldn't happen */
+ qb->errormsg = "unexpected NULL parameter value";
+ qb->errornumber = STMT_EXEC_ERROR;
+ return SQL_ERROR;
}
-
- /* shouldn't happen */
- qb->errormsg = "unexpected NULL parameter value";
- qb->errornumber = STMT_EXEC_ERROR;
- return SQL_ERROR;
}
/* replace DEFAULT with something we can use */
diff --git a/test/expected/large-object-data-at-exec.out b/test/expected/large-object-data-at-exec.out
new file mode 100644
index 0000000..e69de29
diff --git a/test/src/large-object-data-at-exec-test.c b/test/src/large-object-data-at-exec-test.c
new file mode 100644
index 0000000..585e102
--- /dev/null
+++ b/test/src/large-object-data-at-exec-test.c
@@ -0,0 +1,160 @@
+/*
+ * Test data-at-execution, for a large object.
+ */
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "common.h"
+
+static void
+printhex(unsigned char *b, int len)
+{
+ int i;
+
+ printf("hex: ");
+ for (i = 0; i < len; i++)
+ printf("%02X", b[i]);
+}
+
+#define CHECK_STMT_RESULT2(rc, msg, hstmt)\
+ if (SQL_SUCCESS != rc && SQL_SUCCESS_WITH_INFO != rc && SQL_NEED_DATA != rc) \
+ { \
+ print_diag(msg, SQL_HANDLE_STMT, hstmt);\
+ exit(1);\
+ }
+
+
+/*
+ * Insert a large object to table, using a data-at-exec param. Then read it
+ * back and print.
+ */
+static void
+do_test(HSTMT hstmt, int testno, int lobByteSize, char *lobData)
+{
+ char sql[200];
+ int rc;
+ SQLLEN cbParam1;
+ char *buf;
+ SQLLEN ind;
+
+ /**** Insert a Large Object */
+ printf("inserting large object with len %d...\n", lobByteSize);
+ snprintf(sql, sizeof(sql),
+ "INSERT INTO lo_test_tab VALUES (%d, ?)", testno);
+ rc = SQLPrepare(hstmt, (SQLCHAR *) sql, SQL_NTS);
+ CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt);
+
+ /* bind LO param as a data at execution parameter */
+ cbParam1 = SQL_DATA_AT_EXEC;
+ rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT,
+ SQL_C_BINARY, /* value type */
+ SQL_LONGVARBINARY, /* param type */
+ 0, /* column size */
+ 0, /* dec digits */
+ lobData, /* param value ptr */
+ 0, /* buffer len */
+ &cbParam1 /* StrLen_or_IndPtr */);
+ CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt);
+
+ /* Execute */
+ rc = SQLExecute(hstmt);
+ CHECK_STMT_RESULT2(rc, "SQLExecute failed", hstmt);
+
+ /* Check for data-at-execute parameters */
+ if (SQL_NEED_DATA == rc)
+ {
+ SQLLEN lobChunkSize = 4096;
+ SQLPOINTER pParamId = 0;
+ const char *what = 0;
+
+ /* Get the parameter that needs data */
+ what = "SQLParamData failed (first call)";
+ rc = SQLParamData(hstmt, &pParamId);
+ int error = SQL_SUCCESS != rc && SQL_SUCCESS_WITH_INFO != rc && SQL_NEED_DATA != rc;
+ if (SQL_NEED_DATA == rc)
+ {
+ /* Send parameter data in chunks */
+ what = "SQLPutData failed (next chunk)";
+ while (!error && lobByteSize > lobChunkSize)
+ {
+ rc = SQLPutData(hstmt, (SQLPOINTER)pParamId, lobChunkSize);
+ lobByteSize -= lobChunkSize;
+ error = SQL_SUCCESS != rc && SQL_SUCCESS_WITH_INFO != rc && SQL_NEED_DATA != rc;
+ }
+
+ /* Send final chunk */
+ if (!error)
+ {
+ what = "SQLPutData failed (final chunk)";
+ rc = SQLPutData(hstmt, (SQLPOINTER)pParamId, lobByteSize);
+ error = SQL_SUCCESS != rc && SQL_SUCCESS_WITH_INFO != rc && SQL_NEED_DATA != rc;
+ }
+
+ /* Make final call */
+ if (!error)
+ {
+ what = "SQLParamData failed (final call)";
+ rc = SQLParamData(hstmt, &pParamId);
+ error = SQL_SUCCESS != rc && SQL_SUCCESS_WITH_INFO != rc;
+ }
+ }
+ CHECK_STMT_RESULT(rc, (char*)what, hstmt);
+ }
+
+ rc = SQLFreeStmt(hstmt, SQL_CLOSE);
+ CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
+
+ /**** Read it back ****/
+ printf("reading it back...\n");
+
+ snprintf(sql, sizeof(sql),
+ "SELECT id, large_data FROM lo_test_tab WHERE id = %d", testno);
+ SQLExecDirect(hstmt, (SQLCHAR *) sql, SQL_NTS);
+ rc = SQLFetch(hstmt);
+ CHECK_STMT_RESULT(rc, "SQLFetch failed", hstmt);
+
+ buf = malloc(lobByteSize * 2);
+ rc = SQLGetData(hstmt, 2, SQL_C_BINARY, buf, lobByteSize * 2, &ind);
+ CHECK_STMT_RESULT(rc, "SQLGetData failed", hstmt);
+
+ printhex(buf, ind);
+ printf("\n");
+
+ free(buf);
+
+ rc = SQLFreeStmt(hstmt, SQL_CLOSE);
+ CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
+}
+
+int
+main(int argc, char **argv)
+{
+ int rc;
+ HSTMT hstmt = SQL_NULL_HSTMT;
+ char param1[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
+ char param2[100];
+ int i;
+
+ 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);
+ }
+
+ do_test(hstmt, 101, sizeof(param1), param1);
+
+ for (i = 0; i < sizeof(param2); i++)
+ {
+ param2[i] = i % 200;
+ }
+ do_test(hstmt, 102, sizeof(param2), param2);
+
+ /* Clean up */
+ test_disconnect();
+
+ return 0;
+}
diff --git a/test/tests b/test/tests
index e908771..eff409f 100644
--- a/test/tests
+++ b/test/tests
@@ -8,6 +8,7 @@
# to each name in a list, but it's easy to strip them away.
TESTBINS = src/connect-test \
+ src/large-object-data-at-exec-test \
src/stmthandles-test \
src/select-test \
src/update-test \
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git
2015-10-15 12:00 SQL_DATA_AT_EXEC processing broken for large objects in nightly git Vadym Krevs <vkrevs@serena.com>
2015-11-04 07:48 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2015-11-04 11:04 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Heikki Linnakangas <hlinnaka@iki.fi>
@ 2015-11-04 14:26 ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2015-11-09 11:53 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Heikki Linnakangas <hlinnaka@iki.fi>
0 siblings, 1 reply; 9+ messages in thread
From: Inoue, Hiroshi @ 2015-11-04 14:26 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: pgsql-odbc
On 2015/11/04 20:04, Heikki Linnakangas wrote:
> On 11/04/2015 09:48 AM, Inoue, Hiroshi wrote:
>> Hi,
>>
>> I was able to reproduce it here.
>> Because I can't understand the current code at once, please give me some
>> time
>> to solve the problem.
>
> I also started looking at this last week, and came up with a patch
> that I think fixes it, but I got distracted before completing it and
> replying here. So here's what I came up with...
>
The solution seems to generate 2 transactions for 1 insertion.
The insertion seems to be rejected when ByteaAsLongVarBinary=1.
Are they intentional?l
regards,
Hiroshi Inoue
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git
2015-10-15 12:00 SQL_DATA_AT_EXEC processing broken for large objects in nightly git Vadym Krevs <vkrevs@serena.com>
2015-11-04 07:48 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2015-11-04 11:04 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Heikki Linnakangas <hlinnaka@iki.fi>
2015-11-04 14:26 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
@ 2015-11-09 11:53 ` Heikki Linnakangas <hlinnaka@iki.fi>
2015-11-11 11:24 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
0 siblings, 1 reply; 9+ messages in thread
From: Heikki Linnakangas @ 2015-11-09 11:53 UTC (permalink / raw)
To: Inoue, Hiroshi <h-inoue@dream.email.ne.jp>; +Cc: pgsql-odbc
On 11/04/2015 04:26 PM, Inoue, Hiroshi wrote:
>
>
> On 2015/11/04 20:04, Heikki Linnakangas wrote:
>> On 11/04/2015 09:48 AM, Inoue, Hiroshi wrote:
>>> Hi,
>>>
>>> I was able to reproduce it here.
>>> Because I can't understand the current code at once, please give me some
>>> time
>>> to solve the problem.
>>
>> I also started looking at this last week, and came up with a patch
>> that I think fixes it, but I got distracted before completing it and
>> replying here. So here's what I came up with...
>
> The solution seems to generate 2 transactions for 1 insertion.
Hmm, you're right, although that doesn't seem to be a new issue. The
09.03.0400 driver does the same, see attached logs from
log_statements=all. Would be nice to fix that, but it's a separate issue.
> The insertion seems to be rejected when ByteaAsLongVarBinary=1.
Oh. It works for me. How are you testing that?
- Heikki
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
Attachments:
large-object-data-at-exec-log.txt (text/plain, 1.2K) download
master + large-object-data-at-exec-fix.patch:
LOG: statement: BEGIN
LOG: fastpath function call: "lo_creat" (OID 957)
LOG: fastpath function call: "lo_open" (OID 952)
LOG: fastpath function call: "lo_lseek" (OID 956)
LOG: fastpath function call: "lowrite" (OID 955)
LOG: fastpath function call: "lo_close" (OID 953)
LOG: statement: COMMIT
LOG: execute _PLAN0xfb58f0/_PLAN0xfb58f0: INSERT INTO lo_test_tab VALUES (101, $1)
DETAIL: parameters: $1 = '16617'
LOG: statement: DEALLOCATE "_PLAN0xfb58f0"
REL-09_03_0400:
LOG: statement: BEGIN
LOG: execute <unnamed>: SELECT pg_catalog.lo_creat($1)
DETAIL: parameters: $1 = '393216'
LOG: execute <unnamed>: SELECT pg_catalog.lo_open($1, $2)
DETAIL: parameters: $1 = '16688', $2 = '131072'
LOG: execute <unnamed>: SELECT pg_catalog.lo_lseek($1, $2, $3)
DETAIL: parameters: $1 = '0', $2 = '0', $3 = '0'
LOG: execute <unnamed>: SELECT pg_catalog.lowrite($1, $2)
DETAIL: parameters: $1 = '0', $2 = '\x0102030405060708'
LOG: execute <unnamed>: SELECT pg_catalog.lo_close($1)
DETAIL: parameters: $1 = '0'
LOG: statement: COMMIT
LOG: execute _PLAN0x1bf71f0: INSERT INTO lo_test_tab VALUES (101, $1)
DETAIL: parameters: $1 = '16688'
LOG: statement: DEALLOCATE "_PLAN0x1bf71f0"
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git
2015-10-15 12:00 SQL_DATA_AT_EXEC processing broken for large objects in nightly git Vadym Krevs <vkrevs@serena.com>
2015-11-04 07:48 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2015-11-04 11:04 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Heikki Linnakangas <hlinnaka@iki.fi>
2015-11-04 14:26 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2015-11-09 11:53 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Heikki Linnakangas <hlinnaka@iki.fi>
@ 2015-11-11 11:24 ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2015-11-17 02:35 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
0 siblings, 1 reply; 9+ messages in thread
From: Inoue, Hiroshi @ 2015-11-11 11:24 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: pgsql-odbc
On 2015/11/09 20:53, Heikki Linnakangas wrote:
> On 11/04/2015 04:26 PM, Inoue, Hiroshi wrote:
>>
>>
>> On 2015/11/04 20:04, Heikki Linnakangas wrote:
>>> On 11/04/2015 09:48 AM, Inoue, Hiroshi wrote:
>>>> Hi,
>>>>
>>>> I was able to reproduce it here.
>>>> Because I can't understand the current code at once, please give me
>>>> some
>>>> time
>>>> to solve the problem.
>>>
>>> I also started looking at this last week, and came up with a patch
>>> that I think fixes it, but I got distracted before completing it and
>>> replying here. So here's what I came up with...
>>
>> The solution seems to generate 2 transactions for 1 insertion.
>
> Hmm, you're right, although that doesn't seem to be a new issue. The
> 09.03.0400 driver does the same, see attached logs from
> log_statements=all. Would be nice to fix that, but it's a separate issue.
Oh you are right. I will examine it.
>
>
>> The insertion seems to be rejected when ByteaAsLongVarBinary=1.
>
> Oh. It works for me. How are you testing that?
I define LO type and set ByteaAsLongVarBinary=1.
The failure is #ERROR: column "large_data" is of type LO but expression
is type "bytea" .
regards,
Hiroshi Inoue
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git
2015-10-15 12:00 SQL_DATA_AT_EXEC processing broken for large objects in nightly git Vadym Krevs <vkrevs@serena.com>
2015-11-04 07:48 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2015-11-04 11:04 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Heikki Linnakangas <hlinnaka@iki.fi>
2015-11-04 14:26 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2015-11-09 11:53 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Heikki Linnakangas <hlinnaka@iki.fi>
2015-11-11 11:24 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
@ 2015-11-17 02:35 ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2015-12-21 12:58 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Heikki Linnakangas <hlinnaka@iki.fi>
0 siblings, 1 reply; 9+ messages in thread
From: Inoue, Hiroshi @ 2015-11-17 02:35 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: pgsql-odbc
Hi Heikki,
The attached patch seems to fix all but I don't understand
sqltype_to_bind_pgtype() well.
Comments?
regards,
Hiroshi Inoue
On 2015/11/11 20:24, Inoue, Hiroshi wrote:
> On 2015/11/09 20:53, Heikki Linnakangas wrote:
>> On 11/04/2015 04:26 PM, Inoue, Hiroshi wrote:
>>>
>>>
>>> On 2015/11/04 20:04, Heikki Linnakangas wrote:
>>>> On 11/04/2015 09:48 AM, Inoue, Hiroshi wrote:
>>>>> Hi,
>>>>> To
>>>>> I was able to reproduce it here.
>>>>> Because I can't understand the current code at once, please give
>>>>> me some
>>>>> time
>>>>> to solve the problem.
>>>>
>>>> I also started looking at this last week, and came up with a patch
>>>> that I think fixes it, but I got distracted before completing it and
>>>> replying here. So here's what I came up with...
>>>
>>> The solution seems to generate 2 transactions for 1 insertion.
>>
>> Hmm, you're right, although that doesn't seem to be a new issue. The
>> 09.03.0400 driver does the same, see attached logs from
>> log_statements=all. Would be nice to fix that, but it's a separate
>> issue.
>
> Oh you are right. I will examine it.
>
>>
>>
>>> The insertion seems to be rejected when ByteaAsLongVarBinary=1.
>>
>> Oh. It works for me. How are you testing that?
>
> I define LO type and set ByteaAsLongVarBinary=1.
> The failure is #ERROR: column "large_data" is of type LO but
> expression is type "bytea" .
>
> regards,
> Hiroshi Inoue
>
>
>
>
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
Attachments:
lobj.patch (text/x-diff, 1.6K) download
diff --git a/convert.c b/convert.c
index 8802e6e..6756276 100644
--- a/convert.c
+++ b/convert.c
@@ -4116,14 +4116,12 @@ inolog("ipara=%p paramType=%d %d proc_return=%d\n", ipara, ipara ? ipara->paramT
}
else if (!handling_large_object)
{
- CVT_APPEND_CHAR(qb, '?');
- return SQL_SUCCESS;
+ /* shouldn't happen */
+ qb->errormsg = "unexpected NULL parameter value";
+ qb->errornumber = STMT_EXEC_ERROR;
+ return SQL_ERROR;
}
- /* shouldn't happen */
- qb->errormsg = "unexpected NULL parameter value";
- qb->errornumber = STMT_EXEC_ERROR;
- return SQL_ERROR;
}
/* replace DEFAULT with something we can use */
diff --git a/execute.c b/execute.c
index 111230b..2e0977a 100644
--- a/execute.c
+++ b/execute.c
@@ -1340,17 +1340,6 @@ PGAPI_ParamData(HSTMT hstmt,
if (estmt->lobj_fd >= 0)
{
odbc_lo_close(conn, estmt->lobj_fd);
-
- /* commit transaction if needed */
- if (!CC_cursor_count(conn) && CC_does_autocommit(conn))
- {
- if (!CC_commit(conn))
- {
- SC_set_error(stmt, STMT_EXEC_ERROR, "Could not commit (in-line) a transaction", func);
- retval = SQL_ERROR;
- goto cleanup;
- }
- }
estmt->lobj_fd = -1;
}
diff --git a/pgtypes.c b/pgtypes.c
index 167966f..b90e69b 100644
--- a/pgtypes.c
+++ b/pgtypes.c
@@ -1285,13 +1285,6 @@ sqltype_to_bind_pgtype(const ConnectionClass *conn, SQLSMALLINT fSqlType)
pgType = PG_TYPE_INT4;
break;
- case SQL_LONGVARBINARY:
- if (ci->bytea_as_longvarbinary)
- pgType = PG_TYPE_BYTEA;
- else
- pgType = conn->lobj_type;
- break;
-
case SQL_REAL:
pgType = PG_TYPE_FLOAT4;
break;
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git
2015-10-15 12:00 SQL_DATA_AT_EXEC processing broken for large objects in nightly git Vadym Krevs <vkrevs@serena.com>
2015-11-04 07:48 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2015-11-04 11:04 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Heikki Linnakangas <hlinnaka@iki.fi>
2015-11-04 14:26 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2015-11-09 11:53 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Heikki Linnakangas <hlinnaka@iki.fi>
2015-11-11 11:24 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2015-11-17 02:35 ` Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
@ 2015-12-21 12:58 ` Heikki Linnakangas <hlinnaka@iki.fi>
0 siblings, 0 replies; 9+ messages in thread
From: Heikki Linnakangas @ 2015-12-21 12:58 UTC (permalink / raw)
To: Inoue, Hiroshi <h-inoue@dream.email.ne.jp>; +Cc: pgsql-odbc
On 17/11/15 04:35, Inoue, Hiroshi wrote:
> Hi Heikki,
>
> The attached patch seems to fix all but I don't understand
> sqltype_to_bind_pgtype() well.
> Comments?
Ah, thanks, I see what the problem is now. I haven't looked at the
extra-transaction part yet, but the rest looks good to me, so I
committed my original patch and the sqltype_to_bind_pgtype() part of
your patch.
You must've figured this out already, but I'll summarize the issue for
the sake of the archives:
sqltype_to_bind_pgtype() was introduced in commit
1ccd04c70b8037b268eefcaae09ce131c8c33b59. Before that, query parameters
were always sent to the server as 'unknown', and the server deduced the
correct datatype. After that commit, we send a suitable PostgreSQL type
OID to the server, depending on the SQL_* type code that application
gave. For example, if you call SQLBindParameters(SQL_INTEGER), we send
the query parameter to the server as 'int4'. That fixes cases like
"SELECT '555' < ?", where it makes a big difference whether the server
treats the parameter as text or integer.
So when the application binds a parameter as SQL_LONGVARBINARY, we now
send it to the server as 'bytea', if ByteaAsLongVarBinary=1, or as 'lo'
otherwise. If you set ByteaAsLongVarBinary=1, the driver reports bytea
fields as SQL_LONGVARBINARY, so it makes sense that we do the same in
the other direction: when the application binds a parameter as
SQL_LONGVARBINARY, send it as 'bytea' to the server. But unfortunately,
it doesn't work if the column is in fact a large object.
Your patch reverts the behaviour of SQL_LONGVARBINARY parameters back to
sending them as 'unknown'. That seems reasonable. It would be nice to
pass a datatype to the server, but there is no way to specify "bytea or
a large object". If we choose either one, the other case will be wrong.
Sending SQL_LONGVARBINARY parameters as 'unknown' should be OK in
practice, there is not much danger for "SELECT '555' < ?" kind of
ambiguity with binary parameters.
- Heikki
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2015-12-21 12:58 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-10-15 12:00 SQL_DATA_AT_EXEC processing broken for large objects in nightly git Vadym Krevs <vkrevs@serena.com>
2015-11-04 07:48 ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2015-11-04 10:48 ` Vadym Krevs <vkrevs@serena.com>
2015-11-04 11:04 ` Heikki Linnakangas <hlinnaka@iki.fi>
2015-11-04 14:26 ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2015-11-09 11:53 ` Heikki Linnakangas <hlinnaka@iki.fi>
2015-11-11 11:24 ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2015-11-17 02:35 ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2015-12-21 12:58 ` Heikki Linnakangas <hlinnaka@iki.fi>
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