On Wed, Mar 19, 2003 at 09:14:06AM -0500, Rudy Lippan wrote: > 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... :-)
It's obviously one of those days! I won't say it's attached this time. That way if it is, it'll just be a pleasant surprise :) > > > 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 :) Sure. But I'm arguing the case for the defence at the moment :) For applications that don't hold locks, reliable auto-reconnect is good. > The other options is to do a looks like a number and then bind off of the > IV/NV ? Thoughts, suggestions? [If SvNIOK && SvNV!=0 then it's a number. If SvNV=0 then you need to disambiguate further using looks_like_number(). If looks_like_number() is true then treat as number and use SvNV to get the value. If looks_like_number is false then treat as string.] But whichever way you slice it there's a risk of it ending up wrong as some things that should be treated as strings may just happen to *look* like numbers. It's probably best to be simple and consistent by treating as varchar unless the user has used bind_param to set a type. > > > @@ -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. Sure, still could do with a better name though :) > > > @@ -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)) That's a good idea. I might even add a macro to DBIXS.h for that. > > > + { > > > + /*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. SvTRUE will invoke magic. Tim.