@@ -86,10 +86,9 @@ def show_schema(cur, arg=None, **_):
8686 if cur .description :
8787 headers = [x [0 ] for x in cur .description ]
8888 else :
89- return [(None , None , None , "" )]
90-
91- return [(None , tables , headers , status )]
89+ return [(None , None , None , "" )] + _list_indexes (cur , arg = arg )
9290
91+ return [(None , tables , headers , status )] + _list_indexes (cur , arg = arg )
9392
9493@special_command (
9594 ".databases" ,
@@ -110,26 +109,19 @@ def list_databases(cur, **_):
110109 return [(None , None , None , "" )]
111110
112111
113- @special_command (
114- ".indexes" ,
115- ".indexes [tablename]" ,
116- "List indexes." ,
117- arg_type = PARSED_QUERY ,
118- case_sensitive = True ,
119- aliases = ("\\ di" ,),
120- )
121- def list_indexes (cur , arg = None , arg_type = PARSED_QUERY , verbose = False ):
112+ # This is private to make sure .schemas special command can call the function to retreive the index
113+ def _list_indexes (cur , arg = None , arg_type = PARSED_QUERY , verbose = False ):
122114 if arg :
123115 args = ("{0}%" .format (arg ),)
124116 query = """
125- SELECT name FROM sqlite_master
117+ SELECT name, sql FROM sqlite_master
126118 WHERE type = 'index' AND tbl_name LIKE ? AND name NOT LIKE 'sqlite_%'
127119 ORDER BY 1
128120 """
129121 else :
130122 args = tuple ()
131123 query = """
132- SELECT name FROM sqlite_master
124+ SELECT name, sql FROM sqlite_master
133125 WHERE type = 'index' AND name NOT LIKE 'sqlite_%'
134126 ORDER BY 1
135127 """
@@ -144,6 +136,17 @@ def list_indexes(cur, arg=None, arg_type=PARSED_QUERY, verbose=False):
144136 return [(None , None , None , "" )]
145137 return [(None , indexes , headers , status )]
146138
139+ @special_command (
140+ ".indexes" ,
141+ ".indexes [tablename]" ,
142+ "List indexes." ,
143+ arg_type = PARSED_QUERY ,
144+ case_sensitive = True ,
145+ aliases = ("\\ di" ,),
146+ )
147+ def list_indexes (cur , arg = None , arg_type = PARSED_QUERY , verbose = False ):
148+ return _list_indexes (cur , arg = arg , arg_type = arg_type , verbose = verbose )
149+
147150
148151@special_command (
149152 ".status" ,
0 commit comments