Github user iyerr3 commented on a diff in the pull request:
https://github.com/apache/incubator-madlib/pull/157#discussion_r130724667
--- Diff: src/ports/postgres/modules/utilities/control.py_in ---
@@ -24,56 +25,66 @@ HAS_FUNCTION_PROPERTIES =
m4_ifdef(<!__HAS_FUNCTION_PROPERTIES__!>, <!True!>, <!
UDF_ON_SEGMENT_NOT_ALLOWED = m4_ifdef(<!__UDF_ON_SEGMENT_NOT_ALLOWED__!>,
<!True!>, <!False!>)
-class EnableOptimizer(object):
+class OptimizerControl(object):
"""
@brief: A wrapper that enables/disables the optimizer and
then sets it back to the original value on exit
"""
- def __init__(self, to_enable=True):
- self.to_enable = to_enable
+ def __init__(self, enable=True, error_on_fail=False):
+ self.to_enable = enable
+ self.error_on_fail = error_on_fail
self.optimizer_enabled = False
- # we depend on the fact that all GPDB/HAWQ versions that have the
+
+ # use the fact that all GPDB/HAWQ versions that have the
# optimizer also define function properties
self.guc_exists = True if HAS_FUNCTION_PROPERTIES else False
def __enter__(self):
- # we depend on the fact that all GPDB/HAWQ versions that have the
ORCA
- # optimizer also define function properties
if self.guc_exists:
- optimizer = plpy.execute("show optimizer")[0]["optimizer"]
- self.optimizer_enabled = True if optimizer == 'on' else False
- plpy.execute("set optimizer={0}".format(('off',
'on')[self.to_enable]))
+ # check if allowed to change the GUC
+ self.optimizer_control = bool(strtobool(
+ plpy.execute("show
optimizer_control")[0]["optimizer_control"]))
--- End diff --
Good point. Added exception handling for such situations.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---