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

Commitc103ecc

Browse files
committed
restore compatibility with PostgreSQL 9.5
1 parentf85232a commitc103ecc

File tree

6 files changed

+73
-46
lines changed

6 files changed

+73
-46
lines changed

‎src/compat/pg_compat.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,45 @@ create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
268268
add_partial_path(rel,create_seqscan_path(root,rel,NULL,parallel_workers));
269269
}
270270

271+
/*
272+
* Examine contents of MemoryContext.
273+
*/
274+
void
275+
McxtStatsInternal(MemoryContextcontext,intlevel,
276+
boolexamine_children,
277+
MemoryContextCounters*totals)
278+
{
279+
MemoryContextCounterslocal_totals;
280+
MemoryContextchild;
281+
282+
AssertArg(MemoryContextIsValid(context));
283+
284+
/* Examine the context itself */
285+
(*context->methods->stats) (context,level, false,totals);
286+
287+
memset(&local_totals,0,sizeof(local_totals));
288+
289+
if (!examine_children)
290+
return;
291+
292+
/* Examine children */
293+
for (child=context->firstchild;
294+
child!=NULL;
295+
child=child->nextchild)
296+
{
297+
298+
McxtStatsInternal(child,level+1,
299+
examine_children,
300+
&local_totals);
301+
}
302+
303+
/* Save children stats */
304+
totals->nblocks+=local_totals.nblocks;
305+
totals->freechunks+=local_totals.freechunks;
306+
totals->totalspace+=local_totals.totalspace;
307+
totals->freespace+=local_totals.freespace;
308+
}
309+
271310

272311
#else/* PG_VERSION_NUM >= 90500 */
273312

‎src/include/compat/pg_compat.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ extern Result *make_result(List *tlist,
7878
make_result((tlist), (resconstantqual), (subplan))
7979

8080

81+
/* McxtStatsInternal() */
82+
voidMcxtStatsInternal(MemoryContextcontext,intlevel,
83+
boolexamine_children,
84+
MemoryContextCounters*totals);
85+
86+
8187
/* pull_var_clause() */
8288
#definepull_var_clause_compat(node,aggbehavior,phbehavior) \
8389
pull_var_clause((node), (aggbehavior) | (phbehavior))
@@ -93,6 +99,9 @@ extern void set_rel_consider_parallel(PlannerInfo *root,
9399

94100
#else/* PG_VERSION_NUM >= 90500 */
95101

102+
#defineALLOCSET_DEFAULT_SIZES \
103+
ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE
104+
96105
/* adjust_appendrel_attrs() */
97106
#defineadjust_rel_targetlist_compat(root,dst_rel,src_rel,appinfo) \
98107
do { \

‎src/include/utils.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ bool check_security_policy_internal(Oid relid, Oid role);
3434
*/
3535
Oidget_pathman_schema(void);
3636
List*list_reverse(List*l);
37-
voidMcxtStatsInternal(MemoryContextcontext,intlevel,
38-
boolexamine_children,
39-
MemoryContextCounters*totals);
4037

4138
/*
4239
* Useful functions for relations.

‎src/init.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
#include"utils/typcache.h"
3939

4040

41+
/* Define ALLOCSET_DEFAULT_SIZES for our precious MemoryContexts */
42+
#ifPG_VERSION_NUM<90600
43+
#defineALLOCSET_DEFAULT_SIZES \
44+
ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE
45+
#endif
46+
4147
/* Initial size of 'partitioned_rels' table */
4248
#definePART_RELS_SIZE10
4349
#defineCHILD_FACTOR500

‎src/pl_funcs.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,32 +332,45 @@ show_cache_stats_internal(PG_FUNCTION_ARGS)
332332
{
333333
HTAB*current_htab;
334334
MemoryContextcurrent_mcxt;
335-
MemoryContextCountersmcxt_stats;
336335
HeapTuplehtup;
337336
Datumvalues[Natts_pathman_cache_stats];
338337
boolisnull[Natts_pathman_cache_stats]= {0 };
339338

340-
/* Prepare context counters */
341-
memset(&mcxt_stats,0,sizeof(mcxt_stats));
339+
#ifPG_VERSION_NUM >=90600
340+
MemoryContextCountersmcxt_stats;
341+
#endif
342342

343343
/* Select current memory context and hash table (cache) */
344344
current_mcxt=usercxt->pathman_contexts[usercxt->current_item];
345345
current_htab=usercxt->pathman_htables[usercxt->current_item];
346346

347+
values[Anum_pathman_cs_context-1]=
348+
CStringGetTextDatum(simpify_mcxt_name(current_mcxt));
349+
350+
/* We can't check stats of mcxt prior to 9.6 */
351+
#ifPG_VERSION_NUM >=90600
352+
353+
/* Prepare context counters */
354+
memset(&mcxt_stats,0,sizeof(mcxt_stats));
355+
347356
/* NOTE: we do not consider child contexts if it's TopPathmanContext */
348357
McxtStatsInternal(current_mcxt,0,
349358
(current_mcxt!=TopPathmanContext),
350359
&mcxt_stats);
351360

352-
values[Anum_pathman_cs_context-1]=
353-
CStringGetTextDatum(simpify_mcxt_name(current_mcxt));
354-
355361
values[Anum_pathman_cs_size-1]=
356362
Int64GetDatum(mcxt_stats.totalspace);
357363

358364
values[Anum_pathman_cs_used-1]=
359365
Int64GetDatum(mcxt_stats.totalspace-mcxt_stats.freespace);
360366

367+
#else
368+
369+
/* Set unsupported fields to NULL */
370+
isnull[Anum_pathman_cs_size-1]= true;
371+
isnull[Anum_pathman_cs_used-1]= true;
372+
#endif
373+
361374
values[Anum_pathman_cs_entries-1]=
362375
Int64GetDatum(current_htab ?hash_get_num_entries(current_htab) :0);
363376

‎src/utils.c

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -164,43 +164,6 @@ list_reverse(List *l)
164164
returnresult;
165165
}
166166

167-
void
168-
McxtStatsInternal(MemoryContextcontext,intlevel,
169-
boolexamine_children,
170-
MemoryContextCounters*totals)
171-
{
172-
MemoryContextCounterslocal_totals;
173-
MemoryContextchild;
174-
175-
AssertArg(MemoryContextIsValid(context));
176-
177-
/* Examine the context itself */
178-
(*context->methods->stats) (context,level, false,totals);
179-
180-
memset(&local_totals,0,sizeof(local_totals));
181-
182-
if (!examine_children)
183-
return;
184-
185-
/* Examine children */
186-
for (child=context->firstchild;
187-
child!=NULL;
188-
child=child->nextchild)
189-
{
190-
191-
McxtStatsInternal(child,level+1,
192-
examine_children,
193-
&local_totals);
194-
}
195-
196-
/* Save children stats */
197-
totals->nblocks+=local_totals.nblocks;
198-
totals->freechunks+=local_totals.freechunks;
199-
totals->totalspace+=local_totals.totalspace;
200-
totals->freespace+=local_totals.freespace;
201-
}
202-
203-
204167

205168
/*
206169
* Get relation owner.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp