Fix patch errors for postgresql

This commit is contained in:
Yaksh Bariya 2021-06-17 14:16:08 +05:30 committed by Leonid Pliushch
parent 9d7b06bbea
commit 02c27cff27
2 changed files with 49 additions and 143 deletions

View File

@ -1,12 +1,11 @@
diff -uNr postgresql-13.0/contrib/pg_trgm/trgm_regexp.c postgresql-13.0.mod/contrib/pg_trgm/trgm_regexp.c
--- postgresql-13.0/contrib/pg_trgm/trgm_regexp.c 2020-09-21 23:47:36.000000000 +0300
+++ postgresql-13.0.mod/contrib/pg_trgm/trgm_regexp.c 2020-10-19 21:31:14.749878910 +0300
--- ./contrib/pg_trgm/trgm_regexp.c 2021-05-11 02:11:42.000000000 +0530
+++ ./contrib/pg_trgm/trgm_regexp.c.mod 2021-06-17 12:12:01.025156011 +0530
@@ -2173,7 +2173,7 @@
{
/* dot -Tpng -o /tmp/source.png < /tmp/source.gv */
- FILE *fp = fopen("/tmp/source.gv", "w");
+ FILE *fp = fopen("@TERMUX_PREFIX@/tmp/source.gv", "w");
+ FILE *fp = fopen("@TERMUX_PREFIX@/source.gv", "w");
fprintf(fp, "%s", buf.data);
fclose(fp);
@ -15,7 +14,7 @@ diff -uNr postgresql-13.0/contrib/pg_trgm/trgm_regexp.c postgresql-13.0.mod/cont
{
/* dot -Tpng -o /tmp/transformed.png < /tmp/transformed.gv */
- FILE *fp = fopen("/tmp/transformed.gv", "w");
+ FILE *fp = fopen("@TERMUX_PREFIX@/tmp/transformed.gv", "w");
+ FILE *fp = fopen("@TERMUX_PREFIX@/transformed.gv", "w");
fprintf(fp, "%s", buf.data);
fclose(fp);
@ -24,13 +23,12 @@ diff -uNr postgresql-13.0/contrib/pg_trgm/trgm_regexp.c postgresql-13.0.mod/cont
{
/* dot -Tpng -o /tmp/packed.png < /tmp/packed.gv */
- FILE *fp = fopen("/tmp/packed.gv", "w");
+ FILE *fp = fopen("@TERMUX_PREFIX@/tmp/packed.gv", "w");
+ FILE *fp = fopen("@TERMUX_PREFIX@/packed.gv", "w");
fprintf(fp, "%s", buf.data);
fclose(fp);
diff -uNr postgresql-13.0/src/bin/initdb/initdb.c postgresql-13.0.mod/src/bin/initdb/initdb.c
--- postgresql-13.0/src/bin/initdb/initdb.c 2020-09-21 23:47:36.000000000 +0300
+++ postgresql-13.0.mod/src/bin/initdb/initdb.c 2020-10-19 21:31:14.749878910 +0300
--- ./src/bin/initdb/initdb.c 2021-05-11 02:11:42.000000000 +0530
+++ ./src/bin/initdb/initdb.c.mod 2021-06-17 12:16:34.435155906 +0530
@@ -1095,7 +1095,7 @@
#else
snprintf(repltok, sizeof(repltok), "#unix_socket_directories = ''");
@ -40,22 +38,20 @@ diff -uNr postgresql-13.0/src/bin/initdb/initdb.c postgresql-13.0.mod/src/bin/in
repltok);
#if DEF_PGPORT != 5432
diff -uNr postgresql-13.0/src/bin/pg_ctl/pg_ctl.c postgresql-13.0.mod/src/bin/pg_ctl/pg_ctl.c
--- postgresql-13.0/src/bin/pg_ctl/pg_ctl.c 2020-09-21 23:47:36.000000000 +0300
+++ postgresql-13.0.mod/src/bin/pg_ctl/pg_ctl.c 2020-10-19 21:31:14.749878910 +0300
--- ./src/bin/pg_ctl/pg_ctl.c 2021-05-11 02:11:42.000000000 +0530
+++ ./src/bin/pg_ctl/pg_ctl.c.mod 2021-06-17 12:18:58.955155851 +0530
@@ -494,7 +494,7 @@
snprintf(cmd, MAXPGPATH, "exec \"%s\" %s%s < \"%s\" 2>&1",
exec_path, pgdata_opt, post_opts, DEVNULL);
- (void) execl("/bin/sh", "/bin/sh", "-c", cmd, (char *) NULL);
+ (void) execl("@TERMUX_PREFIX@/bin/sh", "sh", "-c", cmd, (char *) NULL);
+ (void) execl("@TERMUX_PREFIX@/bin/sh", "@TERMUX_PREFIX@/bin/sh", "-c", cmd, (char *) NULL);
/* exec failed */
write_stderr(_("%s: could not start server: %s\n"),
diff -uNr postgresql-13.0/src/bin/pg_upgrade/check.c postgresql-13.0.mod/src/bin/pg_upgrade/check.c
--- postgresql-13.0/src/bin/pg_upgrade/check.c 2020-09-21 23:47:36.000000000 +0300
+++ postgresql-13.0.mod/src/bin/pg_upgrade/check.c 2020-10-19 21:31:14.753878949 +0300
@@ -474,7 +474,7 @@
--- ./src/bin/pg_upgrade/check.c 2021-05-11 02:11:42.000000000 +0530
+++ ./src/bin/pg_upgrade/check.c.mod 2021-06-17 12:21:44.835155788 +0530
@@ -471,7 +471,7 @@
#ifndef WIN32
/* add shebang header */
@ -64,7 +60,7 @@ diff -uNr postgresql-13.0/src/bin/pg_upgrade/check.c postgresql-13.0.mod/src/bin
#else
/* suppress command echoing */
fprintf(script, "@echo off\n");
@@ -602,7 +602,7 @@
@@ -630,7 +630,7 @@
#ifndef WIN32
/* add shebang header */
@ -73,10 +69,9 @@ diff -uNr postgresql-13.0/src/bin/pg_upgrade/check.c postgresql-13.0.mod/src/bin
#endif
/* delete old cluster's default tablespace */
diff -uNr postgresql-13.0/src/bin/psql/command.c postgresql-13.0.mod/src/bin/psql/command.c
--- postgresql-13.0/src/bin/psql/command.c 2020-09-21 23:47:36.000000000 +0300
+++ postgresql-13.0.mod/src/bin/psql/command.c 2020-10-19 21:31:14.753878949 +0300
@@ -3577,7 +3577,7 @@
--- ./src/bin/psql/command.c 2021-05-11 02:11:42.000000000 +0530
+++ ./src/bin/psql/command.c.mod 2021-06-17 12:25:14.125155708 +0530
@@ -3707,7 +3707,7 @@
if (result == -1)
pg_log_error("could not start editor \"%s\"", editorName);
else if (result == 127)
@ -85,7 +80,7 @@ diff -uNr postgresql-13.0/src/bin/psql/command.c postgresql-13.0.mod/src/bin/psq
free(sys);
return result == 0;
@@ -3607,7 +3607,7 @@
@@ -3736,7 +3736,7 @@
const char *tmpdir = getenv("TMPDIR");
if (!tmpdir)
@ -94,7 +89,7 @@ diff -uNr postgresql-13.0/src/bin/psql/command.c postgresql-13.0.mod/src/bin/psq
#else
char tmpdir[MAXPGPATH];
int ret;
@@ -4590,7 +4590,7 @@
@@ -4740,7 +4740,7 @@
#ifndef WIN32
@ -103,10 +98,9 @@ diff -uNr postgresql-13.0/src/bin/psql/command.c postgresql-13.0.mod/src/bin/psq
#else
/*
* CMD.EXE is in different places in different Win32 releases so we
diff -uNr postgresql-13.0/src/include/pg_config_manual.h postgresql-13.0.mod/src/include/pg_config_manual.h
--- postgresql-13.0/src/include/pg_config_manual.h 2020-09-21 23:47:36.000000000 +0300
+++ postgresql-13.0.mod/src/include/pg_config_manual.h 2020-10-19 21:31:30.978039951 +0300
@@ -201,7 +201,7 @@
--- ./src/include/pg_config_manual.h 2021-05-11 02:11:42.000000000 +0530
+++ ./src/include/pg_config_manual.h.mod 2021-06-17 12:27:13.665155663 +0530
@@ -208,7 +208,7 @@
* support them yet.
*/
#ifndef WIN32

View File

@ -1,30 +1,6 @@
commit 1cdc12445daed554da8fcc4f02db367371a0abd8
Author: Henrik Grimler <henrik@grimler.se>
Date: Sun Oct 18 10:10:25 2020 +0200
Revert "Remove HAVE_WORKING_LINK"
This reverts commit aaa3aeddee51dd0058d38469907865052706a590.
Commit message:
Previously, hard links were not used on Windows and Cygwin, but they
support them just fine in currently supported OS versions, so we can
use them there as well.
Since all supported platforms now support hard links, we can remove
the alternative code paths.
Rename durable_link_or_rename() to durable_rename_excl() to make the
purpose more clear without referencing the implementation details.
Discussion: https://www.postgresql.org/message-id/flat/72fff73f-dc9c-4ef4-83e8-d2e60c98df48%402ndquadrant.com
diff --git a/src/backend/access/transam/timeline.c b/src/backend/access/transam/timeline.c
index e6a29d9a9b..27d70ff869 100644
--- a/src/backend/access/transam/timeline.c
+++ b/src/backend/access/transam/timeline.c
@@ -446,7 +446,7 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI,
--- ./src/backend/access/transam/timeline.c 2021-05-11 02:11:42.000000000 +0530
+++ ./src/backend/access/transam/timeline.c.mod 2021-06-17 13:56:32.191999896 +0530
@@ -446,7 +446,7 @@
* Perform the rename using link if available, paranoidly trying to avoid
* overwriting an existing file (there shouldn't be one).
*/
@ -33,7 +9,7 @@ index e6a29d9a9b..27d70ff869 100644
/* The history file can be archived immediately. */
if (XLogArchivingActive())
@@ -524,7 +524,7 @@ writeTimeLineHistoryFile(TimeLineID tli, char *content, int size)
@@ -524,7 +524,7 @@
* Perform the rename using link if available, paranoidly trying to avoid
* overwriting an existing file (there shouldn't be one).
*/
@ -42,11 +18,9 @@ index e6a29d9a9b..27d70ff869 100644
}
/*
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 52a67b1170..83c9de70c4 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -3625,11 +3625,11 @@ InstallXLogFileSegment(XLogSegNo *segno, char *tmppath,
--- ./src/backend/access/transam/xlog.c 2021-05-11 02:11:42.000000000 +0530
+++ ./src/backend/access/transam/xlog.c.mod 2021-06-17 13:58:47.831999844 +0530
@@ -3624,11 +3624,11 @@
* Perform the rename using link if available, paranoidly trying to avoid
* overwriting an existing file (there shouldn't be one).
*/
@ -60,26 +34,18 @@ index 52a67b1170..83c9de70c4 100644
return false;
}
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index bd72a87ee3..06fae0bb8c 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -768,11 +768,10 @@ durable_unlink(const char *fname, int elevel)
--- ./src/backend/storage/file/fd.c 2021-05-11 02:11:42.000000000 +0530
+++ ./src/backend/storage/file/fd.c.mod 2021-06-17 14:06:02.861999678 +0530
@@ -767,7 +767,7 @@
}
/*
- * durable_rename_excl -- rename a file in a durable manner, without
- * overwriting an existing target file
- * durable_rename_excl -- rename a file in a durable manner.
+ * durable_link_or_rename -- rename a file in a durable manner.
*
- * Similar to durable_rename(), except that this routine will fail if the
- * target file already exists.
+ * Similar to durable_rename(), except that this routine tries (but does not
+ * guarantee) not to overwrite the target file.
*
* Note that a crash in an unfortunate moment can leave you with two links to
* the target file.
@@ -783,7 +782,7 @@ durable_unlink(const char *fname, int elevel)
* Similar to durable_rename(), except that this routine tries (but does not
* guarantee) not to overwrite the target file.
@@ -785,7 +785,7 @@
* valid upon return.
*/
int
@ -88,73 +54,8 @@ index bd72a87ee3..06fae0bb8c 100644
{
/*
* Ensure that, if we crash directly after the rename/link, a file with
@@ -792,6 +791,7 @@ durable_rename_excl(const char *oldfile, const char *newfile, int elevel)
if (fsync_fname_ext(oldfile, false, false, elevel) != 0)
return -1;
+#ifdef HAVE_WORKING_LINK
if (link(oldfile, newfile) < 0)
{
ereport(elevel,
@@ -801,6 +801,17 @@ durable_rename_excl(const char *oldfile, const char *newfile, int elevel)
return -1;
}
unlink(oldfile);
+#else
+ /* XXX: Add racy file existence check? */
+ if (rename(oldfile, newfile) < 0)
+ {
+ ereport(elevel,
+ (errcode_for_file_access(),
+ errmsg("could not rename file \"%s\" to \"%s\": %m",
+ oldfile, newfile)));
+ return -1;
+ }
+#endif
/*
* Make change persistent in case of an OS crash, both the new entry and
diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h
index 705dc69c06..183bf7c8ff 100644
--- a/src/include/pg_config_manual.h
+++ b/src/include/pg_config_manual.h
@@ -135,6 +135,13 @@
#define EXEC_BACKEND
#endif
+/*
+ * Define this if your operating system supports link()
+ */
+#if !defined(WIN32) && !defined(__CYGWIN__)
+#define HAVE_WORKING_LINK 1
+#endif
+
/*
* USE_POSIX_FADVISE controls whether Postgres will attempt to use the
* posix_fadvise() kernel call. Usually the automatic configure tests are
diff --git a/src/include/storage/fd.h b/src/include/storage/fd.h
index e209f047e8..35244b88db 100644
--- a/src/include/storage/fd.h
+++ b/src/include/storage/fd.h
@@ -157,7 +157,7 @@ extern void fsync_fname(const char *fname, bool isdir);
extern int fsync_fname_ext(const char *fname, bool isdir, bool ignore_perm, int elevel);
extern int durable_rename(const char *oldfile, const char *newfile, int loglevel);
extern int durable_unlink(const char *fname, int loglevel);
-extern int durable_rename_excl(const char *oldfile, const char *newfile, int loglevel);
+extern int durable_link_or_rename(const char *oldfile, const char *newfile, int loglevel);
extern void SyncDataDirectory(void);
extern int data_sync_elevel(int elevel);
commit 85530dfd14cea5fa9f46d210db59d5280714421e
Author: Henrik Grimler <henrik@grimler.se>
Date: Sun Oct 18 10:13:42 2020 +0200
Do not use link on android
diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h
index 183bf7c8ff..3637b26e24 100644
--- a/src/include/pg_config_manual.h
+++ b/src/include/pg_config_manual.h
--- ./src/include/pg_config_manual.h 2021-05-11 02:11:42.000000000 +0530
+++ ./src/include/pg_config_manual.h.mod 2021-06-17 14:09:25.941999601 +0530
@@ -138,7 +138,7 @@
/*
* Define this if your operating system supports link()
@ -164,3 +65,14 @@ index 183bf7c8ff..3637b26e24 100644
#define HAVE_WORKING_LINK 1
#endif
--- ./src/include/storage/fd.h 2021-05-11 02:11:42.000000000 +0530
+++ ./src/include/storage/fd.h.mod 2021-06-17 14:13:22.074549249 +0530
@@ -157,7 +157,7 @@
extern int fsync_fname_ext(const char *fname, bool isdir, bool ignore_perm, int elevel);
extern int durable_rename(const char *oldfile, const char *newfile, int loglevel);
extern int durable_unlink(const char *fname, int loglevel);
-extern int durable_rename_excl(const char *oldfile, const char *newfile, int loglevel);
+extern int durable_link_or_rename(const char *oldfile, const char *newfile, int loglevel);
extern void SyncDataDirectory(void);
extern int data_sync_elevel(int elevel);