--- PApp-SQL/SQL.xs 2001/04/22 14:38:28 1.5 +++ PApp-SQL/SQL.xs 2002/04/11 01:02:10 1.12 @@ -8,7 +8,7 @@ # define call_sv perl_call_sv #endif -#if (PERL_VERSION < 5) || ((PERL_VERSION == 5) && (PERL_SUBVERSION <= 5)) +#if (PERL_VERSION > 5) || ((PERL_VERSION == 5) && (PERL_SUBVERSION >= 6)) # define CAN_UTF8 1 #endif @@ -81,8 +81,6 @@ lru_hash; - /*fprintf (stderr, "F: %08lx %s\n", hash, SvPV_nolen (sql));/*D*/ - n = &lru_list; do { n = n->next; @@ -114,8 +112,6 @@ lru_list.prev = n->prev; n->prev->next = &lru_list; - /*fprintf (stderr, "N: %s\n", SvPV_nolen (n->sql));/*D*/ - SvREFCNT_dec (n->dbh); SvREFCNT_dec (n->sql); SvREFCNT_dec (n->sth); @@ -137,8 +133,6 @@ lru_hash; - /*fprintf (stderr, "S: %08lx %s\n", hash, SvPV_nolen (sql));/*D*/ - lru_size++; if (lru_size > lru_maxsize) lru_nukeone (); @@ -168,7 +162,9 @@ static GV *sql_exec; static GV *DBH; -static SV *sv_prepare, *sv_execute, *sv_bind_columns, *sv_fetchrow_arrayref, *sv_finish; +static SV *sv_prepare, *sv_execute, *sv_bind_columns, + *sv_fetchrow_arrayref, *sv_fetchall_arrayref, + *sv_finish; #define newconstpv(str) newSVpvn ((str), sizeof (str)) @@ -187,6 +183,7 @@ sv_execute = newconstpv ("execute"); sv_bind_columns = newconstpv ("bind_columns"); sv_fetchrow_arrayref = newconstpv ("fetchrow_arrayref"); + sv_fetchall_arrayref = newconstpv ("fetchall_arrayref"); sv_finish = newconstpv ("finish"); } @@ -230,7 +227,7 @@ SV *sth; SV *sql; SV *execute; - STRLEN dc; + STRLEN dc, dd; /* dummy */ /* save our arguments against destruction through function calls */ SP += items; @@ -238,13 +235,15 @@ /* first check wether we should use an explicit db handle */ if (!is_dbh (dbh)) { - dbh = get_sv ("DBH", FALSE); + /* the next line doesn't work - check why later maybe */ + /* dbh = get_sv ("DBH", FALSE); if (!is_dbh (dbh)) - { + {*/ dbh = GvSV(DBH); if (!is_dbh (dbh)) - croak ("sql_exec: no $DBH found in current package or in PApp::SQL::"); - } + croak ("sql_exec: no $DBH argument and no fallback in $PApp::SQL::DBH"); + /*croak ("sql_exec: no $DBH found in current package or in PApp::SQL::"); + }*/ } else arg++; /* we consumed one argument */ @@ -271,7 +270,7 @@ sv_catsv (neu, sql); sv_catpv (neu, " limit 1"); sql = neu; - ix -= 6; /* sql_fetch */ + ix -= 4; /* sql_fetch */ } /* check cache for existing statement handle */ @@ -289,7 +288,7 @@ if (count != 1) croak ("sql_exec: unable to prepare() statement '%s': %s", SvPV (sql, dc), - SvPV (get_sv ("DBI::errstr", TRUE), dc)); + SvPV (get_sv ("DBI::errstr", TRUE), dd)); sth = POPs; @@ -316,14 +315,14 @@ if (count != 1) croak ("sql_exec: execute() didn't return any value ('%s'): %s", SvPV (sql, dc), - SvPV (get_sv ("DBI::errstr", TRUE), dc)); + SvPV (get_sv ("DBI::errstr", TRUE), dd)); execute = POPs; if (!SvTRUE (execute)) croak ("sql_exec: unable to execute statement '%s' (%s)", SvPV (sql, dc), - SvPV (get_sv ("DBI::errstr", TRUE), dc)); + SvPV (get_sv ("DBI::errstr", TRUE), dd)); sv_setsv (GvSV(sql_exec), execute); @@ -344,12 +343,12 @@ if (count != 1) croak ("sql_exec: bind_columns() didn't return any value ('%s'): %s", SvPV (sql, dc), - SvPV (get_sv ("DBI::errstr", TRUE), dc)); + SvPV (get_sv ("DBI::errstr", TRUE), dd)); if (!SvOK (POPs)) croak ("sql_exec: bind_columns() didn't return a true ('%s'): %s", SvPV (sql, dc), - SvPV (get_sv ("DBI::errstr", TRUE), dc)); + SvPV (get_sv ("DBI::errstr", TRUE), dd)); } /* free our arguments from the stack */ @@ -403,7 +402,7 @@ PUSHMARK (SP); XPUSHs (sth); PUTBACK; - count = call_sv (sv_fetchrow_arrayref, G_METHOD | G_SCALAR); + count = call_sv (sv_fetchall_arrayref, G_METHOD | G_SCALAR); SPAGAIN; if (count != 1) @@ -418,7 +417,7 @@ if (count) { - int columns = AvFILL ((AV *)SvRV (AvARRAY(av)[0])) + 1; /* columns? */ + int columns = AvFILL ((AV *) SvRV (AvARRAY (av)[0])) + 1; /* columns? */ EXTEND (SP, count); if (columns == 1)