Skip to content

Commit 26d3945

Browse files
committed
pathman: handle DELETE and UPDATE queries
1 parent 1285042 commit 26d3945

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

contrib/pg_pathman/pathman.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ List *irange_list_union(List *a, List *b);
149149
List *irange_list_intersect(List *a, List *b);
150150
int irange_list_length(List *rangeset);
151151
bool irange_list_find(List *rangeset, int index, bool *lossy);
152+
void print_irange(IndexRange ir);
152153

153154
/* Dynamic shared memory functions */
154155
void init_dsm_config(void);

contrib/pg_pathman/pg_pathman.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ static void pathman_set_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, In
6666
static PlannedStmt * pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams);
6767

6868
/* Utility functions */
69+
static void handle_modification_query(Query *parse);
6970
static void append_child_relation(PlannerInfo *root, RelOptInfo *rel, Index rti,
7071
RangeTblEntry *rte, int index, Oid childOID, List *wrappers);
7172
static Node *wrapper_make_expression(WrapperNode *wrap, int index, bool *alwaysTrue);
@@ -89,7 +90,6 @@ static void set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, Index rt
8990
static List *accumulate_append_subpath(List *subpaths, Path *path);
9091
static void set_pathkeys(PlannerInfo *root, RelOptInfo *childrel, Path *path);
9192

92-
static void handle_delete_query(Query *parse);
9393

9494
/*
9595
* Compare two Datums with the given comarison function
@@ -204,8 +204,9 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
204204
case CMD_SELECT:
205205
disable_inheritance(parse);
206206
break;
207+
case CMD_UPDATE:
207208
case CMD_DELETE:
208-
handle_delete_query(parse);
209+
handle_modification_query(parse);
209210
break;
210211
default:
211212
break;
@@ -269,7 +270,7 @@ disable_inheritance(Query *parse)
269270
* Checks if query is affects only one partition. If true then substitute
270271
*/
271272
static void
272-
handle_delete_query(Query *parse)
273+
handle_modification_query(Query *parse)
273274
{
274275
PartRelationInfo *prel;
275276
List *ranges,
@@ -298,7 +299,7 @@ handle_delete_query(Query *parse)
298299
// }
299300

300301
/* If only one partition is affected then substitute parent table with partition */
301-
if (irange_list_length(ranges))
302+
if (irange_list_length(ranges) == 1)
302303
{
303304
IndexRange irange = (IndexRange) linitial_oid(ranges);
304305
elog(WARNING, "lower: %d, upper: %d, lossy: %d", irange_lower(irange), irange_upper(irange), irange_is_lossy(irange));

contrib/pg_pathman/rangeset.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ print_irange(List *l)
6565
}
6666
#endif
6767

68+
void
69+
print_irange(IndexRange ir)
70+
{
71+
elog(WARNING, "[%d, %d], lossy: %d", irange_lower(ir), irange_upper(ir), irange_is_lossy(ir));
72+
}
73+
6874
/*
6975
* Make union of two index rage lists.
7076
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy