mirror of
https://github.com/postgres/postgres.git
synced 2025-10-18 04:29:09 +03:00
pgindent run for 9.5
This commit is contained in:
@@ -2150,6 +2150,7 @@ compute_scalar_stats(VacAttrStatsP stats,
|
||||
/* We always use the default collation for statistics */
|
||||
ssup.ssup_collation = DEFAULT_COLLATION_OID;
|
||||
ssup.ssup_nulls_first = false;
|
||||
|
||||
/*
|
||||
* For now, don't perform abbreviated key conversion, because full values
|
||||
* are required for MCV slot generation. Supporting that optimization
|
||||
|
@@ -861,8 +861,8 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
|
||||
* RLS (returns RLS_ENABLED) or not for this COPY statement.
|
||||
*
|
||||
* If the relation has a row security policy and we are to apply it
|
||||
* then perform a "query" copy and allow the normal query processing to
|
||||
* handle the policies.
|
||||
* then perform a "query" copy and allow the normal query processing
|
||||
* to handle the policies.
|
||||
*
|
||||
* If RLS is not enabled for this, then just fall through to the
|
||||
* normal non-filtering relation handling.
|
||||
@@ -877,7 +877,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
|
||||
if (is_from)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("COPY FROM not supported with row level security."),
|
||||
errmsg("COPY FROM not supported with row level security."),
|
||||
errhint("Use direct INSERT statements instead.")));
|
||||
|
||||
/* Build target list */
|
||||
@@ -904,7 +904,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
|
||||
select->targetList = list_make1(target);
|
||||
select->fromClause = list_make1(from);
|
||||
|
||||
query = (Node*) select;
|
||||
query = (Node *) select;
|
||||
|
||||
/* Close the handle to the relation as it is no longer needed. */
|
||||
heap_close(rel, (is_from ? RowExclusiveLock : AccessShareLock));
|
||||
@@ -1408,26 +1408,27 @@ BeginCopy(bool is_from,
|
||||
|
||||
/*
|
||||
* If we were passed in a relid, make sure we got the same one back
|
||||
* after planning out the query. It's possible that it changed between
|
||||
* when we checked the policies on the table and decided to use a query
|
||||
* and now.
|
||||
* after planning out the query. It's possible that it changed
|
||||
* between when we checked the policies on the table and decided to
|
||||
* use a query and now.
|
||||
*/
|
||||
if (queryRelId != InvalidOid)
|
||||
{
|
||||
Oid relid = linitial_oid(plan->relationOids);
|
||||
Oid relid = linitial_oid(plan->relationOids);
|
||||
|
||||
/*
|
||||
* There should only be one relationOid in this case, since we will
|
||||
* only get here when we have changed the command for the user from
|
||||
* a "COPY relation TO" to "COPY (SELECT * FROM relation) TO", to
|
||||
* allow row level security policies to be applied.
|
||||
* There should only be one relationOid in this case, since we
|
||||
* will only get here when we have changed the command for the
|
||||
* user from a "COPY relation TO" to "COPY (SELECT * FROM
|
||||
* relation) TO", to allow row level security policies to be
|
||||
* applied.
|
||||
*/
|
||||
Assert(list_length(plan->relationOids) == 1);
|
||||
|
||||
if (relid != queryRelId)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("relation referenced by COPY statement has changed")));
|
||||
errmsg("relation referenced by COPY statement has changed")));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2439,7 +2440,7 @@ CopyFrom(CopyState cstate)
|
||||
|
||||
if (resultRelInfo->ri_NumIndices > 0)
|
||||
recheckIndexes = ExecInsertIndexTuples(slot, &(tuple->t_self),
|
||||
estate, false, NULL,
|
||||
estate, false, NULL,
|
||||
NIL);
|
||||
|
||||
/* AFTER ROW INSERT Triggers */
|
||||
|
@@ -89,7 +89,7 @@ ExecCreateTableAs(CreateTableAsStmt *stmt, const char *queryString,
|
||||
|
||||
if (stmt->if_not_exists)
|
||||
{
|
||||
Oid nspid;
|
||||
Oid nspid;
|
||||
|
||||
nspid = RangeVarGetCreationNamespace(stmt->into->rel);
|
||||
|
||||
|
@@ -554,8 +554,8 @@ createdb(const CreatedbStmt *stmt)
|
||||
* Force a checkpoint before starting the copy. This will force all dirty
|
||||
* buffers, including those of unlogged tables, out to disk, to ensure
|
||||
* source database is up-to-date on disk for the copy.
|
||||
* FlushDatabaseBuffers() would suffice for that, but we also want
|
||||
* to process any pending unlink requests. Otherwise, if a checkpoint
|
||||
* FlushDatabaseBuffers() would suffice for that, but we also want to
|
||||
* process any pending unlink requests. Otherwise, if a checkpoint
|
||||
* happened while we're copying files, a file might be deleted just when
|
||||
* we're about to copy it, causing the lstat() call in copydir() to fail
|
||||
* with ENOENT.
|
||||
@@ -841,8 +841,8 @@ dropdb(const char *dbname, bool missing_ok)
|
||||
if (ReplicationSlotsCountDBSlots(db_id, &nslots, &nslots_active))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_IN_USE),
|
||||
errmsg("database \"%s\" is used by a logical replication slot",
|
||||
dbname),
|
||||
errmsg("database \"%s\" is used by a logical replication slot",
|
||||
dbname),
|
||||
errdetail_plural("There is %d slot, %d of them active.",
|
||||
"There are %d slots, %d of them active.",
|
||||
nslots,
|
||||
|
@@ -415,7 +415,7 @@ does_not_exist_skipping(ObjectType objtype, List *objname, List *objargs)
|
||||
break;
|
||||
case OBJECT_OPCLASS:
|
||||
{
|
||||
List *opcname = list_copy_tail(objname, 1);
|
||||
List *opcname = list_copy_tail(objname, 1);
|
||||
|
||||
if (!schema_does_not_exist_skipping(opcname, &msg, &name))
|
||||
{
|
||||
@@ -427,7 +427,7 @@ does_not_exist_skipping(ObjectType objtype, List *objname, List *objargs)
|
||||
break;
|
||||
case OBJECT_OPFAMILY:
|
||||
{
|
||||
List *opfname = list_copy_tail(objname, 1);
|
||||
List *opfname = list_copy_tail(objname, 1);
|
||||
|
||||
if (!schema_does_not_exist_skipping(opfname, &msg, &name))
|
||||
{
|
||||
|
@@ -57,13 +57,15 @@ typedef struct EventTriggerQueryState
|
||||
bool in_sql_drop;
|
||||
|
||||
/* table_rewrite */
|
||||
Oid table_rewrite_oid; /* InvalidOid, or set for table_rewrite event */
|
||||
Oid table_rewrite_oid; /* InvalidOid, or set for
|
||||
* table_rewrite event */
|
||||
int table_rewrite_reason; /* AT_REWRITE reason */
|
||||
|
||||
/* Support for command collection */
|
||||
bool commandCollectionInhibited;
|
||||
CollectedCommand *currentCommand;
|
||||
List *commandList; /* list of CollectedCommand; see deparse_utility.h */
|
||||
List *commandList; /* list of CollectedCommand; see
|
||||
* deparse_utility.h */
|
||||
struct EventTriggerQueryState *previous;
|
||||
} EventTriggerQueryState;
|
||||
|
||||
@@ -143,7 +145,7 @@ static void AlterEventTriggerOwner_internal(Relation rel,
|
||||
Oid newOwnerId);
|
||||
static event_trigger_command_tag_check_result check_ddl_tag(const char *tag);
|
||||
static event_trigger_command_tag_check_result check_table_rewrite_ddl_tag(
|
||||
const char *tag);
|
||||
const char *tag);
|
||||
static void error_duplicate_filter_variable(const char *defname);
|
||||
static Datum filter_list_to_array(List *filterlist);
|
||||
static Oid insert_event_trigger_tuple(char *trigname, char *eventname,
|
||||
@@ -714,7 +716,7 @@ EventTriggerCommonSetup(Node *parsetree,
|
||||
|
||||
dbgtag = CreateCommandTag(parsetree);
|
||||
if (event == EVT_DDLCommandStart ||
|
||||
event == EVT_DDLCommandEnd ||
|
||||
event == EVT_DDLCommandEnd ||
|
||||
event == EVT_SQLDrop)
|
||||
{
|
||||
if (check_ddl_tag(dbgtag) != EVENT_TRIGGER_COMMAND_TAG_OK)
|
||||
@@ -1562,8 +1564,8 @@ pg_event_trigger_table_rewrite_oid(PG_FUNCTION_ARGS)
|
||||
currentEventTriggerState->table_rewrite_oid == InvalidOid)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_E_R_I_E_EVENT_TRIGGER_PROTOCOL_VIOLATED),
|
||||
errmsg("%s can only be called in a table_rewrite event trigger function",
|
||||
"pg_event_trigger_table_rewrite_oid()")));
|
||||
errmsg("%s can only be called in a table_rewrite event trigger function",
|
||||
"pg_event_trigger_table_rewrite_oid()")));
|
||||
|
||||
PG_RETURN_OID(currentEventTriggerState->table_rewrite_oid);
|
||||
}
|
||||
@@ -1583,8 +1585,8 @@ pg_event_trigger_table_rewrite_reason(PG_FUNCTION_ARGS)
|
||||
currentEventTriggerState->table_rewrite_reason == 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_E_R_I_E_EVENT_TRIGGER_PROTOCOL_VIOLATED),
|
||||
errmsg("%s can only be called in a table_rewrite event trigger function",
|
||||
"pg_event_trigger_table_rewrite_reason()")));
|
||||
errmsg("%s can only be called in a table_rewrite event trigger function",
|
||||
"pg_event_trigger_table_rewrite_reason()")));
|
||||
|
||||
PG_RETURN_INT32(currentEventTriggerState->table_rewrite_reason);
|
||||
}
|
||||
@@ -1672,7 +1674,7 @@ EventTriggerCollectSimpleCommand(ObjectAddress address,
|
||||
command->parsetree = copyObject(parsetree);
|
||||
|
||||
currentEventTriggerState->commandList = lappend(currentEventTriggerState->commandList,
|
||||
command);
|
||||
command);
|
||||
|
||||
MemoryContextSwitchTo(oldcxt);
|
||||
}
|
||||
@@ -1687,13 +1689,13 @@ EventTriggerCollectSimpleCommand(ObjectAddress address,
|
||||
*
|
||||
* XXX -- this API isn't considering the possibility of an ALTER TABLE command
|
||||
* being called reentrantly by an event trigger function. Do we need stackable
|
||||
* commands at this level? Perhaps at least we should detect the condition and
|
||||
* commands at this level? Perhaps at least we should detect the condition and
|
||||
* raise an error.
|
||||
*/
|
||||
void
|
||||
EventTriggerAlterTableStart(Node *parsetree)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
MemoryContext oldcxt;
|
||||
CollectedCommand *command;
|
||||
|
||||
/* ignore if event trigger context not set, or collection disabled */
|
||||
@@ -1744,7 +1746,7 @@ EventTriggerAlterTableRelid(Oid objectId)
|
||||
void
|
||||
EventTriggerCollectAlterTableSubcmd(Node *subcmd, ObjectAddress address)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
MemoryContext oldcxt;
|
||||
CollectedATSubcmd *newsub;
|
||||
|
||||
/* ignore if event trigger context not set, or collection disabled */
|
||||
@@ -1808,8 +1810,8 @@ EventTriggerCollectGrant(InternalGrant *istmt)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
CollectedCommand *command;
|
||||
InternalGrant *icopy;
|
||||
ListCell *cell;
|
||||
InternalGrant *icopy;
|
||||
ListCell *cell;
|
||||
|
||||
/* ignore if event trigger context not set, or collection disabled */
|
||||
if (!currentEventTriggerState ||
|
||||
@@ -1849,9 +1851,9 @@ EventTriggerCollectGrant(InternalGrant *istmt)
|
||||
*/
|
||||
void
|
||||
EventTriggerCollectAlterOpFam(AlterOpFamilyStmt *stmt, Oid opfamoid,
|
||||
List *operators, List *procedures)
|
||||
List *operators, List *procedures)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
MemoryContext oldcxt;
|
||||
CollectedCommand *command;
|
||||
|
||||
/* ignore if event trigger context not set, or collection disabled */
|
||||
@@ -1882,9 +1884,9 @@ EventTriggerCollectAlterOpFam(AlterOpFamilyStmt *stmt, Oid opfamoid,
|
||||
*/
|
||||
void
|
||||
EventTriggerCollectCreateOpClass(CreateOpClassStmt *stmt, Oid opcoid,
|
||||
List *operators, List *procedures)
|
||||
List *operators, List *procedures)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
MemoryContext oldcxt;
|
||||
CollectedCommand *command;
|
||||
|
||||
/* ignore if event trigger context not set, or collection disabled */
|
||||
@@ -1918,7 +1920,7 @@ void
|
||||
EventTriggerCollectAlterTSConfig(AlterTSConfigurationStmt *stmt, Oid cfgId,
|
||||
Oid *dictIds, int ndicts)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
MemoryContext oldcxt;
|
||||
CollectedCommand *command;
|
||||
|
||||
/* ignore if event trigger context not set, or collection disabled */
|
||||
@@ -1952,7 +1954,7 @@ EventTriggerCollectAlterTSConfig(AlterTSConfigurationStmt *stmt, Oid cfgId,
|
||||
void
|
||||
EventTriggerCollectAlterDefPrivs(AlterDefaultPrivilegesStmt *stmt)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
MemoryContext oldcxt;
|
||||
CollectedCommand *command;
|
||||
|
||||
/* ignore if event trigger context not set, or collection disabled */
|
||||
@@ -2034,10 +2036,10 @@ pg_event_trigger_ddl_commands(PG_FUNCTION_ARGS)
|
||||
* object, the returned OID is Invalid. Don't return anything.
|
||||
*
|
||||
* One might think that a viable alternative would be to look up the
|
||||
* Oid of the existing object and run the deparse with that. But since
|
||||
* the parse tree might be different from the one that created the
|
||||
* object in the first place, we might not end up in a consistent state
|
||||
* anyway.
|
||||
* Oid of the existing object and run the deparse with that. But
|
||||
* since the parse tree might be different from the one that created
|
||||
* the object in the first place, we might not end up in a consistent
|
||||
* state anyway.
|
||||
*/
|
||||
if (cmd->type == SCT_Simple &&
|
||||
!OidIsValid(cmd->d.simple.address.objectId))
|
||||
@@ -2074,10 +2076,10 @@ pg_event_trigger_ddl_commands(PG_FUNCTION_ARGS)
|
||||
identity = getObjectIdentity(&addr);
|
||||
|
||||
/*
|
||||
* Obtain schema name, if any ("pg_temp" if a temp object).
|
||||
* If the object class is not in the supported list here,
|
||||
* we assume it's a schema-less object type, and thus
|
||||
* "schema" remains set to NULL.
|
||||
* Obtain schema name, if any ("pg_temp" if a temp
|
||||
* object). If the object class is not in the supported
|
||||
* list here, we assume it's a schema-less object type,
|
||||
* and thus "schema" remains set to NULL.
|
||||
*/
|
||||
if (is_objectclass_supported(addr.classId))
|
||||
{
|
||||
@@ -2099,10 +2101,10 @@ pg_event_trigger_ddl_commands(PG_FUNCTION_ARGS)
|
||||
addr.classId, addr.objectId);
|
||||
schema_oid =
|
||||
heap_getattr(objtup, nspAttnum,
|
||||
RelationGetDescr(catalog), &isnull);
|
||||
RelationGetDescr(catalog), &isnull);
|
||||
if (isnull)
|
||||
elog(ERROR,
|
||||
"invalid null namespace in object %u/%u/%d",
|
||||
"invalid null namespace in object %u/%u/%d",
|
||||
addr.classId, addr.objectId, addr.objectSubId);
|
||||
/* XXX not quite get_namespace_name_or_temp */
|
||||
if (isAnyTempNamespace(schema_oid))
|
||||
@@ -2149,7 +2151,7 @@ pg_event_trigger_ddl_commands(PG_FUNCTION_ARGS)
|
||||
values[i++] = CStringGetTextDatum(CreateCommandTag(cmd->parsetree));
|
||||
/* object_type */
|
||||
values[i++] = CStringGetTextDatum(stringify_adefprivs_objtype(
|
||||
cmd->d.defprivs.objtype));
|
||||
cmd->d.defprivs.objtype));
|
||||
/* schema */
|
||||
nulls[i++] = true;
|
||||
/* identity */
|
||||
@@ -2172,7 +2174,7 @@ pg_event_trigger_ddl_commands(PG_FUNCTION_ARGS)
|
||||
"GRANT" : "REVOKE");
|
||||
/* object_type */
|
||||
values[i++] = CStringGetTextDatum(stringify_grantobjtype(
|
||||
cmd->d.grant.istmt->objtype));
|
||||
cmd->d.grant.istmt->objtype));
|
||||
/* schema */
|
||||
nulls[i++] = true;
|
||||
/* identity */
|
||||
@@ -2230,7 +2232,7 @@ stringify_grantobjtype(GrantObjectType objtype)
|
||||
return "TYPE";
|
||||
default:
|
||||
elog(ERROR, "unrecognized type %d", objtype);
|
||||
return "???"; /* keep compiler quiet */
|
||||
return "???"; /* keep compiler quiet */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2257,6 +2259,6 @@ stringify_adefprivs_objtype(GrantObjectType objtype)
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "unrecognized type %d", objtype);
|
||||
return "???"; /* keep compiler quiet */
|
||||
return "???"; /* keep compiler quiet */
|
||||
}
|
||||
}
|
||||
|
@@ -83,11 +83,11 @@ static void show_merge_append_keys(MergeAppendState *mstate, List *ancestors,
|
||||
static void show_agg_keys(AggState *astate, List *ancestors,
|
||||
ExplainState *es);
|
||||
static void show_grouping_sets(PlanState *planstate, Agg *agg,
|
||||
List *ancestors, ExplainState *es);
|
||||
List *ancestors, ExplainState *es);
|
||||
static void show_grouping_set_keys(PlanState *planstate,
|
||||
Agg *aggnode, Sort *sortnode,
|
||||
List *context, bool useprefix,
|
||||
List *ancestors, ExplainState *es);
|
||||
Agg *aggnode, Sort *sortnode,
|
||||
List *context, bool useprefix,
|
||||
List *ancestors, ExplainState *es);
|
||||
static void show_group_keys(GroupState *gstate, List *ancestors,
|
||||
ExplainState *es);
|
||||
static void show_sort_group_keys(PlanState *planstate, const char *qlabel,
|
||||
@@ -754,7 +754,7 @@ ExplainPreScanNode(PlanState *planstate, Bitmapset **rels_used)
|
||||
((ModifyTable *) plan)->nominalRelation);
|
||||
if (((ModifyTable *) plan)->exclRelRTI)
|
||||
*rels_used = bms_add_member(*rels_used,
|
||||
((ModifyTable *) plan)->exclRelRTI);
|
||||
((ModifyTable *) plan)->exclRelRTI);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -984,6 +984,7 @@ ExplainNode(PlanState *planstate, List *ancestors,
|
||||
* quite messy.
|
||||
*/
|
||||
RangeTblEntry *rte;
|
||||
|
||||
rte = rt_fetch(((SampleScan *) plan)->scanrelid, es->rtable);
|
||||
custom_name = get_tablesample_method_name(rte->tablesample->tsmid);
|
||||
pname = psprintf("Sample Scan (%s)", custom_name);
|
||||
@@ -1895,8 +1896,8 @@ show_grouping_sets(PlanState *planstate, Agg *agg,
|
||||
|
||||
foreach(lc, agg->chain)
|
||||
{
|
||||
Agg *aggnode = lfirst(lc);
|
||||
Sort *sortnode = (Sort *) aggnode->plan.lefttree;
|
||||
Agg *aggnode = lfirst(lc);
|
||||
Sort *sortnode = (Sort *) aggnode->plan.lefttree;
|
||||
|
||||
show_grouping_set_keys(planstate, aggnode, sortnode,
|
||||
context, useprefix, ancestors, es);
|
||||
@@ -2561,7 +2562,7 @@ show_modifytable_info(ModifyTableState *mtstate, List *ancestors,
|
||||
{
|
||||
ExplainProperty("Conflict Resolution",
|
||||
node->onConflictAction == ONCONFLICT_NOTHING ?
|
||||
"NOTHING" : "UPDATE",
|
||||
"NOTHING" : "UPDATE",
|
||||
false, es);
|
||||
|
||||
/*
|
||||
@@ -2582,9 +2583,9 @@ show_modifytable_info(ModifyTableState *mtstate, List *ancestors,
|
||||
/* EXPLAIN ANALYZE display of actual outcome for each tuple proposed */
|
||||
if (es->analyze && mtstate->ps.instrument)
|
||||
{
|
||||
double total;
|
||||
double insert_path;
|
||||
double other_path;
|
||||
double total;
|
||||
double insert_path;
|
||||
double other_path;
|
||||
|
||||
InstrEndLoop(mtstate->mt_plans[0]->instrument);
|
||||
|
||||
|
@@ -921,9 +921,9 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString)
|
||||
ReleaseSysCache(languageTuple);
|
||||
|
||||
/*
|
||||
* Only superuser is allowed to create leakproof functions because leakproof
|
||||
* functions can see tuples which have not yet been filtered out by security
|
||||
* barrier views or row level security policies.
|
||||
* Only superuser is allowed to create leakproof functions because
|
||||
* leakproof functions can see tuples which have not yet been filtered out
|
||||
* by security barrier views or row level security policies.
|
||||
*/
|
||||
if (isLeakProof && !superuser())
|
||||
ereport(ERROR,
|
||||
@@ -932,14 +932,15 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString)
|
||||
|
||||
if (transformDefElem)
|
||||
{
|
||||
ListCell *lc;
|
||||
ListCell *lc;
|
||||
|
||||
Assert(IsA(transformDefElem, List));
|
||||
|
||||
foreach (lc, (List *) transformDefElem)
|
||||
foreach(lc, (List *) transformDefElem)
|
||||
{
|
||||
Oid typeid = typenameTypeId(NULL, lfirst(lc));
|
||||
Oid elt = get_base_element_type(typeid);
|
||||
Oid typeid = typenameTypeId(NULL, lfirst(lc));
|
||||
Oid elt = get_base_element_type(typeid);
|
||||
|
||||
typeid = elt ? elt : typeid;
|
||||
|
||||
get_transform_oid(typeid, languageOid, false);
|
||||
@@ -992,13 +993,13 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString)
|
||||
|
||||
if (list_length(trftypes_list) > 0)
|
||||
{
|
||||
ListCell *lc;
|
||||
Datum *arr;
|
||||
int i;
|
||||
ListCell *lc;
|
||||
Datum *arr;
|
||||
int i;
|
||||
|
||||
arr = palloc(list_length(trftypes_list) * sizeof(Datum));
|
||||
i = 0;
|
||||
foreach (lc, trftypes_list)
|
||||
foreach(lc, trftypes_list)
|
||||
arr[i++] = ObjectIdGetDatum(lfirst_oid(lc));
|
||||
trftypes = construct_array(arr, list_length(trftypes_list),
|
||||
OIDOID, sizeof(Oid), true, 'i');
|
||||
@@ -1716,7 +1717,7 @@ check_transform_function(Form_pg_proc procstruct)
|
||||
if (procstruct->proisagg)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("transform function must not be an aggregate function")));
|
||||
errmsg("transform function must not be an aggregate function")));
|
||||
if (procstruct->proiswindow)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
@@ -1867,9 +1868,9 @@ CreateTransform(CreateTransformStmt *stmt)
|
||||
if (!stmt->replace)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DUPLICATE_OBJECT),
|
||||
errmsg("transform for type %s language \"%s\" already exists",
|
||||
format_type_be(typeid),
|
||||
stmt->lang)));
|
||||
errmsg("transform for type %s language \"%s\" already exists",
|
||||
format_type_be(typeid),
|
||||
stmt->lang)));
|
||||
|
||||
MemSet(replaces, false, sizeof(replaces));
|
||||
replaces[Anum_pg_transform_trffromsql - 1] = true;
|
||||
@@ -1958,9 +1959,9 @@ get_transform_oid(Oid type_id, Oid lang_id, bool missing_ok)
|
||||
if (!OidIsValid(oid) && !missing_ok)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("transform for type %s language \"%s\" does not exist",
|
||||
format_type_be(type_id),
|
||||
get_language_name(lang_id, false))));
|
||||
errmsg("transform for type %s language \"%s\" does not exist",
|
||||
format_type_be(type_id),
|
||||
get_language_name(lang_id, false))));
|
||||
return oid;
|
||||
}
|
||||
|
||||
|
@@ -66,7 +66,7 @@ static char *make_temptable_name_n(char *tempname, int n);
|
||||
static void mv_GenerateOper(StringInfo buf, Oid opoid);
|
||||
|
||||
static void refresh_by_match_merge(Oid matviewOid, Oid tempOid, Oid relowner,
|
||||
int save_sec_context);
|
||||
int save_sec_context);
|
||||
static void refresh_by_heap_swap(Oid matviewOid, Oid OIDNewHeap, char relpersistence);
|
||||
|
||||
static void OpenMatViewIncrementalMaintenance(void);
|
||||
|
@@ -45,27 +45,27 @@
|
||||
#include "utils/syscache.h"
|
||||
|
||||
static void RangeVarCallbackForPolicy(const RangeVar *rv,
|
||||
Oid relid, Oid oldrelid, void *arg);
|
||||
Oid relid, Oid oldrelid, void *arg);
|
||||
static char parse_policy_command(const char *cmd_name);
|
||||
static ArrayType* policy_role_list_to_array(List *roles);
|
||||
static ArrayType *policy_role_list_to_array(List *roles);
|
||||
|
||||
/*
|
||||
* Callback to RangeVarGetRelidExtended().
|
||||
*
|
||||
* Checks the following:
|
||||
* - the relation specified is a table.
|
||||
* - current user owns the table.
|
||||
* - the table is not a system table.
|
||||
* - the relation specified is a table.
|
||||
* - current user owns the table.
|
||||
* - the table is not a system table.
|
||||
*
|
||||
* If any of these checks fails then an error is raised.
|
||||
*/
|
||||
static void
|
||||
RangeVarCallbackForPolicy(const RangeVar *rv, Oid relid, Oid oldrelid,
|
||||
void *arg)
|
||||
void *arg)
|
||||
{
|
||||
HeapTuple tuple;
|
||||
Form_pg_class classform;
|
||||
char relkind;
|
||||
HeapTuple tuple;
|
||||
Form_pg_class classform;
|
||||
char relkind;
|
||||
|
||||
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
@@ -96,8 +96,8 @@ RangeVarCallbackForPolicy(const RangeVar *rv, Oid relid, Oid oldrelid,
|
||||
|
||||
/*
|
||||
* parse_policy_command -
|
||||
* helper function to convert full command strings to their char
|
||||
* representation.
|
||||
* helper function to convert full command strings to their char
|
||||
* representation.
|
||||
*
|
||||
* cmd_name - full string command name. Valid values are 'all', 'select',
|
||||
* 'insert', 'update' and 'delete'.
|
||||
@@ -106,7 +106,7 @@ RangeVarCallbackForPolicy(const RangeVar *rv, Oid relid, Oid oldrelid,
|
||||
static char
|
||||
parse_policy_command(const char *cmd_name)
|
||||
{
|
||||
char cmd;
|
||||
char cmd;
|
||||
|
||||
if (!cmd_name)
|
||||
elog(ERROR, "unrecognized policy command");
|
||||
@@ -129,7 +129,7 @@ parse_policy_command(const char *cmd_name)
|
||||
|
||||
/*
|
||||
* policy_role_list_to_array
|
||||
* helper function to convert a list of RoleSpecs to an array of role ids.
|
||||
* helper function to convert a list of RoleSpecs to an array of role ids.
|
||||
*/
|
||||
static ArrayType *
|
||||
policy_role_list_to_array(List *roles)
|
||||
@@ -156,7 +156,7 @@ policy_role_list_to_array(List *roles)
|
||||
|
||||
foreach(cell, roles)
|
||||
{
|
||||
RoleSpec *spec = lfirst(cell);
|
||||
RoleSpec *spec = lfirst(cell);
|
||||
|
||||
/*
|
||||
* PUBLIC covers all roles, so it only makes sense alone.
|
||||
@@ -167,7 +167,7 @@ policy_role_list_to_array(List *roles)
|
||||
ereport(WARNING,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("ignoring roles specified other than public"),
|
||||
errhint("All roles are members of the public role.")));
|
||||
errhint("All roles are members of the public role.")));
|
||||
temp_array[0] = ObjectIdGetDatum(ACL_ID_PUBLIC);
|
||||
num_roles = 1;
|
||||
break;
|
||||
@@ -193,14 +193,14 @@ policy_role_list_to_array(List *roles)
|
||||
void
|
||||
RelationBuildRowSecurity(Relation relation)
|
||||
{
|
||||
MemoryContext rscxt;
|
||||
MemoryContext oldcxt = CurrentMemoryContext;
|
||||
RowSecurityDesc * volatile rsdesc = NULL;
|
||||
MemoryContext rscxt;
|
||||
MemoryContext oldcxt = CurrentMemoryContext;
|
||||
RowSecurityDesc *volatile rsdesc = NULL;
|
||||
|
||||
/*
|
||||
* Create a memory context to hold everything associated with this
|
||||
* relation's row security policy. This makes it easy to clean up
|
||||
* during a relcache flush.
|
||||
* relation's row security policy. This makes it easy to clean up during
|
||||
* a relcache flush.
|
||||
*/
|
||||
rscxt = AllocSetContextCreate(CacheMemoryContext,
|
||||
"row security descriptor",
|
||||
@@ -209,15 +209,15 @@ RelationBuildRowSecurity(Relation relation)
|
||||
ALLOCSET_SMALL_MAXSIZE);
|
||||
|
||||
/*
|
||||
* Since rscxt lives under CacheMemoryContext, it is long-lived. Use
|
||||
* a PG_TRY block to ensure it'll get freed if we fail partway through.
|
||||
* Since rscxt lives under CacheMemoryContext, it is long-lived. Use a
|
||||
* PG_TRY block to ensure it'll get freed if we fail partway through.
|
||||
*/
|
||||
PG_TRY();
|
||||
{
|
||||
Relation catalog;
|
||||
ScanKeyData skey;
|
||||
SysScanDesc sscan;
|
||||
HeapTuple tuple;
|
||||
Relation catalog;
|
||||
ScanKeyData skey;
|
||||
SysScanDesc sscan;
|
||||
HeapTuple tuple;
|
||||
|
||||
rsdesc = MemoryContextAllocZero(rscxt, sizeof(RowSecurityDesc));
|
||||
rsdesc->rscxt = rscxt;
|
||||
@@ -238,17 +238,17 @@ RelationBuildRowSecurity(Relation relation)
|
||||
*/
|
||||
while (HeapTupleIsValid(tuple = systable_getnext(sscan)))
|
||||
{
|
||||
Datum value_datum;
|
||||
char cmd_value;
|
||||
Datum roles_datum;
|
||||
char *qual_value;
|
||||
Expr *qual_expr;
|
||||
char *with_check_value;
|
||||
Expr *with_check_qual;
|
||||
char *policy_name_value;
|
||||
Oid policy_id;
|
||||
bool isnull;
|
||||
RowSecurityPolicy *policy;
|
||||
Datum value_datum;
|
||||
char cmd_value;
|
||||
Datum roles_datum;
|
||||
char *qual_value;
|
||||
Expr *qual_expr;
|
||||
char *with_check_value;
|
||||
Expr *with_check_qual;
|
||||
char *policy_name_value;
|
||||
Oid policy_id;
|
||||
bool isnull;
|
||||
RowSecurityPolicy *policy;
|
||||
|
||||
/*
|
||||
* Note: all the pass-by-reference data we collect here is either
|
||||
@@ -259,26 +259,26 @@ RelationBuildRowSecurity(Relation relation)
|
||||
|
||||
/* Get policy command */
|
||||
value_datum = heap_getattr(tuple, Anum_pg_policy_polcmd,
|
||||
RelationGetDescr(catalog), &isnull);
|
||||
RelationGetDescr(catalog), &isnull);
|
||||
Assert(!isnull);
|
||||
cmd_value = DatumGetChar(value_datum);
|
||||
|
||||
/* Get policy name */
|
||||
value_datum = heap_getattr(tuple, Anum_pg_policy_polname,
|
||||
RelationGetDescr(catalog), &isnull);
|
||||
RelationGetDescr(catalog), &isnull);
|
||||
Assert(!isnull);
|
||||
policy_name_value = NameStr(*(DatumGetName(value_datum)));
|
||||
|
||||
/* Get policy roles */
|
||||
roles_datum = heap_getattr(tuple, Anum_pg_policy_polroles,
|
||||
RelationGetDescr(catalog), &isnull);
|
||||
RelationGetDescr(catalog), &isnull);
|
||||
/* shouldn't be null, but initdb doesn't mark it so, so check */
|
||||
if (isnull)
|
||||
elog(ERROR, "unexpected null value in pg_policy.polroles");
|
||||
|
||||
/* Get policy qual */
|
||||
value_datum = heap_getattr(tuple, Anum_pg_policy_polqual,
|
||||
RelationGetDescr(catalog), &isnull);
|
||||
RelationGetDescr(catalog), &isnull);
|
||||
if (!isnull)
|
||||
{
|
||||
qual_value = TextDatumGetCString(value_datum);
|
||||
@@ -289,7 +289,7 @@ RelationBuildRowSecurity(Relation relation)
|
||||
|
||||
/* Get WITH CHECK qual */
|
||||
value_datum = heap_getattr(tuple, Anum_pg_policy_polwithcheck,
|
||||
RelationGetDescr(catalog), &isnull);
|
||||
RelationGetDescr(catalog), &isnull);
|
||||
if (!isnull)
|
||||
{
|
||||
with_check_value = TextDatumGetCString(value_datum);
|
||||
@@ -311,7 +311,7 @@ RelationBuildRowSecurity(Relation relation)
|
||||
policy->qual = copyObject(qual_expr);
|
||||
policy->with_check_qual = copyObject(with_check_qual);
|
||||
policy->hassublinks = checkExprHasSubLink((Node *) qual_expr) ||
|
||||
checkExprHasSubLink((Node *) with_check_qual);
|
||||
checkExprHasSubLink((Node *) with_check_qual);
|
||||
|
||||
rsdesc->policies = lcons(policy, rsdesc->policies);
|
||||
|
||||
@@ -330,15 +330,15 @@ RelationBuildRowSecurity(Relation relation)
|
||||
/*
|
||||
* Check if no policies were added
|
||||
*
|
||||
* If no policies exist in pg_policy for this relation, then we
|
||||
* need to create a single default-deny policy. We use InvalidOid for
|
||||
* the Oid to indicate that this is the default-deny policy (we may
|
||||
* decide to ignore the default policy if an extension adds policies).
|
||||
* If no policies exist in pg_policy for this relation, then we need
|
||||
* to create a single default-deny policy. We use InvalidOid for the
|
||||
* Oid to indicate that this is the default-deny policy (we may decide
|
||||
* to ignore the default policy if an extension adds policies).
|
||||
*/
|
||||
if (rsdesc->policies == NIL)
|
||||
{
|
||||
RowSecurityPolicy *policy;
|
||||
Datum role;
|
||||
RowSecurityPolicy *policy;
|
||||
Datum role;
|
||||
|
||||
MemoryContextSwitchTo(rscxt);
|
||||
|
||||
@@ -351,7 +351,7 @@ RelationBuildRowSecurity(Relation relation)
|
||||
policy->roles = construct_array(&role, 1, OIDOID, sizeof(Oid), true,
|
||||
'i');
|
||||
policy->qual = (Expr *) makeConst(BOOLOID, -1, InvalidOid,
|
||||
sizeof(bool), BoolGetDatum(false),
|
||||
sizeof(bool), BoolGetDatum(false),
|
||||
false, true);
|
||||
policy->with_check_qual = copyObject(policy->qual);
|
||||
policy->hassublinks = false;
|
||||
@@ -376,15 +376,15 @@ RelationBuildRowSecurity(Relation relation)
|
||||
|
||||
/*
|
||||
* RemovePolicyById -
|
||||
* remove a policy by its OID. If a policy does not exist with the provided
|
||||
* oid, then an error is raised.
|
||||
* remove a policy by its OID. If a policy does not exist with the provided
|
||||
* oid, then an error is raised.
|
||||
*
|
||||
* policy_id - the oid of the policy.
|
||||
*/
|
||||
void
|
||||
RemovePolicyById(Oid policy_id)
|
||||
{
|
||||
Relation pg_policy_rel;
|
||||
Relation pg_policy_rel;
|
||||
SysScanDesc sscan;
|
||||
ScanKeyData skey[1];
|
||||
HeapTuple tuple;
|
||||
@@ -435,8 +435,8 @@ RemovePolicyById(Oid policy_id)
|
||||
|
||||
/*
|
||||
* Note that, unlike some of the other flags in pg_class, relrowsecurity
|
||||
* is not just an indication of if policies exist. When relrowsecurity
|
||||
* is set by a user, then all access to the relation must be through a
|
||||
* is not just an indication of if policies exist. When relrowsecurity is
|
||||
* set by a user, then all access to the relation must be through a
|
||||
* policy. If no policy is defined for the relation then a default-deny
|
||||
* policy is created and all records are filtered (except for queries from
|
||||
* the owner).
|
||||
@@ -450,31 +450,31 @@ RemovePolicyById(Oid policy_id)
|
||||
|
||||
/*
|
||||
* CreatePolicy -
|
||||
* handles the execution of the CREATE POLICY command.
|
||||
* handles the execution of the CREATE POLICY command.
|
||||
*
|
||||
* stmt - the CreatePolicyStmt that describes the policy to create.
|
||||
*/
|
||||
ObjectAddress
|
||||
CreatePolicy(CreatePolicyStmt *stmt)
|
||||
{
|
||||
Relation pg_policy_rel;
|
||||
Oid policy_id;
|
||||
Relation target_table;
|
||||
Oid table_id;
|
||||
char polcmd;
|
||||
ArrayType *role_ids;
|
||||
ParseState *qual_pstate;
|
||||
ParseState *with_check_pstate;
|
||||
RangeTblEntry *rte;
|
||||
Node *qual;
|
||||
Node *with_check_qual;
|
||||
ScanKeyData skey[2];
|
||||
SysScanDesc sscan;
|
||||
HeapTuple policy_tuple;
|
||||
Datum values[Natts_pg_policy];
|
||||
bool isnull[Natts_pg_policy];
|
||||
ObjectAddress target;
|
||||
ObjectAddress myself;
|
||||
Relation pg_policy_rel;
|
||||
Oid policy_id;
|
||||
Relation target_table;
|
||||
Oid table_id;
|
||||
char polcmd;
|
||||
ArrayType *role_ids;
|
||||
ParseState *qual_pstate;
|
||||
ParseState *with_check_pstate;
|
||||
RangeTblEntry *rte;
|
||||
Node *qual;
|
||||
Node *with_check_qual;
|
||||
ScanKeyData skey[2];
|
||||
SysScanDesc sscan;
|
||||
HeapTuple policy_tuple;
|
||||
Datum values[Natts_pg_policy];
|
||||
bool isnull[Natts_pg_policy];
|
||||
ObjectAddress target;
|
||||
ObjectAddress myself;
|
||||
|
||||
/* Parse command */
|
||||
polcmd = parse_policy_command(stmt->cmd);
|
||||
@@ -506,8 +506,8 @@ CreatePolicy(CreatePolicyStmt *stmt)
|
||||
with_check_pstate = make_parsestate(NULL);
|
||||
|
||||
/* zero-clear */
|
||||
memset(values, 0, sizeof(values));
|
||||
memset(isnull, 0, sizeof(isnull));
|
||||
memset(values, 0, sizeof(values));
|
||||
memset(isnull, 0, sizeof(isnull));
|
||||
|
||||
/* Get id of table. Also handles permissions checks. */
|
||||
table_id = RangeVarGetRelidExtended(stmt->table, AccessExclusiveLock,
|
||||
@@ -515,7 +515,7 @@ CreatePolicy(CreatePolicyStmt *stmt)
|
||||
RangeVarCallbackForPolicy,
|
||||
(void *) stmt);
|
||||
|
||||
/* Open target_table to build quals. No lock is necessary.*/
|
||||
/* Open target_table to build quals. No lock is necessary. */
|
||||
target_table = relation_open(table_id, NoLock);
|
||||
|
||||
/* Add for the regular security quals */
|
||||
@@ -534,9 +534,9 @@ CreatePolicy(CreatePolicyStmt *stmt)
|
||||
"POLICY");
|
||||
|
||||
with_check_qual = transformWhereClause(with_check_pstate,
|
||||
copyObject(stmt->with_check),
|
||||
EXPR_KIND_WHERE,
|
||||
"POLICY");
|
||||
copyObject(stmt->with_check),
|
||||
EXPR_KIND_WHERE,
|
||||
"POLICY");
|
||||
|
||||
/* Open pg_policy catalog */
|
||||
pg_policy_rel = heap_open(PolicyRelationId, RowExclusiveLock);
|
||||
@@ -568,7 +568,7 @@ CreatePolicy(CreatePolicyStmt *stmt)
|
||||
|
||||
values[Anum_pg_policy_polrelid - 1] = ObjectIdGetDatum(table_id);
|
||||
values[Anum_pg_policy_polname - 1] = DirectFunctionCall1(namein,
|
||||
CStringGetDatum(stmt->policy_name));
|
||||
CStringGetDatum(stmt->policy_name));
|
||||
values[Anum_pg_policy_polcmd - 1] = CharGetDatum(polcmd);
|
||||
values[Anum_pg_policy_polroles - 1] = PointerGetDatum(role_ids);
|
||||
|
||||
@@ -625,34 +625,34 @@ CreatePolicy(CreatePolicyStmt *stmt)
|
||||
|
||||
/*
|
||||
* AlterPolicy -
|
||||
* handles the execution of the ALTER POLICY command.
|
||||
* handles the execution of the ALTER POLICY command.
|
||||
*
|
||||
* stmt - the AlterPolicyStmt that describes the policy and how to alter it.
|
||||
*/
|
||||
ObjectAddress
|
||||
AlterPolicy(AlterPolicyStmt *stmt)
|
||||
{
|
||||
Relation pg_policy_rel;
|
||||
Oid policy_id;
|
||||
Relation target_table;
|
||||
Oid table_id;
|
||||
ArrayType *role_ids = NULL;
|
||||
List *qual_parse_rtable = NIL;
|
||||
List *with_check_parse_rtable = NIL;
|
||||
Node *qual = NULL;
|
||||
Node *with_check_qual = NULL;
|
||||
ScanKeyData skey[2];
|
||||
SysScanDesc sscan;
|
||||
HeapTuple policy_tuple;
|
||||
HeapTuple new_tuple;
|
||||
Datum values[Natts_pg_policy];
|
||||
bool isnull[Natts_pg_policy];
|
||||
bool replaces[Natts_pg_policy];
|
||||
ObjectAddress target;
|
||||
ObjectAddress myself;
|
||||
Datum cmd_datum;
|
||||
char polcmd;
|
||||
bool polcmd_isnull;
|
||||
Relation pg_policy_rel;
|
||||
Oid policy_id;
|
||||
Relation target_table;
|
||||
Oid table_id;
|
||||
ArrayType *role_ids = NULL;
|
||||
List *qual_parse_rtable = NIL;
|
||||
List *with_check_parse_rtable = NIL;
|
||||
Node *qual = NULL;
|
||||
Node *with_check_qual = NULL;
|
||||
ScanKeyData skey[2];
|
||||
SysScanDesc sscan;
|
||||
HeapTuple policy_tuple;
|
||||
HeapTuple new_tuple;
|
||||
Datum values[Natts_pg_policy];
|
||||
bool isnull[Natts_pg_policy];
|
||||
bool replaces[Natts_pg_policy];
|
||||
ObjectAddress target;
|
||||
ObjectAddress myself;
|
||||
Datum cmd_datum;
|
||||
char polcmd;
|
||||
bool polcmd_isnull;
|
||||
|
||||
/* Parse role_ids */
|
||||
if (stmt->roles != NULL)
|
||||
@@ -669,8 +669,8 @@ AlterPolicy(AlterPolicyStmt *stmt)
|
||||
/* Parse the using policy clause */
|
||||
if (stmt->qual)
|
||||
{
|
||||
RangeTblEntry *rte;
|
||||
ParseState *qual_pstate = make_parsestate(NULL);
|
||||
RangeTblEntry *rte;
|
||||
ParseState *qual_pstate = make_parsestate(NULL);
|
||||
|
||||
rte = addRangeTableEntryForRelation(qual_pstate, target_table,
|
||||
NULL, false, false);
|
||||
@@ -688,8 +688,8 @@ AlterPolicy(AlterPolicyStmt *stmt)
|
||||
/* Parse the with-check policy clause */
|
||||
if (stmt->with_check)
|
||||
{
|
||||
RangeTblEntry *rte;
|
||||
ParseState *with_check_pstate = make_parsestate(NULL);
|
||||
RangeTblEntry *rte;
|
||||
ParseState *with_check_pstate = make_parsestate(NULL);
|
||||
|
||||
rte = addRangeTableEntryForRelation(with_check_pstate, target_table,
|
||||
NULL, false, false);
|
||||
@@ -706,9 +706,9 @@ AlterPolicy(AlterPolicyStmt *stmt)
|
||||
}
|
||||
|
||||
/* zero-clear */
|
||||
memset(values, 0, sizeof(values));
|
||||
memset(values, 0, sizeof(values));
|
||||
memset(replaces, 0, sizeof(replaces));
|
||||
memset(isnull, 0, sizeof(isnull));
|
||||
memset(isnull, 0, sizeof(isnull));
|
||||
|
||||
/* Find policy to update. */
|
||||
pg_policy_rel = heap_open(PolicyRelationId, RowExclusiveLock);
|
||||
@@ -756,8 +756,8 @@ AlterPolicy(AlterPolicyStmt *stmt)
|
||||
errmsg("only USING expression allowed for SELECT, DELETE")));
|
||||
|
||||
/*
|
||||
* If the command is INSERT then WITH CHECK should be the only
|
||||
* expression provided.
|
||||
* If the command is INSERT then WITH CHECK should be the only expression
|
||||
* provided.
|
||||
*/
|
||||
if ((polcmd == ACL_INSERT_CHR)
|
||||
&& stmt->qual != NULL)
|
||||
@@ -829,19 +829,19 @@ AlterPolicy(AlterPolicyStmt *stmt)
|
||||
|
||||
/*
|
||||
* rename_policy -
|
||||
* change the name of a policy on a relation
|
||||
* change the name of a policy on a relation
|
||||
*/
|
||||
ObjectAddress
|
||||
rename_policy(RenameStmt *stmt)
|
||||
{
|
||||
Relation pg_policy_rel;
|
||||
Relation target_table;
|
||||
Oid table_id;
|
||||
Oid opoloid;
|
||||
ScanKeyData skey[2];
|
||||
SysScanDesc sscan;
|
||||
HeapTuple policy_tuple;
|
||||
ObjectAddress address;
|
||||
Relation pg_policy_rel;
|
||||
Relation target_table;
|
||||
Oid table_id;
|
||||
Oid opoloid;
|
||||
ScanKeyData skey[2];
|
||||
SysScanDesc sscan;
|
||||
HeapTuple policy_tuple;
|
||||
ObjectAddress address;
|
||||
|
||||
/* Get id of table. Also handles permissions checks. */
|
||||
table_id = RangeVarGetRelidExtended(stmt->relation, AccessExclusiveLock,
|
||||
@@ -875,7 +875,7 @@ rename_policy(RenameStmt *stmt)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DUPLICATE_OBJECT),
|
||||
errmsg("policy \"%s\" for table \"%s\" already exists",
|
||||
stmt->newname, RelationGetRelationName(target_table))));
|
||||
stmt->newname, RelationGetRelationName(target_table))));
|
||||
|
||||
systable_endscan(sscan);
|
||||
|
||||
@@ -903,7 +903,7 @@ rename_policy(RenameStmt *stmt)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("policy \"%s\" for table \"%s\" does not exist",
|
||||
stmt->subname, RelationGetRelationName(target_table))));
|
||||
stmt->subname, RelationGetRelationName(target_table))));
|
||||
|
||||
opoloid = HeapTupleGetOid(policy_tuple);
|
||||
|
||||
@@ -923,9 +923,9 @@ rename_policy(RenameStmt *stmt)
|
||||
ObjectAddressSet(address, PolicyRelationId, opoloid);
|
||||
|
||||
/*
|
||||
* Invalidate relation's relcache entry so that other backends (and
|
||||
* this one too!) are sent SI message to make them rebuild relcache
|
||||
* entries. (Ideally this should happen automatically...)
|
||||
* Invalidate relation's relcache entry so that other backends (and this
|
||||
* one too!) are sent SI message to make them rebuild relcache entries.
|
||||
* (Ideally this should happen automatically...)
|
||||
*/
|
||||
CacheInvalidateRelcache(target_table);
|
||||
|
||||
@@ -946,11 +946,11 @@ rename_policy(RenameStmt *stmt)
|
||||
Oid
|
||||
get_relation_policy_oid(Oid relid, const char *policy_name, bool missing_ok)
|
||||
{
|
||||
Relation pg_policy_rel;
|
||||
ScanKeyData skey[2];
|
||||
SysScanDesc sscan;
|
||||
HeapTuple policy_tuple;
|
||||
Oid policy_oid;
|
||||
Relation pg_policy_rel;
|
||||
ScanKeyData skey[2];
|
||||
SysScanDesc sscan;
|
||||
HeapTuple policy_tuple;
|
||||
Oid policy_oid;
|
||||
|
||||
pg_policy_rel = heap_open(PolicyRelationId, AccessShareLock);
|
||||
|
||||
|
@@ -44,7 +44,7 @@ static void AlterSchemaOwner_internal(HeapTuple tup, Relation rel, Oid newOwnerI
|
||||
Oid
|
||||
CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString)
|
||||
{
|
||||
const char *schemaName = stmt->schemaname;
|
||||
const char *schemaName = stmt->schemaname;
|
||||
Oid namespaceId;
|
||||
OverrideSearchPath *overridePath;
|
||||
List *parsetree_list;
|
||||
@@ -68,7 +68,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString)
|
||||
/* fill schema name with the user name if not specified */
|
||||
if (!schemaName)
|
||||
{
|
||||
HeapTuple tuple;
|
||||
HeapTuple tuple;
|
||||
|
||||
tuple = SearchSysCache1(AUTHOID, ObjectIdGetDatum(owner_uid));
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
|
@@ -566,8 +566,8 @@ nextval_internal(Oid relid)
|
||||
PreventCommandIfReadOnly("nextval()");
|
||||
|
||||
/*
|
||||
* Forbid this during parallel operation because, to make it work,
|
||||
* the cooperating backends would need to share the backend-local cached
|
||||
* Forbid this during parallel operation because, to make it work, the
|
||||
* cooperating backends would need to share the backend-local cached
|
||||
* sequence information. Currently, we don't support that.
|
||||
*/
|
||||
PreventCommandIfParallelMode("nextval()");
|
||||
@@ -702,10 +702,10 @@ nextval_internal(Oid relid)
|
||||
|
||||
/*
|
||||
* If something needs to be WAL logged, acquire an xid, so this
|
||||
* transaction's commit will trigger a WAL flush and wait for
|
||||
* syncrep. It's sufficient to ensure the toplevel transaction has an xid,
|
||||
* no need to assign xids subxacts, that'll already trigger an appropriate
|
||||
* wait. (Have to do that here, so we're outside the critical section)
|
||||
* transaction's commit will trigger a WAL flush and wait for syncrep.
|
||||
* It's sufficient to ensure the toplevel transaction has an xid, no need
|
||||
* to assign xids subxacts, that'll already trigger an appropriate wait.
|
||||
* (Have to do that here, so we're outside the critical section)
|
||||
*/
|
||||
if (logit && RelationNeedsWAL(seqrel))
|
||||
GetTopTransactionId();
|
||||
@@ -870,8 +870,8 @@ do_setval(Oid relid, int64 next, bool iscalled)
|
||||
PreventCommandIfReadOnly("setval()");
|
||||
|
||||
/*
|
||||
* Forbid this during parallel operation because, to make it work,
|
||||
* the cooperating backends would need to share the backend-local cached
|
||||
* Forbid this during parallel operation because, to make it work, the
|
||||
* cooperating backends would need to share the backend-local cached
|
||||
* sequence information. Currently, we don't support that.
|
||||
*/
|
||||
PreventCommandIfParallelMode("setval()");
|
||||
|
@@ -306,14 +306,14 @@ static void createForeignKeyTriggers(Relation rel, Oid refRelOid,
|
||||
Constraint *fkconstraint,
|
||||
Oid constraintOid, Oid indexOid);
|
||||
static void ATController(AlterTableStmt *parsetree,
|
||||
Relation rel, List *cmds, bool recurse, LOCKMODE lockmode);
|
||||
Relation rel, List *cmds, bool recurse, LOCKMODE lockmode);
|
||||
static void ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
|
||||
bool recurse, bool recursing, LOCKMODE lockmode);
|
||||
static void ATRewriteCatalogs(List **wqueue, LOCKMODE lockmode);
|
||||
static void ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
|
||||
AlterTableCmd *cmd, LOCKMODE lockmode);
|
||||
static void ATRewriteTables(AlterTableStmt *parsetree,
|
||||
List **wqueue, LOCKMODE lockmode);
|
||||
List **wqueue, LOCKMODE lockmode);
|
||||
static void ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode);
|
||||
static AlteredTableInfo *ATGetQueueEntry(List **wqueue, Relation rel);
|
||||
static void ATSimplePermissions(Relation rel, int allowed_targets);
|
||||
@@ -631,7 +631,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
|
||||
|
||||
cooked = (CookedConstraint *) palloc(sizeof(CookedConstraint));
|
||||
cooked->contype = CONSTR_DEFAULT;
|
||||
cooked->conoid = InvalidOid; /* until created */
|
||||
cooked->conoid = InvalidOid; /* until created */
|
||||
cooked->name = NULL;
|
||||
cooked->attnum = attnum;
|
||||
cooked->expr = colDef->cooked_default;
|
||||
@@ -1751,7 +1751,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
||||
|
||||
cooked = (CookedConstraint *) palloc(sizeof(CookedConstraint));
|
||||
cooked->contype = CONSTR_CHECK;
|
||||
cooked->conoid = InvalidOid; /* until created */
|
||||
cooked->conoid = InvalidOid; /* until created */
|
||||
cooked->name = pstrdup(name);
|
||||
cooked->attnum = 0; /* not used for constraints */
|
||||
cooked->expr = expr;
|
||||
@@ -1781,7 +1781,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
||||
*/
|
||||
if (inhSchema != NIL)
|
||||
{
|
||||
int schema_attno = 0;
|
||||
int schema_attno = 0;
|
||||
|
||||
foreach(entry, schema)
|
||||
{
|
||||
@@ -1809,14 +1809,14 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
||||
* Yes, try to merge the two column definitions. They must
|
||||
* have the same type, typmod, and collation.
|
||||
*/
|
||||
if (exist_attno == schema_attno)
|
||||
if (exist_attno == schema_attno)
|
||||
ereport(NOTICE,
|
||||
(errmsg("merging column \"%s\" with inherited definition",
|
||||
attributeName)));
|
||||
(errmsg("merging column \"%s\" with inherited definition",
|
||||
attributeName)));
|
||||
else
|
||||
ereport(NOTICE,
|
||||
(errmsg("moving and merging column \"%s\" with inherited definition", attributeName),
|
||||
errdetail("User-specified column moved to the position of the inherited column.")));
|
||||
(errmsg("moving and merging column \"%s\" with inherited definition", attributeName),
|
||||
errdetail("User-specified column moved to the position of the inherited column.")));
|
||||
def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1);
|
||||
typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod);
|
||||
typenameTypeIdAndMod(NULL, newdef->typeName, &newTypeId, &newtypmod);
|
||||
@@ -3496,7 +3496,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
|
||||
break;
|
||||
case AT_ReAddIndex: /* ADD INDEX */
|
||||
address = ATExecAddIndex(tab, rel, (IndexStmt *) cmd->def, true,
|
||||
lockmode);
|
||||
lockmode);
|
||||
break;
|
||||
case AT_AddConstraint: /* ADD CONSTRAINT */
|
||||
address =
|
||||
@@ -3803,7 +3803,7 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode)
|
||||
* And fire it only once.
|
||||
*/
|
||||
if (parsetree)
|
||||
EventTriggerTableRewrite((Node *)parsetree,
|
||||
EventTriggerTableRewrite((Node *) parsetree,
|
||||
tab->relid,
|
||||
tab->rewrite);
|
||||
|
||||
@@ -5960,7 +5960,7 @@ ATExecAddIndexConstraint(AlteredTableInfo *tab, Relation rel,
|
||||
true, /* update pg_index */
|
||||
true, /* remove old dependencies */
|
||||
allowSystemTableMods,
|
||||
false); /* is_internal */
|
||||
false); /* is_internal */
|
||||
|
||||
index_close(indexRel, NoLock);
|
||||
|
||||
@@ -6906,7 +6906,7 @@ ATExecValidateConstraint(Relation rel, char *constrName, bool recurse,
|
||||
HeapTupleGetOid(tuple));
|
||||
}
|
||||
else
|
||||
address = InvalidObjectAddress; /* already validated */
|
||||
address = InvalidObjectAddress; /* already validated */
|
||||
|
||||
systable_endscan(scan);
|
||||
|
||||
@@ -7866,11 +7866,12 @@ ATPrepAlterColumnType(List **wqueue,
|
||||
{
|
||||
/*
|
||||
* Set up an expression to transform the old data value to the new
|
||||
* type. If a USING option was given, use the expression as transformed
|
||||
* by transformAlterTableStmt, else just take the old value and try to
|
||||
* coerce it. We do this first so that type incompatibility can be
|
||||
* detected before we waste effort, and because we need the expression
|
||||
* to be parsed against the original table row type.
|
||||
* type. If a USING option was given, use the expression as
|
||||
* transformed by transformAlterTableStmt, else just take the old
|
||||
* value and try to coerce it. We do this first so that type
|
||||
* incompatibility can be detected before we waste effort, and because
|
||||
* we need the expression to be parsed against the original table row
|
||||
* type.
|
||||
*/
|
||||
if (!transform)
|
||||
{
|
||||
@@ -8221,8 +8222,8 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
|
||||
* specified in the policy's USING or WITH CHECK qual
|
||||
* expressions. It might be possible to rewrite and recheck
|
||||
* the policy expression, but punt for now. It's certainly
|
||||
* easy enough to remove and recreate the policy; still,
|
||||
* FIXME someday.
|
||||
* easy enough to remove and recreate the policy; still, FIXME
|
||||
* someday.
|
||||
*/
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
@@ -9701,9 +9702,9 @@ AlterTableMoveAll(AlterTableMoveAllStmt *stmt)
|
||||
!ConditionalLockRelationOid(relOid, AccessExclusiveLock))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_IN_USE),
|
||||
errmsg("aborting because lock on relation \"%s\".\"%s\" is not available",
|
||||
get_namespace_name(relForm->relnamespace),
|
||||
NameStr(relForm->relname))));
|
||||
errmsg("aborting because lock on relation \"%s\".\"%s\" is not available",
|
||||
get_namespace_name(relForm->relnamespace),
|
||||
NameStr(relForm->relname))));
|
||||
else
|
||||
LockRelationOid(relOid, AccessExclusiveLock);
|
||||
|
||||
@@ -10923,9 +10924,9 @@ ATExecReplicaIdentity(Relation rel, ReplicaIdentityStmt *stmt, LOCKMODE lockmode
|
||||
static void
|
||||
ATExecEnableRowSecurity(Relation rel)
|
||||
{
|
||||
Relation pg_class;
|
||||
Oid relid;
|
||||
HeapTuple tuple;
|
||||
Relation pg_class;
|
||||
Oid relid;
|
||||
HeapTuple tuple;
|
||||
|
||||
relid = RelationGetRelid(rel);
|
||||
|
||||
@@ -10949,9 +10950,9 @@ ATExecEnableRowSecurity(Relation rel)
|
||||
static void
|
||||
ATExecDisableRowSecurity(Relation rel)
|
||||
{
|
||||
Relation pg_class;
|
||||
Oid relid;
|
||||
HeapTuple tuple;
|
||||
Relation pg_class;
|
||||
Oid relid;
|
||||
HeapTuple tuple;
|
||||
|
||||
relid = RelationGetRelid(rel);
|
||||
|
||||
|
@@ -4329,7 +4329,7 @@ AfterTriggerEndSubXact(bool isCommit)
|
||||
static void
|
||||
AfterTriggerEnlargeQueryState(void)
|
||||
{
|
||||
int init_depth = afterTriggers.maxquerydepth;
|
||||
int init_depth = afterTriggers.maxquerydepth;
|
||||
|
||||
Assert(afterTriggers.query_depth >= afterTriggers.maxquerydepth);
|
||||
|
||||
@@ -4396,7 +4396,7 @@ SetConstraintStateCreate(int numalloc)
|
||||
state = (SetConstraintState)
|
||||
MemoryContextAllocZero(TopTransactionContext,
|
||||
offsetof(SetConstraintStateData, trigstates) +
|
||||
numalloc * sizeof(SetConstraintTriggerData));
|
||||
numalloc * sizeof(SetConstraintTriggerData));
|
||||
|
||||
state->numalloc = numalloc;
|
||||
|
||||
|
@@ -575,13 +575,13 @@ DefineType(List *names, List *parameters)
|
||||
if (typmodinOid && func_volatile(typmodinOid) == PROVOLATILE_VOLATILE)
|
||||
ereport(WARNING,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("type modifier input function %s should not be volatile",
|
||||
NameListToString(typmodinName))));
|
||||
errmsg("type modifier input function %s should not be volatile",
|
||||
NameListToString(typmodinName))));
|
||||
if (typmodoutOid && func_volatile(typmodoutOid) == PROVOLATILE_VOLATILE)
|
||||
ereport(WARNING,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("type modifier output function %s should not be volatile",
|
||||
NameListToString(typmodoutName))));
|
||||
errmsg("type modifier output function %s should not be volatile",
|
||||
NameListToString(typmodoutName))));
|
||||
|
||||
/*
|
||||
* OK, we're done checking, time to make the type. We must assign the
|
||||
@@ -643,32 +643,32 @@ DefineType(List *names, List *parameters)
|
||||
array_type, /* type name */
|
||||
typeNamespace, /* namespace */
|
||||
InvalidOid, /* relation oid (n/a here) */
|
||||
0, /* relation kind (ditto) */
|
||||
GetUserId(), /* owner's ID */
|
||||
-1, /* internal size (always varlena) */
|
||||
0, /* relation kind (ditto) */
|
||||
GetUserId(), /* owner's ID */
|
||||
-1, /* internal size (always varlena) */
|
||||
TYPTYPE_BASE, /* type-type (base type) */
|
||||
TYPCATEGORY_ARRAY, /* type-category (array) */
|
||||
false, /* array types are never preferred */
|
||||
false, /* array types are never preferred */
|
||||
delimiter, /* array element delimiter */
|
||||
F_ARRAY_IN, /* input procedure */
|
||||
F_ARRAY_OUT, /* output procedure */
|
||||
F_ARRAY_OUT, /* output procedure */
|
||||
F_ARRAY_RECV, /* receive procedure */
|
||||
F_ARRAY_SEND, /* send procedure */
|
||||
typmodinOid, /* typmodin procedure */
|
||||
typmodinOid, /* typmodin procedure */
|
||||
typmodoutOid, /* typmodout procedure */
|
||||
F_ARRAY_TYPANALYZE, /* analyze procedure */
|
||||
typoid, /* element type ID */
|
||||
true, /* yes this is an array type */
|
||||
typoid, /* element type ID */
|
||||
true, /* yes this is an array type */
|
||||
InvalidOid, /* no further array type */
|
||||
InvalidOid, /* base type ID */
|
||||
NULL, /* never a default type value */
|
||||
NULL, /* binary default isn't sent either */
|
||||
false, /* never passed by value */
|
||||
NULL, /* never a default type value */
|
||||
NULL, /* binary default isn't sent either */
|
||||
false, /* never passed by value */
|
||||
alignment, /* see above */
|
||||
'x', /* ARRAY is always toastable */
|
||||
-1, /* typMod (Domains only) */
|
||||
0, /* Array dimensions of typbasetype */
|
||||
false, /* Type NOT NULL */
|
||||
'x', /* ARRAY is always toastable */
|
||||
-1, /* typMod (Domains only) */
|
||||
0, /* Array dimensions of typbasetype */
|
||||
false, /* Type NOT NULL */
|
||||
collation); /* type's collation */
|
||||
|
||||
pfree(array_type);
|
||||
@@ -1616,7 +1616,7 @@ makeRangeConstructors(const char *name, Oid namespace,
|
||||
PointerGetDatum(NULL), /* parameterModes */
|
||||
PointerGetDatum(NULL), /* parameterNames */
|
||||
NIL, /* parameterDefaults */
|
||||
PointerGetDatum(NULL), /* trftypes */
|
||||
PointerGetDatum(NULL), /* trftypes */
|
||||
PointerGetDatum(NULL), /* proconfig */
|
||||
1.0, /* procost */
|
||||
0.0); /* prorows */
|
||||
|
@@ -87,7 +87,8 @@ CreateRole(CreateRoleStmt *stmt)
|
||||
bool createdb = false; /* Can the user create databases? */
|
||||
bool canlogin = false; /* Can this user login? */
|
||||
bool isreplication = false; /* Is this a replication role? */
|
||||
bool bypassrls = false; /* Is this a row security enabled role? */
|
||||
bool bypassrls = false; /* Is this a row security enabled
|
||||
* role? */
|
||||
int connlimit = -1; /* maximum connections allowed */
|
||||
List *addroleto = NIL; /* roles to make this a member of */
|
||||
List *rolemembers = NIL; /* roles to be members of this role */
|
||||
@@ -300,7 +301,7 @@ CreateRole(CreateRoleStmt *stmt)
|
||||
if (!superuser())
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
errmsg("must be superuser to change bypassrls attribute.")));
|
||||
errmsg("must be superuser to change bypassrls attribute.")));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -681,7 +682,7 @@ AlterRole(AlterRoleStmt *stmt)
|
||||
if (!superuser())
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
errmsg("must be superuser to change bypassrls attribute")));
|
||||
errmsg("must be superuser to change bypassrls attribute")));
|
||||
}
|
||||
else if (!have_createrole_privilege())
|
||||
{
|
||||
@@ -721,11 +722,11 @@ AlterRole(AlterRoleStmt *stmt)
|
||||
* Call the password checking hook if there is one defined
|
||||
*/
|
||||
if (check_password_hook && password)
|
||||
(*check_password_hook)(rolename ,
|
||||
password,
|
||||
isMD5(password) ? PASSWORD_TYPE_MD5 : PASSWORD_TYPE_PLAINTEXT,
|
||||
validUntil_datum,
|
||||
validUntil_null);
|
||||
(*check_password_hook) (rolename,
|
||||
password,
|
||||
isMD5(password) ? PASSWORD_TYPE_MD5 : PASSWORD_TYPE_PLAINTEXT,
|
||||
validUntil_datum,
|
||||
validUntil_null);
|
||||
|
||||
/*
|
||||
* Build an updated tuple, perusing the information just obtained
|
||||
@@ -1358,8 +1359,8 @@ roleSpecsToIds(List *memberNames)
|
||||
|
||||
foreach(l, memberNames)
|
||||
{
|
||||
Node *rolespec = (Node *) lfirst(l);
|
||||
Oid roleid;
|
||||
Node *rolespec = (Node *) lfirst(l);
|
||||
Oid roleid;
|
||||
|
||||
roleid = get_rolespec_oid(rolespec, false);
|
||||
result = lappend_oid(result, roleid);
|
||||
@@ -1455,7 +1456,7 @@ AddRoleMems(const char *rolename, Oid roleid,
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_GRANT_OPERATION),
|
||||
(errmsg("role \"%s\" is a member of role \"%s\"",
|
||||
rolename, get_rolespec_name((Node *) memberRole)))));
|
||||
rolename, get_rolespec_name((Node *) memberRole)))));
|
||||
|
||||
/*
|
||||
* Check if entry for this role/member already exists; if so, give
|
||||
@@ -1470,7 +1471,7 @@ AddRoleMems(const char *rolename, Oid roleid,
|
||||
{
|
||||
ereport(NOTICE,
|
||||
(errmsg("role \"%s\" is already a member of role \"%s\"",
|
||||
get_rolespec_name((Node *) memberRole), rolename)));
|
||||
get_rolespec_name((Node *) memberRole), rolename)));
|
||||
ReleaseSysCache(authmem_tuple);
|
||||
continue;
|
||||
}
|
||||
@@ -1581,7 +1582,7 @@ DelRoleMems(const char *rolename, Oid roleid,
|
||||
{
|
||||
ereport(WARNING,
|
||||
(errmsg("role \"%s\" is not a member of role \"%s\"",
|
||||
get_rolespec_name((Node *) memberRole), rolename)));
|
||||
get_rolespec_name((Node *) memberRole), rolename)));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@@ -83,7 +83,7 @@ static bool vacuum_rel(Oid relid, RangeVar *relation, int options,
|
||||
void
|
||||
ExecVacuum(VacuumStmt *vacstmt, bool isTopLevel)
|
||||
{
|
||||
VacuumParams params;
|
||||
VacuumParams params;
|
||||
|
||||
/* sanity checks on options */
|
||||
Assert(vacstmt->options & (VACOPT_VACUUM | VACOPT_ANALYZE));
|
||||
@@ -530,8 +530,8 @@ vacuum_set_xid_limits(Relation rel,
|
||||
|
||||
/*
|
||||
* Compute the multixact age for which freezing is urgent. This is
|
||||
* normally autovacuum_multixact_freeze_max_age, but may be less if we
|
||||
* are short of multixact member space.
|
||||
* normally autovacuum_multixact_freeze_max_age, but may be less if we are
|
||||
* short of multixact member space.
|
||||
*/
|
||||
effective_multixact_freeze_max_age = MultiXactMemberFreezeThreshold();
|
||||
|
||||
@@ -1134,9 +1134,8 @@ vac_truncate_clog(TransactionId frozenXID,
|
||||
return;
|
||||
|
||||
/*
|
||||
* Truncate CLOG and CommitTs to the oldest computed value.
|
||||
* Note we don't truncate multixacts; that will be done by the next
|
||||
* checkpoint.
|
||||
* Truncate CLOG and CommitTs to the oldest computed value. Note we don't
|
||||
* truncate multixacts; that will be done by the next checkpoint.
|
||||
*/
|
||||
TruncateCLOG(frozenXID);
|
||||
TruncateCommitTs(frozenXID, true);
|
||||
|
@@ -105,7 +105,7 @@ typedef struct LVRelStats
|
||||
BlockNumber old_rel_pages; /* previous value of pg_class.relpages */
|
||||
BlockNumber rel_pages; /* total number of pages */
|
||||
BlockNumber scanned_pages; /* number of pages we examined */
|
||||
BlockNumber pinskipped_pages; /* # of pages we skipped due to a pin */
|
||||
BlockNumber pinskipped_pages; /* # of pages we skipped due to a pin */
|
||||
double scanned_tuples; /* counts only tuples on scanned pages */
|
||||
double old_rel_tuples; /* previous value of pg_class.reltuples */
|
||||
double new_rel_tuples; /* new estimated total # of tuples */
|
||||
@@ -336,7 +336,8 @@ lazy_vacuum_rel(Relation onerel, int options, VacuumParams *params,
|
||||
TimestampDifferenceExceeds(starttime, endtime,
|
||||
params->log_min_duration))
|
||||
{
|
||||
StringInfoData buf;
|
||||
StringInfoData buf;
|
||||
|
||||
TimestampDifference(starttime, endtime, &secs, &usecs);
|
||||
|
||||
read_rate = 0;
|
||||
@@ -369,7 +370,7 @@ lazy_vacuum_rel(Relation onerel, int options, VacuumParams *params,
|
||||
vacrelstats->new_rel_tuples,
|
||||
vacrelstats->new_dead_tuples);
|
||||
appendStringInfo(&buf,
|
||||
_("buffer usage: %d hits, %d misses, %d dirtied\n"),
|
||||
_("buffer usage: %d hits, %d misses, %d dirtied\n"),
|
||||
VacuumPageHit,
|
||||
VacuumPageMiss,
|
||||
VacuumPageDirty);
|
||||
@@ -454,7 +455,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
|
||||
BlockNumber next_not_all_visible_block;
|
||||
bool skipping_all_visible_blocks;
|
||||
xl_heap_freeze_tuple *frozen;
|
||||
StringInfoData buf;
|
||||
StringInfoData buf;
|
||||
|
||||
pg_rusage_init(&ru0);
|
||||
|
||||
@@ -1784,7 +1785,7 @@ static bool
|
||||
heap_page_is_all_visible(Relation rel, Buffer buf, TransactionId *visibility_cutoff_xid)
|
||||
{
|
||||
Page page = BufferGetPage(buf);
|
||||
BlockNumber blockno = BufferGetBlockNumber(buf);
|
||||
BlockNumber blockno = BufferGetBlockNumber(buf);
|
||||
OffsetNumber offnum,
|
||||
maxoff;
|
||||
bool all_visible = true;
|
||||
|
Reference in New Issue
Block a user