planner r877 - in trunk: . libplanner src



Author: mvdpot
Date: Sat Feb  2 00:54:47 2008
New Revision: 877
URL: http://svn.gnome.org/viewvc/planner?rev=877&view=rev

Log:
2008-02-02  Maurice van der Pot  <griffon26 kfk4ever com>

	* libplanner/mrp-sql.c: (mrp_sql_load_project),
	(mrp_sql_save_project):
	* src/planner-sql-plugin.c: (sql_get_tested_connection):
	Now setting time zone to UTC in all connections to the database, otherwise
	the database will assume date fields are in local time and mess up the
	conversion to seconds since epoch. This caused a shift in project_start each
	time a project was read from the database.



Modified:
   trunk/ChangeLog
   trunk/libplanner/mrp-sql.c
   trunk/src/planner-sql-plugin.c

Modified: trunk/libplanner/mrp-sql.c
==============================================================================
--- trunk/libplanner/mrp-sql.c	(original)
+++ trunk/libplanner/mrp-sql.c	Sat Feb  2 00:54:47 2008
@@ -2221,6 +2221,15 @@
 		goto out;
 	}
 
+	res = sql_execute_query (data->con, "SET TIME ZONE UTC"); 
+	if (res == NULL) {
+		g_warning ("SET TIME ZONE command failed: %s.",
+				sql_get_last_error (data->con));
+		goto out;
+	}
+	g_object_unref (res);
+	res = NULL;
+
 	res = sql_execute_query (data->con, "BEGIN");
 	if (res == NULL) {
 		g_warning (_("BEGIN command failed %s."),
@@ -3659,9 +3668,9 @@
 	client = gda_client_new ();
 
 #ifdef HAVE_GDA2
-       	data->con = gda_client_open_connection (client, dsn_name, NULL, NULL, 0, error);
+	data->con = gda_client_open_connection (client, dsn_name, NULL, NULL, 0, error);
 #else
-       	data->con = gda_client_open_connection (client, dsn_name, NULL, NULL, 0);
+	data->con = gda_client_open_connection (client, dsn_name, NULL, NULL, 0);
 #endif
 	
 	data->revision = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (data->project), 
@@ -3675,6 +3684,16 @@
 		goto out;
 	}
 
+	res = sql_execute_query (data->con, "SET TIME ZONE UTC"); 
+
+	if (res == NULL) {
+		g_warning ("SET TIME ZONE command failed: %s.",
+				sql_get_last_error (data->con));
+		goto out;
+	}
+	g_object_unref (res);
+	res = NULL;
+
 	res = sql_execute_query (data->con, "BEGIN");
 
 	if (res == NULL) {

Modified: trunk/src/planner-sql-plugin.c
==============================================================================
--- trunk/src/planner-sql-plugin.c	(original)
+++ trunk/src/planner-sql-plugin.c	Sat Feb  2 00:54:47 2008
@@ -679,7 +679,8 @@
 			   GdaClient     *client,
 			   PlannerPlugin *plugin) 
 {
-	GdaConnection *conn;
+	GdaConnection *conn = NULL;
+	GdaDataModel  *res = NULL;
 	gchar         *str;
 #ifdef HAVE_GDA2
 	GError        *error;
@@ -707,18 +708,38 @@
 	}
 
 	if (conn != NULL) {
+
+		res = sql_execute_query (conn, "SET TIME ZONE UTC"); 
+		if (res == NULL) {
+			g_warning ("SET TIME ZONE command failed: %s.",
+					sql_get_last_error (conn));
+			goto out;
+		}
+		g_object_unref (res);
+		res = NULL;
+
 		if (!check_database_tables (conn, plugin)) {		
 			str = g_strdup_printf (_("Test to tables in database '%s' failed."), 
 					       db_name);
 			show_error_dialog (plugin, str);
 			g_free (str);
-			gda_connection_close (conn);
-			conn = NULL;	
+			goto out;
 		}
 	}
 
 	/* g_object_unref (client); */
 	return conn;
+
+out:
+	if (res) {
+		g_object_unref (res);
+	}
+
+	if (conn) {
+		gda_connection_close (conn);
+	}
+
+	return NULL;
 }
 
 /**



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]