From af50e4605516f6f2ff0f38e7a0612f7fd5f0a8a2 Mon Sep 17 00:00:00 2001 From: zw_yan <106359229+zwyan0@users.noreply.github.com> Date: Mon, 27 Nov 2023 18:27:43 +0900 Subject: [PATCH] Support PostgreSQL v16 (#255) * Support PostgreSQL v16 * Remove unnecessary variables --- .github/workflows/build.yml | 12 +++++++----- data.c | 22 +++++++++++----------- restore.c | 7 +++---- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 06f090e6..262bba5b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - REL_16_STABLE - REL_15_STABLE - REL_14_STABLE - REL_13_STABLE @@ -12,6 +13,7 @@ on: pull_request: branches: - master + - REL_16_STABLE - REL_15_STABLE - REL_14_STABLE - REL_13_STABLE @@ -41,11 +43,11 @@ jobs: shell: bash -xe {0} run: | declare -A versions=( - ["master"]="15.1" - ["REL_15_STABLE"]="15.1" - ["REL_14_STABLE"]="14.6" - ["REL_13_STABLE"]="13.9" - ["REL_12_STABLE"]="12.13" + ["master"]="16.1" + ["REL_15_STABLE"]="15.5" + ["REL_14_STABLE"]="14.10" + ["REL_13_STABLE"]="13.13" + ["REL_12_STABLE"]="12.17" ["REL_11_STABLE"]="11.18" ) [ -z "${versions[${{ env.BRANCH }}]}" ] && exit 1 # check if the key exists diff --git a/data.c b/data.c index 6ee2ffd4..353cc229 100644 --- a/data.c +++ b/data.c @@ -217,8 +217,8 @@ parse_page(int blkno, */ *lsn = PageXLogRecPtrGet(header->pd_lsn); - if (PageGetPageSize(header) == BLCKSZ && - PageGetPageLayoutVersion(header) == PG_PAGE_LAYOUT_VERSION && + if (PageGetPageSize(pagedata) == BLCKSZ && + PageGetPageLayoutVersion(pagedata) == PG_PAGE_LAYOUT_VERSION && (header->pd_flags & ~PD_VALID_FLAG_BITS) == 0 && header->pd_lower >= SizeOfPageHeaderData && header->pd_lower <= header->pd_upper && @@ -270,7 +270,7 @@ backup_data_file(const char *from_root, BlockNumber blknum; BlockNumber segno; size_t read_len; - int errno_tmp; + int errno_tmp = 0; pg_crc32c crc; #ifdef HAVE_LIBZ z_stream z; @@ -308,7 +308,7 @@ backup_data_file(const char *from_root, out = fopen(to_path, "w"); if (out == NULL) { - int errno_tmp = errno; + errno_tmp = errno; fclose(in); ereport(ERROR, (errcode(ERROR_SYSTEM), @@ -417,7 +417,7 @@ backup_data_file(const char *from_root, fwrite(page.data, 1, header.hole_offset, out) != header.hole_offset || fwrite(page.data + upper_offset, 1, upper_length, out) != upper_length) { - int errno_tmp = errno; + errno_tmp = errno; /* oops */ fclose(in); fclose(out); @@ -474,7 +474,7 @@ backup_data_file(const char *from_root, { if (fwrite(&header, 1, sizeof(header), out) != sizeof(header)) { - int errno_tmp = errno; + errno_tmp = errno; /* oops */ fclose(in); fclose(out); @@ -498,7 +498,7 @@ backup_data_file(const char *from_root, { if (fwrite(page.data, 1, read_len, out) != read_len) { - int errno_tmp = errno; + errno_tmp = errno; /* oops */ fclose(in); fclose(out); @@ -539,7 +539,7 @@ backup_data_file(const char *from_root, { if (fwrite(&header, 1, sizeof(header), out) != sizeof(header)) { - int errno_tmp = errno; + errno_tmp = errno; /* oops */ fclose(in); fclose(out); @@ -588,7 +588,7 @@ backup_data_file(const char *from_root, */ if (!check && chmod(to_path, FILE_PERMISSION) == -1) { - int errno_tmp = errno; + errno_tmp = errno; fclose(in); fclose(out); @@ -879,7 +879,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file, FILE *in; FILE *out; size_t read_len = 0; - int errno_tmp; + int errno_tmp = 0; char buf[8192]; struct stat st; pg_crc32c crc; @@ -921,7 +921,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file, out = fopen(to_path, "w"); if (out == NULL) { - int errno_tmp = errno; + errno_tmp = errno; fclose(in); ereport(ERROR, (errcode(ERROR_SYSTEM), diff --git a/restore.c b/restore.c index 58a45806..5475c371 100644 --- a/restore.c +++ b/restore.c @@ -270,7 +270,7 @@ do_restore(const char *target_time, */ if (!check) { - int i; + int x; if (verbose) printf(_("----------------------------------------\n")); @@ -280,7 +280,7 @@ do_restore(const char *target_time, dir_list_file(files, pgdata, NULL, false, false); parray_qsort(files, pgFileComparePathDesc); /* delete from leaf */ - for (i = 0; i < parray_num(files); i++) + for (x = 0; x < parray_num(files); x++) { pgFile *file = (pgFile *) parray_get(files, i); pgFileDelete(file); @@ -1230,9 +1230,8 @@ readTimeLineHistory(TimeLineID targetTLI) elog(DEBUG, "the calculated branch history is as below;"); for (i = 0; i < parray_num(result); i++) { - pgTimeLine *timeline = parray_get(result, i); elog(DEBUG, "stage %d: timeline ID = %d", - (int)parray_num(result) - i, timeline->tli); + (int)parray_num(result) - i, ((pgTimeLine *)(parray_get(result,i)))->tli); } return result;