1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Pre-beta mechanical code beautification.

Run pgindent, pgperltidy, and reformat-dat-files.
I manually fixed a couple of comments that pgindent uglified.
This commit is contained in:
Tom Lane
2022-05-12 15:17:30 -04:00
parent 93909599cd
commit 23e7b38bfe
287 changed files with 5193 additions and 3549 deletions

View File

@ -104,8 +104,8 @@ static bool test_raw_expression_coverage(Node *node, void *context);
*/
Query *
parse_analyze_fixedparams(RawStmt *parseTree, const char *sourceText,
const Oid *paramTypes, int numParams,
QueryEnvironment *queryEnv)
const Oid *paramTypes, int numParams,
QueryEnvironment *queryEnv)
{
ParseState *pstate = make_parsestate(NULL);
Query *query;
@ -2076,8 +2076,8 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt,
ListCell *ltl;
ListCell *rtl;
const char *context;
bool recursive = (pstate->p_parent_cte &&
pstate->p_parent_cte->cterecursive);
bool recursive = (pstate->p_parent_cte &&
pstate->p_parent_cte->cterecursive);
context = (stmt->op == SETOP_UNION ? "UNION" :
(stmt->op == SETOP_INTERSECT ? "INTERSECT" :
@ -2231,7 +2231,10 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt,
setup_parser_errposition_callback(&pcbstate, pstate,
bestlocation);
/* If it's a recursive union, we need to require hashing support. */
/*
* If it's a recursive union, we need to require hashing
* support.
*/
op->groupClauses = lappend(op->groupClauses,
makeSortGroupClauseForSetOp(rescoltype, recursive));

View File

@ -2004,7 +2004,7 @@ findTargetlistEntrySQL92(ParseState *pstate, Node *node, List **tlist,
}
if (IsA(node, A_Const))
{
A_Const *aconst = castNode(A_Const, node);
A_Const *aconst = castNode(A_Const, node);
int targetlist_pos = 0;
int target_pos;

View File

@ -692,8 +692,11 @@ assign_collations_walker(Node *node, assign_collations_context *context)
}
break;
case T_JsonExpr:
/* Context item and PASSING arguments are already
* marked with collations in parse_expr.c. */
/*
* Context item and PASSING arguments are already
* marked with collations in parse_expr.c.
*/
break;
default:

View File

@ -3277,7 +3277,7 @@ transformJsonValueExprExt(ParseState *pstate, JsonValueExpr *ve,
if (exprtype == JSONOID || exprtype == JSONBOID)
{
format = JS_FORMAT_DEFAULT; /* do not format json[b] types */
format = JS_FORMAT_DEFAULT; /* do not format json[b] types */
ereport(WARNING,
(errmsg("FORMAT JSON has no effect for json and jsonb types"),
parser_errposition(pstate, ve->format->location)));
@ -3316,7 +3316,7 @@ transformJsonValueExprExt(ParseState *pstate, JsonValueExpr *ve,
format = default_format;
}
else if (exprtype == JSONOID || exprtype == JSONBOID)
format = JS_FORMAT_DEFAULT; /* do not format json[b] types */
format = JS_FORMAT_DEFAULT; /* do not format json[b] types */
else
format = default_format;
@ -3364,13 +3364,13 @@ transformJsonValueExprExt(ParseState *pstate, JsonValueExpr *ve,
FuncExpr *fexpr;
Oid fnoid;
if (cast_is_needed) /* only CAST is allowed */
if (cast_is_needed) /* only CAST is allowed */
ereport(ERROR,
(errcode(ERRCODE_CANNOT_COERCE),
errmsg("cannot cast type %s to %s",
format_type_be(exprtype),
format_type_be(targettype)),
parser_errposition(pstate, location)));
parser_errposition(pstate, location)));
fnoid = targettype == JSONOID ? F_TO_JSON : F_TO_JSONB;
fexpr = makeFuncExpr(fnoid, targettype, list_make1(expr),
@ -3444,7 +3444,7 @@ checkJsonOutputFormat(ParseState *pstate, const JsonFormat *format,
if (format->format_type == JS_FORMAT_JSON)
{
JsonEncoding enc = format->encoding != JS_ENC_DEFAULT ?
format->encoding : JS_ENC_UTF8;
format->encoding : JS_ENC_UTF8;
if (targettype != BYTEAOID &&
format->encoding != JS_ENC_DEFAULT)
@ -3583,6 +3583,7 @@ coerceJsonFuncExpr(ParseState *pstate, Node *expr,
list_make2(texpr, enc),
InvalidOid, InvalidOid,
COERCE_EXPLICIT_CALL);
fexpr->location = location;
return (Node *) fexpr;
@ -3591,7 +3592,7 @@ coerceJsonFuncExpr(ParseState *pstate, Node *expr,
/* try to coerce expression to the output type */
res = coerce_to_target_type(pstate, expr, exprtype,
returning->typid, returning->typmod,
/* XXX throwing errors when casting to char(N) */
/* XXX throwing errors when casting to char(N) */
COERCION_EXPLICIT,
COERCE_EXPLICIT_CAST,
location);
@ -3616,7 +3617,7 @@ makeJsonConstructorExpr(ParseState *pstate, JsonConstructorType type,
Node *placeholder;
Node *coercion;
Oid intermediate_typid =
returning->format->format_type == JS_FORMAT_JSONB ? JSONBOID : JSONOID;
returning->format->format_type == JS_FORMAT_JSONB ? JSONBOID : JSONOID;
jsctor->args = args;
jsctor->func = fexpr;
@ -3694,7 +3695,7 @@ static Node *
transformJsonArrayQueryConstructor(ParseState *pstate,
JsonArrayQueryConstructor *ctor)
{
SubLink *sublink = makeNode(SubLink);
SubLink *sublink = makeNode(SubLink);
SelectStmt *select = makeNode(SelectStmt);
RangeSubselect *range = makeNode(RangeSubselect);
Alias *alias = makeNode(Alias);
@ -3766,8 +3767,8 @@ transformJsonAggConstructor(ParseState *pstate, JsonAggConstructor *agg_ctor,
Oid aggfnoid;
Node *node;
Expr *aggfilter = agg_ctor->agg_filter ? (Expr *)
transformWhereClause(pstate, agg_ctor->agg_filter,
EXPR_KIND_FILTER, "FILTER") : NULL;
transformWhereClause(pstate, agg_ctor->agg_filter,
EXPR_KIND_FILTER, "FILTER") : NULL;
aggfnoid = DatumGetInt32(DirectFunctionCall1(regprocin,
CStringGetDatum(aggfn)));
@ -3809,7 +3810,7 @@ transformJsonAggConstructor(ParseState *pstate, JsonAggConstructor *agg_ctor,
aggref->aggtype = aggtype;
/* aggcollid and inputcollid will be set by parse_collate.c */
aggref->aggtranstype = InvalidOid; /* will be set by planner */
aggref->aggtranstype = InvalidOid; /* will be set by planner */
/* aggargtypes will be set by transformAggregateCall */
/* aggdirectargs and args will be set by transformAggregateCall */
/* aggorder and aggdistinct will be set by transformAggregateCall */
@ -3818,7 +3819,7 @@ transformJsonAggConstructor(ParseState *pstate, JsonAggConstructor *agg_ctor,
aggref->aggvariadic = false;
aggref->aggkind = AGGKIND_NORMAL;
/* agglevelsup will be set by transformAggregateCall */
aggref->aggsplit = AGGSPLIT_SIMPLE; /* planner might change this */
aggref->aggsplit = AGGSPLIT_SIMPLE; /* planner might change this */
aggref->location = agg_ctor->location;
transformAggregateCall(pstate, aggref, args, agg_ctor->agg_order, false);
@ -3860,14 +3861,13 @@ transformJsonObjectAgg(ParseState *pstate, JsonObjectAgg *agg)
{
if (agg->absent_on_null)
if (agg->unique)
aggfnname = "pg_catalog.jsonb_object_agg_unique_strict"; /* F_JSONB_OBJECT_AGG_UNIQUE_STRICT */
aggfnname = "pg_catalog.jsonb_object_agg_unique_strict"; /* F_JSONB_OBJECT_AGG_UNIQUE_STRICT */
else
aggfnname = "pg_catalog.jsonb_object_agg_strict"; /* F_JSONB_OBJECT_AGG_STRICT */
aggfnname = "pg_catalog.jsonb_object_agg_strict"; /* F_JSONB_OBJECT_AGG_STRICT */
else if (agg->unique)
aggfnname = "pg_catalog.jsonb_object_agg_unique"; /* F_JSONB_OBJECT_AGG_UNIQUE */
else
if (agg->unique)
aggfnname = "pg_catalog.jsonb_object_agg_unique"; /* F_JSONB_OBJECT_AGG_UNIQUE */
else
aggfnname = "pg_catalog.jsonb_object_agg"; /* F_JSONB_OBJECT_AGG */
aggfnname = "pg_catalog.jsonb_object_agg"; /* F_JSONB_OBJECT_AGG */
aggtype = JSONBOID;
}
@ -3877,12 +3877,11 @@ transformJsonObjectAgg(ParseState *pstate, JsonObjectAgg *agg)
if (agg->unique)
aggfnname = "pg_catalog.json_object_agg_unique_strict"; /* F_JSON_OBJECT_AGG_UNIQUE_STRICT */
else
aggfnname = "pg_catalog.json_object_agg_strict"; /* F_JSON_OBJECT_AGG_STRICT */
aggfnname = "pg_catalog.json_object_agg_strict"; /* F_JSON_OBJECT_AGG_STRICT */
else if (agg->unique)
aggfnname = "pg_catalog.json_object_agg_unique"; /* F_JSON_OBJECT_AGG_UNIQUE */
else
if (agg->unique)
aggfnname = "pg_catalog.json_object_agg_unique"; /* F_JSON_OBJECT_AGG_UNIQUE */
else
aggfnname = "pg_catalog.json_object_agg"; /* F_JSON_OBJECT_AGG */
aggfnname = "pg_catalog.json_object_agg"; /* F_JSON_OBJECT_AGG */
aggtype = JSONOID;
}
@ -4209,7 +4208,7 @@ coerceJsonExpr(ParseState *pstate, Node *expr, const JsonReturning *returning)
* Transform a JSON output clause of JSON_VALUE and JSON_QUERY.
*/
static void
transformJsonFuncExprOutput(ParseState *pstate, JsonFuncExpr *func,
transformJsonFuncExprOutput(ParseState *pstate, JsonFuncExpr *func,
JsonExpr *jsexpr)
{
Node *expr = jsexpr->formatted_expr;
@ -4333,19 +4332,19 @@ initJsonItemCoercions(ParseState *pstate, JsonItemCoercions *coercions,
Oid typid;
} *p,
coercionTypids[] =
{
{ &coercions->null, UNKNOWNOID },
{ &coercions->string, TEXTOID },
{ &coercions->numeric, NUMERICOID },
{ &coercions->boolean, BOOLOID },
{ &coercions->date, DATEOID },
{ &coercions->time, TIMEOID },
{ &coercions->timetz, TIMETZOID },
{ &coercions->timestamp, TIMESTAMPOID },
{ &coercions->timestamptz, TIMESTAMPTZOID },
{ &coercions->composite, contextItemTypeId },
{ NULL, InvalidOid }
};
{
{&coercions->null, UNKNOWNOID},
{&coercions->string, TEXTOID},
{&coercions->numeric, NUMERICOID},
{&coercions->boolean, BOOLOID},
{&coercions->date, DATEOID},
{&coercions->time, TIMEOID},
{&coercions->timetz, TIMETZOID},
{&coercions->timestamp, TIMESTAMPOID},
{&coercions->timestamptz, TIMESTAMPTZOID},
{&coercions->composite, contextItemTypeId},
{NULL, InvalidOid}
};
for (p = coercionTypids; p->coercion; p++)
*p->coercion = initJsonItemCoercion(pstate, p->typid, returning);
@ -4512,7 +4511,7 @@ static Node *
transformJsonParseExpr(ParseState *pstate, JsonParseExpr *jsexpr)
{
JsonReturning *returning = transformJsonConstructorRet(pstate, jsexpr->output,
"JSON()");
"JSON()");
Node *arg;
if (jsexpr->unique_keys)
@ -4544,8 +4543,8 @@ transformJsonParseExpr(ParseState *pstate, JsonParseExpr *jsexpr)
}
return makeJsonConstructorExpr(pstate, JSCTOR_JSON_PARSE, list_make1(arg), NULL,
returning, jsexpr->unique_keys, false,
jsexpr->location);
returning, jsexpr->unique_keys, false,
jsexpr->location);
}
/*
@ -4556,13 +4555,13 @@ transformJsonScalarExpr(ParseState *pstate, JsonScalarExpr *jsexpr)
{
Node *arg = transformExprRecurse(pstate, (Node *) jsexpr->expr);
JsonReturning *returning = transformJsonConstructorRet(pstate, jsexpr->output,
"JSON_SCALAR()");
"JSON_SCALAR()");
if (exprType(arg) == UNKNOWNOID)
arg = coerce_to_specific_type(pstate, arg, TEXTOID, "JSON_SCALAR");
return makeJsonConstructorExpr(pstate, JSCTOR_JSON_SCALAR, list_make1(arg), NULL,
returning, false, false, jsexpr->location);
returning, false, false, jsexpr->location);
}
/*
@ -4586,5 +4585,5 @@ transformJsonSerializeExpr(ParseState *pstate, JsonSerializeExpr *expr)
}
return makeJsonConstructorExpr(pstate, JSCTOR_JSON_SERIALIZE, list_make1(arg),
NULL, returning, false, false, expr->location);
NULL, returning, false, false, expr->location);
}

View File

@ -33,31 +33,31 @@
/* Context for JSON_TABLE transformation */
typedef struct JsonTableContext
{
ParseState *pstate; /* parsing state */
JsonTable *table; /* untransformed node */
TableFunc *tablefunc; /* transformed node */
List *pathNames; /* list of all path and columns names */
int pathNameId; /* path name id counter */
ParseState *pstate; /* parsing state */
JsonTable *table; /* untransformed node */
TableFunc *tablefunc; /* transformed node */
List *pathNames; /* list of all path and columns names */
int pathNameId; /* path name id counter */
Oid contextItemTypid; /* type oid of context item (json/jsonb) */
} JsonTableContext;
static JsonTableParent * transformJsonTableColumns(JsonTableContext *cxt,
JsonTablePlan *plan,
List *columns,
char *pathSpec,
char **pathName,
int location);
static JsonTableParent *transformJsonTableColumns(JsonTableContext *cxt,
JsonTablePlan *plan,
List *columns,
char *pathSpec,
char **pathName,
int location);
static Node *
makeStringConst(char *str, int location)
{
A_Const *n = makeNode(A_Const);
A_Const *n = makeNode(A_Const);
n->val.node.type = T_String;
n->val.sval.sval = str;
n->location = location;
return (Node *)n;
return (Node *) n;
}
/*
@ -122,7 +122,7 @@ transformJsonTableColumn(JsonTableColumn *jtc, Node *contextItemExpr,
static bool
isJsonTablePathNameDuplicate(JsonTableContext *cxt, const char *pathname)
{
ListCell *lc;
ListCell *lc;
foreach(lc, cxt->pathNames)
{
@ -342,7 +342,7 @@ transformJsonTableChildPlan(JsonTableContext *cxt, JsonTablePlan *plan,
foreach(lc, columns)
{
JsonTableColumn *jtc = castNode(JsonTableColumn, lfirst(lc));
Node *node;
Node *node;
if (jtc->coltype != JTC_NESTED)
continue;
@ -369,10 +369,10 @@ transformJsonTableChildPlan(JsonTableContext *cxt, JsonTablePlan *plan,
}
else
{
Node *node1 =
transformJsonTableChildPlan(cxt, plan->plan1, columns);
Node *node2 =
transformJsonTableChildPlan(cxt, plan->plan2, columns);
Node *node1 = transformJsonTableChildPlan(cxt, plan->plan1,
columns);
Node *node2 = transformJsonTableChildPlan(cxt, plan->plan2,
columns);
return makeJsonTableSiblingJoin(plan->join_type == JSTPJ_CROSS,
node1, node2);
@ -396,7 +396,7 @@ transformJsonTableChildPlan(JsonTableContext *cxt, JsonTablePlan *plan,
static bool
typeIsComposite(Oid typid)
{
char typtype;
char typtype;
if (typid == JSONOID ||
typid == JSONBOID ||
@ -406,7 +406,7 @@ typeIsComposite(Oid typid)
typtype = get_typtype(typid);
if (typtype == TYPTYPE_COMPOSITE)
if (typtype == TYPTYPE_COMPOSITE)
return true;
if (typtype == TYPTYPE_DOMAIN)
@ -424,7 +424,7 @@ appendJsonTableColumns(JsonTableContext *cxt, List *columns)
JsonTable *jt = cxt->table;
TableFunc *tf = cxt->tablefunc;
bool errorOnError = jt->on_error &&
jt->on_error->btype == JSON_BEHAVIOR_ERROR;
jt->on_error->btype == JSON_BEHAVIOR_ERROR;
foreach(col, columns)
{
@ -436,24 +436,23 @@ appendJsonTableColumns(JsonTableContext *cxt, List *columns)
if (rawc->name)
{
/* make sure column names are unique */
ListCell *colname;
ListCell *colname;
foreach(colname, tf->colnames)
if (!strcmp((const char *) colname, rawc->name))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("column name \"%s\" is not unique",
rawc->name),
parser_errposition(pstate, rawc->location)));
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("column name \"%s\" is not unique",
rawc->name),
parser_errposition(pstate, rawc->location)));
tf->colnames = lappend(tf->colnames,
makeString(pstrdup(rawc->name)));
}
/*
* Determine the type and typmod for the new column. FOR
* ORDINALITY columns are INTEGER by standard; the others are
* user-specified.
* Determine the type and typmod for the new column. FOR ORDINALITY
* columns are INTEGER by standard; the others are user-specified.
*/
switch (rawc->coltype)
{
@ -517,8 +516,8 @@ appendJsonTableColumns(JsonTableContext *cxt, List *columns)
tf->coltypmods = lappend_int(tf->coltypmods, typmod);
tf->colcollations = lappend_oid(tf->colcollations,
type_is_collatable(typid)
? DEFAULT_COLLATION_OID
: InvalidOid);
? DEFAULT_COLLATION_OID
: InvalidOid);
tf->colvalexprs = lappend(tf->colvalexprs, colexpr);
}
}
@ -571,7 +570,7 @@ transformJsonTableColumns(JsonTableContext *cxt, JsonTablePlan *plan,
errdetail("JSON_TABLE columns must contain "
"explicit AS pathname specification if "
"explicit PLAN clause is used"),
parser_errposition(cxt->pstate, location)));
parser_errposition(cxt->pstate, location)));
*pathName = generateJsonTablePathName(cxt);
}
@ -662,14 +661,15 @@ transformJsonTable(ParseState *pstate, JsonTable *jt)
registerAllJsonTableColumns(&cxt, jt->columns);
#if 0 /* XXX it' unclear from the standard whether root path name is mandatory or not */
#if 0 /* XXX it' unclear from the standard whether
* root path name is mandatory or not */
if (plan && plan->plan_type != JSTP_DEFAULT && !rootPathName)
{
/* Assign root path name and create corresponding plan node */
JsonTablePlan *rootNode = makeNode(JsonTablePlan);
JsonTablePlan *rootPlan = (JsonTablePlan *)
makeJsonTableJoinedPlan(JSTPJ_OUTER, (Node *) rootNode,
(Node *) plan, jt->location);
makeJsonTableJoinedPlan(JSTPJ_OUTER, (Node *) rootNode,
(Node *) plan, jt->location);
rootPathName = generateJsonTablePathName(&cxt);

View File

@ -382,55 +382,56 @@ make_const(ParseState *pstate, A_Const *aconst)
break;
case T_Float:
{
/* could be an oversize integer as well as a float ... */
int64 val64;
char *endptr;
errno = 0;
val64 = strtoi64(aconst->val.fval.fval, &endptr, 10);
if (errno == 0 && *endptr == '\0')
{
/*
* It might actually fit in int32. Probably only INT_MIN can
* occur, but we'll code the test generally just to be sure.
*/
int32 val32 = (int32) val64;
/* could be an oversize integer as well as a float ... */
if (val64 == (int64) val32)
int64 val64;
char *endptr;
errno = 0;
val64 = strtoi64(aconst->val.fval.fval, &endptr, 10);
if (errno == 0 && *endptr == '\0')
{
val = Int32GetDatum(val32);
/*
* It might actually fit in int32. Probably only INT_MIN
* can occur, but we'll code the test generally just to be
* sure.
*/
int32 val32 = (int32) val64;
typeid = INT4OID;
typelen = sizeof(int32);
typebyval = true;
if (val64 == (int64) val32)
{
val = Int32GetDatum(val32);
typeid = INT4OID;
typelen = sizeof(int32);
typebyval = true;
}
else
{
val = Int64GetDatum(val64);
typeid = INT8OID;
typelen = sizeof(int64);
typebyval = FLOAT8PASSBYVAL; /* int8 and float8 alike */
}
}
else
{
val = Int64GetDatum(val64);
/* arrange to report location if numeric_in() fails */
setup_parser_errposition_callback(&pcbstate, pstate, aconst->location);
val = DirectFunctionCall3(numeric_in,
CStringGetDatum(aconst->val.fval.fval),
ObjectIdGetDatum(InvalidOid),
Int32GetDatum(-1));
cancel_parser_errposition_callback(&pcbstate);
typeid = INT8OID;
typelen = sizeof(int64);
typebyval = FLOAT8PASSBYVAL; /* int8 and float8 alike */
typeid = NUMERICOID;
typelen = -1; /* variable len */
typebyval = false;
}
break;
}
else
{
/* arrange to report location if numeric_in() fails */
setup_parser_errposition_callback(&pcbstate, pstate, aconst->location);
val = DirectFunctionCall3(numeric_in,
CStringGetDatum(aconst->val.fval.fval),
ObjectIdGetDatum(InvalidOid),
Int32GetDatum(-1));
cancel_parser_errposition_callback(&pcbstate);
typeid = NUMERICOID;
typelen = -1; /* variable len */
typebyval = false;
}
break;
}
case T_Boolean:
val = BoolGetDatum(boolVal(&aconst->val));

View File

@ -65,7 +65,7 @@ static bool query_contains_extern_params_walker(Node *node, void *context);
*/
void
setup_parse_fixed_parameters(ParseState *pstate,
const Oid *paramTypes, int numParams)
const Oid *paramTypes, int numParams)
{
FixedParamState *parstate = palloc(sizeof(FixedParamState));
@ -81,7 +81,7 @@ setup_parse_fixed_parameters(ParseState *pstate,
*/
void
setup_parse_variable_parameters(ParseState *pstate,
Oid **paramTypes, int *numParams)
Oid **paramTypes, int *numParams)
{
VarParamState *parstate = palloc(sizeof(VarParamState));

View File

@ -1990,7 +1990,7 @@ addRangeTableEntryForTableFunc(ParseState *pstate,
{
RangeTblEntry *rte = makeNode(RangeTblEntry);
char *refname = alias ? alias->aliasname :
pstrdup(tf->functype == TFT_XMLTABLE ? "xmltable" : "json_table");
pstrdup(tf->functype == TFT_XMLTABLE ? "xmltable" : "json_table");
Alias *eref;
int numaliases;