From 322cf4fad330ab6af909257d90cfec78e70a309b Mon Sep 17 00:00:00 2001 From: miker Date: Thu, 14 Oct 2010 19:33:41 +0000 Subject: [PATCH] backward compat indexing for label instead of label_sortkey git-svn-id: svn://svn.open-ils.org/ILS/trunk@18336 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../Application/Storage/Publisher/asset.pm | 16 ++++++++-------- Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/040.schema.asset.sql | 2 +- .../Pg/upgrade/0438.schema.bytea-index-label.sql | 9 +++++++++ 4 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0438.schema.bytea-index-label.sql diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm index 8f49f4b942..872a2adcc7 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm @@ -230,9 +230,9 @@ sub cn_browse_pagedown { $table cn where not deleted - and (upper(label) > ? or ( cn.id > ? and upper(label) = ? )) + and (cast(upper(label) to bytea) > ? or ( cn.id > ? and cast(upper(label) to bytea) = ? )) and owning_lib in ($orgs) - order by upper(label), 4, 2 + order by cast(upper(label) to bytea), 4, 2 limit $size; SQL @@ -285,9 +285,9 @@ sub cn_browse_pageup { $table cn where not deleted - and (upper(label) < ? or ( cn.id < ? and upper(label) = ? )) + and (cast(upper(label) to bytea) < ? or ( cn.id < ? and cast(upper(label) to bytea) = ? )) and owning_lib in ($orgs) - order by upper(label) desc, 4 desc, 2 desc + order by cast(upper(label) to bytea) desc, 4 desc, 2 desc limit $size ) as bar order by 1,4,2; @@ -343,9 +343,9 @@ sub cn_browse_target { $table cn where not deleted - and upper(label) < ? + and cast(upper(label) to bytea) < ? and owning_lib in ($orgs) - order by upper(label) desc, 4 desc, 2 desc + order by cast(upper(label) to bytea) desc, 4 desc, 2 desc limit $topsize ) as bar order by 1,4,2; @@ -361,9 +361,9 @@ sub cn_browse_target { $table cn where not deleted - and upper(label) >= ? + and cast(upper(label) to bytea) >= ? and owning_lib in ($orgs) - order by upper(label),4,2 + order by cast(upper(label) to bytea),4,2 limit $bottomsize; SQL diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 447c7f2f9b..58bc8fc41f 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -70,7 +70,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0437'); -- miker +INSERT INTO config.upgrade_log (version) VALUES ('0438'); -- miker CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql index 91878e0ee7..1b1f0c6e15 100644 --- a/Open-ILS/src/sql/Pg/040.schema.asset.sql +++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql @@ -293,7 +293,7 @@ CREATE INDEX asset_call_number_record_idx ON asset.call_number (record); 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 (upper(label),id,owning_lib); +CREATE INDEX asset_call_number_upper_label_id_owning_lib_idx ON asset.call_number (cast(upper(label) to bytea),id,owning_lib); CREATE INDEX asset_call_number_label_sortkey ON asset.call_number(cast(label_sortkey as bytea)); CREATE UNIQUE INDEX asset_call_number_label_once_per_lib ON asset.call_number (record, owning_lib, label) WHERE deleted = FALSE OR 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; diff --git a/Open-ILS/src/sql/Pg/upgrade/0438.schema.bytea-index-label.sql b/Open-ILS/src/sql/Pg/upgrade/0438.schema.bytea-index-label.sql new file mode 100644 index 0000000000..c0904b5c3b --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0438.schema.bytea-index-label.sql @@ -0,0 +1,9 @@ + +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0437'); -- miker + +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) to bytea),id,owning_lib); + +COMMIT; -- 2.43.2