public inbox for [email protected]help / color / mirror / Atom feed
Re: MERGE ... WHEN NOT MATCHED BY SOURCE 9+ messages / 2 participants [nested] [flat]
* Re: MERGE ... WHEN NOT MATCHED BY SOURCE @ 2023-01-04 11:57 Alvaro Herrera <[email protected]> 0 siblings, 0 replies; 9+ messages in thread From: Alvaro Herrera @ 2023-01-04 11:57 UTC (permalink / raw) To: Dean Rasheed <[email protected]>; +Cc: PostgreSQL Hackers <[email protected]> I haven't read this patch other than superficially; I suppose the feature it's introducing is an OK one to have as an extension to the standard. (I hope the community members that are committee members will propose this extension to become part of the standard.) On 2023-Jan-02, Dean Rasheed wrote: > --- a/src/backend/optimizer/prep/preptlist.c > +++ b/src/backend/optimizer/prep/preptlist.c > @@ -157,15 +157,14 @@ preprocess_targetlist(PlannerInfo *root) > /* > * Add resjunk entries for any Vars used in each action's > * targetlist and WHEN condition that belong to relations other > - * than target. Note that aggregates, window functions and > - * placeholder vars are not possible anywhere in MERGE's WHEN > - * clauses. (PHVs may be added later, but they don't concern us > - * here.) > + * than target. Note that aggregates and window functions are not > + * possible anywhere in MERGE's WHEN clauses, but PlaceHolderVars > + * may have been added by subquery pullup. > */ > vars = pull_var_clause((Node *) > list_concat_copy((List *) action->qual, > action->targetList), > - 0); > + PVC_INCLUDE_PLACEHOLDERS); Hmm, is this new because of NOT MATCHED BY SOURCE, or is it something that can already be hit by existing features of MERGE? In other words -- is this a bug fix that should be backpatched ahead of introducing NOT MATCHED BY SOURCE? > @@ -127,10 +143,12 @@ transformMergeStmt(ParseState *pstate, M > */ > is_terminal[0] = false; > is_terminal[1] = false; > + is_terminal[2] = false; I think these 0/1/2 should be replaced by the values of MergeMatchKind. > + /* Join type required */ > + if (left_join && right_join) > + qry->mergeJoinType = JOIN_FULL; > + else if (left_join) > + qry->mergeJoinType = JOIN_LEFT; > + else if (right_join) > + qry->mergeJoinType = JOIN_RIGHT; > + else > + qry->mergeJoinType = JOIN_INNER; One of the review comments that MERGE got initially was that parse analysis was not a place to "do query optimization", in the sense that the original code was making a decision whether to make an outer or inner join based on the set of WHEN clauses that appear in the command. That's how we ended up with transform_MERGE_to_join and mergeUseOuterJoin instead. This new code is certainly not the same, but it makes me a bit unconfortable. Maybe it's OK, though. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ ^ permalink raw reply [nested|flat] 9+ messages in thread
* [PATCH v1] psql: Fix \df tab completion for procedures @ 2025-11-22 14:42 Erik Wienhold <[email protected]> 0 siblings, 0 replies; 9+ messages in thread From: Erik Wienhold @ 2025-11-22 14:42 UTC (permalink / raw) \df also covers procedures since fb421231daa. But the tab completion logic was never changed to align with that. Fix this along the lines of 05e85d35afb. --- src/bin/psql/tab-complete.in.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 072b98bea08..8f81f5bf035 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -5669,7 +5669,7 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dew*")) COMPLETE_WITH_QUERY(Query_for_list_of_fdws); else if (TailMatchesCS("\\df*")) - COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(Query_for_list_of_functions); + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_routines); else if (HeadMatchesCS("\\df*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes); -- 2.55.0 --5rsvev5qaoortkiw-- ^ permalink raw reply [nested|flat] 9+ messages in thread
* [PATCH v1] psql: Fix \df tab completion for procedures @ 2025-11-22 14:42 Erik Wienhold <[email protected]> 0 siblings, 0 replies; 9+ messages in thread From: Erik Wienhold @ 2025-11-22 14:42 UTC (permalink / raw) \df also covers procedures since fb421231daa. But the tab completion logic was never changed to align with that. Fix this along the lines of 05e85d35afb. --- src/bin/psql/tab-complete.in.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 072b98bea08..8f81f5bf035 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -5669,7 +5669,7 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dew*")) COMPLETE_WITH_QUERY(Query_for_list_of_fdws); else if (TailMatchesCS("\\df*")) - COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(Query_for_list_of_functions); + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_routines); else if (HeadMatchesCS("\\df*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes); -- 2.55.0 --5rsvev5qaoortkiw-- ^ permalink raw reply [nested|flat] 9+ messages in thread
* [PATCH v1] psql: Fix \df tab completion for procedures @ 2025-11-22 14:42 Erik Wienhold <[email protected]> 0 siblings, 0 replies; 9+ messages in thread From: Erik Wienhold @ 2025-11-22 14:42 UTC (permalink / raw) \df also covers procedures since fb421231daa. But the tab completion logic was never changed to align with that. Fix this along the lines of 05e85d35afb. --- src/bin/psql/tab-complete.in.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 072b98bea08..8f81f5bf035 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -5669,7 +5669,7 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dew*")) COMPLETE_WITH_QUERY(Query_for_list_of_fdws); else if (TailMatchesCS("\\df*")) - COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(Query_for_list_of_functions); + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_routines); else if (HeadMatchesCS("\\df*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes); -- 2.55.0 --5rsvev5qaoortkiw-- ^ permalink raw reply [nested|flat] 9+ messages in thread
* [PATCH v1] psql: Fix \df tab completion for procedures @ 2025-11-22 14:42 Erik Wienhold <[email protected]> 0 siblings, 0 replies; 9+ messages in thread From: Erik Wienhold @ 2025-11-22 14:42 UTC (permalink / raw) \df also covers procedures since fb421231daa. But the tab completion logic was never changed to align with that. Fix this along the lines of 05e85d35afb. --- src/bin/psql/tab-complete.in.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 072b98bea08..8f81f5bf035 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -5669,7 +5669,7 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dew*")) COMPLETE_WITH_QUERY(Query_for_list_of_fdws); else if (TailMatchesCS("\\df*")) - COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(Query_for_list_of_functions); + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_routines); else if (HeadMatchesCS("\\df*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes); -- 2.55.0 --5rsvev5qaoortkiw-- ^ permalink raw reply [nested|flat] 9+ messages in thread
* [PATCH v1] psql: Fix \df tab completion for procedures @ 2025-11-22 14:42 Erik Wienhold <[email protected]> 0 siblings, 0 replies; 9+ messages in thread From: Erik Wienhold @ 2025-11-22 14:42 UTC (permalink / raw) \df also covers procedures since fb421231daa. But the tab completion logic was never changed to align with that. Fix this along the lines of 05e85d35afb. --- src/bin/psql/tab-complete.in.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 072b98bea08..8f81f5bf035 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -5669,7 +5669,7 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dew*")) COMPLETE_WITH_QUERY(Query_for_list_of_fdws); else if (TailMatchesCS("\\df*")) - COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(Query_for_list_of_functions); + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_routines); else if (HeadMatchesCS("\\df*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes); -- 2.55.0 --5rsvev5qaoortkiw-- ^ permalink raw reply [nested|flat] 9+ messages in thread
* [PATCH v1] psql: Fix \df tab completion for procedures @ 2025-11-22 14:42 Erik Wienhold <[email protected]> 0 siblings, 0 replies; 9+ messages in thread From: Erik Wienhold @ 2025-11-22 14:42 UTC (permalink / raw) \df also covers procedures since fb421231daa. But the tab completion logic was never changed to align with that. Fix this along the lines of 05e85d35afb. --- src/bin/psql/tab-complete.in.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 072b98bea08..8f81f5bf035 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -5669,7 +5669,7 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dew*")) COMPLETE_WITH_QUERY(Query_for_list_of_fdws); else if (TailMatchesCS("\\df*")) - COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(Query_for_list_of_functions); + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_routines); else if (HeadMatchesCS("\\df*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes); -- 2.55.0 --5rsvev5qaoortkiw-- ^ permalink raw reply [nested|flat] 9+ messages in thread
* [PATCH v1] psql: Fix \df tab completion for procedures @ 2025-11-22 14:42 Erik Wienhold <[email protected]> 0 siblings, 0 replies; 9+ messages in thread From: Erik Wienhold @ 2025-11-22 14:42 UTC (permalink / raw) \df also covers procedures since fb421231daa. But the tab completion logic was never changed to align with that. Fix this along the lines of 05e85d35afb. --- src/bin/psql/tab-complete.in.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 072b98bea08..8f81f5bf035 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -5669,7 +5669,7 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dew*")) COMPLETE_WITH_QUERY(Query_for_list_of_fdws); else if (TailMatchesCS("\\df*")) - COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(Query_for_list_of_functions); + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_routines); else if (HeadMatchesCS("\\df*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes); -- 2.55.0 --5rsvev5qaoortkiw-- ^ permalink raw reply [nested|flat] 9+ messages in thread
* [PATCH v1] psql: Fix \df tab completion for procedures @ 2025-11-22 14:42 Erik Wienhold <[email protected]> 0 siblings, 0 replies; 9+ messages in thread From: Erik Wienhold @ 2025-11-22 14:42 UTC (permalink / raw) \df also covers procedures since fb421231daa. But the tab completion logic was never changed to align with that. Fix this along the lines of 05e85d35afb. --- src/bin/psql/tab-complete.in.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 072b98bea08..8f81f5bf035 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -5669,7 +5669,7 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dew*")) COMPLETE_WITH_QUERY(Query_for_list_of_fdws); else if (TailMatchesCS("\\df*")) - COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(Query_for_list_of_functions); + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_routines); else if (HeadMatchesCS("\\df*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes); -- 2.55.0 --5rsvev5qaoortkiw-- ^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2025-11-22 14:42 UTC | newest] Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-01-04 11:57 Re: MERGE ... WHEN NOT MATCHED BY SOURCE Alvaro Herrera <[email protected]> 2025-11-22 14:42 [PATCH v1] psql: Fix \df tab completion for procedures Erik Wienhold <[email protected]> 2025-11-22 14:42 [PATCH v1] psql: Fix \df tab completion for procedures Erik Wienhold <[email protected]> 2025-11-22 14:42 [PATCH v1] psql: Fix \df tab completion for procedures Erik Wienhold <[email protected]> 2025-11-22 14:42 [PATCH v1] psql: Fix \df tab completion for procedures Erik Wienhold <[email protected]> 2025-11-22 14:42 [PATCH v1] psql: Fix \df tab completion for procedures Erik Wienhold <[email protected]> 2025-11-22 14:42 [PATCH v1] psql: Fix \df tab completion for procedures Erik Wienhold <[email protected]> 2025-11-22 14:42 [PATCH v1] psql: Fix \df tab completion for procedures Erik Wienhold <[email protected]> 2025-11-22 14:42 [PATCH v1] psql: Fix \df tab completion for procedures Erik Wienhold <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox