Skip to content
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

Allow specify of null constraint name in SET NOT NULL [CORE5806] #6068

Open
firebird-automations opened this issue Apr 25, 2018 · 0 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @livius2

Few thinks about not null constraint and its name - i do not know if this should be as one ticket or some releated tickets

1. Specification of NOT NULL constraint is undocumented feature avaiable for years.
e.g we can do:
Create table A
(
FIELD1 INTEGER CONSTRAINT NK_A_FIELD1 NOT NULL
)

2. In previous Firebird versions (prior FB3.0)
there was possibility to do:

ALTER TABLE XXX ADD FIELDX INTEGER CONSTRAINT NK\_XXX\_\_FIELDX NOT NULL;
UPDATE TABLE XXX SET FIELDX=some calculations;

and after that we have named null constraint

but now in FB3 we can not do same\. We must do:

    ALTER TABLE XXX ADD FIELDX INTEGER;
    UPDATE TABLE XXX SET FIELDX=some calculations;
    ALTER TABLE XXX ALTER FIELDX SET NOT NULL;

and in SET NOT NULL we can not specify NOT NULL constraint name\.
And this is good if user can name all self created constraint in the database\.

3. Will be good to see not null constraint name in error message like it is for all other constraints like PK, FK, CK, UK.

this was discussed on the support mailing list and Mark Rotteveel say there:

"Given named not null constraints are an undocumented feature, you can't
expect too much from it. I suggest you create tickets to get this
documented, and maybe to extend support to allow naming the constraint
when using alter table xxx alter yyy set not null.

I'd suggest something like expanding ALTER TABLE ADD <tconstraint> by
adding the option to tconstraint:

[CONSTRAINT <constraint-name>] NOT NULL (<column-name>)

Or maybe

ALTER TABLE <table name> ALTER <field name> SET [CONSTRAINT
<constraintname>] NOT NULL

Although that might conflict with the oddity of also supporting ALTER
TABLE <table name> ALTER <field name> SET NULL, which is not defined in
the SQL standard and is not a real constraint, and shouldn't get named.

Interestingly, the SQL standard also supports named not null
constraints, but there also naming it using ALTER COLUMN ... SET NOT
NULL is not supported.

Mark
--
Mark Rotteveel
"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant