Author: turnstep
Date: Tue Apr 15 20:18:48 2008
New Revision: 11089

Modified:
   DBD-Pg/trunk/dbdimp.c

Log:
Croak on empty statement preparations. Better than coredumping!


Modified: DBD-Pg/trunk/dbdimp.c
==============================================================================
--- DBD-Pg/trunk/dbdimp.c       (original)
+++ DBD-Pg/trunk/dbdimp.c       Tue Apr 15 20:18:48 2008
@@ -1339,6 +1339,9 @@
 
        if (TSTART) TRC(DBILOGFP, "%sBegin dbd_st_prepare (statement: %s)\n", 
THEADER, statement);
 
+       if ('\0' == *statement)
+               croak ("Cannot prepare empty statement");
+
        /* Set default values for this statement handle */
        imp_sth->placeholder_type = 0;
        imp_sth->numsegs          = 0;
@@ -1365,7 +1368,6 @@
        imp_sth->use_inout        = DBDPG_FALSE; /* Are any of the placeholders 
using inout? */
        imp_sth->all_bound        = DBDPG_FALSE; /* Have all placeholders been 
bound? */
 
-
        /* We inherit some preferences from the database handle */
        imp_sth->server_prepare   = imp_dbh->server_prepare;
        imp_sth->prepare_now      = imp_dbh->prepare_now;
@@ -1529,7 +1531,7 @@
                }
                if (TRACE6) TRC(DBILOGFP, "%sdirect split = (%s) length=(%d)\n",
                                                THEADER, imp_sth->seg->segment, 
imp_sth->totalsize);
-               if (TEND) TRC(DBILOGFP, "%sEnd pg_St_split_statement 
(direct)\n", THEADER);
+               if (TEND) TRC(DBILOGFP, "%sEnd pg_st_split_statement 
(direct)\n", THEADER);
                return;
        }
 

Reply via email to