mirror of
https://github.com/postgres/postgres.git
synced 2025-08-27 07:42:10 +03:00
pgindent run for release 9.3
This is the first run of the Perl-based pgindent script. Also update pgindent instructions.
This commit is contained in:
@@ -241,7 +241,7 @@ DefineQueryRewrite(char *rulename,
|
||||
ListCell *l;
|
||||
Query *query;
|
||||
bool RelisBecomingView = false;
|
||||
Oid ruleId = InvalidOid;
|
||||
Oid ruleId = InvalidOid;
|
||||
|
||||
/*
|
||||
* If we are installing an ON SELECT rule, we had better grab
|
||||
@@ -517,11 +517,11 @@ DefineQueryRewrite(char *rulename,
|
||||
* If the relation is becoming a view:
|
||||
* - delete the associated storage files
|
||||
* - get rid of any system attributes in pg_attribute; a view shouldn't
|
||||
* have any of those
|
||||
* have any of those
|
||||
* - remove the toast table; there is no need for it anymore, and its
|
||||
* presence would make vacuum slightly more complicated
|
||||
* presence would make vacuum slightly more complicated
|
||||
* - set relkind to RELKIND_VIEW, and adjust other pg_class fields
|
||||
* to be appropriate for a view
|
||||
* to be appropriate for a view
|
||||
*
|
||||
* NB: we had better have AccessExclusiveLock to do this ...
|
||||
* ---------------------------------------------------------------------
|
||||
@@ -541,9 +541,9 @@ DefineQueryRewrite(char *rulename,
|
||||
DeleteSystemAttributeTuples(event_relid);
|
||||
|
||||
/*
|
||||
* Drop the toast table if any. (This won't take care of updating
|
||||
* the toast fields in the relation's own pg_class entry; we handle
|
||||
* that below.)
|
||||
* Drop the toast table if any. (This won't take care of updating the
|
||||
* toast fields in the relation's own pg_class entry; we handle that
|
||||
* below.)
|
||||
*/
|
||||
if (OidIsValid(toastrelid))
|
||||
{
|
||||
|
@@ -56,7 +56,7 @@ static void rewriteValuesRTE(RangeTblEntry *rte, Relation target_relation,
|
||||
static void rewriteTargetListUD(Query *parsetree, RangeTblEntry *target_rte,
|
||||
Relation target_relation);
|
||||
static void markQueryForLocking(Query *qry, Node *jtnode,
|
||||
LockClauseStrength strength, bool noWait, bool pushedDown);
|
||||
LockClauseStrength strength, bool noWait, bool pushedDown);
|
||||
static List *matchLocks(CmdType event, RuleLock *rulelocks,
|
||||
int varno, Query *parsetree);
|
||||
static Query *fireRIRrules(Query *parsetree, List *activeRIRs,
|
||||
@@ -131,9 +131,9 @@ AcquireRewriteLocks(Query *parsetree, bool forUpdatePushedDown)
|
||||
*
|
||||
* If the relation is the query's result relation, then we
|
||||
* need RowExclusiveLock. Otherwise, check to see if the
|
||||
* relation is accessed FOR [KEY] UPDATE/SHARE or not. We can't
|
||||
* just grab AccessShareLock because then the executor would
|
||||
* be trying to upgrade the lock, leading to possible
|
||||
* relation is accessed FOR [KEY] UPDATE/SHARE or not. We
|
||||
* can't just grab AccessShareLock because then the executor
|
||||
* would be trying to upgrade the lock, leading to possible
|
||||
* deadlocks.
|
||||
*/
|
||||
if (rt_index == parsetree->resultRelation)
|
||||
@@ -1375,8 +1375,8 @@ ApplyRetrieveRule(Query *parsetree,
|
||||
}
|
||||
|
||||
/*
|
||||
* If FOR [KEY] UPDATE/SHARE of view, be sure we get right initial lock on the
|
||||
* relations it references.
|
||||
* If FOR [KEY] UPDATE/SHARE of view, be sure we get right initial lock on
|
||||
* the relations it references.
|
||||
*/
|
||||
rc = get_parse_rowmark(parsetree, rt_index);
|
||||
forUpdatePushedDown |= (rc != NULL);
|
||||
@@ -1423,9 +1423,9 @@ ApplyRetrieveRule(Query *parsetree,
|
||||
rte->modifiedCols = NULL;
|
||||
|
||||
/*
|
||||
* If FOR [KEY] UPDATE/SHARE of view, mark all the contained tables as implicit
|
||||
* FOR [KEY] UPDATE/SHARE, the same as the parser would have done if the view's
|
||||
* subquery had been written out explicitly.
|
||||
* If FOR [KEY] UPDATE/SHARE of view, mark all the contained tables as
|
||||
* implicit FOR [KEY] UPDATE/SHARE, the same as the parser would have done
|
||||
* if the view's subquery had been written out explicitly.
|
||||
*
|
||||
* Note: we don't consider forUpdatePushedDown here; such marks will be
|
||||
* made by recursing from the upper level in markQueryForLocking.
|
||||
@@ -2089,9 +2089,9 @@ relation_is_updatable(Oid reloid, int req_events)
|
||||
|
||||
/*
|
||||
* If the relation doesn't exist, say "false" rather than throwing an
|
||||
* error. This is helpful since scanning an information_schema view
|
||||
* under MVCC rules can result in referencing rels that were just
|
||||
* deleted according to a SnapshotNow probe.
|
||||
* error. This is helpful since scanning an information_schema view under
|
||||
* MVCC rules can result in referencing rels that were just deleted
|
||||
* according to a SnapshotNow probe.
|
||||
*/
|
||||
if (rel == NULL)
|
||||
return false;
|
||||
@@ -2378,7 +2378,7 @@ rewriteTargetView(Query *parsetree, Relation view)
|
||||
* that does not correspond to what happens in ordinary SELECT usage of a
|
||||
* view: all referenced columns must have read permission, even if
|
||||
* optimization finds that some of them can be discarded during query
|
||||
* transformation. The flattening we're doing here is an optional
|
||||
* transformation. The flattening we're doing here is an optional
|
||||
* optimization, too. (If you are unpersuaded and want to change this,
|
||||
* note that applying adjust_view_column_set to view_rte->selectedCols is
|
||||
* clearly *not* the right answer, since that neglects base-rel columns
|
||||
@@ -2680,10 +2680,10 @@ RewriteQuery(Query *parsetree, List *rewrite_events)
|
||||
parsetree = rewriteTargetView(parsetree, rt_entry_relation);
|
||||
|
||||
/*
|
||||
* At this point product_queries contains any DO ALSO rule actions.
|
||||
* Add the rewritten query before or after those. This must match
|
||||
* the handling the original query would have gotten below, if
|
||||
* we allowed it to be included again.
|
||||
* At this point product_queries contains any DO ALSO rule
|
||||
* actions. Add the rewritten query before or after those. This
|
||||
* must match the handling the original query would have gotten
|
||||
* below, if we allowed it to be included again.
|
||||
*/
|
||||
if (parsetree->commandType == CMD_INSERT)
|
||||
product_queries = lcons(parsetree, product_queries);
|
||||
@@ -2701,43 +2701,43 @@ RewriteQuery(Query *parsetree, List *rewrite_events)
|
||||
returning = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we got any product queries, recursively rewrite them --- but
|
||||
* first check for recursion!
|
||||
*/
|
||||
if (product_queries != NIL)
|
||||
/*
|
||||
* If we got any product queries, recursively rewrite them --- but
|
||||
* first check for recursion!
|
||||
*/
|
||||
if (product_queries != NIL)
|
||||
{
|
||||
ListCell *n;
|
||||
rewrite_event *rev;
|
||||
|
||||
foreach(n, rewrite_events)
|
||||
{
|
||||
ListCell *n;
|
||||
rewrite_event *rev;
|
||||
|
||||
foreach(n, rewrite_events)
|
||||
{
|
||||
rev = (rewrite_event *) lfirst(n);
|
||||
if (rev->relation == RelationGetRelid(rt_entry_relation) &&
|
||||
rev->event == event)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("infinite recursion detected in rules for relation \"%s\"",
|
||||
rev = (rewrite_event *) lfirst(n);
|
||||
if (rev->relation == RelationGetRelid(rt_entry_relation) &&
|
||||
rev->event == event)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("infinite recursion detected in rules for relation \"%s\"",
|
||||
RelationGetRelationName(rt_entry_relation))));
|
||||
}
|
||||
|
||||
rev = (rewrite_event *) palloc(sizeof(rewrite_event));
|
||||
rev->relation = RelationGetRelid(rt_entry_relation);
|
||||
rev->event = event;
|
||||
rewrite_events = lcons(rev, rewrite_events);
|
||||
|
||||
foreach(n, product_queries)
|
||||
{
|
||||
Query *pt = (Query *) lfirst(n);
|
||||
List *newstuff;
|
||||
|
||||
newstuff = RewriteQuery(pt, rewrite_events);
|
||||
rewritten = list_concat(rewritten, newstuff);
|
||||
}
|
||||
|
||||
rewrite_events = list_delete_first(rewrite_events);
|
||||
}
|
||||
|
||||
rev = (rewrite_event *) palloc(sizeof(rewrite_event));
|
||||
rev->relation = RelationGetRelid(rt_entry_relation);
|
||||
rev->event = event;
|
||||
rewrite_events = lcons(rev, rewrite_events);
|
||||
|
||||
foreach(n, product_queries)
|
||||
{
|
||||
Query *pt = (Query *) lfirst(n);
|
||||
List *newstuff;
|
||||
|
||||
newstuff = RewriteQuery(pt, rewrite_events);
|
||||
rewritten = list_concat(rewritten, newstuff);
|
||||
}
|
||||
|
||||
rewrite_events = list_delete_first(rewrite_events);
|
||||
}
|
||||
|
||||
/*
|
||||
* If there is an INSTEAD, and the original query has a RETURNING, we
|
||||
* have to have found a RETURNING in the rule(s), else fail. (Because
|
||||
|
@@ -1221,7 +1221,7 @@ replace_rte_variables_mutator(Node *node,
|
||||
* If the expression tree contains a whole-row Var for the target RTE,
|
||||
* the Var is not changed but *found_whole_row is returned as TRUE.
|
||||
* For most callers this is an error condition, but we leave it to the caller
|
||||
* to report the error so that useful context can be provided. (In some
|
||||
* to report the error so that useful context can be provided. (In some
|
||||
* usages it would be appropriate to modify the Var's vartype and insert a
|
||||
* ConvertRowtypeExpr node to map back to the original vartype. We might
|
||||
* someday extend this function's API to support that. For now, the only
|
||||
@@ -1235,10 +1235,10 @@ replace_rte_variables_mutator(Node *node,
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int target_varno; /* RTE index to search for */
|
||||
int sublevels_up; /* (current) nesting depth */
|
||||
int target_varno; /* RTE index to search for */
|
||||
int sublevels_up; /* (current) nesting depth */
|
||||
const AttrNumber *attno_map; /* map array for user attnos */
|
||||
int map_length; /* number of entries in attno_map[] */
|
||||
int map_length; /* number of entries in attno_map[] */
|
||||
bool *found_whole_row; /* output flag */
|
||||
} map_variable_attnos_context;
|
||||
|
||||
@@ -1256,8 +1256,8 @@ map_variable_attnos_mutator(Node *node,
|
||||
var->varlevelsup == context->sublevels_up)
|
||||
{
|
||||
/* Found a matching variable, make the substitution */
|
||||
Var *newvar = (Var *) palloc(sizeof(Var));
|
||||
int attno = var->varattno;
|
||||
Var *newvar = (Var *) palloc(sizeof(Var));
|
||||
int attno = var->varattno;
|
||||
|
||||
*newvar = *var;
|
||||
if (attno > 0)
|
||||
@@ -1406,13 +1406,14 @@ ReplaceVarsFromTargetList_callback(Var *var,
|
||||
return (Node *) var;
|
||||
|
||||
case REPLACEVARS_SUBSTITUTE_NULL:
|
||||
|
||||
/*
|
||||
* If Var is of domain type, we should add a CoerceToDomain
|
||||
* node, in case there is a NOT NULL domain constraint.
|
||||
*/
|
||||
return coerce_to_domain((Node *) makeNullConst(var->vartype,
|
||||
var->vartypmod,
|
||||
var->varcollid),
|
||||
var->varcollid),
|
||||
InvalidOid, -1,
|
||||
var->vartype,
|
||||
COERCE_IMPLICIT_CAST,
|
||||
|
Reference in New Issue
Block a user