… | |
… | |
6 | # define get_sv perl_get_sv |
6 | # define get_sv perl_get_sv |
7 | # define call_method perl_call_method |
7 | # define call_method perl_call_method |
8 | # define call_sv perl_call_sv |
8 | # define call_sv perl_call_sv |
9 | #endif |
9 | #endif |
10 | |
10 | |
11 | #if (PERL_VERSION < 5) || ((PERL_VERSION == 5) && (PERL_SUBVERSION <= 5)) |
11 | #if (PERL_VERSION > 5) || ((PERL_VERSION == 5) && (PERL_SUBVERSION >= 6)) |
12 | # define CAN_UTF8 1 |
12 | # define CAN_UTF8 1 |
13 | #endif |
13 | #endif |
14 | |
14 | |
15 | static SV * |
15 | static SV * |
16 | sql_upgrade_utf8 (SV *sv) |
16 | sql_upgrade_utf8 (SV *sv) |
… | |
… | |
233 | SP += items; |
233 | SP += items; |
234 | |
234 | |
235 | /* first check wether we should use an explicit db handle */ |
235 | /* first check wether we should use an explicit db handle */ |
236 | if (!is_dbh (dbh)) |
236 | if (!is_dbh (dbh)) |
237 | { |
237 | { |
|
|
238 | /* the next line doesn't work - check why later maybe */ |
238 | dbh = get_sv ("DBH", FALSE); |
239 | /* dbh = get_sv ("DBH", FALSE); |
239 | if (!is_dbh (dbh)) |
240 | if (!is_dbh (dbh)) |
240 | { |
241 | {*/ |
241 | dbh = GvSV(DBH); |
242 | dbh = GvSV(DBH); |
242 | if (!is_dbh (dbh)) |
243 | if (!is_dbh (dbh)) |
|
|
244 | croak ("sql_exec: no $DBH argument and no fallback in $PApp::SQL::DBH"); |
243 | croak ("sql_exec: no $DBH found in current package or in PApp::SQL::"); |
245 | /*croak ("sql_exec: no $DBH found in current package or in PApp::SQL::"); |
244 | } |
246 | }*/ |
245 | } |
247 | } |
246 | else |
248 | else |
247 | arg++; /* we consumed one argument */ |
249 | arg++; /* we consumed one argument */ |
248 | |
250 | |
249 | /* count the remaining references (for bind_columns) */ |
251 | /* count the remaining references (for bind_columns) */ |
… | |
… | |
311 | SPAGAIN; |
313 | SPAGAIN; |
312 | |
314 | |
313 | if (count != 1) |
315 | if (count != 1) |
314 | croak ("sql_exec: execute() didn't return any value ('%s'): %s", |
316 | croak ("sql_exec: execute() didn't return any value ('%s'): %s", |
315 | SvPV (sql, dc), |
317 | SvPV (sql, dc), |
316 | SvPV (get_sv ("DBI::errstr", TRUE), dc)); |
318 | SvPV (get_sv ("DBI::errstr", TRUE), dd)); |
317 | |
319 | |
318 | execute = POPs; |
320 | execute = POPs; |
319 | |
321 | |
320 | if (!SvTRUE (execute)) |
322 | if (!SvTRUE (execute)) |
321 | croak ("sql_exec: unable to execute statement '%s' (%s)", |
323 | croak ("sql_exec: unable to execute statement '%s' (%s)", |
322 | SvPV (sql, dc), |
324 | SvPV (sql, dc), |
323 | SvPV (get_sv ("DBI::errstr", TRUE), dc)); |
325 | SvPV (get_sv ("DBI::errstr", TRUE), dd)); |
324 | |
326 | |
325 | sv_setsv (GvSV(sql_exec), execute); |
327 | sv_setsv (GvSV(sql_exec), execute); |
326 | |
328 | |
327 | if (bind_first != bind_last) |
329 | if (bind_first != bind_last) |
328 | { |
330 | { |
… | |
… | |
339 | SPAGAIN; |
341 | SPAGAIN; |
340 | |
342 | |
341 | if (count != 1) |
343 | if (count != 1) |
342 | croak ("sql_exec: bind_columns() didn't return any value ('%s'): %s", |
344 | croak ("sql_exec: bind_columns() didn't return any value ('%s'): %s", |
343 | SvPV (sql, dc), |
345 | SvPV (sql, dc), |
344 | SvPV (get_sv ("DBI::errstr", TRUE), dc)); |
346 | SvPV (get_sv ("DBI::errstr", TRUE), dd)); |
345 | |
347 | |
346 | if (!SvOK (POPs)) |
348 | if (!SvOK (POPs)) |
347 | croak ("sql_exec: bind_columns() didn't return a true ('%s'): %s", |
349 | croak ("sql_exec: bind_columns() didn't return a true ('%s'): %s", |
348 | SvPV (sql, dc), |
350 | SvPV (sql, dc), |
349 | SvPV (get_sv ("DBI::errstr", TRUE), dc)); |
351 | SvPV (get_sv ("DBI::errstr", TRUE), dd)); |
350 | } |
352 | } |
351 | |
353 | |
352 | /* free our arguments from the stack */ |
354 | /* free our arguments from the stack */ |
353 | SP -= items; |
355 | SP -= items; |
354 | |
356 | |