home *** CD-ROM | disk | FTP | other *** search
-
-
- The Sybase DB-Library - Perl savestr() conflict
- ------------------------------------------------
-
-
- Ah! The joys of tying different packages together!
-
- Both Perl and DB-Library have a function called savestr(). The
- DB-Library version is used in dbcmd() to add an SQL command to the
- list of commands pointed to by dpproc->dbcmdbuf, and in dbuse() as
- well. Now there are several ways to work around this problem.
-
- 1) Compile sybperl.c with -DBROKEN_DBCMD. I've written some code
- that emulates calls to dbcmd() and dbuse(). This works OK on my
- machine/OS/Version of Perl/Version of DBlib, but it relies on
- the internal storing method used by DBlib, and that might
- change in the future.
-
- 2) Recompile Perl (specifically, uperl.o in the Perl source
- directory) with some suitable flags (eg -Dsavestr=p_savestr).
- This does not create any compatibility problems, but is a
- lengthy procedure.
-
- 3) Do something like:
- cc -c sybperl.c
- ld -r -o sybperl2.o sybperl.o -lsybdb
- [edit sybperl2.o and replace `_savestr' with something like `_savest1']
- cc -o sybperl uperl.o sybperl2.o
- This is not a bad solution, but won't work if you have shared
- library versions of libsybdb.a
-
- 4) Edit uperl.o and replace savestr with something else. This is
- the solution I've chosen as the default. It is relatively fast,
- does not rely on any internal knowledge of DB-Library, and does
- not require Perl to be recompiled.
-
- The Makefile gives some information on how to achieve these
- different options.
-
- Thanks to Teemu Torma for providing the initial input on this problem.
-
-
-
- Sybperl Memory Usage
- --------------------
-
- The general format of a Sybperl script usually looks somewhat like
- this:
-
- #!/usr/local/bin/sybperl
-
- &dbcmd( query text );
- &dbsqlexec;
- &dbresults;
-
- while(@data = &dbnextrow)
- {
- process data
- }
-
-
- If you are using a version of Perl prior to release 4, patchlevel
- 35, then this method will result in a rather important memory
- leak. There are two ways around this problem:
-
- 1) Upgrade to Perl 4, patchlevel 35 :-)
-
- 2) Write a subroutine that calls &dbnextrow and stores the returned
- array to a local variable, and which in turn returns that array to
- the main while() loop, like so:
-
- sub getRow
- {
- local(@data);
-
- @data = &dbnextrow;
-
- @data;
- }
-
- while(@data = &getRow)
- {
- etc.
- }
-
-
- This technique should keep the memory usage of Sybperl to a
- manageable level.
-
-
-
-
-
-
-
-
- Please let me know if you find any other problems with Sybperl so
- that I can look into it.
-
- Thank you.
-
- Michael Peppler <mpeppler@itf.ch>
-
-
-