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

Commitedbb359

Browse files
authored
Merge branch 'postgres:master' into master
2 parentscb31df4 +44ce4e1 commitedbb359

File tree

8 files changed

+189
-29
lines changed

8 files changed

+189
-29
lines changed

‎doc/src/sgml/release-18.sgml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<formalpara>
88
<title>Release date:</title>
9-
<para>2025-??-??, CURRENT AS OF 2025-05-01</para>
9+
<para>2025-??-??, CURRENT AS OF 2025-05-23</para>
1010
</formalpara>
1111

1212
<sect2 id="release-18-highlights">
@@ -469,8 +469,8 @@ Allow skip scans of btree indexes (Peter Geoghegan)
469469
</para>
470470

471471
<para>
472-
This allowsmuti-column btree indexes to be used by queries that only
473-
reference the second or later indexed columns.
472+
This allowsmulti-column btree indexes to be used by queries that only
473+
equality-reference the second or later indexed columns.
474474
</para>
475475
</listitem>
476476

@@ -1212,12 +1212,15 @@ This is useful for operating system configuration.
12121212
<!--
12131213
Author: Peter Eisentraut <peter@eisentraut.org>
12141214
2025-03-19 [4f7f7b037] extension_control_path
1215+
Author: Peter Eisentraut <peter@eisentraut.org>
1216+
2025-05-02 [81eaaa2c4] Make "directory" setting work with extension_control_pat
12151217
-->
12161218

12171219
<listitem>
12181220
<para>
12191221
Add server variable extension_control_path to specify the location of extension control files (Peter Eisentraut, Matheus Alcantara)
12201222
<ulink url="&commit_baseurl;4f7f7b037">&sect;</ulink>
1223+
<ulink url="&commit_baseurl;81eaaa2c4">&sect;</ulink>
12211224
</para>
12221225
</listitem>
12231226

@@ -2582,12 +2585,15 @@ Add pg_dump options --with-schema, --with-data, and --with-statistics (Jeff Davi
25822585
<!--
25832586
Author: Nathan Bossart <nathan@postgresql.org>
25842587
2025-03-25 [9c49f0e8c] pg_dump: Add - -sequence-data.
2588+
Author: Nathan Bossart <nathan@postgresql.org>
2589+
2025-05-07 [acea3fc49] pg_dumpall: Add - -sequence-data.
25852590
-->
25862591

25872592
<listitem>
25882593
<para>
2589-
Add pg_dump option --sequence-data to dump sequence data that would normally be excluded (Nathan Bossart)
2594+
Add pg_dumpand pg_dumpalloption --sequence-data to dump sequence data that would normally be excluded (Nathan Bossart)
25902595
<ulink url="&commit_baseurl;9c49f0e8c">&sect;</ulink>
2596+
<ulink url="&commit_baseurl;acea3fc49">&sect;</ulink>
25912597
</para>
25922598
</listitem>
25932599

@@ -2833,6 +2839,18 @@ Injection points can now be created, but not run, via INJECTION_POINT_LOAD(), an
28332839
</para>
28342840
</listitem>
28352841

2842+
<!--
2843+
Author: Michael Paquier <michael@paquier.xyz>
2844+
2025-05-10 [371f2db8b] Add support for runtime arguments in injection points
2845+
-->
2846+
2847+
<listitem>
2848+
<para>
2849+
Support runtime arguments in injection points (Michael Paquier)
2850+
<ulink url="&commit_baseurl;371f2db8b">&sect;</ulink>
2851+
</para>
2852+
</listitem>
2853+
28362854
<!--
28372855
Author: Heikki Linnakangas <heikki.linnakangas@iki.fi>
28382856
2024-07-26 [20e0e7da9] Add test for early backend startup errors

‎src/backend/postmaster/autovacuum.c

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,6 +2073,12 @@ do_autovacuum(void)
20732073
}
20742074
}
20752075
}
2076+
2077+
/* Release stuff to avoid per-relation leakage */
2078+
if (relopts)
2079+
pfree(relopts);
2080+
if (tabentry)
2081+
pfree(tabentry);
20762082
}
20772083

20782084
table_endscan(relScan);
@@ -2089,7 +2095,8 @@ do_autovacuum(void)
20892095
Form_pg_classclassForm= (Form_pg_class)GETSTRUCT(tuple);
20902096
PgStat_StatTabEntry*tabentry;
20912097
Oidrelid;
2092-
AutoVacOpts*relopts=NULL;
2098+
AutoVacOpts*relopts;
2099+
boolfree_relopts= false;
20932100
booldovacuum;
20942101
booldoanalyze;
20952102
boolwraparound;
@@ -2107,7 +2114,9 @@ do_autovacuum(void)
21072114
* main rel
21082115
*/
21092116
relopts=extract_autovac_opts(tuple,pg_class_desc);
2110-
if (relopts==NULL)
2117+
if (relopts)
2118+
free_relopts= true;
2119+
else
21112120
{
21122121
av_relation*hentry;
21132122
boolfound;
@@ -2128,6 +2137,12 @@ do_autovacuum(void)
21282137
/* ignore analyze for toast tables */
21292138
if (dovacuum)
21302139
table_oids=lappend_oid(table_oids,relid);
2140+
2141+
/* Release stuff to avoid leakage */
2142+
if (free_relopts)
2143+
pfree(relopts);
2144+
if (tabentry)
2145+
pfree(tabentry);
21312146
}
21322147

21332148
table_endscan(relScan);
@@ -2499,6 +2514,8 @@ do_autovacuum(void)
24992514
pg_atomic_test_set_flag(&MyWorkerInfo->wi_dobalance);
25002515
}
25012516

2517+
list_free(table_oids);
2518+
25022519
/*
25032520
* Perform additional work items, as requested by backends.
25042521
*/
@@ -2680,8 +2697,8 @@ perform_work_item(AutoVacuumWorkItem *workitem)
26802697
/*
26812698
* extract_autovac_opts
26822699
*
2683-
* Given a relation's pg_class tuple, returnthe AutoVacOpts portion of
2684-
* reloptions, if set; otherwise, return NULL.
2700+
* Given a relation's pg_class tuple, returna palloc'd copy of the
2701+
*AutoVacOpts portion ofreloptions, if set; otherwise, return NULL.
26852702
*
26862703
* Note: callers do not have a relation lock on the table at this point,
26872704
* so the table could have been dropped, and its catalog rows gone, after
@@ -2730,6 +2747,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
27302747
autovac_table*tab=NULL;
27312748
boolwraparound;
27322749
AutoVacOpts*avopts;
2750+
boolfree_avopts= false;
27332751

27342752
/* fetch the relation's relcache entry */
27352753
classTup=SearchSysCacheCopy1(RELOID,ObjectIdGetDatum(relid));
@@ -2742,8 +2760,10 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
27422760
* main table reloptions if the toast table itself doesn't have.
27432761
*/
27442762
avopts=extract_autovac_opts(classTup,pg_class_desc);
2745-
if (classForm->relkind==RELKIND_TOASTVALUE&&
2746-
avopts==NULL&&table_toast_map!=NULL)
2763+
if (avopts)
2764+
free_avopts= true;
2765+
elseif (classForm->relkind==RELKIND_TOASTVALUE&&
2766+
table_toast_map!=NULL)
27472767
{
27482768
av_relation*hentry;
27492769
boolfound;
@@ -2852,6 +2872,8 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
28522872
avopts->vacuum_cost_delay >=0));
28532873
}
28542874

2875+
if (free_avopts)
2876+
pfree(avopts);
28552877
heap_freetuple(classTup);
28562878
returntab;
28572879
}
@@ -2883,6 +2905,10 @@ recheck_relation_needs_vacanalyze(Oid relid,
28832905
effective_multixact_freeze_max_age,
28842906
dovacuum,doanalyze,wraparound);
28852907

2908+
/* Release tabentry to avoid leakage */
2909+
if (tabentry)
2910+
pfree(tabentry);
2911+
28862912
/* ignore ANALYZE for toast tables */
28872913
if (classForm->relkind==RELKIND_TOASTVALUE)
28882914
*doanalyze= false;
@@ -3140,18 +3166,22 @@ autovacuum_do_vac_analyze(autovac_table *tab, BufferAccessStrategy bstrategy)
31403166
VacuumRelation*rel;
31413167
List*rel_list;
31423168
MemoryContextvac_context;
3169+
MemoryContextold_context;
31433170

31443171
/* Let pgstat know what we're doing */
31453172
autovac_report_activity(tab);
31463173

3174+
/* Create a context that vacuum() can use as cross-transaction storage */
3175+
vac_context=AllocSetContextCreate(CurrentMemoryContext,
3176+
"Vacuum",
3177+
ALLOCSET_DEFAULT_SIZES);
3178+
31473179
/* Set up one VacuumRelation target, identified by OID, for vacuum() */
3180+
old_context=MemoryContextSwitchTo(vac_context);
31483181
rangevar=makeRangeVar(tab->at_nspname,tab->at_relname,-1);
31493182
rel=makeVacuumRelation(rangevar,tab->at_relid,NIL);
31503183
rel_list=list_make1(rel);
3151-
3152-
vac_context=AllocSetContextCreate(CurrentMemoryContext,
3153-
"Vacuum",
3154-
ALLOCSET_DEFAULT_SIZES);
3184+
MemoryContextSwitchTo(old_context);
31553185

31563186
vacuum(rel_list,&tab->at_params,bstrategy,vac_context, true);
31573187

‎src/backend/utils/mmgr/alignedalloc.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ AlignedAllocFree(void *pointer)
4545
GetMemoryChunkContext(unaligned)->name,chunk);
4646
#endif
4747

48+
/* Recursively pfree the unaligned chunk */
4849
pfree(unaligned);
4950
}
5051

@@ -96,18 +97,32 @@ AlignedAllocRealloc(void *pointer, Size size, int flags)
9697
Assert(old_size >=redirchunk->requested_size);
9798
#endif
9899

100+
/*
101+
* To keep things simple, we always allocate a new aligned chunk and copy
102+
* data into it. Because of the above inaccuracy, this may end in copying
103+
* more data than was in the original allocation request size, but that
104+
* should be OK.
105+
*/
99106
ctx=GetMemoryChunkContext(unaligned);
100107
newptr=MemoryContextAllocAligned(ctx,size,alignto,flags);
101108

102-
/*
103-
* We may memcpy beyond the end of the original allocation request size,
104-
* so we must mark the entire allocation as defined.
105-
*/
106-
if (likely(newptr!=NULL))
109+
/* Cope cleanly with OOM */
110+
if (unlikely(newptr==NULL))
107111
{
108-
VALGRIND_MAKE_MEM_DEFINED(pointer,old_size);
109-
memcpy(newptr,pointer,Min(size,old_size));
112+
VALGRIND_MAKE_MEM_NOACCESS(redirchunk,sizeof(MemoryChunk));
113+
returnMemoryContextAllocationFailure(ctx,size,flags);
110114
}
115+
116+
/*
117+
* We may memcpy more than the original allocation request size, which
118+
* would result in trying to copy trailing bytes that the original
119+
* MemoryContextAllocAligned call marked NOACCESS. So we must mark the
120+
* entire old_size as defined. That's slightly annoying, but probably not
121+
* worth improving.
122+
*/
123+
VALGRIND_MAKE_MEM_DEFINED(pointer,old_size);
124+
memcpy(newptr,pointer,Min(size,old_size));
125+
111126
pfree(unaligned);
112127

113128
returnnewptr;

‎src/interfaces/libpq-oauth/oauth-curl.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@
8282
*/
8383
#defineMAX_OAUTH_RESPONSE_SIZE (256 * 1024)
8484

85+
/*
86+
* Similarly, a limit on the maximum JSON nesting level keeps a server from
87+
* running us out of stack space. A common nesting level in practice is 2 (for a
88+
* top-level object containing arrays of strings). As of May 2025, the maximum
89+
* depth for standard server metadata appears to be 6, if the document contains
90+
* a full JSON Web Key Set in its "jwks" parameter.
91+
*
92+
* Since it's easy to nest JSON, and the number of parameters and key types
93+
* keeps growing, take a healthy buffer of 16. (If this ever proves to be a
94+
* problem in practice, we may want to switch over to the incremental JSON
95+
* parser instead of playing with this parameter.)
96+
*/
97+
#defineMAX_OAUTH_NESTING_LEVEL 16
98+
8599
/*
86100
* Parsed JSON Representations
87101
*
@@ -495,6 +509,12 @@ oauth_json_object_start(void *state)
495509
}
496510

497511
++ctx->nested;
512+
if (ctx->nested>MAX_OAUTH_NESTING_LEVEL)
513+
{
514+
oauth_parse_set_error(ctx,"JSON is too deeply nested");
515+
returnJSON_SEM_ACTION_FAILED;
516+
}
517+
498518
returnJSON_SUCCESS;
499519
}
500520

@@ -599,6 +619,12 @@ oauth_json_array_start(void *state)
599619
}
600620

601621
++ctx->nested;
622+
if (ctx->nested>MAX_OAUTH_NESTING_LEVEL)
623+
{
624+
oauth_parse_set_error(ctx,"JSON is too deeply nested");
625+
returnJSON_SEM_ACTION_FAILED;
626+
}
627+
602628
returnJSON_SUCCESS;
603629
}
604630

‎src/interfaces/libpq/Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,21 @@ SHLIB_PREREQS = submake-libpgport
9898

9999
SHLIB_EXPORTS = exports.txt
100100

101+
# Appends to a comma-separated list.
102+
comma := ,
103+
defineadd_to_list
104+
$(eval $1 :=$(if$($1),$($1)$(comma) $2,$2))
105+
endef
106+
101107
ifeq ($(with_ssl),openssl)
102-
PKG_CONFIG_REQUIRES_PRIVATE = libssl, libcrypto
108+
$(call add_to_list,PKG_CONFIG_REQUIRES_PRIVATE,libssl)
109+
$(call add_to_list,PKG_CONFIG_REQUIRES_PRIVATE,libcrypto)
103110
endif
104111

105112
ifeq ($(with_libcurl),yes)
106113
# libpq.so doesn't link against libcurl, but libpq.a needs libpq-oauth, and
107114
# libpq-oauth needs libcurl. Put both into *.private.
108-
PKG_CONFIG_REQUIRES_PRIVATE +=libcurl
115+
$(call add_to_list,PKG_CONFIG_REQUIRES_PRIVATE,libcurl)
109116
%.pc: override SHLIB_LINK_INTERNAL += -lpq-oauth
110117
endif
111118

‎src/interfaces/libpq/fe-auth-oauth.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,14 @@ client_initial_response(PGconn *conn, bool discover)
157157
#defineERROR_SCOPE_FIELD "scope"
158158
#defineERROR_OPENID_CONFIGURATION_FIELD "openid-configuration"
159159

160+
/*
161+
* Limit the maximum number of nested objects/arrays. Because OAUTHBEARER
162+
* doesn't have any defined extensions for its JSON yet, we can be much more
163+
* conservative here than with libpq-oauth's MAX_OAUTH_NESTING_LEVEL; we expect
164+
* a nesting level of 1 in practice.
165+
*/
166+
#defineMAX_SASL_NESTING_LEVEL 8
167+
160168
structjson_ctx
161169
{
162170
char*errmsg;/* any non-NULL value stops all processing */
@@ -196,6 +204,9 @@ oauth_json_object_start(void *state)
196204
}
197205

198206
++ctx->nested;
207+
if (ctx->nested>MAX_SASL_NESTING_LEVEL)
208+
oauth_json_set_error(ctx,libpq_gettext("JSON is too deeply nested"));
209+
199210
returnoauth_json_has_error(ctx) ?JSON_SEM_ACTION_FAILED :JSON_SUCCESS;
200211
}
201212

@@ -254,9 +265,22 @@ oauth_json_array_start(void *state)
254265
ctx->target_field_name);
255266
}
256267

268+
++ctx->nested;
269+
if (ctx->nested>MAX_SASL_NESTING_LEVEL)
270+
oauth_json_set_error(ctx,libpq_gettext("JSON is too deeply nested"));
271+
257272
returnoauth_json_has_error(ctx) ?JSON_SEM_ACTION_FAILED :JSON_SUCCESS;
258273
}
259274

275+
staticJsonParseErrorType
276+
oauth_json_array_end(void*state)
277+
{
278+
structjson_ctx*ctx=state;
279+
280+
--ctx->nested;
281+
returnJSON_SUCCESS;
282+
}
283+
260284
staticJsonParseErrorType
261285
oauth_json_scalar(void*state,char*token,JsonTokenTypetype)
262286
{
@@ -519,6 +543,7 @@ handle_oauth_sasl_error(PGconn *conn, const char *msg, int msglen)
519543
sem.object_end=oauth_json_object_end;
520544
sem.object_field_start=oauth_json_object_field_start;
521545
sem.array_start=oauth_json_array_start;
546+
sem.array_end=oauth_json_array_end;
522547
sem.scalar=oauth_json_scalar;
523548

524549
err=pg_parse_json(lex,&sem);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp