install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0294'); -- phasefx
+INSERT INTO config.upgrade_log (version) VALUES ('0295'); -- gmcharlt
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
BEGIN RETURN 'AUTOGENERATED-' || nextval('biblio.autogen_tcn_value_seq'::TEXT); END;
$$ LANGUAGE PLPGSQL;
+CREATE OR REPLACE FUNCTION biblio.check_marcxml_well_formed () RETURNS TRIGGER AS $func$
+BEGIN
+
+ IF xml_is_well_formed(NEW.marc) THEN
+ RETURN NEW;
+ ELSE
+ RAISE EXCEPTION 'Attempted to % MARCXML that is not well formed', TG_OP;
+ END IF;
+
+END;
+$func$ LANGUAGE PLPGSQL;
+
CREATE TABLE biblio.record_entry (
id BIGSERIAL PRIMARY KEY,
creator INT NOT NULL DEFAULT 1,
CREATE INDEX biblio_record_entry_edit_date_idx ON biblio.record_entry ( edit_date );
CREATE INDEX biblio_record_entry_fp_idx ON biblio.record_entry ( fingerprint );
CREATE UNIQUE INDEX biblio_record_unique_tcn ON biblio.record_entry (tcn_value) WHERE deleted = FALSE OR deleted IS FALSE;
+CREATE TRIGGER a_marcxml_is_well_formed BEFORE INSERT OR UPDATE ON biblio.record_entry FOR EACH ROW EXECUTE PROCEDURE biblio.check_marcxml_well_formed();
CREATE TABLE biblio.record_note (
id BIGSERIAL PRIMARY KEY,
CREATE INDEX authority_record_entry_creator_idx ON authority.record_entry ( creator );
CREATE INDEX authority_record_entry_editor_idx ON authority.record_entry ( editor );
CREATE UNIQUE INDEX authority_record_unique_tcn ON authority.record_entry (arn_source,arn_value) WHERE deleted = FALSE OR deleted IS FALSE;
+CREATE TRIGGER a_marcxml_is_well_formed BEFORE INSERT OR UPDATE ON authority.record_entry FOR EACH ROW EXECUTE PROCEDURE biblio.check_marcxml_well_formed();
CREATE TABLE authority.record_note (
id BIGSERIAL PRIMARY KEY,
--- /dev/null
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0295'); -- gmcharlt
+
+CREATE OR REPLACE FUNCTION biblio.check_marcxml_well_formed () RETURNS TRIGGER AS $func$
+BEGIN
+
+ IF xml_is_well_formed(NEW.marc) THEN
+ RETURN NEW;
+ ELSE
+ RAISE EXCEPTION 'Attempted to % MARCXML that is not well formed', TG_OP;
+ END IF;
+
+END;
+$func$ LANGUAGE PLPGSQL;
+
+CREATE TRIGGER a_marcxml_is_well_formed BEFORE INSERT OR UPDATE ON biblio.record_entry FOR EACH ROW EXECUTE PROCEDURE biblio.check_marcxml_well_formed();
+
+CREATE TRIGGER a_marcxml_is_well_formed BEFORE INSERT OR UPDATE ON authority.record_entry FOR EACH ROW EXECUTE PROCEDURE biblio.check_marcxml_well_formed();
+
+COMMIT;