Github user reductionista commented on a diff in the pull request:
https://github.com/apache/madlib/pull/316#discussion_r215102984
--- Diff: src/ports/postgres/modules/utilities/control.py_in ---
@@ -158,6 +159,61 @@ class MinWarning(ContextDecorator):
format(oldMsgLevel=self.oldMsgLevel))
+class AOControl(ContextDecorator):
+
+ """
+ @brief: A wrapper that enables/disables the AO storage option
+ """
+
+ def __init__(self, enable=False):
+ self.to_enable = enable
+ self.was_ao_enabled = False
+ self.guc_exists = True
+ self.storage_options_dict = dict()
+
+ def _parse_gp_default_storage_options(self,
gp_default_storage_options_str):
+ """ Parse comma separated key=value pairs
+
+ Example:
+
appendonly=false,blocksize=32768,compresstype=none,checksum=true,orientation=row
+ """
+ self.storage_options_dict =
extract_keyvalue_params(gp_default_storage_options_str)
+ self.storage_options_dict['appendonly'] = bool(
+ strtobool(self.storage_options_dict['appendonly']))
+
+ def _join_gp_defaut_storage_options(self):
+ return ','.join(['{0}={1}'.format(k, v)
+ for k, v in self.storage_options_dict.iteritems()])
+
+ def __enter__(self):
+ try:
+ _storage_options_str = plpy.execute(
+ "show
gp_default_storage_options")[0]["gp_default_storage_options"]
+ self._parse_gp_default_storage_options(_storage_options_str)
+
+ # Set APPENDONLY=False after backing up existing value
--- End diff --
What about AOControl[True]? Then it will set APPENDONLY=True after backing
up, right?
---