aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2022-02-05 23:11:19 +0000
committerdrh <>2022-02-05 23:11:19 +0000
commit4f77c9208a6d9099aafd3406faebdf2b259a35f0 (patch)
tree44ff6938656d7eab62a79d1ce75cf5f8aa372a65 /src
parent796588ae07590acbd57fcd1509aa4c9706149a7d (diff)
downloadsqlite-4f77c9208a6d9099aafd3406faebdf2b259a35f0.tar.gz
sqlite-4f77c9208a6d9099aafd3406faebdf2b259a35f0.zip
Enhance sqlite3_error_offset() to report the position of unresolved
identifiers. FossilOrigin-Name: 5b8d2577907abda10de29884716bacc10bff0df1451228a0ac40342dbea6d589
Diffstat (limited to 'src')
-rw-r--r--src/printf.c13
-rw-r--r--src/resolve.c1
-rw-r--r--src/sqliteInt.h1
3 files changed, 15 insertions, 0 deletions
diff --git a/src/printf.c b/src/printf.c
index 9fea2d6ef..a8cfc1931 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -935,6 +935,19 @@ void sqlite3RecordErrorByteOffset(sqlite3 *db, const char *z){
}
/*
+** If pExpr has a byte offset for the start of a token, record that as
+** as the error offset.
+*/
+void sqlite3RecordErrorOffsetOfExpr(sqlite3 *db, const Expr *pExpr){
+ if( db->errByteOffset>=0 ) return;
+ while( pExpr && (ExprHasProperty(pExpr,EP_FromJoin) || pExpr->w.iOfst<=0) ){
+ pExpr = pExpr->pLeft;
+ }
+ if( pExpr==0 ) return;
+ db->errByteOffset = pExpr->w.iOfst;
+}
+
+/*
** Enlarge the memory allocation on a StrAccum object so that it is
** able to accept at least N more bytes of text.
**
diff --git a/src/resolve.c b/src/resolve.c
index 78135cf3b..8250ce9ef 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -620,6 +620,7 @@ static int lookupName(
}else{
sqlite3ErrorMsg(pParse, "%s: %s", zErr, zCol);
}
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pExpr);
pParse->checkSchema = 1;
pTopNC->nNcErr++;
}
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index 58fe64ea0..1ed600f4d 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -4995,6 +4995,7 @@ void sqlite3ResultStrAccum(sqlite3_context*,StrAccum*);
void sqlite3SelectDestInit(SelectDest*,int,int);
Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);
void sqlite3RecordErrorByteOffset(sqlite3*,const char*);
+void sqlite3RecordErrorOffsetOfExpr(sqlite3*,const Expr*);
void sqlite3BackupRestart(sqlite3_backup *);
void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);