1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-12-24 14:17:58 +03:00

For CLI, fix how columnar mode fills in empty portions of wrapped row outputs.

FossilOrigin-Name: 77aed89192bdbad819ac17bf5d08728278a9b8cbbbef1d805df230caff79b417
This commit is contained in:
larrybr
2022-04-20 22:41:10 +00:00
parent 41150bf35b
commit 6403e77d3b
4 changed files with 35 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
C Fix\sa\sproblem\swith\susing\smultiple\sSQLITE_SUBTYPE\sfunction\sas\swindow\sfunctions\sin\sa\ssingle\squery.
D 2022-04-20T16:42:57.645
C For\sCLI,\sfix\show\scolumnar\smode\sfills\sin\sempty\sportions\sof\swrapped\srow\soutputs.
D 2022-04-20T22:41:10.920
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -553,7 +553,7 @@ F src/random.c 097dc8b31b8fba5a9aca1697aeb9fd82078ec91be734c16bffda620ced7ab83c
F src/resolve.c 18d99e7146852d6064559561769fcca0743eb32b14a97da6dbed373a30ee0e76
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
F src/select.c 2df3b525acb48c4e005556771164cefca301e32aad14ffc51f5c9480ea04ff38
F src/shell.c.in ecff6f4ab0e8e25acd578b3eb27ac0bad4d48643c160259a277151d6e9d412e1
F src/shell.c.in b3250485b9b6c926c2576e6e89b23574b6d59fcd04ea9bc63131a13fb4243628
F src/sqlite.h.in 2a35f62185eb5e7ecc64a2f68442b538ce9be74f80f28a00abc24837edcf1c17
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h f49e28c25bd941e79794db5415fdf7b202deb3bc072ed6f1ed273d578703684e
@@ -1389,7 +1389,7 @@ F test/sharedA.test 49d87ec54ab640fbbc3786ee3c01de94aaa482a3a9f834ad3fe92770eb69
F test/sharedB.test 16cc7178e20965d75278f410943109b77b2e645e
F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939
F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304
F test/shell1.test b224e0793c5f48aa3749e65d8c64b93a30731bd206f2e41e6c5f1bee1bdb16c6
F test/shell1.test f7a2ef8260aa01f20be3185118213b1ae70518fdcd2105f3e25b021b5ca800ac
F test/shell2.test 7a3a23a9f57b99453f1679b1fe8072cb30e382a622874c0c4d97695fadb0a787
F test/shell3.test a50628ab1d78d90889d9d3f32fb2c084ee15674771e96afe954aaa0accd1de3c
F test/shell4.test 8f6c0fce4abed19a8a7f7262517149812a04caa905d01bdc8f5e92573504b759
@@ -1945,8 +1945,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 24755fd0657252e49793bb1fe906973a2dd84a1bde03bea9a762de36cc96c2d2
R ce489bf3c5c40bd5978c1e86f73a33b2
U dan
Z 359eb52948ae09bab85dc59e491e4aa7
P 9430ead7ba433cbfce99f4f364a0c08499230e3a04f167326b0f131f098ffa09
R 6ef848a57b0ae2fb87aa59c0dc6c64a7
U larrybr
Z 0a5dc40772a2c0441c803c4b4812274a
# Remove this line to create a well-formed Fossil manifest.

View File

@@ -1 +1 @@
9430ead7ba433cbfce99f4f364a0c08499230e3a04f167326b0f131f098ffa09
77aed89192bdbad819ac17bf5d08728278a9b8cbbbef1d805df230caff79b417

View File

@@ -3350,6 +3350,8 @@ static void exec_prepared_stmt_columnar(
int bNextLine = 0;
int bMultiLineRowExists = 0;
int bw = p->cmOpts.bWordWrap;
const char *zEmpty = "";
const char *zShowNull = p->nullValue;
rc = sqlite3_step(pStmt);
if( rc!=SQLITE_ROW ) return;
@@ -3411,12 +3413,14 @@ static void exec_prepared_stmt_columnar(
if( wx<0 ) wx = -wx;
if( useNextLine ){
uz = azNextLine[i];
if( uz==0 ) uz = (char*)zEmpty;
}else if( p->cmOpts.bQuote ){
sqlite3_free(azQuoted[i]);
azQuoted[i] = quoted_column(pStmt,i);
uz = (const unsigned char*)azQuoted[i];
}else{
uz = (const unsigned char*)sqlite3_column_text(pStmt,i);
if( uz==0 ) uz = (char*)zShowNull;
}
azData[nRow*nColumn + i]
= translateForDisplayAndDup(uz, &azNextLine[i], wx, bw);
@@ -3430,7 +3434,7 @@ static void exec_prepared_stmt_columnar(
nTotal = nColumn*(nRow+1);
for(i=0; i<nTotal; i++){
z = azData[i];
if( z==0 ) z = p->nullValue;
if( z==0 ) z = (char*)zEmpty;
n = strlenChar(z);
j = i%nColumn;
if( n>p->actualWidth[j] ) p->actualWidth[j] = n;
@@ -3534,7 +3538,10 @@ columnar_end:
utf8_printf(p->out, "Interrupt\n");
}
nData = (nRow+1)*nColumn;
for(i=0; i<nData; i++) free(azData[i]);
for(i=0; i<nData; i++){
z = azData[i];
if( z!=zEmpty && z!=zShowNull ) free(azData[i]);
}
sqlite3_free(azData);
sqlite3_free((void*)azNextLine);
sqlite3_free(abRowDiv);

View File

@@ -1221,6 +1221,23 @@ do_test shell1-8.4 {
+------------------+-----+
| 6683623321994527 | -47 |
+------------------+-----+}}
do_test shell1-8.5 {
catchcmd ":memory: --box" {
create table t(a text, b int);
insert into t values ('too long for one line', 1), ('shorter', NULL);
.header on
.width 10 10
.nullvalue NADA
select * from t;}
} {0 {┌────────────┬────────────┐
│ a │ b │
├────────────┼────────────┤
│ too long f │ 1 │
│ or one lin │ │
│ e │ │
├────────────┼────────────┤
│ shorter │ NADA │
└────────────┴────────────┘}}
#----------------------------------------------------------------------------
# Test cases shell1-9.*: Basic test that "dot" commands and SQL intermix ok.