Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dp9SY-0003ji-No for pgsql-odbc@arkaria.postgresql.org; Tue, 05 Sep 2017 08:43:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dp9SX-0001mA-BZ for pgsql-odbc@arkaria.postgresql.org; Tue, 05 Sep 2017 08:43:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dp9S8-00016d-33 for pgsql-odbc@postgresql.org; Tue, 05 Sep 2017 08:43:24 +0000 Received: from yello.ksf.kiev.ua ([212.40.47.11]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_CAMELLIA_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dp9Rz-0004Rl-13 for pgsql-odbc@postgresql.org; Tue, 05 Sep 2017 08:43:23 +0000 X-Virus-Scanned: amavisd-new at ksf.kiev.ua Received: from Tokyo (tokyo.ksf [192.168.168.206]) (authenticated bits=0) by yello.ksf.kiev.ua (8.13.8/8.13.8) with ESMTP id v858gPU6050566 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 5 Sep 2017 11:42:25 +0300 (EEST) (envelope-from gpruss@ksf.kiev.ua) From: "Georgy Pruss" To: "'Inoue, Hiroshi'" Cc: References: <004001d320ef$39a6ed70$acf4c850$@ksf.kiev.ua> <227f81fc-49d4-ca6e-9380-d8606c0d588c@dream.email.ne.jp> <005001d32198$829784f0$87c68ed0$@ksf.kiev.ua> <000d01d32565$b8a545c0$29efd140$@projects.ksf.kiev.ua> <0cbe762d-3c23-e725-60f7-c416e990c24b@dream.email.ne.jp> In-Reply-To: <0cbe762d-3c23-e725-60f7-c416e990c24b@dream.email.ne.jp> Subject: Re: Bug in PostgreSQL ODBC - in names with dollar Date: Tue, 5 Sep 2017 11:43:00 +0300 Message-ID: <000a01d32622$fe6ff510$fb4fdf30$@ksf.kiev.ua> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_000B_01D3263C.23C45900" X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQEXFVNQNQoVYgbEO8RzZW42t9HYbwKC/pGZAq0rt+4DDitscgLCr72So8YS+pA= Content-Language: en-us X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.3 (yello.ksf.kiev.ua [212.40.47.11]); Tue, 05 Sep 2017 11:42:26 +0300 (EEST) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org This is a multipart message in MIME format. ------=_NextPart_000_000B_01D3263C.23C45900 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Thank you very much! G.P. =20 =20 From: pgsql-odbc-owner@postgresql.org = [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Inoue, Hiroshi Sent: Tuesday, September 5, 2017 01:05 To: Georgy Pruss Cc: pgsql-odbc@postgresql.org Subject: Re: [ODBC] Bug in PostgreSQL ODBC - in names with dollar =20 Hi Georgy, Sorry for the late reply. We are planning to make a new release this weekend. regards, Hiroshi Inoue On 2017/09/04 19:08, Georgy Pruss wrote: Hi, =20 I=E2=80=99m sorry to bother you again, but I didn=E2=80=99t see any = updates in the mailing list lately. =20 Unfortunately this problem with the dollar signs in names is quite = sensitive to us (we=E2=80=99re porting a set of products to PostgreSQL), = so we=E2=80=99d really like to know, even approximately, if the fix will = be in the official odbc release and the time frame. =20 Any information on that would be greatly appreciated. =20 Thank you. =20 Georgy Pruss. =20 =20 From: Georgy Pruss [mailto:gpruss@ksf.kiev.ua]=20 Sent: Wednesday, August 30, 2017 17:02 To: 'Inoue, Hiroshi' = Cc: pgsql-odbc@postgresql.org =20 Subject: RE: [ODBC] Bug in PostgreSQL ODBC - in names with dollar =20 Thank you very much. =20 It works on Windows. =20 I hope it=E2=80=99ll be the same on Linux. =20 Can I ask when it=E2=80=99s in the official release of ODBC? =20 Thank you. =20 Georgy Pruss =20 =20 =20 From: pgsql-odbc-owner@postgresql.org = = [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Inoue, Hiroshi Sent: Wednesday, August 30, 2017 01:39 To: Georgy Pruss > Cc: pgsql-odbc@postgresql.org =20 Subject: Re: [ODBC] Bug in PostgreSQL ODBC - in names with dollar =20 Hi Georgy, Could you try the git at git.postgresql.org/git/postgresql.git ? (web page = https://git.postgresql.org/gitweb/?p=3Dpsqlodbc.git;a=3Dsummary ). Or could you please try the test drivers 9.6.0415 on Windows at http://www.ne.jp/asahi/inocchichichi/entrance/psqlodbc/ ? regards, Hiroshi Inoue . On 2017/08/30 2:49, Georgy Pruss wrote: Hi, =20 =20 I=E2=80=99m sorry, I really tried to register at pgsql-odbc list at = postgresql.org, using different email addresses, but it = didn=E2=80=99t=E2=80=99 work. =20 I saw that you may deal with this problem. =20 =20 When UseServerSidePrepare is set to 1 (which is default, I guess), any = names with $ in them cause error: =20 =E2=80=9CThe # of binded parameters < the # of parameter = markers=E2=80=9D =20 It=E2=80=99s both on Windows and Linux. =20 It seems that PG tries to use un-paired =E2=80=98$=E2=80=99 symbols as = parameter marks for the server-side prepare/execute feature, even if = there=E2=80=99s no PREPARE or EXECUTE statements. =20 I believe, PG should not parse any statements for $-parameters outside = PREPARE/EXECUTE. =20 =20 Simple ODBC program: =20 =20 $ cat test_odbc.c // gcc -I unixODBC-2.3.4/include -I unixODBC-2.3.4 -L libs -lodbc = test_odbc.c -o test_odbc // test_odbc 0|1 =20 #include #include #include #include =20 int main(int ac, char* av[]) { SQLHENV env; SQLHDBC dbc; SQLRETURN ret; SQLCHAR outstr[1024]; SQLSMALLINT outstrlen; SQLHSTMT stmt; if( ac!=3D2 || av[1][1]!=3D'\0' || !(av[1][0]=3D=3D'0' || = av[1][0]=3D=3D'1')) return 1; SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env); SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc); char conn[512]; sprintf( conn, "DSN=3DPGDriver;UseServerSidePrepare=3D%s", av[1] ); printf( "Connection: %s\n", conn ); ret =3D SQLDriverConnect(dbc, NULL, conn, SQL_NTS, outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_COMPLETE); if(!SQL_SUCCEEDED(ret)) { fprintf(stderr, "Failed to connect\n"); } else { printf("Returned connection string was:\n\t%s\n", outstr); char sql[512]; sprintf( sql, "create table T$_x_%u (f integer)", (int)time(0) ); printf( "Exec: %s\n", sql ); SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt); ret =3D SQLExecDirect(stmt, sql, SQL_NTS); if(SQL_SUCCEEDED(ret)) printf("ok\n"); else printf("error\n"); SQLFreeHandle(SQL_HANDLE_STMT,stmt); SQLDisconnect(dbc); } SQLFreeHandle(SQL_HANDLE_DBC, dbc); SQLFreeHandle(SQL_HANDLE_ENV, env); return 0; } =20 =20 $ test_odbc 0 Connection: DSN=3DPGDriver;UseServerSidePrepare=3D0 Returned connection string was: = DSN=3DPGDriver;DATABASE=3D=E2=80=A6;SERVER=3D=E2=80=A6;PORT=3D5432;UID=3D= =E2=80=A6;PWD=3D=E2=80=A6;SSLmode=3Ddisable;ReadOnly=3D0;Protocol=3D7.4;F= akeOidIndex=3D0;ShowOidColumn=3D0;RowVersioning=3D0;ShowSystemTables=3D0;= =3DFetch=3D100;UnknownSizes=3D0;MaxVarcharSize=3D255;MaxLongVarcharSize=3D= 8190;Debug=3D0;CommLog=3D0;UseDeclareFetch=3D0;TextAsLongVarchar=3D1;Unkn= ownsAsLongVarchar=3D0;BoolsAsChar=3D1;Parse=3D0;ExtraSysTablePrefixes=3D;= LFConversion=3D0;UpdatableCursors=3D1;TrueIsMinus1=3D0;BI=3D0;ByteaAsLong= VarBinary=3D1;UseServerSidePrepare=3D0;LowerCaseIdentifier=3D0; Exec: create table T$_x_1504022913 (f integer) ok =20 =20 $ test_odbc 1 Connection: DSN=3DPGDriver;UseServerSidePrepare=3D1 Returned connection string was: = DSN=3DPGDriver;DATABASE=3D=E2=80=A6;SERVER=3D=E2=80=A6;PORT=3D5432;UID=3D= =E2=80=A6;PWD=3D=E2=80=A6;SSLmode=3Ddisable;ReadOnly=3D0;Protocol=3D7.4;F= akeOidIndex=3D0;ShowOidColumn=3D0;RowVersioning=3D0;ShowSystemTables=3D0;= =3DFetch=3D100;UnknownSizes=3D0;MaxVarcharSize=3D255;MaxLongVarcharSize=3D= 8190;Debug=3D0;CommLog=3D0;UseDeclareFetch=3D0;TextAsLongVarchar=3D1;Unkn= ownsAsLongVarchar=3D0;BoolsAsChar=3D1;Parse=3D0;ExtraSysTablePrefixes=3D;= LFConversion=3D0;UpdatableCursors=3D1;TrueIsMinus1=3D0;BI=3D0;ByteaAsLong= VarBinary=3D1;UseServerSidePrepare=3D1;LowerCaseIdentifier=3D0; Exec: create table T$_x_1504022916 (f integer) error =20 =20 Actually, probably any statement with =E2=80=98$=E2=80=99 in table/field = name causes this error. =20 =20 PGDriver - /usr/pgsql-9.6/lib/psqlodbcw.so Driver Info DBMS Name: PostgreSQL DBMS Version: 9.6.3 PostgreSQL 9.6.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 = 20120313 (Red Hat 4.4.7-18), 64-bit =20 =20 This is probably the same error as in = https://www.postgresql.org/message-id/09ce3d91ce364987964726aa50a16155%40= neosys.si = =20 =20 =20 Thank you. =20 =20 Georgy Pruss. ------=_NextPart_000_000B_01D3263C.23C45900 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable

Thank you very much!

G.P.

 

 

From: pgsql-odbc-owner@postgresql.org = [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Inoue, = Hiroshi
Sent: Tuesday, September 5, 2017 01:05
To: = Georgy Pruss <gpruss@projects.ksf.kiev.ua>
Cc: = pgsql-odbc@postgresql.org
Subject: Re: [ODBC] Bug in = PostgreSQL ODBC - in names with = dollar

 

Hi Georgy,

Sorry for the late = reply.
We are planning to make a new release this = weekend.

regards,
Hiroshi Inoue

On 2017/09/04 19:08, Georgy Pruss = wrote:

Hi,

 

I=E2=80=99m sorry to = bother you again, but I didn=E2=80=99t see any updates in the mailing = list lately.

 

Unfortunately this = problem with the dollar signs in names is quite sensitive to us = (we=E2=80=99re porting a set of products to PostgreSQL), so we=E2=80=99d = really like to know, even approximately, if the fix will be in the = official odbc release and the time frame.

 

Any information on that = would be greatly appreciated.

 

Thank = you.

 

Georgy = Pruss.

 

 

From: Georgy Pruss [mailto:gpruss@ksf.kiev.ua] =
Sent: Wednesday, August 30, 2017 17:02
To: 'Inoue, = Hiroshi' <h-inoue@dream.email.ne.jp&g= t;
Cc: pgsql-odbc@postgresql.orgSubject: RE: [ODBC] Bug in PostgreSQL ODBC - in names with = dollar

 

Thank you very much.

 

It works on = Windows.

 

I hope it=E2=80=99ll be = the same on Linux.

 

Can I ask when = it=E2=80=99s in the official release of ODBC?

 

Thank = you.

 

Georgy = Pruss

 

 

 

From: pgsql-odbc-owner@postgres= ql.org [mailto:pgsql-odbc-owner@p= ostgresql.org] On Behalf Of Inoue, Hiroshi
Sent: = Wednesday, August 30, 2017 01:39
To: Georgy Pruss <gpruss@ksf.kiev.ua>
Cc: pgsql-odbc@postgresql.orgSubject: Re: [ODBC] Bug in PostgreSQL ODBC - in names with = dollar

 

Hi Georgy,

Could you try the git = at git.postgresql.org/git/postgresql.git ?
(web page = https://git.postgresql.org/gitweb/?p=3Dpsqlodbc.git;a=3Dsummary = ).

Or could you please try the test drivers 9.6.0415 on Windows = at
  http://www.ne.jp/asahi/inocchichichi/entrance/psqlodbc/= ?

regards,
Hiroshi Inoue
.

On 2017/08/30 2:49, Georgy Pruss = wrote:

Hi,

 

 

I=E2=80=99m sorry, I = really tried to register at pgsql-odbc list at postgresql.org, using = different email addresses, but it didn=E2=80=99t=E2=80=99 = work.

 

I saw that you may deal = with this problem.

 

 

When = UseServerSidePrepare is set to 1 (which is default, I guess), any names = with $ in them cause error:

 

=E2=80=9CThe # of binded = parameters < the # of parameter = markers=E2=80=9D

 

It=E2=80=99s both on = Windows and Linux.

 

It seems that PG tries = to use un-paired =E2=80=98$=E2=80=99 symbols as parameter marks for the = server-side prepare/execute feature, even if there=E2=80=99s no PREPARE = or EXECUTE statements.

 

I believe, PG should not = parse any statements for $-parameters outside = PREPARE/EXECUTE.

 

 

Simple ODBC = program:

 

 

$ cat = test_odbc.c

// gcc -I unixODBC-2.3.4/include -I = unixODBC-2.3.4 -L libs -lodbc test_odbc.c -o = test_odbc

// test_odbc 0|1

 

#include = <stdio.h>

#include <time.h>

#include = <sql.h>

#include = <sqlext.h>

 

int main(int ac, char* = av[])

{

  SQLHENV = env;

  SQLHDBC dbc;

  SQLRETURN = ret;

  SQLCHAR = outstr[1024];

  SQLSMALLINT = outstrlen;

  SQLHSTMT stmt;

  if( ac!=3D2 || = av[1][1]!=3D'\0' || !(av[1][0]=3D=3D'0' || av[1][0]=3D=3D'1')) return = 1;

  SQLAllocHandle(SQL_HANDLE_ENV, = SQL_NULL_HANDLE, &env);

  = SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, = 0);

  SQLAllocHandle(SQL_HANDLE_DBC, env, = &dbc);

  char conn[512];

  sprintf( conn, = "DSN=3DPGDriver;UseServerSidePrepare=3D%s", av[1] = );

  printf( "Connection: %s\n", = conn );

  ret =3D SQLDriverConnect(dbc, NULL, conn, = SQL_NTS,

       outstr, = sizeof(outstr), &outstrlen, = SQL_DRIVER_COMPLETE);

  = if(!SQL_SUCCEEDED(ret))

  {

    = fprintf(stderr, "Failed to = connect\n");

  }

  = else

  {

    = printf("Returned connection string was:\n\t%s\n", = outstr);

    char = sql[512];

    sprintf( sql, "create = table T$_x_%u (f integer)", (int)time(0) );

    = printf( "Exec: %s\n", sql );

    = SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);

    ret = =3D SQLExecDirect(stmt, sql, SQL_NTS);

    = if(SQL_SUCCEEDED(ret))

      = printf("ok\n");

    = else

      = printf("error\n");

    = SQLFreeHandle(SQL_HANDLE_STMT,stmt);

    = SQLDisconnect(dbc);

  }

  = SQLFreeHandle(SQL_HANDLE_DBC, dbc);

  = SQLFreeHandle(SQL_HANDLE_ENV, env);

  return = 0;

}

 

 

$ test_odbc = 0

Connection: = DSN=3DPGDriver;UseServerSidePrepare=3D0

Returned connection = string was:

        = DSN=3DPGDriver;DATABASE=3D=E2=80=A6;SERVER=3D=E2=80=A6;PORT=3D5432;UID=3D= =E2=80=A6;PWD=3D=E2=80=A6;SSLmode=3Ddisable;ReadOnly=3D0;Protocol=3D7.4;F= akeOidIndex=3D0;ShowOidColumn=3D0;RowVersioning=3D0;ShowSystemTables=3D0;= =3DFetch=3D100;UnknownSizes=3D0;MaxVarcharSize=3D255;MaxLongVarcharSize=3D= 8190;Debug=3D0;CommLog=3D0;UseDeclareFetch=3D0;TextAsLongVarchar=3D1;Unkn= ownsAsLongVarchar=3D0;BoolsAsChar=3D1;Parse=3D0;ExtraSysTablePrefixes=3D;= LFConversion=3D0;UpdatableCursors=3D1;TrueIsMinus1=3D0;BI=3D0;ByteaAsLong= VarBinary=3D1;UseServerSidePrepare=3D0;LowerCaseIdentifier=3D0;

Exec: = create table T$_x_1504022913 (f integer)

ok

 

 

$ test_odbc = 1

Connection: = DSN=3DPGDriver;UseServerSidePrepare=3D1

Returned connection = string was:

        = DSN=3DPGDriver;DATABASE=3D=E2=80=A6;SERVER=3D=E2=80=A6;PORT=3D5432;UID=3D= =E2=80=A6;PWD=3D=E2=80=A6;SSLmode=3Ddisable;ReadOnly=3D0;Protocol=3D7.4;F= akeOidIndex=3D0;ShowOidColumn=3D0;RowVersioning=3D0;ShowSystemTables=3D0;= =3DFetch=3D100;UnknownSizes=3D0;MaxVarcharSize=3D255;MaxLongVarcharSize=3D= 8190;Debug=3D0;CommLog=3D0;UseDeclareFetch=3D0;TextAsLongVarchar=3D1;Unkn= ownsAsLongVarchar=3D0;BoolsAsChar=3D1;Parse=3D0;ExtraSysTablePrefixes=3D;= LFConversion=3D0;UpdatableCursors=3D1;TrueIsMinus1=3D0;BI=3D0;ByteaAsLong= VarBinary=3D1;UseServerSidePrepare=3D1;LowerCaseIdentifier=3D0;

Exec: = create table T$_x_1504022916 (f integer)

error

 

 

Actually, probably any = statement with =E2=80=98$=E2=80=99 in table/field name causes this = error.

 

 

PGDriver - = /usr/pgsql-9.6/lib/psqlodbcw.so

Driver = Info

DBMS Name: PostgreSQL

DBMS Version: = 9.6.3

PostgreSQL 9.6.3 on x86_64-pc-linux-gnu, = compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18), = 64-bit

 

 

This is probably the = same error as in https://www.postgresq= l.org/message-id/09ce3d91ce364987964726aa50a16155%40neosys.si

 

 

Thank = you.

 

 

Georgy = Pruss.

------=_NextPart_000_000B_01D3263C.23C45900--