mirror of
https://github.com/HypoPG/hypopg
synced 2026-05-24 09:38:21 +00:00
Add infrastructure to inject hypothetical partitioning
This commit is contained in:
parent
c44e6ff773
commit
01aa5accc8
3 changed files with 1410 additions and 12 deletions
49
hypopg.c
49
hypopg.c
|
|
@ -20,6 +20,7 @@
|
|||
#include "include/hypopg.h"
|
||||
#include "include/hypopg_import.h"
|
||||
#include "include/hypopg_index.h"
|
||||
#include "include/hypopg_table.h"
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
|
|
@ -71,6 +72,12 @@ static void hypo_get_relation_info_hook(PlannerInfo *root,
|
|||
RelOptInfo *rel);
|
||||
static get_relation_info_hook_type prev_get_relation_info_hook = NULL;
|
||||
|
||||
static void hypo_set_rel_pathlist_hook(PlannerInfo *root,
|
||||
RelOptInfo *rel,
|
||||
Index rti,
|
||||
RangeTblEntry *rte);
|
||||
static set_rel_pathlist_hook_type prev_set_rel_pathlist_hook = NULL;
|
||||
|
||||
static bool hypo_query_walker(Node *node);
|
||||
|
||||
void
|
||||
|
|
@ -89,6 +96,9 @@ _PG_init(void)
|
|||
prev_explain_get_index_name_hook = explain_get_index_name_hook;
|
||||
explain_get_index_name_hook = hypo_explain_get_index_name_hook;
|
||||
|
||||
prev_set_rel_pathlist_hook = set_rel_pathlist_hook;
|
||||
set_rel_pathlist_hook = hypo_set_rel_pathlist_hook;
|
||||
|
||||
isExplain = false;
|
||||
hypoIndexes = NIL;
|
||||
|
||||
|
|
@ -124,7 +134,7 @@ _PG_fini(void)
|
|||
ExecutorEnd_hook = prev_ExecutorEnd_hook;
|
||||
get_relation_info_hook = prev_get_relation_info_hook;
|
||||
explain_get_index_name_hook = prev_explain_get_index_name_hook;
|
||||
|
||||
set_rel_pathlist_hook = prev_set_rel_pathlist_hook;
|
||||
}
|
||||
|
||||
/*---------------------------------
|
||||
|
|
@ -187,12 +197,12 @@ hypo_utility_hook(
|
|||
{
|
||||
isExplain = query_or_expression_tree_walker(
|
||||
#if PG_VERSION_NUM >= 100000
|
||||
(Node *) pstmt,
|
||||
(Node *) pstmt,
|
||||
#else
|
||||
parsetree,
|
||||
parsetree,
|
||||
#endif
|
||||
hypo_query_walker,
|
||||
NULL, 0);
|
||||
hypo_query_walker,
|
||||
NULL, 0);
|
||||
|
||||
if (prev_utility_hook)
|
||||
prev_utility_hook(
|
||||
|
|
@ -318,8 +328,8 @@ hypo_get_relation_info_hook(PlannerInfo *root,
|
|||
* hypothetical index found, add it to the relation's
|
||||
* indextlist
|
||||
*/
|
||||
hypo_injectHypotheticalIndex(root, relationObjectId,
|
||||
inhparent, rel, relation, entry);
|
||||
hypo_injectHypotheticalIndex(root, relationObjectId,
|
||||
inhparent, rel, relation, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -328,10 +338,35 @@ hypo_get_relation_info_hook(PlannerInfo *root,
|
|||
heap_close(relation, AccessShareLock);
|
||||
}
|
||||
|
||||
|
||||
hypo_createHypotheticalTable(root, relationObjectId, rel);
|
||||
|
||||
|
||||
if (prev_get_relation_info_hook)
|
||||
prev_get_relation_info_hook(root, relationObjectId, inhparent, rel);
|
||||
}
|
||||
|
||||
/*
|
||||
* if this child relation is excluded by constraints, call set_dummy_rel_pathlist
|
||||
*/
|
||||
static void
|
||||
hypo_set_rel_pathlist_hook(PlannerInfo *root,
|
||||
RelOptInfo *rel,
|
||||
Index rti,
|
||||
RangeTblEntry *rte)
|
||||
{
|
||||
if(isExplain && hypo_is_enabled)
|
||||
{
|
||||
|
||||
hypo_setHypotheticalDummyrel(root,rel,rti,rte);
|
||||
|
||||
}
|
||||
|
||||
if (prev_set_rel_pathlist_hook)
|
||||
prev_set_rel_pathlist_hook(root, rel, rti, rte);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Reset statistics.
|
||||
*/
|
||||
|
|
|
|||
1366
hypopg_table.c
1366
hypopg_table.c
File diff suppressed because it is too large
Load diff
|
|
@ -21,6 +21,7 @@
|
|||
#define HYPO_TABLE_NB_COLS 5 /* # of column hypopg_table() returns */
|
||||
#define HYPO_ADD_PART_COLS 2 /* # of column hypopg_add_partition() returns */
|
||||
|
||||
#include "optimizer/paths.h"
|
||||
|
||||
/*--- Structs --- */
|
||||
|
||||
|
|
@ -66,4 +67,10 @@ Datum hypopg_drop_table(PG_FUNCTION_ARGS);
|
|||
Datum hypopg_partition_table(PG_FUNCTION_ARGS);
|
||||
Datum hypopg_reset_table(PG_FUNCTION_ARGS);
|
||||
|
||||
void hypo_createHypotheticalTable(PlannerInfo *root,
|
||||
Oid relationObjectId,
|
||||
RelOptInfo *rel);
|
||||
void hypo_setHypotheticalDummyrel(PlannerInfo *root, RelOptInfo *rel,
|
||||
Index rti, RangeTblEntry *rte);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue