[gnome-db] Big patch



	The attached patch and files:

		* Remove gda-recordset.[ch].
		
		* Add a new gda-data-model-hash which is is used by the
		postgres provider.
		
		* Removes GdaField.

		* Makes GdaRow store an array of GdaValue instead of a
		GList of GdaField and remove gda-row-attributes-*.

		* Fixes some warning.

		* Removes dead code (never executed) from
		gda-data-model-array.c

		* Changes to the postgres recordset to implemente
		GdaDataModelHash.

		* A new test under postgres to test speed in random access to
		values.

	Comments?


		
		

-- 
Gonzalo Paniagua Javier <gonzalo gnome-db org>
http://www.gnome-db.org/~gonzalo/

Index: libgda/Makefile.am
===================================================================
RCS file: /cvs/gnome/libgda/libgda/Makefile.am,v
retrieving revision 1.21
diff -u -r1.21 Makefile.am
--- libgda/Makefile.am	4 May 2002 16:39:36 -0000	1.21
+++ libgda/Makefile.am	12 May 2002 08:52:16 -0000
@@ -22,6 +22,7 @@
 	gda-connection.h \
 	gda-data-model.h \
 	gda-data-model-array.h \
+	gda-data-model-hash.h \
 	gda-data-model-list.h \
 	gda-error.h \
 	gda-export.h \
@@ -30,7 +31,6 @@
 	gda-marshal.h \
 	gda-parameter.h \
 	gda-quark-list.h \
-	gda-recordset.h \
 	gda-row.h \
 	gda-server-provider.h \
 	gda-table.h \
@@ -71,6 +71,7 @@
 	gda-connection.c \
 	gda-data-model.c \
 	gda-data-model-array.c \
+	gda-data-model-hash.c \
 	gda-data-model-list.c \
 	gda-error.c \
 	gda-export.c \
@@ -80,7 +81,6 @@
 	gda-log.c \
 	gda-parameter.c \
 	gda-quark-list.c \
-	gda-recordset.c \
 	gda-row.c \
 	gda-server-provider.c \
 	gda-table.c \
Index: libgda/gda-config.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-config.c,v
retrieving revision 1.31
diff -u -r1.31 gda-config.c
--- libgda/gda-config.c	11 May 2002 23:21:32 -0000	1.31
+++ libgda/gda-config.c	12 May 2002 08:52:16 -0000
@@ -1194,7 +1194,7 @@
 		value_list = g_list_append (value_list, gda_value_new_string (dsn_info->description));
 		value_list = g_list_append (value_list, gda_value_new_string (dsn_info->username));
 
-		gda_data_model_append_row (GDA_DATA_MODEL_ARRAY (model), value_list);
+		gda_data_model_append_row (GDA_DATA_MODEL (model), value_list);
 	}
 	
 	/* free memory */
Index: libgda/gda-connection.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-connection.c,v
retrieving revision 1.21
diff -u -r1.21 gda-connection.c
--- libgda/gda-connection.c	22 Apr 2002 22:01:33 -0000	1.21
+++ libgda/gda-connection.c	12 May 2002 08:52:17 -0000
@@ -28,7 +28,6 @@
 #include <libgda/gda-connection.h>
 #include <libgda/gda-intl.h>
 #include <libgda/gda-log.h>
-#include <libgda/gda-recordset.h>
 #include <libgda/gda-server-provider.h>
 
 #define PARENT_TYPE G_TYPE_OBJECT
Index: libgda/gda-data-model-array.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-data-model-array.c,v
retrieving revision 1.10
diff -u -r1.10 gda-data-model-array.c
--- libgda/gda-data-model-array.c	11 May 2002 00:35:19 -0000	1.10
+++ libgda/gda-data-model-array.c	12 May 2002 08:52:17 -0000
@@ -78,10 +78,10 @@
 
 	fields = g_ptr_array_index (GDA_DATA_MODEL_ARRAY (model)->priv->rows, row);
 	if (fields != NULL) {
-		GdaField *field;
+		GdaValue *field;
 
-		field = gda_row_get_field (fields, col);
-		return (const GdaValue *) gda_field_get_value (field);
+		field = gda_row_get_value (fields, col);
+		return (const GdaValue *) field;
 	}
 
 	return NULL;
@@ -99,7 +99,7 @@
 {
 	gint len;
 	gint i;
-	GList *list = NULL;
+	const GList *l;
 	GdaRow *row = NULL;
 
 	g_return_val_if_fail (GDA_IS_DATA_MODEL_ARRAY (model), NULL);
@@ -109,33 +109,17 @@
 	if (len != GDA_DATA_MODEL_ARRAY (model)->priv->number_of_columns)
 		return NULL;
 
+	l = values;
 	row = gda_row_new (len);
 	for (i = 0; i < len; i++) {
-		GList *l;
-		GdaField *field;
-		GdaFieldAttributes *fa;
+		GdaValue *field;
 
-		l = g_list_nth ((GList *) values, i);
 		if (!l)
 			return NULL;
 
-		field = gda_row_get_field (row, i);
-		fa = gda_data_model_describe_column (model, i);
-		if (!fa) {
-			gda_field_set_defined_size (field, gda_field_attributes_get_defined_size (fa));
-			gda_field_set_name (field, gda_field_attributes_get_name (fa));
-			gda_field_set_caption (field, gda_field_attributes_get_caption (fa));
-			gda_field_set_scale (field, gda_field_attributes_get_scale (fa));
-			gda_field_set_gdatype (field, gda_field_attributes_get_gdatype (fa));
-			gda_field_set_allow_null (field, gda_field_attributes_get_allow_null (fa));
-			gda_field_set_primary_key (field, gda_field_attributes_get_primary_key (fa));
-			gda_field_set_unique_key (field, gda_field_attributes_get_unique_key (fa));
-			gda_field_set_references (field, gda_field_attributes_get_references (fa));
-
-			gda_field_attributes_free (fa);
-		}
-
-		gda_field_set_value (field, (const GdaValue *) l->data);
+		field = gda_value_copy ((GdaValue *) l->data);
+		memcpy (gda_row_get_value (row, i), field, sizeof (GdaValue));
+		l = l->next;
 	}
 
 	g_ptr_array_add (GDA_DATA_MODEL_ARRAY (model)->priv->rows, row);
Index: libgda/gda-data-model-list.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-data-model-list.c,v
retrieving revision 1.8
diff -u -r1.8 gda-data-model-list.c
--- libgda/gda-data-model-list.c	9 May 2002 22:52:24 -0000	1.8
+++ libgda/gda-data-model-list.c	12 May 2002 08:52:17 -0000
@@ -102,7 +102,7 @@
 {
 	/* allocate internal structure */
 	list->priv = g_new0 (GdaDataModelListPrivate, 1);
-	list->priv->rows = gda_data_model_array_new (1);
+	list->priv->rows = (GdaDataModelArray *) gda_data_model_array_new (1);
 }
 
 static void
@@ -191,10 +191,10 @@
 	GList *values;
 	GdaRow *row;
 
-	g_return_if_fail (GDA_IS_DATA_MODEL_LIST (model));
-	g_return_if_fail (value != NULL);
+	g_return_val_if_fail (GDA_IS_DATA_MODEL_LIST (model), NULL);
+	g_return_val_if_fail (value != NULL, NULL);
 
-	values = g_list_append (NULL, value);
+	values = g_list_append (NULL, (GdaValue *) value);
 	row = gda_data_model_append_row (GDA_DATA_MODEL (model->priv->rows), values);
 	if (row)
 		gda_data_model_changed (GDA_DATA_MODEL (model));
Index: libgda/gda-data-model.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-data-model.c,v
retrieving revision 1.20
diff -u -r1.20 gda-data-model.c
--- libgda/gda-data-model.c	9 May 2002 23:07:37 -0000	1.20
+++ libgda/gda-data-model.c	12 May 2002 08:52:17 -0000
@@ -303,9 +303,12 @@
 	g_return_val_if_fail (GDA_IS_DATA_MODEL (model), NULL);
 
 	n_cols = gda_data_model_get_n_columns (model);
-	if (col < n_cols && col >= 0)
+	if (col < n_cols && col >= 0){
 		title = g_hash_table_lookup (model->priv->column_titles,
 					     GINT_TO_POINTER (col));
+		if (title == NULL)
+			title = "";
+	}
 	else
 		title = "";
 
@@ -434,25 +437,9 @@
 	for (r = 0; r < rows; r++) {
 		row = gda_row_new (cols);
 		for (c = 0; c < cols; c++) {
-			GdaField *field;
-			GdaFieldAttributes *fa;
-
-			field = gda_row_get_field (row, c);
-			fa = gda_data_model_describe_column (model, c);
-
-			gda_field_set_defined_size (field, gda_field_attributes_get_defined_size (fa));
-			gda_field_set_name (field, gda_field_attributes_get_name (fa));
-			gda_field_set_caption (field, gda_field_attributes_get_caption (fa));
-			gda_field_set_scale (field, gda_field_attributes_get_scale (fa));
-			gda_field_set_gdatype (field, gda_field_attributes_get_gdatype (fa));
-			gda_field_set_allow_null (field, gda_field_attributes_get_allow_null (fa));
-			gda_field_set_primary_key (field, gda_field_attributes_get_primary_key (fa));
-			gda_field_set_unique_key (field, gda_field_attributes_get_unique_key (fa));
-			gda_field_set_references (field, gda_field_attributes_get_references (fa));
-
-			gda_field_set_value (field, gda_data_model_get_value_at (model, c, r));
-
-			gda_field_attributes_free (fa);
+			GdaValue *value;
+			value = gda_value_copy (gda_data_model_get_value_at (model, c, r));
+			memcpy (gda_row_get_value (row, c), value, sizeof (GdaValue));
 		}
 
 		/* call the callback function */
Index: libgda/gda-field.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-field.c,v
retrieving revision 1.5
diff -u -r1.5 gda-field.c
--- libgda/gda-field.c	9 May 2002 04:47:25 -0000	1.5
+++ libgda/gda-field.c	12 May 2002 08:52:17 -0000
@@ -66,7 +66,7 @@
 
 /**
  * gda_field_attributes_get_defined_size
- * @fa: a @GdaRowAttributes
+ * @fa: a @GdaFieldAttributes
  *
  * Returns: the defined size of @fa.
  */
@@ -294,805 +294,3 @@
 		fa->references = g_strdup (ref);
 }
 
-/**
- * gda_field_new
- */
-GdaField *
-gda_field_new (void)
-{
-	GdaField *field;
-
-	field = g_new0 (GdaField, 1);
-	field->actual_size = 0;
-	field->value = gda_value_new_null ();
-	field->attributes = gda_field_attributes_new ();
-
-	return field;
-}
-
-/**
- * gda_field_free
- */
-void
-gda_field_free (GdaField *field)
-{
-	g_return_if_fail (field != NULL);
-
-	gda_value_free (field->value);
-	gda_field_attributes_free (field->attributes);
-	g_free (field);
-}
-
-/**
- * gda_field_get_actual_size
- * @field: a #GdaField
- *
- * Returns: the actual size of @field.
- */
-glong
-gda_field_get_actual_size (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, -1);
-	return field->actual_size;
-}
-
-/**
- * gda_field_set_actual_size
- * @field: a #GdaField
- * @size: the new actual size of @field.
- *
- * Sets the actual size of @field to @size.
- */
-void
-gda_field_set_actual_size (GdaField *field, glong size)
-{
-	g_return_if_fail (field != NULL);
-	field->actual_size = size;
-}
-
-/**
- * gda_field_get_defined_size
- * @field: a #GdaField
- *
- * Returns: the defined size of @field.
- */
-glong
-gda_field_get_defined_size (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, -1);
-	return gda_field_attributes_get_defined_size (field->attributes);
-}
-
-/**
- * gda_field_set_defined_size
- * @field: a #GdaField.
- * @size: the new defined size of @field.
- *
- * Sets the defined size of @field to @size.
- */
-void
-gda_field_set_defined_size (GdaField *field, glong size)
-{
-	g_return_if_fail (field != NULL);
-	gda_field_attributes_set_defined_size (field->attributes, size);
-}
-
-/**
- * gda_field_get_name
- * @field: a #GdaField
- *
- * Returns: the name of @field.
- */
-const gchar *
-gda_field_get_name (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, NULL);
-	return gda_field_attributes_get_name (field->attributes);
-}
-
-/**
- * gda_field_set_name
- * @field: a #GdaField.
- * @name: the new name of @field.
- *
- * Sets the name of @field to @name.
- */
-void
-gda_field_set_name (GdaField *field, const gchar *name)
-{
-	g_return_if_fail (field != NULL);
-	g_return_if_fail (name != NULL);
-
-	gda_field_attributes_set_name (field->attributes, name);
-}
-
-/**
- * gda_field_get_caption
- * @field: a #GdaField.
- *
- * Get the caption associated with this field.
- */
-const gchar *
-gda_field_get_caption (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, NULL);
-	return gda_field_attributes_get_caption (field->attributes);
-}
-
-/**
- * gda_field_get_caption
- * @field: a #GdaField.
- */
-void
-gda_field_set_caption (GdaField *field, const gchar *caption)
-{
-	g_return_if_fail (field != NULL);
-	gda_field_attributes_set_caption (field->attributes, caption);
-}
-
-/**
- * gda_field_get_scale
- * @field: a #GdaField
- *
- * Returns: the scale (number of decimals) of @field.
- */
-glong
-gda_field_get_scale (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, -1);
-	return gda_field_attributes_get_scale (field->attributes);
-}
-
-/**
- * gda_field_set_scale
- * @field: a #GdaField.
- * @scale: the new scale of @field.
- *
- * Sets the scale of @field to @scale.
- */
-void
-gda_field_set_scale (GdaField *field, glong scale)
-{
-	g_return_if_fail (field != NULL);
-	gda_field_attributes_set_scale (field->attributes, scale);
-}
-
-/**
- * gda_field_get_gdatype
- * @field: a #GdaField
- *
- * Returns: the type of @field.
- */
-GdaValueType
-gda_field_get_gdatype (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, GDA_VALUE_TYPE_NULL);
-	return gda_field_attributes_get_gdatype (field->attributes);
-}
-
-/**
- * gda_field_set_gdatype
- * @field: a #GdaField.
- * @type: the new type of @field.
- *
- * Sets the type of @field to @type.
- */
-void
-gda_field_set_gdatype (GdaField *field, GdaValueType type)
-{
-	g_return_if_fail (field != NULL);
-	gda_field_attributes_set_gdatype (field->attributes, type);
-}
-
-/**
- * gda_field_get_allow_null
- * @field: a #GdaField.
- */
-gboolean
-gda_field_get_allow_null (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, FALSE);
-	return gda_field_attributes_get_allow_null (field->attributes);
-}
-
-/**
- * gda_field_set_allow_null
- * @field: a #GdaField.
- * @allow:
- */
-void
-gda_field_set_allow_null (GdaField *field, gboolean allow)
-{
-	g_return_if_fail (field != NULL);
-	gda_field_attributes_set_allow_null (field->attributes, allow);
-}
-
-/**
- * gda_field_get_primary_key
- */
-gboolean
-gda_field_get_primary_key (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, FALSE);
-	return gda_field_attributes_get_primary_key (field->attributes);
-}
-
-/**
- * gda_field_set_primary_key
- */
-void
-gda_field_set_primary_key (GdaField *field, gboolean pk)
-{
-	g_return_if_fail (field != NULL);
-	gda_field_attributes_set_primary_key (field->attributes, pk);
-}
-
-/**
- * gda_field_get_unique_key
- */
-gboolean
-gda_field_get_unique_key (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, FALSE);
-	return gda_field_attributes_get_unique_key (field->attributes);
-}
-
-/**
- * gda_field_set_unique_key
- */
-void
-gda_field_set_unique_key (GdaField *field, gboolean uk)
-{
-	g_return_if_fail (field != NULL);
-	gda_field_attributes_set_unique_key (field->attributes, uk);
-}
-
-/**
- * gda_field_get_references
- */
-const gchar *
-gda_field_get_references (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, NULL);
-	return gda_field_attributes_get_references (field->attributes);
-}
-
-/**
- * gda_field_set_references
- */
-void
-gda_field_set_references (GdaField *field, const gchar *ref)
-{
-	g_return_if_fail (field != NULL);
-	gda_field_attributes_set_references (field->attributes, ref);
-}
-
-/**
- * gda_field_is_null
- * @field: a #GdaField
- *
- * Returns: a gboolean indicating whether or not the value of @field is of
- * type GDA_TYPE_VALUE_NULL.
- */
-gboolean
-gda_field_is_null (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, TRUE);
-	return gda_value_is_null (field->value);
-}
-
-/**
- * gda_field_get_value
- * @field: a #GdaField
- *
- * Returns: the #GdaValue stored in @field.
- */
-GdaValue *
-gda_field_get_value (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, NULL);
-	return field->value;
-}
-
-/**
- * gda_field_set_value
- * @field: a #GdaField.
- * @value: the #GdaValue to store in @field.
- *
- * Sets the value of @field to @value.
- */
-void
-gda_field_set_value (GdaField *field, const GdaValue *value)
-{
-	g_return_if_fail (field != NULL);
-	g_return_if_fail (value != NULL);
-
-	if (field->value)
-		gda_value_free (field->value);
-	field->value = gda_value_copy (value);
-}
-
-/**
- * gda_field_get_bigint_value
- * @field: a #GdaField
- *
- * Returns: the gint64 value stored in @field.
- */
-gint64
-gda_field_get_bigint_value (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, -1);
-	return gda_value_get_bigint (field->value);
-}
-
-/**
- * gda_field_set_bigint_value
- * @field: a #GdaField.
- * @value: the gint64 value to store in @field.
- *
- * Sets the value of @field to @value.
- */
-void
-gda_field_set_bigint_value (GdaField *field, gint64 value)
-{
-	g_return_if_fail (field != NULL);
-
-	gda_field_set_gdatype (field, GDA_VALUE_TYPE_BIGINT);
-	field->actual_size = sizeof (gint64);
-	gda_value_set_bigint (field->value, value);
-}
-
-/**
- * gda_field_get_binary_value
- * @field: a #GdaField
- *
- * NOT IMPLEMENTED YET!
- *
- * Returns: the pointer to the binary data in @field.
- */
-gconstpointer
-gda_field_get_binary_value (GdaField *field)
-{
-	return NULL;
-}
-
-/**
- * gda_field_set_binary_value
- * @field: a #GdaField.
- * @value: the gint64 value to store in @field.
- * @size: size of the buffer pointed to by @value.
- *
- * NOT IMPLEMENTED YET!
- * Sets the value of @field to the contents pointed to by @value.
- */
-void
-gda_field_set_binary_value (GdaField *field, gconstpointer value, glong size)
-{
-}
-
-/**
- * gda_field_get_boolean_value
- * @field: a #GdaField
- *
- * Returns: the gboolean value stored in @field.
- */
-gboolean
-gda_field_get_boolean_value (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, FALSE);
-	return gda_value_get_boolean (field->value);
-}
-
-/**
- * gda_field_set_boolean_value
- * @field: a #GdaField.
- * @value: the gboolean value to store in @field.
- *
- * Sets the value of @field to @value.
- */
-void
-gda_field_set_boolean_value (GdaField *field, gboolean value)
-{
-	g_return_if_fail (field != NULL);
-
-	gda_field_set_gdatype (field, GDA_VALUE_TYPE_BOOLEAN);
-	field->actual_size = sizeof (gboolean);
-	gda_value_set_boolean (field->value, value);
-}
-
-/**
- * gda_field_get_date_value
- * @field: a #GdaField
- *
- * Returns: the pointer to the #GdaDate value stored in @field.
- */
-const GdaDate *
-gda_field_get_date_value (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, NULL);
-
-	return gda_value_get_date (field->value);
-}
-
-/**
- * gda_field_set_date_value
- * @field: a #GdaField.
- * @date: the #GdaDate value to store in @field.
- *
- * Sets the value of @field to the #GdaDate pointed to @value.
- */
-void
-gda_field_set_date_value (GdaField *field, GdaDate *date)
-{
-	g_return_if_fail (field != NULL);
-	g_return_if_fail (date != NULL);
-
-	gda_field_set_gdatype (field, GDA_VALUE_TYPE_DATE);
-	field->actual_size = sizeof (GdaDate);
-	gda_value_set_date (field->value, date);
-}
-
-/**
- * gda_field_get_double_value
- * @field: a #GdaField.
- *
- * Returns: the double precision value stored in @field.
- */
-gdouble
-gda_field_get_double_value (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, -1);
-	return gda_value_get_double (field->value);
-}
-
-/**
- * gda_field_set_double_value
- * @field: a #GdaField.
- * @value: the double precision value to store in @field.
- *
- * Sets the value of @field to @value.
- */
-void
-gda_field_set_double_value (GdaField *field, gdouble value)
-{
-	g_return_if_fail (field != NULL);
-
-	gda_field_set_gdatype (field, GDA_VALUE_TYPE_DOUBLE);
-	field->actual_size = sizeof (gdouble);
-	gda_value_set_double (field->value, value);
-}
-
-/**
- * gda_field_get_geometric_point_value
- * @field: a #GdaField.
- *
- * Returns: the a pointer to the #GdaGeometricPoint value stored in @field.
- */
-const GdaGeometricPoint *
-gda_field_get_geometric_point_value (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, NULL);
-	return gda_value_get_geometric_point (field->value);
-}
-
-/**
- * gda_field_set_geometric_point_value
- * @field: a #GdaField.
- * @value: the #GdaGeometricPoint value to store in @field.
- *
- * Sets the value of @field to @value.
- */
-void
-gda_field_set_geometric_point_value (GdaField *field, GdaGeometricPoint *value)
-{
-	g_return_if_fail (field != NULL);
-	g_return_if_fail (value != NULL);
-
-	gda_field_set_gdatype (field, GDA_VALUE_TYPE_GEOMETRIC_POINT);
-	field->actual_size = sizeof (GdaGeometricPoint);
-	gda_value_set_geometric_point (field->value, value);
-}
-
-/**
- * gda_field_get_integer_value
- * @field: a #GdaField.
- *
- * Returns: the integer value stored in @field.
- */
-gint
-gda_field_get_integer_value (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, -1);
-	return gda_value_get_integer (field->value);
-}
-
-/**
- * gda_field_set_integer_value
- * @field: a #GdaField.
- * @value: the integer value to store in @field.
- *
- * Sets the value of @field to @value.
- */
-void
-gda_field_set_integer_value (GdaField *field, gint value)
-{
-	g_return_if_fail (field != NULL);
-
-	gda_field_set_gdatype (field, GDA_VALUE_TYPE_INTEGER);
-	field->actual_size = sizeof (gint);
-	gda_value_set_integer (field->value, value);
-}
-
-/**
- * gda_field_get_list_value
- * @field: a #GdaField.
- *
- * Returns: a pointer to the #GdaValueList value stored in @field.
- */
-const GdaValueList *
-gda_field_get_list_value (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, NULL);
-	return gda_value_get_list (field->value);
-}
-
-/**
- * gda_field_set_list_value
- * @field: a #GdaField.
- * @value: the #GdaValueList value to store in @field.
- *
- * Sets the value of @field to @value.
- */
-void
-gda_field_set_list_value (GdaField *field, GdaValueList *value)
-{
-	g_return_if_fail (field != NULL);
-	g_return_if_fail (value != NULL);
-
-	gda_field_set_gdatype (field, GDA_VALUE_TYPE_LIST);
-	field->actual_size = sizeof (GdaValue) * g_list_length (value);
-	gda_value_set_list (field->value, value);
-}
-
-/**
- * gda_field_set_null_value
- * @field: a #GdaField.
- *
- * Sets the value of @field to be of type #GDA_TYPE_VALUE_NULL.
- */
-void
-gda_field_set_null_value (GdaField *field)
-{
-	g_return_if_fail (field != NULL);
-
-	field->actual_size = 0;
-	gda_value_set_null (field->value);
-}
-
-/**
- * gda_field_get_numeric_value
- * @field: a #GdaField.
- *
- * Returns: a pointer to the #GdaNumeric value stored in @field.
- */
-const GdaNumeric *
-gda_field_get_numeric_value (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, NULL);
-	return gda_value_get_numeric (field->value);
-}
-
-/**
- * gda_field_set_numeric_value
- * @field: a #GdaField.
- * @value: the #GdaNumeric value to store in @field.
- *
- * Sets the value of @field to @value.
- */
-void
-gda_field_set_numeric_value (GdaField *field, GdaNumeric *value)
-{
-	g_return_if_fail (field != NULL);
-	g_return_if_fail (value != NULL);
-
-	gda_field_set_gdatype (field, GDA_VALUE_TYPE_NUMERIC);
-	field->actual_size = sizeof (GdaNumeric);
-	gda_value_set_numeric (field->value, value);
-}
-
-/**
- * gda_field_get_single_value
- * @field: a #GdaField.
- *
- * Returns: the single precision value stored in @field.
- */
-gfloat
-gda_field_get_single_value (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, -1);
-	return gda_value_get_single (field->value);
-}
-
-/**
- * gda_field_set_single_value
- * @field: a #GdaField.
- * @value: the single precision value to store in @field.
- *
- * Sets the value of @field to @value.
- */
-void
-gda_field_set_single_value (GdaField *field, gfloat value)
-{
-	g_return_if_fail (field != NULL);
-
-	gda_field_set_gdatype (field, GDA_VALUE_TYPE_SINGLE);
-	field->actual_size = sizeof (gfloat);
-	gda_value_set_single (field->value, value);
-}
-
-/**
- * gda_field_get_smallint_value
- * @field: a #GdaField.
- *
- * Returns: the smallint value (16-bit signed integer) stored in @field.
- */
-gshort
-gda_field_get_smallint_value (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, -1);
-	return gda_value_get_smallint (field->value);
-}
-
-/**
- * gda_field_set_smallint_value
- * @field: a #GdaField.
- * @value: the smallint value (16-bit signed integer) to store in @field.
- *
- * Sets the value of @field to @value.
- */
-void
-gda_field_set_smallint_value (GdaField *field, gshort value)
-{
-	g_return_if_fail (field != NULL);
-
-	gda_field_set_gdatype (field, GDA_VALUE_TYPE_SMALLINT);
-	field->actual_size = sizeof (gshort);
-	gda_value_set_smallint (field->value, value);
-}
-
-/**
- * gda_field_get_string_value
- * @field: a #GdaField.
- *
- * Returns: a pointer to the string value stored in @field.
- */
-const gchar *
-gda_field_get_string_value (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, NULL);
-	return gda_value_get_string (field->value);
-}
-
-/**
- * gda_field_set_string_value
- * @field: a #GdaField.
- * @value: the string value to store in @field.
- *
- * Sets the value of @field to @value.
- */
-void
-gda_field_set_string_value (GdaField *field, const gchar *value)
-{
-	g_return_if_fail (field != NULL);
-
-	gda_field_set_gdatype (field, GDA_VALUE_TYPE_STRING);
-	field->actual_size = value ? strlen (value) : 0;
-	gda_value_set_string (field->value, value);
-}
-
-/**
- * gda_field_get_time_value
- * @field: a #GdaField.
- *
- * Returns: a pointer to the #GdaTime value stored in @field.
- */
-const GdaTime *
-gda_field_get_time_value (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, NULL);
-	return gda_value_get_time (field->value);
-}
-
-/**
- * gda_field_set_time_value
- * @field: a #GdaField.
- * @value: the #GdaTime value to store in @field.
- *
- * Sets the value of @field to the contents of @value.
- */
-void
-gda_field_set_time_value (GdaField *field, GdaTime *value)
-{
-	g_return_if_fail (field != NULL);
-	g_return_if_fail (value != NULL);
-	
-	gda_field_set_gdatype (field, GDA_VALUE_TYPE_TIME);
-	field->actual_size = sizeof (GdaTime);
-	gda_value_set_time (field->value, value);
-}
-
-/**
- * gda_field_get_timestamp_value
- * @field: a #GdaField.
- *
- * Returns: a pointer to the #GdaGeometricData stored in @field.
- */
-const GdaTimestamp *
-gda_field_get_timestamp_value (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, NULL);
-	return gda_value_get_timestamp (field->value);
-}
-
-/**
- * gda_field_set_timestamp_value
- * @field: a #GdaField.
- * @value: the #GdaTimestamp value to store in @field.
- *
- * Sets the value of @field to the contents of @value.
- */
-void
-gda_field_set_timestamp_value (GdaField *field, GdaTimestamp *value)
-{
-	g_return_if_fail (field != NULL);
-
-        gda_field_set_gdatype (field, GDA_VALUE_TYPE_TIMESTAMP);
-	field->actual_size = sizeof (GdaTimestamp);
-	gda_value_set_timestamp (field->value, value);
-}
-
-/**
- * gda_field_get_tinyint_value
- * @field: a #GdaField.
- *
- * Returns: the tinyint value (8-bit signed integer) stored in @field.
- */
-gchar
-gda_field_get_tinyint_value (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, -1);
-	return gda_value_get_tinyint (field->value);
-}
-
-/**
- * gda_field_set_tinyint_value
- * @field: a #GdaField.
- * @value: the tinyint value (8-bit signed integer) to store in @field.
- *
- * Sets the value of @field to the contents of @value.
- */
-void
-gda_field_set_tinyint_value (GdaField *field, gchar value)
-{
-	g_return_if_fail (field != NULL);
-
-	gda_field_set_gdatype (field, GDA_VALUE_TYPE_TINYINT);
-	field->actual_size = sizeof (gchar);
-	gda_value_set_tinyint (field->value, value);
-}
-
-/**
- * gda_field_stringify
- * @field: a #GdaField.
- *
- * See also #gda_value_stringify for a list of types and their corresponding
- * string representation format.
- * 
- * Returns: the string representation of the value stored in @field.
- */
-gchar *
-gda_field_stringify (GdaField *field)
-{
-	g_return_val_if_fail (field != NULL, NULL);
-	return gda_value_stringify ((GdaValue *) field->value);
-}
Index: libgda/gda-field.h
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-field.h,v
retrieving revision 1.4
diff -u -r1.4 gda-field.h
--- libgda/gda-field.h	4 May 2002 16:39:36 -0000	1.4
+++ libgda/gda-field.h	12 May 2002 08:52:17 -0000
@@ -72,65 +72,6 @@
 const gchar        *gda_field_attributes_get_references (GdaFieldAttributes *fa);
 void                gda_field_attributes_set_references (GdaFieldAttributes *fa, const gchar *ref);
 
-GdaField           *gda_field_new (void);
-void                gda_field_free (GdaField *field);
-glong               gda_field_get_actual_size (GdaField *field);
-void                gda_field_set_actual_size (GdaField *field, glong size);
-glong               gda_field_get_defined_size (GdaField *field);
-void                gda_field_set_defined_size (GdaField *field, glong size);
-const gchar        *gda_field_get_name (GdaField *field);
-void                gda_field_set_name (GdaField *field, const gchar *name);
-const gchar        *gda_field_get_caption (GdaField *field);
-void                gda_field_set_caption (GdaField *field, const gchar *caption);
-glong               gda_field_get_scale (GdaField *field);
-void                gda_field_set_scale (GdaField *field, glong scale);
-GdaValueType        gda_field_get_gdatype (GdaField *field);
-void                gda_field_set_gdatype (GdaField *field, GdaValueType type);
-gboolean            gda_field_get_allow_null (GdaField *field);
-void                gda_field_set_allow_null (GdaField *field, gboolean allow);
-gboolean            gda_field_get_primary_key (GdaField *field);
-void                gda_field_set_primary_key (GdaField *field, gboolean pk);
-gboolean            gda_field_get_unique_key (GdaField *field);
-void                gda_field_set_unique_key (GdaField *field, gboolean uk);
-const gchar        *gda_field_get_references (GdaField *field);
-void                gda_field_set_references (GdaField *field, const gchar *ref);
-gboolean            gda_field_is_null (GdaField *field);
-GdaValue           *gda_field_get_value (GdaField *field);
-void                gda_field_set_value (GdaField *field, const GdaValue *value);
-gint64              gda_field_get_bigint_value (GdaField *field);
-void                gda_field_set_bigint_value (GdaField *field, gint64 value);
-gconstpointer       gda_field_get_binary_value (GdaField *field);
-void                gda_field_set_binary_value (GdaField *field, gconstpointer value, glong size);
-gboolean            gda_field_get_boolean_value (GdaField *field);
-void                gda_field_set_boolean_value (GdaField *field, gboolean value);
-const GdaDate      *gda_field_get_date_value (GdaField *field);
-void                gda_field_set_date_value (GdaField *field, GdaDate *date);
-gdouble             gda_field_get_double_value (GdaField *field);
-void                gda_field_set_double_value (GdaField *field, gdouble value);
-const GdaGeometricPoint  *gda_field_get_geometric_point_value (GdaField *field);
-void                gda_field_set_geometric_point_value (GdaField *field, GdaGeometricPoint *value);
-gint                gda_field_get_integer_value (GdaField *field);
-void                gda_field_set_integer_value (GdaField *field, gint value);
-const GdaValueList *gda_field_get_list_value (GdaField *field);
-void                gda_field_set_list_value (GdaField *field, GdaValueList *value);
-void                gda_field_set_null_value (GdaField *field);
-const GdaNumeric   *gda_field_get_numeric_value (GdaField *field);
-void                gda_field_set_numeric_value (GdaField *field, GdaNumeric *value);
-gfloat              gda_field_get_single_value (GdaField *field);
-void                gda_field_set_single_value (GdaField *field, gfloat value);
-gshort              gda_field_get_smallint_value (GdaField *field);
-void                gda_field_set_smallint_value (GdaField *field, gshort value);
-const gchar        *gda_field_get_string_value (GdaField *field);
-void                gda_field_set_string_value (GdaField *field, const gchar *value);
-const GdaTime      *gda_field_get_time_value (GdaField *field);
-void                gda_field_set_time_value (GdaField *field, GdaTime *value);
-const GdaTimestamp *gda_field_get_timestamp_value (GdaField *field);
-void                gda_field_set_timestamp_value (GdaField *field, GdaTimestamp *value);
-gchar               gda_field_get_tinyint_value (GdaField *field);
-void                gda_field_set_tinyint_value (GdaField *field, gchar value);
-
-gchar              *gda_field_stringify (GdaField *field);
-
 G_END_DECLS
 
 #endif
Index: libgda/gda-row.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-row.c,v
retrieving revision 1.28
diff -u -r1.28 gda-row.c
--- libgda/gda-row.c	7 May 2002 17:57:56 -0000	1.28
+++ libgda/gda-row.c	12 May 2002 08:52:17 -0000
@@ -26,14 +26,15 @@
 
 struct _GdaRow {
 	gchar *id;
-	GList *fields;
+	GdaValue *fields;
+	gint nfields;
 };
 
 /**
  * gda_row_new
- * @count: number of #GdaField in the new #GdaRow.
+ * @count: number of #GdaValue in the new #GdaRow.
  *
- * Creates a #GdaRow which can hold @count #GdaField.
+ * Creates a #GdaRow which can hold @count #GdaValue.
  *
  * Returns: the newly allocated #GdaRow.
  */
@@ -41,16 +42,13 @@
 gda_row_new (gint count)
 {
 	GdaRow *row = NULL;
-	gint i;
 
 	g_return_val_if_fail (count >= 0, NULL);
 
 	row = g_new0 (GdaRow, 1);
 	row->id = NULL;
-	for (i = 0; i < count; i++) {
-		GdaField *field = gda_field_new ();
-		row->fields = g_list_append (row->fields, field);
-	}
+	row->nfields = count;
+	row->fields = g_new0 (GdaValue, count);
 
 	return row;
 }
@@ -64,17 +62,20 @@
 void
 gda_row_free (GdaRow *row)
 {
+	gint i;
+	
 	g_return_if_fail (row != NULL);
 
 	g_free (row->id);
-	g_list_foreach (row->fields, (GFunc) gda_field_free, NULL);
-	g_list_free (row->fields);
+	for (i = 0; i < row->nfields; i++)
+		gda_value_set_null (&row->fields [i]);
+	g_free (row->fields);
 	g_free (row);
 }
 
 /**
  * gda_row_get_id
- * @row: a #GdaRow (which contains #GdaField).
+ * @row: a #GdaRow (which contains #GdaValue).
  *
  * Return the unique identifier for this row. This identifier is
  * assigned by the different providers, to uniquely identify
@@ -94,7 +95,7 @@
 
 /**
  * gda_row_set_id
- * @row: A #GdaRow (which contains #GdaField).
+ * @row: A #GdaRow (which contains #GdaValue).
  * @id: New identifier for the row.
  *
  * Assign a new identifier to the given row. This function is
@@ -111,96 +112,33 @@
 }
 
 /**
- * gda_row_get_field
- * @row: a #GdaRow (which contains #GdaField).
+ * gda_row_get_value
+ * @row: a #GdaRow (which contains #GdaValue).
  * @num: field index.
  *
- * Gets a pointer to a #GdaField stored in a #GdaRow.
+ * Gets a pointer to a #GdaValue stored in a #GdaRow.
  * 
- * Returns: a pointer to the #GdaField in the position @num of @row.
+ * Returns: a pointer to the #GdaValue in the position @num of @row.
  */
-GdaField *
-gda_row_get_field (GdaRow *row, gint num)
+GdaValue *
+gda_row_get_value (GdaRow *row, gint num)
 {
-	GList *l;
-
 	g_return_val_if_fail (row != NULL, NULL);
-	g_return_val_if_fail (num >= 0, NULL);
-
-	l = g_list_nth (row->fields, num);
-	return l ? (GdaField *) l->data : NULL;
-}
-
-/**
- * gda_row_attributes_new
- * @count: number of #GdaRowAttributes to allocate.
- *
- * Creates a new #GdaRowAttributes which can hold up to @count attributes.
- *
- * Returns: a pointer to the newly allocated row attributes.
- */
-GdaRowAttributes *
-gda_row_attributes_new (gint count)
-{
-	GdaRowAttributes *attrs = NULL;
-	gint i;
-
-	g_return_val_if_fail (count >= 0, NULL);
-
-	for (i = 0; i < count; i++) {
-		GdaFieldAttributes *fa;
-
-		fa = gda_field_attributes_new ();
-		attrs = g_list_append (attrs, fa);
-	}
+	g_return_val_if_fail (num >= 0 && num < row->nfields, NULL);
 
-	return attrs;
+	return &row->fields[num];
 }
 
 /**
- * gda_row_attributes_free
- * @attrs: a #GdaRowAttributes.
+ * gda_row_get_length
+ * @row: a #GdaRow
  *
- * Deallocates the memory associated with @attrs.
- */
-void
-gda_row_attributes_free (GdaRowAttributes *attrs)
-{
-	g_return_if_fail (attrs != NULL);
-
-	g_list_foreach (attrs, (GFunc) gda_field_attributes_free, NULL);
-	g_list_free (attrs);
-}
-
-/**
- * gda_row_attributes_get_length
+ * Gets the number of columns that the row has.
  */
 gint
-gda_row_attributes_get_length (GdaRowAttributes *attrs)
+gda_row_get_length (GdaRow *row)
 {
-	return g_list_length (attrs);
+	g_return_val_if_fail (row != NULL, 0);
+	return row->nfields;
 }
 
-/**
- * gda_row_attributes_get_field
- * @attrs: a #GdaRowAttributes.
- * @num: an index into @attrs.
- *
- * Returns: the @num'th @GdafieldAttributes in @attrs.
- */
-GdaFieldAttributes *
-gda_row_attributes_get_field (GdaRowAttributes *attrs, gint num)
-{
-	GList *l;
-	gint length;
-
-	g_return_val_if_fail (attrs != NULL, NULL);
-	g_return_val_if_fail (num >= 0, NULL);
-
-	length = g_list_length (attrs);
-	if (num < 0 || num >= length)
-		return NULL;
-
-	l = g_list_nth (attrs, num);
-	return l ? (GdaFieldAttributes *) l->data : NULL;
-}
Index: libgda/gda-row.h
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-row.h,v
retrieving revision 1.21
diff -u -r1.21 gda-row.h
--- libgda/gda-row.h	5 May 2002 01:47:54 -0000	1.21
+++ libgda/gda-row.h	12 May 2002 08:52:17 -0000
@@ -29,18 +29,13 @@
 G_BEGIN_DECLS
 
 typedef struct _GdaRow GdaRow;
-typedef GList GdaRowAttributes; /* a GList of GdaFieldAttributes */
 
 GdaRow             *gda_row_new (gint count);
 void                gda_row_free (GdaRow *row);
 const gchar        *gda_row_get_id (GdaRow *row);
 void                gda_row_set_id (GdaRow *row, const gchar *id);
-GdaField           *gda_row_get_field (GdaRow *row, gint num);
-
-GdaRowAttributes   *gda_row_attributes_new (gint count);
-void                gda_row_attributes_free (GdaRowAttributes *attrs);
-gint                gda_row_attributes_get_length (GdaRowAttributes *attrs);
-GdaFieldAttributes *gda_row_attributes_get_field (GdaRowAttributes *attrs, gint num);
+GdaValue           *gda_row_get_value (GdaRow *row, gint num);
+gint		    gda_row_get_length (GdaRow *row);
 
 G_END_DECLS
 
Index: libgda/gda-table.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-table.c,v
retrieving revision 1.6
diff -u -r1.6 gda-table.c
--- libgda/gda-table.c	22 Apr 2002 22:01:33 -0000	1.6
+++ libgda/gda-table.c	12 May 2002 08:52:17 -0000
@@ -199,6 +199,7 @@
 
 		fa = gda_data_model_describe_column (GDA_DATA_MODEL (model), n);
 		gda_table_add_field (table, (const GdaFieldAttributes *) fa);
+		gda_field_attributes_free (fa);
 	}
 
 	/* add the data */
Index: libgda/gda-table.h
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-table.h,v
retrieving revision 1.3
diff -u -r1.3 gda-table.h
--- libgda/gda-table.h	4 Apr 2002 15:36:23 -0000	1.3
+++ libgda/gda-table.h	12 May 2002 08:52:17 -0000
@@ -23,7 +23,7 @@
 #if !defined(__gda_table_h__)
 #  define __gda_table_h__
 
-#include <libgda/gda-recordset.h>
+#include <libgda/gda-data-model-array.h>
 #include <libgda/gda-row.h>
 
 G_BEGIN_DECLS
Index: libgda/libgda.h
===================================================================
RCS file: /cvs/gnome/libgda/libgda/libgda.h,v
retrieving revision 1.13
diff -u -r1.13 libgda.h
--- libgda/libgda.h	4 May 2002 16:39:36 -0000	1.13
+++ libgda/libgda.h	12 May 2002 08:52:17 -0000
@@ -38,7 +38,6 @@
 #include <libgda/gda-log.h>
 #include <libgda/gda-parameter.h>
 #include <libgda/gda-quark-list.h>
-#include <libgda/gda-recordset.h>
 #include <libgda/gda-row.h>
 #include <libgda/gda-table.h>
 #include <libgda/gda-util.h>
Index: providers/default/gda-default-recordset.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/default/gda-default-recordset.c,v
retrieving revision 1.5
diff -u -r1.5 gda-default-recordset.c
--- providers/default/gda-default-recordset.c	22 Apr 2002 22:01:35 -0000	1.5
+++ providers/default/gda-default-recordset.c	12 May 2002 08:52:17 -0000
@@ -31,13 +31,13 @@
  */
 
 static GdaRow *
-fetch_func (GdaRecordset *recset, gulong rownum)
+fetch_func (GdaDataModel *recset, gulong rownum)
 {
 	return NULL;
 }
 
-static GdaRowAttributes *
-describe_func (GdaRecordset *recset)
+static GdaFieldAttributes *
+describe_func (GdaDataModel *recset)
 {
 	return NULL;
 }
@@ -46,7 +46,7 @@
  * Public functions
  */
 
-GdaRecordset *
+GdaDataModel *
 gda_default_recordset_new (GdaConnection *cnc, DEFAULT_Recordset *drecset)
 {
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
Index: providers/default/gda-default-recordset.h
===================================================================
RCS file: /cvs/gnome/libgda/providers/default/gda-default-recordset.h,v
retrieving revision 1.3
diff -u -r1.3 gda-default-recordset.h
--- providers/default/gda-default-recordset.h	22 Apr 2002 22:01:35 -0000	1.3
+++ providers/default/gda-default-recordset.h	12 May 2002 08:52:17 -0000
@@ -25,12 +25,12 @@
 #  define __gda_default_recordset_h__
 
 #include <libgda/gda-connection.h>
-#include <libgda/gda-recordset.h>
+#include <libgda/gda-data-model-array.h>
 #include "gda-default.h"
 
 G_BEGIN_DECLS
 
-GdaRecordset *gda_default_recordset_new (GdaConnection *cnc, DEFAULT_Recordset *drecset);
+GdaDataModel *gda_default_recordset_new (GdaConnection *cnc, DEFAULT_Recordset *drecset);
 
 G_END_DECLS
 
Index: providers/mysql/gda-mysql-recordset.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/mysql/gda-mysql-recordset.c,v
retrieving revision 1.11
diff -u -r1.11 gda-mysql-recordset.c
--- providers/mysql/gda-mysql-recordset.c	10 May 2002 00:33:40 -0000	1.11
+++ providers/mysql/gda-mysql-recordset.c	12 May 2002 08:52:18 -0000
@@ -81,49 +81,44 @@
 		return NULL;
 
 	for (i = 0; i < field_count; i++) {
-		GdaField *field;
+		GdaValue *field;
 		gchar *thevalue;
 
-		field = gda_row_get_field (row, i);
-		gda_field_set_actual_size (field, lengths[i]);
-		gda_field_set_defined_size (field, mysql_fields[i].max_length);
-		gda_field_set_name (field, mysql_fields[i].name);
-		gda_field_set_scale (field, mysql_fields[i].decimals);
-		gda_field_set_gdatype (field, gda_mysql_type_to_gda (mysql_fields[i].type));
+		field = gda_row_get_value (row, i);
 
 		thevalue = mysql_row[i];
 
 		switch (mysql_fields[i].type) {
 		case FIELD_TYPE_DECIMAL :
 		case FIELD_TYPE_DOUBLE :
-			gda_field_set_double_value (field, atof (thevalue));
+			gda_value_set_double (field, atof (thevalue));
 			break;
 		case FIELD_TYPE_FLOAT :
-			gda_field_set_single_value (field, atof (thevalue));
+			gda_value_set_single (field, atof (thevalue));
 			break;
 		case FIELD_TYPE_LONG :
 		case FIELD_TYPE_YEAR :
-			gda_field_set_integer_value (field, atol (thevalue));
+			gda_value_set_integer (field, atol (thevalue));
 			break;
 		case FIELD_TYPE_LONGLONG :
 		case FIELD_TYPE_INT24 :
-			gda_field_set_bigint_value (field, atoll (thevalue));
+			gda_value_set_bigint (field, atoll (thevalue));
 			break;
 		case FIELD_TYPE_SHORT :
-			gda_field_set_smallint_value (field, atoi (thevalue));
+			gda_value_set_smallint (field, atoi (thevalue));
 			break;
 		case FIELD_TYPE_TINY :
-			gda_field_set_tinyint_value (field, atoi (thevalue));
+			gda_value_set_tinyint (field, atoi (thevalue));
 			break;
 		case FIELD_TYPE_TINY_BLOB :
 		case FIELD_TYPE_MEDIUM_BLOB :
 		case FIELD_TYPE_LONG_BLOB :
 		case FIELD_TYPE_BLOB :
-			gda_field_set_binary_value (field, thevalue, lengths[i]);
+			gda_value_set_binary (field, thevalue, lengths[i]);
 			break;
 		case FIELD_TYPE_VAR_STRING :
 		case FIELD_TYPE_STRING :
-			gda_field_set_string_value (field, thevalue ? thevalue : "");
+			gda_value_set_string (field, thevalue ? thevalue : "");
 			break;
 		case FIELD_TYPE_DATE :
 		case FIELD_TYPE_NULL :
@@ -133,10 +128,10 @@
 		case FIELD_TYPE_DATETIME :
 		case FIELD_TYPE_TIME :
 		case FIELD_TYPE_SET : /* FIXME */
-			gda_field_set_string_value (field, thevalue ? thevalue : "");
+			gda_value_set_string (field, thevalue ? thevalue : "");
 			break;
 		default :
-			gda_field_set_string_value (field, thevalue ? thevalue : "");
+			gda_value_set_string (field, thevalue ? thevalue : "");
 		}
 	}
 
@@ -205,7 +200,7 @@
 	gint fetched_rows;
 	gint i;
 	GdaRow *fields = NULL;
-	GdaField *f;
+	GdaValue *f;
 	GdaMysqlRecordset *recset = (GdaMysqlRecordset *) model;
 
 	g_return_val_if_fail (GDA_IS_MYSQL_RECORDSET (recset), NULL);
@@ -223,8 +218,8 @@
 		if (!fields)
 			return NULL;
 
-		f = gda_row_get_field (fields, col);
-		return (const GdaValue *) gda_field_get_value (f);
+		f = gda_row_get_value (fields, col);
+		return (const GdaValue *) f;
 	}
 
 	gda_data_model_freeze (GDA_DATA_MODEL (recset));
@@ -239,9 +234,8 @@
 
 	gda_data_model_thaw (GDA_DATA_MODEL (recset));
 
-	f = gda_row_get_field (fields, col);
-
-	return (const GdaValue *) gda_field_get_value (f);
+	f = gda_row_get_value (fields, col);
+	return (const GdaValue *) f;
 }
 
 static gboolean
Index: providers/postgres/gda-postgres-provider.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/postgres/gda-postgres-provider.c,v
retrieving revision 1.30
diff -u -r1.30 gda-postgres-provider.c
--- providers/postgres/gda-postgres-provider.c	10 May 2002 02:58:10 -0000	1.30
+++ providers/postgres/gda-postgres-provider.c	12 May 2002 08:52:18 -0000
@@ -24,6 +24,7 @@
 #include <config.h>
 #include <stdlib.h>
 #include <string.h>
+#include <libgda/gda-data-model-array.h>
 #include "gda-postgres.h"
 #include "gda-postgres-provider.h"
 
Index: providers/postgres/gda-postgres-recordset.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/postgres/gda-postgres-recordset.c,v
retrieving revision 1.19
diff -u -r1.19 gda-postgres-recordset.c
--- providers/postgres/gda-postgres-recordset.c	12 May 2002 00:05:58 -0000	1.19
+++ providers/postgres/gda-postgres-recordset.c	12 May 2002 08:52:18 -0000
@@ -33,7 +33,7 @@
 #undef PARENT_TYPE
 #endif
 
-#define PARENT_TYPE GDA_TYPE_DATA_MODEL_ARRAY
+#define PARENT_TYPE GDA_TYPE_DATA_MODEL_HASH
 
 struct _GdaPostgresRecordsetPrivate {
 	PGresult *pg_res;
@@ -111,12 +111,11 @@
 static GdaValueType *
 get_column_types (GdaPostgresRecordsetPrivate *priv)
 {
-	gint i, ncols;
+	gint i;
 	GdaValueType *types;
 
-	ncols = PQnfields (priv->pg_res);
-	types = g_new (GdaValueType, ncols);
-	for (i = 0; i < ncols; i++)
+	types = g_new (GdaValueType, priv->ncolumns);
+	for (i = 0; i < priv->ncolumns; i++)
 		types [i] = gda_postgres_type_oid_to_gda (priv->type_data,
 							  priv->ntypes, 
 							  PQftype (priv->pg_res, i));
@@ -124,27 +123,25 @@
 	return types;
 }
 
-static GList *
-get_row (GdaPostgresRecordsetPrivate *priv, gint row)
+static GdaRow *
+get_row (GdaPostgresRecordsetPrivate *priv, gint rownum)
 {
 	gchar *thevalue;
 	GdaValueType ftype;
 	gboolean isNull;
 	GdaValue *value;
+	GdaRow *row;
 	gint i;
-	GList *row_list = NULL;
-
+	
+	row = gda_row_new (priv->ncolumns);
 	for (i = 0; i < priv->ncolumns; i++) {
-		thevalue = PQgetvalue(priv->pg_res, row, i);
+		thevalue = PQgetvalue(priv->pg_res, rownum, i);
 		ftype = priv->column_types [i];
-		isNull = *thevalue != '\0' ? FALSE : PQgetisnull (priv->pg_res, row, i);
-		value = gda_value_new_null ();
-
+		isNull = *thevalue != '\0' ? FALSE : PQgetisnull (priv->pg_res, rownum, i);
+		value = gda_row_get_value (row, i);
 		gda_postgres_set_value (value, ftype, thevalue, isNull);
-
-		row_list = g_list_append (row_list, value);
 	}
-	return row_list;
+	return row;
 }
 
 /*
@@ -156,18 +153,17 @@
 {
 	GdaPostgresRecordset *recset = (GdaPostgresRecordset *) model;
 	GdaPostgresRecordsetPrivate *priv_data;
-	gint field_count;
 	gint row_count;
 	PGresult *pg_res;
-	gint current_row, fetched_rows;
-	GList *row_list;
+	GdaRow *row_list;
+	const GdaValue *value;
 
 	g_return_val_if_fail (GDA_IS_POSTGRES_RECORDSET (recset), NULL);
 	g_return_val_if_fail (recset->priv != NULL, 0);
 	
-	fetched_rows = GDA_DATA_MODEL_CLASS (parent_class)->get_n_rows (model);
-	if (row >= 0 && row < fetched_rows)
-		return GDA_DATA_MODEL_CLASS (parent_class)->get_value_at (model, col, row);
+	value = gda_data_model_hash_get_value_at (model, col, row);
+	if (value != NULL)
+		return value;
 
 	priv_data = recset->priv;
 	pg_res = priv_data->pg_res;
@@ -178,7 +174,6 @@
 	}
 
 	row_count = priv_data->nrows;
-	field_count = priv_data->ncolumns;
 
 	if (row == row_count)
 		return NULL; // For the last row don't add an error.
@@ -189,19 +184,15 @@
 		return NULL;
 	}
 
-	if (col >= field_count) {
+	if (col >= priv_data->ncolumns) {
 		gda_connection_add_error_string (priv_data->cnc,
 						_("Column number out of range"));
 		return NULL;
 	}
 
-	for (current_row = fetched_rows; current_row <= row; current_row++){
-		row_list = get_row (priv_data, current_row);
-		gda_data_model_append_row (GDA_DATA_MODEL (model), row_list);
-		g_list_foreach (row_list, (GFunc) gda_value_free, NULL);
-	}
-
-	return GDA_DATA_MODEL_CLASS (parent_class)->get_value_at (model, col, row);
+	row_list = get_row (priv_data, row);
+	gda_data_model_hash_insert_row (model, row, row_list);
+	return gda_data_model_hash_get_value_at (model, col, row);
 }
 
 static GdaFieldAttributes *
@@ -210,7 +201,6 @@
 	GdaPostgresRecordset *recset = (GdaPostgresRecordset *) model;
 	GdaPostgresRecordsetPrivate *priv_data;
 	PGresult *pg_res;
-	gint field_count;
 	GdaValueType ftype;
 	gint scale;
 	GdaFieldAttributes *field_attrs;
@@ -226,8 +216,7 @@
 		return NULL;
 	}
 
-	field_count = PQnfields (pg_res);
-	if (col >= field_count){
+	if (col >= priv_data->ncolumns){
 		gda_connection_add_error_string (priv_data->cnc,
 						_("Column out of range"));
 		return NULL;
@@ -260,18 +249,11 @@
 gda_postgres_recordset_get_n_rows (GdaDataModel *model)
 {
 	GdaPostgresRecordset *recset = (GdaPostgresRecordset *) model;
-	GdaPostgresRecordsetPrivate *priv_data;
-	PGresult *pg_res;
 
-	g_return_val_if_fail (GDA_IS_DATA_MODEL (model), 0);
+	g_return_val_if_fail (GDA_IS_POSTGRES_RECORDSET (model), 0);
 	g_return_val_if_fail (recset->priv != NULL, 0);
 
-	priv_data = recset->priv;
-	pg_res = priv_data->pg_res;
-	if (!pg_res)
-		return 0;
-
-	return PQntuples (pg_res);
+	return recset->priv->nrows;
 }
 
 /*
@@ -320,7 +302,7 @@
 	model->priv->ncolumns = PQnfields (pg_res);
 	model->priv->nrows = PQntuples (pg_res);
 	model->priv->column_types = get_column_types (model->priv);
-	gda_data_model_array_set_n_columns (GDA_DATA_MODEL_ARRAY (model),
+	gda_data_model_hash_set_n_columns (GDA_DATA_MODEL_HASH (model),
 					    model->priv->ncolumns);
 
 	return GDA_DATA_MODEL (model);
Index: providers/postgres/gda-postgres-recordset.h
===================================================================
RCS file: /cvs/gnome/libgda/providers/postgres/gda-postgres-recordset.h,v
retrieving revision 1.5
diff -u -r1.5 gda-postgres-recordset.h
--- providers/postgres/gda-postgres-recordset.h	10 May 2002 02:58:10 -0000	1.5
+++ providers/postgres/gda-postgres-recordset.h	12 May 2002 08:52:18 -0000
@@ -26,7 +26,7 @@
 #if !defined(__gda_postgres_recordset_h__)
 #  define __gda_postgres_recordset_h__
 
-#include <libgda/gda-data-model-array.h>
+#include <libgda/gda-data-model-hash.h>
 #include <libgda/gda-value.h>
 #include <libpq-fe.h>
 
@@ -43,12 +43,12 @@
 typedef struct _GdaPostgresRecordsetPrivate GdaPostgresRecordsetPrivate;
 
 struct _GdaPostgresRecordset {
-	GdaDataModelArray model;
+	GdaDataModelHash model;
 	GdaPostgresRecordsetPrivate *priv;
 };
 
 struct _GdaPostgresRecordsetClass {
-	GdaDataModelArrayClass parent_class;
+	GdaDataModelHashClass parent_class;
 };
 
 GType          gda_postgres_recordset_get_type (void);
Index: providers/postgres/utils.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/postgres/utils.c,v
retrieving revision 1.23
diff -u -r1.23 utils.c
--- providers/postgres/utils.c	10 May 2002 18:12:44 -0000	1.23
+++ providers/postgres/utils.c	12 May 2002 08:52:18 -0000
@@ -142,11 +142,6 @@
 	GdaGeometricPoint point;
 	GdaNumeric numeric;
 
-	g_return_if_fail (value != NULL);
-	g_return_if_fail (thevalue != NULL);
-
-	//TODO: What do I do with BLOBs?
-
 	if (isNull){
 		gda_value_set_null (value);
 		return;
Index: testing/client.c
===================================================================
RCS file: /cvs/gnome/libgda/testing/client.c,v
retrieving revision 1.19
diff -u -r1.19 client.c
--- testing/client.c	1 May 2002 15:04:00 -0000	1.19
+++ testing/client.c	12 May 2002 08:52:19 -0000
@@ -118,6 +118,7 @@
 	/* Postgres own tests */
 	if (!strcmp (dsn_info->provider, POSTGRES_PROVIDER_NAME))
 		do_postgres_test (cnc);
+	gda_config_free_data_source_info (dsn_info);
 
 	/* close the connection */
 	gda_connection_close (cnc);
Index: testing/models.c
===================================================================
RCS file: /cvs/gnome/libgda/testing/models.c,v
retrieving revision 1.9
diff -u -r1.9 models.c
--- testing/models.c	10 May 2002 02:58:10 -0000	1.9
+++ testing/models.c	12 May 2002 08:52:19 -0000
@@ -96,6 +96,41 @@
 			g_free (strvalue);
 		}
 	}
+
+	/* Do it again. Just to measure the speed */
+	for (r = 0; r < rows; r++) {
+		for (c = 0; c < cols; c++) {
+			gda_data_model_get_column_title (model, c);
+		}
+	}
+}
+
+void
+test_speed_random (GdaDataModel *model)
+{
+	gint cols, rows;
+	gint i, c, r;
+	GRand *generator;
+	GTimer *timer;
+
+	cols = gda_data_model_get_n_columns (model);
+	rows = gda_data_model_get_n_rows (model);
+
+	g_print (" Testing access to values of data model %p, with %d columns and %d rows\n",
+		 model, cols, rows);
+
+	generator = g_rand_new ();
+	timer = g_timer_new ();
+	for (i = 0; i < 10000; i++) {
+		c = g_rand_int_range (generator, 0, cols);
+		r = g_rand_int_range (generator, 0, rows);
+		(void) gda_data_model_get_value_at (model, c, r);
+	}
+	g_timer_stop (timer);
+	g_print (" Elapsed time for fetching 10000 random values: %f\n",
+		 g_timer_elapsed (timer, NULL));
+	g_timer_destroy (timer);
+	g_rand_free (generator);
 }
 
 void
Index: testing/models.h
===================================================================
RCS file: /cvs/gnome/libgda/testing/models.h,v
retrieving revision 1.3
diff -u -r1.3 models.h
--- testing/models.h	14 Jan 2002 23:40:15 -0000	1.3
+++ testing/models.h	12 May 2002 08:52:19 -0000
@@ -27,6 +27,7 @@
 
 void display_recordset_data (GdaDataModel *model);
 void display_data_model (GdaDataModel *model);
+void test_speed_random (GdaDataModel *model);
 /* Main entry point for the data models test suite */
 void test_models (void);
 
Index: testing/postgres-test.c
===================================================================
RCS file: /cvs/gnome/libgda/testing/postgres-test.c,v
retrieving revision 1.4
diff -u -r1.4 postgres-test.c
--- testing/postgres-test.c	18 Jan 2002 23:38:18 -0000	1.4
+++ testing/postgres-test.c	12 May 2002 08:52:19 -0000
@@ -178,6 +178,14 @@
 	g_list_foreach (list, (GFunc) g_object_unref, NULL);
 	g_list_free (list);
 
+	/* Test random access speed */
+	list = select_data (cnc);
+
+	g_list_foreach (list, (GFunc) test_speed_random, NULL);
+	g_print ("-----------------\n");
+
+	g_list_foreach (list, (GFunc) g_object_unref, NULL);
+	g_list_free (list);
 	/* Clean up */
 	g_print ("\t\tDrop table: %s\n", drop_table (cnc) ? "OK" : "Error");
 }


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