Skip to content

Commit 51cc037

Browse files
author
Commitfest Bot
committed
[CF 5780] Standardize the definition of the subtype field of AlterDomainStmt
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/5780 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/[email protected] Author(s): Zongliang Quan
2 parents 1845958 + f253271 commit 51cc037

File tree

4 files changed

+25
-22
lines changed

4 files changed

+25
-22
lines changed

src/backend/commands/tablecmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15727,7 +15727,7 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
1572715727
{
1572815728
AlterDomainStmt *stmt = (AlterDomainStmt *) stm;
1572915729

15730-
if (stmt->subtype == 'C') /* ADD CONSTRAINT */
15730+
if (stmt->subtype == AD_AddConstraint)
1573115731
{
1573215732
Constraint *con = castNode(Constraint, stmt->def);
1573315733
AlterTableCmd *cmd = makeNode(AlterTableCmd);

src/backend/parser/gram.y

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11627,7 +11627,7 @@ AlterDomainStmt:
1162711627
{
1162811628
AlterDomainStmt *n = makeNode(AlterDomainStmt);
1162911629

11630-
n->subtype = 'T';
11630+
n->subtype = AD_AlterDefault;
1163111631
n->typeName = $3;
1163211632
n->def = $4;
1163311633
$$ = (Node *) n;
@@ -11637,7 +11637,7 @@ AlterDomainStmt:
1163711637
{
1163811638
AlterDomainStmt *n = makeNode(AlterDomainStmt);
1163911639

11640-
n->subtype = 'N';
11640+
n->subtype = AD_DropNotNull;
1164111641
n->typeName = $3;
1164211642
$$ = (Node *) n;
1164311643
}
@@ -11646,7 +11646,7 @@ AlterDomainStmt:
1164611646
{
1164711647
AlterDomainStmt *n = makeNode(AlterDomainStmt);
1164811648

11649-
n->subtype = 'O';
11649+
n->subtype = AD_SetNotNull;
1165011650
n->typeName = $3;
1165111651
$$ = (Node *) n;
1165211652
}
@@ -11655,7 +11655,7 @@ AlterDomainStmt:
1165511655
{
1165611656
AlterDomainStmt *n = makeNode(AlterDomainStmt);
1165711657

11658-
n->subtype = 'C';
11658+
n->subtype = AD_AddConstraint;
1165911659
n->typeName = $3;
1166011660
n->def = $5;
1166111661
$$ = (Node *) n;
@@ -11665,7 +11665,7 @@ AlterDomainStmt:
1166511665
{
1166611666
AlterDomainStmt *n = makeNode(AlterDomainStmt);
1166711667

11668-
n->subtype = 'X';
11668+
n->subtype = AD_DropConstraint;
1166911669
n->typeName = $3;
1167011670
n->name = $6;
1167111671
n->behavior = $7;
@@ -11677,7 +11677,7 @@ AlterDomainStmt:
1167711677
{
1167811678
AlterDomainStmt *n = makeNode(AlterDomainStmt);
1167911679

11680-
n->subtype = 'X';
11680+
n->subtype = AD_DropConstraint;
1168111681
n->typeName = $3;
1168211682
n->name = $8;
1168311683
n->behavior = $9;
@@ -11689,7 +11689,7 @@ AlterDomainStmt:
1168911689
{
1169011690
AlterDomainStmt *n = makeNode(AlterDomainStmt);
1169111691

11692-
n->subtype = 'V';
11692+
n->subtype = AD_ValidateConstraint;
1169311693
n->typeName = $3;
1169411694
n->name = $6;
1169511695
$$ = (Node *) n;

src/backend/tcop/utility.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ ProcessUtilitySlow(ParseState *pstate,
13431343
*/
13441344
switch (stmt->subtype)
13451345
{
1346-
case 'T': /* ALTER DOMAIN DEFAULT */
1346+
case AD_AlterDefault:
13471347

13481348
/*
13491349
* Recursively alter column default for table and,
@@ -1353,30 +1353,30 @@ ProcessUtilitySlow(ParseState *pstate,
13531353
AlterDomainDefault(stmt->typeName,
13541354
stmt->def);
13551355
break;
1356-
case 'N': /* ALTER DOMAIN DROP NOT NULL */
1356+
case AD_DropNotNull:
13571357
address =
13581358
AlterDomainNotNull(stmt->typeName,
13591359
false);
13601360
break;
1361-
case 'O': /* ALTER DOMAIN SET NOT NULL */
1361+
case AD_SetNotNull:
13621362
address =
13631363
AlterDomainNotNull(stmt->typeName,
13641364
true);
13651365
break;
1366-
case 'C': /* ADD CONSTRAINT */
1366+
case AD_AddConstraint:
13671367
address =
13681368
AlterDomainAddConstraint(stmt->typeName,
13691369
stmt->def,
13701370
&secondaryObject);
13711371
break;
1372-
case 'X': /* DROP CONSTRAINT */
1372+
case AD_DropConstraint:
13731373
address =
13741374
AlterDomainDropConstraint(stmt->typeName,
13751375
stmt->name,
13761376
stmt->behavior,
13771377
stmt->missing_ok);
13781378
break;
1379-
case 'V': /* VALIDATE CONSTRAINT */
1379+
case AD_ValidateConstraint:
13801380
address =
13811381
AlterDomainValidateConstraint(stmt->typeName,
13821382
stmt->name);

src/include/nodes/parsenodes.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,17 +2536,20 @@ typedef struct AlterCollationStmt
25362536
* this command.
25372537
* ----------------------
25382538
*/
2539+
typedef enum AlterDomainType
2540+
{
2541+
AD_AlterDefault = 'T', /* SET|DROP DEFAULT */
2542+
AD_DropNotNull = 'N', /* DROP NOT NULL */
2543+
AD_SetNotNull = 'O', /* SET NOT NULL */
2544+
AD_AddConstraint = 'C', /* ADD CONSTRAINT */
2545+
AD_DropConstraint = 'X', /* DROP CONSTRAINT */
2546+
AD_ValidateConstraint = 'V', /* VALIDATE CONSTRAINT */
2547+
} AlterDomainType;
2548+
25392549
typedef struct AlterDomainStmt
25402550
{
25412551
NodeTag type;
2542-
char subtype; /*------------
2543-
* T = alter column default
2544-
* N = alter column drop not null
2545-
* O = alter column set not null
2546-
* C = add constraint
2547-
* X = drop constraint
2548-
*------------
2549-
*/
2552+
AlterDomainType subtype; /* Type of domain alteration to apply */
25502553
List *typeName; /* domain to work on */
25512554
char *name; /* column or constraint name to act on */
25522555
Node *def; /* definition of default or constraint */

0 commit comments

Comments
 (0)