firebird icon indicating copy to clipboard operation
firebird copied to clipboard

Implement ability to explicitly validate constraints.

Open hvlad opened this issue 1 year ago • 2 comments

When creating constraint on non-empty table it could take a significant time to check if new constraint is valid. During this check no modifications on table should be allowed.

Another approach is to create constraint in state "not validated" and allow further modifications of table data. Such constraint should be validated later using special SQL statement. New data entered into table is validated and, if check failed - not allowed, as usual. Existing data will be validated using snapshot and, if check passed, constraint state will be set to "validated".

It will be good to have a way to validate few constraints at one pass over table data.

hvlad avatar Jan 16 '24 22:01 hvlad

I doubt that a special SQL statement is needed here. Background validation can run as it is done for encryption now and start automatically on database startup if any not-valid-yet constraint is detected.

aafemt avatar Jan 16 '24 22:01 aafemt

I don't think validation should be run in background. And I'm sure that VALIDATE statement is required. Note, there could be many other user actions between creation of constraint and decision to validate it. For example: add new NOT NULL field, commit, run few UPDATE statements to fill new field with values, then validate new constraint. Also, explicit VALIDATE statement allows to validate few constraints at one pass over the data.

hvlad avatar Jan 17 '24 18:01 hvlad