changeset 524:96803d93b9ae

show fixed for pgsql
author Catherine Devlin <catherine.devlin@gmail.com>
date Thu, 18 Nov 2010 18:47:37 -0500
parents ba3c6c6cc952
children 4ec9438c0036
files sqlpython/connections.py sqlpython/sqlpyPlus.py
diffstat 2 files changed, 34 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/connections.py	Sat Nov 13 06:07:46 2010 -0500
+++ b/sqlpython/connections.py	Thu Nov 18 18:47:37 2010 -0500
@@ -376,6 +376,7 @@
                     FROM   information_schema.routines r
                     WHERE  ( (r.routine_schema %(owner_op)s LOWER(%(owner)S)) OR (r.routine_schema = 'public') )
                     AND    LOWER(r.routine_definition) LIKE %(text)S"""
+    parameter_qry = """SELECT name, unit, setting FROM pg_settings WHERE name LIKE LOWER('%%%s%%');""" 
     gerald_types = {'BASE TABLE': gerald.postgres_schema.Table,
                     'VIEW': gerald.postgres_schema.View}
 
@@ -436,6 +437,16 @@
     tables_and_views_qry = """SELECT table_name
                               FROM   all_tables
                               WHERE  table_name LIKE UPPER(%(table_name)S)"""
+    parameter_qry = """SELECT name, 
+                                              CASE type WHEN 1 THEN 'BOOLEAN'
+                                                        WHEN 2 THEN 'STRING'
+                                                        WHEN 3 THEN 'INTEGER'
+                                                        WHEN 4 THEN 'PARAMETER FILE'
+                                                        WHEN 5 THEN 'RESERVED'
+                                                        WHEN 6 THEN 'BIG INTEGER' END type, 
+                                                        value 
+                                       FROM v$parameter 
+                                       WHERE name LIKE LOWER('%%%s%%');"""
     def source(self, target, opts):
         return self._source(target, opts)
     def bindSyntax(self, varname):
--- a/sqlpython/sqlpyPlus.py	Sat Nov 13 06:07:46 2010 -0500
+++ b/sqlpython/sqlpyPlus.py	Thu Nov 18 18:47:37 2010 -0500
@@ -910,47 +910,37 @@
         '''
         show                  - display value of all sqlpython parameters
         show (parameter name) - display value of a sqlpython parameter
-        show parameter (parameter name) - display value of an ORACLE parameter
+        show parameter (parameter name) - display value of a database parameter
         show err (object type/name)     - errors from latest PL/SQL object compilation.
         show all err (type/name)        - all compilation errors from the user's PL/SQL objects.
         show (index/schema/tablespace/trigger/view/constraint/comment) on (table)
         '''
-        if arg.startswith('param') and self.rdbms == 'oracle':
-            try:
-                paramname = arg.split()[1].lower()
-            except IndexError:
-                paramname = ''
-            self.onecmd(self.parsed("""SELECT name, 
-                                              CASE type WHEN 1 THEN 'BOOLEAN'
-                                                        WHEN 2 THEN 'STRING'
-                                                        WHEN 3 THEN 'INTEGER'
-                                                        WHEN 4 THEN 'PARAMETER FILE'
-                                                        WHEN 5 THEN 'RESERVED'
-                                                        WHEN 6 THEN 'BIG INTEGER' END type, 
-                                                        value 
-                                       FROM v$parameter 
-                                       WHERE name LIKE '%%%s%%';""" % paramname))
+        arg = arg.strip().replace('*', '%').replace('?', '_')
+        if not arg:
+            return Cmd.do_show(self, arg)
+        if arg.lower().startswith('param'):
+            arg = ' '.join(arg.split()[1:]) or '%'
         else:
             argpieces = arg.lower().split()
             argpieces = [a for a in argpieces if not a.startswith('-')]
-            try:
-                for (kwd, shortcut) in (
-                        ('ind', '\\di'), ('schema', '\\dn'), 
-                        ('tablesp', '\\db'), ('trig', '\\dg'), 
-                        ('view', '\\dv'), ('cons', '\\dc'),
-                        ('comm', '\\dd'), ('ref', 'ref')):
-                    if argpieces[0].lower().startswith(kwd):
-                        return self._show_shortcut(shortcut, argpieces)
-                if argpieces[0][:3] == 'err':
-                    return self._show_errors(all_users=False, limit=1, targets=argpieces[1:])
-                elif argpieces[0][:3] == 'tab':
-                    return self.do_ls('table/*')
-                elif (argpieces[0], argpieces[1][:3]) == ('all','err'):
-                    return self._show_errors(all_users=False, limit=None, targets=argpieces[2:])
-            except IndexError:
-                pass
+            for (kwd, shortcut) in (
+                    ('ind', '\\di'), ('schema', '\\dn'), 
+                    ('tablesp', '\\db'), ('trig', '\\dg'), 
+                    ('view', '\\dv'), ('cons', '\\dc'),
+                    ('comm', '\\dd'), ('ref', 'ref')):
+                if argpieces[0].lower().startswith(kwd):
+                    return self._show_shortcut(shortcut, argpieces)
+            if argpieces[0][:3] == 'err':
+                return self._show_errors(all_users=False, limit=1, targets=argpieces[1:])
+            elif argpieces[0][:3] == 'tab':
+                return self.do_ls('table/*')
+            elif (argpieces[0], argpieces[1:2][:3]) == ('all','err'):
+                return self._show_errors(all_users=False, limit=None, targets=argpieces[2:])
+        try:
             return Cmd.do_show(self, arg)
-            
+        except NotImplementedError:
+            return self.onecmd(self.current_instance.parameter_qry % arg)
+                       
     def _vc(self, arg, opts, program):
         if not os.path.exists('.%s' % program):
             create = raw_input('%s repository not yet in current directory (%s).  Create (y/N)? ' %