pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Matt Lilley <matt.lilley@securitease.com>
To: pgsql-odbc@postgresql.org
Subject: pgsql-odbc and iodbc (on OSX, at least)
Date: Wed, 03 Jul 2013 05:21:33 +1200
Message-ID: <51D30C1D.4080501@securitease.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-odbc>

Hi,

I've been chasing down a confusing problem with pgsql-odbc and iodbc. 
I've downloaded the latest version from git, configured with 
--with-iodbc, compiled, and tried running this simple test program with 
surprising results:

#include <sql.h>
#include <sqlext.h>

int main(int argc, char** argv)
{
    SQLHENV henv;
    SQLHDBC hdbc;
    SQLCHAR connection_out[1025];
    SQLSMALLINT connection_out_len;
    SQLAllocEnv(&henv);
    SQLAllocConnect(henv, &hdbc);
    printf("Connect: %d\n", SQLDriverConnect(hdbc, NULL, DRIVER_STRING, 
SQL_NTS, connection_out, 1024, &connection_out_len, SQL_DRIVER_NOPROMPT));
    printf("Status: %d\n", SQLSetConnectOption(hdbc, SQL_AUTOCOMMIT, 0));
    return 0;
}

I get Connect: 0, Status -2. (I should say this is also true of the 
prebuilt binaries for OSX last time I tried them). Time for some 
digging. pgsql-odbc does not implement SQLSetConnectOption, so I 
expected iodbc's call to dlsym(..., "SQLSetConnectOption[W]") to return 
NULL. It doesn't. Digging deeper, I realised that this is defined in 
iodbc, and because iodbc-config --libs returns "-L/usr/lib  -liodbc 
-liodbcinst", psqlodbc[w].so is linked to libiodbc.x.dylib. This 
explains which function it's finding: the driver manager is getting its 
/own/ SQLSetConnectOption, and thinking it's the driver's one. When it 
then calls the function, predictably the result is that the handle is 
not recognised, and the call is rejected. (Yes, I know 
SQLSetConnectOption is deprecated and has been for a long time now. This 
sample code above is really a test case from a much larger application 
which I don't control the source for.)

I edited the Makefile and removed the -liodbc, relinked, and presto - 
everything worked. I don't know what the right answer is here: Is this 
the fault of iodbc for returning -liodbc in --libs? (I'm not entirely 
sure what --libs is intended for. Clearly not database *drivers* if it's 
going to produce this logic!) or is this the fault of pgsql-odbc for not 
doing something else? It's trivial enough to patch around by judicious 
use of sed, but I see that you don't use sed anywhere else in the 
autoconf files. Rather than reach into my personal toolbox and apply a 
band-aid, I thought I'd better just point out the problem to the list in 
the hope I can it fixed properly, and save someone else the same 
head-scratching I went though.

While I have your attention, and discussing deprecated things, in 
configure.ac I see
AM_CONFIG_HEADER([config.h])
which I had to replace with
AC_CONFIG_HEADERS([config.h])
before autotools would let me bootstrap. Is it possible to change this 
as well?

Thanks,
Matt

-- 
_____________________________________________
Matt Lilley
Software Engineer
SecuritEase

Tel:    +64 4 912-2100
Fax:    +64 4 912-2101
E-mail: matt.lilley@securitease.com
Web:    http://www.securitease.com
_____________________________________________

This e-mail has passed our content security scan.
It is covered by the confidentiality clauses at http://www.securitease.com/content_and_confidentiality



-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



Message-ID: <51D30C1D.4080501@securitease.com>
Permalink:  ../51D30C1D.4080501@securitease.com/
Also on:    postgresql.org/message-id/51D30C1D.4080501@securitease.com

 · 

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: matt.lilley@securitease.com
  Subject: Re: pgsql-odbc and iodbc (on OSX, at least)
  In-Reply-To: <51D30C1D.4080501@securitease.com>
  References: <51D30C1D.4080501@securitease.com>

* 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