Skip to content

Commit d01994a

Browse files
committed
more mingw compatibility
1 parent c8d7949 commit d01994a

File tree

12 files changed

+84
-120
lines changed

12 files changed

+84
-120
lines changed

src/archive.c

Lines changed: 1 addition & 1 deletion
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");

src/catalog.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,8 @@ grab_excl_lock_file(const char *root_dir, const char *backup_id, bool strict)
422422
/* complain every fifth interval */
423423
if ((ntries % LOG_FREQ) == 0)
424424
{
425-
elog(WARNING, "Process %d is using backup %s, and is still running",
426-
encoded_pid, backup_id);
425+
elog(WARNING, "Process %lld is using backup %s, and is still running",
426+
(long long)encoded_pid, backup_id);
427427

428428
elog(WARNING, "Waiting %u seconds on exclusive lock for backup %s",
429429
ntries, backup_id);
@@ -437,8 +437,8 @@ grab_excl_lock_file(const char *root_dir, const char *backup_id, bool strict)
437437
else
438438
{
439439
if (errno == ESRCH)
440-
elog(WARNING, "Process %d which used backup %s no longer exists",
441-
encoded_pid, backup_id);
440+
elog(WARNING, "Process %lld which used backup %s no longer exists",
441+
(long long)encoded_pid, backup_id);
442442
else
443443
elog(ERROR, "Failed to send signal 0 to a process %d: %s",
444444
encoded_pid, strerror(errno));
@@ -467,7 +467,7 @@ grab_excl_lock_file(const char *root_dir, const char *backup_id, bool strict)
467467
/*
468468
* Successfully created the file, now fill it.
469469
*/
470-
snprintf(buffer, sizeof(buffer), "%d\n", my_pid);
470+
snprintf(buffer, sizeof(buffer), "%lld\n", (long long)my_pid);
471471

472472
errno = 0;
473473
if (fio_write(fd, buffer, strlen(buffer)) != strlen(buffer))
@@ -574,8 +574,8 @@ wait_shared_owners(pgBackup *backup)
574574
/* complain from time to time */
575575
if ((ntries % LOG_FREQ) == 0)
576576
{
577-
elog(WARNING, "Process %d is using backup %s in shared mode, and is still running",
578-
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));
579579

580580
elog(WARNING, "Waiting %u seconds on lock for backup %s", ntries,
581581
base36enc(backup->start_time));
@@ -587,8 +587,8 @@ wait_shared_owners(pgBackup *backup)
587587
continue;
588588
}
589589
else if (errno != ESRCH)
590-
elog(ERROR, "Failed to send signal 0 to a process %d: %s",
591-
encoded_pid, strerror(errno));
590+
elog(ERROR, "Failed to send signal 0 to a process %lld: %s",
591+
(long long)encoded_pid, strerror(errno));
592592

593593
/* locker is dead */
594594
break;
@@ -605,8 +605,8 @@ wait_shared_owners(pgBackup *backup)
605605
/* some shared owners are still alive */
606606
if (ntries <= 0)
607607
{
608-
elog(WARNING, "Cannot to lock backup %s in exclusive mode, because process %u owns shared lock",
609-
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);
610610
return 1;
611611
}
612612

@@ -661,11 +661,11 @@ grab_shared_lock_file(pgBackup *backup)
661661
* Somebody is still using this backup in shared mode,
662662
* copy this pid into a new file.
663663
*/
664-
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);
665665
}
666666
else if (errno != ESRCH)
667-
elog(ERROR, "Failed to send signal 0 to a process %d: %s",
668-
encoded_pid, strerror(errno));
667+
elog(ERROR, "Failed to send signal 0 to a process %lld: %s",
668+
(long long)encoded_pid, strerror(errno));
669669
}
670670

671671
if (fp_in)
@@ -685,7 +685,7 @@ grab_shared_lock_file(pgBackup *backup)
685685
}
686686

687687
/* add my own pid */
688-
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);
689689

690690
/* write out the collected PIDs to temp lock file */
691691
fwrite(buffer, 1, buffer_len, fp_out);
@@ -783,11 +783,11 @@ release_shared_lock_file(const char *backup_dir)
783783
* Somebody is still using this backup in shared mode,
784784
* copy this pid into a new file.
785785
*/
786-
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);
787787
}
788788
else if (errno != ESRCH)
789-
elog(ERROR, "Failed to send signal 0 to a process %d: %s",
790-
encoded_pid, strerror(errno));
789+
elog(ERROR, "Failed to send signal 0 to a process %lld: %s",
790+
(long long)encoded_pid, strerror(errno));
791791
}
792792

793793
if (ferror(fp_in))

src/catchup.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ catchup_preflight_checks(PGNodeInfo *source_node_info, PGconn *source_conn,
137137
}
138138
else if (pid > 1) /* postmaster is up */
139139
{
140-
elog(ERROR, "Postmaster with pid %u is running in destination directory \"%s\"",
141-
pid, dest_pgdata);
140+
elog(ERROR, "Postmaster with pid %lld is running in destination directory \"%s\"",
141+
(long long)pid, dest_pgdata);
142142
}
143143
}
144144

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

162162
if (source_conn_id != source_id)
163-
elog(ERROR, "Database identifiers mismatch: we connected to DB id %lu, but in \"%s\" we found id %lu",
164-
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);
165165

166166
if (current.backup_mode != BACKUP_MODE_FULL)
167167
{
168168
dest_id = get_system_identifier(FIO_LOCAL_HOST, dest_pgdata, false);
169169
if (source_conn_id != dest_id)
170-
elog(ERROR, "Database identifiers mismatch: we connected to DB id %lu, but in \"%s\" we found id %lu",
171-
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);
172172
}
173173
}
174174

@@ -439,7 +439,7 @@ catchup_thread_runner(void *arg)
439439

440440
if (file->write_size == BYTES_INVALID)
441441
{
442-
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);
443443
continue;
444444
}
445445

src/data.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@ get_header_errormsg(Page page, char **errormsg)
204204

205205
if (PageGetPageSize(phdr) != BLCKSZ)
206206
snprintf(*errormsg, ERRMSG_MAX_LEN, "page header invalid, "
207-
"page size %lu is not equal to block size %u",
207+
"page size %zu is not equal to block size %u",
208208
PageGetPageSize(phdr), BLCKSZ);
209209

210210
else if (phdr->pd_lower < SizeOfPageHeaderData)
211211
snprintf(*errormsg, ERRMSG_MAX_LEN, "page header invalid, "
212-
"pd_lower %i is less than page header size %lu",
212+
"pd_lower %i is less than page header size %zu",
213213
phdr->pd_lower, SizeOfPageHeaderData);
214214

215215
else if (phdr->pd_lower > phdr->pd_upper)
@@ -229,7 +229,7 @@ get_header_errormsg(Page page, char **errormsg)
229229

230230
else if (phdr->pd_special != MAXALIGN(phdr->pd_special))
231231
snprintf(*errormsg, ERRMSG_MAX_LEN, "page header invalid, "
232-
"pd_special %i is misaligned, expected %lu",
232+
"pd_special %i is misaligned, expected %zu",
233233
phdr->pd_special, MAXALIGN(phdr->pd_special));
234234

235235
else if (phdr->pd_flags & ~PD_VALID_FLAG_BITS)
@@ -1196,7 +1196,7 @@ restore_data_file_internal(FILE *in, FILE *out, pgFile *file, uint32 backup_vers
11961196
datapagemap_add(map, blknum);
11971197
}
11981198

1199-
elog(LOG, "Copied file \"%s\": %lu bytes", from_fullpath, write_len);
1199+
elog(LOG, "Copied file \"%s\": %zu bytes", from_fullpath, write_len);
12001200
return write_len;
12011201
}
12021202

@@ -1240,7 +1240,7 @@ restore_non_data_file_internal(FILE *in, FILE *out, pgFile *file,
12401240

12411241
pg_free(buf);
12421242

1243-
elog(LOG, "Copied file \"%s\": %lu bytes", from_fullpath, file->write_size);
1243+
elog(LOG, "Copied file \"%s\": %llu bytes", from_fullpath, (long long)file->write_size);
12441244
}
12451245

12461246
size_t
@@ -1317,9 +1317,9 @@ restore_non_data_file(parray *parent_chain, pgBackup *dest_backup,
13171317
elog(ERROR, "Failed to locate a full copy of non-data file \"%s\"", to_fullpath);
13181318

13191319
if (tmp_file->write_size <= 0)
1320-
elog(ERROR, "Full copy of non-data file has invalid size: %li. "
1320+
elog(ERROR, "Full copy of non-data file has invalid size: %lli. "
13211321
"Metadata corruption in backup %s in file: \"%s\"",
1322-
tmp_file->write_size, base36enc(tmp_backup->start_time),
1322+
(long long)tmp_file->write_size, base36enc(tmp_backup->start_time),
13231323
to_fullpath);
13241324

13251325
/* incremental restore */
@@ -2031,11 +2031,11 @@ get_page_header(FILE *in, const char *fullpath, BackupPageHeader* bph,
20312031
return false; /* EOF found */
20322032
else if (read_len != 0 && feof(in))
20332033
elog(ERROR,
2034-
"Odd size page found at offset %ld of \"%s\"",
2035-
ftello(in), fullpath);
2034+
"Odd size page found at offset %lld of \"%s\"",
2035+
(long long)ftello(in), fullpath);
20362036
else
2037-
elog(ERROR, "Cannot read header at offset %ld of \"%s\": %s",
2038-
ftello(in), fullpath, strerror(errno));
2037+
elog(ERROR, "Cannot read header at offset %lld of \"%s\": %s",
2038+
(long long)ftello(in), fullpath, strerror(errno));
20392039
}
20402040

20412041
/* In older versions < 2.4.0, when crc for file was calculated, header was
@@ -2335,8 +2335,8 @@ copy_pages(const char *to_fullpath, const char *from_fullpath,
23352335
to_fullpath, strerror(errno));
23362336

23372337
if (ftruncate(fileno(out), file->size) == -1)
2338-
elog(ERROR, "Cannot ftruncate file \"%s\" to size %lu: %s",
2339-
to_fullpath, file->size, strerror(errno));
2338+
elog(ERROR, "Cannot ftruncate file \"%s\" to size %llu: %s",
2339+
to_fullpath, (long long)file->size, strerror(errno));
23402340
}
23412341
}
23422342

@@ -2443,7 +2443,7 @@ get_data_file_headers(HeaderMap *hdr_map, pgFile *file, uint32 backup_version, b
24432443
if (hdr_crc != file->hdr_crc)
24442444
{
24452445
elog(strict ? ERROR : WARNING, "Header map for file \"%s\" crc mismatch \"%s\" "
2446-
"offset: %llu, len: %lu, current: %u, expected: %u",
2446+
"offset: %llu, len: %zu, current: %u, expected: %u",
24472447
file->rel_path, hdr_map->path, file->hdr_off, read_len, hdr_crc, file->hdr_crc);
24482448
goto cleanup;
24492449
}

src/merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ merge_files(void *arg)
957957
if (S_ISDIR(dest_file->mode))
958958
goto done;
959959

960-
elog(progress ? INFO : LOG, "Progress: (%d/%lu). Merging file \"%s\"",
960+
elog(progress ? INFO : LOG, "Progress: (%d/%zu). Merging file \"%s\"",
961961
i + 1, n_files, dest_file->rel_path);
962962

963963
if (dest_file->is_datafile && !dest_file->is_cfs)

src/restore.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,14 +1104,14 @@ static void *
11041104
restore_files(void *arg)
11051105
{
11061106
int i;
1107-
uint64 n_files;
1107+
size_t n_files;
11081108
char to_fullpath[MAXPGPATH];
11091109
FILE *out = NULL;
11101110
char *out_buf = pgut_malloc(STDIO_BUFSIZE);
11111111

11121112
restore_files_arg *arguments = (restore_files_arg *) arg;
11131113

1114-
n_files = (unsigned long) parray_num(arguments->dest_files);
1114+
n_files = parray_num(arguments->dest_files);
11151115

11161116
for (i = 0; i < parray_num(arguments->dest_files); i++)
11171117
{
@@ -1132,7 +1132,7 @@ restore_files(void *arg)
11321132
if (interrupted || thread_interrupted)
11331133
elog(ERROR, "Interrupted during restore");
11341134

1135-
elog(progress ? INFO : LOG, "Progress: (%d/%lu). Restore file \"%s\"",
1135+
elog(progress ? INFO : LOG, "Progress: (%d/%zu). Restore file \"%s\"",
11361136
i + 1, n_files, dest_file->rel_path);
11371137

11381138
/* Only files from pgdata can be skipped by partial restore */
@@ -2173,8 +2173,8 @@ check_incremental_compatibility(const char *pgdata, uint64 system_identifier,
21732173
}
21742174
else if (pid > 1) /* postmaster is up */
21752175
{
2176-
elog(WARNING, "Postmaster with pid %u is running in destination directory \"%s\"",
2177-
pid, pgdata);
2176+
elog(WARNING, "Postmaster with pid %llu is running in destination directory \"%s\"",
2177+
(long long)pid, pgdata);
21782178
success = false;
21792179
postmaster_is_up = true;
21802180
}
@@ -2197,9 +2197,9 @@ check_incremental_compatibility(const char *pgdata, uint64 system_identifier,
21972197
if (system_id_pgdata == instance_config.system_identifier)
21982198
system_id_match = true;
21992199
else
2200-
elog(WARNING, "Backup catalog was initialized for system id %lu, "
2201-
"but destination directory system id is %lu",
2202-
system_identifier, system_id_pgdata);
2200+
elog(WARNING, "Backup catalog was initialized for system id %llu, "
2201+
"but destination directory system id is %llu",
2202+
(long long)system_identifier, (long long)system_id_pgdata);
22032203

22042204
/*
22052205
* TODO: maybe there should be some other signs, pointing to pg_control

src/show.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ show_archive_plain(const char *instance_name, uint32 xlog_seg_size,
910910
cur++;
911911

912912
/* N files */
913-
snprintf(row->n_segments, lengthof(row->n_segments), "%lu",
913+
snprintf(row->n_segments, lengthof(row->n_segments), "%zu",
914914
tlinfo->n_xlog_files);
915915
widths[cur] = Max(widths[cur], strlen(row->n_segments));
916916
cur++;
@@ -930,7 +930,7 @@ show_archive_plain(const char *instance_name, uint32 xlog_seg_size,
930930
cur++;
931931

932932
/* N backups */
933-
snprintf(row->n_backups, lengthof(row->n_backups), "%lu",
933+
snprintf(row->n_backups, lengthof(row->n_backups), "%zu",
934934
tlinfo->backups?parray_num(tlinfo->backups):0);
935935
widths[cur] = Max(widths[cur], strlen(row->n_backups));
936936
cur++;
@@ -1086,10 +1086,10 @@ show_archive_json(const char *instance_name, uint32 xlog_seg_size,
10861086
json_add_value(buf, "max-segno", tmp_buf, json_level, true);
10871087

10881088
json_add_key(buf, "n-segments", json_level);
1089-
appendPQExpBuffer(buf, "%lu", tlinfo->n_xlog_files);
1089+
appendPQExpBuffer(buf, "%zu", tlinfo->n_xlog_files);
10901090

10911091
json_add_key(buf, "size", json_level);
1092-
appendPQExpBuffer(buf, "%lu", tlinfo->size);
1092+
appendPQExpBuffer(buf, "%zu", tlinfo->size);
10931093

10941094
json_add_key(buf, "zratio", json_level);
10951095

0 commit comments

Comments
 (0)