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

Commitd50d172

Browse files
author
Etsuro Fujita
committed
postgres_fdw: Perform the (FINAL, 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 (FINAL, NULL) upperrel,which is responsible for doing LockRows, LIMIT, and/or ModifyTable.This provides the ability for postgres_fdw to handle SELECT commandsso that it 1) skips the LockRows step (if any) (note that this issafe since it performs early locking) and 2) pushes down the LIMITand/or OFFSET restrictions (if any) to the remote side. This doesn'thandle the INSERT/UPDATE/DELETE cases.Author: Etsuro FujitaReviewed-By: Antonin Houska and Jeff JanesDiscussion:https://postgr.es/m/87pnz1aby9.fsf@news-spur.riddles.org.uk
1 parentaef65db commitd50d172

File tree

7 files changed

+656
-390
lines changed

7 files changed

+656
-390
lines changed

‎contrib/postgres_fdw/deparse.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ static void deparseSelectSql(List *tlist, bool is_subquery, List **retrieved_att
169169
staticvoiddeparseLockingClause(deparse_expr_cxt*context);
170170
staticvoidappendOrderByClause(List*pathkeys,boolhas_final_sort,
171171
deparse_expr_cxt*context);
172+
staticvoidappendLimitClause(deparse_expr_cxt*context);
172173
staticvoidappendConditions(List*exprs,deparse_expr_cxt*context);
173174
staticvoiddeparseFromExprForRel(StringInfobuf,PlannerInfo*root,
174175
RelOptInfo*foreignrel,booluse_alias,
@@ -930,7 +931,7 @@ build_tlist_to_deparse(RelOptInfo *foreignrel)
930931
void
931932
deparseSelectStmtForRel(StringInfobuf,PlannerInfo*root,RelOptInfo*rel,
932933
List*tlist,List*remote_conds,List*pathkeys,
933-
boolhas_final_sort,boolis_subquery,
934+
boolhas_final_sort,boolhas_limit,boolis_subquery,
934935
List**retrieved_attrs,List**params_list)
935936
{
936937
deparse_expr_cxtcontext;
@@ -988,6 +989,10 @@ deparseSelectStmtForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *rel,
988989
if (pathkeys)
989990
appendOrderByClause(pathkeys,has_final_sort,&context);
990991

992+
/* Add LIMIT clause if necessary */
993+
if (has_limit)
994+
appendLimitClause(&context);
995+
991996
/* Add any necessary FOR UPDATE/SHARE. */
992997
deparseLockingClause(&context);
993998
}
@@ -1591,7 +1596,8 @@ deparseRangeTblRef(StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel,
15911596
/* Deparse the subquery representing the relation. */
15921597
appendStringInfoChar(buf,'(');
15931598
deparseSelectStmtForRel(buf,root,foreignrel,NIL,
1594-
fpinfo->remote_conds,NIL, false, true,
1599+
fpinfo->remote_conds,NIL,
1600+
false, false, true,
15951601
&retrieved_attrs,params_list);
15961602
appendStringInfoChar(buf,')');
15971603

@@ -3160,6 +3166,33 @@ appendOrderByClause(List *pathkeys, bool has_final_sort,
31603166
reset_transmission_modes(nestlevel);
31613167
}
31623168

3169+
/*
3170+
* Deparse LIMIT/OFFSET clause.
3171+
*/
3172+
staticvoid
3173+
appendLimitClause(deparse_expr_cxt*context)
3174+
{
3175+
PlannerInfo*root=context->root;
3176+
StringInfobuf=context->buf;
3177+
intnestlevel;
3178+
3179+
/* Make sure any constants in the exprs are printed portably */
3180+
nestlevel=set_transmission_modes();
3181+
3182+
if (root->parse->limitCount)
3183+
{
3184+
appendStringInfoString(buf," LIMIT ");
3185+
deparseExpr((Expr*)root->parse->limitCount,context);
3186+
}
3187+
if (root->parse->limitOffset)
3188+
{
3189+
appendStringInfoString(buf," OFFSET ");
3190+
deparseExpr((Expr*)root->parse->limitOffset,context);
3191+
}
3192+
3193+
reset_transmission_modes(nestlevel);
3194+
}
3195+
31633196
/*
31643197
* appendFunctionName
31653198
*Deparses function name from given function oid.

‎contrib/postgres_fdw/expected/postgres_fdw.out

Lines changed: 251 additions & 369 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp