This is an automated email from the ASF dual-hosted git repository.

okislal pushed a commit to branch madlib2-master
in repository https://gitbox.apache.org/repos/asf/madlib.git

commit 6d621d5291b5381d1cb048739e8328cc5c527dea
Author: Orhan Kislal <[email protected]>
AuthorDate: Thu Aug 24 23:33:21 2023 +0300

    Build: Add post- scripts for gppkg and gp7 version checks in madpack
---
 deploy/gppkg/gppkg_spec_v2.yml.in | 16 +++++++++++++++-
 src/madpack/madpack.py            | 11 ++++++-----
 src/madpack/upgrade_util.py       | 13 +++++++++----
 3 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/deploy/gppkg/gppkg_spec_v2.yml.in 
b/deploy/gppkg/gppkg_spec_v2.yml.in
index 268d131c..25fd84a6 100644
--- a/deploy/gppkg/gppkg_spec_v2.yml.in
+++ b/deploy/gppkg/gppkg_spec_v2.yml.in
@@ -40,7 +40,21 @@ PostInstall:
     find $GPHOME/madlib/bin -depth -type l -exec rm {} \; 2>/dev/null;
     find $GPHOME/madlib/doc -depth -type l -exec rm {} \; 2>/dev/null;
     find $GPHOME/madlib/Current -depth -type l -exec rm {} \; 2>/dev/null;
-
     ln -nsf $GPHOME/madlib/Versions/@MADLIB_VERSION_STRING@ 
$GPHOME/madlib/Current;
     ln -nsf $GPHOME/madlib/Current/bin $GPHOME/madlib/bin;
     ln -nsf $GPHOME/madlib/Current/doc $GPHOME/madlib/doc;
+PostUpgrade:
+  All:
+    # Remove existing soft links
+    find $GPHOME/madlib/bin -depth -type l -exec rm {} \; 2>/dev/null;
+    find $GPHOME/madlib/doc -depth -type l -exec rm {} \; 2>/dev/null;
+    find $GPHOME/madlib/Current -depth -type l -exec rm {} \; 2>/dev/null;
+    ln -nsf $GPHOME/madlib/Versions/@MADLIB_VERSION_STRING@ 
$GPHOME/madlib/Current;
+    ln -nsf $GPHOME/madlib/Current/bin $GPHOME/madlib/bin;
+    ln -nsf $GPHOME/madlib/Current/doc $GPHOME/madlib/doc;
+PostUninstall:
+  All:
+    # Remove existing soft links
+    find $GPHOME/madlib/bin -depth -type l -exec rm {} \; 2>/dev/null;
+    find $GPHOME/madlib/doc -depth -type l -exec rm {} \; 2>/dev/null;
+    find $GPHOME/madlib/Current -depth -type l -exec rm {} \; 2>/dev/null;
diff --git a/src/madpack/madpack.py b/src/madpack/madpack.py
index 92836a12..87df1c06 100755
--- a/src/madpack/madpack.py
+++ b/src/madpack/madpack.py
@@ -1238,16 +1238,17 @@ def create_install_madlib_sqlfile(args, madpack_cmd):
 
 def get_madlib_function_drop_str(schema):
 
-    if portid == 'greenplum':
+    if ((portid == 'greenplum' and is_rev_gte(get_rev_num(dbver), 
get_rev_num('7.0'))) or
+        (portid == 'postgres')):
         case_str = """
-        CASE
-          WHEN p.proisagg THEN 'aggregate'
+        CASE p.prokind
+          WHEN 'a' THEN 'aggregate'
           ELSE 'function'
           """
     else:
         case_str = """
-        CASE p.prokind
-          WHEN 'a' THEN 'aggregate'
+        CASE
+          WHEN p.proisagg THEN 'aggregate'
           ELSE 'function'
           """
     madlib_functions = _internal_run_query("""
diff --git a/src/madpack/upgrade_util.py b/src/madpack/upgrade_util.py
index f9bbb7b9..f7e5cd09 100644
--- a/src/madpack/upgrade_util.py
+++ b/src/madpack/upgrade_util.py
@@ -498,9 +498,12 @@ class ViewDependency(UpgradeBase):
         """
         @brief  Detect direct view dependencies on MADlib UDFs/UDAs
         """
-        proisagg_wrapper = "p.proisagg"
-        if self._portid == 'postgres' and self._dbver > 11:
+        if ((self._portid == 'greenplum' and 
is_rev_gte(get_rev_num(self._dbver), get_rev_num('7.0'))) or
+            (self._portid == 'postgres')):
             proisagg_wrapper = "p.prokind = 'a'"
+        else:
+            proisagg_wrapper = "p.proisagg"
+
         rows = self._run_sql("""
             SELECT
                 view, nsp.nspname AS schema, procname, procoid, proisagg
@@ -1029,9 +1032,11 @@ class ScriptCleaner(UpgradeBase):
         """
         # See _get_function_info for explanations.
 
-        proisagg_wrapper = "p.proisagg = true"
-        if self._portid == 'postgres' and self._dbver > 11:
+        if ((self._portid == 'greenplum' and 
is_rev_gte(get_rev_num(self._dbver), get_rev_num('7.0'))) or
+            (self._portid == 'postgres')):
             proisagg_wrapper = "p.prokind = 'a'"
+        else:
+            proisagg_wrapper = "p.proisagg"
 
         rows = self._run_sql("""
             SELECT

Reply via email to