[Fusionforge-commits] r14585 - in branches/Branch_5_1: . src/common/search src/db src/deb-specific

Roland Mas lolando at fusionforge.org
Sun Oct 9 14:30:34 CEST 2011


Author: lolando
Date: 2011-10-09 14:30:34 +0200 (Sun, 09 Oct 2011)
New Revision: 14585

Added:
   branches/Branch_5_1/src/db/20111009-string-aggregate-function.sql
Modified:
   branches/Branch_5_1/
   branches/Branch_5_1/src/common/search/ArtifactSearchQuery.class.php
   branches/Branch_5_1/src/common/search/TasksSearchQuery.class.php
   branches/Branch_5_1/src/common/search/TrackersSearchQuery.class.php
   branches/Branch_5_1/src/deb-specific/db-upgrade.pl
Log:
PostgreSQL < 9.0 does not have a built-in string_agg() function

Modified: branches/Branch_5_1/src/common/search/ArtifactSearchQuery.class.php
===================================================================
--- branches/Branch_5_1/src/common/search/ArtifactSearchQuery.class.php	2011-10-09 11:26:07 UTC (rev 14584)
+++ branches/Branch_5_1/src/common/search/ArtifactSearchQuery.class.php	2011-10-09 12:30:34 UTC (rev 14585)
@@ -67,8 +67,8 @@
 		$words = $this->getFTIwords();
 
 		$qpa = db_construct_qpa ($qpa,
-					 'SELECT x.* FROM (SELECT artifact.artifact_id, artifact.group_artifact_id, artifact.summary, artifact.open_date, users.realname, artifact.summary||$1||artifact.details||$1||coalesce(string_agg(artifact_message.body, $1), $2) as full_string_agg',
-						 array ($this->field_separator, ' '));
+					 'SELECT x.* FROM (SELECT artifact.artifact_id, artifact.group_artifact_id, artifact.summary, artifact.open_date, users.realname, artifact.summary||$1||artifact.details||$1||coalesce(ff_string_agg(artifact_message.body), $1) as full_string_agg',
+						 array (''));
 		if (forge_get_config('use_fti')) {
 			$qpa = db_construct_qpa ($qpa,
 						 ', (artifact_idx.vectors || coalesce(ff_tsvector_agg(artifact_message_idx.vectors), $1::tsvector)) AS full_vector_agg',
@@ -138,9 +138,8 @@
 						 'SELECT a.group_artifact_id, a.artifact_id, ts_headline(summary, $1) AS summary, ',
 						 array ($words)) ;
 			$qpa = db_construct_qpa ($qpa,
-						 'a.open_date, users.realname, rank FROM (SELECT a.artifact_id, SUM (ts_rank(ai.vectors, q) + ts_rank(ami.vectors, q)) AS rank, artifact.summary||$1||artifact.details||$1||coalesce(string_agg(artifact_message.body, $1), $2) as full_string_agg FROM artifact a LEFT OUTER JOIN artifact_message am USING (artifact_id)',
-						 array($this->field_separator,
-						       '')) ;
+						 'a.open_date, users.realname, rank FROM (SELECT a.artifact_id, SUM (ts_rank(ai.vectors, q) + ts_rank(ami.vectors, q)) AS rank, artifact.summary||$1||artifact.details||$1||coalesce(ff_string_agg(artifact_message.body), $1) as full_string_agg FROM artifact a LEFT OUTER JOIN artifact_message am USING (artifact_id)',
+						 array('')) ;
 
 			$qpa = db_construct_qpa ($qpa,
 						 ', artifact_idx ai, artifact_message_idx ami, to_tsquery($1) q',

Modified: branches/Branch_5_1/src/common/search/TasksSearchQuery.class.php
===================================================================
--- branches/Branch_5_1/src/common/search/TasksSearchQuery.class.php	2011-10-09 11:26:07 UTC (rev 14584)
+++ branches/Branch_5_1/src/common/search/TasksSearchQuery.class.php	2011-10-09 12:30:34 UTC (rev 14585)
@@ -68,8 +68,8 @@
 		$qpa = db_construct_qpa () ;
 
 		$qpa = db_construct_qpa ($qpa,
-					 'SELECT x.* FROM (SELECT project_task.project_task_id, project_task.summary, project_task.percent_complete, project_task.start_date, project_task.end_date, users.realname, project_group_list.project_name, project_task.summary||$1||project_task.details||$1||coalesce(string_agg(project_messages.body, $1), $2) as full_string_agg',
-					 array ($this->field_separator, ' '));
+					 'SELECT x.* FROM (SELECT project_task.project_task_id, project_task.summary, project_task.percent_complete, project_task.start_date, project_task.end_date, users.realname, project_group_list.project_name, project_task.summary||$1||project_task.details||$1||coalesce(ff_string_agg(project_messages.body), $1) as full_string_agg',
+					 array (''));
 		if (forge_get_config('use_fti')) {
 			$words = $this->getFTIwords();
 			$qpa = db_construct_qpa ($qpa,

Modified: branches/Branch_5_1/src/common/search/TrackersSearchQuery.class.php
===================================================================
--- branches/Branch_5_1/src/common/search/TrackersSearchQuery.class.php	2011-10-09 11:26:07 UTC (rev 14584)
+++ branches/Branch_5_1/src/common/search/TrackersSearchQuery.class.php	2011-10-09 12:30:34 UTC (rev 14585)
@@ -68,8 +68,8 @@
 		$qpa = db_construct_qpa () ;
 
 		$qpa = db_construct_qpa ($qpa,
-					 'SELECT x.* FROM (SELECT artifact.artifact_id, artifact.group_artifact_id, artifact.summary, artifact.open_date, users.realname, artifact_group_list.name, artifact.summary||$1||artifact.details||$1||coalesce(string_agg(artifact_message.body, $1), $2) as full_string_agg',
-						 array ($this->field_separator, ' '));
+					 'SELECT x.* FROM (SELECT artifact.artifact_id, artifact.group_artifact_id, artifact.summary, artifact.open_date, users.realname, artifact_group_list.name, artifact.summary||$1||artifact.details||$1||coalesce(ff_string_agg(artifact_message.body), $1) as full_string_agg',
+						 array (''));
 		if (forge_get_config('use_fti')) {
 			$words = $this->getFTIwords();
 			$qpa = db_construct_qpa ($qpa,

Added: branches/Branch_5_1/src/db/20111009-string-aggregate-function.sql
===================================================================
--- branches/Branch_5_1/src/db/20111009-string-aggregate-function.sql	                        (rev 0)
+++ branches/Branch_5_1/src/db/20111009-string-aggregate-function.sql	2011-10-09 12:30:34 UTC (rev 14585)
@@ -0,0 +1,16 @@
+CREATE OR REPLACE FUNCTION ff_string_add (t1 text, t2 text)
+RETURNS text
+AS $$
+BEGIN
+  RETURN t1 || ' ioM0Thu6_fieldseparator_kaeph9Ee ' || t2 ;
+END;
+$$ LANGUAGE plpgsql
+IMMUTABLE
+RETURNS NULL ON NULL INPUT;
+
+DROP AGGREGATE IF EXISTS ff_string_agg (text);
+CREATE AGGREGATE ff_string_agg (
+       basetype = text,
+       sfunc = ff_string_add,
+       stype = text
+);

Modified: branches/Branch_5_1/src/deb-specific/db-upgrade.pl
===================================================================
--- branches/Branch_5_1/src/deb-specific/db-upgrade.pl	2011-10-09 11:26:07 UTC (rev 14584)
+++ branches/Branch_5_1/src/deb-specific/db-upgrade.pl	2011-10-09 12:30:34 UTC (rev 14585)
@@ -1956,6 +1956,7 @@
     &update_with_sql("FTI-20061025","5.1-8");
     &update_with_sql("20111007-fti-aggregate-functions","5.1-9");
     &update_with_sql("20111007-add-fti-for-task-messages","5.1-10");
+    &update_with_sql("20111009-string-aggregate-function","5.1-11");
 
     ########################### INSERT HERE #################################
 




More information about the Fusionforge-commits mailing list