From 19214534566aee77328d103ba3067880e16164f2 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Mon, 15 Dec 2014 20:32:51 -0500 Subject: [PATCH] LP#1400376: Don't allow NULL attrs to polute an HSTORE as a key That causes the HSTORE to blow up, which is bad for circs that want to succeed. Signed-off-by: Mike Rylander Signed-off-by: Ben Shum --- Open-ILS/src/sql/Pg/030.schema.metabib.sql | 5 ++++- .../src/sql/Pg/upgrade/XXXX.schema.no-null-record_attrs.sql | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.schema.no-null-record_attrs.sql diff --git a/Open-ILS/src/sql/Pg/030.schema.metabib.sql b/Open-ILS/src/sql/Pg/030.schema.metabib.sql index c03868ed36..58729d8f29 100644 --- a/Open-ILS/src/sql/Pg/030.schema.metabib.sql +++ b/Open-ILS/src/sql/Pg/030.schema.metabib.sql @@ -421,7 +421,10 @@ CREATE VIEW metabib.record_attr_flat AS LEFT JOIN config.coded_value_map c ON ( c.id = ANY( v.vlist ) ); CREATE VIEW metabib.record_attr AS - SELECT id, HSTORE( ARRAY_AGG( attr ), ARRAY_AGG( value ) ) AS attrs FROM metabib.record_attr_flat GROUP BY 1; + SELECT id, HSTORE( ARRAY_AGG( attr ), ARRAY_AGG( value ) ) AS attrs + FROM metabib.record_attr_flat + WHERE attr IS NOT NULL + GROUP BY 1; -- Back-back-compat view ... we use to live in an HSTORE world CREATE TYPE metabib.rec_desc_type AS ( diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.no-null-record_attrs.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.no-null-record_attrs.sql new file mode 100644 index 0000000000..ee7f30572a --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.no-null-record_attrs.sql @@ -0,0 +1,10 @@ +BEGIN; + +CREATE OR REPLACE VIEW metabib.record_attr AS + SELECT id, HSTORE( ARRAY_AGG( attr ), ARRAY_AGG( value ) ) AS attrs + FROM metabib.record_attr_flat + WHERE attr IS NOT NULL + GROUP BY 1; + +COMMIT; + -- 2.11.0