Allow deleting a record at database creation.

Using a magical record type "#" will allow the user to
delete previously created record  from the database.
This commit is contained in:
Hinko Kocevar
2024-06-12 19:48:34 +02:00
committed by Andrew Johnson
parent 057eb87101
commit 535c9c2a06
2 changed files with 28 additions and 0 deletions

View File

@ -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") { }
```
-----

View File

@ -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",