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

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
toupdate a column and then look at what SQLNumResultCols returns but SQLNumResultCols errors returning "HY000, No query
hasbeen 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
seta = 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
youget 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
successand 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