Commit 9895b35
committed
Fix ALTER DOMAIN NOT NULL syntax
This addresses a few problems with commit e5da0fe ("Catalog domain
not-null constraints").
In CREATE DOMAIN, a NOT NULL constraint looks like
CREATE DOMAIN d1 AS int [ CONSTRAINT conname ] NOT NULL
(Before e5da0fe, the constraint name was accepted but ignored.)
But in ALTER DOMAIN, a NOT NULL constraint looks like
ALTER DOMAIN d1 ADD [ CONSTRAINT conname ] NOT NULL VALUE
where VALUE is where for a table constraint the column name would be.
(This works as of e5da0fe. Before e5da0fe, this syntax
resulted in an internal error.)
But for domains, this latter syntax is confusing and needlessly
inconsistent between CREATE and ALTER. So this changes it to just
ALTER DOMAIN d1 ADD [ CONSTRAINT conname ] NOT NULL
(None of these syntaxes are per SQL standard; we are just living with
the bits of inconsistency that have built up over time.)
In passing, this also changes the psql \dD output to not show not-null
constraints in the column "Check", since it's already shown in the
column "Nullable". This has also been off since e5da0fe.
Reviewed-by: jian he <jian.universality@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/9ec24d7b-633d-463a-84c6-7acff769c9e8%40eisentraut.org1 parent d21d61b commit 9895b35Copy full SHA for 9895b35
File tree
Expand file treeCollapse file tree
6 files changed
+99
-16
lines changedOpen diff view settings
Filter options
- doc/src/sgml/ref
- src
- backend
- parser
- utils/adt
- bin/psql
- test/regress
- expected
- sql
Expand file treeCollapse file tree
6 files changed
+99
-16
lines changedOpen diff view settings
Collapse file
doc/src/sgml/ref/create_domain.sgml
Copy file name to clipboardExpand all lines: doc/src/sgml/ref/create_domain.sgml+14-3Lines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | | - |
| 27 | + |
28 | 28 | |
29 | | - |
| 29 | + |
30 | 30 | |
31 | 31 | |
32 | 32 | |
| ||
190 | 190 | |
191 | 191 | |
192 | 192 | |
193 | | - |
| 193 | + |
194 | 194 | |
195 | 195 | |
196 | 196 | |
| ||
279 | 279 | |
280 | 280 | |
281 | 281 | |
| 282 | + |
| 283 | + |
| 284 | + |
| 285 | + |
| 286 | + |
| 287 | + |
| 288 | + |
| 289 | + |
| 290 | + |
| 291 | + |
| 292 | + |
282 | 293 | |
283 | 294 | |
284 | 295 | |
|
Collapse file
+57-3Lines changed: 57 additions & 3 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
524 | 524 | |
525 | 525 | |
526 | 526 | |
527 | | - |
| 527 | + |
528 | 528 | |
529 | 529 | |
530 | 530 | |
| ||
596 | 596 | |
597 | 597 | |
598 | 598 | |
599 | | - |
| 599 | + |
600 | 600 | |
601 | 601 | |
602 | 602 | |
| ||
4334 | 4334 | |
4335 | 4335 | |
4336 | 4336 | |
| 4337 | + |
| 4338 | + |
| 4339 | + |
| 4340 | + |
| 4341 | + |
| 4342 | + |
| 4343 | + |
| 4344 | + |
| 4345 | + |
| 4346 | + |
| 4347 | + |
| 4348 | + |
| 4349 | + |
| 4350 | + |
| 4351 | + |
| 4352 | + |
| 4353 | + |
| 4354 | + |
| 4355 | + |
| 4356 | + |
| 4357 | + |
| 4358 | + |
| 4359 | + |
| 4360 | + |
| 4361 | + |
| 4362 | + |
| 4363 | + |
| 4364 | + |
| 4365 | + |
| 4366 | + |
| 4367 | + |
| 4368 | + |
| 4369 | + |
| 4370 | + |
| 4371 | + |
| 4372 | + |
| 4373 | + |
| 4374 | + |
| 4375 | + |
| 4376 | + |
| 4377 | + |
| 4378 | + |
| 4379 | + |
| 4380 | + |
| 4381 | + |
| 4382 | + |
| 4383 | + |
| 4384 | + |
| 4385 | + |
| 4386 | + |
| 4387 | + |
| 4388 | + |
| 4389 | + |
| 4390 | + |
4337 | 4391 | |
4338 | 4392 | |
4339 | 4393 | |
| ||
11586 | 11640 | |
11587 | 11641 | |
11588 | 11642 | |
11589 | | - |
| 11643 | + |
11590 | 11644 | |
11591 | 11645 | |
11592 | 11646 | |
|
Collapse file
src/backend/utils/adt/ruleutils.c
Copy file name to clipboardExpand all lines: src/backend/utils/adt/ruleutils.c+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
2523 | 2523 | |
2524 | 2524 | |
2525 | 2525 | |
2526 | | - |
| 2526 | + |
2527 | 2527 | |
2528 | 2528 | |
2529 | 2529 | |
|
Collapse file
+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
4449 | 4449 | |
4450 | 4450 | |
4451 | 4451 | |
4452 | | - |
| 4452 | + |
4453 | 4453 | |
4454 | 4454 | |
4455 | 4455 | |
|
Collapse file
src/test/regress/expected/domain.out
Copy file name to clipboardExpand all lines: src/test/regress/expected/domain.out+18-4Lines changed: 18 additions & 4 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
785 | 785 | |
786 | 786 | |
787 | 787 | |
| 788 | + |
| 789 | + |
| 790 | + |
| 791 | + |
| 792 | + |
| 793 | + |
| 794 | + |
788 | 795 | |
789 | 796 | |
790 | 797 | |
| ||
805 | 812 | |
806 | 813 | |
807 | 814 | |
808 | | - |
| 815 | + |
809 | 816 | |
810 | 817 | |
811 | | - |
| 818 | + |
812 | 819 | |
813 | 820 | |
814 | | - |
| 821 | + |
815 | 822 | |
816 | 823 | |
817 | 824 | |
818 | 825 | |
819 | 826 | |
820 | 827 | |
821 | | - |
| 828 | + |
822 | 829 | |
823 | 830 | |
824 | 831 | |
825 | 832 | |
826 | 833 | |
827 | 834 | |
| 835 | + |
| 836 | + |
| 837 | + |
| 838 | + |
| 839 | + |
| 840 | + |
| 841 | + |
828 | 842 | |
829 | 843 | |
830 | 844 | |
|
Collapse file
src/test/regress/sql/domain.sql
Copy file name to clipboardExpand all lines: src/test/regress/sql/domain.sql+8-4Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
458 | 458 | |
459 | 459 | |
460 | 460 | |
| 461 | + |
| 462 | + |
461 | 463 | |
462 | 464 | |
463 | 465 | |
| ||
477 | 479 | |
478 | 480 | |
479 | 481 | |
480 | | - |
| 482 | + |
481 | 483 | |
482 | 484 | |
483 | | - |
| 485 | + |
484 | 486 | |
485 | 487 | |
486 | 488 | |
487 | | - |
| 489 | + |
488 | 490 | |
489 | | - |
| 491 | + |
490 | 492 | |
491 | 493 | |
| 494 | + |
| 495 | + |
492 | 496 | |
493 | 497 | |
494 | 498 | |
|
0 commit comments