1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Rename ResolveNew() to ReplaceVarsFromTargetList(), and tweak its API.

This function currently lacks the option to throw error if the provided
targetlist doesn't have any matching entry for a Var to be replaced.
Two of the four existing call sites would be better off with an error,
as would the usage in the pending auto-updatable-views patch, so it seems
past time to extend the API to support that.  To do so, replace the "event"
parameter (historically of type CmdType, though it was declared plain int)
with a special-purpose enum type.

It's unclear whether this function might be called by third-party code.
Since many C compilers wouldn't warn about a call site continuing to use
the old calling convention, rename the function to forcibly break any
such code that hasn't been updated.  The old name was none too well chosen
anyhow.
This commit is contained in:
Tom Lane
2012-11-08 16:52:49 -05:00
parent 75af5ae9c0
commit dcc55dd21a
4 changed files with 106 additions and 76 deletions

View File

@@ -31,6 +31,13 @@ struct replace_rte_variables_context
bool inserted_sublink; /* have we inserted a SubLink? */
};
typedef enum ReplaceVarsNoMatchOption
{
REPLACEVARS_REPORT_ERROR, /* throw error if no match */
REPLACEVARS_CHANGE_VARNO, /* change the Var's varno, nothing else */
REPLACEVARS_SUBSTITUTE_NULL /* replace with a NULL Const */
} ReplaceVarsNoMatchOption;
extern void OffsetVarNodes(Node *node, int offset, int sublevels_up);
extern void ChangeVarNodes(Node *node, int old_varno, int new_varno,
@@ -69,9 +76,12 @@ extern Node *map_variable_attnos(Node *node,
const AttrNumber *attno_map, int map_length,
bool *found_whole_row);
extern Node *ResolveNew(Node *node, int target_varno, int sublevels_up,
RangeTblEntry *target_rte,
List *targetlist, int event, int update_varno,
bool *outer_hasSubLinks);
extern Node *ReplaceVarsFromTargetList(Node *node,
int target_varno, int sublevels_up,
RangeTblEntry *target_rte,
List *targetlist,
ReplaceVarsNoMatchOption nomatch_option,
int nomatch_varno,
bool *outer_hasSubLinks);
#endif /* REWRITEMANIP_H */