Commit d680b18c authored by Maurice van der Pot's avatar Maurice van der Pot Committed by Maurice van der Pot

Now setting time zone to UTC in all connections to the database, otherwise

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.


svn path=/trunk/; revision=877
parent e4d85122
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.
2008-01-29 Kurt Maute <kurt@maute.us>
Patch to correct distcheck error, courtesy of Gilles Dartiguelongue
(bug #464359)
......
......@@ -2221,6 +2221,15 @@ mrp_sql_load_project (MrpStorageSQL *storage,
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 @@ mrp_sql_save_project (MrpStorageSQL *storage,
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 @@ mrp_sql_save_project (MrpStorageSQL *storage,
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) {
......
......@@ -679,7 +679,8 @@ sql_get_tested_connection (const gchar *dsn_name,
GdaClient *client,
PlannerPlugin *plugin)
{
GdaConnection *conn;
GdaConnection *conn = NULL;
GdaDataModel *res = NULL;
gchar *str;
#ifdef HAVE_GDA2
GError *error;
......@@ -707,18 +708,38 @@ sql_get_tested_connection (const gchar *dsn_name,
}
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;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment