From: drh Date: Mon, 1 Oct 2018 21:26:30 +0000 (+0000) Subject: Change the name of the pragma to PRAGMA table_xinfo. Improve the X-Git-Tag: version-3.26.0~106^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bdc9744f603eadefcd0afb783accf2fc211cc627;p=thirdparty%2Fsqlite.git Change the name of the pragma to PRAGMA table_xinfo. Improve the mkpragmatab.tcl script to reuse column names where appropriate. FossilOrigin-Name: 2fdd068987e59b979045d71ae64e700600ef07e54ae340f30c2064e5dcccb8ea --- diff --git a/manifest b/manifest index 25f7ffaa95..5f496d1dd4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sextra\s"hidden"\scolumn\sto\sthe\send\sof\sthe\sPRAGMA\stable_vinfo\soutput. -D 2018-10-01T18:28:42.916 +C Change\sthe\sname\sof\sthe\spragma\sto\sPRAGMA\stable_xinfo.\s\sImprove\sthe\nmkpragmatab.tcl\sscript\sto\sreuse\scolumn\snames\swhere\sappropriate. +D 2018-10-01T21:26:30.705 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 01e95208a78b57d056131382c493c963518f36da4c42b12a97eb324401b3a334 @@ -497,7 +497,7 @@ F src/pcache.c 4196eb6ed3bbf00b80596c8e0b4f50e57eb7d890c19fb27a7354306abb7f983d F src/pcache.h 072f94d29281cffd99e46c1539849f248c4b56ae7684c1f36626797fee375170 F src/pcache1.c 716975564c15eb6679e97f734cec1bfd6c16ac3d4010f05f1f8e509fc7d19880 F src/pragma.c a656ff043a03bd94153e6d731a3fbf1bb420207edc969d8fc04b4d2448387901 -F src/pragma.h 32e7736d98684ecb190765eb51bc60aff6b30e081c03a0325ec768344e3fc495 +F src/pragma.h 0ea639401ed7b8275c145e3a814119831e296118b545421e76ae2e1516f10ad8 F src/prepare.c f8e260d940a0e08494c0f30744521b2f832d7263eca9d02b050cea0ba144b097 F src/printf.c 0f1177cf1dd4d7827bf64d840768514ec76409abecaca9e8b577dbd065150381 F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 @@ -1703,7 +1703,7 @@ F tool/mkmsvcmin.tcl cad0c7b54d7dd92bc87d59f36d4cc4f070eb2e625f14159dc2f5c4204e6 F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c F tool/mkopcodeh.tcl 352a4319c0ad869eb26442bf7c3b015aa15594c21f1cce5a6420dbe999367c21 F tool/mkopts.tcl 680f785fdb09729fd9ac50632413da4eadbdf9071535e3f26d03795828ab07fa -F tool/mkpragmatab.tcl 03d3373f6f98a6a195a5bc78ee4b2b276eb4b692e991304c49c8f03f35c75755 +F tool/mkpragmatab.tcl fc895d5a40e725b19b866b058b3994bfc45db3e7fef40db9e6c6fd921bf8a337 F tool/mkshellc.tcl 1f45770aea226ac093a9c72f718efbb88a2a2833409ec2e1c4cecae4202626f5 F tool/mksourceid.c d458f9004c837bee87a6382228ac20d3eae3c49ea3b0a5aace936f8b60748d3b F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 @@ -1770,7 +1770,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6f606f99231f88ae5ff719d0ce21afc4b844490102c27ac20aa606baaf78d8d6 -R 8168cb89d6e5deec90702b5288566db2 +P cf1b76135f511530dcc7b82f78c952bf97ebcddb40be06f713f9f2326915fabe +R ba010eae61cf933e84f1d1c261299063 U drh -Z a68eabb459073457887cbb002b95bf23 +Z 03cca8b8402459da514c7ddddb7143b7 diff --git a/manifest.uuid b/manifest.uuid index 2122c4fb06..5f1369d3fb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cf1b76135f511530dcc7b82f78c952bf97ebcddb40be06f713f9f2326915fabe \ No newline at end of file +2fdd068987e59b979045d71ae64e700600ef07e54ae340f30c2064e5dcccb8ea \ No newline at end of file diff --git a/src/pragma.h b/src/pragma.h index 371453649a..3d1ba4f341 100644 --- a/src/pragma.h +++ b/src/pragma.h @@ -68,65 +68,57 @@ ** result column is different from the name of the pragma */ static const char *const pragCName[] = { - /* 0 */ "cache_size", /* Used by: default_cache_size */ - /* 1 */ "cid", /* Used by: table_info */ - /* 2 */ "name", - /* 3 */ "type", - /* 4 */ "notnull", - /* 5 */ "dflt_value", - /* 6 */ "pk", - /* 7 */ "cid", /* Used by: table_vinfo */ - /* 8 */ "name", - /* 9 */ "type", - /* 10 */ "notnull", - /* 11 */ "dflt_value", - /* 12 */ "pk", - /* 13 */ "hidden", - /* 14 */ "tbl", /* Used by: stats */ - /* 15 */ "idx", - /* 16 */ "wdth", - /* 17 */ "hght", - /* 18 */ "flgs", - /* 19 */ "seqno", /* Used by: index_info */ - /* 20 */ "cid", - /* 21 */ "name", - /* 22 */ "seqno", /* Used by: index_xinfo */ - /* 23 */ "cid", - /* 24 */ "name", - /* 25 */ "desc", - /* 26 */ "coll", - /* 27 */ "key", - /* 28 */ "seq", /* Used by: index_list */ - /* 29 */ "name", - /* 30 */ "unique", - /* 31 */ "origin", - /* 32 */ "partial", - /* 33 */ "seq", /* Used by: database_list */ - /* 34 */ "name", - /* 35 */ "file", - /* 36 */ "name", /* Used by: function_list */ - /* 37 */ "builtin", - /* 38 */ "name", /* Used by: module_list pragma_list */ - /* 39 */ "seq", /* Used by: collation_list */ - /* 40 */ "name", - /* 41 */ "id", /* Used by: foreign_key_list */ - /* 42 */ "seq", - /* 43 */ "table", - /* 44 */ "from", - /* 45 */ "to", - /* 46 */ "on_update", - /* 47 */ "on_delete", - /* 48 */ "match", - /* 49 */ "table", /* Used by: foreign_key_check */ - /* 50 */ "rowid", - /* 51 */ "parent", - /* 52 */ "fkid", - /* 53 */ "busy", /* Used by: wal_checkpoint */ - /* 54 */ "log", - /* 55 */ "checkpointed", - /* 56 */ "timeout", /* Used by: busy_timeout */ - /* 57 */ "database", /* Used by: lock_status */ - /* 58 */ "status", + /* 0 */ "id", /* Used by: foreign_key_list */ + /* 1 */ "seq", + /* 2 */ "table", + /* 3 */ "from", + /* 4 */ "to", + /* 5 */ "on_update", + /* 6 */ "on_delete", + /* 7 */ "match", + /* 8 */ "cid", /* Used by: table_xinfo */ + /* 9 */ "name", + /* 10 */ "type", + /* 11 */ "notnull", + /* 12 */ "dflt_value", + /* 13 */ "pk", + /* 14 */ "hidden", + /* table_info reuses 8 */ + /* 15 */ "seqno", /* Used by: index_xinfo */ + /* 16 */ "cid", + /* 17 */ "name", + /* 18 */ "desc", + /* 19 */ "coll", + /* 20 */ "key", + /* 21 */ "tbl", /* Used by: stats */ + /* 22 */ "idx", + /* 23 */ "wdth", + /* 24 */ "hght", + /* 25 */ "flgs", + /* 26 */ "seq", /* Used by: index_list */ + /* 27 */ "name", + /* 28 */ "unique", + /* 29 */ "origin", + /* 30 */ "partial", + /* 31 */ "table", /* Used by: foreign_key_check */ + /* 32 */ "rowid", + /* 33 */ "parent", + /* 34 */ "fkid", + /* index_info reuses 15 */ + /* 35 */ "seq", /* Used by: database_list */ + /* 36 */ "name", + /* 37 */ "file", + /* 38 */ "busy", /* Used by: wal_checkpoint */ + /* 39 */ "log", + /* 40 */ "checkpointed", + /* 41 */ "name", /* Used by: function_list */ + /* 42 */ "builtin", + /* collation_list reuses 26 */ + /* 43 */ "database", /* Used by: lock_status */ + /* 44 */ "status", + /* 45 */ "cache_size", /* Used by: default_cache_size */ + /* module_list pragma_list reuses 9 */ + /* 46 */ "timeout", /* Used by: busy_timeout */ }; /* Definitions of all built-in pragmas */ @@ -172,7 +164,7 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "busy_timeout", /* ePragTyp: */ PragTyp_BUSY_TIMEOUT, /* ePragFlg: */ PragFlg_Result0, - /* ColNames: */ 56, 1, + /* ColNames: */ 46, 1, /* iArg: */ 0 }, #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) {/* zName: */ "cache_size", @@ -209,7 +201,7 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "collation_list", /* ePragTyp: */ PragTyp_COLLATION_LIST, /* ePragFlg: */ PragFlg_Result0, - /* ColNames: */ 39, 2, + /* ColNames: */ 26, 2, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS) @@ -244,14 +236,14 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "database_list", /* ePragTyp: */ PragTyp_DATABASE_LIST, /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0, - /* ColNames: */ 33, 3, + /* ColNames: */ 35, 3, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED) {/* zName: */ "default_cache_size", /* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE, /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1, - /* ColNames: */ 0, 1, + /* ColNames: */ 45, 1, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) @@ -281,14 +273,14 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "foreign_key_check", /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK, /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0, - /* ColNames: */ 49, 4, + /* ColNames: */ 31, 4, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_FOREIGN_KEY) {/* zName: */ "foreign_key_list", /* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST, /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, - /* ColNames: */ 41, 8, + /* ColNames: */ 0, 8, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) @@ -324,7 +316,7 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "function_list", /* ePragTyp: */ PragTyp_FUNCTION_LIST, /* ePragFlg: */ PragFlg_Result0, - /* ColNames: */ 36, 2, + /* ColNames: */ 41, 2, /* iArg: */ 0 }, #endif #endif @@ -360,17 +352,17 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "index_info", /* ePragTyp: */ PragTyp_INDEX_INFO, /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, - /* ColNames: */ 19, 3, + /* ColNames: */ 15, 3, /* iArg: */ 0 }, {/* zName: */ "index_list", /* ePragTyp: */ PragTyp_INDEX_LIST, /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, - /* ColNames: */ 28, 5, + /* ColNames: */ 26, 5, /* iArg: */ 0 }, {/* zName: */ "index_xinfo", /* ePragTyp: */ PragTyp_INDEX_INFO, /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, - /* ColNames: */ 22, 6, + /* ColNames: */ 15, 6, /* iArg: */ 1 }, #endif #if !defined(SQLITE_OMIT_INTEGRITY_CHECK) @@ -422,7 +414,7 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "lock_status", /* ePragTyp: */ PragTyp_LOCK_STATUS, /* ePragFlg: */ PragFlg_Result0, - /* ColNames: */ 57, 2, + /* ColNames: */ 43, 2, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) @@ -448,7 +440,7 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "module_list", /* ePragTyp: */ PragTyp_MODULE_LIST, /* ePragFlg: */ PragFlg_Result0, - /* ColNames: */ 38, 1, + /* ColNames: */ 9, 1, /* iArg: */ 0 }, #endif #endif @@ -481,7 +473,7 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "pragma_list", /* ePragTyp: */ PragTyp_PRAGMA_LIST, /* ePragFlg: */ PragFlg_Result0, - /* ColNames: */ 38, 1, + /* ColNames: */ 9, 1, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) @@ -568,7 +560,7 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "stats", /* ePragTyp: */ PragTyp_STATS, /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq, - /* ColNames: */ 14, 5, + /* ColNames: */ 21, 5, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) @@ -582,12 +574,12 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "table_info", /* ePragTyp: */ PragTyp_TABLE_INFO, /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, - /* ColNames: */ 1, 6, + /* ColNames: */ 8, 6, /* iArg: */ 0 }, - {/* zName: */ "table_vinfo", + {/* zName: */ "table_xinfo", /* ePragTyp: */ PragTyp_TABLE_INFO, /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, - /* ColNames: */ 7, 7, + /* ColNames: */ 8, 7, /* iArg: */ 1 }, #endif #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) @@ -652,7 +644,7 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "wal_checkpoint", /* ePragTyp: */ PragTyp_WAL_CHECKPOINT, /* ePragFlg: */ PragFlg_NeedSchema, - /* ColNames: */ 53, 3, + /* ColNames: */ 38, 3, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) diff --git a/tool/mkpragmatab.tcl b/tool/mkpragmatab.tcl index dd0836fba5..c40e3f5b77 100644 --- a/tool/mkpragmatab.tcl +++ b/tool/mkpragmatab.tcl @@ -224,7 +224,7 @@ set pragma_def { COLS: cid name type notnull dflt_value pk IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) - NAME: table_vinfo + NAME: table_xinfo TYPE: TABLE_INFO FLAG: NeedSchema Result1 SchemaOpt ARG: 1 @@ -418,20 +418,20 @@ set cols {} set cols_list {} set arg 0 proc record_one {} { - global name type if arg allbyname typebyif flags cols allcols + global name type if arg allbyname typebyif flags cols all_cols global cols_list colUsedBy if {$name==""} return if {$cols!=""} { - if {![info exists allcols($cols)]} { + if {![info exists all_cols($cols)]} { + set all_cols($cols) 1 lappend cols_list $cols - set allcols($cols) [llength $cols_list] } - set cx $allcols($cols) + set cx $cols lappend colUsedBy($cols) $name } else { set cx 0 } - set allbyname($name) [list $type $arg $if $flags $cx] + set allbyname($name) [list $type $arg $if $flags $cols] set name {} set type {} set if {} @@ -513,6 +513,13 @@ foreach f [lsort [array names allflags]] { set fv [expr {$fv*2}] } +# Sort the column lists so that longer column lists occur first +# +proc colscmp {a b} { + return [expr {[llength $b] - [llength $a]}] +} +set cols_list [lsort -command colscmp $cols_list] + # Generate the array of column names used by pragmas that act like # queries. # @@ -521,10 +528,23 @@ puts $fd "** or that return single-column results where the name of the" puts $fd "** result column is different from the name of the pragma\n*/" puts $fd "static const char *const pragCName\[\] = {" set offset 0 +set allcollist {} foreach cols $cols_list { - set cols_offset($allcols($cols)) $offset + set n [llength $cols] + set limit [expr {[llength $allcollist] - $n}] + for {set i 0} {$i<$limit} {incr i} { + set sublist [lrange $allcollist $i [expr {$i+$n-1}]] + if {$sublist==$cols} { + puts $fd [format "%27s/* $colUsedBy($cols) reuses $i */" ""] + set cols_offset($cols) $i + break + } + } + if {$i<$limit} continue + set cols_offset($cols) $offset set ub " /* Used by: $colUsedBy($cols) */" foreach c $cols { + lappend allcollist $c puts $fd [format " /* %3d */ %-14s%s" $offset \"$c\", $ub] set ub "" incr offset @@ -550,12 +570,12 @@ set current_if {} set spacer [format { %26s } {}] foreach name $allnames { foreach {type arg if flag cx} $allbyname($name) break - if {$cx==0} { + if {$cx==0 || $cx==""} { set cy 0 set nx 0 } else { set cy $cols_offset($cx) - set nx [llength [lindex $cols_list [expr {$cx-1}]]] + set nx [llength $cx] } if {$if!=$current_if} { if {$current_if!=""} {