From aaec3459578d41d5862c72f3f12f936a602d36fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sat, 30 Jun 2012 12:43:29 +0200 Subject: [PATCH] Event definition stored procedures bugfix Fixed a bug which caused events.evdef_finalise() to fail with an exception when the event type identifier was wrong, and to register the event type event if error had occurred on field definitions. --- .../db-structure/parts/040-functions/170-events.sql | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/legacyworlds-server-data/db-structure/parts/040-functions/170-events.sql b/legacyworlds-server-data/db-structure/parts/040-functions/170-events.sql index cbcd8e0..8cdba58 100644 --- a/legacyworlds-server-data/db-structure/parts/040-functions/170-events.sql +++ b/legacyworlds-server-data/db-structure/parts/040-functions/170-events.sql @@ -40,7 +40,12 @@ CREATE TYPE events.evdef_create_result AS ENUM( * finalisation function when an event or field cannot be inserted due to * check failures. */ - 'BAD_SPEC' + 'BAD_SPEC' , + + /* This error code is returned when trying to finalise an event after one + * of the definition calls failed. + */ + 'NO_DATA' ); @@ -166,6 +171,7 @@ BEGIN IF LENGTH( _id ) < 2 OR LENGTH( _id ) > 48 OR NOT _id ~ '^[a-z\-]+$' THEN + DELETE FROM evdef_temp; RETURN 'BAD_ID'::events.evdef_create_result; END IF; @@ -463,6 +469,10 @@ BEGIN SELECT INTO _rec * FROM evdef_temp WHERE evfld_id IS NULL; + IF NOT FOUND + THEN + RETURN 'NO_DATA'; + END IF; _qstr := 'INSERT INTO events.event_definitions (' || 'evdef_id , evdef_priority , evdef_adjustable' ||