aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--testing/postgresql-pglogical/001-fix-stdin-handling.patch51
-rw-r--r--testing/postgresql-pglogical/APKBUILD11
2 files changed, 57 insertions, 5 deletions
diff --git a/testing/postgresql-pglogical/001-fix-stdin-handling.patch b/testing/postgresql-pglogical/001-fix-stdin-handling.patch
new file mode 100644
index 0000000000..8ba3f6c958
--- /dev/null
+++ b/testing/postgresql-pglogical/001-fix-stdin-handling.patch
@@ -0,0 +1,51 @@
+diff --git a/pglogical_apply_spi.c b/pglogical_apply_spi.c
+index 3eaccc4..111a4eb 100644
+--- a/pglogical_apply_spi.c
++++ b/pglogical_apply_spi.c
+@@ -454,7 +454,7 @@ static void
+ pglogical_proccess_copy(pglogical_copyState *pglcstate)
+ {
+ uint64 processed;
+- FILE *save_stdin;
++ int save_stdin;
+
+ if (!pglcstate->copy_parsetree || !pglcstate->copy_buffered_tuples)
+ return;
+@@ -489,8 +489,16 @@ pglogical_proccess_copy(pglogical_copyState *pglcstate)
+ * for this relation. Before that we save the current 'stdin' stream and
+ * restore it back when the COPY is done
+ */
+- save_stdin = stdin;
+- stdin = pglcstate->copy_read_file;
++ save_stdin = dup(fileno(stdin));
++ if (save_stdin < 0)
++ ereport(FATAL,
++ (errcode_for_file_access(),
++ errmsg("could not save stdin: %m")));
++
++ if (dup2(fileno(pglcstate->copy_read_file), fileno(stdin)) < 0)
++ ereport(FATAL,
++ (errcode_for_file_access(),
++ errmsg("could not redirect stdin: %m")));
+
+ /* COPY may call into SPI (triggers, ...) and we already are in SPI. */
+ SPI_push();
+@@ -501,10 +509,17 @@ pglogical_proccess_copy(pglogical_copyState *pglcstate)
+
+ /* Clean up SPI state */
+ SPI_pop();
++ /*
++ * Also close the read end of the pipe and restore 'stdin' to its original
++ * value
++ */
++ if (dup2(save_stdin, fileno(stdin)) < 0)
++ ereport(FATAL,
++ (errcode_for_file_access(),
++ errmsg("could not restore stdin: %m")));
+
+ fclose(pglcstate->copy_read_file);
+ pglcstate->copy_read_file = NULL;
+- stdin = save_stdin;
+
+ /* Ensure we processed correct number of tuples */
+ Assert(processed == pglcstate->copy_buffered_tuples);
diff --git a/testing/postgresql-pglogical/APKBUILD b/testing/postgresql-pglogical/APKBUILD
index cd3986957f..97b3b89cb4 100644
--- a/testing/postgresql-pglogical/APKBUILD
+++ b/testing/postgresql-pglogical/APKBUILD
@@ -1,8 +1,9 @@
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
+# Contributor: Eugene Pirogov <iamexile@gmail.com>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=postgresql-pglogical
_pkgname=pglogical
-pkgver=1.2.1
+pkgver=2.0.1
_pgver=9.6
pkgrel=0
pkgdesc="Logical Replication extension for PostgreSQL $_pgver"
@@ -11,7 +12,8 @@ arch="all"
license="custom"
depends="postgresql>=$_pgver.0"
makedepends="libedit-dev libxml2-dev postgresql-dev>=$_pgver.0 zlib-dev"
-source="http://packages.2ndquadrant.com/pglogical/tarballs/$_pkgname-$pkgver.tar.bz2"
+source="http://packages.2ndquadrant.com/pglogical/tarballs/$_pkgname-$pkgver.tar.bz2
+ 001-fix-stdin-handling.patch"
builddir="$srcdir/$_pkgname-$pkgver"
build() {
@@ -24,6 +26,5 @@ package() {
make USE_PGXS=1 DESTDIR="$pkgdir" install
}
-md5sums="ed339e8fc2f2252fc654a0d7072d7078 pglogical-1.2.1.tar.bz2"
-sha256sums="409eea245b2cacdce6b357628da2b68cd322478582fcc4e2ff5feb954f9512c6 pglogical-1.2.1.tar.bz2"
-sha512sums="0a613b2000f3a91e952e212232617a612b5439fb40a56d60646fc0665fb763e864f78cd91e0cc0b16cb5d6c202655ad2c9de872435fd6c185c5f849083915dca pglogical-1.2.1.tar.bz2"
+sha512sums="e1016484c06ce4a9466eb415ef5d0955b61c68c78e6fa47e84ec82ebef3979ac2eb83460f7c2262a9deac85cfdb365781d1784e8572a4efd5aae5aa3f8ea29db pglogical-2.0.1.tar.bz2
+89df4ed3992f43a0a37eebb5e06dedd2668b6acfad987b3c37e647c05718a9eb0d330d195f4f4426ffc5fad3e1fc7f156c10d3ea6dc7ee778bc2a5b27c6f138f 001-fix-stdin-handling.patch"