mysql - What is the purpose of character_set_connection? -


just read stefan gehrig excellent answer is "set character set utf8" necessary?, goes bit further mysql's documentation @ explaining stages of interpretting , running query w.r.t. character sets , collations, still can't see purpose of character_set_connection, or more transcoding statement character_set_client character_set_connection.

why not use character_set_client query , transcode straight character_set_client character set of column when comparing column values? purpose of intermediate stage? manual gives example of comparing literal stings, why want in first place, let alone in character_set_connection oppose character_set_client? unless understanding of (something "select 'somestr' = 'somestr' x") wrong.

thank you.

after reading answers , documentation, can think of 1 use case character_set_connection (and _collation):

select "stringa" < "stringb"

character_set_client matters transfer server. character_set_connection (and collation, not independent character set) matters interpretation of statement. whether "stringa" less "stringb" depends on character set , collation of literals. developer might choose character set/collation differs character_set_client.

in practice, character_set_connection won't matter of time, because literals compared columns, in case column's charset , collation used.

correct me if i'm wrong!

see https://dev.mysql.com/doc/refman/5.0/en/charset-connection.html:

what character set should server translate statement after receiving it? this, server uses character_set_connection , collation_connection system variables. converts statements sent client character_set_client character_set_connection (except string literals have introducer such _latin1 or _utf8). collation_connection important comparisons of literal strings. comparisons of strings column values, collation_connection not matter because columns have own collation, has higher collation precedence.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -