mirror of
				https://github.com/sqlite/sqlite.git
				synced 2025-11-03 16:53:36 +03:00 
			
		
		
		
	Change the ".schema" command of the shell to output VIEWs in declared order,
rather than alphabetical order, so that nested views will appear in the correct order. Fix for ticket [cfe84e86839e59e8]. FossilOrigin-Name: e092ff69e25363f97495adc622f4250041ca9708
This commit is contained in:
		
							
								
								
									
										14
									
								
								src/shell.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/shell.c
									
									
									
									
									
								
							@@ -2184,23 +2184,25 @@ static int do_meta_command(char *zLine, struct callback_data *p){
 | 
			
		||||
        zShellStatic = azArg[1];
 | 
			
		||||
        rc = sqlite3_exec(p->db,
 | 
			
		||||
          "SELECT sql FROM "
 | 
			
		||||
          "  (SELECT sql sql, type type, tbl_name tbl_name, name name"
 | 
			
		||||
          "  (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x"
 | 
			
		||||
          "     FROM sqlite_master UNION ALL"
 | 
			
		||||
          "   SELECT sql, type, tbl_name, name FROM sqlite_temp_master) "
 | 
			
		||||
          "   SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) "
 | 
			
		||||
          "WHERE lower(tbl_name) LIKE shellstatic()"
 | 
			
		||||
          "  AND type!='meta' AND sql NOTNULL "
 | 
			
		||||
          "ORDER BY substr(type,2,1), name",
 | 
			
		||||
          "ORDER BY substr(type,2,1), "
 | 
			
		||||
                  " CASE type WHEN 'view' THEN rowid ELSE name END",
 | 
			
		||||
          callback, &data, &zErrMsg);
 | 
			
		||||
        zShellStatic = 0;
 | 
			
		||||
      }
 | 
			
		||||
    }else{
 | 
			
		||||
      rc = sqlite3_exec(p->db,
 | 
			
		||||
         "SELECT sql FROM "
 | 
			
		||||
         "  (SELECT sql sql, type type, tbl_name tbl_name, name name"
 | 
			
		||||
         "  (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x"
 | 
			
		||||
         "     FROM sqlite_master UNION ALL"
 | 
			
		||||
         "   SELECT sql, type, tbl_name, name FROM sqlite_temp_master) "
 | 
			
		||||
         "   SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) "
 | 
			
		||||
         "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%'"
 | 
			
		||||
         "ORDER BY substr(type,2,1), name",
 | 
			
		||||
         "ORDER BY substr(type,2,1),"
 | 
			
		||||
                  " CASE type WHEN 'view' THEN rowid ELSE name END",
 | 
			
		||||
         callback, &data, &zErrMsg
 | 
			
		||||
      );
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user