pike.git / lib / modules / Sql.pmod / mysql.pike

version» Context lines:

pike.git/lib/modules/Sql.pmod/mysql.pike:1:   /* -  * $Id: mysql.pike,v 1.23 2006/08/15 14:51:28 grubba Exp $ +  * $Id: mysql.pike,v 1.24 2006/08/22 11:24:16 grubba Exp $    *    * Glue for the Mysql-module    */      //! Implements the glue needed to access the Mysql-module from the generic   //! SQL module.      #pike __REAL_VERSION__      #if constant(Mysql.mysql)
pike.git/lib/modules/Sql.pmod/mysql.pike:542:   Mysql.mysql_result big_query (string query,    mapping(string|int:mixed)|void bindings,    void|string charset)   {    if (bindings)    query = .sql_util.emulate_bindings(query,bindings,this);       string restore_charset;    if (charset) {    restore_charset = send_charset || get_charset(); -  if (charset != restore_charset) +  if (charset != restore_charset) {    ::big_query ("SET character_set_client=" + charset); -  else +  ::big_query ("SET character_set_connection=" + charset); +  } else    restore_charset = 0;    }       else if (send_charset) {    string new_send_charset;       if (utf8_mode & LATIN1_UNICODE_ENCODE_MODE) {    if (String.width (query) == 8)    new_send_charset = "latin1";    else {
pike.git/lib/modules/Sql.pmod/mysql.pike:571:    if (_can_send_as_latin1 (query))    new_send_charset = "latin1";    else {    query = utf8_encode_query (query, string_to_utf8);    new_send_charset = "utf8";    }    }       if (new_send_charset != send_charset) {    mixed err; -  if (err = ::big_query("SET character_set_client=" + new_send_charset)) { +  if (err = catch { +  ::big_query("SET character_set_client=" + new_send_charset); +  ::big_query("SET character_set_connection=" + new_send_charset); +  }) {    if (new_send_charset == "utf8")    predef::error ("The query is a wide string "    "and the MySQL server doesn't support UTF-8: %s\n",    describe_error (err));    throw(err);    }    send_charset = new_send_charset;    }    }       int|object res = ::big_query(query);       if (restore_charset) {    if (send_charset && (<"latin1", "utf8">)[charset])    send_charset = charset; -  else +  else {    ::big_query("SET character_set_client=" + restore_charset); -  +  ::big_query("SET character_set_connection=" + restore_charset);    } -  +  }       if (!objectp(res)) return res;       if (utf8_mode & UNICODE_DECODE_MODE) {    return .sql_util.UnicodeWrapper(res);    }    return res;   }      int(0..1) is_keyword( string name )