PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Kimberly P dot Jones" <kimberly at cnet dot com>
Subject: any thoughts? (fwd)
Date: Mar 10 1999 4:32PM

Hey there.. wondering if any of you might be able to help me.

I have written a C++ program that execs a Perl script using perl_parse and
perl_run.

Note that prior to invoking perl_parse and perl_run this C++ program
creates a db connection (called G_database) using the RogueWave C++
library's RWDBDatabase class (which uses Sybase DBlib).

Also note that in the Perl script that the perl_run function executes
there is the following line: 

   require Sybase::DBlib;

The trouble is this: after perl_run returns, the db connection created
using RogueWave (G_database) (actually the DBPROCESS associated with
it) seems to have been corrupted somehow.

You can see this by looking at the output from the following piece of my
code, which consists of the perl_run command sandwiched by database status
checks and print statments: 

	 cerr <<"******************************************" << endl;
         RWDBStatus status = G_database.status();
	 cerr << "database status: " 
              << status.errorCode() 
              << " (" 
	      << status.message() 
              << ")" 
              << endl;
	 if (!G_database.connection().isValid()) {
	    cerr << "database connection not valid" << endl;
	 } else {
	    cerr << "database connection valid" << endl;
	 }
	 cerr << "******************************************" << endl;

    int runResult = perl_run(perlInterpreter_);

	 cerr << "******************************************" << endl;
         status = G_database.status();
	 cerr << "database status: " 
              << status.errorCode() 
              << " (" 
              << status.message() 
              << ")" 
              << endl;
	 if (!G_database.connection().isValid()) {
	    cerr << "database connection not valid" << endl;
	 } else {
	    cerr << "database connection valid" << endl;
	 }
	 cerr << "******************************************" << endl;

Here is that output:

   *****************************************************
   database status: 0 ()
   database connection valid
   database connection status: 0 ()
   *****************************************************
   *****************************************************
   database status: 0 ()
   DB-Library: NULL DBPROCESS pointer passed to DB-Library.

(After outputting this the program dies.)

So it looks like while the RogueWave db status bit is not getting
thrown, the db connection (G_database) has nonetheless somehow been
altered.

Note that if I removed the "require" line from the Perl script the problem
goes away (as expected). (Trouble is, the Perl script needs to do some db
work... so the require line cannot be removed.)

I suspect that when perl_run completes execution of the Perl script
containing the require Sybase::Dblib line it is doing come sort of
cleanup (pointer descruction) that is affcting the C++ program's db
connection.

If one of you Perl experts can give me some better idea of what is/might
be happening and/or how I might remedy the situation I would be most
grateful. 

My email adddress is in my .sig below.

KJ

Kimberly Passarella Jones (kimberly@cnet.com)
Senior Software Engineer, CNET Inc. (Nasdaq: CNET)
908-575-7400 x225