Sybase::DBlib and Perl from C++ 
Author Message
 Sybase::DBlib and Perl from C++

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


Senior Software Engineer, CNET Inc. (Nasdaq: CNET)
908-575-7400 x225



Sun, 26 Aug 2001 03:00:00 GMT  
 Sybase::DBlib and Perl from C++

Quote:
Kimberly P. Jones wrote...

>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).

From the code you posted there is no way to conclude what could be wrong.
The code itself doesn't contain any statements or expressions that could
do harm to any objects in your program.  Discussing perl, or Sybase, or
RogueWave goes beyond the scope of this comp.lang.c++ newsgroup.  I'd
like to ask the posters, who are going to reply, to use their best
judgement and remove irrelevant newsgroups from the list to avoid
cross-posting.

Victor
--
comp.lang.c FAQ: http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ FAQ: http://www.cerfnet.com/~mpcline/c++-faq-lite/
Please remove capital A's from my address when replying by mail



Sun, 26 Aug 2001 03:00:00 GMT  
 Sybase::DBlib and Perl from C++
This post is off topic here. Standard C++ does not know anything
Sybase, Roguwave, or Perl.

Obviously  something in calling the perl interpreter is trashing
your
db object, and thus you will need to check that code.

Read the Welcome to C++ post.
A copy is kept at http://members.xoom.com/jshiva/welcome.txt
& find out some newsgroups suitable for your question.
like microsoft.public.vc.*

You can get the FAQ at:
         http://www.cerfnet.com/~mpcline/c++-faq-lite/

|
|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
|

|Senior Software Engineer, CNET Inc. (Nasdaq: CNET)
|908-575-7400 x225
|
|
|
|
|
|



Sun, 26 Aug 2001 03:00:00 GMT  
 Sybase::DBlib and Perl from C++

Quote:

> 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.

Possible.

What does your perl script look like?

Michael
--
Michael Peppler         -||-  Data Migrations Inc.

Int. Sybase User Group  -||-  http://www.isug.com



Sun, 26 Aug 2001 03:00:00 GMT  
 Sybase::DBlib and Perl from C++

Quote:

>> 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.

>Possible.

>What does your perl script look like?

Kimberley's post didn't make it to my server, but I looked it
up a DejaNews. Of course, without having Kimberley's Perl code
at hand, we're in for a telepathy, but there are two calls which
could be crucial.

The first is dblogin, and this is called when you say "Require
Sybase::DBlib". Now, if I understand things right, the Sybase
module is already loaded, so nothing should really happen. And
in any case, you should be able to call dblogin twice.

However, do your Perl code call dbexit at the end? In such case
we have the killer. dbexit will close all connections - included
those opened by RougeWave. The fact that RougeWave still reports
the connection as good, is presumably because it consults its in-
ternal structures; it probably does not expect anyone else to
close the connection (not that a call to DBDEAD would have been
an excess on their part).

--

This could have been my two cents worth, but alas the Swedish
government has decided that I am not to have any cents.



Wed, 29 Aug 2001 03:00:00 GMT  
 Sybase::DBlib and Perl from C++

Quote:



> >> 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.

> >Possible.

> >What does your perl script look like?

> However, do your Perl code call dbexit at the end? In such case
> we have the killer. dbexit will close all connections - included
> those opened by RougeWave.

My understanding is that the problem appears if the *only* thing in the
perl script is "require Sybase::DBlib;".

The cleanup code definitely does NOT call dbexit() internally, so I
doubt that this is the problem.

It could be that dbinit() screws things up, though.

Michael
--
Michael Peppler         -||-  Data Migrations Inc.

Int. Sybase User Group  -||-  http://www.isug.com



Thu, 30 Aug 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. sybase extenstions to perl (Sybase::DBlib)

2. Sybase DBlib/Sybperl/Sybase CTlib tutorial.

3. Perl Help With Sybase::DBlib and $DB_ERROR

4. Perl, Sybase: :DBlib and BCP

5. Perl, Sybase: :DBlib and BCP

6. Perl Help With Sybase::DBlib and $DB_ERROR

7. sybperl2b3 compilation with perl 5.001m and Sybase DBlib 4.6.1

8. Sybase DBlib and Unix dbm

9. SYBASE::DBlib

10. Need help with Sybase::DBlib module and setting database name

11. Sybase::DBlib and dbresults

12. From Sybase::DBlib to DBI::mysql

 

 
Powered by phpBB® Forum Software