[gnome-db] New patch for postgres. Constness. Time, Timestamp, Date.
- From: Gonzalo Paniagua Javier <gonzalo gnome-db org>
- To: Gnome-db list <gnome-db-list gnome org>
- Subject: [gnome-db] New patch for postgres. Constness. Time, Timestamp, Date.
- Date: Wed, 9 Jan 2002 02:34:48 +0100
Hi all!
Well, here is another patch. This one fixes my TODO list in the
postgres provider and adds specific test for postgres in gda-test.
Some questions have arised:
-What should the provider do in execute_command() when
one of the command of a ';' separated list have failed?
Should free the already allocated recordsets and return
NULL to show that something failed? Add an error and
continue processing the list of commands?
-Now about the constness: do you think that *get* should
return const and *set* should receive a const argument?
Or should we just say what returned values shouldn't be
modified and return non-const?
Now in my TODO list:
-modify the IDL to add 'timezone' to time and timestamp.
-modify libgda/_whatever_ to make use of the Time, Date
and Timestamp defined in the IDL.
Bye!
Index: libgda/ChangeLog
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/libgda/ChangeLog,v
retrieving revision 1.61
diff -u -r1.61 ChangeLog
--- libgda/ChangeLog 8 Jan 2002 21:51:30 -0000 1.61
+++ libgda/ChangeLog 9 Jan 2002 01:22:26 -0000
@@ -1,3 +1,12 @@
+2002-01-08 Gonzalo Paniagua Javier <gonzalo gnome-db org>
+
+ * gda-row.h: define GdaType as an enumeration.
+
+ * gda-row.[ch]: stringify receives a const argument.
+
+ * gda-value.[ch]: stringify receives a const argument. So does
+ gda_value_isa(). We should talk about constness in the list.
+
2002-01-08 Rodrigo Moya <rodrigo gnome-db org>
* gda-value.[ch] (gda_value_is_null): new function
Index: libgda/gda-row.c
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/libgda/gda-row.c,v
retrieving revision 1.10
diff -u -r1.10 gda-row.c
--- libgda/gda-row.c 8 Jan 2002 21:51:30 -0000 1.10
+++ libgda/gda-row.c 9 Jan 2002 01:10:23 -0000
@@ -664,7 +664,7 @@
* gda_field_stringify
*/
gchar *
-gda_field_stringify (GdaField *field)
+gda_field_stringify (const GdaField *field)
{
g_return_val_if_fail (field != NULL, NULL);
return gda_value_stringify (&field->value);
Index: libgda/gda-row.h
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/libgda/gda-row.h,v
retrieving revision 1.6
diff -u -r1.6 gda-row.h
--- libgda/gda-row.h 4 Jan 2002 01:57:18 -0000 1.6
+++ libgda/gda-row.h 9 Jan 2002 01:10:39 -0000
@@ -33,24 +33,26 @@
typedef GNOME_Database_Row GdaRow;
typedef GNOME_Database_RowAttributes GdaRowAttributes;
typedef GNOME_Database_FieldAttributes GdaFieldAttributes;
-typedef GNOME_Database_Type GdaType;
typedef GNOME_Database_Field GdaField;
-
-#define GDA_TYPE_NULL GNOME_Database_TYPE_NULL
-#define GDA_TYPE_BIGINT GNOME_Database_TYPE_BIGINT
-#define GDA_TYPE_BINARY GNOME_Database_TYPE_BINARY
-#define GDA_TYPE_BOOLEAN GNOME_Database_TYPE_BOOLEAN
-#define GDA_TYPE_DATE GNOME_Database_TYPE_DATE
-#define GDA_TYPE_GEOMETRIC_POINT GNOME_Database_TYPE_GEOMETRIC_POINT
-#define GDA_TYPE_TIME GNOME_Database_TYPE_TIME
-#define GDA_TYPE_TIMESTAMP GNOME_Database_TYPE_TIMESTAMP
-#define GDA_TYPE_DOUBLE GNOME_Database_TYPE_DOUBLE
-#define GDA_TYPE_INTEGER GNOME_Database_TYPE_INTEGER
-#define GDA_TYPE_SINGLE GNOME_Database_TYPE_SINGLE
-#define GDA_TYPE_SMALLINT GNOME_Database_TYPE_SMALLINT
-#define GDA_TYPE_STRING GNOME_Database_TYPE_STRING
-#define GDA_TYPE_TINYINT GNOME_Database_TYPE_TINYINT
-#define GDA_TYPE_UNKNOWN GNOME_Database_TYPE_UNKNOWN
+typedef enum
+{
+ GDA_TYPE_NULL = GNOME_Database_TYPE_NULL,
+ GDA_TYPE_BIGINT = GNOME_Database_TYPE_BIGINT,
+ GDA_TYPE_BINARY = GNOME_Database_TYPE_BINARY,
+ GDA_TYPE_BOOLEAN = GNOME_Database_TYPE_BOOLEAN,
+ GDA_TYPE_DATE = GNOME_Database_TYPE_DATE,
+ GDA_TYPE_GEOMETRIC_POINT = GNOME_Database_TYPE_GEOMETRIC_POINT,
+ GDA_TYPE_TIME = GNOME_Database_TYPE_TIME,
+ GDA_TYPE_TIMESTAMP = GNOME_Database_TYPE_TIMESTAMP,
+ GDA_TYPE_DOUBLE = GNOME_Database_TYPE_DOUBLE,
+ GDA_TYPE_INTEGER = GNOME_Database_TYPE_INTEGER,
+ GDA_TYPE_SINGLE = GNOME_Database_TYPE_SINGLE,
+ GDA_TYPE_SMALLINT = GNOME_Database_TYPE_SMALLINT,
+ GDA_TYPE_TINYINT = GNOME_Database_TYPE_TINYINT,
+ GDA_TYPE_STRING = GNOME_Database_TYPE_STRING,
+ GDA_TYPE_UNKNOWN = GNOME_Database_TYPE_UNKNOWN
+}
+GdaType;
GdaRow *gda_row_new (gint count);
void gda_row_free (GdaRow *row);
@@ -110,7 +112,7 @@
gchar gda_field_get_tinyint_value (GdaField *field);
void gda_field_set_tinyint_value (GdaField *field, gchar value);
-gchar *gda_field_stringify (GdaField *field);
+gchar *gda_field_stringify (const GdaField *field);
G_END_DECLS
Index: libgda/gda-value.c
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/libgda/gda-value.c,v
retrieving revision 1.12
diff -u -r1.12 gda-value.c
--- libgda/gda-value.c 8 Jan 2002 21:51:30 -0000 1.12
+++ libgda/gda-value.c 9 Jan 2002 01:12:40 -0000
@@ -167,7 +167,7 @@
* gda_value_isa
*/
gboolean
-gda_value_isa (GdaValue *value, GdaValueType type)
+gda_value_isa (const GdaValue *value, GdaValueType type)
{
g_return_val_if_fail (value != NULL, FALSE);
return bonobo_arg_type_is_equal (type, value->_type, NULL);
@@ -625,7 +625,7 @@
* gda_value_stringify
*/
gchar *
-gda_value_stringify (GdaValue *value)
+gda_value_stringify (const GdaValue *value)
{
gchar *retval = NULL;
Index: libgda/gda-value.h
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/libgda/gda-value.h,v
retrieving revision 1.6
diff -u -r1.6 gda-value.h
--- libgda/gda-value.h 8 Jan 2002 21:51:30 -0000 1.6
+++ libgda/gda-value.h 9 Jan 2002 01:12:51 -0000
@@ -65,7 +65,7 @@
void gda_value_free (GdaValue *value);
-gboolean gda_value_isa (GdaValue *value, GdaValueType type);
+gboolean gda_value_isa (const GdaValue *value, GdaValueType type);
gboolean gda_value_is_null (GdaValue *value);
GdaValue *gda_value_copy (GdaValue *value);
@@ -97,7 +97,7 @@
gchar gda_value_get_tinyint (GdaValue *value);
void gda_value_set_tinyint (GdaValue *value, gchar val);
-gchar *gda_value_stringify (GdaValue *value);
+gchar *gda_value_stringify (const GdaValue *value);
G_END_DECLS
Index: providers/postgres/ChangeLog
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/providers/postgres/ChangeLog,v
retrieving revision 1.6
diff -u -r1.6 ChangeLog
--- providers/postgres/ChangeLog 7 Jan 2002 23:15:45 -0000 1.6
+++ providers/postgres/ChangeLog 9 Jan 2002 01:17:14 -0000
@@ -1,3 +1,23 @@
+2002-01-08 Gonzalo Paniagua Javier <gonzalo gnome-db org>
+
+ * utils.c (gda_postgres_set_type_value): renamed to
+ gda_postgres_set_field_data(). Now it sets all the field data, not
+ just type and value.
+ (gda_postgres_type_to_gda()): added NAMEOID type (char(32) used for
+ internal names in PostgreSQL). Default return value is now STRING so
+ as describe_func() doesn't set the column type to UNKNOWN.
+
+ * gda-postgres.h: removed declaration of gda_postgres_set_type_value()
+ and added gda_postgres_set_field_data().
+
+ * gda-postgres-recordset.c (fetch_func()): use the new function to set
+ the field data. Removed TODO list. Check for null values.
+ (describe_func()): removed TODO list. Values for scale and
+ defined_size are now ok.
+
+ * gda_postgres_provider.c: free the list of recordsets when there is
+ an error and return NULL after adding the error to the connection.
+
2002-01-07 Gonzalo Paniagua Javier <gonzalo gnome-db org>
* *.[ch]: changed copyright to the GNOME Foundation.
Index: providers/postgres/gda-postgres-provider.c
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/providers/postgres/gda-postgres-provider.c,v
retrieving revision 1.5
diff -u -r1.5 gda-postgres-provider.c
--- providers/postgres/gda-postgres-provider.c 7 Jan 2002 23:15:45 -0000 1.5
+++ providers/postgres/gda-postgres-provider.c 9 Jan 2002 01:09:14 -0000
@@ -326,18 +326,31 @@
while (arr[n]) {
PGresult *pg_res;
GdaServerRecordset *recset;
+ gint status;
pg_res = PQexec(pconn, arr[n]);
if (pg_res == NULL) {
gda_server_connection_add_error (
cnc, gda_postgres_make_error (pconn));
+ g_list_foreach (reclist, (GFunc) g_object_unref, NULL);
+ g_list_free (reclist);
+ reclist = NULL;
break;
}
- if (PQresultStatus(pg_res) == PGRES_TUPLES_OK){
+ status = PQresultStatus(pg_res);
+ if (status == PGRES_TUPLES_OK ||
+ status == PGRES_COMMAND_OK) {
recset = gda_postgres_recordset_new (cnc, pg_res);
if (GDA_IS_SERVER_RECORDSET (recset))
reclist = g_list_append (reclist, recset);
+ } else {
+ gda_server_connection_add_error (
+ cnc, gda_postgres_make_error (pconn));
+ g_list_foreach (reclist, (GFunc) g_object_unref, NULL);
+ g_list_free (reclist);
+ reclist = NULL;
+ break;
}
n++;
Index: providers/postgres/gda-postgres-recordset.c
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/providers/postgres/gda-postgres-recordset.c,v
retrieving revision 1.4
diff -u -r1.4 gda-postgres-recordset.c
--- providers/postgres/gda-postgres-recordset.c 7 Jan 2002 23:15:45 -0000 1.4
+++ providers/postgres/gda-postgres-recordset.c 8 Jan 2002 22:30:26 -0000
@@ -77,25 +77,17 @@
GdaField *field;
gchar *thevalue;
GdaType ftype;
+ gboolean isNull;
field = gda_row_get_field (row, i);
- //TODO: What do I do when PQfsize() returns -1 to show that the
- //field is of variable length?
- //TODO: actual_size == defined_size!!!
- //TODO: What do I do with NULLs?
- //TODO: What do I do with BLOBs?
- //TODO: PQfsize() returns the length of the attribute in the server, not
- //the same length as PQgetlength(), which contains the length of the
- //string returned by PQgetvalue()!!! So PQfsize may be < PQgetlength!!!
- gda_field_set_actual_size (field, PQgetlength (pg_res, rownum, i));
- gda_field_set_defined_size (field, PQfsize (pg_res, i));
- gda_field_set_name (field, PQfname (pg_res, i));
- //TODO: Don't know what the scale is!
- //gda_field_set_scale (field, mysql_fields[i].decimals);
- gda_field_set_scale (field, 0);
- ftype = gda_postgres_type_to_gda (PQftype (pg_res, i));
thevalue = PQgetvalue(pg_res, rownum, i);
- gda_postgres_set_type_value(field, ftype, thevalue);
+
+ ftype = gda_postgres_type_to_gda (PQftype (pg_res, i));
+ isNull = *thevalue != '\0' ?
+ FALSE : PQgetisnull (pg_res, rownum, i);
+
+ gda_postgres_set_field_data (field, PQfname (pg_res, i), ftype,
+ thevalue, PQfsize (pg_res, i), isNull);
}
return row;
@@ -125,15 +117,22 @@
for (i = 0; i < field_count; i++) {
GdaFieldAttributes *field_attrs;
+ GdaType ftype;
+ gint scale;
field_attrs = gda_row_attributes_get_field (attrs, i);
gda_field_attributes_set_name (field_attrs, PQfname (pg_res, i));
- //TODO: PQfsize() or PQgetlength()?
- gda_field_attributes_set_defined_size (field_attrs, PQfsize (pg_res, i));
- //TODO: What is the scale?
- gda_field_attributes_set_scale (field_attrs, 0);
- gda_field_attributes_set_gdatype (field_attrs,
- gda_postgres_type_to_gda (PQftype (pg_res, i)));
+
+ ftype = gda_postgres_type_to_gda (PQftype (pg_res, i));
+ scale = (ftype == GDA_TYPE_DOUBLE) ? DBL_DIG :
+ (ftype == GDA_TYPE_SINGLE) ? FLT_DIG : 0;
+
+ gda_field_attributes_set_scale (field_attrs, scale);
+ gda_field_attributes_set_gdatype (field_attrs, ftype);
+
+ // PQfsize() == -1 => variable length
+ gda_field_attributes_set_defined_size (field_attrs,
+ PQfsize (pg_res, i));
}
return attrs;
Index: providers/postgres/gda-postgres.h
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/providers/postgres/gda-postgres.h,v
retrieving revision 1.4
diff -u -r1.4 gda-postgres.h
--- providers/postgres/gda-postgres.h 7 Jan 2002 23:15:45 -0000 1.4
+++ providers/postgres/gda-postgres.h 8 Jan 2002 15:03:06 -0000
@@ -46,9 +46,9 @@
GdaError *gda_postgres_make_error (PGconn *cnc);
GdaType gda_postgres_type_to_gda (Oid postgres_type);
-void gda_postgres_set_type_value (GdaField *field,
- GdaType type,
- const gchar *value);
+void gda_postgres_set_field_data (GdaField *field, const gchar *fname,
+ GdaType type, const gchar *value,
+ gint dbsize, gboolean isNull);
G_END_DECLS
Index: providers/postgres/utils.c
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/providers/postgres/utils.c,v
retrieving revision 1.6
diff -u -r1.6 utils.c
--- providers/postgres/utils.c 7 Jan 2002 23:15:45 -0000 1.6
+++ providers/postgres/utils.c 9 Jan 2002 01:08:38 -0000
@@ -54,6 +54,7 @@
return GDA_TYPE_BOOLEAN;
case BYTEAOID :
case CHAROID :
+ case NAMEOID :
case TEXTOID :
case BPCHAROID :
case VARCHAROID :
@@ -84,9 +85,10 @@
return GDA_TYPE_GEOMETRIC_POINT;
}
- return GDA_TYPE_UNKNOWN;
+ return GDA_TYPE_STRING;
}
+/* Makes a point from a string like "(3.2,5.6)" */
static GdaGeometricPoint *
make_point (const gchar *value)
{
@@ -113,39 +115,68 @@
}
void
-gda_postgres_set_type_value (GdaField *field, GdaType type, const gchar *value)
+gda_postgres_set_field_data (GdaField *field, const gchar *fname,
+ GdaType type, const gchar *value,
+ gint dbsize, gboolean isNull)
{
GDate *date;
GdaGeometricPoint *point;
+ gint scale;
+
+ g_return_if_fail (field != NULL);
+ g_return_if_fail (fname != NULL);
+ g_return_if_fail (value != NULL);
+
+ //TODO: What do I do with BLOBs?
+
+ gda_field_set_name (field, fname);
+ // dbsize == -1 => variable length
+ gda_field_set_defined_size (field, dbsize);
+ scale = (type == GDA_TYPE_DOUBLE) ? DBL_DIG :
+ (type == GDA_TYPE_SINGLE) ? FLT_DIG : 0;
+ gda_field_set_scale (field, scale);
+
+ if (isNull)
+ type = GDA_TYPE_NULL;
switch (type) {
case GDA_TYPE_BOOLEAN :
gda_field_set_gdatype (field, type);
- gda_field_set_boolean_value (field, atoi (value));
+ gda_field_set_boolean_value (field,
+ (*value == 't') ? TRUE : FALSE);
+ gda_field_set_actual_size (field, sizeof (gboolean));
break;
case GDA_TYPE_STRING :
gda_field_set_gdatype (field, type);
gda_field_set_string_value (field, value);
+ gda_field_set_actual_size (field, strlen (value));
break;
case GDA_TYPE_BIGINT :
gda_field_set_gdatype (field, type);
+ //FIXME: Don't know if atoll() is portable
gda_field_set_bigint_value (field, atoll (value));
+ //TODO: conditionally use gint64 based on G_HAVE_GINT64
+ gda_field_set_actual_size (field, sizeof (gint64));
break;
case GDA_TYPE_INTEGER :
gda_field_set_gdatype (field, type);
gda_field_set_integer_value (field, atol (value));
+ gda_field_set_actual_size (field, sizeof (gint32));
break;
case GDA_TYPE_SMALLINT :
gda_field_set_gdatype (field, type);
gda_field_set_smallint_value (field, atoi (value));
+ gda_field_set_actual_size (field, sizeof (gint16));
break;
case GDA_TYPE_SINGLE :
gda_field_set_gdatype (field, type);
gda_field_set_single_value (field, atof (value));
+ gda_field_set_actual_size (field, sizeof (gfloat));
break;
case GDA_TYPE_DOUBLE :
gda_field_set_gdatype (field, type);
gda_field_set_double_value (field, atof (value));
+ gda_field_set_actual_size (field, sizeof (gdouble));
break;
case GDA_TYPE_DATE :
gda_field_set_gdatype (field, type);
@@ -159,6 +190,7 @@
}
gda_field_set_date_value (field, date);
g_date_free (date);
+ gda_field_set_actual_size (field, sizeof (GDate));
break;
case GDA_TYPE_GEOMETRIC_POINT :
@@ -166,6 +198,12 @@
gda_field_set_geometric_point_value (field, point);
gda_field_set_gdatype (field, type);
delete_point (point);
+ gda_field_set_actual_size (field, sizeof (GdaGeometricPoint));
+ break;
+ case GDA_TYPE_NULL :
+ gda_field_set_gdatype (field, type);
+ gda_field_set_null_value (field);
+ gda_field_set_actual_size (field, 0);
break;
case GDA_TYPE_TIMESTAMP : //FIXME
case GDA_TYPE_TIME : //FIXME
@@ -173,6 +211,7 @@
default :
gda_field_set_string_value (field, value);
gda_field_set_gdatype (field, GDA_TYPE_STRING);
+ gda_field_set_actual_size (field, strlen (value));
}
}
Index: testing/ChangeLog
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/testing/ChangeLog,v
retrieving revision 1.19
diff -u -r1.19 ChangeLog
--- testing/ChangeLog 3 Jan 2002 17:03:32 -0000 1.19
+++ testing/ChangeLog 9 Jan 2002 01:19:58 -0000
@@ -1,3 +1,10 @@
+2002-01-08 Gonzalo Paniagua Javier <gonzalo gnome-db org>
+
+ * client.c (show_schema()): changed value to be const.
+ (do_postgres_test()):
+ (display_row_data()):
+ (open_connection()): new test specific to the postgres provider.
+
2002-01-02 Gonzalo Paniagua Javier <gonzalo gnome-db org>
* client.c: also lists procedures and views (if any). Shows the number
Index: testing/client.c
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/testing/client.c,v
retrieving revision 1.8
diff -u -r1.8 client.c
--- testing/client.c 3 Jan 2002 17:03:32 -0000 1.8
+++ testing/client.c 9 Jan 2002 01:14:49 -0000
@@ -44,7 +44,7 @@
for (r = 0; r < row_count; r++) {
g_print ("\t");
for (c = 0; c < col_count; c++) {
- GdaValue *value;
+ const GdaValue *value;
gchar *str;
value = gda_data_model_get_value_at (model, c, r);
@@ -57,6 +57,124 @@
}
+/* Prints the data in a GdaServerRecordset. Called from g_list_foreach() */
+static void
+display_row_data (gpointer data, gpointer user_data)
+{
+ GdaServerRecordset *recset = GDA_SERVER_RECORDSET (data);
+
+ g_return_if_fail (GDA_IS_SERVER_RECORDSET (recset));
+}
+
+/* Postgres provider own tests */
+static void
+do_postgres_test (GdaConnection *cnc)
+{
+ GdaCommand *create_command;
+ GdaCommand *drop_command;
+ GdaCommand *insert_command;
+ GdaCommand *select_command;
+ GList *list;
+ gint col_count;
+
+ g_return_if_fail (GDA_IS_CONNECTION (cnc));
+
+ /*
+ * Drops table
+ * Creates table
+ * Inserts
+ * Selects
+ * Clean up
+ */
+ g_print ("\tPostgres provider specific tests...\n");
+
+ /* Drops the gda_postgres_test table. Fail if not exists. */
+ drop_command = gda_command_new ( "drop table gda_postgres_test",
+ GDA_COMMAND_TYPE_SQL);
+ list = gda_connection_execute_command (cnc, drop_command, NULL);
+ g_print ("\t\tDrop table: %s\n",
+ list ? "OK" : "Error (don't worry about this one)");
+ g_list_foreach (list, (GFunc) g_object_unref, NULL);
+ g_list_free (list);
+
+ /* Creates a table with all supported data types */
+ create_command = gda_command_new ( "create table gda_postgres_test ("
+ "boolean_value boolean, "
+ "int2_value smallint, "
+ "int4_value integer, "
+ "bigint_value bigint, "
+ "float_value real, "
+ "double_value double precision, "
+ "numeric_value numeric(15, 3), "
+ "char_value char(50), "
+ "varchar_value varchar(20), "
+ "text_value text, "
+ "point_value point, "
+ "null_value char(1) "
+ ")",
+ GDA_COMMAND_TYPE_SQL);
+ list = gda_connection_execute_command (cnc, create_command, NULL);
+ g_print ("\t\tCreate table with all supported types: %s\n",
+ list ? "OK" : "Error");
+ g_list_foreach (list, (GFunc) g_object_unref, NULL);
+ g_list_free (list);
+
+ /* Inserts values */
+ insert_command = gda_command_new ( "insert into gda_postgres_test ("
+ "boolean_value, "
+ "int2_value, "
+ "int4_value, "
+ "bigint_value, "
+ "float_value, "
+ "double_value, "
+ "numeric_value, "
+ "char_value, "
+ "varchar_value, "
+ "text_value, "
+ "point_value "
+ ") values ("
+ "'T', "
+ "-22, "
+ "1048000, "
+ "123456789012345, "
+ "3.141592, "
+ "3.1415926969696, "
+ "123456789012.345, "
+ "'This is a char', "
+ "'This is a varchar', "
+ "'This is a text', "
+ "'(1,0)' "
+ ")",
+ GDA_COMMAND_TYPE_SQL);
+ list = gda_connection_execute_command (cnc, insert_command, NULL);
+ g_print ("\t\tInsert values for all known types: %s\n",
+ list ? "OK" : "Error");
+ g_list_foreach (list, (GFunc) g_object_unref, NULL);
+ g_list_free (list);
+
+ /* Selects values */
+ select_command = gda_command_new ( "select * from gda_postgres_test",
+ GDA_COMMAND_TYPE_SQL);
+ list = gda_connection_execute_command (cnc, select_command, NULL);
+ g_print ("\t\tSelecting values for all known types: %s\n",
+ list ? "OK" : "Error");
+
+ g_list_foreach (list, display_row_data, NULL);
+ g_list_foreach (list, (GFunc) g_object_unref, NULL);
+ g_list_free (list);
+
+ /* Clean up */
+ list = gda_connection_execute_command (cnc, drop_command, NULL);
+ g_print ("\t\tDrop table: %s\n",
+ list ? "OK" : "Error");
+ g_list_foreach (list, (GFunc) g_object_unref, NULL);
+ g_list_free (list);
+
+ gda_command_free (select_command);
+ gda_command_free (insert_command);
+ gda_command_free (create_command);
+ gda_command_free (drop_command);
+}
/* Opens a connection and test basic operations on it */
static void
open_connection (GdaClient *client,
@@ -103,6 +221,10 @@
g_print ("\tRolling back transaction...");
res = gda_connection_rollback_transaction (cnc, NULL);
g_print ("%s\n", res ? "OK" : "Error");
+
+ /* Postgres own tests */
+ if (!strcmp (name, "postgres"))
+ do_postgres_test (cnc);
/* close the connection */
gda_connection_close (cnc);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]