pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: ericgolson@gmail.com
To: pgsql-odbc@postgresql.org
Subject: ODBCv3 help...
Date: 1 Jul 2004 13:04:45 -0700
Message-ID: <fa023786.0407011204.3124bac7@posting.google.com> (raw)

my system is configured as follows:
Red Hat 8, postgreSQL 7.4.3, psqlodbc-07.03.0200, and unixODBC-2.2.9.

I have been trying to get the following very simple code snippet
working but it always seg faults after connecting to the db....it
connects then if I try to execute a sql statement it seg faults or in
the below example just freeing the DBC handle will cause a seg
fault...am I missing something?? with the v2 calls to alloc handle and
free handle EVERYTHING works fine...I'm thinking maybe I didn't
configure something properly to use ODBCv3?:

#include "sql.h"
#include "sqlext.h"
#include "stdio.h"
int main () {
 
    SQLHENV env;
    SQLHDBC dbc;    
    SQLAllocHandle (SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);

    fprintf (stderr, "Allocated ENV\n");

    SQLAllocHandle( SQL_HANDLE_DBC, env, &dbc );
    fprintf (stderr, "Allocated DBC\n");

    SQLConnect( dbc,
                    (SQLCHAR*) "erictest", SQL_NTS,
                    (SQLCHAR* ) "olsoneg", SQL_NTS,
                    (SQLCHAR*) NULL, SQL_NTS );

    fprintf (stderr, "Connected\n");


     SQLDisconnect( dbc );
     
    SQLFreeHandle (SQL_HANDLE_DBC, dbc);

    SQLFreeHandle (SQL_HANDLE_ENV, env);

}


However if I substitute with the V2 ODBC functions like that follows
then everything works:
#include "sql.h"
#include "sqlext.h"
#include "stdio.h"
int main () {
 
    SQLHENV env;
    SQLHDBC dbc;
    SQLAllocEnv (&env);    

    fprintf (stderr, "Allocated ENV\n");

    SQLAllocConnect (env, &dbc);
    fprintf (stderr, "Allocated DBC\n");

    SQLConnect( dbc,
                    (SQLCHAR*) "erictest", SQL_NTS,
                    (SQLCHAR* ) "olsoneg", SQL_NTS,
                    (SQLCHAR*) NULL, SQL_NTS );

    fprintf (stderr, "Connected\n");

     SQLDisconnect( dbc );
     
     SQLFreeConnect (dbc);
     
     SQLFreeEnv (env);
    
}


Any help on why the V2 calls work but the V3 don't would be GREATLY
appreciated...



view thread (3+ messages)  latest in thread

Message-ID: <fa023786.0407011204.3124bac7@posting.google.com>
Permalink:  ../fa023786.0407011204.3124bac7@posting.google.com/
Also on:    postgresql.org/message-id/fa023786.0407011204.3124bac7@posting.google.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: ericgolson@gmail.com
  Subject: Re: ODBCv3 help...
  In-Reply-To: <fa023786.0407011204.3124bac7@posting.google.com>
  References: <fa023786.0407011204.3124bac7@posting.google.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