[gnome-db] Patch to libgda 0.2.9x - postgres provider - schmea_aggregates



I have a patch for the postgres provider for libgda 0.2.9x.  Can someone
take a look at it or commit it to cvs for me please?

My modifications were done for the gnome-1-x-branch.

The patch is for bug 71484 which can be seen at: 
http://bugzilla.gnome.org/show_bug.cgi?id=71484

Here are the problems with schema_aggregates in
gda-postgres-connection.c:

1.  ORDER BY was incorrect.  This caused an error when calling
schema_attributes in any applications that connected to Postgres through
libgda, such as, gnomedb-fe and gASQL.
This error message was "ERROR:  Attribute 'aggname' not found".

Resolution: changed to ORDER BY 1,3

2.  For extra info, the constraint value being passed in, ie. 'avg' is
being compared to the object id of the aggregate 'a.oid'. This caused an
error message "ERROR: oidin: error in "avg": can't parse "avg"".

Resolution: in the WHERE clause for extra info, changed a.oid to
a.aggname.  The name of the aggregates was changed from a.aggname to
a.aggname || '(' || t.typname || ')' so it will be compared properly to
'avg(int4)'.  However, this causes the display in the listbox in
gnomedb-fe to display 'avg(int4)' now.

3. variable "gchar * and_condition" was being freed too early. 
This caused the extra information to lock up
gnomedb-fe/libgda/gda-postgres-srv and break the CORBA connection.
Error message shown: "an error occurred in the CORBA system".

Resolution: move the freeing of and_condition later on when its not used
anymore.

Can someone take a look it?

Thank you,
Daniel

Index: po/ChangeLog
===================================================================
RCS file: /cvs/gnome/libgda/po/ChangeLog,v
retrieving revision 1.74.2.32
diff -u -r1.74.2.32 ChangeLog
--- po/ChangeLog	2002/02/02 12:52:14	1.74.2.32
+++ po/ChangeLog	2002/02/18 14:20:27
@@ -1,3 +1,7 @@
+2002-02-18  gettextize  <bug-gnu-utils gnu org>
+
+	* Makefile.in.in: Upgrade to gettext-0.10.38.
+
 2002-02-02  Christophe Merlet  <redfox eikonex org>
 
 	* fr.po: Updated French translation from work of
Index: providers/gda-postgres-server/gda-postgres-connection.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/gda-postgres-server/Attic/gda-postgres-connection.c,v
retrieving revision 1.12
diff -u -r1.12 gda-postgres-connection.c
--- providers/gda-postgres-server/gda-postgres-connection.c	2001/07/18 23:05:40	1.12
+++ providers/gda-postgres-server/gda-postgres-connection.c	2002/02/18 14:20:32
@@ -1531,7 +1531,7 @@
 	GdaServerRecordset *recset = 0;
 	GDA_Connection_Constraint *ptr;
 	gint cnt;
-	GString *and_condition = 0;
+	GString *and_condition = 0, *and_condition2 = 0;
 	gulong affected;
 	gboolean extra_info = FALSE;
 
@@ -1544,18 +1544,30 @@
 			break;
 		case GDA_Connection_OBJECT_NAME:
 			if (!and_condition)
+			{
 				and_condition = g_string_new ("");
-			g_string_sprintfa (and_condition, "AND a.oid='%s' ",
+				and_condition2 = g_string_new ("");
+			}
+			g_string_sprintfa (and_condition, " AND a.aggname || '(' || t.typname || ')' = '%s' ",
 					   ptr->value);
+			g_string_sprintfa (and_condition2, " AND a2.aggname || '( )' = '%s' ",
+					   ptr->value);
+
 			fprintf (stderr,
 				 "schema_tables: aggregate name = '%s'\n",
 				 ptr->value);
 			break;
 		case GDA_Connection_OBJECT_SCHEMA:
 			if (!and_condition)
+			{
 				and_condition = g_string_new ("");
+				and_condition2 = g_string_new ("");
+			}
 			g_string_sprintfa (and_condition,
-					   "AND b.usename='%s' ", ptr->value);
+					   " AND b.usename='%s' ", ptr->value);
+			g_string_sprintfa (and_condition2,
+					   " AND b2.usename='%s' ", ptr->value);
+
 			fprintf (stderr,
 				 "schema_tables: table_schema = '%s'\n",
 				 ptr->value);
@@ -1577,7 +1589,7 @@
 
 	/* build the query: no difference between postgres versions. */
 	/* 1st: aggregates that work on a particular type */
-	query = g_string_new ("SELECT a.aggname AS \"Name\", "
+	query = g_string_new ("SELECT a.aggname || '(' || t.typname || ')' AS \"Name\", "
 			      "a.oid AS \"Object Id\", "
 			      "t.typname as \"IN Type\", ");
 	if (extra_info)
@@ -1592,30 +1604,30 @@
 			 "WHERE a.aggbasetype = t.oid AND b.usesysid=a.aggowner ");
 	if (and_condition) {
 		g_string_append (query, and_condition->str);
-		g_string_free (and_condition, TRUE);
 	}
 
 	/* 2nd: aggregates that work on any type */
 	g_string_append (query, " UNION ");
-	g_string_append (query, "SELECT a.aggname AS \"Name\", "
-			 "a.oid AS \"Object Id\", " "'---' as \"IN Type\", ");
+	g_string_append (query, " SELECT a2.aggname || '( )' AS \"Name\", "
+			 "a2.oid AS \"Object Id\", " "'---' as \"IN Type\", ");
 	if (extra_info)
-		g_string_append (query, "b.usename AS \"Owner\", "
-				 "obj_description(a.oid) AS \"Comments\", "
-				 "a.oid AS \"SQL\" ");
+		g_string_append (query, "b2.usename AS \"Owner\", "
+				 "obj_description(a2.oid) AS \"Comments\", "
+				 "a2.oid AS \"SQL\" ");
 	else
 		g_string_append (query,
-				 "obj_description(a.oid) AS \"Comments\" ");
+				 "obj_description(a2.oid) AS \"Comments\" ");
 
-	g_string_append (query, "FROM pg_aggregate a, pg_user b "
-			 "WHERE a.aggbasetype = 0 AND b.usesysid=a.aggowner ");
+	g_string_append (query, "FROM pg_aggregate a2, pg_user b2 "
+			 "WHERE a2.aggbasetype = 0 AND b2.usesysid=a2.aggowner ");
 	if (and_condition) {
-		g_string_append (query, and_condition->str);
+		g_string_append (query, and_condition2->str);
 		g_string_free (and_condition, TRUE);
+		g_string_free (and_condition2, TRUE);
 	}
 
 	/* then ordering */
-	g_string_append (query, "ORDER BY aggname, typname");
+	g_string_append (query, " ORDER BY 1, 3 ");
 
 	/* build the command object */
 	cmd = gda_server_command_new (cnc);


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