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.
This commit is contained in:
Emmanuel BENOîT 2012-06-30 12:43:29 +02:00
parent a6562052d3
commit aaec345957

View file

@ -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' ||