/* Convert a simple string representation of a value into a more specific * perl type based on an sql_type value. * The semantics of SQL standard TYPE values are interpreted _very_ loosely * on the basis of "be liberal in what you accept and let's throw in some * extra semantics while we're here" :) * Returns: * -2: sql_type isn't handled, value unchanged * -1: sv is undef, value unchanged * 0: sv couldn't be cast cleanly and DBIstcf_STRICT was used * 1: sv couldn't be cast cleanly and DBIstcf_STRICT was not used * 2: sv was cast ok */ int sql_type_cast_svpv(pTHX_ SV *sv, int sql_type, U32 flags, void *v) { int cast_ok = 0; switch(sql_type) { default: return -2; /* not a recognised SQL TYPE, value unchanged */ case SQL_DOUBLE: { /* mje - I don't understand why sv_2nv returns 0 in the following when sv is "aa" */ sv_2nv(sv); /* SvNOK should be set but won't if sv is not numeric (in which * case perl would have warn'd already if -w or warnings are in effect) */ /* mje it is true perl warns if sv is "aa" and warnings enabled so it knew it was not a number so why is cast_ok = 512 */ cast_ok = SvNOK(sv); break; } } if (cast_ok) return 2; /* mje always getting here but wanted 0 or 1 depending on DBIstcf_STRICT */ else if (flags & DBIstcf_STRICT) return 0; else return 1; }