Seems that the compiled-in default character set of your libmysqlclient
is latin1 instead of utf8. Actually, what done by the SET NAMES query is
to change the client character set to another.

-- 
UEMURA (fka. MAENAKA) Tetsuya <[EMAIL PROTECTED]>

Posted on Wed, 28 Nov 2007 10:43:10 +0100
by author bugtrack <[EMAIL PROTECTED]>
> http://www.dbmail.org/mantis/view.php?id=655 
> ---------------------------------------------------------------------- 
>  maenaka - 28-Nov-07 01:40  
> ---------------------------------------------------------------------- 
> MySQL's automatic reconnection is unsafe because of the following reason.
> 
> First, SET NAMES query is a required arbitration between server and client
> if both's character encoding is different. This should be done at the time
> of connection open. (Of course you can issue SET NAMES between every query
> with the huge overhead though.)
> 
> By the way, MySQL's automatic reconnection is made transparent to the
> client. So the client never know that SET NAMES should be issued again.
> 
> Therefore, if the connection is restored this way, the character encoding
> mismatch may occur (and some or all data is garbled or lost). 
> 
> ---------------------------------------------------------------------- 
>  idk - 28-Nov-07 10:43  
> ---------------------------------------------------------------------- 
> You are right, but...
> 
> I have both client and server in the same charset (database, tables and
> fields too), I don't know why SET NAMES latin1 (and not utf8) is sent in
> the background (transparent for client) after auto reconnection is made
> and before last (failed) query is repeated, but this issue exposes
> transparent (for client) auto reconnection problem.
> 
> Though recommended solution is not transparent for client, but for all
> database calls is. The solution is sufficient for single queries (as
> SELECT NOW()), there is no need to know that reconnection was made. But
> all transactions and sequent queries (as SELECT LAST_INSERT_ID()) are at
> risk from data inconsistency, as I wrote above.
> 
> For me, if I don't restart MySQL server in middle of the transaction and
> every quasi auto reconnection (invoked after unsuccessful ping incl. SET
> NAMES utf8) is caused by connection idle timeout (so not in time of
> usage), this issue (charset mismatch) will be solved.
> 
> Yeasterday, I have removed reconnection setting out and append TRACE
> message when ping miss. Now I'll wait for some days when issue will
> happen. 

_______________________________________________
Dbmail-dev mailing list
Dbmail-dev@dbmail.org
http://twister.fastxs.net/mailman/listinfo/dbmail-dev

Reply via email to