pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Georgy Pruss <gpruss@ksf.kiev.ua>
To: 'Inoue, Hiroshi' <h-inoue@dream.email.ne.jp>
Cc: pgsql-odbc@postgresql.org
Subject: Re: error with $ in names again
Date: Mon, 30 Oct 2017 15:31:32 +0200
Message-ID: <00a401d35183$6da80590$48f810b0$@ksf.kiev.ua> (raw)
In-Reply-To: <aa1a9836-519a-a4a2-e84b-3b376e941ad6@dream.email.ne.jp>
References: <001301d3427d$e75774d0$b6065e70$@ksf.kiev.ua>
	<0ae50a45-159e-2552-2b4b-7abee1ef64db@dream.email.ne.jp>
	<aa1a9836-519a-a4a2-e84b-3b376e941ad6@dream.email.ne.jp>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-odbc>

Hi,

Any news on new driver for 9.6 on Linux?

I guess everybody must be busy with 10.0, but still, maybe some progress…

Thank you!

G.P.

 

 

From: Inoue, Hiroshi [mailto:h-inoue@dream.email.ne.jp] 
Sent: Friday, October 13, 2017 16:52
To: Georgy Pruss <gpruss@ksf.kiev.ua>
Cc: pgsql-odbc@postgresql.org
Subject: Re: [ODBC] error with $ in names again

 

Hi Georgy,

On 2017/10/11 23:08, Inoue, Hiroshi wrote:

Hi Gregory,

On 2017/10/11 19:44, Georgy Pruss wrote:

Hi,

 

I think there’s still a bug in parsing names with dollars.

Linux RHEL66

 

UseServerSidePrepare=0:

 

create table T$001 (…)      ok 

create table T_$001 (…)     ok 

 

UseServerSidePrepare=1:

 

create table T$001 (…)      ok 

create table T_$001 (…)     error


Thanks for the report.
I would examine the issue.


I found a cause and committed the fix to git.
We would make a new release soon.

regards,
Hiroshi Inoue





regards,
Hiroshi Inoue




 

Here is session log for that:

 

$ test_odbc 0 'T$001'

Connection: DSN=PGDriver;UseServerSidePrepare=0

Returned connection string was: …;UseDeclareFetch=0;…;Parse=0;…;UseServerSidePrepare=1;LowerCaseIdentifier=0;

Exec: create table T$001 (i integer)

ok

 

$ test_odbc 1 'T$001'

Connection: DSN=PGDriver;UseServerSidePrepare=1

Returned connection string was: …

Exec: create table T$001 (i integer)

ok

 

$ test_odbc 0 'T_$001'

Connection: DSN=PGDriver;UseServerSidePrepare=0

Returned connection string was: …

Exec: create table T_$001 (i integer)

ok

 

$ test_odbc 1 'T_$001'

Connection: DSN=PGDriver;UseServerSidePrepare=1

Returned connection string was: …

Exec: create table T_$001 (i integer)

Error

 

ODBC error:  "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’s ‘?’, right?

(I know, internally ‘?’ are replaced by ‘$n’, maybe it’s too much for pure ‘$’ sign – literal strings, parameters for PREPARE, internal parameters for ODBC…)

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - -

 

$ 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[])

{

  SQLHENV env;

  SQLHDBC dbc;

  SQLRETURN ret;

  SQLCHAR outstr[1024];

  SQLSMALLINT outstrlen;

  SQLHSTMT stmt;

  if( ac!=3 || av[1][1]!='\0' || !(av[1][0]=='0' || av[1][0]=='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=PGDriver;UseServerSidePrepare=%s", av[1] );

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

  ret = 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 = 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;

}

 

$ cat $ODBCINI

[ODBC Data Sources]

PGDriver   = PG ODBC Data Source

 

[PGDriver]

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

Servername = <….>

Port       = 5432

Database   = <….>

Username   = <….>

Password   = <….>

 

$ 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

 

$ cat /etc/redhat-release

Red Hat Enterprise Linux Server release 6.6 (Santiago)

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - -

 

Regards

 

Georgy Pruss

view thread (4+ messages)

Message-ID: <00a401d35183$6da80590$48f810b0$@ksf.kiev.ua>
Permalink:  ../00a401d35183$6da80590$48f810b0$@ksf.kiev.ua/
Also on:    postgresql.org/message-id/00a401d35183$6da80590$48f810b0$@ksf.kiev.ua

 · 

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: gpruss@ksf.kiev.ua, h-inoue@dream.email.ne.jp
  Subject: Re: error with $ in names again
  In-Reply-To: <00a401d35183$6da80590$48f810b0$@ksf.kiev.ua>
  References: <001301d3427d$e75774d0$b6065e70$@ksf.kiev.ua> <0ae50a45-159e-2552-2b4b-7abee1ef64db@dream.email.ne.jp> <aa1a9836-519a-a4a2-e84b-3b376e941ad6@dream.email.ne.jp> <00a401d35183$6da80590$48f810b0$@ksf.kiev.ua>

* 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