diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index fc535d0d8..343de180f 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -22,6 +22,21 @@ should also be read to understand what has changed since earlier releases: ## Changes made on the 7.0 branch since 7.0.8.1 +### Allow users to delete previously created records from the database + +From this release, record instances and aliases that have already been loaded +by an IOC can be removed from the database again before the call to iocInit +by loading a second instance of the named records but using `"#"` in place of +the record type. Values for the fields are not required or advised, just use +an empty record body { }. This is useful when a template defines records that +are not wanted in some IOCs, without having to split or duplicate the original +template. + +For example this will remove the record named "unwanted": + +``` +record("#", "unwanted") { } +``` ----- diff --git a/modules/database/src/ioc/dbStatic/dbLexRoutines.c b/modules/database/src/ioc/dbStatic/dbLexRoutines.c index 702b2291e..7efde6cf0 100644 --- a/modules/database/src/ioc/dbStatic/dbLexRoutines.c +++ b/modules/database/src/ioc/dbStatic/dbLexRoutines.c @@ -1119,6 +1119,19 @@ static void dbRecordHead(char *recordType, char *name, int visible) return; } + if (recordType[0] == '#' && recordType[1] == 0) { + status = dbFindRecord(pdbentry, name); + if (status == 0) { + dbDeleteRecord(pdbentry); + fprintf(stderr, ERL_WARNING ": Record \"%s\" DELETED!\n", name); + return; /* done */ + } + fprintf(stderr, ERL_ERROR ": Record \"%s\" not found\n", name); + yyerror(NULL); + duplicate = TRUE; + return; + } + status = dbFindRecordType(pdbentry, recordType); if (status) { fprintf(stderr, "Record \"%s\" is of unknown type \"%s\"\n",