pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
Cc: pgsql-odbc@postgresql.org
Subject: Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git
Date: Mon, 21 Dec 2015 14:58:57 +0200
Message-ID: <5677F791.10006@iki.fi> (raw)
In-Reply-To: <564A925B.9040809@dream.email.ne.jp>
References: <561F954E.7020808@serena.com>
	<5639B85F.7030408@dream.email.ne.jp>
	<5639E621.1020505@iki.fi>
	<563A159A.5080104@dream.email.ne.jp>
	<5640892B.7060700@iki.fi>
	<5643255C.2060207@dream.email.ne.jp>
	<564A925B.9040809@dream.email.ne.jp>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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



view thread (9+ messages)

Message-ID: <5677F791.10006@iki.fi>
Permalink:  ../5677F791.10006@iki.fi/
Also on:    postgresql.org/message-id/5677F791.10006@iki.fi

 · 

reply

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, h-inoue@dream.email.ne.jp
  Subject: Re: SQL_DATA_AT_EXEC processing broken for large objects in nightly git
  In-Reply-To: <5677F791.10006@iki.fi>
  References: <561F954E.7020808@serena.com> <5639B85F.7030408@dream.email.ne.jp> <5639E621.1020505@iki.fi> <563A159A.5080104@dream.email.ne.jp> <5640892B.7060700@iki.fi> <5643255C.2060207@dream.email.ne.jp> <564A925B.9040809@dream.email.ne.jp> <5677F791.10006@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