Skip to content

Commit e05a8c3

Browse files
committed
Merge branch 'REL_2_6-PBCKP-245-mingw' into REL_2_6_tmp
2 parents ea9d249 + ccee8ab commit e05a8c3

36 files changed

+296
-387
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ BORROWED_C_SRC := \
5050
src/bin/pg_basebackup/streamutil.c \
5151
src/bin/pg_basebackup/walmethods.c
5252

53-
OBJS += src/fu_util/impl/ft_impl.o src/fu_util/impl/fo_impl.o
54-
5553
BORROW_DIR := src/borrowed
5654
BORROWED_H := $(addprefix $(BORROW_DIR)/, $(notdir $(BORROWED_H_SRC)))
5755
BORROWED_C := $(addprefix $(BORROW_DIR)/, $(notdir $(BORROWED_C_SRC)))
5856
OBJS += $(patsubst %.c, %.o, $(BORROWED_C))
5957
EXTRA_CLEAN := $(BORROWED_H) $(BORROWED_C) $(BORROW_DIR) borrowed.mk
6058

59+
OBJS += src/fu_util/impl/ft_impl.o src/fu_util/impl/fo_impl.o
60+
6161
# off-source build support
6262
ifneq ($(abspath $(CURDIR))/, $(top_pbk_srcdir))
6363
VPATH := $(top_pbk_srcdir)
@@ -95,7 +95,7 @@ borrowed.mk: $(firstword $(MAKEFILE_LIST))
9595
$(file >$@,# This file is autogenerated. Do not edit!)
9696
$(foreach borrowed_file, $(BORROWED_H_SRC) $(BORROWED_C_SRC), \
9797
$(file >>$@,$(addprefix $(BORROW_DIR)/, $(notdir $(borrowed_file))): | $(CURDIR)/$(BORROW_DIR)/ $(realpath $(top_srcdir)/$(borrowed_file))) \
98-
$(file >>$@,$(shell echo "\t"'$$(LN_S) $(realpath $(top_srcdir)/$(borrowed_file)) $$@')) \
98+
$(file >>$@,$(shell echo " "'$$(LN_S) $(realpath $(top_srcdir)/$(borrowed_file)) $$@')) \
9999
)
100100
include borrowed.mk
101101

src/archive.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ do_archive_push(InstanceState *instanceState, InstanceConfig *instance, char *pg
148148
n_threads = parray_num(batch_files);
149149

150150
elog(INFO, "pg_probackup archive-push WAL file: %s, "
151-
"threads: %i/%i, batch: %lu/%i, compression: %s",
151+
"threads: %i/%i, batch: %zu/%i, compression: %s",
152152
wal_file_name, n_threads, num_threads,
153153
parray_num(batch_files), batch_size,
154154
is_compress ? "zlib" : "none");
@@ -279,7 +279,7 @@ push_files(void *arg)
279279
int rc;
280280
archive_push_arg *args = (archive_push_arg *) arg;
281281

282-
my_thread_num = args->thread_num;
282+
set_my_thread_num(args->thread_num);
283283

284284
for (i = 0; i < parray_num(args->files); i++)
285285
{
@@ -553,17 +553,17 @@ push_file_internal(const char *wal_file_name, const char *pg_xlog_dir,
553553

554554
/* enable streaming compression */
555555
if (is_compress)
556-
#ifdef HAVE_LIBZ
557556
{
557+
#ifdef HAVE_LIBZ
558558
pioFilter_i flt = pioGZCompressFilter(compress_level);
559559
err = pioCopy($reduce(pioWriteFlush, out),
560560
$reduce(pioRead, in),
561561
flt);
562-
}
563-
else
564562
#else
565-
elog(ERROR, "Compression is requested, but not compiled it");
563+
elog(ERROR, "Compression is requested, but not compiled it");
566564
#endif
565+
}
566+
else
567567
{
568568
err = pioCopy($reduce(pioWriteFlush, out),
569569
$reduce(pioRead, in));
@@ -1012,7 +1012,7 @@ get_files(void *arg)
10121012
char from_fullpath[MAXPGPATH];
10131013
archive_get_arg *args = (archive_get_arg *) arg;
10141014

1015-
my_thread_num = args->thread_num;
1015+
set_my_thread_num(args->thread_num);
10161016

10171017
for (i = 0; i < parray_num(args->files); i++)
10181018
{

src/backup.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "pgtar.h"
1818
#include "streamutil.h"
1919

20-
#include <sys/stat.h>
2120
#include <time.h>
2221
#include <unistd.h>
2322

@@ -2229,6 +2228,7 @@ check_external_for_tablespaces(parray *external_list, PGconn *backup_conn)
22292228
PGresult *res;
22302229
int i = 0;
22312230
int j = 0;
2231+
int ntups;
22322232
char *tablespace_path = NULL;
22332233
char *query = "SELECT pg_catalog.pg_tablespace_location(oid) "
22342234
"FROM pg_catalog.pg_tablespace "
@@ -2240,7 +2240,8 @@ check_external_for_tablespaces(parray *external_list, PGconn *backup_conn)
22402240
if (!res)
22412241
elog(ERROR, "Failed to get list of tablespaces");
22422242

2243-
for (i = 0; i < res->ntups; i++)
2243+
ntups = PQntuples(res);
2244+
for (i = 0; i < ntups; i++)
22442245
{
22452246
tablespace_path = PQgetvalue(res, i, 0);
22462247
Assert (strlen(tablespace_path) > 0);

src/catalog.c

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#include <dirent.h>
1515
#include <signal.h>
16-
#include <sys/stat.h>
1716
#include <unistd.h>
1817

1918
#include "utils/file.h"
@@ -423,8 +422,8 @@ grab_excl_lock_file(const char *root_dir, const char *backup_id, bool strict)
423422
/* complain every fifth interval */
424423
if ((ntries % LOG_FREQ) == 0)
425424
{
426-
elog(WARNING, "Process %d is using backup %s, and is still running",
427-
encoded_pid, backup_id);
425+
elog(WARNING, "Process %lld is using backup %s, and is still running",
426+
(long long)encoded_pid, backup_id);
428427

429428
elog(WARNING, "Waiting %u seconds on exclusive lock for backup %s",
430429
ntries, backup_id);
@@ -438,8 +437,8 @@ grab_excl_lock_file(const char *root_dir, const char *backup_id, bool strict)
438437
else
439438
{
440439
if (errno == ESRCH)
441-
elog(WARNING, "Process %d which used backup %s no longer exists",
442-
encoded_pid, backup_id);
440+
elog(WARNING, "Process %lld which used backup %s no longer exists",
441+
(long long)encoded_pid, backup_id);
443442
else
444443
elog(ERROR, "Failed to send signal 0 to a process %d: %s",
445444
encoded_pid, strerror(errno));
@@ -468,7 +467,7 @@ grab_excl_lock_file(const char *root_dir, const char *backup_id, bool strict)
468467
/*
469468
* Successfully created the file, now fill it.
470469
*/
471-
snprintf(buffer, sizeof(buffer), "%d\n", my_pid);
470+
snprintf(buffer, sizeof(buffer), "%lld\n", (long long)my_pid);
472471

473472
errno = 0;
474473
if (fio_write(fd, buffer, strlen(buffer)) != strlen(buffer))
@@ -575,8 +574,8 @@ wait_shared_owners(pgBackup *backup)
575574
/* complain from time to time */
576575
if ((ntries % LOG_FREQ) == 0)
577576
{
578-
elog(WARNING, "Process %d is using backup %s in shared mode, and is still running",
579-
encoded_pid, base36enc(backup->start_time));
577+
elog(WARNING, "Process %lld is using backup %s in shared mode, and is still running",
578+
(long long)encoded_pid, base36enc(backup->start_time));
580579

581580
elog(WARNING, "Waiting %u seconds on lock for backup %s", ntries,
582581
base36enc(backup->start_time));
@@ -588,8 +587,8 @@ wait_shared_owners(pgBackup *backup)
588587
continue;
589588
}
590589
else if (errno != ESRCH)
591-
elog(ERROR, "Failed to send signal 0 to a process %d: %s",
592-
encoded_pid, strerror(errno));
590+
elog(ERROR, "Failed to send signal 0 to a process %lld: %s",
591+
(long long)encoded_pid, strerror(errno));
593592

594593
/* locker is dead */
595594
break;
@@ -606,8 +605,8 @@ wait_shared_owners(pgBackup *backup)
606605
/* some shared owners are still alive */
607606
if (ntries <= 0)
608607
{
609-
elog(WARNING, "Cannot to lock backup %s in exclusive mode, because process %u owns shared lock",
610-
base36enc(backup->start_time), encoded_pid);
608+
elog(WARNING, "Cannot to lock backup %s in exclusive mode, because process %llu owns shared lock",
609+
base36enc(backup->start_time), (long long)encoded_pid);
611610
return 1;
612611
}
613612

@@ -662,11 +661,11 @@ grab_shared_lock_file(pgBackup *backup)
662661
* Somebody is still using this backup in shared mode,
663662
* copy this pid into a new file.
664663
*/
665-
buffer_len += snprintf(buffer+buffer_len, 4096, "%u\n", encoded_pid);
664+
buffer_len += snprintf(buffer+buffer_len, 4096, "%llu\n", (long long)encoded_pid);
666665
}
667666
else if (errno != ESRCH)
668-
elog(ERROR, "Failed to send signal 0 to a process %d: %s",
669-
encoded_pid, strerror(errno));
667+
elog(ERROR, "Failed to send signal 0 to a process %lld: %s",
668+
(long long)encoded_pid, strerror(errno));
670669
}
671670

672671
if (fp_in)
@@ -686,7 +685,7 @@ grab_shared_lock_file(pgBackup *backup)
686685
}
687686

688687
/* add my own pid */
689-
buffer_len += snprintf(buffer+buffer_len, sizeof(buffer), "%u\n", my_pid);
688+
buffer_len += snprintf(buffer+buffer_len, sizeof(buffer), "%llu\n", (long long)my_pid);
690689

691690
/* write out the collected PIDs to temp lock file */
692691
fwrite(buffer, 1, buffer_len, fp_out);
@@ -784,11 +783,11 @@ release_shared_lock_file(const char *backup_dir)
784783
* Somebody is still using this backup in shared mode,
785784
* copy this pid into a new file.
786785
*/
787-
buffer_len += snprintf(buffer+buffer_len, 4096, "%u\n", encoded_pid);
786+
buffer_len += snprintf(buffer+buffer_len, 4096, "%llu\n", (long long)encoded_pid);
788787
}
789788
else if (errno != ESRCH)
790-
elog(ERROR, "Failed to send signal 0 to a process %d: %s",
791-
encoded_pid, strerror(errno));
789+
elog(ERROR, "Failed to send signal 0 to a process %lld: %s",
790+
(long long)encoded_pid, strerror(errno));
792791
}
793792

794793
if (ferror(fp_in))

src/catchup.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "pgtar.h"
1818
#include "streamutil.h"
1919

20-
#include <sys/stat.h>
2120
#include <time.h>
2221
#include <unistd.h>
2322

@@ -138,8 +137,8 @@ catchup_preflight_checks(PGNodeInfo *source_node_info, PGconn *source_conn,
138137
}
139138
else if (pid > 1) /* postmaster is up */
140139
{
141-
elog(ERROR, "Postmaster with pid %u is running in destination directory \"%s\"",
142-
pid, dest_pgdata);
140+
elog(ERROR, "Postmaster with pid %lld is running in destination directory \"%s\"",
141+
(long long)pid, dest_pgdata);
143142
}
144143
}
145144

@@ -161,15 +160,15 @@ catchup_preflight_checks(PGNodeInfo *source_node_info, PGconn *source_conn,
161160
source_id = get_system_identifier(FIO_DB_HOST, source_pgdata, false); /* same as instance_config.system_identifier */
162161

163162
if (source_conn_id != source_id)
164-
elog(ERROR, "Database identifiers mismatch: we connected to DB id %lu, but in \"%s\" we found id %lu",
165-
source_conn_id, source_pgdata, source_id);
163+
elog(ERROR, "Database identifiers mismatch: we connected to DB id %llu, but in \"%s\" we found id %llu",
164+
(long long)source_conn_id, source_pgdata, (long long)source_id);
166165

167166
if (current.backup_mode != BACKUP_MODE_FULL)
168167
{
169168
dest_id = get_system_identifier(FIO_LOCAL_HOST, dest_pgdata, false);
170169
if (source_conn_id != dest_id)
171-
elog(ERROR, "Database identifiers mismatch: we connected to DB id %lu, but in \"%s\" we found id %lu",
172-
source_conn_id, dest_pgdata, dest_id);
170+
elog(ERROR, "Database identifiers mismatch: we connected to DB id %llu, but in \"%s\" we found id %llu",
171+
(long long)source_conn_id, dest_pgdata, (long long)dest_id);
173172
}
174173
}
175174

@@ -230,6 +229,7 @@ catchup_check_tablespaces_existance_in_tbsmapping(PGconn *conn)
230229
{
231230
PGresult *res;
232231
int i;
232+
int ntups;
233233
char *tablespace_path = NULL;
234234
const char *linked_path = NULL;
235235
char *query = "SELECT pg_catalog.pg_tablespace_location(oid) "
@@ -241,7 +241,8 @@ catchup_check_tablespaces_existance_in_tbsmapping(PGconn *conn)
241241
if (!res)
242242
elog(ERROR, "Failed to get list of tablespaces");
243243

244-
for (i = 0; i < res->ntups; i++)
244+
ntups = PQntuples(res);
245+
for (i = 0; i < ntups; i++)
245246
{
246247
tablespace_path = PQgetvalue(res, i, 0);
247248
Assert (strlen(tablespace_path) > 0);
@@ -438,7 +439,7 @@ catchup_thread_runner(void *arg)
438439

439440
if (file->write_size == BYTES_INVALID)
440441
{
441-
elog(LOG, "Skipping the unchanged file: \"%s\", read %li bytes", from_fullpath, file->read_size);
442+
elog(LOG, "Skipping the unchanged file: \"%s\", read %zu bytes", from_fullpath, file->read_size);
442443
continue;
443444
}
444445

src/checkdb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include "pg_probackup.h"
1818

19-
#include <sys/stat.h>
2019
#include <time.h>
2120
#include <unistd.h>
2221

@@ -293,7 +292,8 @@ check_indexes(void *arg)
293292
int i;
294293
check_indexes_arg *arguments = (check_indexes_arg *) arg;
295294
int n_indexes = 0;
296-
my_thread_num = arguments->thread_num;
295+
296+
set_my_thread_num(arguments->thread_num);
297297

298298
if (arguments->index_list)
299299
n_indexes = parray_num(arguments->index_list);

src/data.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "utils/file.h"
1717

1818
#include <unistd.h>
19-
#include <sys/stat.h>
2019

2120
#ifdef HAVE_LIBZ
2221
#include <zlib.h>
@@ -208,12 +207,12 @@ get_header_errormsg(Page page, char **errormsg)
208207

209208
if (PageGetPageSize(phdr) != BLCKSZ)
210209
snprintf(*errormsg, ERRMSG_MAX_LEN, "page header invalid, "
211-
"page size %lu is not equal to block size %u",
210+
"page size %zu is not equal to block size %u",
212211
PageGetPageSize(phdr), BLCKSZ);
213212

214213
else if (phdr->pd_lower < SizeOfPageHeaderData)
215214
snprintf(*errormsg, ERRMSG_MAX_LEN, "page header invalid, "
216-
"pd_lower %i is less than page header size %lu",
215+
"pd_lower %i is less than page header size %zu",
217216
phdr->pd_lower, SizeOfPageHeaderData);
218217

219218
else if (phdr->pd_lower > phdr->pd_upper)
@@ -233,7 +232,7 @@ get_header_errormsg(Page page, char **errormsg)
233232

234233
else if (phdr->pd_special != MAXALIGN(phdr->pd_special))
235234
snprintf(*errormsg, ERRMSG_MAX_LEN, "page header invalid, "
236-
"pd_special %i is misaligned, expected %lu",
235+
"pd_special %i is misaligned, expected %zu",
237236
phdr->pd_special, MAXALIGN(phdr->pd_special));
238237

239238
else if (phdr->pd_flags & ~PD_VALID_FLAG_BITS)
@@ -1203,7 +1202,7 @@ restore_data_file_internal(FILE *in, FILE *out, pgFile *file, uint32 backup_vers
12031202
datapagemap_add(map, blknum);
12041203
}
12051204

1206-
elog(LOG, "Copied file \"%s\": %lu bytes", from_fullpath, write_len);
1205+
elog(LOG, "Copied file \"%s\": %zu bytes", from_fullpath, write_len);
12071206
return write_len;
12081207
}
12091208

@@ -1247,7 +1246,7 @@ restore_non_data_file_internal(FILE *in, FILE *out, pgFile *file,
12471246

12481247
pg_free(buf);
12491248

1250-
elog(LOG, "Copied file \"%s\": %lu bytes", from_fullpath, file->write_size);
1249+
elog(LOG, "Copied file \"%s\": %llu bytes", from_fullpath, (long long)file->write_size);
12511250
}
12521251

12531252
size_t
@@ -1324,9 +1323,9 @@ restore_non_data_file(parray *parent_chain, pgBackup *dest_backup,
13241323
elog(ERROR, "Failed to locate a full copy of non-data file \"%s\"", to_fullpath);
13251324

13261325
if (tmp_file->write_size <= 0)
1327-
elog(ERROR, "Full copy of non-data file has invalid size: %li. "
1326+
elog(ERROR, "Full copy of non-data file has invalid size: %lli. "
13281327
"Metadata corruption in backup %s in file: \"%s\"",
1329-
tmp_file->write_size, base36enc(tmp_backup->start_time),
1328+
(long long)tmp_file->write_size, base36enc(tmp_backup->start_time),
13301329
to_fullpath);
13311330

13321331
/* incremental restore */
@@ -2038,11 +2037,11 @@ get_page_header(FILE *in, const char *fullpath, BackupPageHeader* bph,
20382037
return false; /* EOF found */
20392038
else if (read_len != 0 && feof(in))
20402039
elog(ERROR,
2041-
"Odd size page found at offset %ld of \"%s\"",
2042-
ftello(in), fullpath);
2040+
"Odd size page found at offset %lld of \"%s\"",
2041+
(long long)ftello(in), fullpath);
20432042
else
2044-
elog(ERROR, "Cannot read header at offset %ld of \"%s\": %s",
2045-
ftello(in), fullpath, strerror(errno));
2043+
elog(ERROR, "Cannot read header at offset %lld of \"%s\": %s",
2044+
(long long)ftello(in), fullpath, strerror(errno));
20462045
}
20472046

20482047
/* In older versions < 2.4.0, when crc for file was calculated, header was
@@ -2342,8 +2341,8 @@ copy_pages(const char *to_fullpath, const char *from_fullpath,
23422341
to_fullpath, strerror(errno));
23432342

23442343
if (ftruncate(fileno(out), file->size) == -1)
2345-
elog(ERROR, "Cannot ftruncate file \"%s\" to size %lu: %s",
2346-
to_fullpath, file->size, strerror(errno));
2344+
elog(ERROR, "Cannot ftruncate file \"%s\" to size %llu: %s",
2345+
to_fullpath, (long long)file->size, strerror(errno));
23472346
}
23482347
}
23492348

@@ -2452,7 +2451,7 @@ get_data_file_headers(HeaderMap *hdr_map, pgFile *file, uint32 backup_version, b
24522451
if (hdr_crc != file->hdr_crc)
24532452
{
24542453
elog(strict ? ERROR : WARNING, "Header map for file \"%s\" crc mismatch \"%s\" "
2455-
"offset: %llu, len: %lu, current: %u, expected: %u",
2454+
"offset: %llu, len: %zu, current: %u, expected: %u",
24562455
file->rel_path, hdr_map->path, file->hdr_off, read_len, hdr_crc, file->hdr_crc);
24572456
goto cleanup;
24582457
}

0 commit comments

Comments
 (0)