Skip to content

libgda: Fix h/m/s calculation of gda_parse_formatted_timestamp()

My database was:

$ createdb testdb
$ psql testdb
psql=> CREATE TABLE table_1 (t timestamp with time zone);
psql=> INSERT INTO table_1 VALUES ('2004-08-29 02:00:00+02');
psql=> INSERT INTO table_1 VALUES ('2004-08-30');
psql=> SELECT * FROM table_1;
        t
------------------------
2004-08-29 02:00:00+02
2004-08-30 00:00:00+02
(2 rows)

I tried to read the database with libgda.

cnc = gda_connection_open_from_string ("PostgreSQL", cnc_str, auth_str, options, &error);
parser = gda_connection_create_parser (cnc);
sql = "SELECT t FROM table_1;";
stmt = gda_sql_parser_parse_string (parser, sql, NULL, error);
model = gda_connection_statement_execute_select (cnc, stmt, NULL, error);
for (int i = 0; i < gda_data_model_get_n_rows (model); i++)
  {
    value = gda_data_model_get_value_at (model, 0, i, error);
  }

And I got:

ERROR: Invalid timestamp value '2004-08-29 02:00:00+02'

Merge request reports