… | |
… | |
237 | n = lru_list.prev; |
237 | n = lru_list.prev; |
238 | |
238 | |
239 | lru_list.prev = n->prev; |
239 | lru_list.prev = n->prev; |
240 | n->prev->next = &lru_list; |
240 | n->prev->next = &lru_list; |
241 | |
241 | |
242 | SvREFCNT_dec (n->dbh); |
242 | SvREFCNT_dec_NN (n->dbh); |
243 | SvREFCNT_dec (n->sql); |
243 | SvREFCNT_dec_NN (n->sql); |
244 | SvREFCNT_dec (n->sth); |
244 | SvREFCNT_dec_NN (n->sth); |
245 | Safefree (n); |
245 | Safefree (n); |
246 | |
246 | |
247 | lru_size--; |
247 | lru_size--; |
248 | } |
248 | } |
249 | } |
249 | } |
… | |
… | |
265 | lru_trim (); |
265 | lru_trim (); |
266 | |
266 | |
267 | New (0, n, 1, lru_node); |
267 | New (0, n, 1, lru_node); |
268 | |
268 | |
269 | n->hash = hash; |
269 | n->hash = hash; |
270 | n->dbh = dbh; SvREFCNT_inc (dbh); /* note: this is the dbi hash itself, not the reference */ |
270 | n->dbh = SvREFCNT_inc_NN (dbh); /* note: this is the dbi hash itself, not the reference */ |
271 | n->sql = newSVsv (sql); |
271 | n->sql = newSVsv (sql); |
272 | n->sth = sth; SvREFCNT_inc (sth); |
272 | n->sth = SvREFCNT_inc_NN (sth); |
273 | n->sth_imp = sth_get_imp (sth); |
273 | n->sth_imp = sth_get_imp (sth); |
274 | n->mc = mc; |
274 | n->mc = mc; |
275 | |
275 | |
276 | n->next = lru_list.next; |
276 | n->next = lru_list.next; |
277 | n->prev = &lru_list; |
277 | n->prev = &lru_list; |
… | |
… | |
401 | if (!SvPOK (ST(arg))) |
401 | if (!SvPOK (ST(arg))) |
402 | croak ("sql_exec: sql-statement must be a string"); |
402 | croak ("sql_exec: sql-statement must be a string"); |
403 | |
403 | |
404 | sql = ST(arg); arg++; |
404 | sql = ST(arg); arg++; |
405 | |
405 | |
406 | if ((ix & ~1) == 6) |
406 | if ((ix & ~1) == 6) /* sql_exists */ |
407 | { |
407 | { |
408 | SV *neu = sv_2mortal (newSVpv ("select count(*) > 0 from ", 0)); |
408 | SV *neu = sv_2mortal (newSVpv ("select count(*) > 0 from ", 0)); |
409 | sv_catsv (neu, sql); |
409 | sv_catsv (neu, sql); |
410 | sv_catpv (neu, " limit 1"); |
410 | sv_catpv (neu, " limit 1"); |
411 | sql = neu; |
411 | sql = neu; |
… | |
… | |
507 | arg++; |
507 | arg++; |
508 | } |
508 | } |
509 | |
509 | |
510 | /* now use execute without any arguments */ |
510 | /* now use execute without any arguments */ |
511 | PUSHMARK (SP); |
511 | PUSHMARK (SP); |
512 | EXTEND (SP, 1); |
|
|
513 | PUSHs (sth); |
512 | XPUSHs (sth); |
514 | } |
513 | } |
515 | else |
514 | else |
516 | { |
515 | { |
517 | sth = sv_2mortal (SvREFCNT_inc (lru->sth)); |
516 | sth = sv_2mortal (SvREFCNT_inc (lru->sth)); |
518 | mc = lru->mc; |
517 | mc = lru->mc; |
… | |
… | |
588 | SvPV (get_sv ("DBI::errstr", TRUE), dd)); |
587 | SvPV (get_sv ("DBI::errstr", TRUE), dd)); |
589 | |
588 | |
590 | POPs; |
589 | POPs; |
591 | } |
590 | } |
592 | |
591 | |
593 | if ((ix & ~1) == 2) |
592 | if ((ix & ~1) == 2) /* sql_fetch */ |
594 | { /* sql_fetch */ |
593 | { |
595 | SV *row; |
594 | SV *row; |
596 | |
595 | |
597 | PUSHMARK (SP); |
596 | PUSHMARK (SP); |
598 | XPUSHs (sth); |
597 | XPUSHs (sth); |
599 | PUTBACK; |
598 | PUTBACK; |
… | |
… | |
636 | default: |
635 | default: |
637 | abort (); |
636 | abort (); |
638 | } |
637 | } |
639 | } |
638 | } |
640 | } |
639 | } |
641 | else if ((ix & ~1) == 4) |
640 | else if ((ix & ~1) == 4) /* sql_fetchall */ |
642 | { /* sql_fetchall */ |
641 | { |
643 | SV *rows; |
642 | SV *rows; |
644 | |
643 | |
645 | PUSHMARK (SP); |
644 | PUSHMARK (SP); |
646 | XPUSHs (sth); |
645 | XPUSHs (sth); |
647 | PUTBACK; |
646 | PUTBACK; |
… | |
… | |
682 | { |
681 | { |
683 | SP = PL_stack_base + orig_stack; |
682 | SP = PL_stack_base + orig_stack; |
684 | XPUSHs (sth); |
683 | XPUSHs (sth); |
685 | } |
684 | } |
686 | |
685 | |
687 | if (ix > 1 || GIMME_V == G_VOID) |
686 | if (ix >= 2 || GIMME_V == G_VOID) |
688 | { |
687 | { |
689 | orig_stack = SP - PL_stack_base; |
688 | orig_stack = SP - PL_stack_base; |
690 | |
689 | |
691 | PUSHMARK (SP); |
690 | PUSHMARK (SP); |
692 | XPUSHs (sth); |
691 | XPUSHs (sth); |