dbTalk Databases Forums  

Pervasive PSQL 8.5 and C++ On Linux

comp.databases.btrieve comp.databases.btrieve


Discuss Pervasive PSQL 8.5 and C++ On Linux in the comp.databases.btrieve forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
John C. Frickson
 
Posts: n/a

Default Pervasive PSQL 8.5 and C++ On Linux - 03-12-2007 , 01:40 PM






I'm migrating some of our applications from Windows to our
Linux servers. The programs are in C++. They always get a
segmentation fault in SQLDriverConnect(). I've created a very
simple program in both C and C++ that exhibits the problem.
Save as both prg_c.c and prg_cpp.cpp and compiled with:
gcc -m32 -lodbc -o prg_c prg_c.c
g++ -m32 -lodbc -o prg_cpp prg_cpp.c
(-m32 because the server is running 64-bit Linux and PSQL
only comes with 32-bit drivers.)

-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----
#include <string.h>
#include <sql.h>
#include <sqlext.h>

int main(int argc, char **argv)
{
SQLHENV henv;
SQLHDBC hdbc;
SQLCHAR dsn[120];
short buflen;
char buffer[257];
int status;

strcpy((char*)dsn, "DSN=Paragon");
if (SQLAllocEnv (&henv) != SQL_SUCCESS)
return -1;
if (SQLAllocConnect (henv, &hdbc) != SQL_SUCCESS)
return -1;
status = SQLDriverConnect (hdbc, 0, dsn, SQL_NTS,
(SQLCHAR*)buffer, sizeof (buffer), &buflen,
SQL_DRIVER_COMPLETE);
if (status != SQL_SUCCESS && status != SQL_SUCCESS_WITH_INFO)
return -1;
SQLDisconnect (hdbc);
SQLFreeConnect (hdbc);
SQLFreeEnv (henv);

return 0;
}
-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----

The straight C program runs fine. The C++ program blows in
the SQLDriverConnect() call.

I've tried both -lodbc and -liodbc and both fail at the same
place.

John

Reply With Quote
  #2  
Old   
Bill Bach
 
Posts: n/a

Default Re: Pervasive PSQL 8.5 and C++ On Linux - 03-13-2007 , 10:13 AM






Not sure if it is the same thing or not, but this sounds awfully
similar:
http://bugs.mysql.com/bug.php?id=15248

Other random suggestions (with no basis whatsoever):
1) buflen is not initialized. Definition I found was "Pointer to the
total number of bytes (excluding the null termination byte) available
to return in szConnStrOut." Not sure if it should be initialized to
256 or not.
2) Have you tried the more simplistic SQLConnect? Or do you need more
flexibility in your "real" code?
BtrieveBill

John C. Frickson wrote:

Quote:
I'm migrating some of our applications from Windows to our
Linux servers. The programs are in C++. They always get a
segmentation fault in SQLDriverConnect(). I've created a very
simple program in both C and C++ that exhibits the problem.
Save as both prg_c.c and prg_cpp.cpp and compiled with:
gcc -m32 -lodbc -o prg_c prg_c.c
g++ -m32 -lodbc -o prg_cpp prg_cpp.c
(-m32 because the server is running 64-bit Linux and PSQL
only comes with 32-bit drivers.)

-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----
#include <string.h
#include <sql.h
#include <sqlext.h

int main(int argc, char **argv)
{
SQLHENV henv;
SQLHDBC hdbc;
SQLCHAR dsn[120];
short buflen;
char buffer[257];
int status;

strcpy((char*)dsn, "DSN=Paragon");
if (SQLAllocEnv (&henv) != SQL_SUCCESS)
return -1;
if (SQLAllocConnect (henv, &hdbc) != SQL_SUCCESS)
return -1;
status = SQLDriverConnect (hdbc, 0, dsn, SQL_NTS,
(SQLCHAR*)buffer, sizeof (buffer), &buflen,
SQL_DRIVER_COMPLETE);
if (status != SQL_SUCCESS && status != SQL_SUCCESS_WITH_INFO)
return -1;
SQLDisconnect (hdbc);
SQLFreeConnect (hdbc);
SQLFreeEnv (henv);

return 0;
}
-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----

The straight C program runs fine. The C++ program blows in
the SQLDriverConnect() call.

I've tried both -lodbc and -liodbc and both fail at the same
place.

John


Reply With Quote
  #3  
Old   
John C. Frickson
 
Posts: n/a

Default Re: Pervasive PSQL 8.5 and C++ On Linux - 03-14-2007 , 11:28 AM



I tried initializing buflen, and using SQLConnect(). Still get
seg fault.

For grins, I tried installing the 9.5 driver, but it couldn't
talk to the 8.5 server. I didn't think it would work, but it was
worth a try.

Maybe I'll try writing C wrapper functions and call them from
the C++ program.


On 2007-03-13 11:13, Bill Bach wrote:
Quote:
Not sure if it is the same thing or not, but this sounds awfully
similar:
http://bugs.mysql.com/bug.php?id=15248

Other random suggestions (with no basis whatsoever):
1) buflen is not initialized. Definition I found was "Pointer to the
total number of bytes (excluding the null termination byte) available
to return in szConnStrOut." Not sure if it should be initialized to
256 or not.
2) Have you tried the more simplistic SQLConnect? Or do you need more
flexibility in your "real" code?
BtrieveBill

John C. Frickson wrote:

I'm migrating some of our applications from Windows to our
Linux servers. The programs are in C++. They always get a
segmentation fault in SQLDriverConnect(). I've created a very
simple program in both C and C++ that exhibits the problem.
Save as both prg_c.c and prg_cpp.cpp and compiled with:
gcc -m32 -lodbc -o prg_c prg_c.c
g++ -m32 -lodbc -o prg_cpp prg_cpp.c
(-m32 because the server is running 64-bit Linux and PSQL
only comes with 32-bit drivers.)

-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----
#include <string.h
#include <sql.h
#include <sqlext.h

int main(int argc, char **argv)
{
SQLHENV henv;
SQLHDBC hdbc;
SQLCHAR dsn[120];
short buflen;
char buffer[257];
int status;

strcpy((char*)dsn, "DSN=Paragon");
if (SQLAllocEnv (&henv) != SQL_SUCCESS)
return -1;
if (SQLAllocConnect (henv, &hdbc) != SQL_SUCCESS)
return -1;
status = SQLDriverConnect (hdbc, 0, dsn, SQL_NTS,
(SQLCHAR*)buffer, sizeof (buffer), &buflen,
SQL_DRIVER_COMPLETE);
if (status != SQL_SUCCESS && status != SQL_SUCCESS_WITH_INFO)
return -1;
SQLDisconnect (hdbc);
SQLFreeConnect (hdbc);
SQLFreeEnv (henv);

return 0;
}
-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----

The straight C program runs fine. The C++ program blows in
the SQLDriverConnect() call.

I've tried both -lodbc and -liodbc and both fail at the same
place.

John


Reply With Quote
  #4  
Old   
Bill Bach
 
Posts: n/a

Default Re: Pervasive PSQL 8.5 and C++ On Linux - 03-15-2007 , 06:16 AM



V8.5 was pretty early in the Linux code. Perhaps moving to V8.7 would
help? This is a free update...
Goldstar Software Inc.
Pervasive-based Products, Training & Services
Bill Bach
BillBach (AT) goldstarsoftware (DOT) com
http://www.goldstarsoftware.com
*** Chicago: Pervasive Service & Support Class - 03/2007 ***

John C. Frickson wrote:

Quote:
I tried initializing buflen, and using SQLConnect(). Still get
seg fault.

For grins, I tried installing the 9.5 driver, but it couldn't
talk to the 8.5 server. I didn't think it would work, but it was
worth a try.

Maybe I'll try writing C wrapper functions and call them from
the C++ program.


On 2007-03-13 11:13, Bill Bach wrote:
Not sure if it is the same thing or not, but this sounds awfully
similar:
http://bugs.mysql.com/bug.php?id=15248

Other random suggestions (with no basis whatsoever):
1) buflen is not initialized. Definition I found was "Pointer to
the total number of bytes (excluding the null termination byte)
available to return in szConnStrOut." Not sure if it should be
initialized to 256 or not.
2) Have you tried the more simplistic SQLConnect? Or do you need
more flexibility in your "real" code?
BtrieveBill

John C. Frickson wrote:

I'm migrating some of our applications from Windows to our
Linux servers. The programs are in C++. They always get a
segmentation fault in SQLDriverConnect(). I've created a very
simple program in both C and C++ that exhibits the problem.
Save as both prg_c.c and prg_cpp.cpp and compiled with:
gcc -m32 -lodbc -o prg_c prg_c.c
g++ -m32 -lodbc -o prg_cpp prg_cpp.c
(-m32 because the server is running 64-bit Linux and PSQL
only comes with 32-bit drivers.)

-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----
#include <string.h
#include <sql.h
#include <sqlext.h

int main(int argc, char **argv)
{
SQLHENV henv;
SQLHDBC hdbc;
SQLCHAR dsn[120];
short buflen;
char buffer[257];
int status;

strcpy((char*)dsn, "DSN=Paragon");
if (SQLAllocEnv (&henv) != SQL_SUCCESS)
return -1;
if (SQLAllocConnect (henv, &hdbc) != SQL_SUCCESS)
return -1;
status = SQLDriverConnect (hdbc, 0, dsn, SQL_NTS,
(SQLCHAR*)buffer, sizeof (buffer), &buflen,
SQL_DRIVER_COMPLETE);
if (status != SQL_SUCCESS && status != SQL_SUCCESS_WITH_INFO)
return -1;
SQLDisconnect (hdbc);
SQLFreeConnect (hdbc);
SQLFreeEnv (henv);

return 0;
}
-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----

The straight C program runs fine. The C++ program blows in
the SQLDriverConnect() call.

I've tried both -lodbc and -liodbc and both fail at the same
place.

John



Reply With Quote
  #5  
Old   
John C. Frickson
 
Posts: n/a

Default Re: Pervasive PSQL 8.5 and C++ On Linux - 03-23-2007 , 03:20 PM



I downloaded/installed the 8.7 client on Linux. Still blew
at the same place. I didn't upgrade the server to 8.7 because
we have to go through a whole test and acceptance process.
If the 8.7 client acted any differently I probably would have
upgraded the server.

Can a 9.x client talk to an 8.5 server?


On 2007-03-15 07:16, Bill Bach wrote:
Quote:
V8.5 was pretty early in the Linux code. Perhaps moving to V8.7 would
help? This is a free update...
Goldstar Software Inc.
Pervasive-based Products, Training & Services
Bill Bach
BillBach (AT) goldstarsoftware (DOT) com
http://www.goldstarsoftware.com
*** Chicago: Pervasive Service & Support Class - 03/2007 ***

John C. Frickson wrote:

I tried initializing buflen, and using SQLConnect(). Still get
seg fault.

For grins, I tried installing the 9.5 driver, but it couldn't
talk to the 8.5 server. I didn't think it would work, but it was
worth a try.

Maybe I'll try writing C wrapper functions and call them from
the C++ program.


On 2007-03-13 11:13, Bill Bach wrote:
Not sure if it is the same thing or not, but this sounds awfully
similar:
http://bugs.mysql.com/bug.php?id=15248

Other random suggestions (with no basis whatsoever):
1) buflen is not initialized. Definition I found was "Pointer to
the total number of bytes (excluding the null termination byte)
available to return in szConnStrOut." Not sure if it should be
initialized to 256 or not.
2) Have you tried the more simplistic SQLConnect? Or do you need
more flexibility in your "real" code?
BtrieveBill

John C. Frickson wrote:

I'm migrating some of our applications from Windows to our
Linux servers. The programs are in C++. They always get a
segmentation fault in SQLDriverConnect(). I've created a very
simple program in both C and C++ that exhibits the problem.
Save as both prg_c.c and prg_cpp.cpp and compiled with:
gcc -m32 -lodbc -o prg_c prg_c.c
g++ -m32 -lodbc -o prg_cpp prg_cpp.c
(-m32 because the server is running 64-bit Linux and PSQL
only comes with 32-bit drivers.)

-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----
#include <string.h
#include <sql.h
#include <sqlext.h

int main(int argc, char **argv)
{
SQLHENV henv;
SQLHDBC hdbc;
SQLCHAR dsn[120];
short buflen;
char buffer[257];
int status;

strcpy((char*)dsn, "DSN=Paragon");
if (SQLAllocEnv (&henv) != SQL_SUCCESS)
return -1;
if (SQLAllocConnect (henv, &hdbc) != SQL_SUCCESS)
return -1;
status = SQLDriverConnect (hdbc, 0, dsn, SQL_NTS,
(SQLCHAR*)buffer, sizeof (buffer), &buflen,
SQL_DRIVER_COMPLETE);
if (status != SQL_SUCCESS && status != SQL_SUCCESS_WITH_INFO)
return -1;
SQLDisconnect (hdbc);
SQLFreeConnect (hdbc);
SQLFreeEnv (henv);

return 0;
}
-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----

The straight C program runs fine. The C++ program blows in
the SQLDriverConnect() call.

I've tried both -lodbc and -liodbc and both fail at the same
place.

John



Reply With Quote
  #6  
Old   
Bill Bach
 
Posts: n/a

Default Re: Pervasive PSQL 8.5 and C++ On Linux - 03-23-2007 , 04:32 PM



The 9.x client expects a 9.x server. Don't try to mix & match those
two versions.
BB

John C. Frickson wrote:

Quote:
I downloaded/installed the 8.7 client on Linux. Still blew
at the same place. I didn't upgrade the server to 8.7 because
we have to go through a whole test and acceptance process.
If the 8.7 client acted any differently I probably would have
upgraded the server.

Can a 9.x client talk to an 8.5 server?


On 2007-03-15 07:16, Bill Bach wrote:
V8.5 was pretty early in the Linux code. Perhaps moving to V8.7
would help? This is a free update...
Goldstar Software Inc.
Pervasive-based Products, Training & Services
Bill Bach
BillBach (AT) goldstarsoftware (DOT) com
http://www.goldstarsoftware.com
*** Chicago: Pervasive Service & Support Class - 03/2007 ***

John C. Frickson wrote:

I tried initializing buflen, and using SQLConnect(). Still get
seg fault.

For grins, I tried installing the 9.5 driver, but it couldn't
talk to the 8.5 server. I didn't think it would work, but it was
worth a try.

Maybe I'll try writing C wrapper functions and call them from
the C++ program.


On 2007-03-13 11:13, Bill Bach wrote:
Not sure if it is the same thing or not, but this sounds awfully
similar:
http://bugs.mysql.com/bug.php?id=15248

Other random suggestions (with no basis whatsoever):
1) buflen is not initialized. Definition I found was "Pointer to
the total number of bytes (excluding the null termination byte)
available to return in szConnStrOut." Not sure if it should be
initialized to 256 or not.
2) Have you tried the more simplistic SQLConnect? Or do you need
more flexibility in your "real" code?
BtrieveBill

John C. Frickson wrote:

I'm migrating some of our applications from Windows to our
Linux servers. The programs are in C++. They always get a
segmentation fault in SQLDriverConnect(). I've created a very
simple program in both C and C++ that exhibits the problem.
Save as both prg_c.c and prg_cpp.cpp and compiled with:
gcc -m32 -lodbc -o prg_c prg_c.c
g++ -m32 -lodbc -o prg_cpp prg_cpp.c
(-m32 because the server is running 64-bit Linux and PSQL
only comes with 32-bit drivers.)

-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----
#include <string.h
#include <sql.h
#include <sqlext.h

int main(int argc, char **argv)
{
SQLHENV henv;
SQLHDBC hdbc;
SQLCHAR dsn[120];
short buflen;
char buffer[257];
int status;

strcpy((char*)dsn, "DSN=Paragon");
if (SQLAllocEnv (&henv) != SQL_SUCCESS)
return -1;
if (SQLAllocConnect (henv, &hdbc) != SQL_SUCCESS)
return -1;
status = SQLDriverConnect (hdbc, 0, dsn, SQL_NTS,
(SQLCHAR*)buffer, sizeof (buffer), &buflen,
SQL_DRIVER_COMPLETE);
if (status != SQL_SUCCESS && status != SQL_SUCCESS_WITH_INFO)
return -1;
SQLDisconnect (hdbc);
SQLFreeConnect (hdbc);
SQLFreeEnv (henv);

return 0;
}
-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----

The straight C program runs fine. The C++ program blows in
the SQLDriverConnect() call.

I've tried both -lodbc and -liodbc and both fail at the same
place.

John




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.