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

Commitf26c959

Browse files
committed
remove unneeded funtion dir_read_file_list()
1 parent0fd2fde commitf26c959

File tree

3 files changed

+107
-125
lines changed

3 files changed

+107
-125
lines changed

‎src/catalog.c

Lines changed: 104 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -876,19 +876,118 @@ catalog_get_backup_list(const char *instance_name, time_t requested_backup_id)
876876
}
877877

878878
/*
879-
* Create list of backup datafiles.
880-
* If 'requested_backup_id' is INVALID_BACKUP_ID, exit with error.
881-
* If valid backup id is passed only matching backup will be added to the list.
882-
* TODO this function only used once. Is it really needed?
879+
* Get list of files in the backup from the DATABASE_FILE_LIST.
883880
*/
884881
parray*
885882
get_backup_filelist(pgBackup*backup,boolstrict)
886883
{
887884
parray*files=NULL;
888885
charbackup_filelist_path[MAXPGPATH];
886+
FILE*fp;
887+
charbuf[BLCKSZ];
888+
charstdio_buf[STDIO_BUFSIZE];
889+
pg_crc32content_crc=0;
889890

890891
join_path_components(backup_filelist_path,backup->root_dir,DATABASE_FILE_LIST);
891-
files=dir_read_file_list(NULL,NULL,backup_filelist_path,FIO_BACKUP_HOST,backup->content_crc);
892+
893+
fp=fio_open_stream(backup_filelist_path,FIO_BACKUP_HOST);
894+
if (fp==NULL)
895+
elog(ERROR,"cannot open \"%s\": %s",backup_filelist_path,strerror(errno));
896+
897+
/* enable stdio buffering for local file */
898+
if (!fio_is_remote(FIO_BACKUP_HOST))
899+
setvbuf(fp,stdio_buf,_IOFBF,STDIO_BUFSIZE);
900+
901+
files=parray_new();
902+
903+
INIT_FILE_CRC32(true,content_crc);
904+
905+
while (fgets(buf,lengthof(buf),fp))
906+
{
907+
charpath[MAXPGPATH];
908+
charlinked[MAXPGPATH];
909+
charcompress_alg_string[MAXPGPATH];
910+
int64write_size,
911+
mode,/* bit length of mode_t depends on platforms */
912+
is_datafile,
913+
is_cfs,
914+
external_dir_num,
915+
crc,
916+
segno,
917+
n_blocks,
918+
n_headers,
919+
dbOid,/* used for partial restore */
920+
hdr_crc,
921+
hdr_off,
922+
hdr_size;
923+
pgFile*file;
924+
925+
COMP_FILE_CRC32(true,content_crc,buf,strlen(buf));
926+
927+
get_control_value(buf,"path",path,NULL, true);
928+
get_control_value(buf,"size",NULL,&write_size, true);
929+
get_control_value(buf,"mode",NULL,&mode, true);
930+
get_control_value(buf,"is_datafile",NULL,&is_datafile, true);
931+
get_control_value(buf,"is_cfs",NULL,&is_cfs, false);
932+
get_control_value(buf,"crc",NULL,&crc, true);
933+
get_control_value(buf,"compress_alg",compress_alg_string,NULL, false);
934+
get_control_value(buf,"external_dir_num",NULL,&external_dir_num, false);
935+
get_control_value(buf,"dbOid",NULL,&dbOid, false);
936+
937+
file=pgFileInit(path);
938+
file->write_size= (int64)write_size;
939+
file->mode= (mode_t)mode;
940+
file->is_datafile=is_datafile ? true : false;
941+
file->is_cfs=is_cfs ? true : false;
942+
file->crc= (pg_crc32)crc;
943+
file->compress_alg=parse_compress_alg(compress_alg_string);
944+
file->external_dir_num=external_dir_num;
945+
file->dbOid=dbOid ?dbOid :0;
946+
947+
/*
948+
* Optional fields
949+
*/
950+
if (get_control_value(buf,"linked",linked,NULL, false)&&linked[0])
951+
{
952+
file->linked=pgut_strdup(linked);
953+
canonicalize_path(file->linked);
954+
}
955+
956+
if (get_control_value(buf,"segno",NULL,&segno, false))
957+
file->segno= (int)segno;
958+
959+
if (get_control_value(buf,"n_blocks",NULL,&n_blocks, false))
960+
file->n_blocks= (int)n_blocks;
961+
962+
if (get_control_value(buf,"n_headers",NULL,&n_headers, false))
963+
file->n_headers= (int)n_headers;
964+
965+
if (get_control_value(buf,"hdr_crc",NULL,&hdr_crc, false))
966+
file->hdr_crc= (pg_crc32)hdr_crc;
967+
968+
if (get_control_value(buf,"hdr_off",NULL,&hdr_off, false))
969+
file->hdr_off=hdr_off;
970+
971+
if (get_control_value(buf,"hdr_size",NULL,&hdr_size, false))
972+
file->hdr_size= (int)hdr_size;
973+
974+
parray_append(files,file);
975+
}
976+
977+
FIN_FILE_CRC32(true,content_crc);
978+
979+
if (ferror(fp))
980+
elog(ERROR,"Failed to read from file: \"%s\"",backup_filelist_path);
981+
982+
fio_close_stream(fp);
983+
984+
if (backup->content_crc!=0&&
985+
backup->content_crc!=content_crc)
986+
{
987+
elog(WARNING,"Invalid CRC of backup control file '%s': %u. Expected: %u",
988+
backup_filelist_path,content_crc,backup->content_crc);
989+
returnNULL;
990+
}
892991

893992
/* redundant sanity? */
894993
if (!files)

‎src/dir.c

Lines changed: 1 addition & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ get_external_remap(char *current_dir)
14301430
*
14311431
* Returns true if the value was found in the line.
14321432
*/
1433-
staticbool
1433+
bool
14341434
get_control_value(constchar*str,constchar*name,
14351435
char*value_str,int64*value_int64,boolis_mandatory)
14361436
{
@@ -1554,123 +1554,6 @@ get_control_value(const char *str, const char *name,
15541554
return false;/* Make compiler happy */
15551555
}
15561556

1557-
/*
1558-
* Construct parray of pgFile from the backup content list.
1559-
* If root is not NULL, path will be absolute path.
1560-
*/
1561-
parray*
1562-
dir_read_file_list(constchar*root,constchar*external_prefix,
1563-
constchar*file_txt,fio_locationlocation,pg_crc32expected_crc)
1564-
{
1565-
FILE*fp;
1566-
parray*files;
1567-
charbuf[BLCKSZ];
1568-
charstdio_buf[STDIO_BUFSIZE];
1569-
pg_crc32content_crc=0;
1570-
1571-
fp=fio_open_stream(file_txt,location);
1572-
if (fp==NULL)
1573-
elog(ERROR,"cannot open \"%s\": %s",file_txt,strerror(errno));
1574-
1575-
/* enable stdio buffering for local file */
1576-
if (!fio_is_remote(location))
1577-
setvbuf(fp,stdio_buf,_IOFBF,STDIO_BUFSIZE);
1578-
1579-
files=parray_new();
1580-
1581-
INIT_FILE_CRC32(true,content_crc);
1582-
1583-
while (fgets(buf,lengthof(buf),fp))
1584-
{
1585-
charpath[MAXPGPATH];
1586-
charlinked[MAXPGPATH];
1587-
charcompress_alg_string[MAXPGPATH];
1588-
int64write_size,
1589-
mode,/* bit length of mode_t depends on platforms */
1590-
is_datafile,
1591-
is_cfs,
1592-
external_dir_num,
1593-
crc,
1594-
segno,
1595-
n_blocks,
1596-
n_headers,
1597-
dbOid,/* used for partial restore */
1598-
hdr_crc,
1599-
hdr_off,
1600-
hdr_size;
1601-
pgFile*file;
1602-
1603-
COMP_FILE_CRC32(true,content_crc,buf,strlen(buf));
1604-
1605-
get_control_value(buf,"path",path,NULL, true);
1606-
get_control_value(buf,"size",NULL,&write_size, true);
1607-
get_control_value(buf,"mode",NULL,&mode, true);
1608-
get_control_value(buf,"is_datafile",NULL,&is_datafile, true);
1609-
get_control_value(buf,"is_cfs",NULL,&is_cfs, false);
1610-
get_control_value(buf,"crc",NULL,&crc, true);
1611-
get_control_value(buf,"compress_alg",compress_alg_string,NULL, false);
1612-
get_control_value(buf,"external_dir_num",NULL,&external_dir_num, false);
1613-
get_control_value(buf,"dbOid",NULL,&dbOid, false);
1614-
1615-
file=pgFileInit(path);
1616-
file->write_size= (int64)write_size;
1617-
file->mode= (mode_t)mode;
1618-
file->is_datafile=is_datafile ? true : false;
1619-
file->is_cfs=is_cfs ? true : false;
1620-
file->crc= (pg_crc32)crc;
1621-
file->compress_alg=parse_compress_alg(compress_alg_string);
1622-
file->external_dir_num=external_dir_num;
1623-
file->dbOid=dbOid ?dbOid :0;
1624-
1625-
/*
1626-
* Optional fields
1627-
*/
1628-
1629-
if (get_control_value(buf,"linked",linked,NULL, false)&&linked[0])
1630-
{
1631-
file->linked=pgut_strdup(linked);
1632-
canonicalize_path(file->linked);
1633-
}
1634-
1635-
if (get_control_value(buf,"segno",NULL,&segno, false))
1636-
file->segno= (int)segno;
1637-
1638-
if (get_control_value(buf,"n_blocks",NULL,&n_blocks, false))
1639-
file->n_blocks= (int)n_blocks;
1640-
1641-
if (get_control_value(buf,"n_headers",NULL,&n_headers, false))
1642-
file->n_headers= (int)n_headers;
1643-
1644-
if (get_control_value(buf,"hdr_crc",NULL,&hdr_crc, false))
1645-
file->hdr_crc= (pg_crc32)hdr_crc;
1646-
1647-
if (get_control_value(buf,"hdr_off",NULL,&hdr_off, false))
1648-
file->hdr_off=hdr_off;
1649-
1650-
if (get_control_value(buf,"hdr_size",NULL,&hdr_size, false))
1651-
file->hdr_size= (int)hdr_size;
1652-
1653-
parray_append(files,file);
1654-
}
1655-
1656-
FIN_FILE_CRC32(true,content_crc);
1657-
1658-
if (ferror(fp))
1659-
elog(ERROR,"Failed to read from file: \"%s\"",file_txt);
1660-
1661-
fio_close_stream(fp);
1662-
1663-
if (expected_crc!=0&&
1664-
expected_crc!=content_crc)
1665-
{
1666-
elog(WARNING,"Invalid CRC of backup control file '%s': %u. Expected: %u",
1667-
file_txt,content_crc,expected_crc);
1668-
returnNULL;
1669-
}
1670-
1671-
returnfiles;
1672-
}
1673-
16741557
/*
16751558
* Check if directory empty.
16761559
*/

‎src/pg_probackup.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,8 @@ extern CompressAlg parse_compress_alg(const char *arg);
975975
externconstchar*deparse_compress_alg(intalg);
976976

977977
/* in dir.c */
978+
externboolget_control_value(constchar*str,constchar*name,
979+
char*value_str,int64*value_int64,boolis_mandatory);
978980
externvoiddir_list_file(parray*files,constchar*root,boolexclude,
979981
boolfollow_symlink,booladd_root,boolbackup_logs,
980982
boolskip_hidden,intexternal_dir_num,fio_locationlocation);
@@ -1000,8 +1002,6 @@ extern void db_map_entry_free(void *map);
10001002

10011003
externvoidprint_file_list(FILE*out,constparray*files,constchar*root,
10021004
constchar*external_prefix,parray*external_list);
1003-
externparray*dir_read_file_list(constchar*root,constchar*external_prefix,
1004-
constchar*file_txt,fio_locationlocation,pg_crc32expected_crc);
10051005
externparray*make_external_directory_list(constchar*colon_separated_dirs,
10061006
boolremap);
10071007
externvoidfree_dir_list(parray*list);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp