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

Commit62ce0c7

Browse files
committed
Fix catalog data of pg_stop_backup(), labelled v2
This function has been incorrectly marked as a set-returning functionwith prorows (estimated number of rows) set to 1 since its creation in7117685, that introduced non-exclusive backups. There is no need forthat as the function is designed to return only one tuple.This commit fixes the catalog definition of pg_stop_backup_v2() so as itis not marked as proretset anymore, with prorows set to 0. Thissimplifies its internals by removing one tuplestore (used for one singlerecord anyway) and by removing all the checks related to a set-returningfunction.Issue found during my quest to simplify some of the logic used inin-core system functions.Bump catalog version.Reviewed-by: Aleksander Alekseev, Kyotaro HoriguchiDiscussion:https://postgr.es/m/Yh8guT78f1Ercfzw@paquier.xyz
1 parent50f0347 commit62ce0c7

File tree

4 files changed

+11
-35
lines changed

4 files changed

+11
-35
lines changed

‎src/backend/access/transam/xlogfuncs.c

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -165,43 +165,20 @@ pg_stop_backup(PG_FUNCTION_ARGS)
165165
Datum
166166
pg_stop_backup_v2(PG_FUNCTION_ARGS)
167167
{
168-
ReturnSetInfo*rsinfo= (ReturnSetInfo*)fcinfo->resultinfo;
168+
#definePG_STOP_BACKUP_V2_COLS 3
169169
TupleDesctupdesc;
170-
Tuplestorestate*tupstore;
171-
MemoryContextper_query_ctx;
172-
MemoryContextoldcontext;
173-
Datumvalues[3];
174-
boolnulls[3];
170+
Datumvalues[PG_STOP_BACKUP_V2_COLS];
171+
boolnulls[PG_STOP_BACKUP_V2_COLS];
175172

176173
boolexclusive=PG_GETARG_BOOL(0);
177174
boolwaitforarchive=PG_GETARG_BOOL(1);
178175
XLogRecPtrstoppoint;
179176
SessionBackupStatestatus=get_backup_status();
180177

181-
/* check to see if caller supports us returning a tuplestore */
182-
if (rsinfo==NULL|| !IsA(rsinfo,ReturnSetInfo))
183-
ereport(ERROR,
184-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
185-
errmsg("set-valued function called in context that cannot accept a set")));
186-
if (!(rsinfo->allowedModes&SFRM_Materialize))
187-
ereport(ERROR,
188-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
189-
errmsg("materialize mode required, but it is not allowed in this context")));
190-
191-
/* Build a tuple descriptor for our result type */
178+
/* Initialize attributes information in the tuple descriptor */
192179
if (get_call_result_type(fcinfo,NULL,&tupdesc)!=TYPEFUNC_COMPOSITE)
193180
elog(ERROR,"return type must be a row type");
194181

195-
per_query_ctx=rsinfo->econtext->ecxt_per_query_memory;
196-
oldcontext=MemoryContextSwitchTo(per_query_ctx);
197-
198-
tupstore=tuplestore_begin_heap(true, false,work_mem);
199-
rsinfo->returnMode=SFRM_Materialize;
200-
rsinfo->setResult=tupstore;
201-
rsinfo->setDesc=tupdesc;
202-
203-
MemoryContextSwitchTo(oldcontext);
204-
205182
MemSet(values,0,sizeof(values));
206183
MemSet(nulls,0,sizeof(nulls));
207184

@@ -251,9 +228,8 @@ pg_stop_backup_v2(PG_FUNCTION_ARGS)
251228
/* Stoppoint is included on both exclusive and nonexclusive backups */
252229
values[0]=LSNGetDatum(stoppoint);
253230

254-
tuplestore_putvalues(tupstore,tupdesc,values,nulls);
255-
256-
return (Datum)0;
231+
/* Returns the record as Datum */
232+
PG_RETURN_DATUM(HeapTupleGetDatum(heap_form_tuple(tupdesc,values,nulls)));
257233
}
258234

259235
/*

‎src/backend/catalog/system_functions.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ CREATE OR REPLACE FUNCTION
384384
CREATE OR REPLACEFUNCTIONpg_stop_backup (
385385
exclusiveboolean, wait_for_archiveboolean DEFAULT true,
386386
OUT lsn pg_lsn, OUT labelfiletext, OUT spcmapfiletext)
387-
RETURNSSETOFrecord STRICT VOLATILE LANGUAGE internalas'pg_stop_backup_v2'
387+
RETURNS record STRICT VOLATILE LANGUAGE internalas'pg_stop_backup_v2'
388388
PARALLEL RESTRICTED;
389389

390390
CREATEOR REPLACE FUNCTION

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO202203011
56+
#defineCATALOG_VERSION_NO202203031
5757

5858
#endif

‎src/include/catalog/pg_proc.dat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6275,9 +6275,9 @@
62756275
proname => 'pg_stop_backup', provolatile => 'v', proparallel => 'r',
62766276
prorettype => 'pg_lsn', proargtypes => '', prosrc => 'pg_stop_backup' },
62776277
{ oid => '2739', descr => 'finish taking an online backup',
6278-
proname => 'pg_stop_backup',prorows => '1',proretset => 't',
6279-
provolatile => 'v',proparallel => 'r', prorettype => 'record',
6280-
proargtypes => 'bool bool',proallargtypes => '{bool,bool,pg_lsn,text,text}',
6278+
proname => 'pg_stop_backup',provolatile => 'v',proparallel => 'r',
6279+
prorettype => 'record',proargtypes => 'bool bool',
6280+
proallargtypes => '{bool,bool,pg_lsn,text,text}',
62816281
proargmodes => '{i,i,o,o,o}',
62826282
proargnames => '{exclusive,wait_for_archive,lsn,labelfile,spcmapfile}',
62836283
prosrc => 'pg_stop_backup_v2' },

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp