Skip to content

Compilation of version 2.6 windows port with MinGW64 UCRT environment. #540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Oct 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
822111e
[PBCKP-232] remove 9.5-9.6 support, part 1
kulaginm Jul 19, 2022
ae275dc
[PBCKP-232] remove 9.5-9.6 support, part 2
kulaginm Jul 19, 2022
5ed469d
[PBCKP-232] remove depricated options (master-db, master-host, master…
kulaginm Jul 20, 2022
a880b91
[PBCKP-232] makefile simplification
kulaginm Jul 20, 2022
249876a
[PBCKP-232] remove deprecated options (master-db, master-host, master…
kulaginm Aug 26, 2022
14781dd
Merge branch 'REL_2_6' into release_2_6-pbckp-232
kulaginm Aug 26, 2022
dcf52ee
[PBCKP-230] remove instr_time.h from borrowed filelist
kulaginm Aug 26, 2022
491452a
[PBCKP-256] remove src/backend/utils/hash/pg_crc.c borrowing
kulaginm Aug 27, 2022
f6a8381
Merge branch 'REL_2_6' into REL_2_6-PBCKP-256
kulaginm Sep 1, 2022
4b08603
[PBCKP-245] fu_utils: compilable under MinGW
funny-falcon Sep 12, 2022
5e1dd7e
[PBCKP-245] don't include libpq-int.h
funny-falcon Aug 15, 2022
3fa33c8
[PBCKP-245] mingw: no need to define custom sleep/usleep
funny-falcon Sep 12, 2022
2fd4757
[PBCKP-248] a bit more accurate ifdef
funny-falcon Sep 18, 2022
e180a36
[PBCKP-248] Use native mingw pthread
funny-falcon Sep 18, 2022
3acd1a7
[PBCKP-245] don't include sys/stat.h so often
funny-falcon Sep 13, 2022
ca6e394
[PBCKP-245] make Makefile more portable
funny-falcon Sep 13, 2022
085b99f
[PBCKP-245] more mingw compatibility
funny-falcon Sep 15, 2022
0e85c52
[PBCKP-245] mingw: ucrt strftime is good enough
funny-falcon Sep 19, 2022
0e0027b
[PBCKP-245] fix EACCES usage
funny-falcon Sep 20, 2022
ccee8ab
Merge branch 'REL_2_6-PBCKP-256' into REL_2_6-PBCKP-245-mingw
funny-falcon Oct 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,28 @@ OBJS := src/utils/configuration.o src/utils/json.o src/utils/logger.o \
OBJS += src/archive.o src/backup.o src/catalog.o src/checkdb.o src/configure.o src/data.o \
src/delete.o src/dir.o src/fetch.o src/help.o src/init.o src/merge.o \
src/parsexlog.o src/ptrack.o src/pg_probackup.o src/restore.o src/show.o src/stream.o \
src/util.o src/validate.o src/datapagemap.o src/catchup.o
src/util.o src/validate.o src/datapagemap.o src/catchup.o \
src/compatibility/pg-11.o

# sources borrowed from postgresql (paths are relative to pg top dir)
BORROWED_H_SRC := \
src/include/portability/instr_time.h \
src/bin/pg_basebackup/receivelog.h \
src/bin/pg_basebackup/streamutil.h \
src/bin/pg_basebackup/walmethods.h
BORROWED_C_SRC := \
src/backend/access/transam/xlogreader.c \
src/backend/utils/hash/pg_crc.c \
src/bin/pg_basebackup/receivelog.c \
src/bin/pg_basebackup/streamutil.c \
src/bin/pg_basebackup/walmethods.c

OBJS += src/fu_util/impl/ft_impl.o src/fu_util/impl/fo_impl.o

BORROW_DIR := src/borrowed
BORROWED_H := $(addprefix $(BORROW_DIR)/, $(notdir $(BORROWED_H_SRC)))
BORROWED_C := $(addprefix $(BORROW_DIR)/, $(notdir $(BORROWED_C_SRC)))
OBJS += $(patsubst %.c, %.o, $(BORROWED_C))
EXTRA_CLEAN := $(BORROWED_H) $(BORROWED_C) $(BORROW_DIR) borrowed.mk

OBJS += src/fu_util/impl/ft_impl.o src/fu_util/impl/fo_impl.o

# off-source build support
ifneq ($(abspath $(CURDIR))/, $(top_pbk_srcdir))
VPATH := $(top_pbk_srcdir)
Expand Down Expand Up @@ -87,7 +86,6 @@ override CPPFLAGS := -DFRONTEND $(CPPFLAGS) $(PG_CPPFLAGS)
PG_LIBS_INTERNAL = $(libpq_pgport) ${PTHREAD_CFLAGS}

# additional dependencies on borrowed files
src/archive.o: $(BORROW_DIR)/instr_time.h
src/backup.o src/catchup.o src/pg_probackup.o: $(BORROW_DIR)/streamutil.h
src/stream.o $(BORROW_DIR)/receivelog.o $(BORROW_DIR)/streamutil.o $(BORROW_DIR)/walmethods.o: $(BORROW_DIR)/receivelog.h
$(BORROW_DIR)/receivelog.h: $(BORROW_DIR)/walmethods.h
Expand All @@ -97,7 +95,7 @@ borrowed.mk: $(firstword $(MAKEFILE_LIST))
$(file >$@,# This file is autogenerated. Do not edit!)
$(foreach borrowed_file, $(BORROWED_H_SRC) $(BORROWED_C_SRC), \
$(file >>$@,$(addprefix $(BORROW_DIR)/, $(notdir $(borrowed_file))): | $(CURDIR)/$(BORROW_DIR)/ $(realpath $(top_srcdir)/$(borrowed_file))) \
$(file >>$@,$(shell echo "\t"'$$(LN_S) $(realpath $(top_srcdir)/$(borrowed_file)) $$@')) \
$(file >>$@,$(shell echo " "'$$(LN_S) $(realpath $(top_srcdir)/$(borrowed_file)) $$@')) \
)
include borrowed.mk

Expand Down
16 changes: 8 additions & 8 deletions src/archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <unistd.h>
#include "pg_probackup.h"
#include "utils/thread.h"
#include "instr_time.h"
#include "portability/instr_time.h"

static int push_file_internal(const char *wal_file_name,
const char *pg_xlog_dir,
Expand Down Expand Up @@ -148,7 +148,7 @@ do_archive_push(InstanceState *instanceState, InstanceConfig *instance, char *pg
n_threads = parray_num(batch_files);

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

my_thread_num = args->thread_num;
set_my_thread_num(args->thread_num);

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

/* enable streaming compression */
if (is_compress)
#ifdef HAVE_LIBZ
{
#ifdef HAVE_LIBZ
pioFilter_i flt = pioGZCompressFilter(compress_level);
err = pioCopy($reduce(pioWriteFlush, out),
$reduce(pioRead, in),
flt);
}
else
#else
elog(ERROR, "Compression is requested, but not compiled it");
elog(ERROR, "Compression is requested, but not compiled it");
#endif
}
else
{
err = pioCopy($reduce(pioWriteFlush, out),
$reduce(pioRead, in));
Expand Down Expand Up @@ -1011,7 +1011,7 @@ get_files(void *arg)
char from_fullpath[MAXPGPATH];
archive_get_arg *args = (archive_get_arg *) arg;

my_thread_num = args->thread_num;
set_my_thread_num(args->thread_num);

for (i = 0; i < parray_num(args->files); i++)
{
Expand Down
7 changes: 4 additions & 3 deletions src/backup.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "pgtar.h"
#include "streamutil.h"

#include <sys/stat.h>
#include <time.h>
#include <unistd.h>

Expand Down Expand Up @@ -1725,7 +1724,7 @@ pg_stop_backup_write_file_helper(const char *path, const char *filename, const c

if (S_ISREG(file->mode))
{
file->crc = pgFileGetCRC(full_filename, true, false);
file->crc = pgFileGetCRC32C(full_filename, false);

file->write_size = file->size;
file->uncompressed_size = file->size;
Expand Down Expand Up @@ -2179,6 +2178,7 @@ check_external_for_tablespaces(parray *external_list, PGconn *backup_conn)
PGresult *res;
int i = 0;
int j = 0;
int ntups;
char *tablespace_path = NULL;
char *query = "SELECT pg_catalog.pg_tablespace_location(oid) "
"FROM pg_catalog.pg_tablespace "
Expand All @@ -2190,7 +2190,8 @@ check_external_for_tablespaces(parray *external_list, PGconn *backup_conn)
if (!res)
elog(ERROR, "Failed to get list of tablespaces");

for (i = 0; i < res->ntups; i++)
ntups = PQntuples(res);
for (i = 0; i < ntups; i++)
{
tablespace_path = PQgetvalue(res, i, 0);
Assert (strlen(tablespace_path) > 0);
Expand Down
49 changes: 24 additions & 25 deletions src/catalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#include <dirent.h>
#include <signal.h>
#include <sys/stat.h>
#include <unistd.h>

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

elog(WARNING, "Waiting %u seconds on exclusive lock for backup %s",
ntries, backup_id);
Expand All @@ -438,8 +437,8 @@ grab_excl_lock_file(const char *root_dir, const char *backup_id, bool strict)
else
{
if (errno == ESRCH)
elog(WARNING, "Process %d which used backup %s no longer exists",
encoded_pid, backup_id);
elog(WARNING, "Process %lld which used backup %s no longer exists",
(long long)encoded_pid, backup_id);
else
elog(ERROR, "Failed to send signal 0 to a process %d: %s",
encoded_pid, strerror(errno));
Expand Down Expand Up @@ -468,7 +467,7 @@ grab_excl_lock_file(const char *root_dir, const char *backup_id, bool strict)
/*
* Successfully created the file, now fill it.
*/
snprintf(buffer, sizeof(buffer), "%d\n", my_pid);
snprintf(buffer, sizeof(buffer), "%lld\n", (long long)my_pid);

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

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

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

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

if (fp_in)
Expand All @@ -686,7 +685,7 @@ grab_shared_lock_file(pgBackup *backup)
}

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

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

if (ferror(fp_in))
Expand Down Expand Up @@ -1067,7 +1066,7 @@ get_backup_filelist(pgBackup *backup, bool strict)

files = parray_new();

INIT_FILE_CRC32(true, content_crc);
INIT_CRC32C(content_crc);

while (fgets(buf, lengthof(buf), fp))
{
Expand All @@ -1089,7 +1088,7 @@ get_backup_filelist(pgBackup *backup, bool strict)
hdr_size;
pgFile *file;

COMP_FILE_CRC32(true, content_crc, buf, strlen(buf));
COMP_CRC32C(content_crc, buf, strlen(buf));

get_control_value_str(buf, "path", path, sizeof(path),true);
get_control_value_int64(buf, "size", &write_size, true);
Expand Down Expand Up @@ -1141,7 +1140,7 @@ get_backup_filelist(pgBackup *backup, bool strict)
parray_append(files, file);
}

FIN_FILE_CRC32(true, content_crc);
FIN_CRC32C(content_crc);

if (ferror(fp))
elog(ERROR, "Failed to read from file: \"%s\"", backup_filelist_path);
Expand Down Expand Up @@ -2538,7 +2537,7 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
setvbuf(out, buf, _IOFBF, BUFFERSZ);

if (sync)
INIT_FILE_CRC32(true, backup->content_crc);
INIT_CRC32C(backup->content_crc);

/* print each file in the list */
for (i = 0; i < parray_num(files); i++)
Expand Down Expand Up @@ -2606,13 +2605,13 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
sprintf(line+len, "}\n");

if (sync)
COMP_FILE_CRC32(true, backup->content_crc, line, strlen(line));
COMP_CRC32C(backup->content_crc, line, strlen(line));

fprintf(out, "%s", line);
}

if (sync)
FIN_FILE_CRC32(true, backup->content_crc);
FIN_CRC32C(backup->content_crc);

if (fflush(out) != 0)
elog(ERROR, "Cannot flush file list \"%s\": %s",
Expand Down
19 changes: 10 additions & 9 deletions src/catchup.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "pgtar.h"
#include "streamutil.h"

#include <sys/stat.h>
#include <time.h>
#include <unistd.h>

Expand Down Expand Up @@ -138,8 +137,8 @@ catchup_preflight_checks(PGNodeInfo *source_node_info, PGconn *source_conn,
}
else if (pid > 1) /* postmaster is up */
{
elog(ERROR, "Postmaster with pid %u is running in destination directory \"%s\"",
pid, dest_pgdata);
elog(ERROR, "Postmaster with pid %lld is running in destination directory \"%s\"",
(long long)pid, dest_pgdata);
}
}

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

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

if (current.backup_mode != BACKUP_MODE_FULL)
{
dest_id = get_system_identifier(FIO_LOCAL_HOST, dest_pgdata, false);
if (source_conn_id != dest_id)
elog(ERROR, "Database identifiers mismatch: we connected to DB id %lu, but in \"%s\" we found id %lu",
source_conn_id, dest_pgdata, dest_id);
elog(ERROR, "Database identifiers mismatch: we connected to DB id %llu, but in \"%s\" we found id %llu",
(long long)source_conn_id, dest_pgdata, (long long)dest_id);
}
}

Expand Down Expand Up @@ -230,6 +229,7 @@ catchup_check_tablespaces_existance_in_tbsmapping(PGconn *conn)
{
PGresult *res;
int i;
int ntups;
char *tablespace_path = NULL;
const char *linked_path = NULL;
char *query = "SELECT pg_catalog.pg_tablespace_location(oid) "
Expand All @@ -241,7 +241,8 @@ catchup_check_tablespaces_existance_in_tbsmapping(PGconn *conn)
if (!res)
elog(ERROR, "Failed to get list of tablespaces");

for (i = 0; i < res->ntups; i++)
ntups = PQntuples(res);
for (i = 0; i < ntups; i++)
{
tablespace_path = PQgetvalue(res, i, 0);
Assert (strlen(tablespace_path) > 0);
Expand Down Expand Up @@ -438,7 +439,7 @@ catchup_thread_runner(void *arg)

if (file->write_size == BYTES_INVALID)
{
elog(LOG, "Skipping the unchanged file: \"%s\", read %li bytes", from_fullpath, file->read_size);
elog(LOG, "Skipping the unchanged file: \"%s\", read %zu bytes", from_fullpath, file->read_size);
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions src/checkdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include "pg_probackup.h"

#include <sys/stat.h>
#include <time.h>
#include <unistd.h>

Expand Down Expand Up @@ -293,7 +292,8 @@ check_indexes(void *arg)
int i;
check_indexes_arg *arguments = (check_indexes_arg *) arg;
int n_indexes = 0;
my_thread_num = arguments->thread_num;

set_my_thread_num(arguments->thread_num);

if (arguments->index_list)
n_indexes = parray_num(arguments->index_list);
Expand Down
Loading