Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Enhance .schema in shell to enable matching patterns with literal underscores. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
98e3f5247a6012f58642a2fcdc9be062 |
User & Date: | mistachkin 2018-03-23 14:24:34.734 |
Context
2018-03-23
| ||
14:50 | Fix typo in a comment used for documentation. No changes to code. (check-in: 49974d3b30 user: drh tags: trunk) | |
14:24 | Enhance .schema in shell to enable matching patterns with literal underscores. (check-in: 98e3f5247a user: mistachkin tags: trunk) | |
13:18 | Fix an error in the CLI in the previous ([0249d9aecf69948]) check-in. Only the pattern to sqlite3_strlike() need to be escaped. (check-in: 71d5f6e632 user: drh tags: trunk) | |
Changes
Changes to src/shell.c.in.
︙ | ︙ | |||
6617 6618 6619 6620 6621 6622 6623 | }else{ raw_printf(stderr, "Usage: .schema ?--indent? ?LIKE-PATTERN?\n"); rc = 1; goto meta_command_exit; } } if( zName!=0 ){ | | | | 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 | }else{ raw_printf(stderr, "Usage: .schema ?--indent? ?LIKE-PATTERN?\n"); rc = 1; goto meta_command_exit; } } if( zName!=0 ){ int isMaster = sqlite3_strlike(zName, "sqlite_master", '\\')==0; if( isMaster || sqlite3_strlike(zName,"sqlite_temp_master", '\\')==0 ){ char *new_argv[2], *new_colv[2]; new_argv[0] = sqlite3_mprintf( "CREATE TABLE %s (\n" " type text,\n" " name text,\n" " tbl_name text,\n" " rootpage integer,\n" |
︙ | ︙ | |||
6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 | " UNION ALL SELECT shell_module_schema(name)," " 'table', name, name, name, 9e+99, 'main' FROM pragma_module_list", 0); } #endif appendText(&sSelect, ") WHERE ", 0); if( zName ){ char *zQarg = sqlite3_mprintf("%Q", zName); if( strchr(zName, '.') ){ appendText(&sSelect, "lower(printf('%s.%s',sname,tbl_name))", 0); }else{ appendText(&sSelect, "lower(tbl_name)", 0); } | > > > | > | > | 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 | " UNION ALL SELECT shell_module_schema(name)," " 'table', name, name, name, 9e+99, 'main' FROM pragma_module_list", 0); } #endif appendText(&sSelect, ") WHERE ", 0); if( zName ){ char *zQarg = sqlite3_mprintf("%Q", zName); int bGlob = strchr(zName, '*') != 0 || strchr(zName, '?') != 0 || strchr(zName, '[') != 0; if( strchr(zName, '.') ){ appendText(&sSelect, "lower(printf('%s.%s',sname,tbl_name))", 0); }else{ appendText(&sSelect, "lower(tbl_name)", 0); } appendText(&sSelect, bGlob ? " GLOB " : " LIKE ", 0); appendText(&sSelect, zQarg, 0); if( !bGlob ){ appendText(&sSelect, " ESCAPE '\\' ", 0); } appendText(&sSelect, " AND ", 0); sqlite3_free(zQarg); } appendText(&sSelect, "type!='meta' AND sql IS NOT NULL" " ORDER BY snum, rowid", 0); if( bDebug ){ utf8_printf(p->out, "SQL: %s;\n", sSelect.z); |
︙ | ︙ |
Changes to test/shell1.test.
︙ | ︙ | |||
1093 1094 1095 1096 1097 1098 1099 1100 | if {$res ne "CREATE TABLE ${test}(x);"} { error "failed with mismatch: $res" } forcedelete test3.db } {} } finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 | if {$res ne "CREATE TABLE ${test}(x);"} { error "failed with mismatch: $res" } forcedelete test3.db } {} } db close forcedelete test.db test.db-journal test.db-wal sqlite3 db test.db do_test shell1-7.1.1 { db eval { CREATE TABLE Z (x TEXT PRIMARY KEY); CREATE TABLE _ (x TEXT PRIMARY KEY); CREATE TABLE YY (x TEXT PRIMARY KEY); CREATE TABLE __ (x TEXT PRIMARY KEY); CREATE TABLE WWW (x TEXT PRIMARY KEY); CREATE TABLE ___ (x TEXT PRIMARY KEY); } } {} do_test shell1-7.1.2 { catchcmd "test.db" ".schema _" } {0 {CREATE TABLE Z (x TEXT PRIMARY KEY); CREATE TABLE _ (x TEXT PRIMARY KEY);}} do_test shell1-7.1.3 { catchcmd "test.db" ".schema \\\\_" } {0 {CREATE TABLE _ (x TEXT PRIMARY KEY);}} do_test shell1-7.1.4 { catchcmd "test.db" ".schema __" } {0 {CREATE TABLE YY (x TEXT PRIMARY KEY); CREATE TABLE __ (x TEXT PRIMARY KEY);}} do_test shell1-7.1.5 { catchcmd "test.db" ".schema \\\\_\\\\_" } {0 {CREATE TABLE __ (x TEXT PRIMARY KEY);}} do_test shell1-7.1.6 { catchcmd "test.db" ".schema ___" } {0 {CREATE TABLE WWW (x TEXT PRIMARY KEY); CREATE TABLE ___ (x TEXT PRIMARY KEY);}} do_test shell1-7.1.7 { catchcmd "test.db" ".schema \\\\_\\\\_\\\\_" } {0 {CREATE TABLE ___ (x TEXT PRIMARY KEY);}} finish_test |