|
|
Choosing A Webhost: |
CVS update of libmysequoia/src (CarobMySQL.cpp MySQLAPI.cpp): msg#00175db.carob.cvs
Date: Thursday, January 26, 2006 @ 11:21:04 Author: csaba Path: /cvsroot/carob/libmysequoia/src Modified: CarobMySQL.cpp (1.35 -> 1.36) MySQLAPI.cpp (1.32 -> 1.33) Set the character set. ----------------+ CarobMySQL.cpp | 64 ++++++++++++++++++++++++++++++++++++++----------------- MySQLAPI.cpp | 3 -- 2 files changed, 46 insertions(+), 21 deletions(-) Index: libmysequoia/src/CarobMySQL.cpp diff -u libmysequoia/src/CarobMySQL.cpp:1.35 libmysequoia/src/CarobMySQL.cpp:1.36 --- libmysequoia/src/CarobMySQL.cpp:1.35 Wed Jan 25 11:58:42 2006 +++ libmysequoia/src/CarobMySQL.cpp Thu Jan 26 11:21:04 2006 @@ -49,6 +49,9 @@ mysql->protocol_version = PROTOCOL_VERSION; // TODO fill in other required mysql fields + // force reading the my.cnf file + mysql->options.my_cnf_group = cstrdup("client"); + mysqlPtr = mysql; LOG4CXX_DEBUG(logger, "Leaving constructor."); @@ -67,12 +70,14 @@ FREE_AND_NULL_ARRAY(mysqlPtr->host_info); FREE_AND_NULL_ARRAY(mysqlPtr->info); - FREE_AND_NULL(mysqlPtr->options.my_cnf_file); - FREE_AND_NULL(mysqlPtr->options.my_cnf_group); - FREE_AND_NULL(mysqlPtr->options.host); - FREE_AND_NULL(mysqlPtr->options.user); - FREE_AND_NULL(mysqlPtr->options.password); - FREE_AND_NULL(mysqlPtr->options.db); + FREE_AND_NULL_ARRAY(mysqlPtr->options.my_cnf_file); + FREE_AND_NULL_ARRAY(mysqlPtr->options.my_cnf_group); + FREE_AND_NULL_ARRAY(mysqlPtr->options.host); + FREE_AND_NULL_ARRAY(mysqlPtr->options.user); + FREE_AND_NULL_ARRAY(mysqlPtr->options.password); + FREE_AND_NULL_ARRAY(mysqlPtr->options.db); + FREE_AND_NULL_ARRAY(mysqlPtr->options.charset_name); + FREE_AND_NULL_ARRAY(mysqlPtr->options.charset_dir); mysqlPtr->options.port = 0; mysqlPtr->field_alloc.used = 0; @@ -98,8 +103,8 @@ if (mysqlPtr->options.my_cnf_file || mysqlPtr->options.my_cnf_group) { read_ini_file(); - FREE_AND_NULL(mysqlPtr->options.my_cnf_file); - FREE_AND_NULL(mysqlPtr->options.my_cnf_group); + FREE_AND_NULL_ARRAY(mysqlPtr->options.my_cnf_file); + FREE_AND_NULL_ARRAY(mysqlPtr->options.my_cnf_group); } if (unix_socket) @@ -142,6 +147,10 @@ port = 25322; } + /* set the default character set if not set */ + if (!mysqlPtr->options.charset_name) + mysqlPtr->options.charset_name = cstrdup("latin1"); + /* Check for delayed connection. If db name not given, the connection can't happen, because sequoia doesn't support it. * The real connection will happen after the user call the command mysql_select_db or mysql_real_connect */ if (!db || !*db) @@ -825,13 +834,12 @@ LOG4CXX_DEBUG(logger, "Leaving delete_row_data."); } - void CarobMYSQL::read_ini_file() { char *group; - string def_home_env = string(getenv("DEFAULT_HOME_ENV")) + "/my.cnf"; - string home_dir = string(getenv("HOME")) + "/.my.cnf"; + char *def_home_env = getenv("DEFAULT_HOME_ENV"); + char *home_dir = getenv("HOME"); IniParser ini; /* @@ -844,21 +852,39 @@ */ ini.parseFile("/etc/my.cnf"); - ini.parseFile(def_home_env.c_str()); + if (def_home_env) + { + string s = string(def_home_env) + "/my.cnf"; + ini.parseFile(s.c_str()); + } ini.parseFile("my.cnf"); - ini.parseFile(home_dir.c_str()); - ini.parseFile(mysqlPtr->options.my_cnf_file); + if (home_dir) + { + string s = string(home_dir) + "/.my.cnf"; + ini.parseFile(s.c_str()); + } + if (mysqlPtr->options.my_cnf_file) + ini.parseFile(mysqlPtr->options.my_cnf_file); if (mysqlPtr->options.my_cnf_group && *mysqlPtr->options.my_cnf_group) group = mysqlPtr->options.my_cnf_group; else group = "client"; - mysqlPtr->options.host = cstrdup(ini.get(group, "host").c_str()); - mysqlPtr->options.user = cstrdup(ini.get(group, "user").c_str()); - mysqlPtr->options.password = cstrdup(ini.get(group, "password").c_str()); - mysqlPtr->options.db = cstrdup(ini.get(group, "db").c_str()); + /* + * read the host, user, password, db, default-character-set, character-sets-dir, port + * from the config file + */ + cstrdupcond(mysqlPtr->options.host, ini.get(group, "host").c_str()); + cstrdupcond(mysqlPtr->options.user, ini.get(group, "user").c_str()); + cstrdupcond(mysqlPtr->options.password, ini.get(group, "password").c_str()); + cstrdupcond(mysqlPtr->options.db, ini.get(group, "db").c_str()); mysqlPtr->options.port = atoi(ini.get(group, "port").c_str()); - + if (!mysqlPtr->options.charset_name || !*mysqlPtr->options.charset_name) + cstrdupcond(mysqlPtr->options.charset_name, ini.get(group, "default-character-set").c_str()); + if (!mysqlPtr->options.charset_dir || !*mysqlPtr->options.charset_dir) + cstrdupcond(mysqlPtr->options.charset_dir, ini.get(group, "character-sets-dir").c_str()); + + /* read the init_command from the config file */ push_init_command(ini.get(group, "init_command").c_str()); } Index: libmysequoia/src/MySQLAPI.cpp diff -u libmysequoia/src/MySQLAPI.cpp:1.32 libmysequoia/src/MySQLAPI.cpp:1.33 --- libmysequoia/src/MySQLAPI.cpp:1.32 Wed Jan 25 09:46:23 2006 +++ libmysequoia/src/MySQLAPI.cpp Thu Jan 26 11:21:04 2006 @@ -838,8 +838,7 @@ { LOG4CXX_DEBUG(logger, "Entering mysql_character_set_name: mysql=" << mysql); - // TODO implementation - char *result = 0; + char *result = mysql->options.charset_name; LOG4CXX_DEBUG(logger, "Leaving mysql_character_set_name: result=" << result); return result;
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS update of carob/test/40-Parameter-PreparedStatement (1 file), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of carob/test (GNUmakefile), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of carob/include (JavaSocket.hpp), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Next by Thread: | CVS update of carob/test (GNUmakefile), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home
| advertise | OSDir is
an inevitable website.
|