-
-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CREATE DOMAIN and ALTER DOMAIN do not validate the default value #8303
Comments
I only tagged 5.0.1, but I assume this also applies to older versions. |
Domain's default can return dynamic expression like CURRENT_USER, which may be a number inside a string or a date.
Because in this case it must evaluate to store the value in the table format. |
Technically, it should validate things, as specified by the SQL Standard, 11.5 <default clause>, but those rules are more strict than the expressions and conversions that Firebird allows. For example,
or a datetime function of the exact same type:
And, as to your example, CURRENT_USER should only be allowed against a string-type column:
Obviously, that is too restrictive for historic reasons, but some form of validation should be performed, if only for literals. |
Removed my previous comment about CURRENT_USER preventing table alteration, as it is probably not accurate. |
In other words, maybe we shouldn't generally validate it, but we should validate if a literal is convertible without error to the domain type. |
CREATE DOMAIN
does not evaluate the default value for validity, which makes it possible to create a domain with an invalid default:Result: no error
Expected:
Same happens for
ALTER DOMAIN
if the domain is not yet used for aNOT NULL
column.Result: no error
Expected:
If you then attempt to create a table with this domain as a nullable column, it works, until you insert with default values. If you create a table with the domain as a not null column, it fails. The
ALTER DOMAIN
does fail if the domain was already used for aNOT NULL
column.I would expect Firebird to validate if the
DEFAULT
expression produces a valid value of the domain type.The text was updated successfully, but these errors were encountered: