mirror of
https://github.com/postgres/postgres.git
synced 2026-03-22 10:30:21 -04:00
Add some const qualifiers enabled by typeof_unqual change on copyObject
The recent commit to change copyObject() to use typeof_unqual allows cleaning up some APIs to take advantage of this improved qualifier handling. EventTriggerCollectSimpleCommand() is a good example: It takes a node tree and makes a copy that it keeps around for its internal purposes, but it can't communicate via its function signature that it promises not scribble on the passed node tree. That is now fixed. Reviewed-by: David Geier <geidav.pg@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/92f9750f-c7f6-42d8-9a4a-85a3cbe808f3%40eisentraut.org
This commit is contained in:
parent
46fb08aff6
commit
7724cb9935
13 changed files with 44 additions and 41 deletions
|
|
@ -3708,7 +3708,7 @@ reindex_index(const ReindexStmt *stmt, Oid indexId,
|
|||
ObjectAddressSet(address, RelationRelationId, indexId);
|
||||
EventTriggerCollectSimpleCommand(address,
|
||||
InvalidObjectAddress,
|
||||
(Node *) stmt);
|
||||
(const Node *) stmt);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1715,7 +1715,7 @@ EventTriggerUndoInhibitCommandCollection(void)
|
|||
void
|
||||
EventTriggerCollectSimpleCommand(ObjectAddress address,
|
||||
ObjectAddress secondaryObject,
|
||||
Node *parsetree)
|
||||
const Node *parsetree)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
CollectedCommand *command;
|
||||
|
|
@ -1751,7 +1751,7 @@ EventTriggerCollectSimpleCommand(ObjectAddress address,
|
|||
* add it to the command list.
|
||||
*/
|
||||
void
|
||||
EventTriggerAlterTableStart(Node *parsetree)
|
||||
EventTriggerAlterTableStart(const Node *parsetree)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
CollectedCommand *command;
|
||||
|
|
@ -1803,7 +1803,7 @@ EventTriggerAlterTableRelid(Oid objectId)
|
|||
* internally, so that's all that this code needs to handle at the moment.
|
||||
*/
|
||||
void
|
||||
EventTriggerCollectAlterTableSubcmd(Node *subcmd, ObjectAddress address)
|
||||
EventTriggerCollectAlterTableSubcmd(const Node *subcmd, ObjectAddress address)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
CollectedATSubcmd *newsub;
|
||||
|
|
@ -1920,7 +1920,7 @@ EventTriggerCollectGrant(InternalGrant *istmt)
|
|||
* executed
|
||||
*/
|
||||
void
|
||||
EventTriggerCollectAlterOpFam(AlterOpFamilyStmt *stmt, Oid opfamoid,
|
||||
EventTriggerCollectAlterOpFam(const AlterOpFamilyStmt *stmt, Oid opfamoid,
|
||||
List *operators, List *procedures)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
|
|
@ -1953,7 +1953,7 @@ EventTriggerCollectAlterOpFam(AlterOpFamilyStmt *stmt, Oid opfamoid,
|
|||
* Save data about a CREATE OPERATOR CLASS command being executed
|
||||
*/
|
||||
void
|
||||
EventTriggerCollectCreateOpClass(CreateOpClassStmt *stmt, Oid opcoid,
|
||||
EventTriggerCollectCreateOpClass(const CreateOpClassStmt *stmt, Oid opcoid,
|
||||
List *operators, List *procedures)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
|
|
@ -1987,7 +1987,7 @@ EventTriggerCollectCreateOpClass(CreateOpClassStmt *stmt, Oid opcoid,
|
|||
* executed
|
||||
*/
|
||||
void
|
||||
EventTriggerCollectAlterTSConfig(AlterTSConfigurationStmt *stmt, Oid cfgId,
|
||||
EventTriggerCollectAlterTSConfig(const AlterTSConfigurationStmt *stmt, Oid cfgId,
|
||||
Oid *dictIds, int ndicts)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
|
|
@ -2025,7 +2025,7 @@ EventTriggerCollectAlterTSConfig(AlterTSConfigurationStmt *stmt, Oid cfgId,
|
|||
* executed
|
||||
*/
|
||||
void
|
||||
EventTriggerCollectAlterDefPrivs(AlterDefaultPrivilegesStmt *stmt)
|
||||
EventTriggerCollectAlterDefPrivs(const AlterDefaultPrivilegesStmt *stmt)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
CollectedCommand *command;
|
||||
|
|
|
|||
|
|
@ -544,7 +544,7 @@ WaitForOlderSnapshots(TransactionId limitXmin, bool progress)
|
|||
ObjectAddress
|
||||
DefineIndex(ParseState *pstate,
|
||||
Oid tableId,
|
||||
IndexStmt *stmt,
|
||||
const IndexStmt *stmt,
|
||||
Oid indexRelationId,
|
||||
Oid parentIndexId,
|
||||
Oid parentConstraintId,
|
||||
|
|
@ -4048,7 +4048,7 @@ ReindexRelationConcurrently(const ReindexStmt *stmt, Oid relationOid, const Rein
|
|||
ObjectAddressSet(address, RelationRelationId, newIndexId);
|
||||
EventTriggerCollectSimpleCommand(address,
|
||||
InvalidObjectAddress,
|
||||
(Node *) stmt);
|
||||
(const Node *) stmt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ static HeapTuple check_modified_virtual_generated(TupleDesc tupdesc, HeapTuple t
|
|||
* (but see CloneRowTriggersToPartition).
|
||||
*/
|
||||
ObjectAddress
|
||||
CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
|
||||
CreateTrigger(const CreateTrigStmt *stmt, const char *queryString,
|
||||
Oid relOid, Oid refRelOid, Oid constraintOid, Oid indexOid,
|
||||
Oid funcoid, Oid parentTriggerOid, Node *whenClause,
|
||||
bool isInternal, bool in_partition)
|
||||
|
|
@ -176,7 +176,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
|
|||
* (always/origin/replica/disabled) can be specified.
|
||||
*/
|
||||
ObjectAddress
|
||||
CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
|
||||
CreateTriggerFiringOn(const CreateTrigStmt *stmt, const char *queryString,
|
||||
Oid relOid, Oid refRelOid, Oid constraintOid,
|
||||
Oid indexOid, Oid funcoid, Oid parentTriggerOid,
|
||||
Node *whenClause, bool isInternal, bool in_partition,
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ static void replace_vars_in_jointree(Node *jtnode,
|
|||
pullup_replace_vars_context *context);
|
||||
static Node *pullup_replace_vars(Node *expr,
|
||||
pullup_replace_vars_context *context);
|
||||
static Node *pullup_replace_vars_callback(Var *var,
|
||||
static Node *pullup_replace_vars_callback(const Var *var,
|
||||
replace_rte_variables_context *context);
|
||||
static Query *pullup_replace_vars_subquery(Query *query,
|
||||
pullup_replace_vars_context *context);
|
||||
|
|
@ -2761,7 +2761,7 @@ pullup_replace_vars(Node *expr, pullup_replace_vars_context *context)
|
|||
}
|
||||
|
||||
static Node *
|
||||
pullup_replace_vars_callback(Var *var,
|
||||
pullup_replace_vars_callback(const Var *var,
|
||||
replace_rte_variables_context *context)
|
||||
{
|
||||
pullup_replace_vars_context *rcon = (pullup_replace_vars_context *) context->callback_arg;
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ static PartitionPruneStep *gen_prune_step_combine(GeneratePruningStepsContext *c
|
|||
static List *gen_prune_steps_from_opexps(GeneratePruningStepsContext *context,
|
||||
List **keyclauses, Bitmapset *nullkeys);
|
||||
static PartClauseMatchStatus match_clause_to_partition_key(GeneratePruningStepsContext *context,
|
||||
Expr *clause, Expr *partkey, int partkeyidx,
|
||||
const Expr *clause, const Expr *partkey, int partkeyidx,
|
||||
bool *clause_is_not_null,
|
||||
PartClauseInfo **pc, List **clause_steps);
|
||||
static List *get_steps_using_prefix(GeneratePruningStepsContext *context,
|
||||
|
|
@ -196,8 +196,8 @@ static PruneStepResult *perform_pruning_combine_step(PartitionPruneContext *cont
|
|||
PartitionPruneStepCombine *cstep,
|
||||
PruneStepResult **step_results);
|
||||
static PartClauseMatchStatus match_boolean_partition_clause(Oid partopfamily,
|
||||
Expr *clause,
|
||||
Expr *partkey,
|
||||
const Expr *clause,
|
||||
const Expr *partkey,
|
||||
Expr **outconst,
|
||||
bool *notclause);
|
||||
static void partkey_datum_from_expr(PartitionPruneContext *context,
|
||||
|
|
@ -1816,7 +1816,7 @@ gen_prune_steps_from_opexps(GeneratePruningStepsContext *context,
|
|||
*/
|
||||
static PartClauseMatchStatus
|
||||
match_clause_to_partition_key(GeneratePruningStepsContext *context,
|
||||
Expr *clause, Expr *partkey, int partkeyidx,
|
||||
const Expr *clause, const Expr *partkey, int partkeyidx,
|
||||
bool *clause_is_not_null, PartClauseInfo **pc,
|
||||
List **clause_steps)
|
||||
{
|
||||
|
|
@ -3697,10 +3697,10 @@ perform_pruning_combine_step(PartitionPruneContext *context,
|
|||
* 'partkey'.
|
||||
*/
|
||||
static PartClauseMatchStatus
|
||||
match_boolean_partition_clause(Oid partopfamily, Expr *clause, Expr *partkey,
|
||||
match_boolean_partition_clause(Oid partopfamily, const Expr *clause, const Expr *partkey,
|
||||
Expr **outconst, bool *notclause)
|
||||
{
|
||||
Expr *leftop;
|
||||
const Expr *leftop;
|
||||
|
||||
*outconst = NULL;
|
||||
*notclause = false;
|
||||
|
|
|
|||
|
|
@ -1769,7 +1769,7 @@ typedef struct
|
|||
} ReplaceVarsFromTargetList_context;
|
||||
|
||||
static Node *
|
||||
ReplaceVarsFromTargetList_callback(Var *var,
|
||||
ReplaceVarsFromTargetList_callback(const Var *var,
|
||||
replace_rte_variables_context *context)
|
||||
{
|
||||
ReplaceVarsFromTargetList_context *rcon = (ReplaceVarsFromTargetList_context *) context->callback_arg;
|
||||
|
|
@ -1790,7 +1790,7 @@ ReplaceVarsFromTargetList_callback(Var *var,
|
|||
}
|
||||
|
||||
Node *
|
||||
ReplaceVarFromTargetList(Var *var,
|
||||
ReplaceVarFromTargetList(const Var *var,
|
||||
RangeTblEntry *target_rte,
|
||||
List *targetlist,
|
||||
int result_relation,
|
||||
|
|
@ -1876,11 +1876,14 @@ ReplaceVarFromTargetList(Var *var,
|
|||
break;
|
||||
|
||||
case REPLACEVARS_CHANGE_VARNO:
|
||||
var = copyObject(var);
|
||||
var->varno = nomatch_varno;
|
||||
var->varlevelsup = 0;
|
||||
/* we leave the syntactic referent alone */
|
||||
return (Node *) var;
|
||||
{
|
||||
Var *newvar = copyObject(var);
|
||||
|
||||
newvar->varno = nomatch_varno;
|
||||
newvar->varlevelsup = 0;
|
||||
/* we leave the syntactic referent alone */
|
||||
return (Node *) newvar;
|
||||
}
|
||||
|
||||
case REPLACEVARS_SUBSTITUTE_NULL:
|
||||
{
|
||||
|
|
|
|||
2
src/backend/utils/cache/plancache.c
vendored
2
src/backend/utils/cache/plancache.c
vendored
|
|
@ -182,7 +182,7 @@ InitPlanCache(void)
|
|||
* commandTag: command tag for query, or UNKNOWN if empty query
|
||||
*/
|
||||
CachedPlanSource *
|
||||
CreateCachedPlan(RawStmt *raw_parse_tree,
|
||||
CreateCachedPlan(const RawStmt *raw_parse_tree,
|
||||
const char *query_string,
|
||||
CommandTag commandTag)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ extern void RemoveObjects(DropStmt *stmt);
|
|||
/* commands/indexcmds.c */
|
||||
extern ObjectAddress DefineIndex(ParseState *pstate,
|
||||
Oid tableId,
|
||||
IndexStmt *stmt,
|
||||
const IndexStmt *stmt,
|
||||
Oid indexRelationId,
|
||||
Oid parentIndexId,
|
||||
Oid parentConstraintId,
|
||||
|
|
|
|||
|
|
@ -75,23 +75,23 @@ extern void EventTriggerUndoInhibitCommandCollection(void);
|
|||
|
||||
extern void EventTriggerCollectSimpleCommand(ObjectAddress address,
|
||||
ObjectAddress secondaryObject,
|
||||
Node *parsetree);
|
||||
const Node *parsetree);
|
||||
|
||||
extern void EventTriggerAlterTableStart(Node *parsetree);
|
||||
extern void EventTriggerAlterTableStart(const Node *parsetree);
|
||||
extern void EventTriggerAlterTableRelid(Oid objectId);
|
||||
extern void EventTriggerCollectAlterTableSubcmd(Node *subcmd,
|
||||
extern void EventTriggerCollectAlterTableSubcmd(const Node *subcmd,
|
||||
ObjectAddress address);
|
||||
extern void EventTriggerAlterTableEnd(void);
|
||||
|
||||
extern void EventTriggerCollectGrant(InternalGrant *istmt);
|
||||
extern void EventTriggerCollectAlterOpFam(AlterOpFamilyStmt *stmt,
|
||||
extern void EventTriggerCollectAlterOpFam(const AlterOpFamilyStmt *stmt,
|
||||
Oid opfamoid, List *operators,
|
||||
List *procedures);
|
||||
extern void EventTriggerCollectCreateOpClass(CreateOpClassStmt *stmt,
|
||||
extern void EventTriggerCollectCreateOpClass(const CreateOpClassStmt *stmt,
|
||||
Oid opcoid, List *operators,
|
||||
List *procedures);
|
||||
extern void EventTriggerCollectAlterTSConfig(AlterTSConfigurationStmt *stmt,
|
||||
extern void EventTriggerCollectAlterTSConfig(const AlterTSConfigurationStmt *stmt,
|
||||
Oid cfgId, Oid *dictIds, int ndicts);
|
||||
extern void EventTriggerCollectAlterDefPrivs(AlterDefaultPrivilegesStmt *stmt);
|
||||
extern void EventTriggerCollectAlterDefPrivs(const AlterDefaultPrivilegesStmt *stmt);
|
||||
|
||||
#endif /* EVENT_TRIGGER_H */
|
||||
|
|
|
|||
|
|
@ -153,11 +153,11 @@ extern PGDLLIMPORT int SessionReplicationRole;
|
|||
#define TRIGGER_FIRES_ON_REPLICA 'R'
|
||||
#define TRIGGER_DISABLED 'D'
|
||||
|
||||
extern ObjectAddress CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
|
||||
extern ObjectAddress CreateTrigger(const CreateTrigStmt *stmt, const char *queryString,
|
||||
Oid relOid, Oid refRelOid, Oid constraintOid, Oid indexOid,
|
||||
Oid funcoid, Oid parentTriggerOid, Node *whenClause,
|
||||
bool isInternal, bool in_partition);
|
||||
extern ObjectAddress CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
|
||||
extern ObjectAddress CreateTriggerFiringOn(const CreateTrigStmt *stmt, const char *queryString,
|
||||
Oid relOid, Oid refRelOid, Oid constraintOid,
|
||||
Oid indexOid, Oid funcoid, Oid parentTriggerOid,
|
||||
Node *whenClause, bool isInternal, bool in_partition,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ typedef struct AttrMap AttrMap; /* avoid including attmap.h here */
|
|||
|
||||
typedef struct replace_rte_variables_context replace_rte_variables_context;
|
||||
|
||||
typedef Node *(*replace_rte_variables_callback) (Var *var,
|
||||
typedef Node *(*replace_rte_variables_callback) (const Var *var,
|
||||
replace_rte_variables_context *context);
|
||||
|
||||
struct replace_rte_variables_context
|
||||
|
|
@ -104,7 +104,7 @@ extern Node *map_variable_attnos(Node *node,
|
|||
const AttrMap *attno_map,
|
||||
Oid to_rowtype, bool *found_whole_row);
|
||||
|
||||
extern Node *ReplaceVarFromTargetList(Var *var,
|
||||
extern Node *ReplaceVarFromTargetList(const Var *var,
|
||||
RangeTblEntry *target_rte,
|
||||
List *targetlist,
|
||||
int result_relation,
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ extern void ResetPlanCache(void);
|
|||
|
||||
extern void ReleaseAllPlanCacheRefsInOwner(ResourceOwner owner);
|
||||
|
||||
extern CachedPlanSource *CreateCachedPlan(RawStmt *raw_parse_tree,
|
||||
extern CachedPlanSource *CreateCachedPlan(const RawStmt *raw_parse_tree,
|
||||
const char *query_string,
|
||||
CommandTag commandTag);
|
||||
extern CachedPlanSource *CreateCachedPlanForQuery(Query *analyzed_parse_tree,
|
||||
|
|
|
|||
Loading…
Reference in a new issue