--- PApp-SQL/SQL.xs 2002/06/26 03:26:39 1.13 +++ PApp-SQL/SQL.xs 2004/01/28 19:50:38 1.16 @@ -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++; } @@ -332,6 +339,10 @@ EXTEND (SP, bind_last - bind_first + 2); PUSHs (sth); do { +#if CAN_UTF8 + if(ix & 1) + SvUTF8_on(SvRV(ST(bind_first))); +#endif PUSHs (ST(bind_first)); bind_first++; } while (bind_first != bind_last);