Skip site navigation (1) Skip section navigation (2)

[ psqlodbc-Bugs-1007690 ] SQLNumResultCols returns error and HY000 error when it should be success and 0 columns

From: <noreply(at)pgfoundry(dot)org>
To: noreply(at)pgfoundry(dot)org
Subject: [ psqlodbc-Bugs-1007690 ] SQLNumResultCols returns error and HY000 error when it should be success and 0 columns
Date: 2007-07-16 13:21:40
Message-ID: 20070716132140.C3B61217040@pgfoundry.org (view raw or flat)
Thread:
Lists: pgsql-odbc
Bugs item #1007690, was opened at 2007-07-16 13:21
You can respond by visiting: 
http://pgfoundry.org/tracker/?func=detail&atid=538&aid=1007690&group_id=1000125

Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Martin Evans (mjevans)
Assigned to: Nobody (None)
Summary: SQLNumResultCols returns error and HY000 error when it should be success and 0 columns

Initial Comment:
Using the Postgres ODBC Driver 08.01.0200 on Linux/Ubuntu it fails some of the Perl DBD::ODBC tests. The tests attempt to update a column and then look at what SQLNumResultCols returns but SQLNumResultCols errors returning "HY000, No query has been executed with that handle". This may be demonstrated with:

create table fred (a int)
insert into table fred values (1)

perl -e 'use Data::Dumper;use DBI;$h=DBI->connect("dbi:ODBC:mydb","martin","easysoft");$s = $h->prepare("update fred set a = 1  where a = 1");print Dumper($s->{NAME});$s->execute;print Dumper($s->{NAME});'

$VAR1 = [];
Describe failed during DBI::st=HASH(0x82fca90)->FETCH(NAME,0) at /usr/lib/perl/5.8/Data/Dumper.pm line 511.
$VAR1 = undef;

If you look at an ODBC trace you'll see:

SQLPrepare(update table set column = 100 where column = 100);
SQLNumResultCols returns 0 columns
SQLMoreResults returns SQL_NO_DATA
SQLExecute
SQLRowCount returns 1 row affected
SQLNumResultCols returns 0 columns
SQLMoreResults returns SQL_NO_DATA
SQLNumResultCols returns an error saying
  HY000 No query has been executed with that handle

The unixODBC driver manager lets this call through because it is not a function sequence error (usually the only error you get from SQLNumResultCols) and:

1. as far as I can see from the ODBC spec SQLNumResultCols should return success and 0 columns here
2. 3 other drivers I've tried today all work fine with this. 

As far as I can tell this HY000 error has been specifically inserted into the postgres ODBC driver when returning success and 0 columns is the behavior outlined by ODBC and what most (if not all) other ODBC drivers do.


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

You can respond by visiting: 
http://pgfoundry.org/tracker/?func=detail&atid=538&aid=1007690&group_id=1000125

pgsql-odbc by date

Next:From: Andrei KovalevskiDate: 2007-07-17 13:06:28
Subject: New Win32 ODBCng for PostgreSQL released
Previous:From: noreplyDate: 2007-07-16 13:11:35
Subject: [ psqlodbc-Bugs-1007689 ] Returns ODBC 2.0 column names for SQLTables calls but reports ODBC 3.0

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group