Commit 646ef35a authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

SQLCatalog: add getOptimizerSwitchKeyList().

parent 6a46887a
<catalog_method>
<item key="sql_optimizer_switch" type="int">
<value>1</value>
</item>
</catalog_method>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="SQL" module="Products.ZSQLMethods.SQL"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_col</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>name</string> </key>
<value> <string>@@optimizer_switch</string> </value>
</item>
<item>
<key> <string>null</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>t</string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>610</int> </value>
</item>
</dictionary>
</list>
</value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z_select_optimizer_switch</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -130,6 +130,7 @@ erp5_mysql_innodb/z_related_uid_or_parent_uid ...@@ -130,6 +130,7 @@ erp5_mysql_innodb/z_related_uid_or_parent_uid
erp5_mysql_innodb/z_reserve_uid erp5_mysql_innodb/z_reserve_uid
erp5_mysql_innodb/z_search_results erp5_mysql_innodb/z_search_results
erp5_mysql_innodb/z_search_security erp5_mysql_innodb/z_search_security
erp5_mysql_innodb/z_select_optimizer_switch
erp5_mysql_innodb/z_show_category_columns erp5_mysql_innodb/z_show_category_columns
erp5_mysql_innodb/z_show_columns erp5_mysql_innodb/z_show_columns
erp5_mysql_innodb/z_show_index erp5_mysql_innodb/z_show_index
......
...@@ -474,6 +474,11 @@ class Catalog(Folder, ...@@ -474,6 +474,11 @@ class Catalog(Folder,
'type' : 'selection', 'type' : 'selection',
'select_variable' : 'getCatalogMethodIds', 'select_variable' : 'getCatalogMethodIds',
'mode' : 'w' }, 'mode' : 'w' },
{ 'id' : 'sql_optimizer_switch',
'description': 'Method to get optimizer_switch value',
'type' : 'selection',
'select_variable' : 'getCatalogMethodIds',
'mode' : 'w' },
{ 'id' : 'sql_catalog_tables', { 'id' : 'sql_catalog_tables',
'description' : 'Method to get the main catalog tables', 'description' : 'Method to get the main catalog tables',
'type' : 'selection', 'type' : 'selection',
...@@ -599,6 +604,7 @@ class Catalog(Folder, ...@@ -599,6 +604,7 @@ class Catalog(Folder,
sql_count_results = '' sql_count_results = ''
sql_getitem_by_path = '' sql_getitem_by_path = ''
sql_getitem_by_uid = '' sql_getitem_by_uid = ''
sql_optimizer_switch = ''
sql_catalog_tables = '' sql_catalog_tables = ''
sql_search_tables = () sql_search_tables = ()
sql_catalog_schema = '' sql_catalog_schema = ''
...@@ -2899,6 +2905,30 @@ class Catalog(Folder, ...@@ -2899,6 +2905,30 @@ class Catalog(Folder,
} }
return getEngine().getContext(data) return getEngine().getContext(data)
def _getOptimizerSwitch(self):
method_name = self.sql_optimizer_switch
try:
method = getattr(self, method_name)
except AttributeError:
pass
else:
try:
return method()[0][0]
except (ConflictError, DatabaseError):
raise
except Exception:
pass
LOG('SQLCatalog', WARNING, 'getTableIds failed with the method %s'
% method_name, error=sys.exc_info())
return ''
security.declarePublic('getOptimizerSwitchKeyList')
@transactional_cache_decorator('SQLCatalog.getOptimizerSwitchKeyList')
def getOptimizerSwitchKeyList(self):
return [pair.split('=', 1)[0] for pair in \
self._getOptimizerSwitch().split(',')]
InitializeClass(Catalog) InitializeClass(Catalog)
class CatalogError(Exception): pass class CatalogError(Exception): pass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment