Found a few last functions that need changing to native SQL
authorBen Shum <bshum@biblio.org>
Fri, 7 Feb 2014 06:18:08 +0000 (01:18 -0500)
committerDan Scott <dscott@laurentian.ca>
Fri, 7 Feb 2014 22:00:22 +0000 (17:00 -0500)
These new uses probably went in more recently as authority fixes. Updated them to
use the native functions as well.

Signed-off-by: Ben Shum <bshum@biblio.org>
Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/sql/Pg/011.schema.authority.sql
Open-ILS/src/sql/Pg/030.schema.metabib.sql

index 9892495..d40bf31 100644 (file)
@@ -702,7 +702,7 @@ CREATE OR REPLACE FUNCTION authority.axis_authority_tags_refs(a TEXT) RETURNS IN
     SELECT ARRAY_AGG(y) from (
        SELECT  unnest(ARRAY_CAT(
                  ARRAY[a.field],
-                 (SELECT ARRAY_ACCUM(x.id) FROM authority.control_set_authority_field x WHERE x.main_entry = a.field)
+                 (SELECT ARRAY_AGG(x.id) FROM authority.control_set_authority_field x WHERE x.main_entry = a.field)
              )) y
        FROM  authority.browse_axis_authority_field_map a
        WHERE axis = $1) x
@@ -718,7 +718,7 @@ CREATE OR REPLACE FUNCTION authority.btag_authority_tags_refs(btag TEXT) RETURNS
     SELECT ARRAY_AGG(y) from (
         SELECT  unnest(ARRAY_CAT(
                     ARRAY[a.authority_field],
-                    (SELECT ARRAY_ACCUM(x.id) FROM authority.control_set_authority_field x WHERE x.main_entry = a.authority_field)
+                    (SELECT ARRAY_AGG(x.id) FROM authority.control_set_authority_field x WHERE x.main_entry = a.authority_field)
                 )) y
       FROM  authority.control_set_bib_field a
       WHERE a.tag = $1) x
@@ -733,7 +733,7 @@ CREATE OR REPLACE FUNCTION authority.atag_authority_tags_refs(atag TEXT) RETURNS
     SELECT ARRAY_AGG(y) from (
         SELECT  unnest(ARRAY_CAT(
                     ARRAY[a.id],
-                    (SELECT ARRAY_ACCUM(x.id) FROM authority.control_set_authority_field x WHERE x.main_entry = a.id)
+                    (SELECT ARRAY_AGG(x.id) FROM authority.control_set_authority_field x WHERE x.main_entry = a.id)
                 )) y
       FROM  authority.control_set_authority_field a
       WHERE a.tag = $1) x
index a163d0d..4e1d445 100644 (file)
@@ -1922,7 +1922,7 @@ BEGIN
         -- Gather aggregate data based on the MBE row we're looking at now, authority axis
         SELECT INTO all_arecords, result_row.sees, afields
                 ARRAY_AGG(DISTINCT abl.bib), -- bibs to check for visibility
-                ARRAY_TO_STRING(ARRAY_AGG(DISTINCT aal.source), $$,$$), -- authority record ids
+                STRING_AGG(DISTINCT aal.source, $$,$$), -- authority record ids
                 ARRAY_AGG(DISTINCT map.metabib_field) -- authority-tag-linked CMF rows
 
           FROM  metabib.browse_entry_simple_heading_map mbeshm
@@ -1939,13 +1939,13 @@ BEGIN
         -- Gather aggregate data based on the MBE row we're looking at now, bib axis
         SELECT INTO all_brecords, result_row.authorities, bfields
                 ARRAY_AGG(DISTINCT source),
-                ARRAY_TO_STRING(ARRAY_AGG(DISTINCT authority), $$,$$),
+                STRING_AGG(DISTINCT authority, $$,$$),
                 ARRAY_AGG(DISTINCT def)
           FROM  metabib.browse_entry_def_map
           WHERE entry = rec.id
                 AND def = ANY(fields);
 
-        SELECT INTO result_row.fields ARRAY_TO_STRING(ARRAY_AGG(DISTINCT x), $$,$$) FROM UNNEST(afields || bfields) x;
+        SELECT INTO result_row.fields STRING_AGG(DISTINCT x, $$,$$) FROM UNNEST(afields || bfields) x;
 
         result_row.sources := 0;
         result_row.asources := 0;