mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Merge fixes from trunk.
FossilOrigin-Name: d2aac001204621062e6cb3230ce2ac1b4545cb83b3ebb6bfebccee4d51162e97
This commit is contained in:
@@ -1 +1 @@
|
|||||||
66858d87507bfdd17bb76c0afb1108ad5dec752438a79bf57f0f51690232e943
|
d2aac001204621062e6cb3230ce2ac1b4545cb83b3ebb6bfebccee4d51162e97
|
||||||
@@ -1112,8 +1112,8 @@ static void strftimeFunc(
|
|||||||
case 'm': sqlite3_snprintf(3, &z[j],"%02d",x.M); j+=2; break;
|
case 'm': sqlite3_snprintf(3, &z[j],"%02d",x.M); j+=2; break;
|
||||||
case 'M': sqlite3_snprintf(3, &z[j],"%02d",x.m); j+=2; break;
|
case 'M': sqlite3_snprintf(3, &z[j],"%02d",x.m); j+=2; break;
|
||||||
case 's': {
|
case 's': {
|
||||||
sqlite3_snprintf(30,&z[j],"%lld",
|
i64 iS = (i64)(x.iJD/1000 - 21086676*(i64)10000);
|
||||||
(i64)(x.iJD/1000 - 21086676*(i64)10000));
|
sqlite3Int64ToText(iS, &z[j]);
|
||||||
j += sqlite3Strlen30(&z[j]);
|
j += sqlite3Strlen30(&z[j]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
15
src/select.c
15
src/select.c
@@ -264,8 +264,10 @@ int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){
|
|||||||
*/
|
*/
|
||||||
static int columnIndex(Table *pTab, const char *zCol){
|
static int columnIndex(Table *pTab, const char *zCol){
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i<pTab->nCol; i++){
|
u8 h = sqlite3StrIHash(zCol);
|
||||||
if( sqlite3StrICmp(pTab->aCol[i].zName, zCol)==0 ) return i;
|
Column *pCol;
|
||||||
|
for(pCol=pTab->aCol, i=0; i<pTab->nCol; pCol++, i++){
|
||||||
|
if( pCol->hName==h && sqlite3StrICmp(pCol->zName, zCol)==0 ) return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -1136,7 +1138,14 @@ static void selectInnerLoop(
|
|||||||
{
|
{
|
||||||
int i2 = pDest->iSDParm2;
|
int i2 = pDest->iSDParm2;
|
||||||
int r1 = sqlite3GetTempReg(pParse);
|
int r1 = sqlite3GetTempReg(pParse);
|
||||||
sqlite3VdbeAddOp3(v, OP_MakeRecord,regResult+(i2<0),nResultCol-(i2<0),r1);
|
|
||||||
|
/* If the UPDATE FROM join is an aggregate that matches no rows, it
|
||||||
|
** might still be trying to return one row, because that is what
|
||||||
|
** aggregates do. Don't record that empty row in the output table. */
|
||||||
|
sqlite3VdbeAddOp2(v, OP_IsNull, regResult, iBreak); VdbeCoverage(v);
|
||||||
|
|
||||||
|
sqlite3VdbeAddOp3(v, OP_MakeRecord,
|
||||||
|
regResult+(i2<0), nResultCol-(i2<0), r1);
|
||||||
if( i2<0 ){
|
if( i2<0 ){
|
||||||
sqlite3VdbeAddOp3(v, OP_Insert, iParm, r1, regResult);
|
sqlite3VdbeAddOp3(v, OP_Insert, iParm, r1, regResult);
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -623,6 +623,21 @@ static int strlenChar(const char *z){
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Return true if zFile does not exist or if it is not an ordinary file.
|
||||||
|
*/
|
||||||
|
#ifdef _WIN32
|
||||||
|
# define notNormalFile(X) 0
|
||||||
|
#else
|
||||||
|
static int notNormalFile(const char *zFile){
|
||||||
|
struct stat x;
|
||||||
|
int rc;
|
||||||
|
memset(&x, 0, sizeof(x));
|
||||||
|
rc = stat(zFile, &x);
|
||||||
|
return rc || !S_ISREG(x.st_mode);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This routine reads a line of text from FILE in, stores
|
** This routine reads a line of text from FILE in, stores
|
||||||
** the text in memory obtained from malloc() and returns a pointer
|
** the text in memory obtained from malloc() and returns a pointer
|
||||||
@@ -8932,8 +8947,9 @@ static int do_meta_command(char *zLine, ShellState *p){
|
|||||||
rc = 1;
|
rc = 1;
|
||||||
goto meta_command_exit;
|
goto meta_command_exit;
|
||||||
}
|
}
|
||||||
p->in = fopen(azArg[1], "rb");
|
if( notNormalFile(azArg[1])
|
||||||
if( p->in==0 ){
|
|| (p->in = fopen(azArg[1], "rb"))==0
|
||||||
|
){
|
||||||
utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]);
|
utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]);
|
||||||
rc = 1;
|
rc = 1;
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -4462,6 +4462,7 @@ int sqlite3FixExpr(DbFixer*, Expr*);
|
|||||||
int sqlite3FixExprList(DbFixer*, ExprList*);
|
int sqlite3FixExprList(DbFixer*, ExprList*);
|
||||||
int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
|
int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
|
||||||
int sqlite3RealSameAsInt(double,sqlite3_int64);
|
int sqlite3RealSameAsInt(double,sqlite3_int64);
|
||||||
|
void sqlite3Int64ToText(i64,char*);
|
||||||
int sqlite3AtoF(const char *z, double*, int, u8);
|
int sqlite3AtoF(const char *z, double*, int, u8);
|
||||||
int sqlite3GetInt32(const char *, int*);
|
int sqlite3GetInt32(const char *, int*);
|
||||||
int sqlite3Atoi(const char*);
|
int sqlite3Atoi(const char*);
|
||||||
|
|||||||
24
src/util.c
24
src/util.c
@@ -595,6 +595,30 @@ do_atof_calc:
|
|||||||
#pragma warning(default : 4756)
|
#pragma warning(default : 4756)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Render an signed 64-bit integer as text. Store the result in zOut[].
|
||||||
|
**
|
||||||
|
** The caller must ensure that zOut[] is at least 21 bytes in size.
|
||||||
|
*/
|
||||||
|
void sqlite3Int64ToText(i64 v, char *zOut){
|
||||||
|
int i;
|
||||||
|
u64 x;
|
||||||
|
char zTemp[22];
|
||||||
|
if( v<0 ){
|
||||||
|
x = (v==SMALLEST_INT64) ? ((u64)1)<<63 : -v;
|
||||||
|
}else{
|
||||||
|
x = v;
|
||||||
|
}
|
||||||
|
i = sizeof(zTemp)-2;
|
||||||
|
zTemp[sizeof(zTemp)-1] = 0;
|
||||||
|
do{
|
||||||
|
zTemp[i--] = (x%10) + '0';
|
||||||
|
x = x/10;
|
||||||
|
}while( x );
|
||||||
|
if( v<0 ) zTemp[i--] = '-';
|
||||||
|
memcpy(zOut, &zTemp[i+1], sizeof(zTemp)-1-i);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Compare the 19-character string zNum against the text representation
|
** Compare the 19-character string zNum against the text representation
|
||||||
** value 2^63: 9223372036854775808. Return negative, zero, or positive
|
** value 2^63: 9223372036854775808. Return negative, zero, or positive
|
||||||
|
|||||||
@@ -104,17 +104,26 @@ int sqlite3VdbeCheckMemInvariants(Mem *p){
|
|||||||
static void vdbeMemRenderNum(int sz, char *zBuf, Mem *p){
|
static void vdbeMemRenderNum(int sz, char *zBuf, Mem *p){
|
||||||
StrAccum acc;
|
StrAccum acc;
|
||||||
assert( p->flags & (MEM_Int|MEM_Real|MEM_IntReal) );
|
assert( p->flags & (MEM_Int|MEM_Real|MEM_IntReal) );
|
||||||
sqlite3StrAccumInit(&acc, 0, zBuf, sz, 0);
|
assert( sz>22 );
|
||||||
if( p->flags & MEM_Int ){
|
if( p->flags & MEM_Int ){
|
||||||
sqlite3_str_appendf(&acc, "%lld", p->u.i);
|
#if GCC_VERSION>=7000000
|
||||||
}else if( p->flags & MEM_IntReal ){
|
/* Work-around for GCC bug
|
||||||
sqlite3_str_appendf(&acc, "%!.15g", (double)p->u.i);
|
** https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96270 */
|
||||||
|
i64 x;
|
||||||
|
assert( (p->flags&MEM_Int)*2==sizeof(x) );
|
||||||
|
memcpy(&x, (char*)&p->u, (p->flags&MEM_Int)*2);
|
||||||
|
sqlite3Int64ToText(x, zBuf);
|
||||||
|
#else
|
||||||
|
sqlite3Int64ToText(p->u.i, zBuf);
|
||||||
|
#endif
|
||||||
}else{
|
}else{
|
||||||
sqlite3_str_appendf(&acc, "%!.15g", p->u.r);
|
sqlite3StrAccumInit(&acc, 0, zBuf, sz, 0);
|
||||||
}
|
sqlite3_str_appendf(&acc, "%!.15g",
|
||||||
|
(p->flags & MEM_IntReal)!=0 ? (double)p->u.i : p->u.r);
|
||||||
assert( acc.zText==zBuf && acc.mxAlloc<=0 );
|
assert( acc.zText==zBuf && acc.mxAlloc<=0 );
|
||||||
zBuf[acc.nChar] = 0; /* Fast version of sqlite3StrAccumFinish(&acc) */
|
zBuf[acc.nChar] = 0; /* Fast version of sqlite3StrAccumFinish(&acc) */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef SQLITE_DEBUG
|
#ifdef SQLITE_DEBUG
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -164,4 +164,15 @@ do_test 2.3.2 { catch { execsql {
|
|||||||
UPDATE t5 AS apples SET b=1 FROM t5 AS apples;
|
UPDATE t5 AS apples SET b=1 FROM t5 AS apples;
|
||||||
} } } 1
|
} } } 1
|
||||||
|
|
||||||
|
# Problem found by OSSFuzz on 2020-07-20
|
||||||
|
# https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24282
|
||||||
|
#
|
||||||
|
reset_db
|
||||||
|
do_execsql_test 3.1 {
|
||||||
|
CREATE TABLE t0(a);
|
||||||
|
CREATE TABLE t1(b);
|
||||||
|
UPDATE t1 SET b=sum(a) FROM t0;
|
||||||
|
SELECT * FROM t0, t1;
|
||||||
|
} {}
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
|||||||
Reference in New Issue
Block a user