khannaekta commented on a change in pull request #495:
URL: https://github.com/apache/madlib/pull/495#discussion_r414134906
##########
File path: src/madpack/madpack.py
##########
@@ -1200,10 +1194,63 @@ def create_install_madlib_sqlfile(args, madpack_cmd):
else:
# 3) Run upgrade
_plpy_check(py_min_ver)
+
return_signal = _db_upgrade(schema, output_filehandle,
db_madlib_ver)
return 1 if return_signal > 0 else 0
+def get_madlib_function_drop_str(schema):
+
+ madlib_functions = _internal_run_query("""
+ SELECT n.nspname as "Schema",
+ p.proname as "name",
+ pg_catalog.pg_get_function_arguments(p.oid) as "args",
+ CASE p.prokind
+ WHEN 'a' THEN 'aggregate'
+ WHEN 'p' THEN 'procedure'
+ ELSE 'function'
+ END as "type"
+ FROM pg_catalog.pg_proc p
+ LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
+ WHERE n.nspname OPERATOR(pg_catalog.~) '^(%s)$'
+ ORDER BY 4, 1, 2;
+ """ % schema.lower(), True)
+
+ drop_str = ""
+
+ for i in madlib_functions:
+
+ # We don't drop type related functions
+ no_drop = ['bytea8', 'float8arr', 'svec']
+ if not any(x in i['name'] for x in no_drop):
+ drop_str = drop_str + "DROP {0} {1}.{2}({3}); \n".format(
+ i['type'], schema, i['name'], i['args'])
+ return drop_str
+
+
+def get_madlib_operator_drop_str(schema):
+
+ madlib_operators = _internal_run_query("""
+ SELECT n.nspname as "Schema",
+ o.oprname AS "name",
+ CASE WHEN o.oprkind='l' THEN NULL
+ ELSE pg_catalog.format_type(o.oprleft, NULL) END AS "left_op",
+ CASE WHEN o.oprkind='r' THEN NULL
+ ELSE pg_catalog.format_type(o.oprright, NULL) END AS "right_op"
+ FROM pg_catalog.pg_operator o
+ LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace
+ WHERE n.nspname OPERATOR(pg_catalog.~) '^(%s)$'
+ ORDER BY 1, 2, 3, 4;
+ """ % schema.lower(), True)
+
+ # Drop the Operator Class before the individual operators
+ drop_str = "DROP OPERATOR CLASS IF EXISTS {0}.svec_ops USING btree;
\n".format(schema)
Review comment:
Shouldn't this go through `self._udoc` instead of just dropping the
`svec_ops`? Also, do we still need to call `drop_changed_udoc()` at
[L566](https://github.com/apache/madlib/pull/495/files#diff-aee20fa9b7d6f9749f7683e14158369aR566)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]