Skip to content
Snippets Groups Projects
Select Git revision
  • 38079b035f0da1e69181fe764a41f98fa2cae5c5
  • master default protected
  • 9.0
  • 8.0
  • nt-tools
  • 7.8
  • 7.6
  • 7.4
  • 7.2
  • 7.0
  • 0.6
  • rosuav/latex-markdown-renderer
  • rxnpatch/rxnpatch
  • marcus/gobject-introspection
  • rxnpatch/8.0
  • rosuav/pre-listening-ports
  • rosuav/async-annotations
  • rosuav/pgsql-ssl
  • rxnpatch/rxnpatch-broken/2023-10-06T094250
  • grubba/fdlib
  • grubba/wip/sakura/8.0
  • v8.0.2020
  • v8.0.2018
  • v8.0.2016
  • v8.0.2014
  • v8.0.2012
  • v8.0.2008
  • v8.0.2006
  • v8.0.2004
  • v8.0.2002
  • v8.0.2000
  • v8.0.1998
  • v8.0.1996
  • v8.0.1994
  • v8.0.1992
  • v8.0.1990
  • v8.0.1988
  • v8.0.1986
  • rxnpatch/clusters/8.0/2025-04-29T124414
  • rxnpatch/2025-04-29T124414
  • v8.0.1984
41 results

mysql.pike

Blame
  • mysql.pike 32.06 KiB
    /*
     * $Id$
     *
     * Glue for the Mysql-module
     */
    
    //! Implements the glue needed to access the Mysql-module from the generic
    //! SQL module.
    
    #pike __REAL_VERSION__
    
    // Cannot dump this since the #if constant(...) check below may depend
    // on the presence of system libs at runtime.
    constant dont_dump_program = 1;
    
    #if constant(Mysql.mysql)
    
    inherit Mysql.mysql;
    
    #define UNICODE_DECODE_MODE	1 // Unicode decode mode
    #define LATIN1_UNICODE_ENCODE_MODE 2 // Unicode encode mode with latin1 charset
    #define UTF8_UNICODE_ENCODE_MODE 4 // Unicode encode mode with utf8 charset
    
    #ifdef MYSQL_CHARSET_DEBUG
    #define CH_DEBUG(X...)	werror("Sql.mysql: " + X)
    #else
    #define CH_DEBUG(X...)
    #endif
    
    #if !constant (Mysql.mysql.HAVE_MYSQL_FIELD_CHARSETNR)
    // Recognition constant to tell that the unicode decode mode would use
    // the buggy MySQLBrokenUnicodeWrapper if it would be enabled through
    // any of the undocumented methods.
    constant unicode_decode_mode_is_broken = 1;
    #endif
    
    // Set to the above if the connection is requested to be in one of the
    // unicode modes. latin1 unicode encode mode is enabled by default; it
    // should be compatible with earlier pike versions.
    protected int utf8_mode;
    
    // The charset, either "latin1" or "utf8", currently assigned to
    // character_set_client when unicode encode mode is enabled. Zero when
    // the connection charset has been set to something else than "latin1"
    // or "unicode".
    protected string send_charset;
    
    protected void update_unicode_encode_mode_from_charset (string charset)
    {
      switch (charset) {		// Lowercase assumed.
        case "latin1":
          utf8_mode |= LATIN1_UNICODE_ENCODE_MODE;
          utf8_mode &= ~UTF8_UNICODE_ENCODE_MODE;
          send_charset = "latin1";
          CH_DEBUG ("Entering latin1 encode mode.\n");
          break;
        case "unicode":
          utf8_mode |= UTF8_UNICODE_ENCODE_MODE;
          utf8_mode &= ~LATIN1_UNICODE_ENCODE_MODE;
          send_charset = "utf8";
          CH_DEBUG ("Entering unicode encode mode.\n");
          break;
        default:
          // Wrong charset - the mode can't be used.
          utf8_mode |= LATIN1_UNICODE_ENCODE_MODE|UTF8_UNICODE_ENCODE_MODE;
          send_charset = 0;
          CH_DEBUG ("Not entering latin1/unicode encode mode "
    		"due to incompatible charset %O.\n", charset);
          break;
      }