ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/PApp-SQL/SQL.xs
(Generate patch)

Comparing PApp-SQL/SQL.xs (file contents):
Revision 1.2 by root, Tue Oct 24 04:21:45 2000 UTC vs.
Revision 1.3 by root, Tue Dec 19 14:22:05 2000 UTC

1#include "EXTERN.h" 1#include "EXTERN.h"
2#include "perl.h" 2#include "perl.h"
3#include "XSUB.h" 3#include "XSUB.h"
4
5#if (PERL_VERSION < 5) || ((PERL_VERSION == 5) && (PERL_SUBVERSION <= 6))
6# define get_sv perl_get_sv
7# define call_method perl_call_method
8#endif
4 9
5#define is_dbh(sv) ((sv) && sv_isobject (sv) && sv_derived_from ((sv), "DBI::db")) 10#define is_dbh(sv) ((sv) && sv_isobject (sv) && sv_derived_from ((sv), "DBI::db"))
6 11
7typedef struct lru_node { 12typedef struct lru_node {
8 struct lru_node *next; 13 struct lru_node *next;
178 int count; 183 int count;
179 SV *dbh = ST(0); 184 SV *dbh = ST(0);
180 SV *sth; 185 SV *sth;
181 SV *sql; 186 SV *sql;
182 SV *execute; 187 SV *execute;
188 STRLEN dc;
183 189
184 /* save our arguments against destruction through function calls */ 190 /* save our arguments against destruction through function calls */
185 SP += items; 191 SP += items;
186 192
187 /* first check wether we should use an explicit db handle */ 193 /* first check wether we should use an explicit db handle */
235 count = call_method ("prepare", G_SCALAR); 241 count = call_method ("prepare", G_SCALAR);
236 SPAGAIN; 242 SPAGAIN;
237 243
238 if (count != 1) 244 if (count != 1)
239 croak ("sql_exec: unable to prepare() statement '%s': %s", 245 croak ("sql_exec: unable to prepare() statement '%s': %s",
240 SvPV_nolen (sql), 246 SvPV (sql, dc),
241 SvPV_nolen (get_sv ("DBI::errstr", TRUE))); 247 SvPV (get_sv ("DBI::errstr", TRUE), dc));
242 248
243 sth = POPs; 249 sth = POPs;
244 250
245 lru_store (dbh, sql, sth); 251 lru_store (dbh, sql, sth);
246 } 252 }
262 count = call_method ("execute", G_SCALAR); 268 count = call_method ("execute", G_SCALAR);
263 SPAGAIN; 269 SPAGAIN;
264 270
265 if (count != 1) 271 if (count != 1)
266 croak ("sql_exec: execute() didn't return any value ('%s'): %s", 272 croak ("sql_exec: execute() didn't return any value ('%s'): %s",
267 SvPV_nolen (sql), 273 SvPV (sql, dc),
268 SvPV_nolen (get_sv ("DBI::errstr", TRUE))); 274 SvPV (get_sv ("DBI::errstr", TRUE), dc));
269 275
270 execute = POPs; 276 execute = POPs;
271 277
272 if (!SvTRUE (execute)) 278 if (!SvTRUE (execute))
273 croak ("sql_exec: unable to execute statement '%s' (%s)", 279 croak ("sql_exec: unable to execute statement '%s' (%s)",
274 SvPV_nolen (sql), 280 SvPV (sql, dc),
275 SvPV_nolen (get_sv ("DBI::errstr", TRUE))); 281 SvPV (get_sv ("DBI::errstr", TRUE), dc));
276 282
277 sv_setsv (GvSV(sql_exec), execute); 283 sv_setsv (GvSV(sql_exec), execute);
278 284
279 if (bind_first != bind_last) 285 if (bind_first != bind_last)
280 { 286 {
290 count = call_method ("bind_columns", G_SCALAR); 296 count = call_method ("bind_columns", G_SCALAR);
291 SPAGAIN; 297 SPAGAIN;
292 298
293 if (count != 1) 299 if (count != 1)
294 croak ("sql_exec: bind_columns() didn't return any value ('%s'): %s", 300 croak ("sql_exec: bind_columns() didn't return any value ('%s'): %s",
295 SvPV_nolen (sql), 301 SvPV (sql, dc),
296 SvPV_nolen (get_sv ("DBI::errstr", TRUE))); 302 SvPV (get_sv ("DBI::errstr", TRUE), dc));
297 303
298 if (!SvOK (POPs)) 304 if (!SvOK (POPs))
299 croak ("sql_exec: bind_columns() didn't return a true ('%s'): %s", 305 croak ("sql_exec: bind_columns() didn't return a true ('%s'): %s",
300 SvPV_nolen (sql), 306 SvPV (sql, dc),
301 SvPV_nolen (get_sv ("DBI::errstr", TRUE))); 307 SvPV (get_sv ("DBI::errstr", TRUE), dc));
302 } 308 }
303 309
304 /* free our arguments from the stack */ 310 /* free our arguments from the stack */
305 SP -= items; 311 SP -= items;
306 312

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines