-
Notifications
You must be signed in to change notification settings - Fork 68
Adapt pg_pathman for PG 11. #166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## next #166 +/- ##
==========================================
- Coverage 90.07% 90.04% -0.03%
==========================================
Files 40 40
Lines 6460 6462 +2
==========================================
Hits 5819 5819
- Misses 641 643 +2
Continue to review full report at Codecov.
|
src/compat/pg_compat.c
Outdated
@@ -48,7 +48,12 @@ create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel) | |||
{ | |||
int parallel_workers; | |||
|
|||
#if PG_VERSION_NUM >= 110000 | |||
parallel_workers = compute_parallel_worker(rel, rel->pages, -1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you extract this one as compute_parallel_worker
macro, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/hooks.c
Outdated
generate_gather_paths(root, rel); | ||
/* consider gathering partial paths for the parent appendrel */ | ||
#if PG_VERSION_NUM >= 110000 | ||
generate_gather_paths(root, rel, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And also this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/init.c
Outdated
@@ -25,7 +25,9 @@ | |||
#include "catalog/indexing.h" | |||
#include "catalog/pg_extension.h" | |||
#include "catalog/pg_inherits.h" | |||
#if PG_VERSION_NUM < 110000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bikeshedding: usually, I place conditional includes at the bottom.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/hooks.c
Outdated
@@ -514,13 +514,20 @@ pathman_rel_pathlist_hook(PlannerInfo *root, | |||
rel->partial_pathlist = NIL; | |||
#endif | |||
|
|||
/* Convert list to array for faster lookups */ | |||
#if PG_VERSION_NUM >= 110000 | |||
setup_append_rel_array(root); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this is ok? We might add new AppendRelInfos
each time pathman_rel_pathlist_hook
is called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is not good. Fixed.
@@ -411,7 +414,7 @@ build_pathman_relation_info(Oid relid, Datum *values) | |||
|
|||
/* Create a new memory context to store expression tree etc */ | |||
prel_mcxt = AllocSetContextCreate(PathmanParentsCacheContext, | |||
__FUNCTION__, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because since 9fa6f00b1308dd10da4eca2f31ccbfc7b35bb461 AllocSetContextCreate
ensures that this arg is __builtin_constant_p
, and __FUNCTION__
stores func name in global buffer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks!
@@ -29,7 +29,7 @@ | |||
|
|||
|
|||
#define ERR_PART_ATTR_NULL "partitioning expression's value should not be NULL" | |||
#define ERR_PART_ATTR_MULTIPLE_RESULTS "partitioning expression should return single value" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one looks odd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See below changes in pg_compat.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvm.
src/nodes_common.c
Outdated
RelOptInfo *child_rel = ((Path *) lfirst(lc1))->parent; | ||
RelOptInfo *child_rel = ((Path *) lfirst(lc1))->parent; | ||
#if PG_VERSION_NUM >= 110000 | ||
AppendRelInfo *appinfo = root->append_rel_array[child_rel->relid]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: this is closely related to setup_append_rel_array
.
UPD: maybe we should reconsider each usage of root->append_rel_list
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, except for access in nodes_common.c all others are just iterations over the whole list, so not sure we need to change something here.
src/pathman_workers.c
Outdated
@@ -483,7 +483,7 @@ bgw_main_concurrent_part(Datum main_arg) | |||
|
|||
Oid types[2] = { OIDOID, INT4OID }; | |||
Datum vals[2] = { part_slot->relid, part_slot->batch_size }; | |||
bool nulls[2] = { false, false }; | |||
char nulls[2] = { false, false }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, but this is also wrong. SPI requires nulls to be equal to 'n'
. I guess we should get rid of nulls
array and just pass NULL
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, fixed.
@@ -651,7 +651,7 @@ def test_conc_part_drop_runtime_append(self): | |||
|
|||
# Thread for connection #2 (it has to wait) | |||
def con2_thread(): | |||
con1.begin() | |||
con2.begin() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one.
static inline void mult_result_handler() { elog(ERROR, ERR_PART_ATTR_MULTIPLE_RESULTS); } | ||
static inline void mult_result_handler() | ||
{ | ||
elog(ERROR, "partitioning expression should return single value"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess ERR_PART_ATTR_MULTIPLE_RESULTS
is useless now, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. As commit message says, inclusion of partition_filter.h created dependency hell here.
BEGIN | ||
SELECT create_range_partitions('permissions.user1_table', 'id', 1, 10, 2); | ||
EXCEPTION | ||
WHEN insufficient_privilege THEN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we raise a notice in case of insufficient_privilege
? Otherwise we won't know if this call failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, if it is indeed insufficient_privilige
, then that's what we are after here, so silently eating it is fine. Actually, an attempt to hide the error is the only reason for this change -- one word changed in the error message from relation
to table
in 10 and 11 PG. If this is any other exception, it will fall through shouting along the way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(We still can add some unifying NOTICE in exception handler or just a comment explaining this, if you like)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
src/relation_info.c
Outdated
@@ -45,7 +48,7 @@ | |||
#include "optimizer/planmain.h" | |||
#endif | |||
|
|||
#if PG_VERSION_NUM >= 90600 | |||
#if PG_VERSION_NUM >= 90600 && PG_VERSION_NUM < 11000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should replace 11000
with 110000
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
I kinda lost interest to exorcise a couple of tests further in attempts to make them pass on all supported versions and just added copies. These are * pathman_expressions now differs because planner converts ROW(Const, Const) to just Const of record type. * Same with pathman_rebuild_updates. I have removed inclusion of partition_filter.h in pg_compat.h in 9.5 as it created circular dependency hell. I think it is not worthwhile to fight with it since the only thing actually needed was error message, which is used in this single place. Small typo fix in partitioning_test.py: con2.begin instead of con1.begin. Finally, run python tests with --failfast and --verbose options.
Also a bunch of other stuff noted by @funbringer.
Merged, thanks a lot! |
I kinda lost interest to exorcise a couple of tests further in attempts to make
them pass on all supported versions and just added copies. These are
just Const of record type.
I have removed inclusion of partition_filter.h in pg_compat.h in 9.5 as it
created circular dependency hell. I think it is not worthwhile to fight with it
since the only thing actually needed was error message, which is used in this
single place.
Small typo fix in partitioning_test.py: con2.begin instead of con1.begin.
Finally, run python tests with --failfast and --verbose options.