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

Commite1e6f8f

Browse files
committed
Remove dependency to StringInfo in xlogbackup.{c.h}
This was used as the returned result type of the generated contents forthe backup_label and backup history files. This is replaced by a simplestring, reducing the cleanup burden of all the callers ofbuild_backup_content().Reviewed-by: Bharath RupireddyDiscussion:https://postgr.es/m/YzERvNPaZivHEKZJ@paquier.xyz
1 parent31d2c47 commite1e6f8f

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8711,7 +8711,7 @@ do_pg_backup_stop(BackupState *state, bool waitforarchive)
87118711
}
87128712
else
87138713
{
8714-
StringInfohistory_file;
8714+
char*history_file;
87158715

87168716
/*
87178717
* Write the backup-end xlog record
@@ -8751,8 +8751,7 @@ do_pg_backup_stop(BackupState *state, bool waitforarchive)
87518751

87528752
/* Build and save the contents of the backup history file */
87538753
history_file=build_backup_content(state, true);
8754-
fprintf(fp,"%s",history_file->data);
8755-
pfree(history_file->data);
8754+
fprintf(fp,"%s",history_file);
87568755
pfree(history_file);
87578756

87588757
if (fflush(fp)||ferror(fp)||FreeFile(fp))

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@
2323
* When ishistoryfile is true, it creates the contents for a backup history
2424
* file, otherwise it creates contents for a backup_label file.
2525
*
26-
* Returns the result generated as a palloc'dStringInfo.
26+
* Returns the result generated as a palloc'dstring.
2727
*/
28-
StringInfo
28+
char*
2929
build_backup_content(BackupState*state,boolishistoryfile)
3030
{
3131
charstartstrbuf[128];
3232
charstartxlogfile[MAXFNAMELEN];/* backup start WAL file */
3333
XLogSegNostartsegno;
3434
StringInforesult=makeStringInfo();
35+
char*data;
3536

3637
Assert(state!=NULL);
3738

@@ -76,5 +77,8 @@ build_backup_content(BackupState *state, bool ishistoryfile)
7677
appendStringInfo(result,"STOP TIMELINE: %u\n",state->stoptli);
7778
}
7879

79-
returnresult;
80+
data=result->data;
81+
pfree(result);
82+
83+
returndata;
8084
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pg_backup_stop(PG_FUNCTION_ARGS)
130130
Datumvalues[PG_BACKUP_STOP_V2_COLS]= {0};
131131
boolnulls[PG_BACKUP_STOP_V2_COLS]= {0};
132132
boolwaitforarchive=PG_GETARG_BOOL(0);
133-
StringInfobackup_label;
133+
char*backup_label;
134134
SessionBackupStatestatus=get_backup_status();
135135

136136
/* Initialize attributes information in the tuple descriptor */
@@ -153,7 +153,7 @@ pg_backup_stop(PG_FUNCTION_ARGS)
153153
backup_label=build_backup_content(backup_state, false);
154154

155155
values[0]=LSNGetDatum(backup_state->stoppoint);
156-
values[1]=CStringGetTextDatum(backup_label->data);
156+
values[1]=CStringGetTextDatum(backup_label);
157157
values[2]=CStringGetTextDatum(tablespace_map->data);
158158

159159
/* Deallocate backup-related variables */
@@ -162,7 +162,6 @@ pg_backup_stop(PG_FUNCTION_ARGS)
162162
pfree(tablespace_map->data);
163163
pfree(tablespace_map);
164164
tablespace_map=NULL;
165-
pfree(backup_label->data);
166165
pfree(backup_label);
167166

168167
/* Returns the record as Datum */

‎src/backend/backup/basebackup.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,15 +317,14 @@ perform_base_backup(basebackup_options *opt, bbsink *sink)
317317
{
318318
structstatstatbuf;
319319
boolsendtblspclinks= true;
320-
StringInfobackup_label;
320+
char*backup_label;
321321

322322
bbsink_begin_archive(sink,"base.tar");
323323

324324
/* In the main tar, include the backup_label first... */
325325
backup_label=build_backup_content(backup_state, false);
326326
sendFileWithContent(sink,BACKUP_LABEL_FILE,
327-
backup_label->data,&manifest);
328-
pfree(backup_label->data);
327+
backup_label,&manifest);
329328
pfree(backup_label);
330329

331330
/* Then the tablespace_map file, if required... */

‎src/include/access/xlogbackup.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#defineXLOG_BACKUP_H
1616

1717
#include"access/xlogdefs.h"
18-
#include"lib/stringinfo.h"
1918
#include"pgtime.h"
2019

2120
/* Structure to hold backup state. */
@@ -36,7 +35,7 @@ typedef struct BackupState
3635
pg_time_tstoptime;/* backup stop time */
3736
}BackupState;
3837

39-
externStringInfobuild_backup_content(BackupState*state,
40-
boolishistoryfile);
38+
externchar*build_backup_content(BackupState*state,
39+
boolishistoryfile);
4140

4241
#endif/* XLOG_BACKUP_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp