Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Change ".fkey_missing_indexes" to ".lint fkey-indexes". |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | fkey-missing-indexes |
Files: | files | file ages | folders |
SHA1: |
ee621ade38c11806e1df57c459da5f01 |
User & Date: | dan 2016-12-16 17:28:56.295 |
Context
2016-12-16
| ||
18:41 | Fix minor issues with the ".lint" command implemention in the shell and the shell help text related to ".lint". (Closed-Leaf check-in: 1268dc7771 user: drh tags: fkey-missing-indexes) | |
17:28 | Change ".fkey_missing_indexes" to ".lint fkey-indexes". (check-in: ee621ade38 user: dan tags: fkey-missing-indexes) | |
16:44 | Update .fkey_missing_indexes to use the built-in pragma vtabs. (check-in: 3ab05987b0 user: dan tags: fkey-missing-indexes) | |
Changes
Changes to src/shell.c.
︙ | ︙ | |||
3251 3252 3253 3254 3255 3256 3257 | #else rc = unlink(zFilename); #endif return rc; } | < < < < | | 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 | #else rc = unlink(zFilename); #endif return rc; } /* ** The implementation of SQL scalar function fkey_collate_clause(), used ** by the ".lint fkey-indexes" command. This scalar function is always ** called with four arguments - the parent table name, the parent column name, ** the child table name and the child column name. ** ** fkey_collate_clause('parent-tab', 'parent-col', 'child-tab', 'child-col') ** ** If either of the named tables or columns do not exist, this function ** returns an empty string. An empty string is also returned if both tables |
︙ | ︙ | |||
3309 3310 3311 3312 3313 3314 3315 | sqlite3_result_text(pCtx, z, -1, SQLITE_TRANSIENT); sqlite3_free(z); } } /* | | | | 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 | sqlite3_result_text(pCtx, z, -1, SQLITE_TRANSIENT); sqlite3_free(z); } } /* ** The implementation of dot-command ".lint fkey-indexes". */ static int lintFkeyIndexes( ShellState *pState, /* Current shell tool state */ char **azArg, /* Array of arguments passed to dot command */ int nArg /* Number of entries in azArg[] */ ){ sqlite3 *db = pState->db; /* Database handle to query "main" db of */ FILE *out = pState->out; /* Stream to write non-error output to */ int bVerbose = 0; /* If -verbose is present */ |
︙ | ︙ | |||
3388 3389 3390 3391 3392 3393 3394 | " f.[table] " "FROM sqlite_master AS s, pragma_foreign_key_list(s.name) AS f " "GROUP BY s.name, f.id " "ORDER BY (CASE WHEN ? THEN f.[table] ELSE s.name END)" ; | | | > > | 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 | " f.[table] " "FROM sqlite_master AS s, pragma_foreign_key_list(s.name) AS f " "GROUP BY s.name, f.id " "ORDER BY (CASE WHEN ? THEN f.[table] ELSE s.name END)" ; for(i=2; i<nArg; i++){ int n = strlen(azArg[i]); if( n>1 && sqlite3_strnicmp("-verbose", azArg[i], n)==0 ){ bVerbose = 1; } else if( n>1 && sqlite3_strnicmp("-groupbyparent", azArg[i], n)==0 ){ bGroupByParent = 1; zIndent = " "; } else{ raw_printf(stderr, "Usage: %s %s ?-verbose? ?-groupbyparent?\n", azArg[0], azArg[1] ); return SQLITE_ERROR; } } /* Register the fkey_collate_clause() SQL function */ rc = sqlite3_create_function(db, "fkey_collate_clause", 4, SQLITE_UTF8, 0, shellFkeyCollateClause, 0, 0 |
︙ | ︙ | |||
3477 3478 3479 3480 3481 3482 3483 3484 | } }else{ raw_printf(stderr, "%s\n", sqlite3_errmsg(db)); } return rc; } /* | > | > > > > > > > > > > | > > > > > > > | 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 | } }else{ raw_printf(stderr, "%s\n", sqlite3_errmsg(db)); } return rc; } /* ** Implementation of ".lint" dot command. */ static int lintDotCommand( ShellState *pState, /* Current shell tool state */ char **azArg, /* Array of arguments passed to dot command */ int nArg /* Number of entries in azArg[] */ ){ int n; n = (nArg>=1 ? strlen(azArg[1]) : 0); if( n<1 || sqlite3_strnicmp(azArg[1], "fkey-indexes", n) ) goto usage; return lintFkeyIndexes(pState, azArg, nArg); usage: raw_printf(stderr, "Usage %s sub-command ?switches...?\n", azArg[0]); raw_printf(stderr, "Where sub-commands are:\n"); raw_printf(stderr, " fkey-indexes\n"); return SQLITE_ERROR; } /* ** If an input line begins with "." then invoke this routine to ** process that line. ** ** Return 1 on error, 2 to exit, and 0 otherwise. */ |
︙ | ︙ | |||
3794 3795 3796 3797 3798 3799 3800 | p->autoExplain = 0; }else if( val==99 ){ if( p->mode==MODE_Explain ) p->mode = p->normalMode; p->autoExplain = 1; } }else | < < < < | 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 | p->autoExplain = 0; }else if( val==99 ){ if( p->mode==MODE_Explain ) p->mode = p->normalMode; p->autoExplain = 1; } }else if( c=='f' && strncmp(azArg[0], "fullschema", n)==0 ){ ShellState data; char *zErrMsg = 0; int doStats = 0; memcpy(&data, p, sizeof(data)); data.showHeader = 0; data.cMode = data.mode = MODE_Semi; |
︙ | ︙ | |||
4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 | sqlite3_limit(p->db, aLimit[iLimit].limitCode, (int)integerValue(azArg[2])); } printf("%20s %d\n", aLimit[iLimit].zLimitName, sqlite3_limit(p->db, aLimit[iLimit].limitCode, -1)); } }else #ifndef SQLITE_OMIT_LOAD_EXTENSION if( c=='l' && strncmp(azArg[0], "load", n)==0 ){ const char *zFile, *zProc; char *zErrMsg = 0; if( nArg<2 ){ raw_printf(stderr, "Usage: .load FILE ?ENTRYPOINT?\n"); | > > > > | 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 | sqlite3_limit(p->db, aLimit[iLimit].limitCode, (int)integerValue(azArg[2])); } printf("%20s %d\n", aLimit[iLimit].zLimitName, sqlite3_limit(p->db, aLimit[iLimit].limitCode, -1)); } }else if( c=='l' && n>2 && strncmp(azArg[0], "lint", n)==0 ){ lintDotCommand(p, azArg, nArg); }else #ifndef SQLITE_OMIT_LOAD_EXTENSION if( c=='l' && strncmp(azArg[0], "load", n)==0 ){ const char *zFile, *zProc; char *zErrMsg = 0; if( nArg<2 ){ raw_printf(stderr, "Usage: .load FILE ?ENTRYPOINT?\n"); |
︙ | ︙ |
Changes to test/shell6.test.
︙ | ︙ | |||
80 81 82 83 84 85 86 | set line [string trim $line] if {$line!=""} { append expected "$line\n" } } do_test 1.$tn.1 { | | | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | set line [string trim $line] if {$line!=""} { append expected "$line\n" } } do_test 1.$tn.1 { set RES [catchcmd test.db [list .lint fkey-indexes]] } [list 0 [string trim $expected]] do_test 1.$tn.2 { execsql [lindex $RES 1] catchcmd test.db [list .lint fkey-indexes] } {0 {}} db close } finish_test |
︙ | ︙ |