@@ -186,7 +186,8 @@ pgFileInit(const char *path)
186
186
187
187
file -> is_cfs = false;
188
188
file -> exists_in_prev = false; /* can change only in Incremental backup. */
189
- file -> n_blocks = -1 ; /* can change only in DELTA backup. Number of blocks readed during backup */
189
+ /* Number of blocks readed during backup */
190
+ file -> n_blocks = BLOCKNUM_INVALID ;
190
191
file -> compress_alg = NOT_DEFINED_COMPRESS ;
191
192
return file ;
192
193
}
@@ -836,7 +837,7 @@ print_file_list(FILE *out, const parray *files, const char *root)
836
837
#endif
837
838
fprintf (out , ",\"linked\":\"%s\"" , file -> linked );
838
839
839
- if (file -> n_blocks != -1 )
840
+ if (file -> n_blocks != BLOCKNUM_INVALID )
840
841
fprintf (out , ",\"n_blocks\":\"%i\"" , file -> n_blocks );
841
842
842
843
fprintf (out , "}\n" );
@@ -858,23 +859,25 @@ print_file_list(FILE *out, const parray *files, const char *root)
858
859
* {"name1":"value1", "name2":"value2"}
859
860
*
860
861
* The value will be returned to "value_str" as string if it is not NULL. If it
861
- * is NULL the value will be returned to "value_ulong" as unsigned long.
862
+ * is NULL the value will be returned to "value_uint64" as int64.
863
+ *
864
+ * Returns true if the value was found in the line.
862
865
*/
863
- static void
866
+ static bool
864
867
get_control_value (const char * str , const char * name ,
865
- char * value_str , uint64 * value_uint64 , bool is_mandatory )
868
+ char * value_str , int64 * value_int64 , bool is_mandatory )
866
869
{
867
870
int state = CONTROL_WAIT_NAME ;
868
871
char * name_ptr = (char * ) name ;
869
872
char * buf = (char * ) str ;
870
- char buf_uint64 [32 ], /* Buffer for "value_uint64 " */
871
- * buf_uint64_ptr = buf_uint64 ;
873
+ char buf_int64 [32 ], /* Buffer for "value_int64 " */
874
+ * buf_int64_ptr = buf_int64 ;
872
875
873
876
/* Set default values */
874
877
if (value_str )
875
878
* value_str = '\0' ;
876
- else if (value_uint64 )
877
- * value_uint64 = 0 ;
879
+ else if (value_int64 )
880
+ * value_int64 = 0 ;
878
881
879
882
while (* buf )
880
883
{
@@ -909,7 +912,7 @@ get_control_value(const char *str, const char *name,
909
912
if (* buf == '"' )
910
913
{
911
914
state = CONTROL_INVALUE ;
912
- buf_uint64_ptr = buf_uint64 ;
915
+ buf_int64_ptr = buf_int64 ;
913
916
}
914
917
else if (IsAlpha (* buf ))
915
918
goto bad_format ;
@@ -922,19 +925,19 @@ get_control_value(const char *str, const char *name,
922
925
{
923
926
* value_str = '\0' ;
924
927
}
925
- else if (value_uint64 )
928
+ else if (value_int64 )
926
929
{
927
930
/* Length of buf_uint64 should not be greater than 31 */
928
- if (buf_uint64_ptr - buf_uint64 >= 32 )
931
+ if (buf_int64_ptr - buf_int64 >= 32 )
929
932
elog (ERROR , "field \"%s\" is out of range in the line %s of the file %s" ,
930
933
name , str , DATABASE_FILE_LIST );
931
934
932
- * buf_uint64_ptr = '\0' ;
933
- if (!parse_uint64 ( buf_uint64 , value_uint64 , 0 ))
935
+ * buf_int64_ptr = '\0' ;
936
+ if (!parse_int64 ( buf_int64 , value_int64 , 0 ))
934
937
goto bad_format ;
935
938
}
936
939
937
- return ;
940
+ return true ;
938
941
}
939
942
else
940
943
{
@@ -945,8 +948,8 @@ get_control_value(const char *str, const char *name,
945
948
}
946
949
else
947
950
{
948
- * buf_uint64_ptr = * buf ;
949
- buf_uint64_ptr ++ ;
951
+ * buf_int64_ptr = * buf ;
952
+ buf_int64_ptr ++ ;
950
953
}
951
954
}
952
955
break ;
@@ -970,11 +973,12 @@ get_control_value(const char *str, const char *name,
970
973
if (is_mandatory )
971
974
elog (ERROR , "field \"%s\" is not found in the line %s of the file %s" ,
972
975
name , str , DATABASE_FILE_LIST );
973
- return ;
976
+ return false ;
974
977
975
978
bad_format :
976
979
elog (ERROR , "%s file has invalid format in line %s" ,
977
980
DATABASE_FILE_LIST , str );
981
+ return false; /* Make compiler happy */
978
982
}
979
983
980
984
/*
@@ -1001,7 +1005,7 @@ dir_read_file_list(const char *root, const char *file_txt)
1001
1005
char filepath [MAXPGPATH ];
1002
1006
char linked [MAXPGPATH ];
1003
1007
char compress_alg_string [MAXPGPATH ];
1004
- uint64 write_size ,
1008
+ int64 write_size ,
1005
1009
mode , /* bit length of mode_t depends on platforms */
1006
1010
is_datafile ,
1007
1011
is_cfs ,
@@ -1016,12 +1020,7 @@ dir_read_file_list(const char *root, const char *file_txt)
1016
1020
get_control_value (buf , "is_datafile" , NULL , & is_datafile , true);
1017
1021
get_control_value (buf , "is_cfs" , NULL , & is_cfs , false);
1018
1022
get_control_value (buf , "crc" , NULL , & crc , true);
1019
-
1020
- /* optional fields */
1021
- get_control_value (buf , "linked" , linked , NULL , false);
1022
- get_control_value (buf , "segno" , NULL , & segno , false);
1023
1023
get_control_value (buf , "compress_alg" , compress_alg_string , NULL , false);
1024
- get_control_value (buf , "n_blocks" , NULL , & n_blocks , false);
1025
1024
1026
1025
if (root )
1027
1026
join_path_components (filepath , root , path );
@@ -1036,10 +1035,19 @@ dir_read_file_list(const char *root, const char *file_txt)
1036
1035
file -> is_cfs = is_cfs ? true : false;
1037
1036
file -> crc = (pg_crc32 ) crc ;
1038
1037
file -> compress_alg = parse_compress_alg (compress_alg_string );
1039
- if (linked [0 ])
1038
+
1039
+ /*
1040
+ * Optional fields
1041
+ */
1042
+
1043
+ if (get_control_value (buf , "linked" , linked , NULL , false) && linked [0 ])
1040
1044
file -> linked = pgut_strdup (linked );
1041
- file -> segno = (int ) segno ;
1042
- file -> n_blocks = (int ) n_blocks ;
1045
+
1046
+ if (get_control_value (buf , "segno" , NULL , & segno , false))
1047
+ file -> segno = (int ) segno ;
1048
+
1049
+ if (get_control_value (buf , "n_blocks" , NULL , & n_blocks , false))
1050
+ file -> n_blocks = (int ) n_blocks ;
1043
1051
1044
1052
parray_append (files , file );
1045
1053
}
0 commit comments