mirror of
https://github.com/postgres/postgres.git
synced 2025-10-29 22:49:41 +03:00
Post-PG 10 beta1 pgindent run
perltidy run not included.
This commit is contained in:
@@ -1637,7 +1637,7 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
|
||||
* Recursively transform the components of the tree.
|
||||
*/
|
||||
sostmt = castNode(SetOperationStmt,
|
||||
transformSetOperationTree(pstate, stmt, true, NULL));
|
||||
transformSetOperationTree(pstate, stmt, true, NULL));
|
||||
Assert(sostmt);
|
||||
qry->setOperations = (Node *) sostmt;
|
||||
|
||||
@@ -2809,8 +2809,8 @@ transformLockingClause(ParseState *pstate, Query *qry, LockingClause *lc,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s cannot be applied to a named tuplestore",
|
||||
LCS_asString(lc->strength)),
|
||||
errmsg("%s cannot be applied to a named tuplestore",
|
||||
LCS_asString(lc->strength)),
|
||||
parser_errposition(pstate, thisrel->location)));
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -60,7 +60,7 @@ static Node *transformJoinUsingClause(ParseState *pstate,
|
||||
static Node *transformJoinOnClause(ParseState *pstate, JoinExpr *j,
|
||||
List *namespace);
|
||||
static RangeTblEntry *getRTEForSpecialRelationTypes(ParseState *pstate,
|
||||
RangeVar *rv);
|
||||
RangeVar *rv);
|
||||
static RangeTblEntry *transformTableEntry(ParseState *pstate, RangeVar *r);
|
||||
static RangeTblEntry *transformCTEReference(ParseState *pstate, RangeVar *r,
|
||||
CommonTableExpr *cte, Index levelsup);
|
||||
@@ -70,7 +70,7 @@ static RangeTblEntry *transformRangeSubselect(ParseState *pstate,
|
||||
static RangeTblEntry *transformRangeFunction(ParseState *pstate,
|
||||
RangeFunction *r);
|
||||
static RangeTblEntry *transformRangeTableFunc(ParseState *pstate,
|
||||
RangeTableFunc *t);
|
||||
RangeTableFunc *t);
|
||||
static TableSampleClause *transformRangeTableSample(ParseState *pstate,
|
||||
RangeTableSample *rts);
|
||||
static Node *transformFromClauseItem(ParseState *pstate, Node *n,
|
||||
@@ -359,7 +359,7 @@ transformJoinUsingClause(ParseState *pstate,
|
||||
|
||||
/* Now create the lvar = rvar join condition */
|
||||
e = makeSimpleA_Expr(AEXPR_OP, "=",
|
||||
(Node *) copyObject(lvar), (Node *) copyObject(rvar),
|
||||
(Node *) copyObject(lvar), (Node *) copyObject(rvar),
|
||||
-1);
|
||||
|
||||
/* Prepare to combine into an AND clause, if multiple join columns */
|
||||
@@ -759,7 +759,7 @@ transformRangeTableFunc(ParseState *pstate, RangeTableFunc *rtf)
|
||||
/* Transform and apply typecast to the row-generating expression ... */
|
||||
Assert(rtf->rowexpr != NULL);
|
||||
tf->rowexpr = coerce_to_specific_type(pstate,
|
||||
transformExpr(pstate, rtf->rowexpr, EXPR_KIND_FROM_FUNCTION),
|
||||
transformExpr(pstate, rtf->rowexpr, EXPR_KIND_FROM_FUNCTION),
|
||||
TEXTOID,
|
||||
constructName);
|
||||
assign_expr_collations(pstate, tf->rowexpr);
|
||||
@@ -767,7 +767,7 @@ transformRangeTableFunc(ParseState *pstate, RangeTableFunc *rtf)
|
||||
/* ... and to the document itself */
|
||||
Assert(rtf->docexpr != NULL);
|
||||
tf->docexpr = coerce_to_specific_type(pstate,
|
||||
transformExpr(pstate, rtf->docexpr, EXPR_KIND_FROM_FUNCTION),
|
||||
transformExpr(pstate, rtf->docexpr, EXPR_KIND_FROM_FUNCTION),
|
||||
docType,
|
||||
constructName);
|
||||
assign_expr_collations(pstate, tf->docexpr);
|
||||
@@ -792,9 +792,8 @@ transformRangeTableFunc(ParseState *pstate, RangeTableFunc *rtf)
|
||||
makeString(pstrdup(rawc->colname)));
|
||||
|
||||
/*
|
||||
* Determine the type and typmod for the new column. FOR
|
||||
* ORDINALITY columns are INTEGER per spec; the others are
|
||||
* user-specified.
|
||||
* Determine the type and typmod for the new column. FOR ORDINALITY
|
||||
* columns are INTEGER per spec; the others are user-specified.
|
||||
*/
|
||||
if (rawc->for_ordinality)
|
||||
{
|
||||
@@ -824,14 +823,14 @@ transformRangeTableFunc(ParseState *pstate, RangeTableFunc *rtf)
|
||||
tf->coltypes = lappend_oid(tf->coltypes, typid);
|
||||
tf->coltypmods = lappend_int(tf->coltypmods, typmod);
|
||||
tf->colcollations = lappend_oid(tf->colcollations,
|
||||
type_is_collatable(typid) ? DEFAULT_COLLATION_OID : InvalidOid);
|
||||
type_is_collatable(typid) ? DEFAULT_COLLATION_OID : InvalidOid);
|
||||
|
||||
/* Transform the PATH and DEFAULT expressions */
|
||||
if (rawc->colexpr)
|
||||
{
|
||||
colexpr = coerce_to_specific_type(pstate,
|
||||
transformExpr(pstate, rawc->colexpr,
|
||||
EXPR_KIND_FROM_FUNCTION),
|
||||
transformExpr(pstate, rawc->colexpr,
|
||||
EXPR_KIND_FROM_FUNCTION),
|
||||
TEXTOID,
|
||||
constructName);
|
||||
assign_expr_collations(pstate, colexpr);
|
||||
@@ -842,8 +841,8 @@ transformRangeTableFunc(ParseState *pstate, RangeTableFunc *rtf)
|
||||
if (rawc->coldefexpr)
|
||||
{
|
||||
coldefexpr = coerce_to_specific_type_typmod(pstate,
|
||||
transformExpr(pstate, rawc->coldefexpr,
|
||||
EXPR_KIND_FROM_FUNCTION),
|
||||
transformExpr(pstate, rawc->coldefexpr,
|
||||
EXPR_KIND_FROM_FUNCTION),
|
||||
typid, typmod,
|
||||
constructName);
|
||||
assign_expr_collations(pstate, coldefexpr);
|
||||
@@ -1050,7 +1049,6 @@ transformRangeTableSample(ParseState *pstate, RangeTableSample *rts)
|
||||
static RangeTblEntry *
|
||||
getRTEForSpecialRelationTypes(ParseState *pstate, RangeVar *rv)
|
||||
{
|
||||
|
||||
CommonTableExpr *cte;
|
||||
Index levelsup;
|
||||
RangeTblEntry *rte = NULL;
|
||||
|
||||
@@ -1255,7 +1255,7 @@ transformAExprIn(ParseState *pstate, A_Expr *a)
|
||||
/* ROW() op ROW() is handled specially */
|
||||
cmp = make_row_comparison_op(pstate,
|
||||
a->name,
|
||||
copyObject(((RowExpr *) lexpr)->args),
|
||||
copyObject(((RowExpr *) lexpr)->args),
|
||||
((RowExpr *) rexpr)->args,
|
||||
a->location);
|
||||
}
|
||||
|
||||
@@ -1164,6 +1164,7 @@ parserOpenTable(ParseState *pstate, const RangeVar *relation, int lockmode)
|
||||
*/
|
||||
if (get_visible_ENR_metadata(pstate->p_queryEnv, relation->relname))
|
||||
rel = NULL;
|
||||
|
||||
/*
|
||||
* An unqualified name might have been meant as a reference to
|
||||
* some not-yet-in-scope CTE. The bare "does not exist" message
|
||||
@@ -2002,7 +2003,7 @@ addRangeTableEntryForENR(ParseState *pstate,
|
||||
|
||||
default:
|
||||
elog(ERROR, "unexpected enrtype: %d", enrmd->enrtype);
|
||||
return NULL; /* for fussy compilers */
|
||||
return NULL; /* for fussy compilers */
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -363,7 +363,7 @@ generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column,
|
||||
char **snamespace_p, char **sname_p)
|
||||
{
|
||||
ListCell *option;
|
||||
DefElem *nameEl = NULL;
|
||||
DefElem *nameEl = NULL;
|
||||
Oid snamespaceid;
|
||||
char *snamespace;
|
||||
char *sname;
|
||||
@@ -378,12 +378,12 @@ generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column,
|
||||
* used by pg_dump. Else, generate a name.
|
||||
*
|
||||
* Although we use ChooseRelationName, it's not guaranteed that the
|
||||
* selected sequence name won't conflict; given sufficiently long
|
||||
* field names, two different serial columns in the same table could
|
||||
* be assigned the same sequence name, and we'd not notice since we
|
||||
* aren't creating the sequence quite yet. In practice this seems
|
||||
* quite unlikely to be a problem, especially since few people would
|
||||
* need two serial columns in one table.
|
||||
* selected sequence name won't conflict; given sufficiently long field
|
||||
* names, two different serial columns in the same table could be assigned
|
||||
* the same sequence name, and we'd not notice since we aren't creating
|
||||
* the sequence quite yet. In practice this seems quite unlikely to be a
|
||||
* problem, especially since few people would need two serial columns in
|
||||
* one table.
|
||||
*/
|
||||
|
||||
foreach(option, seqoptions)
|
||||
@@ -402,7 +402,8 @@ generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column,
|
||||
|
||||
if (nameEl)
|
||||
{
|
||||
RangeVar *rv = makeRangeVarFromNameList(castNode(List, nameEl->arg));
|
||||
RangeVar *rv = makeRangeVarFromNameList(castNode(List, nameEl->arg));
|
||||
|
||||
snamespace = rv->schemaname;
|
||||
sname = rv->relname;
|
||||
seqoptions = list_delete_ptr(seqoptions, nameEl);
|
||||
@@ -429,14 +430,14 @@ generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column,
|
||||
cxt->relation->relname, column->colname)));
|
||||
|
||||
/*
|
||||
* Build a CREATE SEQUENCE command to create the sequence object, and
|
||||
* add it to the list of things to be done before this CREATE/ALTER
|
||||
* TABLE.
|
||||
* Build a CREATE SEQUENCE command to create the sequence object, and add
|
||||
* it to the list of things to be done before this CREATE/ALTER TABLE.
|
||||
*/
|
||||
seqstmt = makeNode(CreateSeqStmt);
|
||||
seqstmt->for_identity = for_identity;
|
||||
seqstmt->sequence = makeRangeVar(snamespace, sname, -1);
|
||||
seqstmt->options = seqoptions;
|
||||
|
||||
/*
|
||||
* If a sequence data type was specified, add it to the options. Prepend
|
||||
* to the list rather than append; in case a user supplied their own AS
|
||||
@@ -448,11 +449,11 @@ generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column,
|
||||
seqstmt->options);
|
||||
|
||||
/*
|
||||
* If this is ALTER ADD COLUMN, make sure the sequence will be owned
|
||||
* by the table's owner. The current user might be someone else
|
||||
* (perhaps a superuser, or someone who's only a member of the owning
|
||||
* role), but the SEQUENCE OWNED BY mechanisms will bleat unless table
|
||||
* and sequence have exactly the same owning role.
|
||||
* If this is ALTER ADD COLUMN, make sure the sequence will be owned by
|
||||
* the table's owner. The current user might be someone else (perhaps a
|
||||
* superuser, or someone who's only a member of the owning role), but the
|
||||
* SEQUENCE OWNED BY mechanisms will bleat unless table and sequence have
|
||||
* exactly the same owning role.
|
||||
*/
|
||||
if (cxt->rel)
|
||||
seqstmt->ownerId = cxt->rel->rd_rel->relowner;
|
||||
@@ -462,9 +463,9 @@ generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column,
|
||||
cxt->blist = lappend(cxt->blist, seqstmt);
|
||||
|
||||
/*
|
||||
* Build an ALTER SEQUENCE ... OWNED BY command to mark the sequence
|
||||
* as owned by this column, and add it to the list of things to be
|
||||
* done after this CREATE/ALTER TABLE.
|
||||
* Build an ALTER SEQUENCE ... OWNED BY command to mark the sequence as
|
||||
* owned by this column, and add it to the list of things to be done after
|
||||
* this CREATE/ALTER TABLE.
|
||||
*/
|
||||
altseqstmt = makeNode(AlterSeqStmt);
|
||||
altseqstmt->sequence = makeRangeVar(snamespace, sname, -1);
|
||||
@@ -647,31 +648,31 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
|
||||
break;
|
||||
|
||||
case CONSTR_IDENTITY:
|
||||
{
|
||||
Type ctype;
|
||||
Oid typeOid;
|
||||
{
|
||||
Type ctype;
|
||||
Oid typeOid;
|
||||
|
||||
ctype = typenameType(cxt->pstate, column->typeName, NULL);
|
||||
typeOid = HeapTupleGetOid(ctype);
|
||||
ReleaseSysCache(ctype);
|
||||
ctype = typenameType(cxt->pstate, column->typeName, NULL);
|
||||
typeOid = HeapTupleGetOid(ctype);
|
||||
ReleaseSysCache(ctype);
|
||||
|
||||
if (saw_identity)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("multiple identity specifications for column \"%s\" of table \"%s\"",
|
||||
if (saw_identity)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("multiple identity specifications for column \"%s\" of table \"%s\"",
|
||||
column->colname, cxt->relation->relname),
|
||||
parser_errposition(cxt->pstate,
|
||||
constraint->location)));
|
||||
parser_errposition(cxt->pstate,
|
||||
constraint->location)));
|
||||
|
||||
generateSerialExtraStmts(cxt, column,
|
||||
typeOid, constraint->options, true,
|
||||
NULL, NULL);
|
||||
generateSerialExtraStmts(cxt, column,
|
||||
typeOid, constraint->options, true,
|
||||
NULL, NULL);
|
||||
|
||||
column->identity = constraint->generated_when;
|
||||
saw_identity = true;
|
||||
column->is_not_null = TRUE;
|
||||
break;
|
||||
}
|
||||
column->identity = constraint->generated_when;
|
||||
saw_identity = true;
|
||||
column->is_not_null = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
case CONSTR_CHECK:
|
||||
cxt->ckconstraints = lappend(cxt->ckconstraints, constraint);
|
||||
@@ -1036,7 +1037,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
|
||||
if (attribute->attidentity &&
|
||||
(table_like_clause->options & CREATE_TABLE_LIKE_IDENTITY))
|
||||
{
|
||||
Oid seq_relid;
|
||||
Oid seq_relid;
|
||||
List *seq_options;
|
||||
|
||||
/*
|
||||
@@ -1067,7 +1068,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
|
||||
|
||||
stmt->objtype = OBJECT_COLUMN;
|
||||
stmt->object = (Node *) list_make3(makeString(cxt->relation->schemaname),
|
||||
makeString(cxt->relation->relname),
|
||||
makeString(cxt->relation->relname),
|
||||
makeString(def->colname));
|
||||
stmt->comment = comment;
|
||||
|
||||
@@ -1132,7 +1133,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
|
||||
|
||||
stmt->objtype = OBJECT_TABCONSTRAINT;
|
||||
stmt->object = (Node *) list_make3(makeString(cxt->relation->schemaname),
|
||||
makeString(cxt->relation->relname),
|
||||
makeString(cxt->relation->relname),
|
||||
makeString(n->conname));
|
||||
stmt->comment = comment;
|
||||
|
||||
@@ -2766,7 +2767,11 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
|
||||
* change the data type of the sequence.
|
||||
*/
|
||||
attnum = get_attnum(relid, cmd->name);
|
||||
/* if attribute not found, something will error about it later */
|
||||
|
||||
/*
|
||||
* if attribute not found, something will error about it
|
||||
* later
|
||||
*/
|
||||
if (attnum != InvalidAttrNumber && get_attidentity(relid, attnum))
|
||||
{
|
||||
Oid seq_relid = getOwnedSequence(relid, attnum);
|
||||
@@ -2774,7 +2779,7 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
|
||||
AlterSeqStmt *altseqstmt = makeNode(AlterSeqStmt);
|
||||
|
||||
altseqstmt->sequence = makeRangeVar(get_namespace_name(get_rel_namespace(seq_relid)),
|
||||
get_rel_name(seq_relid),
|
||||
get_rel_name(seq_relid),
|
||||
-1);
|
||||
altseqstmt->options = list_make1(makeDefElem("as", (Node *) makeTypeNameFromOid(typeOid, -1), -1));
|
||||
altseqstmt->for_identity = true;
|
||||
@@ -2787,8 +2792,8 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
|
||||
|
||||
case AT_AddIdentity:
|
||||
{
|
||||
Constraint *def = castNode(Constraint, cmd->def);
|
||||
ColumnDef *newdef = makeNode(ColumnDef);
|
||||
Constraint *def = castNode(Constraint, cmd->def);
|
||||
ColumnDef *newdef = makeNode(ColumnDef);
|
||||
AttrNumber attnum;
|
||||
|
||||
newdef->colname = cmd->name;
|
||||
@@ -2796,7 +2801,11 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
|
||||
cmd->def = (Node *) newdef;
|
||||
|
||||
attnum = get_attnum(relid, cmd->name);
|
||||
/* if attribute not found, something will error about it later */
|
||||
|
||||
/*
|
||||
* if attribute not found, something will error about it
|
||||
* later
|
||||
*/
|
||||
if (attnum != InvalidAttrNumber)
|
||||
generateSerialExtraStmts(&cxt, newdef,
|
||||
get_atttype(relid, attnum),
|
||||
@@ -2825,7 +2834,7 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
|
||||
*/
|
||||
foreach(lc, castNode(List, cmd->def))
|
||||
{
|
||||
DefElem *def = lfirst_node(DefElem, lc);
|
||||
DefElem *def = lfirst_node(DefElem, lc);
|
||||
|
||||
if (strcmp(def->defname, "generated") == 0)
|
||||
newdef = lappend(newdef, def);
|
||||
@@ -2846,7 +2855,7 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
|
||||
seqstmt = makeNode(AlterSeqStmt);
|
||||
seq_relid = linitial_oid(seqlist);
|
||||
seqstmt->sequence = makeRangeVar(get_namespace_name(get_rel_namespace(seq_relid)),
|
||||
get_rel_name(seq_relid), -1);
|
||||
get_rel_name(seq_relid), -1);
|
||||
seqstmt->options = newseqopts;
|
||||
seqstmt->for_identity = true;
|
||||
seqstmt->missing_ok = false;
|
||||
@@ -2854,8 +2863,11 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
|
||||
cxt.alist = lappend(cxt.alist, seqstmt);
|
||||
}
|
||||
}
|
||||
/* If column was not found or was not an identity column, we
|
||||
* just let the ALTER TABLE command error out later. */
|
||||
|
||||
/*
|
||||
* If column was not found or was not an identity column,
|
||||
* we just let the ALTER TABLE command error out later.
|
||||
*/
|
||||
|
||||
cmd->def = (Node *) newdef;
|
||||
newcmds = lappend(newcmds, cmd);
|
||||
@@ -3392,8 +3404,8 @@ transformPartitionBound(ParseState *pstate, Relation parent, Node *bound)
|
||||
else if (seen_unbounded)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("cannot specify finite value after UNBOUNDED"),
|
||||
parser_errposition(pstate, exprLocation((Node *) ldatum))));
|
||||
errmsg("cannot specify finite value after UNBOUNDED"),
|
||||
parser_errposition(pstate, exprLocation((Node *) ldatum))));
|
||||
}
|
||||
seen_unbounded = false;
|
||||
foreach(cell1, spec->upperdatums)
|
||||
@@ -3406,8 +3418,8 @@ transformPartitionBound(ParseState *pstate, Relation parent, Node *bound)
|
||||
else if (seen_unbounded)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("cannot specify finite value after UNBOUNDED"),
|
||||
parser_errposition(pstate, exprLocation((Node *) rdatum))));
|
||||
errmsg("cannot specify finite value after UNBOUNDED"),
|
||||
parser_errposition(pstate, exprLocation((Node *) rdatum))));
|
||||
}
|
||||
|
||||
i = j = 0;
|
||||
|
||||
Reference in New Issue
Block a user