From 3e8bd5095f85491f4ffc9252624d6afea0b6cbf6 Mon Sep 17 00:00:00 2001
From: Russell Foster <russman7474@gmail.com>
Date: Tue, 26 May 2020 14:38:46 -0400
Subject: [PATCH] * Allow updates from joined tables. This was already being
 done for tables using "JOIN" syntax, but not for "X JOIN" * Build now accepts
 the path to the postgres install

From: worldleaderpretend <russman7474@gmail.com>

---
 installer/buildInstallers.ps1 | 13 +++++++++++--
 parse.c                       |  2 --
 winbuild/BuildAll.ps1         | 21 ++++++++++++++++-----
 3 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/installer/buildInstallers.ps1 b/installer/buildInstallers.ps1
index d190673..cb0bb77 100644
--- a/installer/buildInstallers.ps1
+++ b/installer/buildInstallers.ps1
@@ -18,6 +18,9 @@
     Specify the configuration xml file name if you want to use
     the configuration file other than standard one.
     The relative path is relative to the current directory.
+.PARAMETER DatabaseInstallPath
+    Specify the Postgres installation directory.  If absent, it will search
+    for this path in Program Files directory.
 .EXAMPLE
     > .\buildInstallers
 	Build 32bit and 64bit installers.
@@ -37,7 +40,8 @@ Param(
 [switch]$ExcludeRuntime,
 [switch]$RedistUCRT,
 [switch]$NoPDB,
-[string]$BuildConfigPath
+[string]$BuildConfigPath,
+[string]$DatabaseInstallPath
 )
 
 [int]$ucrt_version=14
@@ -149,7 +153,12 @@ function findRuntime([int]$toolset_no, [String]$pgmvc)
 
 function buildInstaller([string]$CPUTYPE)
 {
-	$LIBPQBINDIR=getPGDir $configInfo $CPUTYPE "bin"
+    if ("$DatabaseInstallPath" -eq "") {
+        $LIBPQBINDIR=getPGDir $configInfo $CPUTYPE "bin"
+	} else {
+        $LIBPQBINDIR="$DatabaseInstallPath\bin"
+	}
+
 	# msvc runtime psqlodbc links
 	$PODBCMSVCDLL = ""
 	$PODBCMSVPDLL = ""
diff --git a/parse.c b/parse.c
index b0d751f..5bbb502 100644
--- a/parse.c
+++ b/parse.c
@@ -681,8 +681,6 @@ MYLOG(0, "updatable=%d tab=%d fields=%d", updatable, stmt->ntab, num_fields);
 	{
 		if (1 > stmt->ntab)
 			updatable = FALSE;
-		else if (has_multi_table(stmt))
-			updatable = FALSE;
 	}
 MYPRINTF(0, "->%d\n", updatable);
 	if (stmt->updatable < 0)
diff --git a/winbuild/BuildAll.ps1 b/winbuild/BuildAll.ps1
index fd27ddb..df9b835 100755
--- a/winbuild/BuildAll.ps1
+++ b/winbuild/BuildAll.ps1
@@ -28,6 +28,9 @@
     Specify the configuration xml file name if you want to use
     the configuration file other than standard one.
     The relative path is relative to the current directory.
+.PARAMETER DatabaseInstallPath
+    Specify the Postgres installation directory.  If absent, it will search
+    for this path in Program Files directory.
 .EXAMPLE
     > .\BuildAll
 	Build with default or automatically selected parameters.
@@ -63,7 +66,8 @@ Param(
 [ValidateSet("Debug", "Release")]
 [String]$Configuration="Release",
 [string]$BuildConfigPath,
-[switch]$AlongWithInstallers
+[switch]$AlongWithInstallers,
+[string]$DatabaseInstallPath
 )
 
 function buildPlatform([xml]$configInfo, [string]$Platform)
@@ -74,9 +78,16 @@ function buildPlatform([xml]$configInfo, [string]$Platform)
 		$platinfo=$configInfo.Configuration.x86
 	}
 	$BUILD_MACROS=$platinfo.build_macros
-	$PG_INC=getPGDir $configInfo $Platform "include"
-	$PG_LIB=getPGDir $configInfo $Platform "lib"
-	$PG_BIN=getPGDir $configInfo $Platform "bin"
+
+    if ("$DatabaseInstallPath" -eq "") {
+        $PG_INC=getPGDir $configInfo $Platform "include"
+        $PG_LIB=getPGDir $configInfo $Platform "lib"
+        $PG_BIN=getPGDir $configInfo $Platform "bin"
+	} else {
+        $PG_INC="$DatabaseInstallPath\include"
+        $PG_LIB="$DatabaseInstallPath\lib"
+        $PG_BIN="$DatabaseInstallPath\bin"
+	}
 
 	Write-Host "USE LIBPQ  : ($PG_INC $PG_LIB $PG_BIN)"
 
@@ -180,7 +191,7 @@ try {
                 if ($Platform -eq "win32") {
                         $cpu = "x86"
                 }
-                ..\installer\buildInstallers.ps1 -cpu $cpu -BuildConfigPath $BuildConfigPath
+                ..\installer\buildInstallers.ps1 -cpu $cpu -BuildConfigPath $BuildConfigPath -DatabaseInstallPath $DatabaseInstallPath
                 if ($LASTEXITCODE -ne 0) {
                         throw "Failed to build installers"
                 }
-- 
2.16.1.windows.4

