Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: michael dot peppler at bnpparibas dot com
Subject: Re: The call to "prepare" is also executing the statement (also under bug report 599)
Date: Jun 27 2005 1:19PM

I'm working on fixing this.


Internet - 27/06/2005 14:51

Sent by:

To:    sybperl-l


Subject:    The call to "prepare" is also executing the statement (also
       under bug report 599)

I believe to have found a bug in the behavior of "prepare" in DBD::Sybase

The act of preparing a statement that has no bound parameters is, in fact,
executing the statement as well.

A snippet from my test script follows:

my $dbh = DBI->connect($data_source, $username, $password);
my $st = $dbh->prepare('select * into tmp from some_table');

I stepped through the code in the debugger and found that immediately after
call to prepare, the trace log indicates: "cmd_execute() -> ct_command()
I confirmed that it does insert these rows into the database at the point
merely preparing the statement.

My understanding is that this statement should not execute until I
call "$st->execute()". Version 1.02 of the driver behaved as I expected
it did not execute until "execute" was called).

Have I found a bug or is this a misunderstanding of the api?

Many thanks for a great product.


I thought this pasted snippet from my debug session may be helpful:

main::( my $st = $dbh->prepare('select * into tmp from
DB<3> n
-> prepare for DBD::Sybase::db (DBI::db=HASH(0x8df1a68)~0x8e29a38 'select *
into tmp from some_table')
New DBI::st (for DBD::Sybase::st, parent=DBI::db=HASH(0x8e29a38), id=)
DBD::Sybase::st, 8df8820, Null!)
dbih_make_com(DBI::db=HASH(0x8e29a38), 0x8e2a5d8, DBD::Sybase::st, 420,
(nil)) thr#(nil)
dbih_setup_attrib(DBI::st=HASH(0x8d8b304), Err, DBI::db=HASH(0x8e29a38))
SCALAR(0x81f50f4) (already defined)
dbih_setup_attrib(DBI::st=HASH(0x8d8b304), State, DBI::db=HASH(0x8e29a38))
SCALAR(0x81f516c) (already defined)
dbih_setup_attrib(DBI::st=HASH(0x8d8b304), Errstr, DBI::db=HASH(0x8e29a38))
SCALAR(0x81f5130) (already defined)
dbih_setup_attrib(DBI::st=HASH(0x8d8b304), TraceLevel, DBI::db=HASH
(0x8e29a38)) 0 (already defined)
dbih_setup_attrib(DBI::st=HASH(0x8d8b304), FetchHashKeyName, DBI::db=HASH
(0x8e29a38)) 'NAME' (already defined)
dbih_setup_attrib(DBI::st=HASH(0x8d8b304), HandleSetErr, DBI::db=HASH
(0x8e29a38)) undef (not defined)
dbih_setup_attrib(DBI::st=HASH(0x8d8b304), HandleError, DBI::db=HASH
(0x8e29a38)) undef (not defined)
syb_st_prepare() -> inUse = 0
syb_alloc_cmd() -> CS_COMMAND 8e5e4b8 for CS_CONNECTION 8e2b098
cmd_execute() -> ct_command() OK
cmd_execute() -> ct_send() OK
cmd_execute() -> set inUse flag
syb_st_prepare() -> set inUse
<- prepare= DBI::st=HASH(0x8e2a378) at line 52
main::( exit



This e-mail contains information that may be confidential and
proprietary. It is to be read and used solely by the intended recipient(s).
Citadel and its affiliates retain all proprietary rights they may have in
information. If you are not an intended recipient, please notify us
immediately either by reply e-mail or by telephone at 312-395-2100
and delete this e-mail (including any attachments hereto) immediately
without reading, disseminating, distributing or copying. We cannot give
any assurances that this e-mail and any attachments are free of viruses
and other harmful code. Citadel reserves the right to monitor, intercept
and block all communications involving its computer systems.

This message and any attachments (the "message") is
intended solely for the addressees and is confidential. 
If you receive this message in error, please delete it and 
immediately notify the sender. Any use not in accord with 
its purpose, any dissemination or disclosure, either whole 
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message. 
BNP PARIBAS (and its subsidiaries) shall (will) not 
therefore be liable for the message if modified. 


Ce message et toutes les pieces jointes (ci-apres le 
"message") sont etablis a l'intention exclusive de ses 
destinataires et sont confidentiels. Si vous recevez ce 
message par erreur, merci de le detruire et d'en avertir 
immediatement l'expediteur. Toute utilisation de ce 
message non conforme a sa destination, toute diffusion 
ou toute publication, totale ou partielle, est interdite, sauf 
autorisation expresse. L'internet ne permettant pas 
d'assurer l'integrite de ce message, BNP PARIBAS (et ses
filiales) decline(nt) toute responsabilite au titre de ce 
message, dans l'hypothese ou il aurait ete modifie.