aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authordrh <>2023-01-12 13:25:48 +0000
committerdrh <>2023-01-12 13:25:48 +0000
commitf84cbd167689edf19c4905e515325a3a0c7cabe4 (patch)
treed71db36fc336a7e855ffa9f31b03d05dd8455456 /src/util.c
parent8518eaccd79ae83a55fad3c3fa545beb16fb127c (diff)
downloadsqlite-f84cbd167689edf19c4905e515325a3a0c7cabe4.tar.gz
sqlite-f84cbd167689edf19c4905e515325a3a0c7cabe4.zip
Attempt to provide a mechanism to do early termination of long-running
statement preparation by invoking the progress handler at strategic points during sqlite3_parpare(). This experiment shows that sqlite3_prepare() might leave the resulting prepared statement uninitialized following an interrupt. FossilOrigin-Name: 79636f2d80aee70832913a78933da2a7e30cc037810b93903ebbc1925ea93fef
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 23c6b1a66..a648c3a81 100644
--- a/src/util.c
+++ b/src/util.c
@@ -176,6 +176,23 @@ void sqlite3ErrorWithMsg(sqlite3 *db, int err_code, const char *zFormat, ...){
}
/*
+** Check for interrupts and invoke progress callback.
+*/
+void sqlite3ProgressCheck(Parse *p){
+ sqlite3 *db = p->db;
+ if( AtomicLoad(&db->u1.isInterrupted) ){
+ p->nErr++;
+ p->rc = SQLITE_INTERRUPT;
+ }
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+ if( db->xProgress && db->xProgress(db->pProgressArg) ){
+ p->nErr++;
+ p->rc = SQLITE_INTERRUPT;
+ }
+#endif
+}
+
+/*
** Add an error message to pParse->zErrMsg and increment pParse->nErr.
**
** This function should be used to report any error that occurs while