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

Commit2729986

Browse files
committed
refactoring & code cleansing, reformat pg_pathman.c
1 parent1c1ffaf commit2729986

File tree

6 files changed

+866
-897
lines changed

6 files changed

+866
-897
lines changed

‎src/hooks.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include"hooks.h"
1616
#include"init.h"
1717
#include"partition_filter.h"
18+
#include"pathman_workers.h"
1819
#include"planner_tree_modification.h"
1920
#include"runtimeappend.h"
2021
#include"runtime_merge_append.h"
@@ -591,7 +592,7 @@ pathman_shmem_startup_hook(void)
591592

592593
/* Allocate shared memory objects */
593594
LWLockAcquire(AddinShmemInitLock,LW_EXCLUSIVE);
594-
init_shmem_config();
595+
init_concurrent_part_task_slots();
595596
LWLockRelease(AddinShmemInitLock);
596597
}
597598

‎src/include/init.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,15 @@ extern PathmanInitState pg_pathman_init_state;
9494
#defineDEFAULT_INIT_CALLBACKInvalidOid
9595
#defineDEFAULT_SPAWN_USING_BGWfalse
9696

97+
/* Other default values (for GUCs etc) */
98+
#defineDEFAULT_PATHMAN_ENABLEtrue
99+
#defineDEFAULT_OVERRIDE_COPYtrue
100+
97101

98102
/* Lowest version of Pl/PgSQL frontend compatible with internals (0xAA_BB_CC) */
99103
#defineLOWEST_COMPATIBLE_FRONT0x010300
100104

101-
/* Current versionon native C library (0xAA_BB_CC) */
105+
/* Current versionof native C library (0xAA_BB_CC) */
102106
#defineCURRENT_LIB_VERSION0x010300
103107

104108

@@ -118,9 +122,10 @@ void restore_pathman_init_state(const PathmanInitState *temp_init_state);
118122
*/
119123
voidinit_main_pathman_toggles(void);
120124

125+
/*
126+
* Shared & local config.
127+
*/
121128
Sizeestimate_pathman_shmem_size(void);
122-
voidinit_shmem_config(void);
123-
124129
boolload_config(void);
125130
voidunload_config(void);
126131

‎src/include/pathman.h

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -88,49 +88,15 @@ extern Oidpathman_config_params_relid;
8888
Oidget_pathman_config_relid(boolinvalid_is_ok);
8989
Oidget_pathman_config_params_relid(boolinvalid_is_ok);
9090

91-
/*
92-
* pg_pathman's global state structure.
93-
*/
94-
typedefstructPathmanState
95-
{
96-
LWLock*dsm_init_lock;/* unused */
97-
}PathmanState;
98-
99-
100-
/*
101-
* Result of search_range_partition_eq().
102-
*/
103-
typedefenum
104-
{
105-
SEARCH_RANGEREL_OUT_OF_RANGE=0,
106-
SEARCH_RANGEREL_GAP,
107-
SEARCH_RANGEREL_FOUND
108-
}search_rangerel_result;
109-
110-
111-
/*
112-
* pg_pathman's global state.
113-
*/
114-
externPathmanState*pmstate;
115-
116-
117-
intappend_child_relation(PlannerInfo*root,Relationparent_relation,
118-
Indexparent_rti,intir_index,Oidchild_oid,
119-
List*wrappers);
120-
121-
search_rangerel_resultsearch_range_partition_eq(constDatumvalue,
122-
FmgrInfo*cmp_func,
123-
constPartRelationInfo*prel,
124-
RangeEntry*out_re);
12591

126-
uint32hash_to_part_index(uint32value,uint32partitions);
127-
128-
/* copied from allpaths.h */
129-
voidset_append_rel_size(PlannerInfo*root,RelOptInfo*rel,
130-
Indexrti,RangeTblEntry*rte);
13192
voidset_append_rel_pathlist(PlannerInfo*root,RelOptInfo*rel,Indexrti,
13293
PathKey*pathkeyAsc,PathKey*pathkeyDesc);
13394

95+
Indexappend_child_relation(PlannerInfo*root,Relationparent_relation,
96+
Indexparent_rti,intir_index,Oidchild_oid,
97+
List*wrappers);
98+
99+
134100
typedefstruct
135101
{
136102
constNode*orig;/* examined expression */
@@ -148,9 +114,7 @@ typedef struct
148114
boolfor_insert;/* are we in PartitionFilter now? */
149115
}WalkerContext;
150116

151-
/*
152-
* Usual initialization procedure for WalkerContext.
153-
*/
117+
/* Usual initialization procedure for WalkerContext */
154118
#defineInitWalkerContext(context,prel_vno,prel_info,ecxt,for_ins) \
155119
do { \
156120
(context)->prel_varno = (prel_vno); \
@@ -162,15 +126,37 @@ typedef struct
162126
/* Check that WalkerContext contains ExprContext (plan execution stage) */
163127
#defineWcxtHasExprContext(wcxt) ( (wcxt)->econtext )
164128

129+
/* Examine expression in order to select partitions */
130+
WrapperNode*walk_expr_tree(Expr*expr,WalkerContext*context);
131+
132+
165133
voidselect_range_partitions(constDatumvalue,
166134
FmgrInfo*cmp_func,
167135
constRangeEntry*ranges,
168136
constintnranges,
169137
constintstrategy,
170138
WrapperNode*result);
171139

172-
/* Examine expression in order to select partitions. */
173-
WrapperNode*walk_expr_tree(Expr*expr,WalkerContext*context);
140+
/* Result of search_range_partition_eq() */
141+
typedefenum
142+
{
143+
SEARCH_RANGEREL_OUT_OF_RANGE=0,
144+
SEARCH_RANGEREL_GAP,
145+
SEARCH_RANGEREL_FOUND
146+
}search_rangerel_result;
147+
148+
search_rangerel_resultsearch_range_partition_eq(constDatumvalue,
149+
FmgrInfo*cmp_func,
150+
constPartRelationInfo*prel,
151+
RangeEntry*out_re);
152+
153+
154+
/* Convert hash value to the partition index */
155+
staticinlineuint32
156+
hash_to_part_index(uint32value,uint32partitions)
157+
{
158+
returnvalue %partitions;
159+
}
174160

175161

176162
/*

‎src/include/utils.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ void extract_op_func_and_ret_type(char *opname,
5151
Oid*op_func,
5252
Oid*op_ret_type);
5353

54-
5554
/*
5655
* Print values and cast types.
5756
*/

‎src/init.c

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ init_main_pathman_toggles(void)
163163
"Enables pg_pathman's optimizations during the planner stage",
164164
NULL,
165165
&pg_pathman_init_state.pg_pathman_enable,
166-
true,
166+
DEFAULT_PATHMAN_ENABLE,
167167
PGC_SUSET,
168168
0,
169169
NULL,
@@ -187,7 +187,7 @@ init_main_pathman_toggles(void)
187187
"Override COPY statement handling",
188188
NULL,
189189
&pg_pathman_init_state.override_copy,
190-
true,
190+
DEFAULT_OVERRIDE_COPY,
191191
PGC_SUSET,
192192
0,
193193
NULL,
@@ -259,8 +259,7 @@ unload_config(void)
259259
Size
260260
estimate_pathman_shmem_size(void)
261261
{
262-
returnestimate_concurrent_part_task_slots_size()+
263-
MAXALIGN(sizeof(PathmanState));
262+
returnestimate_concurrent_part_task_slots_size();
264263
}
265264

266265
/*
@@ -358,33 +357,6 @@ fini_local_cache(void)
358357
parent_cache=NULL;
359358
}
360359

361-
/*
362-
* Initializes pg_pathman's global state (PathmanState) & locks.
363-
*/
364-
void
365-
init_shmem_config(void)
366-
{
367-
boolfound;
368-
369-
/* Check if module was initialized in postmaster */
370-
pmstate=ShmemInitStruct("pg_pathman's global state",
371-
sizeof(PathmanState),&found);
372-
if (!found)
373-
{
374-
/*
375-
* Initialize locks in postmaster
376-
*/
377-
if (!IsUnderPostmaster)
378-
{
379-
/* NOTE: dsm_array is redundant, hence the commented code */
380-
/* pmstate->dsm_init_lock = LWLockAssign(); */
381-
}
382-
}
383-
384-
/* Allocate some space for concurrent part slots */
385-
init_concurrent_part_task_slots();
386-
}
387-
388360
/*
389361
* Fill PartRelationInfo with partition-related info.
390362
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp