1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-10-23 21:49:02 +03:00

Enhance QRF so that it terminates more quickly if it encounters an OOM

or oversize string error, and fix it so that it reports such errors.

FossilOrigin-Name: ebedeb6169cc3bc3708130d4061065af600a8851e896fc3eeaf33c8c83fe3b95
This commit is contained in:
drh
2026-01-07 16:19:18 +00:00
parent 242a9347f8
commit 03c0ac435e
4 changed files with 37 additions and 12 deletions

View File

@@ -140,6 +140,15 @@ static void qrfOom(Qrf *p){
qrfError(p, SQLITE_NOMEM, "out of memory");
}
/*
** Transfer any error in pStr over into p.
*/
static void qrfStrErr(Qrf *p, sqlite3_str *pStr){
int rc = pStr ? sqlite3_str_errcode(pStr) : 0;
if( rc ){
qrfError(p, rc, sqlite3_errstr(rc));
}
}
/*
@@ -362,7 +371,9 @@ static void qrfEqpStats(Qrf *p){
qrfEqpAppend(p, iId, iPid, zo);
}
}
qrfStrErr(p, pLine);
sqlite3_free(sqlite3_str_finish(pLine));
qrfStrErr(p, pStats);
sqlite3_free(sqlite3_str_finish(pStats));
#endif
}
@@ -1876,6 +1887,7 @@ static void qrfColumnar(Qrf *p){
pStr = sqlite3_str_new(p->db);
qrfEncodeText(p, pStr, z ? z : "");
n = sqlite3_str_length(pStr);
qrfStrErr(p, pStr);
z = data.az[data.n] = sqlite3_str_finish(pStr);
if( p->spec.nTitleLimit ){
nNL = 0;
@@ -1903,6 +1915,7 @@ static void qrfColumnar(Qrf *p){
pStr = sqlite3_str_new(p->db);
qrfRenderValue(p, pStr, i);
n = sqlite3_str_length(pStr);
qrfStrErr(p, pStr);
z = data.az[data.n] = sqlite3_str_finish(pStr);
data.abNum[data.n] = eType==SQLITE_INTEGER || eType==SQLITE_FLOAT;
data.aiWth[data.n] = w = qrfDisplayWidth(z, n, &nNL);
@@ -2057,7 +2070,7 @@ static void qrfColumnar(Qrf *p){
}else{
bRTrim = 0;
}
for(i=0; i<data.n; i+=nColumn){
for(i=0; i<data.n && sqlite3_str_errcode(p->pOut)==SQLITE_OK; i+=nColumn){
int bMore;
int nRow = 0;
@@ -2244,7 +2257,7 @@ static void qrfExplain(Qrf *p){
assert( 0==sqlite3_stricmp( sqlite3_column_name(p->pStmt, 2), "p1" ) );
assert( 0==sqlite3_stricmp( sqlite3_column_name(p->pStmt, 3), "p2" ) );
for(iOp=0; SQLITE_ROW==sqlite3_step(p->pStmt); iOp++){
for(iOp=0; SQLITE_ROW==sqlite3_step(p->pStmt) && !p->iErr; iOp++){
int iAddr = sqlite3_column_int(p->pStmt, 0);
const char *zOp = (const char*)sqlite3_column_text(p->pStmt, 1);
int p1 = sqlite3_column_int(p->pStmt, 2);
@@ -2301,7 +2314,7 @@ static void qrfExplain(Qrf *p){
}
if( nArg>nWidth ) nArg = nWidth;
for(iOp=0; sqlite3_step(p->pStmt)==SQLITE_ROW; iOp++){
for(iOp=0; sqlite3_step(p->pStmt)==SQLITE_ROW && !p->iErr; iOp++){
/* If this is the first row seen, print out the headers */
if( iOp==0 ){
for(i=0; i<nArg; i++){
@@ -2557,6 +2570,7 @@ static void qrfOneSimpleRow(Qrf *p){
}while( zVal[0] );
sqlite3_str_reset(pVal);
}
qrfStrErr(p, pVal);
sqlite3_free(sqlite3_str_finish(pVal));
qrfWrite(p);
break;
@@ -2620,7 +2634,7 @@ static void qrfInitialize(
qrfOom(p);
return;
}
p->iErr = 0;
p->iErr = SQLITE_OK;
p->nCol = sqlite3_column_count(p->pStmt);
p->nRow = 0;
sz = sizeof(sqlite3_qrf_spec);
@@ -2798,6 +2812,7 @@ static void qrfFinalize(Qrf *p){
break;
}
}
qrfStrErr(p, p->pOut);
if( p->spec.pzOutput ){
if( p->spec.pzOutput[0] ){
sqlite3_int64 n, sz;

View File

@@ -1,5 +1,5 @@
C Add\sthe\s-p\sor\s--port\soption\sto\ssqlite3_rsync.
D 2026-01-06T21:39:12.874
C Enhance\sQRF\sso\sthat\sit\sterminates\smore\squickly\sif\sit\sencounters\san\sOOM\nor\soversize\sstring\serror,\sand\sfix\sit\sso\sthat\sit\sreports\ssuch\serrors.
D 2026-01-07T16:19:18.474
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -418,7 +418,7 @@ F ext/misc/zipfile.c 5234adb7566731f87de6afd612ca710766ef8c4b556f7ed210f3642d90b
F ext/misc/zorder.c bddff2e1b9661a90c95c2a9a9c7ecd8908afab5763256294dd12d609d4664eee
F ext/qrf/README.md e6e0ce2700acf6fd06312b42726a8f08ca240f30e1b122bff87c71c602046352
F ext/qrf/dev-notes.md e68a6d91ce4c7eb296ef2daadc2bb79c95c317ad15b9fafe40850c67b29c2430
F ext/qrf/qrf.c f1125c71e306106997065b4260a9870119d7c0f5556587234b8ec1747fb2d61d
F ext/qrf/qrf.c f237af24ea6293ed364405044ff334259c978dfc24aed11e49b5cba09cf580df
F ext/qrf/qrf.h 2ac14b0aaacf44636d8c81051bfeab4afae50a98fbb2e10ff5aed0c28a87b2b2
F ext/rbu/rbu.c 801450b24eaf14440d8fd20385aacc751d5c9d6123398df41b1b5aa804bf4ce8
F ext/rbu/rbu1.test 25870dd7db7eb5597e2b4d6e29e7a7e095abf332660f67d89959552ce8f8f255
@@ -1444,7 +1444,7 @@ F test/mmap4.test 2e2b4e32555b58da15176e6fe750f17c9dcf7f93
F test/mmapcorrupt.test 470fb44fe92e99c1d23701d156f8c17865f5b027063c9119dcfdb842791f4465
F test/mmapfault.test d4c9eff9cd8c2dc14bc43e71e042f175b0a26fe3
F test/mmapwarm.test 2272005969cd17a910077bd5082f70bc1fefad9a875afec7fc9af483898ecaf3
F test/modeA.sql 6d0a1b91844d378553c71526e62ee7da1cc01fb5779ab6d3a935e4dcafb2eb59
F test/modeA.sql 3f2b5a7ce7074a52b2b7ec07b07dc1a08edba19e40bce9b4d65d3965413bbea3
F test/multiplex.test d74c034e52805f6de8cc5432cef8c9eb774bb64ec29b83a22effc8ca4dac1f08
F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a
F test/multiplex3.test fac575e0b1b852025575a6a8357701d80933e98b5d2fe6d35ddaa68f92f6a1f7
@@ -2189,8 +2189,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
P 395b7168b873390c05ea2cc71fe14bafb5bdee77f32a047bec8d7ed6feb9ed90
R 61e691278319c14f8aaf1e887223f62c
P 53f806fdab7161e439a165af47bd45332c15233b87bc35c2272621256a2dc337
R cf85c1397cc1b2d22a690795998c55cf
U drh
Z 1ebada17ce6751bcaffca669ab289ad4
Z 90a7bdaa1645e01c822a73d7422497a0
# Remove this line to create a well-formed Fossil manifest.

View File

@@ -1 +1 @@
53f806fdab7161e439a165af47bd45332c15233b87bc35c2272621256a2dc337
ebedeb6169cc3bc3708130d4061065af600a8851e896fc3eeaf33c8c83fe3b95

View File

@@ -291,3 +291,13 @@ SELECT * FROM tbl1;
INSERT INTO new_table VALUES('hello!',10);
INSERT INTO new_table VALUES('goodbye',20);
END
# QRF reports an error if the string is too big.
#
.testcase 800
.mode box
.limit length 1000
WITH c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<100)
SELECT hex(randomblob(100)) c;
.check -glob "*: string or blob too big"
.limit length 10000000