Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2EVG-0003U3-7r for pgsql-odbc@arkaria.postgresql.org; Wed, 11 Oct 2017 10:44:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e2EVE-0005yg-GX for pgsql-odbc@arkaria.postgresql.org; Wed, 11 Oct 2017 10:44:40 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e2EVD-0005yO-N2 for pgsql-odbc@postgresql.org; Wed, 11 Oct 2017 10:44:39 +0000 Received: from yello.ksf.kiev.ua ([212.40.47.11]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_CAMELLIA_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1e2EV4-0003AT-HZ for pgsql-odbc@postgresql.org; Wed, 11 Oct 2017 10:44:38 +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 v9BAhcwM050450 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 11 Oct 2017 13:43:38 +0300 (EEST) (envelope-from gpruss@ksf.kiev.ua) From: "Georgy Pruss" To: Subject: error with $ in names again Date: Wed, 11 Oct 2017 13:44:19 +0300 Message-ID: <001301d3427d$e75774d0$b6065e70$@ksf.kiev.ua> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0014_01D34297.0CA940B0" X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdNCfFpdYhRoC9AuSDWQm+Mq79gx+A== 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]); Wed, 11 Oct 2017 13:43:38 +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_0014_01D34297.0CA940B0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi, =20 I think there=E2=80=99s still a bug in parsing names with dollars. Linux RHEL66 =20 UseServerSidePrepare=3D0: =20 create table T$001 (=E2=80=A6) ok=20 create table T_$001 (=E2=80=A6) ok=20 =20 UseServerSidePrepare=3D1: =20 create table T$001 (=E2=80=A6) ok=20 create table T_$001 (=E2=80=A6) error =20 Here is session log for that: =20 $ test_odbc 0 'T$001' Connection: DSN=3DPGDriver;UseServerSidePrepare=3D0 Returned connection string was: = =E2=80=A6;UseDeclareFetch=3D0;=E2=80=A6;Parse=3D0;=E2=80=A6;UseServerSide= Prepare=3D1;LowerCaseIdentifier=3D0; Exec: create table T$001 (i integer) ok =20 $ test_odbc 1 'T$001' Connection: DSN=3DPGDriver;UseServerSidePrepare=3D1 Returned connection string was: =E2=80=A6 Exec: create table T$001 (i integer) ok =20 $ test_odbc 0 'T_$001' Connection: DSN=3DPGDriver;UseServerSidePrepare=3D0 Returned connection string was: =E2=80=A6 Exec: create table T_$001 (i integer) ok =20 $ test_odbc 1 'T_$001' Connection: DSN=3DPGDriver;UseServerSidePrepare=3D1 Returned connection string was: =E2=80=A6 Exec: create table T_$001 (i integer) Error =20 ODBC error: "Parameters exist but IPD isn't set. Please call = SQLDescribeParam()" =20 I guess $n parameters should not be allowed/treated in any ODBC = statements except PREPARE/EXECUTE at all, right? In ODBC statements (and in any case not in table names) it=E2=80=99s = =E2=80=98?=E2=80=99, right? (I know, internally =E2=80=98?=E2=80=99 are replaced by = =E2=80=98$n=E2=80=99, maybe it=E2=80=99s too much for pure = =E2=80=98$=E2=80=99 sign =E2=80=93 literal strings, parameters for = PREPARE, internal parameters for ODBC=E2=80=A6) =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 'tablename' =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!=3D3 || av[1][1]!=3D'\0' || !(av[1][0]=3D=3D'0' || = av[1][0]=3D=3D'1') ) return printf( "Syntax: test_odbc 0|1 'tablename'\n" ), 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 %s (i integer)", av[2] ); // = <------------- 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); sprintf( sql, "drop table if exists %s", av[2] ); SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt); SQLExecDirect(stmt, sql, SQL_NTS); SQLFreeHandle(SQL_HANDLE_STMT,stmt); SQLDisconnect(dbc); } SQLFreeHandle(SQL_HANDLE_DBC, dbc); SQLFreeHandle(SQL_HANDLE_ENV, env); return 0; } =20 $ cat $ODBCINI [ODBC Data Sources] PGDriver =3D PG ODBC Data Source =20 [PGDriver] Driver =3D /usr/pgsql-9.6/lib/psqlodbcw.so Servername =3D <=E2=80=A6.> Port =3D 5432 Database =3D <=E2=80=A6.> Username =3D <=E2=80=A6.> Password =3D <=E2=80=A6.> =20 $ rpm -qa |grep postgresql postgresql96-server-9.6.5-1PGDG.rhel6.x86_64 postgresql96-9.6.5-1PGDG.rhel6.x86_64 postgresql96-libs-9.6.5-1PGDG.rhel6.x86_64 postgresql96-odbc-09.06.0500-1PGDG.rhel6.x86_64 =20 $ cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.6 (Santiago) =20 - - - - - - - - - - - - - - - - - - - - - - - - - - - - =20 Regards =20 Georgy Pruss =20 ------=_NextPart_000_0014_01D34297.0CA940B0 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable

Hi,

 

I think there=E2=80=99s = still a bug in parsing names with dollars.

Linux = RHEL66

 

UseServerSidePrepare=3D0:

 

create table T$001 = (=E2=80=A6)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ok

create table T_$001 = (=E2=80=A6)=C2=A0=C2=A0=C2=A0=C2=A0 ok

 

UseServerSidePrepare=3D1:

 

create table T$001 = (=E2=80=A6)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ok

create table T_$001 = (=E2=80=A6)=C2=A0=C2=A0=C2=A0=C2=A0 error

 

Here is session log for = that:

 

$ test_odbc 0 = 'T$001'

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

Returned connection = string was: = =E2=80=A6;UseDeclareFetch=3D0;=E2=80=A6;Parse=3D0;=E2=80=A6;UseServerSide= Prepare=3D1;LowerCaseIdentifier=3D0;

Exec: create table T$001 = (i integer)

ok

 

$ test_odbc 1 = 'T$001'

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

Returned connection = string was: =E2=80=A6

Exec: create table T$001 (i = integer)

ok

 

$ test_odbc 0 = 'T_$001'

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

Returned connection = string was: =E2=80=A6

Exec: create table T_$001 (i = integer)

ok

 

$ test_odbc 1 = 'T_$001'

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

Returned connection = string was: =E2=80=A6

Exec: create table T_$001 (i = integer)

Error

 

ODBC error:=C2=A0 = "Parameters exist but IPD isn't set. Please call = SQLDescribeParam()"

 

I guess $n parameters = should not be allowed/treated in any ODBC statements except = PREPARE/EXECUTE at all, right?

In ODBC statements (and = in any case not in table names) it=E2=80=99s =E2=80=98?=E2=80=99, = right?

(I know, internally =E2=80=98?=E2=80=99 are = replaced by =E2=80=98$n=E2=80=99, maybe it=E2=80=99s too much for pure = =E2=80=98$=E2=80=99 sign =E2=80=93 literal strings, parameters for = PREPARE, internal parameters for ODBC=E2=80=A6)

 

- - - - - - - - - - - - = - - - - - - - - - - - - - - - -

 

$ 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 = 'tablename'

 

#include = <stdio.h>

#include <time.h>

#include = <sql.h>

#include = <sqlext.h>

 

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

{

=C2=A0 SQLHENV = env;

=C2=A0 SQLHDBC dbc;

=C2=A0 SQLRETURN = ret;

=C2=A0 SQLCHAR = outstr[1024];

=C2=A0 SQLSMALLINT = outstrlen;

=C2=A0 SQLHSTMT stmt;

=C2=A0 if( ac!=3D3 || = av[1][1]!=3D'\0' || !(av[1][0]=3D=3D'0' || av[1][0]=3D=3D'1') = )

=C2=A0=C2=A0=C2=A0 return printf( "Syntax: = test_odbc 0|1 'tablename'\n" ), 1;

=C2=A0 = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, = &env);

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

=C2=A0 SQLAllocHandle(SQL_HANDLE_DBC, env, = &dbc);

=C2=A0 char conn[512];

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

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

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

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

=C2=A0 = if(!SQL_SUCCEEDED(ret))

=C2=A0 =C2=A0=C2=A0{ fprintf(stderr, = "Failed to connect\n"); }

=C2=A0 = else

=C2=A0 {

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

=C2=A0=C2=A0=C2=A0 char = sql[512];

=C2=A0=C2=A0=C2=A0 sprintf( sql, "create = table %s (i integer)", av[2] );=C2=A0 // = <-------------

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

=C2=A0=C2=A0=C2=A0 = SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);

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

=C2=A0=C2=A0=C2=A0 if( = SQL_SUCCEEDED(ret) )

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = printf("ok\n");

=C2=A0=C2=A0=C2=A0 = else

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = printf("error\n");

=C2=A0=C2=A0=C2=A0 = SQLFreeHandle(SQL_HANDLE_STMT,stmt);

=C2=A0=C2=A0=C2=A0 = sprintf( sql, "drop table if exists %s", av[2] = );

=C2=A0=C2=A0=C2=A0 = SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);

=C2=A0=C2=A0=C2=A0 = SQLExecDirect(stmt, sql, SQL_NTS);

=C2=A0=C2=A0=C2=A0 = SQLFreeHandle(SQL_HANDLE_STMT,stmt);

=C2=A0=C2=A0=C2=A0 = SQLDisconnect(dbc);

=C2=A0 }

=C2=A0 = SQLFreeHandle(SQL_HANDLE_DBC, dbc);

=C2=A0 = SQLFreeHandle(SQL_HANDLE_ENV, env);

=C2=A0 return = 0;

}

 

$ cat = $ODBCINI

[ODBC Data Sources]

PGDriver=C2=A0=C2=A0 =3D = PG ODBC Data Source

 

[PGDriver]

Driver=C2=A0=C2=A0=C2=A0=C2=A0 =3D = /usr/pgsql-9.6/lib/psqlodbcw.so

Servername =3D = <=E2=80=A6.>

Port=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D = 5432

Database=C2=A0=C2=A0 =3D = <=E2=80=A6.>

Username=C2=A0=C2=A0 =3D = <=E2=80=A6.>

Password=C2=A0=C2=A0 =3D = <=E2=80=A6.>

 

$ rpm -qa |grep = postgresql

postgresql96-server-9.6.5-1PGDG.rhel6.x86_64=

postgresql96-9.6.5-1PGDG.rhel6.x86_64<= /span>

postgresql96-libs-9.6.5-1PGDG.rhel6.x86_64

postgresql96-odbc-09.06.0500-1PGDG.rhel6.x86_64

 

$ cat = /etc/redhat-release

Red Hat Enterprise Linux Server release 6.6 = (Santiago)

 

- - - - - - - - - - - - = - - - - - - - - - - - - - - - -

 

Regards

 

Georgy = Pruss

 

------=_NextPart_000_0014_01D34297.0CA940B0--