pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Bug in ODBC driver 08.00.0004 and stored procedure
7+ messages / 3 participants
[nested] [flat]

* Bug in ODBC driver 08.00.0004 and stored procedure
@ 2005-02-13 20:22  Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
  0 siblings, 0 replies; 7+ messages in thread

From: Joost Kraaijeveld @ 2005-02-13 20:22 UTC (permalink / raw)
  To: Dave Page <dpage@vale-housing.co.uk>; +Cc: pgsql-odbc

Hi all,

Attached is a little ODBC program that shows the bug. Running the program against a database with a stored procedure it reports an error calling SQLExecute: 

"SQLSTATE = HY010
Message: The cursor is open."

I think the cursor is open because the query is allready executed to get the data for SQLNumResultCols. Rerunning the query to get the data leads to this error.

To reproduce the error you can use the following database and function (and/or adjust the code to represent your database, user and password):

CREATE DATABASE "TestDB"  WITH OWNER = postgres  ENCODING = 'SQL_ASCII';

CREATE OR REPLACE FUNCTION getobjectid()
  RETURNS text AS
'
	select((select(to_char(current_timestamp, \'yyyy-mm-dd-hh-mm-ss\'))) || (select(to_char((nextval(\'tsfraction\')),\'-FM000000MI\')))) as return;
'
  LANGUAGE 'sql' VOLATILE;


Groeten,

Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
e-mail: J.Kraaijeveld@Askesis.nl
web: www.askesis.nl

Attachments:

  main.cpp (application/octet-stream, 4.4K) download

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Bug in ODBC driver 08.00.0004 and stored procedure
@ 2005-02-15 18:19  Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
  0 siblings, 0 replies; 7+ messages in thread

From: Joost Kraaijeveld @ 2005-02-15 18:19 UTC (permalink / raw)
  To: Dave Page <dpage@vale-housing.co.uk>; +Cc: pgsql-odbc

Hi Dave,

Attached are the patches I created for solving the problem.

Also attached a MinGW makefile that works and gives a working dll. I have given the autoconf stuff a look but that is higher math to me. Something for the bright people amongs us.

Groeten,

Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
e-mail: J.Kraaijeveld@Askesis.nl
web: www.askesis.nl

Attachments: download all (4 files, .tar.gz)

  psqlodbc_win32.def (application/octet-stream, 2.1K) download

parse.c.diff (application/octet-stream, 3.7K) download --- ../../VC/psqlodbc-08.00.0004/parse.c 2005-01-28 22:36:18.000000000 +0100 +++ ./parse.c 2005-02-15 18:57:16.184535900 +0100 @@ -334,6 +334,7 @@ char in_field = FALSE, in_expr = FALSE, in_func = FALSE, + out_func = FALSE, in_dot = FALSE, in_as = FALSE; int j, @@ -351,6 +352,10 @@ RETCODE result; BOOL updatable = TRUE; + QResultClass* resultClass; + HSTMT privStmt; + + mylog("%s: entering...\n", func); ptr = stmt->statement; @@ -677,14 +682,33 @@ out_table = TRUE; continue; } - if (out_table && !in_table) /* new table */ + if (out_table && !in_table && !in_func) /* new table */ { if (!dquote) { if (token[0] == '(' || token[0] == ')') continue; + + /* + * Detect a function call that looks like a table, eg. + * SELECT * FROM version() + * + * This needs work to properly handle functions found in the from + * clause, but this at least prevents nasty errors for now. + * + * DJP, 2005-01-08 + */ + if (ptr[0] == '(') + { + in_func = TRUE; + mylog("**** got function = '%s'\n", token); + mylog("FIXME: functions in the FROM clause are currently ignored!!\n"); + continue; + } } + + if (!(stmt->ntab % TAB_INCR)) { ti = (TABLE_INFO **) realloc(ti, (stmt->ntab + TAB_INCR) * sizeof(TABLE_INFO *)); @@ -725,6 +749,64 @@ continue; } + if (out_table && !in_table && in_func) /* old function */ + { + /* Just skipped a function alias */ + if (out_func) + { + in_func = FALSE; + out_func = FALSE; + mylog("leaving func (and ignoring alias)\n"); + continue; + } + + /* Normal function, no alias */ + if (token[0] == ')' && (ptr[0] == ',' || strlen(ptr) == 0)) + { + in_func = FALSE; + + /* + * TODO: shouldn't we cache the metadata somewhere? + */ + SC_pre_execute(stmt); + resultClass = SC_get_Curres(stmt); + + mylog("PGAPI_NumResultCols: result = %u, status = %d, numcols = %d\n", resultClass, stmt->status, resultClass!= NULL ? QR_NumResultCols(resultClass) : -1); + if ((!resultClass) || ((stmt->status != STMT_FINISHED) && (stmt->status != STMT_PREMATURE))) + { + /* no query has been executed on this statement */ + SC_set_error(stmt, STMT_EXEC_ERROR, "No query has been executed with that handle"); + SC_log_error(func, "", stmt); + return SQL_ERROR; + } + else if (!QR_command_maybe_successful(resultClass)) + { + SC_set_errornumber(stmt, STMT_EXEC_ERROR); + SC_log_error(func, "", stmt); + return SQL_ERROR; + } + /* + * If the parse_statement is called to get the number of + * result columns throught SQLColAttribute. + */ + irdflds->nfields = QR_NumPublicResultCols(resultClass); + + mylog("leaving func.\n"); + + stmt->parse_status = STMT_PARSE_FATAL; + return FALSE; + } + + /* Function with following alias */ + if (token[0] == ')') + { + out_func = TRUE; + continue; + } + + + } + if (!dquote && stricmp(token, "JOIN") == 0) { in_table = FALSE;
statement.c.diff (application/octet-stream, 613B) download --- ../../VC/psqlodbc-08.00.0004/statement.c 2005-01-28 22:36:20.000000000 +0100 +++ ./statement.c 2005-02-15 19:01:49.058059500 +0100 @@ -500,6 +500,15 @@ SC_set_error(self, STMT_SEQUENCE_ERROR, "Statement is currently executing a transaction."); return TRUE; } + /* + * We get here if a statement is prepared and executed to get the metadata. + */ + if (self->prepare && self->status == STMT_PREMATURE) + { + mylog("SC_opencheck: self->prepare && self->status == STMT_PREMATURE\n"); + return FALSE; + } + if (res = SC_get_Curres(self), NULL != res) { if (res->backend_tuples)
psqlodbc_win32.def.diff (application/octet-stream, 333B) download --- ../../VC/psqlodbc-08.00.0004/psqlodbc_win32.def 2005-01-28 22:36:20.000000000 +0100 +++ ./psqlodbc_win32.def 2005-02-15 18:45:01.345062500 +0100 @@ -47,7 +47,7 @@ SQLProcedureColumns @66 SQLProcedures @67 SQLSetPos @68 -SQLSetScrollOptions @69 +;SQLSetScrollOptions @69 SQLTablePrivileges @70 SQLBindParameter @72
^ permalink raw reply [nested|flat] 7+ messages in thread

* Re: Bug in ODBC driver 08.00.0004 and stored procedure
@ 2005-02-23 16:54  Dave Page <dpage@vale-housing.co.uk>
  0 siblings, 0 replies; 7+ messages in thread

From: Dave Page @ 2005-02-23 16:54 UTC (permalink / raw)
  To: Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>; +Cc: pgsql-odbc; Peter Eisentraut <peter_e@gmx.net>

 

> -----Original Message-----
> From: Joost Kraaijeveld [mailto:J.Kraaijeveld@Askesis.nl] 
> Sent: 15 February 2005 18:20
> To: Dave Page
> Cc: pgsql-odbc@postgresql.org
> Subject: RE: [ODBC] Bug in ODBC driver 08.00.0004 and stored procedure
> 
> Hi Dave,
> 
> Attached are the patches I created for solving the problem.

Thanks Joost - patches applied (I also modified SQLGetFunctions in
info.c to stop it reporting that SQLSetScrollOptions was implemented).

> Also attached a MinGW makefile that works and gives a working 
> dll. I have given the autoconf stuff a look but that is 
> higher math to me. Something for the bright people amongs us.

Err, it wasn't attached :-(. Perhaps Peter can look at detecting the
Windows DM as a valid alternative to iODBC/unixODBC though - he's the
resident autoconf guru :-)

Regards, Dave.



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Bug in ODBC driver 08.00.0004 and stored procedure
@ 2005-02-23 17:35  Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
  0 siblings, 1 reply; 7+ messages in thread

From: Joost Kraaijeveld @ 2005-02-23 17:35 UTC (permalink / raw)
  To: Dave Page <dpage@vale-housing.co.uk>; +Cc: pgsql-odbc; Peter Eisentraut <peter_e@gmx.net>

Hi Dave,

Dave Page schreef:
> Err, it wasn't attached :-(. Perhaps Peter can look at detecting the
> Windows DM as a valid alternative to iODBC/unixODBC though - he's the
> resident autoconf guru :-) 
Sorry about that. New trial. Maybe the file can be used as a starting point for Peter.

Groeten,

Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
e-mail: J.Kraaijeveld@Askesis.nl
web: www.askesis.nl

Attachments:

  Makefile.mingw (application/octet-stream, 3.5K) download

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Bug in ODBC driver 08.00.0004 and stored procedure
@ 2005-02-24 20:18  Peter Eisentraut <peter_e@gmx.net>
  parent: Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
  0 siblings, 0 replies; 7+ messages in thread

From: Peter Eisentraut @ 2005-02-24 20:18 UTC (permalink / raw)
  To: Joost Kraaijeveld <J.Kraaijeveld@askesis.nl>; +Cc: Dave Page <dpage@vale-housing.co.uk>; pgsql-odbc

Joost Kraaijeveld wrote:
> > Err, it wasn't attached :-(. Perhaps Peter can look at detecting
> > the Windows DM as a valid alternative to iODBC/unixODBC though -
> > he's the resident autoconf guru :-)
>
> Sorry about that. New trial. Maybe the file can be used as a starting
> point for Peter.

Perhaps we can start by determining what is wrong with the current 
setup.  What happens when you do configure; make; make install?

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Bug in ODBC driver 08.00.0004 and stored procedure
@ 2005-02-24 20:54  Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
  0 siblings, 0 replies; 7+ messages in thread

From: Joost Kraaijeveld @ 2005-02-24 20:54 UTC (permalink / raw)
  To: Peter Eisentraut <peter_e@gmx.net>; +Cc: Dave Page <dpage@vale-housing.co.uk>; pgsql-odbc

Hi Peter,

Attached the output of ./configure  (err.txt) and the config.log. configure tries to find SQLGetPrivateProfileString in the wrong libraries:

checking for SQLGetPrivateProfileString in -lodbcinst... no
checking for SQLGetPrivateProfileString in -liodbcinst... no
configure: error: no suitable ODBC driver manager found

Groeten,

Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
e-mail: J.Kraaijeveld@Askesis.nl
web: www.askesis.nl

Attachments:

  config.log (application/octet-stream, 10.4K) download

err.txt (text/plain, 916B) download checking for a BSD-compatible install... /bin/install -c checking whether build environment is sane... yes checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether to enable maintainer-specific portions of Makefiles... no checking for style of include used by make... GNU checking for gcc... gcc checking for C compiler default output... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... .exe checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking dependency style of gcc... gcc3 checking for SQLGetPrivateProfileString in -lodbcinst... no checking for SQLGetPrivateProfileString in -liodbcinst... no configure: error: no suitable ODBC driver manager found
^ permalink raw reply [nested|flat] 7+ messages in thread

* Re: Bug in ODBC driver 08.00.0004 and stored procedure
@ 2005-02-24 21:42  Dave Page <dpage@vale-housing.co.uk>
  0 siblings, 0 replies; 7+ messages in thread

From: Dave Page @ 2005-02-24 21:42 UTC (permalink / raw)
  To: Peter Eisentraut <peter_e@gmx.net>; Joost Kraaijeveld <J.Kraaijeveld@askesis.nl>; +Cc: pgsql-odbc

 

> -----Original Message-----
> From: Peter Eisentraut [mailto:peter_e@gmx.net] 
> Sent: 24 February 2005 20:18
> To: Joost Kraaijeveld
> Cc: Dave Page; pgsql-odbc@postgresql.org
> Subject: Re: [ODBC] Bug in ODBC driver 08.00.0004 and stored procedure
> 
> Joost Kraaijeveld wrote:
> > > Err, it wasn't attached :-(. Perhaps Peter can look at detecting
> > > the Windows DM as a valid alternative to iODBC/unixODBC though -
> > > he's the resident autoconf guru :-)
> >
> > Sorry about that. New trial. Maybe the file can be used as 
> a starting
> > point for Peter.
> 
> Perhaps we can start by determining what is wrong with the current 
> setup.  What happens when you do configure; make; make install?

It complains because neither unixODBC or iODBC can be found. Windows has
it's own DM of course.

Regards, Dave.



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2005-02-24 21:42 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-02-13 20:22 Bug in ODBC driver 08.00.0004 and stored procedure Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
2005-02-15 18:19 Re: Bug in ODBC driver 08.00.0004 and stored procedure Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
2005-02-23 16:54 Re: Bug in ODBC driver 08.00.0004 and stored procedure Dave Page <dpage@vale-housing.co.uk>
2005-02-23 17:35 Re: Bug in ODBC driver 08.00.0004 and stored procedure Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
2005-02-24 20:18 ` Peter Eisentraut <peter_e@gmx.net>
2005-02-24 20:54 Re: Bug in ODBC driver 08.00.0004 and stored procedure Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
2005-02-24 21:42 Re: Bug in ODBC driver 08.00.0004 and stored procedure Dave Page <dpage@vale-housing.co.uk>

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