Yuriy Kaminskiy wrote:
> Alternative 2: (partially tested)
> Explicitly use case-insensitive comparison for table/indexes, no matter what
> case_sensitive_like is.
> 
> Index: sqlite3-3.7.8/src/shell.c
> ===================================================================
> --- sqlite3-3.7.8.orig/src/shell.c    2011-10-23 13:52:44.000000000 +0400
> +++ sqlite3-3.7.8/src/shell.c 2011-10-23 13:54:13.000000000 +0400
> @@ -1573,16 +1573,18 @@ static int do_meta_command(char *zLine,
>        for(i=1; i<nArg; i++){
> +        int j;
> +        for(j=0; azArg[i][j]; i++) azArg[i][j] = (char)tolower(azArg[i][j]);

Doh :-( Fixed version:
Index: sqlite3-3.7.8/src/shell.c
===================================================================
--- sqlite3-3.7.8.orig/src/shell.c      2011-10-23 13:52:44.000000000 +0400
+++ sqlite3-3.7.8/src/shell.c   2011-10-23 13:54:13.000000000 +0400
@@ -1573,16 +1573,18 @@ static int do_meta_command(char *zLine,
     }else{
       int i;
       for(i=1; i<nArg; i++){
+        int j;
+        for(j=0; azArg[i][j]; j++) azArg[i][j] = (char)tolower(azArg[i][j]);
         zShellStatic = azArg[i];
         run_schema_dump_query(p,
           "SELECT name, type, sql FROM sqlite_master "
-          "WHERE tbl_name LIKE shellstatic() AND type=='table'"
+          "WHERE lower(tbl_name) LIKE shellstatic() AND type=='table'"
           "  AND sql NOT NULL", 0);
         run_table_dump_query(p->out, p->db,
           "SELECT sql FROM sqlite_master "
           "WHERE sql NOT NULL"
           "  AND type IN ('index','trigger','view')"
-          "  AND tbl_name LIKE shellstatic()", 0
+          "  AND lower(tbl_name) LIKE shellstatic()", 0
         );
         zShellStatic = 0;
       }
@@ -1790,13 +1792,15 @@ static int do_meta_command(char *zLine,
         callback, &data, &zErrMsg
       );
     }else{
+      int j;
+      for(j=0; azArg[1][j]; j++) azArg[1][j] = (char)tolower(azArg[1][j]);
       zShellStatic = azArg[1];
       rc = sqlite3_exec(p->db,
         "SELECT name FROM sqlite_master "
-        "WHERE type='index' AND tbl_name LIKE shellstatic() "
+        "WHERE type='index' AND lower(tbl_name) LIKE shellstatic() "
         "UNION ALL "
         "SELECT name FROM sqlite_temp_master "
-        "WHERE type='index' AND tbl_name LIKE shellstatic() "
+        "WHERE type='index' AND lower(tbl_name) LIKE shellstatic() "
         "ORDER BY 1",
         callback, &data, &zErrMsg
       );
@@ -2055,7 +2059,7 @@ static int do_meta_command(char *zLine,
           "  (SELECT sql sql, type type, tbl_name tbl_name, name name"
           "     FROM sqlite_master UNION ALL"
           "   SELECT sql, type, tbl_name, name FROM sqlite_temp_master) "
-          "WHERE tbl_name LIKE shellstatic() AND type!='meta' AND sql NOTNULL "
+          "WHERE lower(tbl_name) LIKE shellstatic() AND type!='meta' AND sql
NOTNULL "
           "ORDER BY substr(type,2,1), name",
           callback, &data, &zErrMsg);
         zShellStatic = 0;
@@ -2130,13 +2134,15 @@ static int do_meta_command(char *zLine,
         &azResult, &nRow, 0, &zErrMsg
       );
     }else{
+      int j;
+      for(j=0; azArg[1][j]; j++) azArg[1][j] = (char)tolower(azArg[1][j]);
       zShellStatic = azArg[1];
       rc = sqlite3_get_table(p->db,
         "SELECT name FROM sqlite_master "
-        "WHERE type IN ('table','view') AND name LIKE shellstatic() "
+        "WHERE type IN ('table','view') AND lower(name) LIKE shellstatic() "
         "UNION ALL "
         "SELECT name FROM sqlite_temp_master "
-        "WHERE type IN ('table','view') AND name LIKE shellstatic() "
+        "WHERE type IN ('table','view') AND lower(name) LIKE shellstatic() "
         "ORDER BY 1",
         &azResult, &nRow, 0, &zErrMsg
       );

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to