sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
| 1 | # 2025-11-15 |
| 2 | # |
| 3 | # The author disclaims copyright to this source code. In place of |
| 4 | # a legal notice, here is a blessing: |
| 5 | # |
| 6 | # May you do good and not evil. |
| 7 | # May you find forgiveness for yourself and forgive others. |
| 8 | # May you share freely, never taking more than you give. |
| 9 | # |
| 10 | #*********************************************************************** |
| 11 | # |
| 12 | # Test cases for the Query Result Formatter (QRF) |
| 13 | # |
| 14 | # Format narrowing due to nScreenWidth |
| 15 | # |
| 16 | |
| 17 | set testdir [file dirname $argv0] |
| 18 | source $testdir/tester.tcl |
| 19 | set testprefix qrf03 |
| 20 | |
| 21 | do_execsql_test 1.0 { |
| 22 | CREATE TABLE mlink( |
| 23 | mid INTEGER, |
| 24 | fid INTEGER, |
| 25 | pmid INTEGER, |
| 26 | pid INTEGER, |
| 27 | fnid INTEGER REFERENCES filename, |
| 28 | pfnid INTEGER, |
| 29 | mperm INTEGER, |
| 30 | isaux BOOLEAN DEFAULT 0 |
| 31 | ); |
| 32 | INSERT INTO mlink VALUES(28775,28774,28773,28706,1,0,0,0); |
| 33 | INSERT INTO mlink VALUES(28773,28706,28770,28685,1,0,0,0); |
| 34 | INSERT INTO mlink VALUES(28770,28736,28769,28695,2,0,0,0); |
| 35 | INSERT INTO mlink VALUES(28770,28697,28769,28698,3,0,0,0); |
| 36 | INSERT INTO mlink VALUES(28767,28768,28759,28746,4,0,0,0); |
| 37 | CREATE TABLE event( |
| 38 | type TEXT, |
| 39 | mtime DATETIME, |
| 40 | objid INTEGER PRIMARY KEY, |
| 41 | tagid INTEGER, |
| 42 | uid INTEGER REFERENCES user, |
| 43 | bgcolor TEXT, |
| 44 | euser TEXT, |
| 45 | user TEXT, |
| 46 | ecomment TEXT, |
| 47 | comment TEXT, |
| 48 | brief TEXT, |
| 49 | omtime DATETIME |
| 50 | ); |
| 51 | INSERT INTO event VALUES('ci',2460994.978048461023,126223,NULL,NULL,NULL,NULL,'drh',NULL,unistr('Data structure improvements on columnar layout. Prep work for getting\u000acolumnar layouts to respond to nScreenWidth.'),NULL,2460994.978048461023); |
| 52 | INSERT INTO event VALUES('ci',2460994.836955601816,126218,NULL,NULL,NULL,NULL,'stephan',NULL,'API doc typo fix.',NULL,2460994.836955601816); |
| 53 | INSERT INTO event VALUES('ci',2460994.88823369192,126212,NULL,NULL,NULL,NULL,'stephan',NULL,'Move sqlite3-api-cleanup.js into post-js-footer.js to remove the final direct Emscripten dependency from the intermediary build product sqlite3-api.js (the whole library, waiting to be bootstrapped). This is partly in response to [forum:4b7d45433731d2e0|forum post 4b7d45433731d2e0], which demonstrates a potential use case for a standalone sqlite3-api.js. This is a build/doc change, not a functional one.',NULL,2460994.88823369192); |
| 54 | INSERT INTO event VALUES('ci',2460994.516081551089,126211,NULL,NULL,NULL,NULL,'drh',NULL,unistr('Improve columnar layout in QRF so that it correctly deals with control\u000acharacters, and especially tabs.'),NULL,2460994.516081551089); |
| 55 | INSERT INTO event VALUES('ci',2460994.409343171865,126208,NULL,NULL,NULL,NULL,'drh',NULL,'Make use of the new sqlite3_str_free() interface in the CLI.',NULL,2460994.409343171865); |
| 56 | } |
| 57 | |
| 58 | do_test 1.10 { |
| 59 | set x "\n[db format -style box -screenwidth 68 \ |
| 60 | {SELECT * FROM mlink ORDER BY rowid}]" |
| 61 | |
| 62 | } { |
| 63 | ╭───────┬───────┬───────┬───────┬──────┬───────┬───────┬───────╮ |
| 64 | │ mid │ fid │ pmid │ pid │ fnid │ pfnid │ mperm │ isaux │ |
| 65 | ╞═══════╪═══════╪═══════╪═══════╪══════╪═══════╪═══════╪═══════╡ |
| 66 | │ 28775 │ 28774 │ 28773 │ 28706 │ 1 │ 0 │ 0 │ 0 │ |
| 67 | │ 28773 │ 28706 │ 28770 │ 28685 │ 1 │ 0 │ 0 │ 0 │ |
| 68 | │ 28770 │ 28736 │ 28769 │ 28695 │ 2 │ 0 │ 0 │ 0 │ |
| 69 | │ 28770 │ 28697 │ 28769 │ 28698 │ 3 │ 0 │ 0 │ 0 │ |
| 70 | │ 28767 │ 28768 │ 28759 │ 28746 │ 4 │ 0 │ 0 │ 0 │ |
| 71 | ╰───────┴───────┴───────┴───────┴──────┴───────┴───────┴───────╯ |
| 72 | } |
| 73 | do_test 1.11 { |
| 74 | set x "\n[db format -style box -screenwidth 52 \ |
| 75 | {SELECT * FROM mlink ORDER BY rowid}]" |
| 76 | |
| 77 | } { |
| 78 | ╭─────┬─────┬─────┬─────┬────┬─────┬─────┬─────╮ |
| 79 | │ mid │ fid │pmid │ pid │fnid│pfnid│mperm│isaux│ |
| 80 | ╞═════╪═════╪═════╪═════╪════╪═════╪═════╪═════╡ |
| 81 | │28775│28774│28773│28706│ 1│ 0│ 0│ 0│ |
| 82 | │28773│28706│28770│28685│ 1│ 0│ 0│ 0│ |
| 83 | │28770│28736│28769│28695│ 2│ 0│ 0│ 0│ |
| 84 | │28770│28697│28769│28698│ 3│ 0│ 0│ 0│ |
| 85 | │28767│28768│28759│28746│ 4│ 0│ 0│ 0│ |
| 86 | ╰─────┴─────┴─────┴─────┴────┴─────┴─────┴─────╯ |
| 87 | } |
| 88 | |
| 89 | do_test 1.20 { |
| 90 | set x "\n[db format -style table -screenwidth 68 \ |
| 91 | {SELECT * FROM mlink ORDER BY rowid}]" |
| 92 | |
| 93 | } { |
| 94 | +-------+-------+-------+-------+------+-------+-------+-------+ |
| 95 | | mid | fid | pmid | pid | fnid | pfnid | mperm | isaux | |
| 96 | +-------+-------+-------+-------+------+-------+-------+-------+ |
| 97 | | 28775 | 28774 | 28773 | 28706 | 1 | 0 | 0 | 0 | |
| 98 | | 28773 | 28706 | 28770 | 28685 | 1 | 0 | 0 | 0 | |
| 99 | | 28770 | 28736 | 28769 | 28695 | 2 | 0 | 0 | 0 | |
| 100 | | 28770 | 28697 | 28769 | 28698 | 3 | 0 | 0 | 0 | |
| 101 | | 28767 | 28768 | 28759 | 28746 | 4 | 0 | 0 | 0 | |
| 102 | +-------+-------+-------+-------+------+-------+-------+-------+ |
| 103 | } |
| 104 | do_test 1.21 { |
| 105 | set x "\n[db format -style table -screenwidth 52 \ |
| 106 | {SELECT * FROM mlink ORDER BY rowid}]" |
| 107 | |
| 108 | } { |
| 109 | +-----+-----+-----+-----+----+-----+-----+-----+ |
| 110 | | mid | fid |pmid | pid |fnid|pfnid|mperm|isaux| |
| 111 | +-----+-----+-----+-----+----+-----+-----+-----+ |
| 112 | |28775|28774|28773|28706| 1| 0| 0| 0| |
| 113 | |28773|28706|28770|28685| 1| 0| 0| 0| |
| 114 | |28770|28736|28769|28695| 2| 0| 0| 0| |
| 115 | |28770|28697|28769|28698| 3| 0| 0| 0| |
| 116 | |28767|28768|28759|28746| 4| 0| 0| 0| |
| 117 | +-----+-----+-----+-----+----+-----+-----+-----+ |
| 118 | } |
| 119 | |
| 120 | do_test 1.30 { |
| 121 | set x "\n[db format -style markdown -screenwidth 68 \ |
| 122 | {SELECT * FROM mlink ORDER BY rowid}]" |
| 123 | |
| 124 | } { |
| 125 | | mid | fid | pmid | pid | fnid | pfnid | mperm | isaux | |
| 126 | |-------|-------|-------|-------|------|-------|-------|-------| |
| 127 | | 28775 | 28774 | 28773 | 28706 | 1 | 0 | 0 | 0 | |
| 128 | | 28773 | 28706 | 28770 | 28685 | 1 | 0 | 0 | 0 | |
| 129 | | 28770 | 28736 | 28769 | 28695 | 2 | 0 | 0 | 0 | |
| 130 | | 28770 | 28697 | 28769 | 28698 | 3 | 0 | 0 | 0 | |
| 131 | | 28767 | 28768 | 28759 | 28746 | 4 | 0 | 0 | 0 | |
| 132 | } |
| 133 | do_test 1.31 { |
| 134 | set x "\n[db format -style markdown -screenwidth 52 \ |
| 135 | {SELECT * FROM mlink ORDER BY rowid}]" |
| 136 | |
| 137 | } { |
| 138 | | mid | fid |pmid | pid |fnid|pfnid|mperm|isaux| |
| 139 | |-----|-----|-----|-----|----|-----|-----|-----| |
| 140 | |28775|28774|28773|28706| 1| 0| 0| 0| |
| 141 | |28773|28706|28770|28685| 1| 0| 0| 0| |
| 142 | |28770|28736|28769|28695| 2| 0| 0| 0| |
| 143 | |28770|28697|28769|28698| 3| 0| 0| 0| |
| 144 | |28767|28768|28759|28746| 4| 0| 0| 0| |
| 145 | } |
| 146 | |
| 147 | do_test 1.40 { |
| 148 | set x "\n[db format -style column -screenwidth 68 \ |
| 149 | {SELECT * FROM mlink ORDER BY rowid}]" |
| 150 | |
| 151 | } { |
| 152 | mid fid pmid pid fnid pfnid mperm isaux |
| 153 | ----- ----- ----- ----- ---- ----- ----- ----- |
| 154 | 28775 28774 28773 28706 1 0 0 0 |
| 155 | 28773 28706 28770 28685 1 0 0 0 |
| 156 | 28770 28736 28769 28695 2 0 0 0 |
| 157 | 28770 28697 28769 28698 3 0 0 0 |
| 158 | 28767 28768 28759 28746 4 0 0 0 |
| 159 | } |
| 160 | do_test 1.41 { |
| 161 | set x "\n[db format -style column -screenwidth 52 \ |
| 162 | {SELECT * FROM mlink ORDER BY rowid}]" |
| 163 | |
| 164 | } { |
| 165 | mid fid pmid pid fnid pfnid mperm isaux |
| 166 | ----- ----- ----- ----- ---- ----- ----- ----- |
| 167 | 28775 28774 28773 28706 1 0 0 0 |
| 168 | 28773 28706 28770 28685 1 0 0 0 |
| 169 | 28770 28736 28769 28695 2 0 0 0 |
| 170 | 28770 28697 28769 28698 3 0 0 0 |
| 171 | 28767 28768 28759 28746 4 0 0 0 |
| 172 | } |
| 173 | |
| 174 | |
| 175 | |
| 176 | finish_test |