[GitHub] incubator-madlib pull request #157: Multiple: Check optimizer_control before...

2017-08-08 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/incubator-madlib/pull/157


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-madlib pull request #157: Multiple: Check optimizer_control before...

2017-08-01 Thread iyerr3
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(, , , 
, )
 
 
-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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-madlib pull request #157: Multiple: Check optimizer_control before...

2017-08-01 Thread edespino
Github user edespino commented on a diff in the pull request:

https://github.com/apache/incubator-madlib/pull/157#discussion_r130696569
  
--- Diff: src/ports/postgres/modules/utilities/control.py_in ---
@@ -24,56 +25,66 @@ HAS_FUNCTION_PROPERTIES = 
m4_ifdef(, , , 
, )
 
 
-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 --

Not sure how much it matters, but I took a quick look at HAWQ and it 
appears the guc `optimizer_control` is not available. Will this throw an 
exception and be handled properly?

Here is a link to HAWQ guc.c: 
https://github.com/apache/incubator-hawq/blob/master/src/backend/utils/misc/guc.c


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---