Date: Tuesday, January 24, 2006 @ 15:47:47
Author: csaba
Path: /cvsroot/carob/libmysequoia
Modified: include/CarobMySQL.hpp (1.20 -> 1.21) src/CarobMySQL.cpp (1.32
-> 1.33)
In mysql_real_connect() read the default options from the my.cnf ini file.
------------------------+
include/CarobMySQL.hpp | 5 +++
src/CarobMySQL.cpp | 69 +++++++++++++++++++++++++++++++++++++----------
2 files changed, 60 insertions(+), 14 deletions(-)
Index: libmysequoia/include/CarobMySQL.hpp
diff -u libmysequoia/include/CarobMySQL.hpp:1.20
libmysequoia/include/CarobMySQL.hpp:1.21
--- libmysequoia/include/CarobMySQL.hpp:1.20 Wed Jan 11 11:25:37 2006
+++ libmysequoia/include/CarobMySQL.hpp Tue Jan 24 15:47:47 2006
@@ -266,6 +266,11 @@
* @param field_count number of fields in the row
*/
static void delete_row_data (MYSQL_ROW & row, const unsigned int
field_count);
+
+ /**
+ * Read the MySQL ini file.
+ */
+ void read_ini_file();
};
#endif /* _CAROBMYSQL_HPP */
Index: libmysequoia/src/CarobMySQL.cpp
diff -u libmysequoia/src/CarobMySQL.cpp:1.32
libmysequoia/src/CarobMySQL.cpp:1.33
--- libmysequoia/src/CarobMySQL.cpp:1.32 Thu Jan 19 15:37:21 2006
+++ libmysequoia/src/CarobMySQL.cpp Tue Jan 24 15:47:47 2006
@@ -40,7 +40,7 @@
mysql->field_alloc.block_size = MYSEQUOIA_MAGIC;
mysql->free_me = free_me;
//TODO maybe a real server version string ???
- mysql->server_version = "50015";
+ mysql->server_version = "50018";
mysql->protocol_version = PROTOCOL_VERSION;
// TODO fill in other required mysql fields
@@ -61,7 +61,15 @@
FREE_AND_NULL_ARRAY(mysqlPtr->db);
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);
+ mysqlPtr->options.port = 0;
+
mysqlPtr->field_alloc.used = 0;
mysqlPtr->extra_info = 0;
@@ -82,6 +90,13 @@
return false;
}
+ 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);
+ }
+
if (unix_socket)
{
set_error(CR_NOT_IMPLEMENTED, SQLT_UNKNOWN);
@@ -92,29 +107,49 @@
/* Must supply at least a user name, or connection to sequoia will fail */
if (!user || !*user)
{
- set_error(CR_NULL_POINTER, SQLT_UNKNOWN);
- LOG4CXX_DEBUG(logger, "Leaving connect.");
- return false;
+ user = mysqlPtr->options.user;
+ if (!user || !*user)
+ {
+ set_error(CR_NULL_POINTER, SQLT_UNKNOWN);
+ LOG4CXX_DEBUG(logger, "Leaving connect.");
+ return false;
+ }
}
if (!host || !*host)
- host = "localhost";
-
+ {
+ host = mysqlPtr->options.host;
+ if (!host || !*host)
+ host = "localhost";
+ }
+
if (!passwd)
- passwd = "";
+ {
+ passwd = mysqlPtr->options.password;
+ if (!passwd)
+ passwd = "";
+ }
if (!port)
- port = 25322;
+ {
+ port = mysqlPtr->options.port;
+ if (!port)
+ port = 25322;
+ }
/* 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)
{
- delete_connection();
- set_connect_info(host, user, passwd, 0, port);
-
- LOG4CXX_DEBUG(logger, "Leaving connect.");
- return true;
+ db = mysqlPtr->options.db;
+ if (!db || !*db)
+ {
+ delete_connection();
+ set_connect_info(host, user, passwd, 0, port);
+
+ LOG4CXX_DEBUG(logger, "Leaving connect (delayed connection.)");
+ return true;
+ }
}
try
@@ -771,3 +806,9 @@
LOG4CXX_DEBUG(logger, "Leaving delete_row_data.");
}
+
+void
+CarobMYSQL::read_ini_file()
+{
+ // TODO implementation
+}
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits