--- PApp-SQL/SQL.xs 2002/06/26 03:26:39 1.13 +++ PApp-SQL/SQL.xs 2002/11/07 01:57:58 1.15 @@ -12,6 +12,8 @@ # define CAN_UTF8 1 #endif +#define MAX_CACHED_STATEMENT_SIZE 8192 + static SV * sql_upgrade_utf8 (SV *sv) { @@ -292,7 +294,8 @@ sth = POPs; - lru_store (dbh, sql, sth); + if (SvLEN (sql) < MAX_CACHED_STATEMENT_SIZE) + lru_store (dbh, sql, sth); } PUSHMARK (SP); @@ -300,7 +303,11 @@ PUSHs (sth); while (items > arg) { - PUSHs (maybe_upgrade_utf8 (ix & 1, ST(arg))); + SV *sv = ST(arg); + /* we sv_mortalcopy magical values since DBI seems to have a memory + * leak when magical values are passed into execute(). + */ + PUSHs (maybe_upgrade_utf8 (ix & 1, SvMAGICAL(sv) ? sv_mortalcopy(sv) : sv)); arg++; }