Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcc35d89

Browse files
committed
Rename field "relkind" to "objtype" for CTAS and ALTER TABLE nodes
"relkind" normally refers to the char field from pg_class. However, inthe parse nodes AlterTableStmt and CreateTableAsStmt, "relkind" was usedfor a field of type enum ObjectType, that could refer to other objecttypes than those possible for a relkind. Such fields being usuallynamed "objtype", switch the name in both structures to make things moreconsistent. Note that this led to some confusion in functions thatalso operate on a RangeTableEntry object, which also has a field named"relkind".This naming goes back to commit 09d4e96, where only OBJECT_TABLE andOBJECT_INDEX were used. This got extended later to use as wellOBJECT_TYPE withe440e12, not really a relation kind.Author: Mark DilgerReviewed-by: Daniel Gustafsson, Álvaro Herrera, Michael PaquierDiscussion:https://postgr.es/m/609181AE-E399-47C7-9221-856E0F96BF93@enterprisedb.com
1 parentdf64650 commitcc35d89

File tree

8 files changed

+37
-37
lines changed

8 files changed

+37
-37
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4709,7 +4709,7 @@ ATParseTransformCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
47094709
-1);
47104710
atstmt->relation->inh = recurse;
47114711
atstmt->cmds = list_make1(cmd);
4712-
atstmt->relkind = OBJECT_TABLE; /* needn't be picky here */
4712+
atstmt->objtype = OBJECT_TABLE; /* needn't be picky here */
47134713
atstmt->missing_ok = false;
47144714

47154715
/* Transform the AlterTableStmt */
@@ -15594,7 +15594,7 @@ RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid, Oid oldrelid,
1559415594
reltype = ((AlterObjectSchemaStmt *) stmt)->objectType;
1559515595

1559615596
else if (IsA(stmt, AlterTableStmt))
15597-
reltype = ((AlterTableStmt *) stmt)->relkind;
15597+
reltype = ((AlterTableStmt *) stmt)->objtype;
1559815598
else
1559915599
{
1560015600
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(stmt));

‎src/backend/nodes/copyfuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3204,7 +3204,7 @@ _copyAlterTableStmt(const AlterTableStmt *from)
32043204

32053205
COPY_NODE_FIELD(relation);
32063206
COPY_NODE_FIELD(cmds);
3207-
COPY_SCALAR_FIELD(relkind);
3207+
COPY_SCALAR_FIELD(objtype);
32083208
COPY_SCALAR_FIELD(missing_ok);
32093209

32103210
returnnewnode;
@@ -3980,7 +3980,7 @@ _copyCreateTableAsStmt(const CreateTableAsStmt *from)
39803980

39813981
COPY_NODE_FIELD(query);
39823982
COPY_NODE_FIELD(into);
3983-
COPY_SCALAR_FIELD(relkind);
3983+
COPY_SCALAR_FIELD(objtype);
39843984
COPY_SCALAR_FIELD(is_select_into);
39853985
COPY_SCALAR_FIELD(if_not_exists);
39863986

‎src/backend/nodes/equalfuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ _equalAlterTableStmt(const AlterTableStmt *a, const AlterTableStmt *b)
10871087
{
10881088
COMPARE_NODE_FIELD(relation);
10891089
COMPARE_NODE_FIELD(cmds);
1090-
COMPARE_SCALAR_FIELD(relkind);
1090+
COMPARE_SCALAR_FIELD(objtype);
10911091
COMPARE_SCALAR_FIELD(missing_ok);
10921092

10931093
return true;
@@ -1735,7 +1735,7 @@ _equalCreateTableAsStmt(const CreateTableAsStmt *a, const CreateTableAsStmt *b)
17351735
{
17361736
COMPARE_NODE_FIELD(query);
17371737
COMPARE_NODE_FIELD(into);
1738-
COMPARE_SCALAR_FIELD(relkind);
1738+
COMPARE_SCALAR_FIELD(objtype);
17391739
COMPARE_SCALAR_FIELD(is_select_into);
17401740
COMPARE_SCALAR_FIELD(if_not_exists);
17411741

‎src/backend/parser/analyze.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ transformOptionalSelectInto(ParseState *pstate, Node *parseTree)
229229

230230
ctas->query=parseTree;
231231
ctas->into=stmt->intoClause;
232-
ctas->relkind=OBJECT_TABLE;
232+
ctas->objtype=OBJECT_TABLE;
233233
ctas->is_select_into= true;
234234

235235
/*
@@ -2572,7 +2572,7 @@ transformCreateTableAsStmt(ParseState *pstate, CreateTableAsStmt *stmt)
25722572
stmt->query= (Node*)query;
25732573

25742574
/* additional work needed for CREATE MATERIALIZED VIEW */
2575-
if (stmt->relkind==OBJECT_MATVIEW)
2575+
if (stmt->objtype==OBJECT_MATVIEW)
25762576
{
25772577
/*
25782578
* Prohibit a data-modifying CTE in the query used to create a

‎src/backend/parser/gram.y

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,7 +1844,7 @@ AlterTableStmt:
18441844
AlterTableStmt *n = makeNode(AlterTableStmt);
18451845
n->relation =$3;
18461846
n->cmds =$4;
1847-
n->relkind = OBJECT_TABLE;
1847+
n->objtype = OBJECT_TABLE;
18481848
n->missing_ok =false;
18491849
$$ = (Node *)n;
18501850
}
@@ -1853,7 +1853,7 @@ AlterTableStmt:
18531853
AlterTableStmt *n = makeNode(AlterTableStmt);
18541854
n->relation =$5;
18551855
n->cmds =$6;
1856-
n->relkind = OBJECT_TABLE;
1856+
n->objtype = OBJECT_TABLE;
18571857
n->missing_ok =true;
18581858
$$ = (Node *)n;
18591859
}
@@ -1862,7 +1862,7 @@ AlterTableStmt:
18621862
AlterTableStmt *n = makeNode(AlterTableStmt);
18631863
n->relation =$3;
18641864
n->cmds = list_make1($4);
1865-
n->relkind = OBJECT_TABLE;
1865+
n->objtype = OBJECT_TABLE;
18661866
n->missing_ok =false;
18671867
$$ = (Node *)n;
18681868
}
@@ -1871,7 +1871,7 @@ AlterTableStmt:
18711871
AlterTableStmt *n = makeNode(AlterTableStmt);
18721872
n->relation =$5;
18731873
n->cmds = list_make1($6);
1874-
n->relkind = OBJECT_TABLE;
1874+
n->objtype = OBJECT_TABLE;
18751875
n->missing_ok =true;
18761876
$$ = (Node *)n;
18771877
}
@@ -1902,7 +1902,7 @@ AlterTableStmt:
19021902
AlterTableStmt *n = makeNode(AlterTableStmt);
19031903
n->relation =$3;
19041904
n->cmds =$4;
1905-
n->relkind = OBJECT_INDEX;
1905+
n->objtype = OBJECT_INDEX;
19061906
n->missing_ok =false;
19071907
$$ = (Node *)n;
19081908
}
@@ -1911,7 +1911,7 @@ AlterTableStmt:
19111911
AlterTableStmt *n = makeNode(AlterTableStmt);
19121912
n->relation =$5;
19131913
n->cmds =$6;
1914-
n->relkind = OBJECT_INDEX;
1914+
n->objtype = OBJECT_INDEX;
19151915
n->missing_ok =true;
19161916
$$ = (Node *)n;
19171917
}
@@ -1920,7 +1920,7 @@ AlterTableStmt:
19201920
AlterTableStmt *n = makeNode(AlterTableStmt);
19211921
n->relation =$3;
19221922
n->cmds = list_make1($4);
1923-
n->relkind = OBJECT_INDEX;
1923+
n->objtype = OBJECT_INDEX;
19241924
n->missing_ok =false;
19251925
$$ = (Node *)n;
19261926
}
@@ -1951,7 +1951,7 @@ AlterTableStmt:
19511951
AlterTableStmt *n = makeNode(AlterTableStmt);
19521952
n->relation =$3;
19531953
n->cmds =$4;
1954-
n->relkind = OBJECT_SEQUENCE;
1954+
n->objtype = OBJECT_SEQUENCE;
19551955
n->missing_ok =false;
19561956
$$ = (Node *)n;
19571957
}
@@ -1960,7 +1960,7 @@ AlterTableStmt:
19601960
AlterTableStmt *n = makeNode(AlterTableStmt);
19611961
n->relation =$5;
19621962
n->cmds =$6;
1963-
n->relkind = OBJECT_SEQUENCE;
1963+
n->objtype = OBJECT_SEQUENCE;
19641964
n->missing_ok =true;
19651965
$$ = (Node *)n;
19661966
}
@@ -1969,7 +1969,7 @@ AlterTableStmt:
19691969
AlterTableStmt *n = makeNode(AlterTableStmt);
19701970
n->relation =$3;
19711971
n->cmds =$4;
1972-
n->relkind = OBJECT_VIEW;
1972+
n->objtype = OBJECT_VIEW;
19731973
n->missing_ok =false;
19741974
$$ = (Node *)n;
19751975
}
@@ -1978,7 +1978,7 @@ AlterTableStmt:
19781978
AlterTableStmt *n = makeNode(AlterTableStmt);
19791979
n->relation =$5;
19801980
n->cmds =$6;
1981-
n->relkind = OBJECT_VIEW;
1981+
n->objtype = OBJECT_VIEW;
19821982
n->missing_ok =true;
19831983
$$ = (Node *)n;
19841984
}
@@ -1987,7 +1987,7 @@ AlterTableStmt:
19871987
AlterTableStmt *n = makeNode(AlterTableStmt);
19881988
n->relation =$4;
19891989
n->cmds =$5;
1990-
n->relkind = OBJECT_MATVIEW;
1990+
n->objtype = OBJECT_MATVIEW;
19911991
n->missing_ok =false;
19921992
$$ = (Node *)n;
19931993
}
@@ -1996,7 +1996,7 @@ AlterTableStmt:
19961996
AlterTableStmt *n = makeNode(AlterTableStmt);
19971997
n->relation =$6;
19981998
n->cmds =$7;
1999-
n->relkind = OBJECT_MATVIEW;
1999+
n->objtype = OBJECT_MATVIEW;
20002000
n->missing_ok =true;
20012001
$$ = (Node *)n;
20022002
}
@@ -2027,7 +2027,7 @@ AlterTableStmt:
20272027
AlterTableStmt *n = makeNode(AlterTableStmt);
20282028
n->relation =$4;
20292029
n->cmds =$5;
2030-
n->relkind = OBJECT_FOREIGN_TABLE;
2030+
n->objtype = OBJECT_FOREIGN_TABLE;
20312031
n->missing_ok =false;
20322032
$$ = (Node *)n;
20332033
}
@@ -2036,7 +2036,7 @@ AlterTableStmt:
20362036
AlterTableStmt *n = makeNode(AlterTableStmt);
20372037
n->relation =$6;
20382038
n->cmds =$7;
2039-
n->relkind = OBJECT_FOREIGN_TABLE;
2039+
n->objtype = OBJECT_FOREIGN_TABLE;
20402040
n->missing_ok =true;
20412041
$$ = (Node *)n;
20422042
}
@@ -2856,7 +2856,7 @@ AlterCompositeTypeStmt:
28562856
/* can't use qualified_name, sigh*/
28572857
n->relation = makeRangeVarFromAnyName($3,@3, yyscanner);
28582858
n->cmds =$4;
2859-
n->relkind = OBJECT_TYPE;
2859+
n->objtype = OBJECT_TYPE;
28602860
$$ = (Node *)n;
28612861
}
28622862
;
@@ -4072,7 +4072,7 @@ CreateAsStmt:
40724072
CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
40734073
ctas->query =$6;
40744074
ctas->into =$4;
4075-
ctas->relkind = OBJECT_TABLE;
4075+
ctas->objtype = OBJECT_TABLE;
40764076
ctas->is_select_into =false;
40774077
ctas->if_not_exists =false;
40784078
/* cram additional flags into the IntoClause*/
@@ -4085,7 +4085,7 @@ CreateAsStmt:
40854085
CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
40864086
ctas->query =$9;
40874087
ctas->into =$7;
4088-
ctas->relkind = OBJECT_TABLE;
4088+
ctas->objtype = OBJECT_TABLE;
40894089
ctas->is_select_into =false;
40904090
ctas->if_not_exists =true;
40914091
/* cram additional flags into the IntoClause*/
@@ -4131,7 +4131,7 @@ CreateMatViewStmt:
41314131
CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
41324132
ctas->query =$7;
41334133
ctas->into =$5;
4134-
ctas->relkind = OBJECT_MATVIEW;
4134+
ctas->objtype = OBJECT_MATVIEW;
41354135
ctas->is_select_into =false;
41364136
ctas->if_not_exists =false;
41374137
/* cram additional flags into the IntoClause*/
@@ -4144,7 +4144,7 @@ CreateMatViewStmt:
41444144
CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
41454145
ctas->query =$10;
41464146
ctas->into =$8;
4147-
ctas->relkind = OBJECT_MATVIEW;
4147+
ctas->objtype = OBJECT_MATVIEW;
41484148
ctas->is_select_into =false;
41494149
ctas->if_not_exists =true;
41504150
/* cram additional flags into the IntoClause*/
@@ -10695,7 +10695,7 @@ ExecuteStmt: EXECUTE name execute_param_clause
1069510695
n->params =$8;
1069610696
ctas->query = (Node *) n;
1069710697
ctas->into =$4;
10698-
ctas->relkind = OBJECT_TABLE;
10698+
ctas->objtype = OBJECT_TABLE;
1069910699
ctas->is_select_into =false;
1070010700
ctas->if_not_exists =false;
1070110701
/* cram additional flags into the IntoClause*/
@@ -10712,7 +10712,7 @@ ExecuteStmt: EXECUTE name execute_param_clause
1071210712
n->params =$11;
1071310713
ctas->query = (Node *) n;
1071410714
ctas->into =$7;
10715-
ctas->relkind = OBJECT_TABLE;
10715+
ctas->objtype = OBJECT_TABLE;
1071610716
ctas->is_select_into =false;
1071710717
ctas->if_not_exists =true;
1071810718
/* cram additional flags into the IntoClause*/

‎src/backend/parser/parse_utilcmd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
829829
stmt=makeNode(AlterTableStmt);
830830
stmt->relation=cxt->relation;
831831
stmt->cmds=NIL;
832-
stmt->relkind=OBJECT_FOREIGN_TABLE;
832+
stmt->objtype=OBJECT_FOREIGN_TABLE;
833833
stmt->cmds=lappend(stmt->cmds,cmd);
834834

835835
cxt->alist=lappend(cxt->alist,stmt);
@@ -2508,7 +2508,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
25082508

25092509
alterstmt->relation=copyObject(cxt->relation);
25102510
alterstmt->cmds=notnullcmds;
2511-
alterstmt->relkind=OBJECT_TABLE;
2511+
alterstmt->objtype=OBJECT_TABLE;
25122512
alterstmt->missing_ok= false;
25132513

25142514
cxt->alist=lappend(cxt->alist,alterstmt);
@@ -2610,7 +2610,7 @@ transformFKConstraints(CreateStmtContext *cxt,
26102610

26112611
alterstmt->relation=cxt->relation;
26122612
alterstmt->cmds=NIL;
2613-
alterstmt->relkind=OBJECT_TABLE;
2613+
alterstmt->objtype=OBJECT_TABLE;
26142614

26152615
foreach(fkclist,cxt->fkconstraints)
26162616
{

‎src/backend/tcop/utility.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,7 +2574,7 @@ CreateCommandTag(Node *parsetree)
25742574
break;
25752575

25762576
caseT_AlterTableStmt:
2577-
tag=AlterObjectTypeCommandTag(((AlterTableStmt*)parsetree)->relkind);
2577+
tag=AlterObjectTypeCommandTag(((AlterTableStmt*)parsetree)->objtype);
25782578
break;
25792579

25802580
caseT_AlterDomainStmt:
@@ -2752,7 +2752,7 @@ CreateCommandTag(Node *parsetree)
27522752
break;
27532753

27542754
caseT_CreateTableAsStmt:
2755-
switch (((CreateTableAsStmt*)parsetree)->relkind)
2755+
switch (((CreateTableAsStmt*)parsetree)->objtype)
27562756
{
27572757
caseOBJECT_TABLE:
27582758
if (((CreateTableAsStmt*)parsetree)->is_select_into)

‎src/include/nodes/parsenodes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,7 @@ typedef struct AlterTableStmt
17761776
NodeTagtype;
17771777
RangeVar*relation;/* table to work on */
17781778
List*cmds;/* list of subcommands */
1779-
ObjectTyperelkind;/* type of object */
1779+
ObjectTypeobjtype;/* type of object */
17801780
boolmissing_ok;/* skip error if table missing */
17811781
}AlterTableStmt;
17821782

@@ -3275,7 +3275,7 @@ typedef struct CreateTableAsStmt
32753275
NodeTagtype;
32763276
Node*query;/* the query (see comments above) */
32773277
IntoClause*into;/* destination table */
3278-
ObjectTyperelkind;/* OBJECT_TABLE or OBJECT_MATVIEW */
3278+
ObjectTypeobjtype;/* OBJECT_TABLE or OBJECT_MATVIEW */
32793279
boolis_select_into;/* it was written as SELECT INTO */
32803280
boolif_not_exists;/* just do nothing if it already exists? */
32813281
}CreateTableAsStmt;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp