Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitffab494

Browse files
author
Etsuro Fujita
committed
postgres_fdw: Perform the (ORDERED, NULL) upperrel operations remotely.
The upper-planner pathification allows FDWs to arrange to push downdifferent types of upper-stage operations to the remote side. Thiscommit teaches postgres_fdw to do it for the (ORDERED, NULL) upperrel,which is responsible for evaluating the query's ORDER BY ordering.Since postgres_fdw is already able to evaluate that ordering remotelyfor foreign baserels and foreign joinrels (see commitaa09cd2 et al.),this adds support for that for foreign grouping relations.Author: Etsuro FujitaReviewed-By: Antonin Houska and Jeff JanesDiscussion:https://postgr.es/m/87pnz1aby9.fsf@news-spur.riddles.org.uk
1 parente2d28c0 commitffab494

File tree

4 files changed

+457
-138
lines changed

4 files changed

+457
-138
lines changed

‎contrib/postgres_fdw/deparse.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ static void printRemotePlaceholder(Oid paramtype, int32 paramtypmod,
167167
staticvoiddeparseSelectSql(List*tlist,boolis_subquery,List**retrieved_attrs,
168168
deparse_expr_cxt*context);
169169
staticvoiddeparseLockingClause(deparse_expr_cxt*context);
170-
staticvoidappendOrderByClause(List*pathkeys,deparse_expr_cxt*context);
170+
staticvoidappendOrderByClause(List*pathkeys,boolhas_final_sort,
171+
deparse_expr_cxt*context);
171172
staticvoidappendConditions(List*exprs,deparse_expr_cxt*context);
172173
staticvoiddeparseFromExprForRel(StringInfobuf,PlannerInfo*root,
173174
RelOptInfo*foreignrel,booluse_alias,
@@ -929,8 +930,8 @@ build_tlist_to_deparse(RelOptInfo *foreignrel)
929930
void
930931
deparseSelectStmtForRel(StringInfobuf,PlannerInfo*root,RelOptInfo*rel,
931932
List*tlist,List*remote_conds,List*pathkeys,
932-
boolis_subquery,List**retrieved_attrs,
933-
List**params_list)
933+
boolhas_final_sort,boolis_subquery,
934+
List**retrieved_attrs,List**params_list)
934935
{
935936
deparse_expr_cxtcontext;
936937
PgFdwRelationInfo*fpinfo= (PgFdwRelationInfo*)rel->fdw_private;
@@ -985,7 +986,7 @@ deparseSelectStmtForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *rel,
985986

986987
/* Add ORDER BY clause if we found any useful pathkeys */
987988
if (pathkeys)
988-
appendOrderByClause(pathkeys,&context);
989+
appendOrderByClause(pathkeys,has_final_sort,&context);
989990

990991
/* Add any necessary FOR UPDATE/SHARE. */
991992
deparseLockingClause(&context);
@@ -1590,7 +1591,7 @@ deparseRangeTblRef(StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel,
15901591
/* Deparse the subquery representing the relation. */
15911592
appendStringInfoChar(buf,'(');
15921593
deparseSelectStmtForRel(buf,root,foreignrel,NIL,
1593-
fpinfo->remote_conds,NIL, true,
1594+
fpinfo->remote_conds,NIL,false,true,
15941595
&retrieved_attrs,params_list);
15951596
appendStringInfoChar(buf,')');
15961597

@@ -3109,7 +3110,8 @@ appendGroupByClause(List *tlist, deparse_expr_cxt *context)
31093110
* base relation are obtained and deparsed.
31103111
*/
31113112
staticvoid
3112-
appendOrderByClause(List*pathkeys,deparse_expr_cxt*context)
3113+
appendOrderByClause(List*pathkeys,boolhas_final_sort,
3114+
deparse_expr_cxt*context)
31133115
{
31143116
ListCell*lcell;
31153117
intnestlevel;
@@ -3126,7 +3128,19 @@ appendOrderByClause(List *pathkeys, deparse_expr_cxt *context)
31263128
PathKey*pathkey=lfirst(lcell);
31273129
Expr*em_expr;
31283130

3129-
em_expr=find_em_expr_for_rel(pathkey->pk_eclass,baserel);
3131+
if (has_final_sort)
3132+
{
3133+
/*
3134+
* By construction, context->foreignrel is the input relation to
3135+
* the final sort.
3136+
*/
3137+
em_expr=find_em_expr_for_input_target(context->root,
3138+
pathkey->pk_eclass,
3139+
context->foreignrel->reltarget);
3140+
}
3141+
else
3142+
em_expr=find_em_expr_for_rel(pathkey->pk_eclass,baserel);
3143+
31303144
Assert(em_expr!=NULL);
31313145

31323146
appendStringInfoString(buf,delim);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp