On Wed, 19 Mar 2003, Tim Bunce wrote:
> >
> > Can you resend? I did not seem to get the attachment?
>
> Oops, forgot. Attached. I've tweaked it slightly to use quote_identifier(),
> which I'm presuming you're supporting (probably via adding get_info() data).
>
> Some of the CHAR_SET_* and COLLATION_* fields could possibly be
> added for mysql v4.1.
>
Um, Tim... :-)
> > I try to make my code robust against such things; I ping the db and
> > reconnect if needed.
>
> Doing it in the driver for all server interactions is a more 'robust'
> approach as it's impractical to do so it completely in the application.
>
It depends on your aim. From my POV, if the db restarts within the scope
of a request, there should be an error thrown because my application
might be using locked tables or transactions, but that is why you wanted
the attribute, right :)
> By forcing all to SQL_VARCHAR. That's worth noting in the docs
> because (I think) some mysql SQL expressions/functions behave
> differently if given a number or a string.
>
Yes it should be documented either way, because (if what you say is
true) currently,
$foo = 12;
$foo = "12";
would behave differently, so an application could make the same query
twice and get different results.
The other options is to do a looks like a number and then bind off of the
IV/NV ? Thoughts, suggestions?
> > @@ -1047,11 +1056,11 @@
> > char *key = SvPV(keysv, kl);
> > SV *cachesv = Nullsv;
> > int cacheit = FALSE;
> > + bool newval = SvTRUE(valuesv);
>
> newval doesn't seem like a good name for this. bool_value perhaps.
That was in there, I just moved the line out of the if block so newval
could be used by both AutoCommit & mysqL_auto_reconnect.
>
> > @@ -1091,6 +1100,12 @@
> > + } else if (strlen("mysql_auto_reconnect")
> > + == kl && strEQ(key,"mysql_auto_reconnect") )
>
> Are you presuming the compiler will optimize strlen("mysql_auto_reconnect")
> at compile time? I'd use kl==20 instead.
>
I was hoping :) I am bad at counting, so I thought I would make it a
little simpler on myself, besides how long does a strlen("") take on
something that is not used very often? How about using
sizeof("mysql_auto_reconnect")-1 so the I can do something akin to:
#define getthingey(a) ((sizeof(a)-1) == kl && strEQ(key,a))
Which is where I was going in the first place -- Forgetting to change the
constant has bitten me a number of times :)
> > + {
> > + /*XXX: Does DBI handle the magic ? */
> > + imp_dbh->auto_reconnect = newval;
>
> What magic, specifically?
>
not there exactly, but up where the SvTRUE is. What happens if the
variable is tied? I did not think it very important at this time -- I
just wanted to note it as something to look into.
> > @@ -1157,6 +1172,10 @@
> > }
> >
> > switch(*key) {
> > + case 'a':
> > + if (kl == strlen("auto_reconnect") && strEQ(key, "auto_reconnect"))
> > + result = sv_2mortal(newSViv(imp_dbh->auto_reconnect));
> > + break;
>
> Should have mysql_ prefix.
>
It does, above (not in patch) the case statement there is a
if (strncmp(key, "mysql_", 6) == 0) {
fine_key = key;
key = key+6;
kl = kl-6;
}
Rudy