[open-ils-commits] r18369 - in branches/rel_1_6_1/Open-ILS/src: perlmods/OpenILS/Application perlmods/OpenILS/Application/Storage/Publisher sql/Pg (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Sat Oct 16 11:49:15 EDT 2010
Author: miker
Date: 2010-10-16 11:49:12 -0400 (Sat, 16 Oct 2010)
New Revision: 18369
Modified:
branches/rel_1_6_1/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm
branches/rel_1_6_1/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
branches/rel_1_6_1/Open-ILS/src/sql/Pg/002.functions.config.sql
branches/rel_1_6_1/Open-ILS/src/sql/Pg/040.schema.asset.sql
branches/rel_1_6_1/Open-ILS/src/sql/Pg/1.6.1.2-1.6.1.3-upgrade-db.sql
Log:
Backport oils_text_as_bytea work from the 1.6 branch
Modified: branches/rel_1_6_1/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm
===================================================================
--- branches/rel_1_6_1/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm 2010-10-16 15:46:43 UTC (rev 18368)
+++ branches/rel_1_6_1/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm 2010-10-16 15:49:12 UTC (rev 18369)
@@ -230,9 +230,9 @@
$table cn
where
not deleted
- and (cast(upper(label) as bytea) > ? or ( cn.id > ? and cast(upper(label) as bytea) = ? ))
+ and (oils_text_as_bytea(upper(label)) > ? or ( cn.id > ? and oils_text_as_bytea(upper(label)) = ? ))
and owning_lib in ($orgs)
- order by cast(upper(label) as bytea), 4, 2
+ order by oils_text_as_bytea(upper(label)), 4, 2
limit $size;
SQL
@@ -285,9 +285,9 @@
$table cn
where
not deleted
- and (cast(upper(label) as bytea) < ? or ( cn.id < ? and cast(upper(label) as bytea) = ? ))
+ and (oils_text_as_bytea(upper(label)) < ? or ( cn.id < ? and oils_text_as_bytea(upper(label)) = ? ))
and owning_lib in ($orgs)
- order by cast(upper(label) as bytea) desc, 4 desc, 2 desc
+ order by oils_text_as_bytea(upper(label)) desc, 4 desc, 2 desc
limit $size
) as bar
order by 1,4,2;
@@ -343,9 +343,9 @@
$table cn
where
not deleted
- and cast(upper(label) as bytea) < ?
+ and oils_text_as_bytea(upper(label)) < ?
and owning_lib in ($orgs)
- order by cast(upper(label) as bytea) desc, 4 desc, 2 desc
+ order by oils_text_as_bytea(upper(label)) desc, 4 desc, 2 desc
limit $topsize
) as bar
order by 1,4,2;
@@ -361,9 +361,9 @@
$table cn
where
not deleted
- and cast(upper(label) as bytea) >= ?
+ and oils_text_as_bytea(upper(label)) >= ?
and owning_lib in ($orgs)
- order by cast(upper(label) as bytea),4,2
+ order by oils_text_as_bytea(upper(label)),4,2
limit $bottomsize;
SQL
Modified: branches/rel_1_6_1/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
===================================================================
--- branches/rel_1_6_1/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm 2010-10-16 15:46:43 UTC (rev 18368)
+++ branches/rel_1_6_1/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm 2010-10-16 15:49:12 UTC (rev 18369)
@@ -287,7 +287,7 @@
},
{ flesh => 1,
flesh_fields => { acn => [qw/record owning_lib/] },
- order_by => { acn => "cast(upper(label) as bytea) desc, id desc, owning_lib desc" },
+ order_by => { acn => "oils_text_as_bytea(upper(label)) desc, id desc, owning_lib desc" },
limit => $before_limit,
offset => abs($page) * $page_size - $before_offset,
}
@@ -304,7 +304,7 @@
},
{ flesh => 1,
flesh_fields => { acn => [qw/record owning_lib/] },
- order_by => { acn => "cast(upper(label) as bytea), id, owning_lib" },
+ order_by => { acn => "oils_text_as_bytea(upper(label)), id, owning_lib" },
limit => $after_limit,
offset => abs($page) * $page_size - $after_offset,
}
Modified: branches/rel_1_6_1/Open-ILS/src/sql/Pg/002.functions.config.sql
===================================================================
--- branches/rel_1_6_1/Open-ILS/src/sql/Pg/002.functions.config.sql 2010-10-16 15:46:43 UTC (rev 18368)
+++ branches/rel_1_6_1/Open-ILS/src/sql/Pg/002.functions.config.sql 2010-10-16 15:49:12 UTC (rev 18369)
@@ -120,5 +120,9 @@
SELECT SUBSTRING( $1 FROM $_$^\S+$_$);
$$ LANGUAGE SQL;
+CREATE OR REPLACE FUNCTION oils_text_as_bytea (TEXT) RETURNS BYTEA AS $_$
+ SELECT CAST(REGEXP_REPLACE($1, $$\\$$, $$\\\\$$, 'g') AS BYTEA);
+$_$ LANGUAGE SQL IMMUTABLE;
+
COMMIT;
Modified: branches/rel_1_6_1/Open-ILS/src/sql/Pg/040.schema.asset.sql
===================================================================
--- branches/rel_1_6_1/Open-ILS/src/sql/Pg/040.schema.asset.sql 2010-10-16 15:46:43 UTC (rev 18368)
+++ branches/rel_1_6_1/Open-ILS/src/sql/Pg/040.schema.asset.sql 2010-10-16 15:49:12 UTC (rev 18369)
@@ -156,7 +156,7 @@
CREATE INDEX asset_call_number_creator_idx ON asset.call_number (creator);
CREATE INDEX asset_call_number_editor_idx ON asset.call_number (editor);
CREATE INDEX asset_call_number_dewey_idx ON asset.call_number (public.call_number_dewey(label));
-CREATE INDEX asset_call_number_upper_label_id_owning_lib_idx ON asset.call_number (cast(upper(label) as bytea),id,owning_lib);
+CREATE INDEX asset_call_number_upper_label_id_owning_lib_idx ON asset.call_number (oils_text_as_bytea(upper(label)),id,owning_lib);
CREATE UNIQUE INDEX asset_call_number_label_once_per_lib ON asset.call_number (record, owning_lib, label) WHERE deleted IS FALSE;
CREATE RULE protect_cn_delete AS ON DELETE TO asset.call_number DO INSTEAD UPDATE asset.call_number SET deleted = TRUE WHERE OLD.id = asset.call_number.id;
Modified: branches/rel_1_6_1/Open-ILS/src/sql/Pg/1.6.1.2-1.6.1.3-upgrade-db.sql
===================================================================
--- branches/rel_1_6_1/Open-ILS/src/sql/Pg/1.6.1.2-1.6.1.3-upgrade-db.sql 2010-10-16 15:46:43 UTC (rev 18368)
+++ branches/rel_1_6_1/Open-ILS/src/sql/Pg/1.6.1.2-1.6.1.3-upgrade-db.sql 2010-10-16 15:49:12 UTC (rev 18369)
@@ -1,7 +1,11 @@
BEGIN;
+CREATE OR REPLACE FUNCTION oils_text_as_bytea (TEXT) RETURNS BYTEA AS $_$
+ SELECT CAST(REGEXP_REPLACE($1, $$\\$$, $$\\\\$$, 'g') AS BYTEA);
+$_$ LANGUAGE SQL IMMUTABLE;
+
DROP INDEX asset.asset_call_number_upper_label_id_owning_lib_idx;
-CREATE INDEX asset_call_number_upper_label_id_owning_lib_idx ON asset.call_number (cast(upper(label) as bytea),id,owning_lib);
+CREATE INDEX asset_call_number_upper_label_id_owning_lib_idx ON asset.call_number (oils_text_as_bytea(upper(label)),id,owning_lib);
COMMIT;
More information about the open-ils-commits
mailing list