Fossil SCM

Update the built-in SQLite to the latest 3.52.0 alpha for testing.

drh 2025-12-11 23:27 trunk
Commit ae7e3f0485e46e63a1b8eaa454929c8b8529a94730510f55409adef71d8c7b08
--- extsrc/qrf.h
+++ extsrc/qrf.h
@@ -39,10 +39,11 @@
3939
unsigned char bSplitColumn; /* Wrap single-column output into many columns */
4040
unsigned char bBorder; /* Show outer border in Box and Table styles */
4141
short int nWrap; /* Wrap columns wider than this */
4242
short int nScreenWidth; /* Maximum overall table width */
4343
short int nLineLimit; /* Maximum number of lines for any row */
44
+ short int nTitleLimit; /* Maximum number of characters in a title */
4445
int nCharLimit; /* Maximum number of characters in a cell */
4546
int nWidth; /* Number of entries in aWidth[] */
4647
int nAlign; /* Number of entries in aAlignment[] */
4748
short int *aWidth; /* Column widths */
4849
unsigned char *aAlign; /* Column alignments */
4950
--- extsrc/qrf.h
+++ extsrc/qrf.h
@@ -39,10 +39,11 @@
39 unsigned char bSplitColumn; /* Wrap single-column output into many columns */
40 unsigned char bBorder; /* Show outer border in Box and Table styles */
41 short int nWrap; /* Wrap columns wider than this */
42 short int nScreenWidth; /* Maximum overall table width */
43 short int nLineLimit; /* Maximum number of lines for any row */
 
44 int nCharLimit; /* Maximum number of characters in a cell */
45 int nWidth; /* Number of entries in aWidth[] */
46 int nAlign; /* Number of entries in aAlignment[] */
47 short int *aWidth; /* Column widths */
48 unsigned char *aAlign; /* Column alignments */
49
--- extsrc/qrf.h
+++ extsrc/qrf.h
@@ -39,10 +39,11 @@
39 unsigned char bSplitColumn; /* Wrap single-column output into many columns */
40 unsigned char bBorder; /* Show outer border in Box and Table styles */
41 short int nWrap; /* Wrap columns wider than this */
42 short int nScreenWidth; /* Maximum overall table width */
43 short int nLineLimit; /* Maximum number of lines for any row */
44 short int nTitleLimit; /* Maximum number of characters in a title */
45 int nCharLimit; /* Maximum number of characters in a cell */
46 int nWidth; /* Number of entries in aWidth[] */
47 int nAlign; /* Number of entries in aAlignment[] */
48 short int *aWidth; /* Column widths */
49 unsigned char *aAlign; /* Column alignments */
50
+144 -69
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -71,18 +71,10 @@
7171
# define SHELL_STRINGIFY(f) SHELL_STRINGIFY_(f)
7272
#ifdef SQLITE_CUSTOM_INCLUDE
7373
# include SHELL_STRINGIFY(SQLITE_CUSTOM_INCLUDE)
7474
#endif
7575
76
-/*
77
-** Determine if we are dealing with WinRT, which provides only a subset of
78
-** the full Win32 API.
79
-*/
80
-#if !defined(SQLITE_OS_WINRT)
81
-# define SQLITE_OS_WINRT 0
82
-#endif
83
-
8476
/*
8577
** If SQLITE_SHELL_FIDDLE is defined then the shell is modified
8678
** somewhat for use as a WASM module in a web browser. This flag
8779
** should only be used when building the "fiddle" web application, as
8880
** the browser-mode build has much different user input requirements
@@ -218,13 +210,10 @@
218210
# define deliberate_fall_through
219211
# endif
220212
#endif
221213
222214
#if defined(_WIN32) || defined(WIN32)
223
-# if SQLITE_OS_WINRT
224
-# define SQLITE_OMIT_POPEN 1
225
-# else
226215
# include <io.h>
227216
# include <fcntl.h>
228217
# define isatty(h) _isatty(h)
229218
# ifndef access
230219
# define access(f,m) _access((f),(m))
@@ -235,11 +224,10 @@
235224
# ifndef strdup
236225
# define strdup _strdup
237226
# endif
238227
# undef pclose
239228
# define pclose _pclose
240
-# endif
241229
#else
242230
/* Make sure isatty() has a prototype. */
243231
extern int isatty(int);
244232
245233
# if !defined(__RTP__) && !defined(_WRS_KERNEL) && !defined(SQLITE_WASI)
@@ -266,13 +254,10 @@
266254
#define ToLower(X) (char)tolower((unsigned char)X)
267255
#define IsAlnum(X) isalnum((unsigned char)X)
268256
#define IsAlpha(X) isalpha((unsigned char)X)
269257
270258
#if defined(_WIN32) || defined(WIN32)
271
-#if SQLITE_OS_WINRT
272
-#include <intrin.h>
273
-#endif
274259
#undef WIN32_LEAN_AND_MEAN
275260
#define WIN32_LEAN_AND_MEAN
276261
#include <windows.h>
277262
278263
/* string conversion routines only needed on Win32 */
@@ -708,10 +693,11 @@
708693
unsigned char bSplitColumn; /* Wrap single-column output into many columns */
709694
unsigned char bBorder; /* Show outer border in Box and Table styles */
710695
short int nWrap; /* Wrap columns wider than this */
711696
short int nScreenWidth; /* Maximum overall table width */
712697
short int nLineLimit; /* Maximum number of lines for any row */
698
+ short int nTitleLimit; /* Maximum number of characters in a title */
713699
int nCharLimit; /* Maximum number of characters in a cell */
714700
int nWidth; /* Number of entries in aWidth[] */
715701
int nAlign; /* Number of entries in aAlignment[] */
716702
short int *aWidth; /* Column widths */
717703
unsigned char *aAlign; /* Column alignments */
@@ -925,11 +911,11 @@
925911
int mxWidth; /* Screen width */
926912
int mxHeight; /* nLineLimit */
927913
union {
928914
struct { /* Content for QRF_STYLE_Line */
929915
int mxColWth; /* Maximum display width of any column */
930
- const char **azCol; /* Names of output columns (MODE_Line) */
916
+ char **azCol; /* Names of output columns (MODE_Line) */
931917
} sLine;
932918
qrfEQPGraph *pGraph; /* EQP graph (Eqp, Stats, and StatsEst) */
933919
struct { /* Content for QRF_STYLE_Explain */
934920
int nIndent; /* Slots allocated for aiIndent */
935921
int iIndent; /* Current slot */
@@ -1813,10 +1799,57 @@
18131799
return (const char*)sqlite3_column_text(p->pJTrans, 0);
18141800
}else{
18151801
return 0;
18161802
}
18171803
}
1804
+
1805
+/*
1806
+** Adjust the input string zIn[] such that it is no more than N display
1807
+** characters wide. If it is wider than that, then truncate and add
1808
+** ellipsis. Or if zIn[] contains a \r or \n, truncate at that point,
1809
+** adding ellipsis. Embedded tabs in zIn[] are converted into ordinary
1810
+** spaces.
1811
+**
1812
+** Return this display width of the modified title string.
1813
+*/
1814
+static int qrfTitleLimit(char *zIn, int N){
1815
+ unsigned char *z = (unsigned char*)zIn;
1816
+ int n = 0;
1817
+ unsigned char *zEllipsis = 0;
1818
+ while( 1 /*exit-by-break*/ ){
1819
+ if( z[0]<' ' ){
1820
+ int k;
1821
+ if( z[0]==0 ){
1822
+ zEllipsis = 0;
1823
+ break;
1824
+ }else if( z[0]=='\033' && (k = qrfIsVt100(z))>0 ){
1825
+ z += k;
1826
+ }else if( z[0]=='\t' ){
1827
+ z[0] = ' ';
1828
+ }else if( z[0]=='\n' || z[0]=='\r' ){
1829
+ z[0] = ' ';
1830
+ }else{
1831
+ z++;
1832
+ }
1833
+ }else if( (0x80&z[0])==0 ){
1834
+ if( n>=(N-3) && zEllipsis==0 ) zEllipsis = z;
1835
+ if( n==N ){ z[0] = 0; break; }
1836
+ n++;
1837
+ z++;
1838
+ }else{
1839
+ int u = 0;
1840
+ int len = sqlite3_qrf_decode_utf8(z, &u);
1841
+ if( n+len>(N-3) && zEllipsis==0 ) zEllipsis = z;
1842
+ if( n+len>N ){ z[0] = 0; break; }
1843
+ z += len;
1844
+ n += sqlite3_qrf_wcwidth(u);
1845
+ }
1846
+ }
1847
+ if( zEllipsis && N>=3 ) memcpy(zEllipsis,"...",4);
1848
+ return n;
1849
+}
1850
+
18181851
18191852
/*
18201853
** Render value pVal into pOut
18211854
*/
18221855
static void qrfRenderValue(Qrf *p, sqlite3_str *pOut, int iCol){
@@ -2697,11 +2730,17 @@
26972730
int n, w;
26982731
pStr = sqlite3_str_new(p->db);
26992732
qrfEncodeText(p, pStr, z ? z : "");
27002733
n = sqlite3_str_length(pStr);
27012734
z = data.az[data.n] = sqlite3_str_finish(pStr);
2702
- data.aiWth[data.n] = w = qrfDisplayWidth(z, n, &nNL);
2735
+ if( p->spec.nTitleLimit ){
2736
+ nNL = 0;
2737
+ data.aiWth[data.n] = w = qrfTitleLimit(data.az[data.n],
2738
+ p->spec.nTitleLimit );
2739
+ }else{
2740
+ data.aiWth[data.n] = w = qrfDisplayWidth(z, n, &nNL);
2741
+ }
27032742
data.n++;
27042743
if( w>data.a[i].mxW ) data.a[i].mxW = w;
27052744
if( nNL ) data.bMultiRow = 1;
27062745
}
27072746
p->spec.eText = saved_eText;
@@ -3323,34 +3362,40 @@
33233362
}
33243363
case QRF_STYLE_Line: {
33253364
sqlite3_str *pVal;
33263365
int mxW;
33273366
int bWW;
3367
+ int nSep;
33283368
if( p->u.sLine.azCol==0 ){
33293369
p->u.sLine.azCol = sqlite3_malloc64( p->nCol*sizeof(char*) );
33303370
if( p->u.sLine.azCol==0 ){
33313371
qrfOom(p);
33323372
break;
33333373
}
33343374
p->u.sLine.mxColWth = 0;
33353375
for(i=0; i<p->nCol; i++){
33363376
int sz;
3337
- p->u.sLine.azCol[i] = sqlite3_column_name(p->pStmt, i);
3338
- if( p->u.sLine.azCol[i]==0 ) p->u.sLine.azCol[i] = "unknown";
3377
+ const char *zCName = sqlite3_column_name(p->pStmt, i);
3378
+ if( zCName==0 ) zCName = "unknown";
3379
+ p->u.sLine.azCol[i] = sqlite3_mprintf("%s", zCName);
3380
+ if( p->spec.nTitleLimit>0 ){
3381
+ (void)qrfTitleLimit(p->u.sLine.azCol[i], p->spec.nTitleLimit);
3382
+ }
33393383
sz = (int)sqlite3_qrf_wcswidth(p->u.sLine.azCol[i]);
33403384
if( sz > p->u.sLine.mxColWth ) p->u.sLine.mxColWth = sz;
33413385
}
33423386
}
33433387
if( p->nRow ) sqlite3_str_append(p->pOut, "\n", 1);
33443388
pVal = sqlite3_str_new(p->db);
3345
- mxW = p->mxWidth - (3 + p->u.sLine.mxColWth);
3389
+ nSep = (int)strlen(p->spec.zColumnSep);
3390
+ mxW = p->mxWidth - (nSep + p->u.sLine.mxColWth);
33463391
bWW = p->spec.bWordWrap==QRF_Yes;
33473392
for(i=0; i<p->nCol; i++){
33483393
const char *zVal;
33493394
int cnt = 0;
33503395
qrfWidthPrint(p, p->pOut, -p->u.sLine.mxColWth, p->u.sLine.azCol[i]);
3351
- sqlite3_str_append(p->pOut, " = ", 3);
3396
+ sqlite3_str_append(p->pOut, p->spec.zColumnSep, nSep);
33523397
qrfRenderValue(p, pVal, i);
33533398
zVal = sqlite3_str_value(pVal);
33543399
if( zVal==0 ) zVal = "";
33553400
do{
33563401
int nThis, nWide, iNext;
@@ -3476,10 +3521,16 @@
34763521
p->spec.zNull = "NULL";
34773522
if( p->spec.zTableName==0 || p->spec.zTableName[0]==0 ){
34783523
p->spec.zTableName = "tab";
34793524
}
34803525
break;
3526
+ }
3527
+ case QRF_STYLE_Line: {
3528
+ if( p->spec.zColumnSep==0 ){
3529
+ p->spec.zColumnSep = ": ";
3530
+ }
3531
+ break;
34813532
}
34823533
case QRF_STYLE_Csv: {
34833534
p->spec.eStyle = QRF_STYLE_List;
34843535
p->spec.eText = QRF_TEXT_Csv;
34853536
p->spec.zColumnSep = ",";
@@ -3585,11 +3636,15 @@
35853636
qrfWrite(p);
35863637
}
35873638
break;
35883639
}
35893640
case QRF_STYLE_Line: {
3590
- if( p->u.sLine.azCol ) sqlite3_free(p->u.sLine.azCol);
3641
+ if( p->u.sLine.azCol ){
3642
+ int i;
3643
+ for(i=0; i<p->nCol; i++) sqlite3_free(p->u.sLine.azCol[i]);
3644
+ sqlite3_free(p->u.sLine.azCol);
3645
+ }
35913646
break;
35923647
}
35933648
case QRF_STYLE_Stats:
35943649
case QRF_STYLE_StatsEst:
35953650
case QRF_STYLE_Eqp: {
@@ -3879,11 +3934,10 @@
38793934
*/
38803935
static int hasTimer(void){
38813936
if( getProcessTimesAddr ){
38823937
return 1;
38833938
} else {
3884
-#if !SQLITE_OS_WINRT
38853939
/* GetProcessTimes() isn't supported in WIN95 and some other Windows
38863940
** versions. See if the version we are running on has it, and if it
38873941
** does, save off a pointer to it and the current process handle.
38883942
*/
38893943
hProcess = GetCurrentProcess();
@@ -3896,11 +3950,10 @@
38963950
return 1;
38973951
}
38983952
FreeLibrary(hinstLib);
38993953
}
39003954
}
3901
-#endif
39023955
}
39033956
return 0;
39043957
}
39053958
39063959
/*
@@ -10765,11 +10818,10 @@
1076510818
}
1076610819
}
1076710820
1076810821
if( mtime>=0 ){
1076910822
#if defined(_WIN32)
10770
-#if !SQLITE_OS_WINRT
1077110823
/* Windows */
1077210824
FILETIME lastAccess;
1077310825
FILETIME lastWrite;
1077410826
SYSTEMTIME currentTime;
1077510827
LONGLONG intervals;
@@ -10796,11 +10848,10 @@
1079610848
CloseHandle(hFile);
1079710849
return !bResult;
1079810850
}else{
1079910851
return 1;
1080010852
}
10801
-#endif
1080210853
#elif defined(AT_FDCWD) && 0 /* utimensat() is not universally available */
1080310854
/* Recent unix */
1080410855
struct timespec times[2];
1080510856
times[0].tv_nsec = times[1].tv_nsec = 0;
1080610857
times[0].tv_sec = time(0);
@@ -13632,11 +13683,11 @@
1363213683
}else{
1363313684
err = inflate(&str, Z_NO_FLUSH);
1363413685
if( err!=Z_STREAM_END ){
1363513686
zipfileCtxErrorMsg(pCtx, "inflate() failed (%d)", err);
1363613687
}else{
13637
- sqlite3_result_blob(pCtx, aRes, nOut, zipfileFree);
13688
+ sqlite3_result_blob(pCtx, aRes, (int)str.total_out, zipfileFree);
1363813689
aRes = 0;
1363913690
}
1364013691
}
1364113692
sqlite3_free(aRes);
1364213693
inflateEnd(&str);
@@ -24319,12 +24370,12 @@
2431924370
2432024371
/* String constants used by built-in modes */
2432124372
static const char *aModeStr[] =
2432224373
/* 0 1 2 3 4 5 6 7 8 */
2432324374
{ 0, "\n", "|", " ", ",", "\r\n", "\036", "\037", "\t",
24324
- "", "NULL", "null", "\"\"" };
24325
- /* 9 10 11 12 */
24375
+ "", "NULL", "null", "\"\"", ": ", };
24376
+ /* 9 10 11 12 13 */
2432624377
2432724378
static const ModeInfo aModeInfo[] = {
2432824379
/* zName eCSep eRSep eNull eText eHdr eBlob bHdr eStyle eCx mFlg */
2432924380
{ "ascii", 7, 6, 9, 1, 1, 0, 1, 12, 0, 0 },
2433024381
{ "box", 0, 0, 9, 1, 1, 0, 2, 1, 2, 0 },
@@ -24335,11 +24386,11 @@
2433524386
{ "html", 0, 0, 9, 4, 4, 0, 2, 7, 0, 0 },
2433624387
{ "insert", 0, 0, 10, 2, 2, 0, 1, 8, 0, 0 },
2433724388
{ "jatom", 4, 1, 11, 6, 6, 0, 1, 12, 0, 0 },
2433824389
{ "jobject", 0, 1, 11, 6, 6, 0, 0, 10, 0, 0 },
2433924390
{ "json", 0, 0, 11, 6, 6, 0, 0, 9, 0, 0 },
24340
- { "line", 0, 1, 9, 1, 1, 0, 0, 11, 1, 0 },
24391
+ { "line", 13, 1, 9, 1, 1, 0, 0, 11, 1, 0 },
2434124392
{ "list", 2, 1, 9, 1, 1, 0, 1, 12, 0, 0 },
2434224393
{ "markdown", 0, 0, 9, 1, 1, 0, 2, 13, 2, 0 },
2434324394
{ "off", 0, 0, 0, 0, 0, 0, 0, 14, 0, 0 },
2434424395
{ "psql", 0, 0, 9, 1, 1, 0, 2, 19, 2, 1 },
2434524396
{ "qbox", 0, 0, 10, 2, 1, 0, 2, 1, 2, 0 },
@@ -24377,10 +24428,23 @@
2437724428
#define SEP_Comma ","
2437824429
#define SEP_CrLf "\r\n"
2437924430
#define SEP_Unit "\x1F"
2438024431
#define SEP_Record "\x1E"
2438124432
24433
+/*
24434
+** Default values for the various QRF limits
24435
+*/
24436
+#ifndef DFLT_CHAR_LIMIT
24437
+# define DFLT_CHAR_LIMIT 300
24438
+#endif
24439
+#ifndef DFLT_LINE_LIMIT
24440
+# define DFLT_LINE_LIMIT 5
24441
+#endif
24442
+#ifndef DFLT_TITLE_LIMIT
24443
+# define DFLT_TITLE_LIMIT 20
24444
+#endif
24445
+
2438224446
/*
2438324447
** Limit input nesting via .read or any other input redirect.
2438424448
** It's not too expensive, so a generous allowance can be made.
2438524449
*/
2438624450
#define MAX_INPUT_NESTING 25
@@ -24497,13 +24561,14 @@
2449724561
u8 mFlags = p->mode.mFlags;
2449824562
modeFree(&p->mode);
2449924563
modeChange(p, MODE_QBox);
2450024564
p->mode.bAutoScreenWidth = 1;
2450124565
p->mode.spec.eText = QRF_TEXT_Relaxed;
24502
- p->mode.spec.nCharLimit = 300;
24503
- p->mode.spec.nLineLimit = 5;
24566
+ p->mode.spec.nCharLimit = DFLT_CHAR_LIMIT;
24567
+ p->mode.spec.nLineLimit = DFLT_LINE_LIMIT;
2450424568
p->mode.spec.bTextJsonb = QRF_Yes;
24569
+ p->mode.spec.nTitleLimit = DFLT_TITLE_LIMIT;
2450524570
p->mode.mFlags = mFlags;
2450624571
}
2450724572
}
2450824573
2450924574
/*
@@ -26811,12 +26876,15 @@
2681126876
" or \"symbol\".\n"
2681226877
" --linelimit N Set the maximum number of output lines to show for\n"
2681326878
" any single SQL value to N. Longer values are\n"
2681426879
" truncated. Zero means \"no limit\". Only works\n"
2681526880
" in \"line\" mode and in columnar modes.\n"
26816
-" --limits L,C Shorthand for \"--linelimit L --charlimit C\".\n"
26817
-" Or \"off\" to mean \"0,0\". Or \"on\" for \"5,300\".\n"
26881
+" --limits L,C,T Shorthand for \"--linelimit L --charlimit C\n"
26882
+" --titlelimit T\". The \",T\" can be omitted in which\n"
26883
+" case the --titlelimit is unchanged. The argument\n"
26884
+" can also be \"off\" to mean \"0,0,0\" or \"on\" to\n"
26885
+" mean \"5,300,20\".\n"
2681826886
" --list List available modes\n"
2681926887
" --null STRING Render SQL NULL values as the given string\n"
2682026888
" --once Setting changes to the right are reverted after\n"
2682126889
" the next SQL command.\n"
2682226890
" --quote ARG Enable/disable quoting of text. ARG can be\n"
@@ -26834,10 +26902,11 @@
2683426902
" --tag NAME Save mode to the left as NAME.\n"
2683526903
" --textjsonb BOOLEAN If enabled, JSONB text is displayed as text JSON.\n"
2683626904
" --title ARG Whether or not to show column headers, and if so\n"
2683726905
" how to encode them. ARG can be \"off\", \"on\",\n"
2683826906
" \"sql\", \"csv\", \"html\", \"tcl\", or \"json\".\n"
26907
+" --titlelimit N Limit the length of column titles to N characters.\n"
2683926908
" -v|--verbose Verbose output\n"
2684026909
" --widths LIST Set the columns widths for columnar modes. The\n"
2684126910
" argument is a list of integers, one for each\n"
2684226911
" column. A \"0\" width means use a dynamic width\n"
2684326912
" based on the actual width of data. If there are\n"
@@ -30697,12 +30766,15 @@
3069730766
** or "symbol".
3069830767
** --linelimit N Set the maximum number of output lines to show for
3069930768
** any single SQL value to N. Longer values are
3070030769
** truncated. Zero means "no limit". Only works
3070130770
** in "line" mode and in columnar modes.
30702
-** --limits L,C Shorthand for "--linelimit L --charlimit C".
30703
-** Or "off" to mean "0,0". Or "on" for "5,300".
30771
+** --limits L,C,T Shorthand for "--linelimit L --charlimit C
30772
+** --titlelimit T". The ",T" can be omitted in which
30773
+** case the --titlelimit is unchanged. The argument
30774
+** can also be "off" to mean "0,0,0" or "on" to
30775
+** mean "5,300,20".
3070430776
** --list List available modes
3070530777
** --null STRING Render SQL NULL values as the given string
3070630778
** --once Setting changes to the right are reverted after
3070730779
** the next SQL command.
3070830780
** --quote ARG Enable/disable quoting of text. ARG can be
@@ -30720,10 +30792,11 @@
3072030792
** --tag NAME Save mode to the left as NAME.
3072130793
** --textjsonb BOOLEAN If enabled, JSONB text is displayed as text JSON.
3072230794
** --title ARG Whether or not to show column headers, and if so
3072330795
** how to encode them. ARG can be "off", "on",
3072430796
** "sql", "csv", "html", "tcl", or "json".
30797
+** --titlelimit N Limit the length of column titles to N characters.
3072530798
** -v|--verbose Verbose output
3072630799
** --widths LIST Set the columns widths for columnar modes. The
3072730800
** argument is a list of integers, one for each
3072830801
** column. A "0" width means use a dynamic width
3072930802
** based on the actual width of data. If there are
@@ -30814,21 +30887,21 @@
3081430887
k = pickStr(azArg[i], 0, "auto", "off", "on", "");
3081530888
if( k>=0 ){
3081630889
p->mode.spec.bBorder = k & 0x3;
3081730890
}
3081830891
chng = 1;
30819
- }else if( 0<=(k=pickStr(z,0,"-charlimit","-linelimit","")) ){
30892
+ }else if( 0<=(k=pickStr(z,0,"-charlimit","-linelimit","-titlelimit","")) ){
3082030893
int w; /* 0 1 */
3082130894
if( i+1>=nArg ){
3082230895
dotCmdError(p, i, "missing argument", 0);
3082330896
return 1;
3082430897
}
3082530898
w = integerValue(azArg[++i]);
30826
- if( k==0 ){
30827
- p->mode.spec.nCharLimit = w;
30828
- }else{
30829
- p->mode.spec.nLineLimit = w;
30899
+ switch( k ){
30900
+ case 0: p->mode.spec.nCharLimit = w; break;
30901
+ case 1: p->mode.spec.nLineLimit = w; break;
30902
+ default: p->mode.spec.nTitleLimit = w; break;
3083030903
}
3083130904
chng = 1;
3083230905
}else if( 0<=(k=pickStr(z,0,"-tablename","-rowsep","-colsep","-null","")) ){
3083330906
/* 0 1 2 3 */
3083430907
if( i+1>=nArg ){
@@ -30863,25 +30936,28 @@
3086330936
dotCmdError(p, i-1, "missing argument", 0);
3086430937
return 1;
3086530938
}
3086630939
k = pickStr(azArg[i],0,"on","off","");
3086730940
if( k==0 ){
30868
- p->mode.spec.nLineLimit = 5;
30869
- p->mode.spec.nCharLimit = 300;
30941
+ p->mode.spec.nLineLimit = DFLT_LINE_LIMIT;
30942
+ p->mode.spec.nCharLimit = DFLT_CHAR_LIMIT;
30943
+ p->mode.spec.nTitleLimit = DFLT_TITLE_LIMIT;
3087030944
}else if( k==1 ){
3087130945
p->mode.spec.nLineLimit = 0;
3087230946
p->mode.spec.nCharLimit = 0;
30947
+ p->mode.spec.nTitleLimit = 0;
3087330948
}else{
30874
- int L, C;
30875
- int nNum = sscanf(azArg[i], "%d,%d", &L, &C);
30876
- if( nNum!=2 || L<0 || C<0 ){
30877
- dotCmdError(p, i, "bad argument", "Should be \"L,C\" where L and C"
30878
- " are unsigned integers");
30949
+ int L, C, T = 0;
30950
+ int nNum = sscanf(azArg[i], "%d,%d,%d", &L, &C, &T);
30951
+ if( nNum<2 || L<0 || C<0 || T<0){
30952
+ dotCmdError(p, i, "bad argument", "Should be \"L,C,T\" where L, C"
30953
+ " and T are unsigned integers");
3087930954
return 1;
3088030955
}
3088130956
p->mode.spec.nLineLimit = L;
3088230957
p->mode.spec.nCharLimit = C;
30958
+ if( nNum==3 ) p->mode.spec.nTitleLimit = T;
3088330959
}
3088430960
chng = 1;
3088530961
}else if( optionMatch(z,"list") ){
3088630962
int ii;
3088730963
cli_puts("available modes:", p->out);
@@ -31134,31 +31210,38 @@
3113431210
/* 0 1 2 3 4 5 6
3113531211
** Must match QRF_BLOB_xxxx values. See all instances of tag-20251124a */
3113631212
u8 e = p->mode.spec.eBlob;
3113731213
sqlite3_str_appendf(pDesc, " --blob-quote %s", azBQuote[e]);
3113831214
}
31139
- if( !bAll && p->mode.spec.nLineLimit==0 && p->mode.spec.nCharLimit>0 ){
31140
- sqlite3_str_appendf(pDesc, " --charlimit %d",p->mode.spec.nCharLimit);
31141
- }
3114231215
zSetting = aModeStr[pI->eCSep];
3114331216
if( bAll || (zSetting && cli_strcmp(zSetting,p->mode.spec.zColumnSep)!=0) ){
3114431217
sqlite3_str_appendf(pDesc, " --colsep ");
3114531218
append_c_string(pDesc, p->mode.spec.zColumnSep);
3114631219
}
3114731220
if( bAll || p->mode.spec.eEsc!=QRF_Auto ){
3114831221
sqlite3_str_appendf(pDesc, " --escape %s",qrfEscNames[p->mode.spec.eEsc]);
3114931222
}
31150
- if( bAll || (p->mode.spec.nLineLimit>0 && p->mode.spec.nCharLimit>0) ){
31151
- if( p->mode.spec.nLineLimit==0 && p->mode.spec.nCharLimit==0 ){
31223
+ if( bAll
31224
+ || (p->mode.spec.nLineLimit>0 && pI->eCx>0)
31225
+ || p->mode.spec.nCharLimit>0
31226
+ || (p->mode.spec.nTitleLimit>0 && pI->eCx>0)
31227
+ ){
31228
+ if( p->mode.spec.nLineLimit==0
31229
+ && p->mode.spec.nCharLimit==0
31230
+ && p->mode.spec.nTitleLimit==0
31231
+ ){
3115231232
sqlite3_str_appendf(pDesc, " --limits off");
31233
+ }else if( p->mode.spec.nLineLimit==DFLT_LINE_LIMIT
31234
+ && p->mode.spec.nCharLimit==DFLT_CHAR_LIMIT
31235
+ && p->mode.spec.nTitleLimit==DFLT_TITLE_LIMIT
31236
+ ){
31237
+ sqlite3_str_appendf(pDesc, " --limits on");
3115331238
}else{
31154
- sqlite3_str_appendf(pDesc, " --limits %d,%d",
31155
- p->mode.spec.nLineLimit, p->mode.spec.nCharLimit);
31239
+ sqlite3_str_appendf(pDesc, " --limits %d,%d,%d",
31240
+ p->mode.spec.nLineLimit, p->mode.spec.nCharLimit,
31241
+ p->mode.spec.nTitleLimit);
3115631242
}
31157
- }else
31158
- if( p->mode.spec.nCharLimit==0 && p->mode.spec.nLineLimit>0 && pI->eCx>0 ){
31159
- sqlite3_str_appendf(pDesc, " --linelimit %d",p->mode.spec.nLineLimit);
3116031243
}
3116131244
zSetting = aModeStr[pI->eNull];
3116231245
if( bAll || (zSetting && cli_strcmp(zSetting,p->mode.spec.zNull)!=0) ){
3116331246
sqlite3_str_appendf(pDesc, " --null ");
3116431247
append_c_string(pDesc, p->mode.spec.zNull);
@@ -31175,13 +31258,13 @@
3117531258
}
3117631259
if( bAll
3117731260
|| (pI->eCx && (p->mode.spec.nScreenWidth>0 || p->mode.bAutoScreenWidth))
3117831261
){
3117931262
if( p->mode.bAutoScreenWidth ){
31180
- sqlite3_str_appendall(pDesc, " --screenwidth auto");
31263
+ sqlite3_str_appendall(pDesc, " --sw auto");
3118131264
}else{
31182
- sqlite3_str_appendf(pDesc," --screenwidth %d",
31265
+ sqlite3_str_appendf(pDesc," --sw %d",
3118331266
p->mode.spec.nScreenWidth);
3118431267
}
3118531268
}
3118631269
if( bAll || p->mode.eMode==MODE_Insert ){
3118731270
sqlite3_str_appendf(pDesc," --tablename ");
@@ -31221,11 +31304,11 @@
3122131304
sqlite3_str_appendf(pDesc, " --wrap %d", p->mode.spec.nWrap);
3122231305
}
3122331306
if( !bAll ) sqlite3_str_append(pDesc, " --ww", 5);
3122431307
}
3122531308
zDesc = sqlite3_str_finish(pDesc);
31226
- cli_printf(p->out, "current output mode: %s\n", zDesc);
31309
+ cli_printf(p->out, ".mode %s\n", zDesc);
3122731310
fflush(p->out);
3122831311
sqlite3_free(zDesc);
3122931312
}
3123031313
return 0;
3123131314
}
@@ -35374,22 +35457,18 @@
3537435457
/*
3537535458
** Output text to the console in a font that attracts extra attention.
3537635459
*/
3537735460
#if defined(_WIN32) || defined(WIN32)
3537835461
static void printBold(const char *zText){
35379
-#if !SQLITE_OS_WINRT
3538035462
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
3538135463
CONSOLE_SCREEN_BUFFER_INFO defaultScreenInfo;
3538235464
GetConsoleScreenBufferInfo(out, &defaultScreenInfo);
3538335465
SetConsoleTextAttribute(out,
3538435466
FOREGROUND_RED|FOREGROUND_INTENSITY
3538535467
);
35386
-#endif
3538735468
sputz(stdout, zText);
35388
-#if !SQLITE_OS_WINRT
3538935469
SetConsoleTextAttribute(out, defaultScreenInfo.wAttributes);
35390
-#endif
3539135470
}
3539235471
#else
3539335472
static void printBold(const char *zText){
3539435473
cli_printf(stdout, "\033[1m%s\033[0m", zText);
3539535474
}
@@ -35491,15 +35570,11 @@
3549135570
){
3549235571
exit(1);
3549335572
}
3549435573
}else{
3549535574
#if defined(_WIN32) || defined(WIN32)
35496
-#if SQLITE_OS_WINRT
35497
- __debugbreak();
35498
-#else
3549935575
DebugBreak();
35500
-#endif
3550135576
#elif defined(SIGTRAP)
3550235577
raise(SIGTRAP);
3550335578
#endif
3550435579
}
3550535580
}
3550635581
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -71,18 +71,10 @@
71 # define SHELL_STRINGIFY(f) SHELL_STRINGIFY_(f)
72 #ifdef SQLITE_CUSTOM_INCLUDE
73 # include SHELL_STRINGIFY(SQLITE_CUSTOM_INCLUDE)
74 #endif
75
76 /*
77 ** Determine if we are dealing with WinRT, which provides only a subset of
78 ** the full Win32 API.
79 */
80 #if !defined(SQLITE_OS_WINRT)
81 # define SQLITE_OS_WINRT 0
82 #endif
83
84 /*
85 ** If SQLITE_SHELL_FIDDLE is defined then the shell is modified
86 ** somewhat for use as a WASM module in a web browser. This flag
87 ** should only be used when building the "fiddle" web application, as
88 ** the browser-mode build has much different user input requirements
@@ -218,13 +210,10 @@
218 # define deliberate_fall_through
219 # endif
220 #endif
221
222 #if defined(_WIN32) || defined(WIN32)
223 # if SQLITE_OS_WINRT
224 # define SQLITE_OMIT_POPEN 1
225 # else
226 # include <io.h>
227 # include <fcntl.h>
228 # define isatty(h) _isatty(h)
229 # ifndef access
230 # define access(f,m) _access((f),(m))
@@ -235,11 +224,10 @@
235 # ifndef strdup
236 # define strdup _strdup
237 # endif
238 # undef pclose
239 # define pclose _pclose
240 # endif
241 #else
242 /* Make sure isatty() has a prototype. */
243 extern int isatty(int);
244
245 # if !defined(__RTP__) && !defined(_WRS_KERNEL) && !defined(SQLITE_WASI)
@@ -266,13 +254,10 @@
266 #define ToLower(X) (char)tolower((unsigned char)X)
267 #define IsAlnum(X) isalnum((unsigned char)X)
268 #define IsAlpha(X) isalpha((unsigned char)X)
269
270 #if defined(_WIN32) || defined(WIN32)
271 #if SQLITE_OS_WINRT
272 #include <intrin.h>
273 #endif
274 #undef WIN32_LEAN_AND_MEAN
275 #define WIN32_LEAN_AND_MEAN
276 #include <windows.h>
277
278 /* string conversion routines only needed on Win32 */
@@ -708,10 +693,11 @@
708 unsigned char bSplitColumn; /* Wrap single-column output into many columns */
709 unsigned char bBorder; /* Show outer border in Box and Table styles */
710 short int nWrap; /* Wrap columns wider than this */
711 short int nScreenWidth; /* Maximum overall table width */
712 short int nLineLimit; /* Maximum number of lines for any row */
 
713 int nCharLimit; /* Maximum number of characters in a cell */
714 int nWidth; /* Number of entries in aWidth[] */
715 int nAlign; /* Number of entries in aAlignment[] */
716 short int *aWidth; /* Column widths */
717 unsigned char *aAlign; /* Column alignments */
@@ -925,11 +911,11 @@
925 int mxWidth; /* Screen width */
926 int mxHeight; /* nLineLimit */
927 union {
928 struct { /* Content for QRF_STYLE_Line */
929 int mxColWth; /* Maximum display width of any column */
930 const char **azCol; /* Names of output columns (MODE_Line) */
931 } sLine;
932 qrfEQPGraph *pGraph; /* EQP graph (Eqp, Stats, and StatsEst) */
933 struct { /* Content for QRF_STYLE_Explain */
934 int nIndent; /* Slots allocated for aiIndent */
935 int iIndent; /* Current slot */
@@ -1813,10 +1799,57 @@
1813 return (const char*)sqlite3_column_text(p->pJTrans, 0);
1814 }else{
1815 return 0;
1816 }
1817 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1818
1819 /*
1820 ** Render value pVal into pOut
1821 */
1822 static void qrfRenderValue(Qrf *p, sqlite3_str *pOut, int iCol){
@@ -2697,11 +2730,17 @@
2697 int n, w;
2698 pStr = sqlite3_str_new(p->db);
2699 qrfEncodeText(p, pStr, z ? z : "");
2700 n = sqlite3_str_length(pStr);
2701 z = data.az[data.n] = sqlite3_str_finish(pStr);
2702 data.aiWth[data.n] = w = qrfDisplayWidth(z, n, &nNL);
 
 
 
 
 
 
2703 data.n++;
2704 if( w>data.a[i].mxW ) data.a[i].mxW = w;
2705 if( nNL ) data.bMultiRow = 1;
2706 }
2707 p->spec.eText = saved_eText;
@@ -3323,34 +3362,40 @@
3323 }
3324 case QRF_STYLE_Line: {
3325 sqlite3_str *pVal;
3326 int mxW;
3327 int bWW;
 
3328 if( p->u.sLine.azCol==0 ){
3329 p->u.sLine.azCol = sqlite3_malloc64( p->nCol*sizeof(char*) );
3330 if( p->u.sLine.azCol==0 ){
3331 qrfOom(p);
3332 break;
3333 }
3334 p->u.sLine.mxColWth = 0;
3335 for(i=0; i<p->nCol; i++){
3336 int sz;
3337 p->u.sLine.azCol[i] = sqlite3_column_name(p->pStmt, i);
3338 if( p->u.sLine.azCol[i]==0 ) p->u.sLine.azCol[i] = "unknown";
 
 
 
 
3339 sz = (int)sqlite3_qrf_wcswidth(p->u.sLine.azCol[i]);
3340 if( sz > p->u.sLine.mxColWth ) p->u.sLine.mxColWth = sz;
3341 }
3342 }
3343 if( p->nRow ) sqlite3_str_append(p->pOut, "\n", 1);
3344 pVal = sqlite3_str_new(p->db);
3345 mxW = p->mxWidth - (3 + p->u.sLine.mxColWth);
 
3346 bWW = p->spec.bWordWrap==QRF_Yes;
3347 for(i=0; i<p->nCol; i++){
3348 const char *zVal;
3349 int cnt = 0;
3350 qrfWidthPrint(p, p->pOut, -p->u.sLine.mxColWth, p->u.sLine.azCol[i]);
3351 sqlite3_str_append(p->pOut, " = ", 3);
3352 qrfRenderValue(p, pVal, i);
3353 zVal = sqlite3_str_value(pVal);
3354 if( zVal==0 ) zVal = "";
3355 do{
3356 int nThis, nWide, iNext;
@@ -3476,10 +3521,16 @@
3476 p->spec.zNull = "NULL";
3477 if( p->spec.zTableName==0 || p->spec.zTableName[0]==0 ){
3478 p->spec.zTableName = "tab";
3479 }
3480 break;
 
 
 
 
 
 
3481 }
3482 case QRF_STYLE_Csv: {
3483 p->spec.eStyle = QRF_STYLE_List;
3484 p->spec.eText = QRF_TEXT_Csv;
3485 p->spec.zColumnSep = ",";
@@ -3585,11 +3636,15 @@
3585 qrfWrite(p);
3586 }
3587 break;
3588 }
3589 case QRF_STYLE_Line: {
3590 if( p->u.sLine.azCol ) sqlite3_free(p->u.sLine.azCol);
 
 
 
 
3591 break;
3592 }
3593 case QRF_STYLE_Stats:
3594 case QRF_STYLE_StatsEst:
3595 case QRF_STYLE_Eqp: {
@@ -3879,11 +3934,10 @@
3879 */
3880 static int hasTimer(void){
3881 if( getProcessTimesAddr ){
3882 return 1;
3883 } else {
3884 #if !SQLITE_OS_WINRT
3885 /* GetProcessTimes() isn't supported in WIN95 and some other Windows
3886 ** versions. See if the version we are running on has it, and if it
3887 ** does, save off a pointer to it and the current process handle.
3888 */
3889 hProcess = GetCurrentProcess();
@@ -3896,11 +3950,10 @@
3896 return 1;
3897 }
3898 FreeLibrary(hinstLib);
3899 }
3900 }
3901 #endif
3902 }
3903 return 0;
3904 }
3905
3906 /*
@@ -10765,11 +10818,10 @@
10765 }
10766 }
10767
10768 if( mtime>=0 ){
10769 #if defined(_WIN32)
10770 #if !SQLITE_OS_WINRT
10771 /* Windows */
10772 FILETIME lastAccess;
10773 FILETIME lastWrite;
10774 SYSTEMTIME currentTime;
10775 LONGLONG intervals;
@@ -10796,11 +10848,10 @@
10796 CloseHandle(hFile);
10797 return !bResult;
10798 }else{
10799 return 1;
10800 }
10801 #endif
10802 #elif defined(AT_FDCWD) && 0 /* utimensat() is not universally available */
10803 /* Recent unix */
10804 struct timespec times[2];
10805 times[0].tv_nsec = times[1].tv_nsec = 0;
10806 times[0].tv_sec = time(0);
@@ -13632,11 +13683,11 @@
13632 }else{
13633 err = inflate(&str, Z_NO_FLUSH);
13634 if( err!=Z_STREAM_END ){
13635 zipfileCtxErrorMsg(pCtx, "inflate() failed (%d)", err);
13636 }else{
13637 sqlite3_result_blob(pCtx, aRes, nOut, zipfileFree);
13638 aRes = 0;
13639 }
13640 }
13641 sqlite3_free(aRes);
13642 inflateEnd(&str);
@@ -24319,12 +24370,12 @@
24319
24320 /* String constants used by built-in modes */
24321 static const char *aModeStr[] =
24322 /* 0 1 2 3 4 5 6 7 8 */
24323 { 0, "\n", "|", " ", ",", "\r\n", "\036", "\037", "\t",
24324 "", "NULL", "null", "\"\"" };
24325 /* 9 10 11 12 */
24326
24327 static const ModeInfo aModeInfo[] = {
24328 /* zName eCSep eRSep eNull eText eHdr eBlob bHdr eStyle eCx mFlg */
24329 { "ascii", 7, 6, 9, 1, 1, 0, 1, 12, 0, 0 },
24330 { "box", 0, 0, 9, 1, 1, 0, 2, 1, 2, 0 },
@@ -24335,11 +24386,11 @@
24335 { "html", 0, 0, 9, 4, 4, 0, 2, 7, 0, 0 },
24336 { "insert", 0, 0, 10, 2, 2, 0, 1, 8, 0, 0 },
24337 { "jatom", 4, 1, 11, 6, 6, 0, 1, 12, 0, 0 },
24338 { "jobject", 0, 1, 11, 6, 6, 0, 0, 10, 0, 0 },
24339 { "json", 0, 0, 11, 6, 6, 0, 0, 9, 0, 0 },
24340 { "line", 0, 1, 9, 1, 1, 0, 0, 11, 1, 0 },
24341 { "list", 2, 1, 9, 1, 1, 0, 1, 12, 0, 0 },
24342 { "markdown", 0, 0, 9, 1, 1, 0, 2, 13, 2, 0 },
24343 { "off", 0, 0, 0, 0, 0, 0, 0, 14, 0, 0 },
24344 { "psql", 0, 0, 9, 1, 1, 0, 2, 19, 2, 1 },
24345 { "qbox", 0, 0, 10, 2, 1, 0, 2, 1, 2, 0 },
@@ -24377,10 +24428,23 @@
24377 #define SEP_Comma ","
24378 #define SEP_CrLf "\r\n"
24379 #define SEP_Unit "\x1F"
24380 #define SEP_Record "\x1E"
24381
 
 
 
 
 
 
 
 
 
 
 
 
 
24382 /*
24383 ** Limit input nesting via .read or any other input redirect.
24384 ** It's not too expensive, so a generous allowance can be made.
24385 */
24386 #define MAX_INPUT_NESTING 25
@@ -24497,13 +24561,14 @@
24497 u8 mFlags = p->mode.mFlags;
24498 modeFree(&p->mode);
24499 modeChange(p, MODE_QBox);
24500 p->mode.bAutoScreenWidth = 1;
24501 p->mode.spec.eText = QRF_TEXT_Relaxed;
24502 p->mode.spec.nCharLimit = 300;
24503 p->mode.spec.nLineLimit = 5;
24504 p->mode.spec.bTextJsonb = QRF_Yes;
 
24505 p->mode.mFlags = mFlags;
24506 }
24507 }
24508
24509 /*
@@ -26811,12 +26876,15 @@
26811 " or \"symbol\".\n"
26812 " --linelimit N Set the maximum number of output lines to show for\n"
26813 " any single SQL value to N. Longer values are\n"
26814 " truncated. Zero means \"no limit\". Only works\n"
26815 " in \"line\" mode and in columnar modes.\n"
26816 " --limits L,C Shorthand for \"--linelimit L --charlimit C\".\n"
26817 " Or \"off\" to mean \"0,0\". Or \"on\" for \"5,300\".\n"
 
 
 
26818 " --list List available modes\n"
26819 " --null STRING Render SQL NULL values as the given string\n"
26820 " --once Setting changes to the right are reverted after\n"
26821 " the next SQL command.\n"
26822 " --quote ARG Enable/disable quoting of text. ARG can be\n"
@@ -26834,10 +26902,11 @@
26834 " --tag NAME Save mode to the left as NAME.\n"
26835 " --textjsonb BOOLEAN If enabled, JSONB text is displayed as text JSON.\n"
26836 " --title ARG Whether or not to show column headers, and if so\n"
26837 " how to encode them. ARG can be \"off\", \"on\",\n"
26838 " \"sql\", \"csv\", \"html\", \"tcl\", or \"json\".\n"
 
26839 " -v|--verbose Verbose output\n"
26840 " --widths LIST Set the columns widths for columnar modes. The\n"
26841 " argument is a list of integers, one for each\n"
26842 " column. A \"0\" width means use a dynamic width\n"
26843 " based on the actual width of data. If there are\n"
@@ -30697,12 +30766,15 @@
30697 ** or "symbol".
30698 ** --linelimit N Set the maximum number of output lines to show for
30699 ** any single SQL value to N. Longer values are
30700 ** truncated. Zero means "no limit". Only works
30701 ** in "line" mode and in columnar modes.
30702 ** --limits L,C Shorthand for "--linelimit L --charlimit C".
30703 ** Or "off" to mean "0,0". Or "on" for "5,300".
 
 
 
30704 ** --list List available modes
30705 ** --null STRING Render SQL NULL values as the given string
30706 ** --once Setting changes to the right are reverted after
30707 ** the next SQL command.
30708 ** --quote ARG Enable/disable quoting of text. ARG can be
@@ -30720,10 +30792,11 @@
30720 ** --tag NAME Save mode to the left as NAME.
30721 ** --textjsonb BOOLEAN If enabled, JSONB text is displayed as text JSON.
30722 ** --title ARG Whether or not to show column headers, and if so
30723 ** how to encode them. ARG can be "off", "on",
30724 ** "sql", "csv", "html", "tcl", or "json".
 
30725 ** -v|--verbose Verbose output
30726 ** --widths LIST Set the columns widths for columnar modes. The
30727 ** argument is a list of integers, one for each
30728 ** column. A "0" width means use a dynamic width
30729 ** based on the actual width of data. If there are
@@ -30814,21 +30887,21 @@
30814 k = pickStr(azArg[i], 0, "auto", "off", "on", "");
30815 if( k>=0 ){
30816 p->mode.spec.bBorder = k & 0x3;
30817 }
30818 chng = 1;
30819 }else if( 0<=(k=pickStr(z,0,"-charlimit","-linelimit","")) ){
30820 int w; /* 0 1 */
30821 if( i+1>=nArg ){
30822 dotCmdError(p, i, "missing argument", 0);
30823 return 1;
30824 }
30825 w = integerValue(azArg[++i]);
30826 if( k==0 ){
30827 p->mode.spec.nCharLimit = w;
30828 }else{
30829 p->mode.spec.nLineLimit = w;
30830 }
30831 chng = 1;
30832 }else if( 0<=(k=pickStr(z,0,"-tablename","-rowsep","-colsep","-null","")) ){
30833 /* 0 1 2 3 */
30834 if( i+1>=nArg ){
@@ -30863,25 +30936,28 @@
30863 dotCmdError(p, i-1, "missing argument", 0);
30864 return 1;
30865 }
30866 k = pickStr(azArg[i],0,"on","off","");
30867 if( k==0 ){
30868 p->mode.spec.nLineLimit = 5;
30869 p->mode.spec.nCharLimit = 300;
 
30870 }else if( k==1 ){
30871 p->mode.spec.nLineLimit = 0;
30872 p->mode.spec.nCharLimit = 0;
 
30873 }else{
30874 int L, C;
30875 int nNum = sscanf(azArg[i], "%d,%d", &L, &C);
30876 if( nNum!=2 || L<0 || C<0 ){
30877 dotCmdError(p, i, "bad argument", "Should be \"L,C\" where L and C"
30878 " are unsigned integers");
30879 return 1;
30880 }
30881 p->mode.spec.nLineLimit = L;
30882 p->mode.spec.nCharLimit = C;
 
30883 }
30884 chng = 1;
30885 }else if( optionMatch(z,"list") ){
30886 int ii;
30887 cli_puts("available modes:", p->out);
@@ -31134,31 +31210,38 @@
31134 /* 0 1 2 3 4 5 6
31135 ** Must match QRF_BLOB_xxxx values. See all instances of tag-20251124a */
31136 u8 e = p->mode.spec.eBlob;
31137 sqlite3_str_appendf(pDesc, " --blob-quote %s", azBQuote[e]);
31138 }
31139 if( !bAll && p->mode.spec.nLineLimit==0 && p->mode.spec.nCharLimit>0 ){
31140 sqlite3_str_appendf(pDesc, " --charlimit %d",p->mode.spec.nCharLimit);
31141 }
31142 zSetting = aModeStr[pI->eCSep];
31143 if( bAll || (zSetting && cli_strcmp(zSetting,p->mode.spec.zColumnSep)!=0) ){
31144 sqlite3_str_appendf(pDesc, " --colsep ");
31145 append_c_string(pDesc, p->mode.spec.zColumnSep);
31146 }
31147 if( bAll || p->mode.spec.eEsc!=QRF_Auto ){
31148 sqlite3_str_appendf(pDesc, " --escape %s",qrfEscNames[p->mode.spec.eEsc]);
31149 }
31150 if( bAll || (p->mode.spec.nLineLimit>0 && p->mode.spec.nCharLimit>0) ){
31151 if( p->mode.spec.nLineLimit==0 && p->mode.spec.nCharLimit==0 ){
 
 
 
 
 
 
 
31152 sqlite3_str_appendf(pDesc, " --limits off");
 
 
 
 
 
31153 }else{
31154 sqlite3_str_appendf(pDesc, " --limits %d,%d",
31155 p->mode.spec.nLineLimit, p->mode.spec.nCharLimit);
 
31156 }
31157 }else
31158 if( p->mode.spec.nCharLimit==0 && p->mode.spec.nLineLimit>0 && pI->eCx>0 ){
31159 sqlite3_str_appendf(pDesc, " --linelimit %d",p->mode.spec.nLineLimit);
31160 }
31161 zSetting = aModeStr[pI->eNull];
31162 if( bAll || (zSetting && cli_strcmp(zSetting,p->mode.spec.zNull)!=0) ){
31163 sqlite3_str_appendf(pDesc, " --null ");
31164 append_c_string(pDesc, p->mode.spec.zNull);
@@ -31175,13 +31258,13 @@
31175 }
31176 if( bAll
31177 || (pI->eCx && (p->mode.spec.nScreenWidth>0 || p->mode.bAutoScreenWidth))
31178 ){
31179 if( p->mode.bAutoScreenWidth ){
31180 sqlite3_str_appendall(pDesc, " --screenwidth auto");
31181 }else{
31182 sqlite3_str_appendf(pDesc," --screenwidth %d",
31183 p->mode.spec.nScreenWidth);
31184 }
31185 }
31186 if( bAll || p->mode.eMode==MODE_Insert ){
31187 sqlite3_str_appendf(pDesc," --tablename ");
@@ -31221,11 +31304,11 @@
31221 sqlite3_str_appendf(pDesc, " --wrap %d", p->mode.spec.nWrap);
31222 }
31223 if( !bAll ) sqlite3_str_append(pDesc, " --ww", 5);
31224 }
31225 zDesc = sqlite3_str_finish(pDesc);
31226 cli_printf(p->out, "current output mode: %s\n", zDesc);
31227 fflush(p->out);
31228 sqlite3_free(zDesc);
31229 }
31230 return 0;
31231 }
@@ -35374,22 +35457,18 @@
35374 /*
35375 ** Output text to the console in a font that attracts extra attention.
35376 */
35377 #if defined(_WIN32) || defined(WIN32)
35378 static void printBold(const char *zText){
35379 #if !SQLITE_OS_WINRT
35380 HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
35381 CONSOLE_SCREEN_BUFFER_INFO defaultScreenInfo;
35382 GetConsoleScreenBufferInfo(out, &defaultScreenInfo);
35383 SetConsoleTextAttribute(out,
35384 FOREGROUND_RED|FOREGROUND_INTENSITY
35385 );
35386 #endif
35387 sputz(stdout, zText);
35388 #if !SQLITE_OS_WINRT
35389 SetConsoleTextAttribute(out, defaultScreenInfo.wAttributes);
35390 #endif
35391 }
35392 #else
35393 static void printBold(const char *zText){
35394 cli_printf(stdout, "\033[1m%s\033[0m", zText);
35395 }
@@ -35491,15 +35570,11 @@
35491 ){
35492 exit(1);
35493 }
35494 }else{
35495 #if defined(_WIN32) || defined(WIN32)
35496 #if SQLITE_OS_WINRT
35497 __debugbreak();
35498 #else
35499 DebugBreak();
35500 #endif
35501 #elif defined(SIGTRAP)
35502 raise(SIGTRAP);
35503 #endif
35504 }
35505 }
35506
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -71,18 +71,10 @@
71 # define SHELL_STRINGIFY(f) SHELL_STRINGIFY_(f)
72 #ifdef SQLITE_CUSTOM_INCLUDE
73 # include SHELL_STRINGIFY(SQLITE_CUSTOM_INCLUDE)
74 #endif
75
 
 
 
 
 
 
 
 
76 /*
77 ** If SQLITE_SHELL_FIDDLE is defined then the shell is modified
78 ** somewhat for use as a WASM module in a web browser. This flag
79 ** should only be used when building the "fiddle" web application, as
80 ** the browser-mode build has much different user input requirements
@@ -218,13 +210,10 @@
210 # define deliberate_fall_through
211 # endif
212 #endif
213
214 #if defined(_WIN32) || defined(WIN32)
 
 
 
215 # include <io.h>
216 # include <fcntl.h>
217 # define isatty(h) _isatty(h)
218 # ifndef access
219 # define access(f,m) _access((f),(m))
@@ -235,11 +224,10 @@
224 # ifndef strdup
225 # define strdup _strdup
226 # endif
227 # undef pclose
228 # define pclose _pclose
 
229 #else
230 /* Make sure isatty() has a prototype. */
231 extern int isatty(int);
232
233 # if !defined(__RTP__) && !defined(_WRS_KERNEL) && !defined(SQLITE_WASI)
@@ -266,13 +254,10 @@
254 #define ToLower(X) (char)tolower((unsigned char)X)
255 #define IsAlnum(X) isalnum((unsigned char)X)
256 #define IsAlpha(X) isalpha((unsigned char)X)
257
258 #if defined(_WIN32) || defined(WIN32)
 
 
 
259 #undef WIN32_LEAN_AND_MEAN
260 #define WIN32_LEAN_AND_MEAN
261 #include <windows.h>
262
263 /* string conversion routines only needed on Win32 */
@@ -708,10 +693,11 @@
693 unsigned char bSplitColumn; /* Wrap single-column output into many columns */
694 unsigned char bBorder; /* Show outer border in Box and Table styles */
695 short int nWrap; /* Wrap columns wider than this */
696 short int nScreenWidth; /* Maximum overall table width */
697 short int nLineLimit; /* Maximum number of lines for any row */
698 short int nTitleLimit; /* Maximum number of characters in a title */
699 int nCharLimit; /* Maximum number of characters in a cell */
700 int nWidth; /* Number of entries in aWidth[] */
701 int nAlign; /* Number of entries in aAlignment[] */
702 short int *aWidth; /* Column widths */
703 unsigned char *aAlign; /* Column alignments */
@@ -925,11 +911,11 @@
911 int mxWidth; /* Screen width */
912 int mxHeight; /* nLineLimit */
913 union {
914 struct { /* Content for QRF_STYLE_Line */
915 int mxColWth; /* Maximum display width of any column */
916 char **azCol; /* Names of output columns (MODE_Line) */
917 } sLine;
918 qrfEQPGraph *pGraph; /* EQP graph (Eqp, Stats, and StatsEst) */
919 struct { /* Content for QRF_STYLE_Explain */
920 int nIndent; /* Slots allocated for aiIndent */
921 int iIndent; /* Current slot */
@@ -1813,10 +1799,57 @@
1799 return (const char*)sqlite3_column_text(p->pJTrans, 0);
1800 }else{
1801 return 0;
1802 }
1803 }
1804
1805 /*
1806 ** Adjust the input string zIn[] such that it is no more than N display
1807 ** characters wide. If it is wider than that, then truncate and add
1808 ** ellipsis. Or if zIn[] contains a \r or \n, truncate at that point,
1809 ** adding ellipsis. Embedded tabs in zIn[] are converted into ordinary
1810 ** spaces.
1811 **
1812 ** Return this display width of the modified title string.
1813 */
1814 static int qrfTitleLimit(char *zIn, int N){
1815 unsigned char *z = (unsigned char*)zIn;
1816 int n = 0;
1817 unsigned char *zEllipsis = 0;
1818 while( 1 /*exit-by-break*/ ){
1819 if( z[0]<' ' ){
1820 int k;
1821 if( z[0]==0 ){
1822 zEllipsis = 0;
1823 break;
1824 }else if( z[0]=='\033' && (k = qrfIsVt100(z))>0 ){
1825 z += k;
1826 }else if( z[0]=='\t' ){
1827 z[0] = ' ';
1828 }else if( z[0]=='\n' || z[0]=='\r' ){
1829 z[0] = ' ';
1830 }else{
1831 z++;
1832 }
1833 }else if( (0x80&z[0])==0 ){
1834 if( n>=(N-3) && zEllipsis==0 ) zEllipsis = z;
1835 if( n==N ){ z[0] = 0; break; }
1836 n++;
1837 z++;
1838 }else{
1839 int u = 0;
1840 int len = sqlite3_qrf_decode_utf8(z, &u);
1841 if( n+len>(N-3) && zEllipsis==0 ) zEllipsis = z;
1842 if( n+len>N ){ z[0] = 0; break; }
1843 z += len;
1844 n += sqlite3_qrf_wcwidth(u);
1845 }
1846 }
1847 if( zEllipsis && N>=3 ) memcpy(zEllipsis,"...",4);
1848 return n;
1849 }
1850
1851
1852 /*
1853 ** Render value pVal into pOut
1854 */
1855 static void qrfRenderValue(Qrf *p, sqlite3_str *pOut, int iCol){
@@ -2697,11 +2730,17 @@
2730 int n, w;
2731 pStr = sqlite3_str_new(p->db);
2732 qrfEncodeText(p, pStr, z ? z : "");
2733 n = sqlite3_str_length(pStr);
2734 z = data.az[data.n] = sqlite3_str_finish(pStr);
2735 if( p->spec.nTitleLimit ){
2736 nNL = 0;
2737 data.aiWth[data.n] = w = qrfTitleLimit(data.az[data.n],
2738 p->spec.nTitleLimit );
2739 }else{
2740 data.aiWth[data.n] = w = qrfDisplayWidth(z, n, &nNL);
2741 }
2742 data.n++;
2743 if( w>data.a[i].mxW ) data.a[i].mxW = w;
2744 if( nNL ) data.bMultiRow = 1;
2745 }
2746 p->spec.eText = saved_eText;
@@ -3323,34 +3362,40 @@
3362 }
3363 case QRF_STYLE_Line: {
3364 sqlite3_str *pVal;
3365 int mxW;
3366 int bWW;
3367 int nSep;
3368 if( p->u.sLine.azCol==0 ){
3369 p->u.sLine.azCol = sqlite3_malloc64( p->nCol*sizeof(char*) );
3370 if( p->u.sLine.azCol==0 ){
3371 qrfOom(p);
3372 break;
3373 }
3374 p->u.sLine.mxColWth = 0;
3375 for(i=0; i<p->nCol; i++){
3376 int sz;
3377 const char *zCName = sqlite3_column_name(p->pStmt, i);
3378 if( zCName==0 ) zCName = "unknown";
3379 p->u.sLine.azCol[i] = sqlite3_mprintf("%s", zCName);
3380 if( p->spec.nTitleLimit>0 ){
3381 (void)qrfTitleLimit(p->u.sLine.azCol[i], p->spec.nTitleLimit);
3382 }
3383 sz = (int)sqlite3_qrf_wcswidth(p->u.sLine.azCol[i]);
3384 if( sz > p->u.sLine.mxColWth ) p->u.sLine.mxColWth = sz;
3385 }
3386 }
3387 if( p->nRow ) sqlite3_str_append(p->pOut, "\n", 1);
3388 pVal = sqlite3_str_new(p->db);
3389 nSep = (int)strlen(p->spec.zColumnSep);
3390 mxW = p->mxWidth - (nSep + p->u.sLine.mxColWth);
3391 bWW = p->spec.bWordWrap==QRF_Yes;
3392 for(i=0; i<p->nCol; i++){
3393 const char *zVal;
3394 int cnt = 0;
3395 qrfWidthPrint(p, p->pOut, -p->u.sLine.mxColWth, p->u.sLine.azCol[i]);
3396 sqlite3_str_append(p->pOut, p->spec.zColumnSep, nSep);
3397 qrfRenderValue(p, pVal, i);
3398 zVal = sqlite3_str_value(pVal);
3399 if( zVal==0 ) zVal = "";
3400 do{
3401 int nThis, nWide, iNext;
@@ -3476,10 +3521,16 @@
3521 p->spec.zNull = "NULL";
3522 if( p->spec.zTableName==0 || p->spec.zTableName[0]==0 ){
3523 p->spec.zTableName = "tab";
3524 }
3525 break;
3526 }
3527 case QRF_STYLE_Line: {
3528 if( p->spec.zColumnSep==0 ){
3529 p->spec.zColumnSep = ": ";
3530 }
3531 break;
3532 }
3533 case QRF_STYLE_Csv: {
3534 p->spec.eStyle = QRF_STYLE_List;
3535 p->spec.eText = QRF_TEXT_Csv;
3536 p->spec.zColumnSep = ",";
@@ -3585,11 +3636,15 @@
3636 qrfWrite(p);
3637 }
3638 break;
3639 }
3640 case QRF_STYLE_Line: {
3641 if( p->u.sLine.azCol ){
3642 int i;
3643 for(i=0; i<p->nCol; i++) sqlite3_free(p->u.sLine.azCol[i]);
3644 sqlite3_free(p->u.sLine.azCol);
3645 }
3646 break;
3647 }
3648 case QRF_STYLE_Stats:
3649 case QRF_STYLE_StatsEst:
3650 case QRF_STYLE_Eqp: {
@@ -3879,11 +3934,10 @@
3934 */
3935 static int hasTimer(void){
3936 if( getProcessTimesAddr ){
3937 return 1;
3938 } else {
 
3939 /* GetProcessTimes() isn't supported in WIN95 and some other Windows
3940 ** versions. See if the version we are running on has it, and if it
3941 ** does, save off a pointer to it and the current process handle.
3942 */
3943 hProcess = GetCurrentProcess();
@@ -3896,11 +3950,10 @@
3950 return 1;
3951 }
3952 FreeLibrary(hinstLib);
3953 }
3954 }
 
3955 }
3956 return 0;
3957 }
3958
3959 /*
@@ -10765,11 +10818,10 @@
10818 }
10819 }
10820
10821 if( mtime>=0 ){
10822 #if defined(_WIN32)
 
10823 /* Windows */
10824 FILETIME lastAccess;
10825 FILETIME lastWrite;
10826 SYSTEMTIME currentTime;
10827 LONGLONG intervals;
@@ -10796,11 +10848,10 @@
10848 CloseHandle(hFile);
10849 return !bResult;
10850 }else{
10851 return 1;
10852 }
 
10853 #elif defined(AT_FDCWD) && 0 /* utimensat() is not universally available */
10854 /* Recent unix */
10855 struct timespec times[2];
10856 times[0].tv_nsec = times[1].tv_nsec = 0;
10857 times[0].tv_sec = time(0);
@@ -13632,11 +13683,11 @@
13683 }else{
13684 err = inflate(&str, Z_NO_FLUSH);
13685 if( err!=Z_STREAM_END ){
13686 zipfileCtxErrorMsg(pCtx, "inflate() failed (%d)", err);
13687 }else{
13688 sqlite3_result_blob(pCtx, aRes, (int)str.total_out, zipfileFree);
13689 aRes = 0;
13690 }
13691 }
13692 sqlite3_free(aRes);
13693 inflateEnd(&str);
@@ -24319,12 +24370,12 @@
24370
24371 /* String constants used by built-in modes */
24372 static const char *aModeStr[] =
24373 /* 0 1 2 3 4 5 6 7 8 */
24374 { 0, "\n", "|", " ", ",", "\r\n", "\036", "\037", "\t",
24375 "", "NULL", "null", "\"\"", ": ", };
24376 /* 9 10 11 12 13 */
24377
24378 static const ModeInfo aModeInfo[] = {
24379 /* zName eCSep eRSep eNull eText eHdr eBlob bHdr eStyle eCx mFlg */
24380 { "ascii", 7, 6, 9, 1, 1, 0, 1, 12, 0, 0 },
24381 { "box", 0, 0, 9, 1, 1, 0, 2, 1, 2, 0 },
@@ -24335,11 +24386,11 @@
24386 { "html", 0, 0, 9, 4, 4, 0, 2, 7, 0, 0 },
24387 { "insert", 0, 0, 10, 2, 2, 0, 1, 8, 0, 0 },
24388 { "jatom", 4, 1, 11, 6, 6, 0, 1, 12, 0, 0 },
24389 { "jobject", 0, 1, 11, 6, 6, 0, 0, 10, 0, 0 },
24390 { "json", 0, 0, 11, 6, 6, 0, 0, 9, 0, 0 },
24391 { "line", 13, 1, 9, 1, 1, 0, 0, 11, 1, 0 },
24392 { "list", 2, 1, 9, 1, 1, 0, 1, 12, 0, 0 },
24393 { "markdown", 0, 0, 9, 1, 1, 0, 2, 13, 2, 0 },
24394 { "off", 0, 0, 0, 0, 0, 0, 0, 14, 0, 0 },
24395 { "psql", 0, 0, 9, 1, 1, 0, 2, 19, 2, 1 },
24396 { "qbox", 0, 0, 10, 2, 1, 0, 2, 1, 2, 0 },
@@ -24377,10 +24428,23 @@
24428 #define SEP_Comma ","
24429 #define SEP_CrLf "\r\n"
24430 #define SEP_Unit "\x1F"
24431 #define SEP_Record "\x1E"
24432
24433 /*
24434 ** Default values for the various QRF limits
24435 */
24436 #ifndef DFLT_CHAR_LIMIT
24437 # define DFLT_CHAR_LIMIT 300
24438 #endif
24439 #ifndef DFLT_LINE_LIMIT
24440 # define DFLT_LINE_LIMIT 5
24441 #endif
24442 #ifndef DFLT_TITLE_LIMIT
24443 # define DFLT_TITLE_LIMIT 20
24444 #endif
24445
24446 /*
24447 ** Limit input nesting via .read or any other input redirect.
24448 ** It's not too expensive, so a generous allowance can be made.
24449 */
24450 #define MAX_INPUT_NESTING 25
@@ -24497,13 +24561,14 @@
24561 u8 mFlags = p->mode.mFlags;
24562 modeFree(&p->mode);
24563 modeChange(p, MODE_QBox);
24564 p->mode.bAutoScreenWidth = 1;
24565 p->mode.spec.eText = QRF_TEXT_Relaxed;
24566 p->mode.spec.nCharLimit = DFLT_CHAR_LIMIT;
24567 p->mode.spec.nLineLimit = DFLT_LINE_LIMIT;
24568 p->mode.spec.bTextJsonb = QRF_Yes;
24569 p->mode.spec.nTitleLimit = DFLT_TITLE_LIMIT;
24570 p->mode.mFlags = mFlags;
24571 }
24572 }
24573
24574 /*
@@ -26811,12 +26876,15 @@
26876 " or \"symbol\".\n"
26877 " --linelimit N Set the maximum number of output lines to show for\n"
26878 " any single SQL value to N. Longer values are\n"
26879 " truncated. Zero means \"no limit\". Only works\n"
26880 " in \"line\" mode and in columnar modes.\n"
26881 " --limits L,C,T Shorthand for \"--linelimit L --charlimit C\n"
26882 " --titlelimit T\". The \",T\" can be omitted in which\n"
26883 " case the --titlelimit is unchanged. The argument\n"
26884 " can also be \"off\" to mean \"0,0,0\" or \"on\" to\n"
26885 " mean \"5,300,20\".\n"
26886 " --list List available modes\n"
26887 " --null STRING Render SQL NULL values as the given string\n"
26888 " --once Setting changes to the right are reverted after\n"
26889 " the next SQL command.\n"
26890 " --quote ARG Enable/disable quoting of text. ARG can be\n"
@@ -26834,10 +26902,11 @@
26902 " --tag NAME Save mode to the left as NAME.\n"
26903 " --textjsonb BOOLEAN If enabled, JSONB text is displayed as text JSON.\n"
26904 " --title ARG Whether or not to show column headers, and if so\n"
26905 " how to encode them. ARG can be \"off\", \"on\",\n"
26906 " \"sql\", \"csv\", \"html\", \"tcl\", or \"json\".\n"
26907 " --titlelimit N Limit the length of column titles to N characters.\n"
26908 " -v|--verbose Verbose output\n"
26909 " --widths LIST Set the columns widths for columnar modes. The\n"
26910 " argument is a list of integers, one for each\n"
26911 " column. A \"0\" width means use a dynamic width\n"
26912 " based on the actual width of data. If there are\n"
@@ -30697,12 +30766,15 @@
30766 ** or "symbol".
30767 ** --linelimit N Set the maximum number of output lines to show for
30768 ** any single SQL value to N. Longer values are
30769 ** truncated. Zero means "no limit". Only works
30770 ** in "line" mode and in columnar modes.
30771 ** --limits L,C,T Shorthand for "--linelimit L --charlimit C
30772 ** --titlelimit T". The ",T" can be omitted in which
30773 ** case the --titlelimit is unchanged. The argument
30774 ** can also be "off" to mean "0,0,0" or "on" to
30775 ** mean "5,300,20".
30776 ** --list List available modes
30777 ** --null STRING Render SQL NULL values as the given string
30778 ** --once Setting changes to the right are reverted after
30779 ** the next SQL command.
30780 ** --quote ARG Enable/disable quoting of text. ARG can be
@@ -30720,10 +30792,11 @@
30792 ** --tag NAME Save mode to the left as NAME.
30793 ** --textjsonb BOOLEAN If enabled, JSONB text is displayed as text JSON.
30794 ** --title ARG Whether or not to show column headers, and if so
30795 ** how to encode them. ARG can be "off", "on",
30796 ** "sql", "csv", "html", "tcl", or "json".
30797 ** --titlelimit N Limit the length of column titles to N characters.
30798 ** -v|--verbose Verbose output
30799 ** --widths LIST Set the columns widths for columnar modes. The
30800 ** argument is a list of integers, one for each
30801 ** column. A "0" width means use a dynamic width
30802 ** based on the actual width of data. If there are
@@ -30814,21 +30887,21 @@
30887 k = pickStr(azArg[i], 0, "auto", "off", "on", "");
30888 if( k>=0 ){
30889 p->mode.spec.bBorder = k & 0x3;
30890 }
30891 chng = 1;
30892 }else if( 0<=(k=pickStr(z,0,"-charlimit","-linelimit","-titlelimit","")) ){
30893 int w; /* 0 1 */
30894 if( i+1>=nArg ){
30895 dotCmdError(p, i, "missing argument", 0);
30896 return 1;
30897 }
30898 w = integerValue(azArg[++i]);
30899 switch( k ){
30900 case 0: p->mode.spec.nCharLimit = w; break;
30901 case 1: p->mode.spec.nLineLimit = w; break;
30902 default: p->mode.spec.nTitleLimit = w; break;
30903 }
30904 chng = 1;
30905 }else if( 0<=(k=pickStr(z,0,"-tablename","-rowsep","-colsep","-null","")) ){
30906 /* 0 1 2 3 */
30907 if( i+1>=nArg ){
@@ -30863,25 +30936,28 @@
30936 dotCmdError(p, i-1, "missing argument", 0);
30937 return 1;
30938 }
30939 k = pickStr(azArg[i],0,"on","off","");
30940 if( k==0 ){
30941 p->mode.spec.nLineLimit = DFLT_LINE_LIMIT;
30942 p->mode.spec.nCharLimit = DFLT_CHAR_LIMIT;
30943 p->mode.spec.nTitleLimit = DFLT_TITLE_LIMIT;
30944 }else if( k==1 ){
30945 p->mode.spec.nLineLimit = 0;
30946 p->mode.spec.nCharLimit = 0;
30947 p->mode.spec.nTitleLimit = 0;
30948 }else{
30949 int L, C, T = 0;
30950 int nNum = sscanf(azArg[i], "%d,%d,%d", &L, &C, &T);
30951 if( nNum<2 || L<0 || C<0 || T<0){
30952 dotCmdError(p, i, "bad argument", "Should be \"L,C,T\" where L, C"
30953 " and T are unsigned integers");
30954 return 1;
30955 }
30956 p->mode.spec.nLineLimit = L;
30957 p->mode.spec.nCharLimit = C;
30958 if( nNum==3 ) p->mode.spec.nTitleLimit = T;
30959 }
30960 chng = 1;
30961 }else if( optionMatch(z,"list") ){
30962 int ii;
30963 cli_puts("available modes:", p->out);
@@ -31134,31 +31210,38 @@
31210 /* 0 1 2 3 4 5 6
31211 ** Must match QRF_BLOB_xxxx values. See all instances of tag-20251124a */
31212 u8 e = p->mode.spec.eBlob;
31213 sqlite3_str_appendf(pDesc, " --blob-quote %s", azBQuote[e]);
31214 }
 
 
 
31215 zSetting = aModeStr[pI->eCSep];
31216 if( bAll || (zSetting && cli_strcmp(zSetting,p->mode.spec.zColumnSep)!=0) ){
31217 sqlite3_str_appendf(pDesc, " --colsep ");
31218 append_c_string(pDesc, p->mode.spec.zColumnSep);
31219 }
31220 if( bAll || p->mode.spec.eEsc!=QRF_Auto ){
31221 sqlite3_str_appendf(pDesc, " --escape %s",qrfEscNames[p->mode.spec.eEsc]);
31222 }
31223 if( bAll
31224 || (p->mode.spec.nLineLimit>0 && pI->eCx>0)
31225 || p->mode.spec.nCharLimit>0
31226 || (p->mode.spec.nTitleLimit>0 && pI->eCx>0)
31227 ){
31228 if( p->mode.spec.nLineLimit==0
31229 && p->mode.spec.nCharLimit==0
31230 && p->mode.spec.nTitleLimit==0
31231 ){
31232 sqlite3_str_appendf(pDesc, " --limits off");
31233 }else if( p->mode.spec.nLineLimit==DFLT_LINE_LIMIT
31234 && p->mode.spec.nCharLimit==DFLT_CHAR_LIMIT
31235 && p->mode.spec.nTitleLimit==DFLT_TITLE_LIMIT
31236 ){
31237 sqlite3_str_appendf(pDesc, " --limits on");
31238 }else{
31239 sqlite3_str_appendf(pDesc, " --limits %d,%d,%d",
31240 p->mode.spec.nLineLimit, p->mode.spec.nCharLimit,
31241 p->mode.spec.nTitleLimit);
31242 }
 
 
 
31243 }
31244 zSetting = aModeStr[pI->eNull];
31245 if( bAll || (zSetting && cli_strcmp(zSetting,p->mode.spec.zNull)!=0) ){
31246 sqlite3_str_appendf(pDesc, " --null ");
31247 append_c_string(pDesc, p->mode.spec.zNull);
@@ -31175,13 +31258,13 @@
31258 }
31259 if( bAll
31260 || (pI->eCx && (p->mode.spec.nScreenWidth>0 || p->mode.bAutoScreenWidth))
31261 ){
31262 if( p->mode.bAutoScreenWidth ){
31263 sqlite3_str_appendall(pDesc, " --sw auto");
31264 }else{
31265 sqlite3_str_appendf(pDesc," --sw %d",
31266 p->mode.spec.nScreenWidth);
31267 }
31268 }
31269 if( bAll || p->mode.eMode==MODE_Insert ){
31270 sqlite3_str_appendf(pDesc," --tablename ");
@@ -31221,11 +31304,11 @@
31304 sqlite3_str_appendf(pDesc, " --wrap %d", p->mode.spec.nWrap);
31305 }
31306 if( !bAll ) sqlite3_str_append(pDesc, " --ww", 5);
31307 }
31308 zDesc = sqlite3_str_finish(pDesc);
31309 cli_printf(p->out, ".mode %s\n", zDesc);
31310 fflush(p->out);
31311 sqlite3_free(zDesc);
31312 }
31313 return 0;
31314 }
@@ -35374,22 +35457,18 @@
35457 /*
35458 ** Output text to the console in a font that attracts extra attention.
35459 */
35460 #if defined(_WIN32) || defined(WIN32)
35461 static void printBold(const char *zText){
 
35462 HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
35463 CONSOLE_SCREEN_BUFFER_INFO defaultScreenInfo;
35464 GetConsoleScreenBufferInfo(out, &defaultScreenInfo);
35465 SetConsoleTextAttribute(out,
35466 FOREGROUND_RED|FOREGROUND_INTENSITY
35467 );
 
35468 sputz(stdout, zText);
 
35469 SetConsoleTextAttribute(out, defaultScreenInfo.wAttributes);
 
35470 }
35471 #else
35472 static void printBold(const char *zText){
35473 cli_printf(stdout, "\033[1m%s\033[0m", zText);
35474 }
@@ -35491,15 +35570,11 @@
35570 ){
35571 exit(1);
35572 }
35573 }else{
35574 #if defined(_WIN32) || defined(WIN32)
 
 
 
35575 DebugBreak();
 
35576 #elif defined(SIGTRAP)
35577 raise(SIGTRAP);
35578 #endif
35579 }
35580 }
35581
+209 -424
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
1616
** if you want a wrapper to interface SQLite with your choice of programming
1717
** language. The code for the "sqlite3" command-line shell is also in a
1818
** separate file. This file contains only code for the core SQLite library.
1919
**
2020
** The content in this amalgamation comes from Fossil check-in
21
-** b3da6a8728641a0c9ca2f3b20c9817c0a2be with changes in files:
21
+** 01409738afc2c0d5bdaa248ffb508aa5f36a with changes in files:
2222
**
2323
**
2424
*/
2525
#ifndef SQLITE_AMALGAMATION
2626
#define SQLITE_CORE 1
@@ -467,14 +467,14 @@
467467
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468468
** [sqlite_version()] and [sqlite_source_id()].
469469
*/
470470
#define SQLITE_VERSION "3.52.0"
471471
#define SQLITE_VERSION_NUMBER 3052000
472
-#define SQLITE_SOURCE_ID "2025-12-06 11:54:43 b3da6a8728641a0c9ca2f3b20c9817c0a2be6c5bf05f020590547480d2aff0e0"
472
+#define SQLITE_SOURCE_ID "2025-12-11 23:24:05 01409738afc2c0d5bdaa248ffb508aa5f36a66390f6b8e4834734529ee8ed2fa"
473473
#define SQLITE_SCM_BRANCH "trunk"
474474
#define SQLITE_SCM_TAGS ""
475
-#define SQLITE_SCM_DATETIME "2025-12-06T11:54:43.371Z"
475
+#define SQLITE_SCM_DATETIME "2025-12-11T23:24:05.667Z"
476476
477477
/*
478478
** CAPI3REF: Run-Time Library Version Numbers
479479
** KEYWORDS: sqlite3_version sqlite3_sourceid
480480
**
@@ -30650,18 +30650,10 @@
3065030650
# define SQLITE_OS_WINCE 1
3065130651
#else
3065230652
# define SQLITE_OS_WINCE 0
3065330653
#endif
3065430654
30655
-/*
30656
-** Determine if we are dealing with WinRT, which provides only a subset of
30657
-** the full Win32 API.
30658
-*/
30659
-#if !defined(SQLITE_OS_WINRT)
30660
-# define SQLITE_OS_WINRT 0
30661
-#endif
30662
-
3066330655
/*
3066430656
** For WinCE, some API function parameters do not appear to be declared as
3066530657
** volatile.
3066630658
*/
3066730659
#if SQLITE_OS_WINCE
@@ -30672,11 +30664,11 @@
3067230664
3067330665
/*
3067430666
** For some Windows sub-platforms, the _beginthreadex() / _endthreadex()
3067530667
** functions are not available (e.g. those not using MSVC, Cygwin, etc).
3067630668
*/
30677
-#if SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \
30669
+#if SQLITE_OS_WIN && !SQLITE_OS_WINCE && \
3067830670
SQLITE_THREADSAFE>0 && !defined(__CYGWIN__)
3067930671
# define SQLITE_OS_WIN_THREADS 1
3068030672
#else
3068130673
# define SQLITE_OS_WIN_THREADS 0
3068230674
#endif
@@ -30789,15 +30781,11 @@
3078930781
static int winMutexInit(void){
3079030782
/* The first to increment to 1 does actual initialization */
3079130783
if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){
3079230784
int i;
3079330785
for(i=0; i<ArraySize(winMutex_staticMutexes); i++){
30794
-#if SQLITE_OS_WINRT
30795
- InitializeCriticalSectionEx(&winMutex_staticMutexes[i].mutex, 0, 0);
30796
-#else
3079730786
InitializeCriticalSection(&winMutex_staticMutexes[i].mutex);
30798
-#endif
3079930787
}
3080030788
winMutex_isInit = 1;
3080130789
}else{
3080230790
/* Another thread is (in the process of) initializing the static
3080330791
** mutexes */
@@ -30883,15 +30871,11 @@
3088330871
#ifdef SQLITE_DEBUG
3088430872
#ifdef SQLITE_WIN32_MUTEX_TRACE_DYNAMIC
3088530873
p->trace = 1;
3088630874
#endif
3088730875
#endif
30888
-#if SQLITE_OS_WINRT
30889
- InitializeCriticalSectionEx(&p->mutex, 0, 0);
30890
-#else
3089130876
InitializeCriticalSection(&p->mutex);
30892
-#endif
3089330877
}
3089430878
break;
3089530879
}
3089630880
default: {
3089730881
#ifdef SQLITE_ENABLE_API_ARMOR
@@ -38300,11 +38284,11 @@
3830038284
3830138285
/*****************************************************************************
3830238286
** Debugging logic
3830338287
*/
3830438288
38305
-/* SQLITE_KV_TRACE() is used for tracing calls to kvstorage routines. */
38289
+/* SQLITE_KV_TRACE() is used for tracing calls to kvrecord routines. */
3830638290
#if 0
3830738291
#define SQLITE_KV_TRACE(X) printf X
3830838292
#else
3830938293
#define SQLITE_KV_TRACE(X)
3831038294
#endif
@@ -38314,18 +38298,22 @@
3831438298
#define SQLITE_KV_LOG(X) printf X
3831538299
#else
3831638300
#define SQLITE_KV_LOG(X)
3831738301
#endif
3831838302
38319
-
3832038303
/*
3832138304
** Forward declaration of objects used by this VFS implementation
3832238305
*/
3832338306
typedef struct KVVfsFile KVVfsFile;
3832438307
3832538308
/* A single open file. There are only two files represented by this
3832638309
** VFS - the database and the rollback journal.
38310
+**
38311
+** Maintenance reminder: if this struct changes in any way, the JSON
38312
+** rendering of its structure must be updated in
38313
+** sqlite3-wasm.c:sqlite3__wasm_enum_json(). There are no binary
38314
+** compatibility concerns, so it does not need an iVersion member.
3832738315
*/
3832838316
struct KVVfsFile {
3832938317
sqlite3_file base; /* IO methods */
3833038318
const char *zClass; /* Storage class */
3833138319
int isJournal; /* True if this is a journal file */
@@ -38371,11 +38359,11 @@
3837138359
static int kvvfsSleep(sqlite3_vfs*, int microseconds);
3837238360
static int kvvfsCurrentTime(sqlite3_vfs*, double*);
3837338361
static int kvvfsCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*);
3837438362
3837538363
static sqlite3_vfs sqlite3OsKvvfsObject = {
38376
- 1, /* iVersion */
38364
+ 2, /* iVersion */
3837738365
sizeof(KVVfsFile), /* szOsFile */
3837838366
1024, /* mxPathname */
3837938367
0, /* pNext */
3838038368
"kvvfs", /* zName */
3838138369
0, /* pAppData */
@@ -38447,42 +38435,56 @@
3844738435
#include <sys/stat.h>
3844838436
#include <unistd.h>
3844938437
3845038438
/* Forward declarations for the low-level storage engine
3845138439
*/
38452
-static int kvstorageWrite(const char*, const char *zKey, const char *zData);
38453
-static int kvstorageDelete(const char*, const char *zKey);
38454
-static int kvstorageRead(const char*, const char *zKey, char *zBuf, int nBuf);
38455
-#define KVSTORAGE_KEY_SZ 32
38440
+#ifndef SQLITE_WASM
38441
+/* In WASM builds these are implemented in JS. */
38442
+static int kvrecordWrite(const char*, const char *zKey, const char *zData);
38443
+static int kvrecordDelete(const char*, const char *zKey);
38444
+static int kvrecordRead(const char*, const char *zKey, char *zBuf, int nBuf);
38445
+#endif
38446
+#ifndef KVRECORD_KEY_SZ
38447
+#define KVRECORD_KEY_SZ 32
38448
+#endif
3845638449
3845738450
/* Expand the key name with an appropriate prefix and put the result
3845838451
** in zKeyOut[]. The zKeyOut[] buffer is assumed to hold at least
38459
-** KVSTORAGE_KEY_SZ bytes.
38452
+** KVRECORD_KEY_SZ bytes.
3846038453
*/
38461
-static void kvstorageMakeKey(
38454
+static void kvrecordMakeKey(
3846238455
const char *zClass,
3846338456
const char *zKeyIn,
3846438457
char *zKeyOut
3846538458
){
38466
- sqlite3_snprintf(KVSTORAGE_KEY_SZ, zKeyOut, "kvvfs-%s-%s", zClass, zKeyIn);
38459
+ assert( zKeyIn );
38460
+ assert( zKeyOut );
38461
+ assert( zClass );
38462
+ sqlite3_snprintf(KVRECORD_KEY_SZ, zKeyOut, "kvvfs-%s-%s",
38463
+ zClass, zKeyIn);
3846738464
}
3846838465
38466
+#ifndef SQLITE_WASM
38467
+/* In WASM builds do not define APIs which use fopen(), fwrite(),
38468
+** and the like because those APIs are a portability issue for
38469
+** WASM.
38470
+*/
3846938471
/* Write content into a key. zClass is the particular namespace of the
3847038472
** underlying key/value store to use - either "local" or "session".
3847138473
**
3847238474
** Both zKey and zData are zero-terminated pure text strings.
3847338475
**
3847438476
** Return the number of errors.
3847538477
*/
38476
-static int kvstorageWrite(
38478
+static int kvrecordWrite(
3847738479
const char *zClass,
3847838480
const char *zKey,
3847938481
const char *zData
3848038482
){
3848138483
FILE *fd;
38482
- char zXKey[KVSTORAGE_KEY_SZ];
38483
- kvstorageMakeKey(zClass, zKey, zXKey);
38484
+ char zXKey[KVRECORD_KEY_SZ];
38485
+ kvrecordMakeKey(zClass, zKey, zXKey);
3848438486
fd = fopen(zXKey, "wb");
3848538487
if( fd ){
3848638488
SQLITE_KV_TRACE(("KVVFS-WRITE %-15s (%d) %.50s%s\n", zXKey,
3848738489
(int)strlen(zData), zData,
3848838490
strlen(zData)>50 ? "..." : ""));
@@ -38496,13 +38498,13 @@
3849638498
3849738499
/* Delete a key (with its corresponding data) from the key/value
3849838500
** namespace given by zClass. If the key does not previously exist,
3849938501
** this routine is a no-op.
3850038502
*/
38501
-static int kvstorageDelete(const char *zClass, const char *zKey){
38502
- char zXKey[KVSTORAGE_KEY_SZ];
38503
- kvstorageMakeKey(zClass, zKey, zXKey);
38503
+static int kvrecordDelete(const char *zClass, const char *zKey){
38504
+ char zXKey[KVRECORD_KEY_SZ];
38505
+ kvrecordMakeKey(zClass, zKey, zXKey);
3850438506
unlink(zXKey);
3850538507
SQLITE_KV_TRACE(("KVVFS-DELETE %-15s\n", zXKey));
3850638508
return 0;
3850738509
}
3850838510
@@ -38519,20 +38521,20 @@
3851938521
** If nBuf<=0 then this routine simply returns the size of the data
3852038522
** without actually reading it. Similarly, if nBuf==1 then it
3852138523
** zero-terminates zBuf at zBuf[0] and returns the size of the data
3852238524
** without reading it.
3852338525
*/
38524
-static int kvstorageRead(
38526
+static int kvrecordRead(
3852538527
const char *zClass,
3852638528
const char *zKey,
3852738529
char *zBuf,
3852838530
int nBuf
3852938531
){
3853038532
FILE *fd;
3853138533
struct stat buf;
38532
- char zXKey[KVSTORAGE_KEY_SZ];
38533
- kvstorageMakeKey(zClass, zKey, zXKey);
38534
+ char zXKey[KVRECORD_KEY_SZ];
38535
+ kvrecordMakeKey(zClass, zKey, zXKey);
3853438536
if( access(zXKey, R_OK)!=0
3853538537
|| stat(zXKey, &buf)!=0
3853638538
|| !S_ISREG(buf.st_mode)
3853738539
){
3853838540
SQLITE_KV_TRACE(("KVVFS-READ %-15s (-1)\n", zXKey));
@@ -38560,27 +38562,39 @@
3856038562
SQLITE_KV_TRACE(("KVVFS-READ %-15s (%lld) %.50s%s\n", zXKey,
3856138563
n, zBuf, n>50 ? "..." : ""));
3856238564
return (int)n;
3856338565
}
3856438566
}
38567
+#endif /* #ifndef SQLITE_WASM */
38568
+
3856538569
3856638570
/*
3856738571
** An internal level of indirection which enables us to replace the
3856838572
** kvvfs i/o methods with JavaScript implementations in WASM builds.
3856938573
** Maintenance reminder: if this struct changes in any way, the JSON
3857038574
** rendering of its structure must be updated in
3857138575
** sqlite3-wasm.c:sqlite3__wasm_enum_json(). There are no binary
38572
-** compatibility concerns, so it does not need an iVersion
38573
-** member.
38576
+** compatibility concerns, so it does not need an iVersion member.
3857438577
*/
3857538578
typedef struct sqlite3_kvvfs_methods sqlite3_kvvfs_methods;
3857638579
struct sqlite3_kvvfs_methods {
38577
- int (*xRead)(const char *zClass, const char *zKey, char *zBuf, int nBuf);
38578
- int (*xWrite)(const char *zClass, const char *zKey, const char *zData);
38579
- int (*xDelete)(const char *zClass, const char *zKey);
38580
+ int (*xRcrdRead)(const char*, const char *zKey, char *zBuf, int nBuf);
38581
+ int (*xRcrdWrite)(const char*, const char *zKey, const char *zData);
38582
+ int (*xRcrdDelete)(const char*, const char *zKey);
3858038583
const int nKeySize;
38584
+ const int nBufferSize;
38585
+#ifndef SQLITE_WASM
38586
+# define MAYBE_CONST const
38587
+#else
38588
+# define MAYBE_CONST
38589
+#endif
38590
+ MAYBE_CONST sqlite3_vfs * pVfs;
38591
+ MAYBE_CONST sqlite3_io_methods *pIoDb;
38592
+ MAYBE_CONST sqlite3_io_methods *pIoJrnl;
38593
+#undef MAYBE_CONST
3858138594
};
38595
+
3858238596
3858338597
/*
3858438598
** This object holds the kvvfs I/O methods which may be swapped out
3858538599
** for JavaScript-side implementations in WASM builds. In such builds
3858638600
** it cannot be const, but in native builds it should be so that
@@ -38592,14 +38606,24 @@
3859238606
*/
3859338607
#ifndef SQLITE_WASM
3859438608
const
3859538609
#endif
3859638610
SQLITE_PRIVATE sqlite3_kvvfs_methods sqlite3KvvfsMethods = {
38597
-kvstorageRead,
38598
-kvstorageWrite,
38599
-kvstorageDelete,
38600
-KVSTORAGE_KEY_SZ
38611
+#ifndef SQLITE_WASM
38612
+ .xRcrdRead = kvrecordRead,
38613
+ .xRcrdWrite = kvrecordWrite,
38614
+ .xRcrdDelete = kvrecordDelete,
38615
+#else
38616
+ .xRcrdRead = 0,
38617
+ .xRcrdWrite = 0,
38618
+ .xRcrdDelete = 0,
38619
+#endif
38620
+ .nKeySize = KVRECORD_KEY_SZ,
38621
+ .nBufferSize = SQLITE_KVOS_SZ,
38622
+ .pVfs = &sqlite3OsKvvfsObject,
38623
+ .pIoDb = &kvvfs_db_io_methods,
38624
+ .pIoJrnl = &kvvfs_jrnl_io_methods
3860138625
};
3860238626
3860338627
/****** Utility subroutines ************************************************/
3860438628
3860538629
/*
@@ -38622,11 +38646,14 @@
3862238646
**
3862338647
** * Because there is no overlap between the encoding characters
3862438648
** of hexadecimal and base-26 numbers, it is always clear where
3862538649
** one stops and the next begins.
3862638650
*/
38627
-static int kvvfsEncode(const char *aData, int nData, char *aOut){
38651
+#ifndef SQLITE_WASM
38652
+static
38653
+#endif
38654
+int kvvfsEncode(const char *aData, int nData, char *aOut){
3862838655
int i, j;
3862938656
const unsigned char *a = (const unsigned char*)aData;
3863038657
for(i=j=0; i<nData; i++){
3863138658
unsigned char c = a[i];
3863238659
if( c!=0 ){
@@ -38673,13 +38700,17 @@
3867338700
3867438701
/*
3867538702
** Decode the text encoding back to binary. The binary content is
3867638703
** written into pOut, which must be at least nOut bytes in length.
3867738704
**
38678
-** The return value is the number of bytes actually written into aOut[].
38705
+** The return value is the number of bytes actually written into aOut[], or
38706
+** -1 for malformed inputs.
3867938707
*/
38680
-static int kvvfsDecode(const char *a, char *aOut, int nOut){
38708
+#ifndef SQLITE_WASM
38709
+static
38710
+#endif
38711
+int kvvfsDecode(const char *a, char *aOut, int nOut){
3868138712
int i, j;
3868238713
int c;
3868338714
const unsigned char *aIn = (const unsigned char*)a;
3868438715
i = 0;
3868538716
j = 0;
@@ -38700,11 +38731,11 @@
3870038731
j += n;
3870138732
if( c==0 || mult==1 ) break; /* progress stalled if mult==1 */
3870238733
}else{
3870338734
aOut[j] = c<<4;
3870438735
c = kvvfsHexValue[aIn[++i]];
38705
- if( c<0 ) break;
38736
+ if( c<0 ) return -1 /* hex bytes are always in pairs */;
3870638737
aOut[j++] += c;
3870738738
i++;
3870838739
}
3870938740
}
3871038741
return j;
@@ -38753,17 +38784,18 @@
3875338784
** Read or write the "sz" element, containing the database file size.
3875438785
*/
3875538786
static sqlite3_int64 kvvfsReadFileSize(KVVfsFile *pFile){
3875638787
char zData[50];
3875738788
zData[0] = 0;
38758
- sqlite3KvvfsMethods.xRead(pFile->zClass, "sz", zData, sizeof(zData)-1);
38789
+ sqlite3KvvfsMethods.xRcrdRead(pFile->zClass, "sz", zData,
38790
+ sizeof(zData)-1);
3875938791
return strtoll(zData, 0, 0);
3876038792
}
3876138793
static int kvvfsWriteFileSize(KVVfsFile *pFile, sqlite3_int64 sz){
3876238794
char zData[50];
3876338795
sqlite3_snprintf(sizeof(zData), zData, "%lld", sz);
38764
- return sqlite3KvvfsMethods.xWrite(pFile->zClass, "sz", zData);
38796
+ return sqlite3KvvfsMethods.xRcrdWrite(pFile->zClass, "sz", zData);
3876538797
}
3876638798
3876738799
/****** sqlite3_io_methods methods ******************************************/
3876838800
3876938801
/*
@@ -38774,10 +38806,13 @@
3877438806
3877538807
SQLITE_KV_LOG(("xClose %s %s\n", pFile->zClass,
3877638808
pFile->isJournal ? "journal" : "db"));
3877738809
sqlite3_free(pFile->aJrnl);
3877838810
sqlite3_free(pFile->aData);
38811
+#ifdef SQLITE_WASM
38812
+ memset(pFile, 0, sizeof(*pFile));
38813
+#endif
3877938814
return SQLITE_OK;
3878038815
}
3878138816
3878238817
/*
3878338818
** Read from the -journal file.
@@ -38790,20 +38825,26 @@
3879038825
){
3879138826
KVVfsFile *pFile = (KVVfsFile*)pProtoFile;
3879238827
assert( pFile->isJournal );
3879338828
SQLITE_KV_LOG(("xRead('%s-journal',%d,%lld)\n", pFile->zClass, iAmt, iOfst));
3879438829
if( pFile->aJrnl==0 ){
38795
- int szTxt = kvstorageRead(pFile->zClass, "jrnl", 0, 0);
38830
+ int rc;
38831
+ int szTxt = sqlite3KvvfsMethods.xRcrdRead(pFile->zClass, "jrnl",
38832
+ 0, 0);
3879638833
char *aTxt;
3879738834
if( szTxt<=4 ){
3879838835
return SQLITE_IOERR;
3879938836
}
3880038837
aTxt = sqlite3_malloc64( szTxt+1 );
3880138838
if( aTxt==0 ) return SQLITE_NOMEM;
38802
- kvstorageRead(pFile->zClass, "jrnl", aTxt, szTxt+1);
38803
- kvvfsDecodeJournal(pFile, aTxt, szTxt);
38839
+ rc = sqlite3KvvfsMethods.xRcrdRead(pFile->zClass, "jrnl",
38840
+ aTxt, szTxt+1);
38841
+ if( rc>=0 ){
38842
+ kvvfsDecodeJournal(pFile, aTxt, szTxt);
38843
+ }
3880438844
sqlite3_free(aTxt);
38845
+ if( rc ) return rc;
3880538846
if( pFile->aJrnl==0 ) return SQLITE_IOERR;
3880638847
}
3880738848
if( iOfst+iAmt>pFile->nJrnl ){
3880838849
return SQLITE_IOERR_SHORT_READ;
3880938850
}
@@ -38839,12 +38880,12 @@
3883938880
pgno = 1 + iOfst/iAmt;
3884038881
}else{
3884138882
pgno = 1;
3884238883
}
3884338884
sqlite3_snprintf(sizeof(zKey), zKey, "%u", pgno);
38844
- got = sqlite3KvvfsMethods.xRead(pFile->zClass, zKey,
38845
- aData, SQLITE_KVOS_SZ-1);
38885
+ got = sqlite3KvvfsMethods.xRcrdRead(pFile->zClass, zKey,
38886
+ aData, SQLITE_KVOS_SZ-1);
3884638887
if( got<0 ){
3884738888
n = 0;
3884838889
}else{
3884938890
aData[got] = 0;
3885038891
if( iOfst+iAmt<512 ){
@@ -38908,35 +38949,36 @@
3890838949
){
3890938950
KVVfsFile *pFile = (KVVfsFile*)pProtoFile;
3891038951
unsigned int pgno;
3891138952
char zKey[30];
3891238953
char *aData = pFile->aData;
38954
+ int rc;
3891338955
SQLITE_KV_LOG(("xWrite('%s-db',%d,%lld)\n", pFile->zClass, iAmt, iOfst));
3891438956
assert( iAmt>=512 && iAmt<=65536 );
3891538957
assert( (iAmt & (iAmt-1))==0 );
3891638958
assert( pFile->szPage<0 || pFile->szPage==iAmt );
3891738959
pFile->szPage = iAmt;
3891838960
pgno = 1 + iOfst/iAmt;
3891938961
sqlite3_snprintf(sizeof(zKey), zKey, "%u", pgno);
3892038962
kvvfsEncode(zBuf, iAmt, aData);
38921
- if( sqlite3KvvfsMethods.xWrite(pFile->zClass, zKey, aData) ){
38922
- return SQLITE_IOERR;
38963
+ rc = sqlite3KvvfsMethods.xRcrdWrite(pFile->zClass, zKey, aData);
38964
+ if( 0==rc ){
38965
+ if( iOfst+iAmt > pFile->szDb ){
38966
+ pFile->szDb = iOfst + iAmt;
38967
+ }
3892338968
}
38924
- if( iOfst+iAmt > pFile->szDb ){
38925
- pFile->szDb = iOfst + iAmt;
38926
- }
38927
- return SQLITE_OK;
38969
+ return rc;
3892838970
}
3892938971
3893038972
/*
3893138973
** Truncate an kvvfs-file.
3893238974
*/
3893338975
static int kvvfsTruncateJrnl(sqlite3_file *pProtoFile, sqlite_int64 size){
3893438976
KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
3893538977
SQLITE_KV_LOG(("xTruncate('%s-journal',%lld)\n", pFile->zClass, size));
3893638978
assert( size==0 );
38937
- sqlite3KvvfsMethods.xDelete(pFile->zClass, "jrnl");
38979
+ sqlite3KvvfsMethods.xRcrdDelete(pFile->zClass, "jrnl");
3893838980
sqlite3_free(pFile->aJrnl);
3893938981
pFile->aJrnl = 0;
3894038982
pFile->nJrnl = 0;
3894138983
return SQLITE_OK;
3894238984
}
@@ -38951,11 +38993,11 @@
3895138993
SQLITE_KV_LOG(("xTruncate('%s-db',%lld)\n", pFile->zClass, size));
3895238994
pgno = 1 + size/pFile->szPage;
3895338995
pgnoMax = 2 + pFile->szDb/pFile->szPage;
3895438996
while( pgno<=pgnoMax ){
3895538997
sqlite3_snprintf(sizeof(zKey), zKey, "%u", pgno);
38956
- sqlite3KvvfsMethods.xDelete(pFile->zClass, zKey);
38998
+ sqlite3KvvfsMethods.xRcrdDelete(pFile->zClass, zKey);
3895738999
pgno++;
3895839000
}
3895939001
pFile->szDb = size;
3896039002
return kvvfsWriteFileSize(pFile, size) ? SQLITE_IOERR : SQLITE_OK;
3896139003
}
@@ -38983,11 +39025,11 @@
3898339025
zOut[i++] = 'a' + (n%26);
3898439026
n /= 26;
3898539027
}while( n>0 );
3898639028
zOut[i++] = ' ';
3898739029
kvvfsEncode(pFile->aJrnl, pFile->nJrnl, &zOut[i]);
38988
- i = sqlite3KvvfsMethods.xWrite(pFile->zClass, "jrnl", zOut);
39030
+ i = sqlite3KvvfsMethods.xRcrdWrite(pFile->zClass, "jrnl", zOut);
3898939031
sqlite3_free(zOut);
3899039032
return i ? SQLITE_IOERR : SQLITE_OK;
3899139033
}
3899239034
static int kvvfsSyncDb(sqlite3_file *pProtoFile, int flags){
3899339035
return SQLITE_OK;
@@ -39097,53 +39139,56 @@
3909739139
int *pOutFlags
3909839140
){
3909939141
KVVfsFile *pFile = (KVVfsFile*)pProtoFile;
3910039142
if( zName==0 ) zName = "";
3910139143
SQLITE_KV_LOG(("xOpen(\"%s\")\n", zName));
39102
- if( strcmp(zName, "local")==0
39103
- || strcmp(zName, "session")==0
39104
- ){
39105
- pFile->isJournal = 0;
39106
- pFile->base.pMethods = &kvvfs_db_io_methods;
39107
- }else
39108
- if( strcmp(zName, "local-journal")==0
39109
- || strcmp(zName, "session-journal")==0
39110
- ){
39144
+ assert(!pFile->zClass);
39145
+ assert(!pFile->aData);
39146
+ assert(!pFile->aJrnl);
39147
+ assert(!pFile->nJrnl);
39148
+ assert(!pFile->base.pMethods);
39149
+ pFile->szPage = -1;
39150
+ pFile->szDb = -1;
39151
+ if( 0==sqlite3_strglob("*-journal", zName) ){
3911139152
pFile->isJournal = 1;
3911239153
pFile->base.pMethods = &kvvfs_jrnl_io_methods;
39154
+ if( 0==strcmp("session-journal",zName) ){
39155
+ pFile->zClass = "session";
39156
+ }else if( 0==strcmp("local-journal",zName) ){
39157
+ pFile->zClass = "local";
39158
+ }
3911339159
}else{
39114
- return SQLITE_CANTOPEN;
39160
+ pFile->isJournal = 0;
39161
+ pFile->base.pMethods = &kvvfs_db_io_methods;
3911539162
}
39116
- if( zName[0]=='s' ){
39117
- pFile->zClass = "session";
39118
- }else{
39119
- pFile->zClass = "local";
39163
+ if( !pFile->zClass ){
39164
+ pFile->zClass = zName;
3912039165
}
3912139166
pFile->aData = sqlite3_malloc64(SQLITE_KVOS_SZ);
3912239167
if( pFile->aData==0 ){
3912339168
return SQLITE_NOMEM;
3912439169
}
39125
- pFile->aJrnl = 0;
39126
- pFile->nJrnl = 0;
39127
- pFile->szPage = -1;
39128
- pFile->szDb = -1;
3912939170
return SQLITE_OK;
3913039171
}
3913139172
3913239173
/*
3913339174
** Delete the file located at zPath. If the dirSync argument is true,
3913439175
** ensure the file-system modifications are synced to disk before
3913539176
** returning.
3913639177
*/
3913739178
static int kvvfsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
39179
+ int rc /* The JS impl can fail with OOM in argument conversion */;
3913839180
if( strcmp(zPath, "local-journal")==0 ){
39139
- sqlite3KvvfsMethods.xDelete("local", "jrnl");
39181
+ rc = sqlite3KvvfsMethods.xRcrdDelete("local", "jrnl");
3914039182
}else
3914139183
if( strcmp(zPath, "session-journal")==0 ){
39142
- sqlite3KvvfsMethods.xDelete("session", "jrnl");
39184
+ rc = sqlite3KvvfsMethods.xRcrdDelete("session", "jrnl");
3914339185
}
39144
- return SQLITE_OK;
39186
+ else{
39187
+ rc = 0;
39188
+ }
39189
+ return rc;
3914539190
}
3914639191
3914739192
/*
3914839193
** Test for access permissions. Return true if the requested permission
3914939194
** is available, or false otherwise.
@@ -39153,25 +39198,46 @@
3915339198
const char *zPath,
3915439199
int flags,
3915539200
int *pResOut
3915639201
){
3915739202
SQLITE_KV_LOG(("xAccess(\"%s\")\n", zPath));
39203
+#if 0 && defined(SQLITE_WASM)
39204
+ /*
39205
+ ** This is not having the desired effect in the JS bindings.
39206
+ ** It's ostensibly the same logic as the #else block, but
39207
+ ** it's not behaving that way.
39208
+ **
39209
+ ** In JS we map all zPaths to Storage objects, and -journal files
39210
+ ** are mapped to the storage for the main db (which is is exactly
39211
+ ** what the mapping of "local-journal" -> "local" is doing).
39212
+ */
39213
+ const char *zKey = (0==sqlite3_strglob("*-journal", zPath))
39214
+ ? "jrnl" : "sz";
39215
+ *pResOut =
39216
+ sqlite3KvvfsMethods.xRcrdRead(zPath, zKey, 0, 0)>0;
39217
+#else
3915839218
if( strcmp(zPath, "local-journal")==0 ){
39159
- *pResOut = sqlite3KvvfsMethods.xRead("local", "jrnl", 0, 0)>0;
39219
+ *pResOut =
39220
+ sqlite3KvvfsMethods.xRcrdRead("local", "jrnl", 0, 0)>0;
3916039221
}else
3916139222
if( strcmp(zPath, "session-journal")==0 ){
39162
- *pResOut = sqlite3KvvfsMethods.xRead("session", "jrnl", 0, 0)>0;
39223
+ *pResOut =
39224
+ sqlite3KvvfsMethods.xRcrdRead("session", "jrnl", 0, 0)>0;
3916339225
}else
3916439226
if( strcmp(zPath, "local")==0 ){
39165
- *pResOut = sqlite3KvvfsMethods.xRead("local", "sz", 0, 0)>0;
39227
+ *pResOut =
39228
+ sqlite3KvvfsMethods.xRcrdRead("local", "sz", 0, 0)>0;
3916639229
}else
3916739230
if( strcmp(zPath, "session")==0 ){
39168
- *pResOut = sqlite3KvvfsMethods.xRead("session", "sz", 0, 0)>0;
39231
+ *pResOut =
39232
+ sqlite3KvvfsMethods.xRcrdRead("session", "sz", 0, 0)>0;
3916939233
}else
3917039234
{
3917139235
*pResOut = 0;
3917239236
}
39237
+ /*all current JS tests avoid triggering: assert( *pResOut == 0 ); */
39238
+#endif
3917339239
SQLITE_KV_LOG(("xAccess returns %d\n",*pResOut));
3917439240
return SQLITE_OK;
3917539241
}
3917639242
3917739243
/*
@@ -47896,19 +47962,19 @@
4789647962
4789747963
/*
4789847964
** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
4789947965
** based on the sub-platform)?
4790047966
*/
47901
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(SQLITE_WIN32_NO_ANSI)
47967
+#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_ANSI)
4790247968
# define SQLITE_WIN32_HAS_ANSI
4790347969
#endif
4790447970
4790547971
/*
4790647972
** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
4790747973
** based on the sub-platform)?
4790847974
*/
47909
-#if (SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT) && \
47975
+#if (SQLITE_OS_WINCE || SQLITE_OS_WINNT) && \
4791047976
!defined(SQLITE_WIN32_NO_WIDE)
4791147977
# define SQLITE_WIN32_HAS_WIDE
4791247978
#endif
4791347979
4791447980
/*
@@ -48043,20 +48109,11 @@
4804348109
** mode or memory mapped files (e.g. these APIs are available in the Windows
4804448110
** CE SDK; however, they are not present in the header file)?
4804548111
*/
4804648112
#if SQLITE_WIN32_FILEMAPPING_API && \
4804748113
(!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
48048
-/*
48049
-** Two of the file mapping APIs are different under WinRT. Figure out which
48050
-** set we need.
48051
-*/
48052
-#if SQLITE_OS_WINRT
48053
-WINBASEAPI HANDLE WINAPI CreateFileMappingFromApp(HANDLE, \
48054
- LPSECURITY_ATTRIBUTES, ULONG, ULONG64, LPCWSTR);
48055
-
48056
-WINBASEAPI LPVOID WINAPI MapViewOfFileFromApp(HANDLE, ULONG, ULONG64, SIZE_T);
48057
-#else
48114
+
4805848115
#if defined(SQLITE_WIN32_HAS_ANSI)
4805948116
WINBASEAPI HANDLE WINAPI CreateFileMappingA(HANDLE, LPSECURITY_ATTRIBUTES, \
4806048117
DWORD, DWORD, DWORD, LPCSTR);
4806148118
#endif /* defined(SQLITE_WIN32_HAS_ANSI) */
4806248119
@@ -48064,11 +48121,10 @@
4806448121
WINBASEAPI HANDLE WINAPI CreateFileMappingW(HANDLE, LPSECURITY_ATTRIBUTES, \
4806548122
DWORD, DWORD, DWORD, LPCWSTR);
4806648123
#endif /* defined(SQLITE_WIN32_HAS_WIDE) */
4806748124
4806848125
WINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T);
48069
-#endif /* SQLITE_OS_WINRT */
4807048126
4807148127
/*
4807248128
** These file mapping APIs are common to both Win32 and WinRT.
4807348129
*/
4807448130
@@ -48355,11 +48411,11 @@
4835548411
4835648412
/*
4835748413
** This function is not available on Windows CE or WinRT.
4835848414
*/
4835948415
48360
-#if SQLITE_OS_WINCE || SQLITE_OS_WINRT
48416
+#if SQLITE_OS_WINCE
4836148417
# define osAreFileApisANSI() 1
4836248418
#endif
4836348419
4836448420
/*
4836548421
** Many system calls are accessed through pointer-to-functions so that
@@ -48370,11 +48426,11 @@
4837048426
static struct win_syscall {
4837148427
const char *zName; /* Name of the system call */
4837248428
sqlite3_syscall_ptr pCurrent; /* Current value of the system call */
4837348429
sqlite3_syscall_ptr pDefault; /* Default value */
4837448430
} aSyscall[] = {
48375
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
48431
+#if !SQLITE_OS_WINCE
4837648432
{ "AreFileApisANSI", (SYSCALL)AreFileApisANSI, 0 },
4837748433
#else
4837848434
{ "AreFileApisANSI", (SYSCALL)0, 0 },
4837948435
#endif
4838048436
@@ -48409,20 +48465,20 @@
4840948465
#endif
4841048466
4841148467
#define osCreateFileA ((HANDLE(WINAPI*)(LPCSTR,DWORD,DWORD, \
4841248468
LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[4].pCurrent)
4841348469
48414
-#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
48470
+#if defined(SQLITE_WIN32_HAS_WIDE)
4841548471
{ "CreateFileW", (SYSCALL)CreateFileW, 0 },
4841648472
#else
4841748473
{ "CreateFileW", (SYSCALL)0, 0 },
4841848474
#endif
4841948475
4842048476
#define osCreateFileW ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD, \
4842148477
LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[5].pCurrent)
4842248478
48423
-#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_ANSI) && \
48479
+#if defined(SQLITE_WIN32_HAS_ANSI) && \
4842448480
(!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) && \
4842548481
SQLITE_WIN32_CREATEFILEMAPPINGA
4842648482
{ "CreateFileMappingA", (SYSCALL)CreateFileMappingA, 0 },
4842748483
#else
4842848484
{ "CreateFileMappingA", (SYSCALL)0, 0 },
@@ -48429,21 +48485,21 @@
4842948485
#endif
4843048486
4843148487
#define osCreateFileMappingA ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \
4843248488
DWORD,DWORD,DWORD,LPCSTR))aSyscall[6].pCurrent)
4843348489
48434
-#if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \
48435
- (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0))
48490
+#if (SQLITE_OS_WINCE || defined(SQLITE_WIN32_HAS_WIDE)) && \
48491
+ (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
4843648492
{ "CreateFileMappingW", (SYSCALL)CreateFileMappingW, 0 },
4843748493
#else
4843848494
{ "CreateFileMappingW", (SYSCALL)0, 0 },
4843948495
#endif
4844048496
4844148497
#define osCreateFileMappingW ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \
4844248498
DWORD,DWORD,DWORD,LPCWSTR))aSyscall[7].pCurrent)
4844348499
48444
-#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
48500
+#if defined(SQLITE_WIN32_HAS_WIDE)
4844548501
{ "CreateMutexW", (SYSCALL)CreateMutexW, 0 },
4844648502
#else
4844748503
{ "CreateMutexW", (SYSCALL)0, 0 },
4844848504
#endif
4844948505
@@ -48525,11 +48581,11 @@
4852548581
#endif
4852648582
4852748583
#define osGetDiskFreeSpaceA ((BOOL(WINAPI*)(LPCSTR,LPDWORD,LPDWORD,LPDWORD, \
4852848584
LPDWORD))aSyscall[18].pCurrent)
4852948585
48530
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
48586
+#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE)
4853148587
{ "GetDiskFreeSpaceW", (SYSCALL)GetDiskFreeSpaceW, 0 },
4853248588
#else
4853348589
{ "GetDiskFreeSpaceW", (SYSCALL)0, 0 },
4853448590
#endif
4853548591
@@ -48542,11 +48598,11 @@
4854248598
{ "GetFileAttributesA", (SYSCALL)0, 0 },
4854348599
#endif
4854448600
4854548601
#define osGetFileAttributesA ((DWORD(WINAPI*)(LPCSTR))aSyscall[20].pCurrent)
4854648602
48547
-#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
48603
+#if defined(SQLITE_WIN32_HAS_WIDE)
4854848604
{ "GetFileAttributesW", (SYSCALL)GetFileAttributesW, 0 },
4854948605
#else
4855048606
{ "GetFileAttributesW", (SYSCALL)0, 0 },
4855148607
#endif
4855248608
@@ -48559,15 +48615,11 @@
4855948615
#endif
4856048616
4856148617
#define osGetFileAttributesExW ((BOOL(WINAPI*)(LPCWSTR,GET_FILEEX_INFO_LEVELS, \
4856248618
LPVOID))aSyscall[22].pCurrent)
4856348619
48564
-#if !SQLITE_OS_WINRT
4856548620
{ "GetFileSize", (SYSCALL)GetFileSize, 0 },
48566
-#else
48567
- { "GetFileSize", (SYSCALL)0, 0 },
48568
-#endif
4856948621
4857048622
#define osGetFileSize ((DWORD(WINAPI*)(HANDLE,LPDWORD))aSyscall[23].pCurrent)
4857148623
4857248624
#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_ANSI)
4857348625
{ "GetFullPathNameA", (SYSCALL)GetFullPathNameA, 0 },
@@ -48576,11 +48628,11 @@
4857648628
#endif
4857748629
4857848630
#define osGetFullPathNameA ((DWORD(WINAPI*)(LPCSTR,DWORD,LPSTR, \
4857948631
LPSTR*))aSyscall[24].pCurrent)
4858048632
48581
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
48633
+#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE)
4858248634
{ "GetFullPathNameW", (SYSCALL)GetFullPathNameW, 0 },
4858348635
#else
4858448636
{ "GetFullPathNameW", (SYSCALL)0, 0 },
4858548637
#endif
4858648638
@@ -48611,20 +48663,14 @@
4861148663
#endif
4861248664
4861348665
#define osGetProcAddressA ((FARPROC(WINAPI*)(HMODULE, \
4861448666
LPCSTR))aSyscall[27].pCurrent)
4861548667
48616
-#if !SQLITE_OS_WINRT
4861748668
{ "GetSystemInfo", (SYSCALL)GetSystemInfo, 0 },
48618
-#else
48619
- { "GetSystemInfo", (SYSCALL)0, 0 },
48620
-#endif
48621
-
4862248669
#define osGetSystemInfo ((VOID(WINAPI*)(LPSYSTEM_INFO))aSyscall[28].pCurrent)
4862348670
4862448671
{ "GetSystemTime", (SYSCALL)GetSystemTime, 0 },
48625
-
4862648672
#define osGetSystemTime ((VOID(WINAPI*)(LPSYSTEMTIME))aSyscall[29].pCurrent)
4862748673
4862848674
#if !SQLITE_OS_WINCE
4862948675
{ "GetSystemTimeAsFileTime", (SYSCALL)GetSystemTimeAsFileTime, 0 },
4863048676
#else
@@ -48640,23 +48686,19 @@
4864048686
{ "GetTempPathA", (SYSCALL)0, 0 },
4864148687
#endif
4864248688
4864348689
#define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent)
4864448690
48645
-#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
48691
+#if defined(SQLITE_WIN32_HAS_WIDE)
4864648692
{ "GetTempPathW", (SYSCALL)GetTempPathW, 0 },
4864748693
#else
4864848694
{ "GetTempPathW", (SYSCALL)0, 0 },
4864948695
#endif
4865048696
4865148697
#define osGetTempPathW ((DWORD(WINAPI*)(DWORD,LPWSTR))aSyscall[32].pCurrent)
4865248698
48653
-#if !SQLITE_OS_WINRT
4865448699
{ "GetTickCount", (SYSCALL)GetTickCount, 0 },
48655
-#else
48656
- { "GetTickCount", (SYSCALL)0, 0 },
48657
-#endif
4865848700
4865948701
#define osGetTickCount ((DWORD(WINAPI*)(VOID))aSyscall[33].pCurrent)
4866048702
4866148703
#if defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_GETVERSIONEX
4866248704
{ "GetVersionExA", (SYSCALL)GetVersionExA, 0 },
@@ -48665,11 +48707,11 @@
4866548707
#endif
4866648708
4866748709
#define osGetVersionExA ((BOOL(WINAPI*)( \
4866848710
LPOSVERSIONINFOA))aSyscall[34].pCurrent)
4866948711
48670
-#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \
48712
+#if defined(SQLITE_WIN32_HAS_WIDE) && \
4867148713
SQLITE_WIN32_GETVERSIONEX
4867248714
{ "GetVersionExW", (SYSCALL)GetVersionExW, 0 },
4867348715
#else
4867448716
{ "GetVersionExW", (SYSCALL)0, 0 },
4867548717
#endif
@@ -48680,24 +48722,16 @@
4868048722
{ "HeapAlloc", (SYSCALL)HeapAlloc, 0 },
4868148723
4868248724
#define osHeapAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD, \
4868348725
SIZE_T))aSyscall[36].pCurrent)
4868448726
48685
-#if !SQLITE_OS_WINRT
4868648727
{ "HeapCreate", (SYSCALL)HeapCreate, 0 },
48687
-#else
48688
- { "HeapCreate", (SYSCALL)0, 0 },
48689
-#endif
4869048728
4869148729
#define osHeapCreate ((HANDLE(WINAPI*)(DWORD,SIZE_T, \
4869248730
SIZE_T))aSyscall[37].pCurrent)
4869348731
48694
-#if !SQLITE_OS_WINRT
4869548732
{ "HeapDestroy", (SYSCALL)HeapDestroy, 0 },
48696
-#else
48697
- { "HeapDestroy", (SYSCALL)0, 0 },
48698
-#endif
4869948733
4870048734
#define osHeapDestroy ((BOOL(WINAPI*)(HANDLE))aSyscall[38].pCurrent)
4870148735
4870248736
{ "HeapFree", (SYSCALL)HeapFree, 0 },
4870348737
@@ -48711,20 +48745,16 @@
4871148745
{ "HeapSize", (SYSCALL)HeapSize, 0 },
4871248746
4871348747
#define osHeapSize ((SIZE_T(WINAPI*)(HANDLE,DWORD, \
4871448748
LPCVOID))aSyscall[41].pCurrent)
4871548749
48716
-#if !SQLITE_OS_WINRT
4871748750
{ "HeapValidate", (SYSCALL)HeapValidate, 0 },
48718
-#else
48719
- { "HeapValidate", (SYSCALL)0, 0 },
48720
-#endif
4872148751
4872248752
#define osHeapValidate ((BOOL(WINAPI*)(HANDLE,DWORD, \
4872348753
LPCVOID))aSyscall[42].pCurrent)
4872448754
48725
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
48755
+#if !SQLITE_OS_WINCE
4872648756
{ "HeapCompact", (SYSCALL)HeapCompact, 0 },
4872748757
#else
4872848758
{ "HeapCompact", (SYSCALL)0, 0 },
4872948759
#endif
4873048760
@@ -48736,28 +48766,24 @@
4873648766
{ "LoadLibraryA", (SYSCALL)0, 0 },
4873748767
#endif
4873848768
4873948769
#define osLoadLibraryA ((HMODULE(WINAPI*)(LPCSTR))aSyscall[44].pCurrent)
4874048770
48741
-#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \
48771
+#if defined(SQLITE_WIN32_HAS_WIDE) && \
4874248772
!defined(SQLITE_OMIT_LOAD_EXTENSION)
4874348773
{ "LoadLibraryW", (SYSCALL)LoadLibraryW, 0 },
4874448774
#else
4874548775
{ "LoadLibraryW", (SYSCALL)0, 0 },
4874648776
#endif
4874748777
4874848778
#define osLoadLibraryW ((HMODULE(WINAPI*)(LPCWSTR))aSyscall[45].pCurrent)
4874948779
48750
-#if !SQLITE_OS_WINRT
4875148780
{ "LocalFree", (SYSCALL)LocalFree, 0 },
48752
-#else
48753
- { "LocalFree", (SYSCALL)0, 0 },
48754
-#endif
4875548781
4875648782
#define osLocalFree ((HLOCAL(WINAPI*)(HLOCAL))aSyscall[46].pCurrent)
4875748783
48758
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
48784
+#if !SQLITE_OS_WINCE
4875948785
{ "LockFile", (SYSCALL)LockFile, 0 },
4876048786
#else
4876148787
{ "LockFile", (SYSCALL)0, 0 },
4876248788
#endif
4876348789
@@ -48775,12 +48801,11 @@
4877548801
#ifndef osLockFileEx
4877648802
#define osLockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,DWORD, \
4877748803
LPOVERLAPPED))aSyscall[48].pCurrent)
4877848804
#endif
4877948805
48780
-#if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && \
48781
- (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0))
48806
+#if SQLITE_OS_WINCE || !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
4878248807
{ "MapViewOfFile", (SYSCALL)MapViewOfFile, 0 },
4878348808
#else
4878448809
{ "MapViewOfFile", (SYSCALL)0, 0 },
4878548810
#endif
4878648811
@@ -48804,33 +48829,25 @@
4880448829
4880548830
{ "SetEndOfFile", (SYSCALL)SetEndOfFile, 0 },
4880648831
4880748832
#define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[53].pCurrent)
4880848833
48809
-#if !SQLITE_OS_WINRT
4881048834
{ "SetFilePointer", (SYSCALL)SetFilePointer, 0 },
48811
-#else
48812
- { "SetFilePointer", (SYSCALL)0, 0 },
48813
-#endif
4881448835
4881548836
#define osSetFilePointer ((DWORD(WINAPI*)(HANDLE,LONG,PLONG, \
4881648837
DWORD))aSyscall[54].pCurrent)
4881748838
48818
-#if !SQLITE_OS_WINRT
4881948839
{ "Sleep", (SYSCALL)Sleep, 0 },
48820
-#else
48821
- { "Sleep", (SYSCALL)0, 0 },
48822
-#endif
4882348840
4882448841
#define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[55].pCurrent)
4882548842
4882648843
{ "SystemTimeToFileTime", (SYSCALL)SystemTimeToFileTime, 0 },
4882748844
4882848845
#define osSystemTimeToFileTime ((BOOL(WINAPI*)(const SYSTEMTIME*, \
4882948846
LPFILETIME))aSyscall[56].pCurrent)
4883048847
48831
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
48848
+#if !SQLITE_OS_WINCE
4883248849
{ "UnlockFile", (SYSCALL)UnlockFile, 0 },
4883348850
#else
4883448851
{ "UnlockFile", (SYSCALL)0, 0 },
4883548852
#endif
4883648853
@@ -48864,15 +48881,11 @@
4886448881
{ "WriteFile", (SYSCALL)WriteFile, 0 },
4886548882
4886648883
#define osWriteFile ((BOOL(WINAPI*)(HANDLE,LPCVOID,DWORD,LPDWORD, \
4886748884
LPOVERLAPPED))aSyscall[61].pCurrent)
4886848885
48869
-#if SQLITE_OS_WINRT
4887048886
{ "CreateEventExW", (SYSCALL)CreateEventExW, 0 },
48871
-#else
48872
- { "CreateEventExW", (SYSCALL)0, 0 },
48873
-#endif
4887448887
4887548888
#define osCreateEventExW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,LPCWSTR, \
4887648889
DWORD,DWORD))aSyscall[62].pCurrent)
4887748890
4887848891
/*
@@ -48893,68 +48906,30 @@
4889348906
#endif
4889448907
4889548908
#define osWaitForSingleObjectEx ((DWORD(WINAPI*)(HANDLE,DWORD, \
4889648909
BOOL))aSyscall[64].pCurrent)
4889748910
48898
-#if SQLITE_OS_WINRT
4889948911
{ "SetFilePointerEx", (SYSCALL)SetFilePointerEx, 0 },
48900
-#else
48901
- { "SetFilePointerEx", (SYSCALL)0, 0 },
48902
-#endif
4890348912
4890448913
#define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \
4890548914
PLARGE_INTEGER,DWORD))aSyscall[65].pCurrent)
4890648915
48907
-#if SQLITE_OS_WINRT
4890848916
{ "GetFileInformationByHandleEx", (SYSCALL)GetFileInformationByHandleEx, 0 },
48909
-#else
48910
- { "GetFileInformationByHandleEx", (SYSCALL)0, 0 },
48911
-#endif
4891248917
4891348918
#define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \
4891448919
FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[66].pCurrent)
4891548920
48916
-#if SQLITE_OS_WINRT && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
48917
- { "MapViewOfFileFromApp", (SYSCALL)MapViewOfFileFromApp, 0 },
48918
-#else
48919
- { "MapViewOfFileFromApp", (SYSCALL)0, 0 },
48920
-#endif
48921
-
48922
-#define osMapViewOfFileFromApp ((LPVOID(WINAPI*)(HANDLE,ULONG,ULONG64, \
48923
- SIZE_T))aSyscall[67].pCurrent)
48924
-
48925
-#if SQLITE_OS_WINRT
4892648921
{ "CreateFile2", (SYSCALL)CreateFile2, 0 },
48927
-#else
48928
- { "CreateFile2", (SYSCALL)0, 0 },
48929
-#endif
4893048922
4893148923
#define osCreateFile2 ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD,DWORD, \
4893248924
LPCREATEFILE2_EXTENDED_PARAMETERS))aSyscall[68].pCurrent)
4893348925
48934
-#if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_LOAD_EXTENSION)
48935
- { "LoadPackagedLibrary", (SYSCALL)LoadPackagedLibrary, 0 },
48936
-#else
48937
- { "LoadPackagedLibrary", (SYSCALL)0, 0 },
48938
-#endif
48939
-
48940
-#define osLoadPackagedLibrary ((HMODULE(WINAPI*)(LPCWSTR, \
48941
- DWORD))aSyscall[69].pCurrent)
48942
-
48943
-#if SQLITE_OS_WINRT
4894448926
{ "GetTickCount64", (SYSCALL)GetTickCount64, 0 },
48945
-#else
48946
- { "GetTickCount64", (SYSCALL)0, 0 },
48947
-#endif
4894848927
4894948928
#define osGetTickCount64 ((ULONGLONG(WINAPI*)(VOID))aSyscall[70].pCurrent)
4895048929
48951
-#if SQLITE_OS_WINRT
4895248930
{ "GetNativeSystemInfo", (SYSCALL)GetNativeSystemInfo, 0 },
48953
-#else
48954
- { "GetNativeSystemInfo", (SYSCALL)0, 0 },
48955
-#endif
4895648931
4895748932
#define osGetNativeSystemInfo ((VOID(WINAPI*)( \
4895848933
LPSYSTEM_INFO))aSyscall[71].pCurrent)
4895948934
4896048935
#if defined(SQLITE_WIN32_HAS_ANSI)
@@ -48975,19 +48950,10 @@
4897548950
4897648951
{ "GetProcessHeap", (SYSCALL)GetProcessHeap, 0 },
4897748952
4897848953
#define osGetProcessHeap ((HANDLE(WINAPI*)(VOID))aSyscall[74].pCurrent)
4897948954
48980
-#if SQLITE_OS_WINRT && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
48981
- { "CreateFileMappingFromApp", (SYSCALL)CreateFileMappingFromApp, 0 },
48982
-#else
48983
- { "CreateFileMappingFromApp", (SYSCALL)0, 0 },
48984
-#endif
48985
-
48986
-#define osCreateFileMappingFromApp ((HANDLE(WINAPI*)(HANDLE, \
48987
- LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[75].pCurrent)
48988
-
4898948955
/*
4899048956
** NOTE: On some sub-platforms, the InterlockedCompareExchange "function"
4899148957
** is really just a macro that uses a compiler intrinsic (e.g. x64).
4899248958
** So do not try to make this is into a redefinable interface.
4899348959
*/
@@ -49000,19 +48966,19 @@
4900048966
4900148967
#define osInterlockedCompareExchange ((LONG(WINAPI*)(LONG \
4900248968
SQLITE_WIN32_VOLATILE*, LONG,LONG))aSyscall[76].pCurrent)
4900348969
#endif /* defined(InterlockedCompareExchange) */
4900448970
49005
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID
48971
+#if !SQLITE_OS_WINCE && SQLITE_WIN32_USE_UUID
4900648972
{ "UuidCreate", (SYSCALL)UuidCreate, 0 },
4900748973
#else
4900848974
{ "UuidCreate", (SYSCALL)0, 0 },
4900948975
#endif
4901048976
4901148977
#define osUuidCreate ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[77].pCurrent)
4901248978
49013
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID
48979
+#if !SQLITE_OS_WINCE && SQLITE_WIN32_USE_UUID
4901448980
{ "UuidCreateSequential", (SYSCALL)UuidCreateSequential, 0 },
4901548981
#else
4901648982
{ "UuidCreateSequential", (SYSCALL)0, 0 },
4901748983
#endif
4901848984
@@ -49219,14 +49185,14 @@
4921949185
4922049186
winMemAssertMagic();
4922149187
hHeap = winMemGetHeap();
4922249188
assert( hHeap!=0 );
4922349189
assert( hHeap!=INVALID_HANDLE_VALUE );
49224
-#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)
49190
+#if defined(SQLITE_WIN32_MALLOC_VALIDATE)
4922549191
assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );
4922649192
#endif
49227
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
49193
+#if !SQLITE_OS_WINCE
4922849194
if( (nLargest=osHeapCompact(hHeap, SQLITE_WIN32_HEAP_FLAGS))==0 ){
4922949195
DWORD lastErrno = osGetLastError();
4923049196
if( lastErrno==NO_ERROR ){
4923149197
sqlite3_log(SQLITE_NOMEM, "failed to HeapCompact (no space), heap=%p",
4923249198
(void*)hHeap);
@@ -49335,32 +49301,15 @@
4933549301
}
4933649302
#endif
4933749303
}
4933849304
#endif /* _WIN32 */
4933949305
49340
-/*
49341
-** The following routine suspends the current thread for at least ms
49342
-** milliseconds. This is equivalent to the Win32 Sleep() interface.
49343
-*/
49344
-#if SQLITE_OS_WINRT
49345
-static HANDLE sleepObj = NULL;
49346
-#endif
49347
-
4934849306
SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds){
49349
-#if SQLITE_OS_WINRT
49350
- if ( sleepObj==NULL ){
49351
- sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET,
49352
- SYNCHRONIZE);
49353
- }
49354
- assert( sleepObj!=NULL );
49355
- osWaitForSingleObjectEx(sleepObj, milliseconds, FALSE);
49356
-#else
4935749307
osSleep(milliseconds);
49358
-#endif
4935949308
}
4936049309
49361
-#if SQLITE_MAX_WORKER_THREADS>0 && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \
49310
+#if SQLITE_MAX_WORKER_THREADS>0 && !SQLITE_OS_WINCE && \
4936249311
SQLITE_THREADSAFE>0
4936349312
SQLITE_PRIVATE DWORD sqlite3Win32Wait(HANDLE hObject){
4936449313
DWORD rc;
4936549314
while( (rc = osWaitForSingleObjectEx(hObject, INFINITE,
4936649315
TRUE))==WAIT_IO_COMPLETION ){}
@@ -49380,11 +49329,11 @@
4938049329
** the LockFileEx() API.
4938149330
*/
4938249331
4938349332
#if !SQLITE_WIN32_GETVERSIONEX
4938449333
# define osIsNT() (1)
49385
-#elif SQLITE_OS_WINCE || SQLITE_OS_WINRT || !defined(SQLITE_WIN32_HAS_ANSI)
49334
+#elif SQLITE_OS_WINCE || !defined(SQLITE_WIN32_HAS_ANSI)
4938649335
# define osIsNT() (1)
4938749336
#elif !defined(SQLITE_WIN32_HAS_WIDE)
4938849337
# define osIsNT() (0)
4938949338
#else
4939049339
# define osIsNT() ((sqlite3_os_type==2) || sqlite3_win32_is_nt())
@@ -49393,17 +49342,11 @@
4939349342
/*
4939449343
** This function determines if the machine is running a version of Windows
4939549344
** based on the NT kernel.
4939649345
*/
4939749346
SQLITE_API int sqlite3_win32_is_nt(void){
49398
-#if SQLITE_OS_WINRT
49399
- /*
49400
- ** NOTE: The WinRT sub-platform is always assumed to be based on the NT
49401
- ** kernel.
49402
- */
49403
- return 1;
49404
-#elif SQLITE_WIN32_GETVERSIONEX
49347
+#if SQLITE_WIN32_GETVERSIONEX
4940549348
if( osInterlockedCompareExchange(&sqlite3_os_type, 0, 0)==0 ){
4940649349
#if defined(SQLITE_WIN32_HAS_ANSI)
4940749350
OSVERSIONINFOA sInfo;
4940849351
sInfo.dwOSVersionInfoSize = sizeof(sInfo);
4940949352
osGetVersionExA(&sInfo);
@@ -49441,11 +49384,11 @@
4944149384
4944249385
winMemAssertMagic();
4944349386
hHeap = winMemGetHeap();
4944449387
assert( hHeap!=0 );
4944549388
assert( hHeap!=INVALID_HANDLE_VALUE );
49446
-#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)
49389
+#if defined(SQLITE_WIN32_MALLOC_VALIDATE)
4944749390
assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );
4944849391
#endif
4944949392
assert( nBytes>=0 );
4945049393
p = osHeapAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, (SIZE_T)nBytes);
4945149394
if( !p ){
@@ -49463,11 +49406,11 @@
4946349406
4946449407
winMemAssertMagic();
4946549408
hHeap = winMemGetHeap();
4946649409
assert( hHeap!=0 );
4946749410
assert( hHeap!=INVALID_HANDLE_VALUE );
49468
-#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)
49411
+#if defined(SQLITE_WIN32_MALLOC_VALIDATE)
4946949412
assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) );
4947049413
#endif
4947149414
if( !pPrior ) return; /* Passing NULL to HeapFree is undefined. */
4947249415
if( !osHeapFree(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ){
4947349416
sqlite3_log(SQLITE_NOMEM, "failed to HeapFree block %p (%lu), heap=%p",
@@ -49484,11 +49427,11 @@
4948449427
4948549428
winMemAssertMagic();
4948649429
hHeap = winMemGetHeap();
4948749430
assert( hHeap!=0 );
4948849431
assert( hHeap!=INVALID_HANDLE_VALUE );
49489
-#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)
49432
+#if defined(SQLITE_WIN32_MALLOC_VALIDATE)
4949049433
assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) );
4949149434
#endif
4949249435
assert( nBytes>=0 );
4949349436
if( !pPrior ){
4949449437
p = osHeapAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, (SIZE_T)nBytes);
@@ -49512,11 +49455,11 @@
4951249455
4951349456
winMemAssertMagic();
4951449457
hHeap = winMemGetHeap();
4951549458
assert( hHeap!=0 );
4951649459
assert( hHeap!=INVALID_HANDLE_VALUE );
49517
-#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)
49460
+#if defined(SQLITE_WIN32_MALLOC_VALIDATE)
4951849461
assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, p) );
4951949462
#endif
4952049463
if( !p ) return 0;
4952149464
n = osHeapSize(hHeap, SQLITE_WIN32_HEAP_FLAGS, p);
4952249465
if( n==(SIZE_T)-1 ){
@@ -49542,11 +49485,11 @@
4954249485
4954349486
if( !pWinMemData ) return SQLITE_ERROR;
4954449487
assert( pWinMemData->magic1==WINMEM_MAGIC1 );
4954549488
assert( pWinMemData->magic2==WINMEM_MAGIC2 );
4954649489
49547
-#if !SQLITE_OS_WINRT && SQLITE_WIN32_HEAP_CREATE
49490
+#if SQLITE_WIN32_HEAP_CREATE
4954849491
if( !pWinMemData->hHeap ){
4954949492
DWORD dwInitialSize = SQLITE_WIN32_HEAP_INIT_SIZE;
4955049493
DWORD dwMaximumSize = (DWORD)sqlite3GlobalConfig.nHeap;
4955149494
if( dwMaximumSize==0 ){
4955249495
dwMaximumSize = SQLITE_WIN32_HEAP_MAX_SIZE;
@@ -49575,11 +49518,11 @@
4957549518
pWinMemData->bOwned = FALSE;
4957649519
assert( !pWinMemData->bOwned );
4957749520
#endif
4957849521
assert( pWinMemData->hHeap!=0 );
4957949522
assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE );
49580
-#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)
49523
+#if defined(SQLITE_WIN32_MALLOC_VALIDATE)
4958149524
assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );
4958249525
#endif
4958349526
return SQLITE_OK;
4958449527
}
4958549528
@@ -49593,11 +49536,11 @@
4959349536
assert( pWinMemData->magic1==WINMEM_MAGIC1 );
4959449537
assert( pWinMemData->magic2==WINMEM_MAGIC2 );
4959549538
4959649539
if( pWinMemData->hHeap ){
4959749540
assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE );
49598
-#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)
49541
+#if defined(SQLITE_WIN32_MALLOC_VALIDATE)
4959949542
assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );
4960049543
#endif
4960149544
if( pWinMemData->bOwned ){
4960249545
if( !osHeapDestroy(pWinMemData->hHeap) ){
4960349546
sqlite3_log(SQLITE_NOMEM, "failed to HeapDestroy (%lu), heap=%p",
@@ -49974,21 +49917,10 @@
4997449917
*/
4997549918
DWORD dwLen = 0;
4997649919
char *zOut = 0;
4997749920
4997849921
if( osIsNT() ){
49979
-#if SQLITE_OS_WINRT
49980
- WCHAR zTempWide[SQLITE_WIN32_MAX_ERRMSG_CHARS+1];
49981
- dwLen = osFormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
49982
- FORMAT_MESSAGE_IGNORE_INSERTS,
49983
- NULL,
49984
- lastErrno,
49985
- 0,
49986
- zTempWide,
49987
- SQLITE_WIN32_MAX_ERRMSG_CHARS,
49988
- 0);
49989
-#else
4999049922
LPWSTR zTempWide = NULL;
4999149923
dwLen = osFormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
4999249924
FORMAT_MESSAGE_FROM_SYSTEM |
4999349925
FORMAT_MESSAGE_IGNORE_INSERTS,
4999449926
NULL,
@@ -49995,20 +49927,17 @@
4999549927
lastErrno,
4999649928
0,
4999749929
(LPWSTR) &zTempWide,
4999849930
0,
4999949931
0);
50000
-#endif
5000149932
if( dwLen > 0 ){
5000249933
/* allocate a buffer and convert to UTF8 */
5000349934
sqlite3BeginBenignMalloc();
5000449935
zOut = winUnicodeToUtf8(zTempWide);
5000549936
sqlite3EndBenignMalloc();
50006
-#if !SQLITE_OS_WINRT
5000749937
/* free the system buffer allocated by FormatMessage */
5000849938
osLocalFree(zTempWide);
50009
-#endif
5001049939
}
5001149940
}
5001249941
#ifdef SQLITE_WIN32_HAS_ANSI
5001349942
else{
5001449943
char *zTemp = NULL;
@@ -50665,11 +50594,10 @@
5066550594
** error code.
5066650595
*/
5066750596
static int winHandleSeek(HANDLE h, sqlite3_int64 iOffset){
5066850597
int rc = SQLITE_OK; /* Return value */
5066950598
50670
-#if !SQLITE_OS_WINRT
5067150599
LONG upperBits; /* Most sig. 32 bits of new offset */
5067250600
LONG lowerBits; /* Least sig. 32 bits of new offset */
5067350601
DWORD dwRet; /* Value returned by SetFilePointer() */
5067450602
5067550603
upperBits = (LONG)((iOffset>>32) & 0x7fffffff);
@@ -50687,24 +50615,11 @@
5068750615
DWORD lastErrno = osGetLastError();
5068850616
if( lastErrno!=NO_ERROR ){
5068950617
rc = SQLITE_IOERR_SEEK;
5069050618
}
5069150619
}
50692
-#else
50693
- /* This implementation works for WinRT. */
50694
- LARGE_INTEGER x; /* The new offset */
50695
- BOOL bRet; /* Value returned by SetFilePointerEx() */
50696
-
50697
- x.QuadPart = iOffset;
50698
- bRet = osSetFilePointerEx(h, x, 0, FILE_BEGIN);
50699
-
50700
- if(!bRet){
50701
- rc = SQLITE_IOERR_SEEK;
50702
- }
50703
-#endif
50704
-
50705
- OSTRACE(("SEEK file=%p, offset=%lld rc=%s\n", h, iOffset, sqlite3ErrName(rc)));
50620
+ OSTRACE(("SEEK file=%p, offset=%lld rc=%s\n", h, iOffset,sqlite3ErrName(rc)));
5070650621
return rc;
5070750622
}
5070850623
5070950624
/*
5071050625
** Move the current position of the file handle passed as the first
@@ -51001,32 +50916,19 @@
5100150916
** Determine the size in bytes of the file opened by the handle passed as
5100250917
** the first argument.
5100350918
*/
5100450919
static int winHandleSize(HANDLE h, sqlite3_int64 *pnByte){
5100550920
int rc = SQLITE_OK;
51006
-
51007
-#if SQLITE_OS_WINRT
51008
- FILE_STANDARD_INFO info;
51009
- BOOL b;
51010
- b = osGetFileInformationByHandleEx(h, FileStandardInfo, &info, sizeof(info));
51011
- if( b ){
51012
- *pnByte = info.EndOfFile.QuadPart;
51013
- }else{
51014
- rc = SQLITE_IOERR_FSTAT;
51015
- }
51016
-#else
5101750921
DWORD upperBits = 0;
5101850922
DWORD lowerBits = 0;
5101950923
5102050924
assert( pnByte );
5102150925
lowerBits = osGetFileSize(h, &upperBits);
5102250926
*pnByte = (((sqlite3_int64)upperBits)<<32) + lowerBits;
5102350927
if( lowerBits==INVALID_FILE_SIZE && osGetLastError()!=NO_ERROR ){
5102450928
rc = SQLITE_IOERR_FSTAT;
5102550929
}
51026
-#endif
51027
-
5102850930
return rc;
5102950931
}
5103050932
5103150933
/*
5103250934
** Close the handle passed as the only argument.
@@ -51221,24 +51123,10 @@
5122151123
5122251124
assert( id!=0 );
5122351125
assert( pSize!=0 );
5122451126
SimulateIOError(return SQLITE_IOERR_FSTAT);
5122551127
OSTRACE(("SIZE file=%p, pSize=%p\n", pFile->h, pSize));
51226
-
51227
-#if SQLITE_OS_WINRT
51228
- {
51229
- FILE_STANDARD_INFO info;
51230
- if( osGetFileInformationByHandleEx(pFile->h, FileStandardInfo,
51231
- &info, sizeof(info)) ){
51232
- *pSize = info.EndOfFile.QuadPart;
51233
- }else{
51234
- pFile->lastErrno = osGetLastError();
51235
- rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,
51236
- "winFileSize", pFile->zPath);
51237
- }
51238
- }
51239
-#else
5124051128
{
5124151129
DWORD upperBits;
5124251130
DWORD lowerBits;
5124351131
DWORD lastErrno;
5124451132
@@ -51249,11 +51137,10 @@
5124951137
pFile->lastErrno = lastErrno;
5125051138
rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,
5125151139
"winFileSize", pFile->zPath);
5125251140
}
5125351141
}
51254
-#endif
5125551142
OSTRACE(("SIZE file=%p, pSize=%p, *pSize=%lld, rc=%s\n",
5125651143
pFile->h, pSize, *pSize, sqlite3ErrName(rc)));
5125751144
return rc;
5125851145
}
5125951146
@@ -52211,33 +52098,18 @@
5221152098
5221252099
/* TODO: platforms.
5221352100
** TODO: retry-on-ioerr.
5221452101
*/
5221552102
if( osIsNT() ){
52216
-#if SQLITE_OS_WINRT
52217
- CREATEFILE2_EXTENDED_PARAMETERS extendedParameters;
52218
- memset(&extendedParameters, 0, sizeof(extendedParameters));
52219
- extendedParameters.dwSize = sizeof(extendedParameters);
52220
- extendedParameters.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
52221
- extendedParameters.dwFileFlags = flag_overlapped;
52222
- extendedParameters.dwSecurityQosFlags = SECURITY_ANONYMOUS;
52223
- h = osCreateFile2((LPCWSTR)zConverted,
52224
- (GENERIC_READ | (bReadonly ? 0 : GENERIC_WRITE)),/* dwDesiredAccess */
52225
- FILE_SHARE_READ | FILE_SHARE_WRITE, /* dwShareMode */
52226
- OPEN_ALWAYS, /* dwCreationDisposition */
52227
- &extendedParameters
52228
- );
52229
-#else
5223052103
h = osCreateFileW((LPCWSTR)zConverted, /* lpFileName */
5223152104
(GENERIC_READ | (bReadonly ? 0 : GENERIC_WRITE)), /* dwDesiredAccess */
5223252105
FILE_SHARE_READ | FILE_SHARE_WRITE, /* dwShareMode */
5223352106
NULL, /* lpSecurityAttributes */
5223452107
OPEN_ALWAYS, /* dwCreationDisposition */
5223552108
FILE_ATTRIBUTE_NORMAL|flag_overlapped,
5223652109
NULL
5223752110
);
52238
-#endif
5223952111
}else{
5224052112
/* Due to pre-processor directives earlier in this file,
5224152113
** SQLITE_WIN32_HAS_ANSI is always defined if osIsNT() is false. */
5224252114
#ifdef SQLITE_WIN32_HAS_ANSI
5224352115
h = osCreateFileA((LPCSTR)zConverted,
@@ -52701,13 +52573,11 @@
5270152573
5270252574
while( pShmNode->nRegion<=iRegion ){
5270352575
HANDLE hMap = NULL; /* file-mapping handle */
5270452576
void *pMap = 0; /* Mapped memory region */
5270552577
52706
-#if SQLITE_OS_WINRT
52707
- hMap = osCreateFileMappingFromApp(hShared, NULL, protect, nByte, NULL);
52708
-#elif defined(SQLITE_WIN32_HAS_WIDE)
52578
+#if defined(SQLITE_WIN32_HAS_WIDE)
5270952579
hMap = osCreateFileMappingW(hShared, NULL, protect, 0, nByte, NULL);
5271052580
#elif defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_CREATEFILEMAPPINGA
5271152581
hMap = osCreateFileMappingA(hShared, NULL, protect, 0, nByte, NULL);
5271252582
#endif
5271352583
@@ -52715,19 +52585,13 @@
5271552585
osGetCurrentProcessId(), pShmNode->nRegion, nByte,
5271652586
hMap ? "ok" : "failed"));
5271752587
if( hMap ){
5271852588
int iOffset = pShmNode->nRegion*szRegion;
5271952589
int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity;
52720
-#if SQLITE_OS_WINRT
52721
- pMap = osMapViewOfFileFromApp(hMap, flags,
52722
- iOffset - iOffsetShift, szRegion + iOffsetShift
52723
- );
52724
-#else
5272552590
pMap = osMapViewOfFile(hMap, flags,
5272652591
0, iOffset - iOffsetShift, szRegion + iOffsetShift
5272752592
);
52728
-#endif
5272952593
OSTRACE(("SHM-MAP-MAP pid=%lu, region=%d, offset=%d, size=%d, rc=%s\n",
5273052594
osGetCurrentProcessId(), pShmNode->nRegion, iOffset,
5273152595
szRegion, pMap ? "ok" : "failed"));
5273252596
}
5273352597
if( !pMap ){
@@ -52856,13 +52720,11 @@
5285652720
if( (pFd->ctrlFlags & WINFILE_RDONLY)==0 ){
5285752721
protect = PAGE_READWRITE;
5285852722
flags |= FILE_MAP_WRITE;
5285952723
}
5286052724
#endif
52861
-#if SQLITE_OS_WINRT
52862
- pFd->hMap = osCreateFileMappingFromApp(pFd->h, NULL, protect, nMap, NULL);
52863
-#elif defined(SQLITE_WIN32_HAS_WIDE)
52725
+#if defined(SQLITE_WIN32_HAS_WIDE)
5286452726
pFd->hMap = osCreateFileMappingW(pFd->h, NULL, protect,
5286552727
(DWORD)((nMap>>32) & 0xffffffff),
5286652728
(DWORD)(nMap & 0xffffffff), NULL);
5286752729
#elif defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_CREATEFILEMAPPINGA
5286852730
pFd->hMap = osCreateFileMappingA(pFd->h, NULL, protect,
@@ -52878,15 +52740,11 @@
5287852740
osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
5287952741
return SQLITE_OK;
5288052742
}
5288152743
assert( (nMap % winSysInfo.dwPageSize)==0 );
5288252744
assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
52883
-#if SQLITE_OS_WINRT
52884
- pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);
52885
-#else
5288652745
pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
52887
-#endif
5288852746
if( pNew==NULL ){
5288952747
osCloseHandle(pFd->hMap);
5289052748
pFd->hMap = NULL;
5289152749
pFd->lastErrno = osGetLastError();
5289252750
rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
@@ -53217,11 +53075,10 @@
5321753075
}
5321853076
}
5321953077
}
5322053078
#endif
5322153079
53222
-#if !SQLITE_OS_WINRT && defined(_WIN32)
5322353080
else if( osIsNT() ){
5322453081
char *zMulti;
5322553082
LPWSTR zWidePath = sqlite3MallocZero( nMax*sizeof(WCHAR) );
5322653083
if( !zWidePath ){
5322753084
sqlite3_free(zBuf);
@@ -53271,11 +53128,10 @@
5327153128
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
5327253129
return SQLITE_IOERR_NOMEM_BKPT;
5327353130
}
5327453131
}
5327553132
#endif /* SQLITE_WIN32_HAS_ANSI */
53276
-#endif /* !SQLITE_OS_WINRT */
5327753133
5327853134
/*
5327953135
** Check to make sure the temporary directory ends with an appropriate
5328053136
** separator. If it does not and there is not enough space left to add
5328153137
** one, fail.
@@ -53446,17 +53302,10 @@
5344653302
5344753303
assert( pFile!=0 );
5344853304
memset(pFile, 0, sizeof(winFile));
5344953305
pFile->h = INVALID_HANDLE_VALUE;
5345053306
53451
-#if SQLITE_OS_WINRT
53452
- if( !zUtf8Name && !sqlite3_temp_directory ){
53453
- sqlite3_log(SQLITE_ERROR,
53454
- "sqlite3_temp_directory variable should be set for WinRT");
53455
- }
53456
-#endif
53457
-
5345853307
/* If the second argument to this function is NULL, generate a
5345953308
** temporary file name to use
5346053309
*/
5346153310
if( !zUtf8Name ){
5346253311
assert( isDelete && !isOpenJournal );
@@ -53535,35 +53384,10 @@
5353553384
#if SQLITE_OS_WINCE
5353653385
dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
5353753386
#endif
5353853387
5353953388
if( osIsNT() ){
53540
-#if SQLITE_OS_WINRT
53541
- CREATEFILE2_EXTENDED_PARAMETERS extendedParameters;
53542
- extendedParameters.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
53543
- extendedParameters.dwFileAttributes =
53544
- dwFlagsAndAttributes & FILE_ATTRIBUTE_MASK;
53545
- extendedParameters.dwFileFlags = dwFlagsAndAttributes & FILE_FLAG_MASK;
53546
- extendedParameters.dwSecurityQosFlags = SECURITY_ANONYMOUS;
53547
- extendedParameters.lpSecurityAttributes = NULL;
53548
- extendedParameters.hTemplateFile = NULL;
53549
- do{
53550
- h = osCreateFile2((LPCWSTR)zConverted,
53551
- dwDesiredAccess,
53552
- dwShareMode,
53553
- dwCreationDisposition,
53554
- &extendedParameters);
53555
- if( h!=INVALID_HANDLE_VALUE ) break;
53556
- if( isReadWrite ){
53557
- int rc2;
53558
- sqlite3BeginBenignMalloc();
53559
- rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ|NORETRY, &isRO);
53560
- sqlite3EndBenignMalloc();
53561
- if( rc2==SQLITE_OK && isRO ) break;
53562
- }
53563
- }while( winRetryIoerr(&cnt, &lastErrno) );
53564
-#else
5356553389
do{
5356653390
h = osCreateFileW((LPCWSTR)zConverted,
5356753391
dwDesiredAccess,
5356853392
dwShareMode, NULL,
5356953393
dwCreationDisposition,
@@ -53576,11 +53400,10 @@
5357653400
rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ|NORETRY, &isRO);
5357753401
sqlite3EndBenignMalloc();
5357853402
if( rc2==SQLITE_OK && isRO ) break;
5357953403
}
5358053404
}while( winRetryIoerr(&cnt, &lastErrno) );
53581
-#endif
5358253405
}
5358353406
#ifdef SQLITE_WIN32_HAS_ANSI
5358453407
else{
5358553408
do{
5358653409
h = osCreateFileA((LPCSTR)zConverted,
@@ -53713,29 +53536,11 @@
5371353536
OSTRACE(("DELETE name=%s, rc=SQLITE_IOERR_NOMEM\n", zFilename));
5371453537
return SQLITE_IOERR_NOMEM_BKPT;
5371553538
}
5371653539
if( osIsNT() ){
5371753540
do {
53718
-#if SQLITE_OS_WINRT
53719
- WIN32_FILE_ATTRIBUTE_DATA sAttrData;
53720
- memset(&sAttrData, 0, sizeof(sAttrData));
53721
- if ( osGetFileAttributesExW(zConverted, GetFileExInfoStandard,
53722
- &sAttrData) ){
53723
- attr = sAttrData.dwFileAttributes;
53724
- }else{
53725
- lastErrno = osGetLastError();
53726
- if( lastErrno==ERROR_FILE_NOT_FOUND
53727
- || lastErrno==ERROR_PATH_NOT_FOUND ){
53728
- rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */
53729
- }else{
53730
- rc = SQLITE_ERROR;
53731
- }
53732
- break;
53733
- }
53734
-#else
5373553541
attr = osGetFileAttributesW(zConverted);
53736
-#endif
5373753542
if ( attr==INVALID_FILE_ATTRIBUTES ){
5373853543
lastErrno = osGetLastError();
5373953544
if( lastErrno==ERROR_FILE_NOT_FOUND
5374053545
|| lastErrno==ERROR_PATH_NOT_FOUND ){
5374153546
rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */
@@ -54022,11 +53827,11 @@
5402253827
sqlite3_vfs *pVfs, /* Pointer to vfs object */
5402353828
const char *zRelative, /* Possibly relative input path */
5402453829
int nFull, /* Size of output buffer in bytes */
5402553830
char *zFull /* Output buffer */
5402653831
){
54027
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
53832
+#if !SQLITE_OS_WINCE
5402853833
int nByte;
5402953834
void *zConverted;
5403053835
char *zOut;
5403153836
#endif
5403253837
@@ -54111,11 +53916,11 @@
5411153916
return rc;
5411253917
}
5411353918
}
5411453919
#endif /* __CYGWIN__ */
5411553920
54116
-#if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && defined(_WIN32)
53921
+#if SQLITE_OS_WINCE && defined(_WIN32)
5411753922
SimulateIOError( return SQLITE_ERROR );
5411853923
/* WinCE has no concept of a relative pathname, or so I am told. */
5411953924
/* WinRT has no way to convert a relative path to an absolute one. */
5412053925
if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
5412153926
/*
@@ -54130,11 +53935,11 @@
5413053935
sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative);
5413153936
}
5413253937
return SQLITE_OK;
5413353938
#endif
5413453939
54135
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
53940
+#if !SQLITE_OS_WINCE
5413653941
#if defined(_WIN32)
5413753942
/* It's odd to simulate an io-error here, but really this is just
5413853943
** using the io-error infrastructure to test that SQLite handles this
5413953944
** function failing. This function could fail if, for example, the
5414053945
** current working directory has been unlinked.
@@ -54262,15 +54067,11 @@
5426254067
if( zConverted==0 ){
5426354068
OSTRACE(("DLOPEN name=%s, handle=%p\n", zFilename, (void*)0));
5426454069
return 0;
5426554070
}
5426654071
if( osIsNT() ){
54267
-#if SQLITE_OS_WINRT
54268
- h = osLoadPackagedLibrary((LPCWSTR)zConverted, 0);
54269
-#else
5427054072
h = osLoadLibraryW((LPCWSTR)zConverted);
54271
-#endif
5427254073
}
5427354074
#ifdef SQLITE_WIN32_HAS_ANSI
5427454075
else{
5427554076
h = osLoadLibraryA((char*)zConverted);
5427654077
}
@@ -54348,37 +54149,30 @@
5434854149
}
5434954150
{
5435054151
DWORD pid = osGetCurrentProcessId();
5435154152
xorMemory(&e, (unsigned char*)&pid, sizeof(DWORD));
5435254153
}
54353
-#if SQLITE_OS_WINRT
54354
- {
54355
- ULONGLONG cnt = osGetTickCount64();
54356
- xorMemory(&e, (unsigned char*)&cnt, sizeof(ULONGLONG));
54357
- }
54358
-#else
5435954154
{
5436054155
DWORD cnt = osGetTickCount();
5436154156
xorMemory(&e, (unsigned char*)&cnt, sizeof(DWORD));
5436254157
}
54363
-#endif /* SQLITE_OS_WINRT */
5436454158
{
5436554159
LARGE_INTEGER i;
5436654160
osQueryPerformanceCounter(&i);
5436754161
xorMemory(&e, (unsigned char*)&i, sizeof(LARGE_INTEGER));
5436854162
}
54369
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID
54163
+#if !SQLITE_OS_WINCE && SQLITE_WIN32_USE_UUID
5437054164
{
5437154165
UUID id;
5437254166
memset(&id, 0, sizeof(UUID));
5437354167
osUuidCreate(&id);
5437454168
xorMemory(&e, (unsigned char*)&id, sizeof(UUID));
5437554169
memset(&id, 0, sizeof(UUID));
5437654170
osUuidCreateSequential(&id);
5437754171
xorMemory(&e, (unsigned char*)&id, sizeof(UUID));
5437854172
}
54379
-#endif /* !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID */
54173
+#endif /* !SQLITE_OS_WINCE && SQLITE_WIN32_USE_UUID */
5438054174
return e.nXor>nBuf ? nBuf : e.nXor;
5438154175
#endif /* defined(SQLITE_TEST) || defined(SQLITE_OMIT_RANDOMNESS) */
5438254176
}
5438354177
5438454178
@@ -54605,19 +54399,15 @@
5460554399
};
5460654400
#endif
5460754401
5460854402
/* Double-check that the aSyscall[] array has been constructed
5460954403
** correctly. See ticket [bb3a86e890c8e96ab] */
54610
- assert( ArraySize(aSyscall)==89 );
54404
+ assert( ArraySize(aSyscall)==86 );
5461154405
5461254406
/* get memory map allocation granularity */
5461354407
memset(&winSysInfo, 0, sizeof(SYSTEM_INFO));
54614
-#if SQLITE_OS_WINRT
54615
- osGetNativeSystemInfo(&winSysInfo);
54616
-#else
5461754408
osGetSystemInfo(&winSysInfo);
54618
-#endif
5461954409
assert( winSysInfo.dwAllocationGranularity>0 );
5462054410
assert( winSysInfo.dwPageSize>0 );
5462154411
5462254412
sqlite3_vfs_register(&winVfs, 1);
5462354413
@@ -54637,21 +54427,13 @@
5463754427
5463854428
return SQLITE_OK;
5463954429
}
5464054430
5464154431
SQLITE_API int sqlite3_os_end(void){
54642
-#if SQLITE_OS_WINRT
54643
- if( sleepObj!=NULL ){
54644
- osCloseHandle(sleepObj);
54645
- sleepObj = NULL;
54646
- }
54647
-#endif
54648
-
5464954432
#ifndef SQLITE_OMIT_WAL
5465054433
winBigLock = 0;
5465154434
#endif
54652
-
5465354435
return SQLITE_OK;
5465454436
}
5465554437
5465654438
#endif /* SQLITE_OS_WIN */
5465754439
@@ -188384,15 +188166,16 @@
188384188166
188385188167
/* Initialize the output variables to -1 in case an error occurs. */
188386188168
if( pnLog ) *pnLog = -1;
188387188169
if( pnCkpt ) *pnCkpt = -1;
188388188170
188171
+ assert( SQLITE_CHECKPOINT_NOOP==-1 );
188389188172
assert( SQLITE_CHECKPOINT_PASSIVE==0 );
188390188173
assert( SQLITE_CHECKPOINT_FULL==1 );
188391188174
assert( SQLITE_CHECKPOINT_RESTART==2 );
188392188175
assert( SQLITE_CHECKPOINT_TRUNCATE==3 );
188393
- if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_TRUNCATE ){
188176
+ if( eMode<SQLITE_CHECKPOINT_NOOP || eMode>SQLITE_CHECKPOINT_TRUNCATE ){
188394188177
/* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint
188395188178
** mode: */
188396188179
return SQLITE_MISUSE_BKPT;
188397188180
}
188398188181
@@ -203418,11 +203201,12 @@
203418203201
PendingList *pList;
203419203202
int rc = SQLITE_OK;
203420203203
203421203204
pList = (PendingList *)fts3HashFind(pHash, zToken, nToken);
203422203205
if( pList ){
203423
- assert( pList->nData+nToken+sizeof(Fts3HashElem) <= (i64)p->nPendingData );
203206
+ assert( (i64)pList->nData+(i64)nToken+(i64)sizeof(Fts3HashElem)
203207
+ <= (i64)p->nPendingData );
203424203208
p->nPendingData -= (int)(pList->nData + nToken + sizeof(Fts3HashElem));
203425203209
}
203426203210
if( fts3PendingListAppend(&pList, p->iPrevDocid, iCol, iPos, &rc) ){
203427203211
if( pList==fts3HashInsert(pHash, zToken, nToken, pList) ){
203428203212
/* Malloc failed while inserting the new entry. This can only
@@ -225114,11 +224898,11 @@
225114224898
total += cnt;
225115224899
if( total>limit ){
225116224900
/* ERROR: copy exceeds output file size */
225117224901
return -1;
225118224902
}
225119
- if( (int)(ofst+cnt) > lenSrc ){
224903
+ if( (u64)ofst+(u64)cnt > (u64)lenSrc ){
225120224904
/* ERROR: copy extends past end of input */
225121224905
return -1;
225122224906
}
225123224907
memcpy(zOut, &zSrc[ofst], cnt);
225124224908
zOut += cnt;
@@ -259795,10 +259579,11 @@
259795259579
}
259796259580
}
259797259581
}
259798259582
259799259583
update_out:
259584
+ sqlite3Fts5IndexCloseReader(pTab->p.pIndex);
259800259585
pTab->p.pConfig->pzErrmsg = 0;
259801259586
return rc;
259802259587
}
259803259588
259804259589
/*
@@ -261312,11 +261097,11 @@
261312261097
int nArg, /* Number of args */
261313261098
sqlite3_value **apUnused /* Function arguments */
261314261099
){
261315261100
assert( nArg==0 );
261316261101
UNUSED_PARAM2(nArg, apUnused);
261317
- sqlite3_result_text(pCtx, "fts5: 2025-12-06 11:54:43 b3da6a8728641a0c9ca2f3b20c9817c0a2be6c5bf05f020590547480d2aff0e0", -1, SQLITE_TRANSIENT);
261102
+ sqlite3_result_text(pCtx, "fts5: 2025-12-11 18:16:39 e785a80e4100c368dca8d73cb662cff4d0fd76734fa0f3fa9b5754a380f7c746", -1, SQLITE_TRANSIENT);
261318261103
}
261319261104
261320261105
/*
261321261106
** Implementation of fts5_locale(LOCALE, TEXT) function.
261322261107
**
261323261108
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** b3da6a8728641a0c9ca2f3b20c9817c0a2be with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -467,14 +467,14 @@
467 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468 ** [sqlite_version()] and [sqlite_source_id()].
469 */
470 #define SQLITE_VERSION "3.52.0"
471 #define SQLITE_VERSION_NUMBER 3052000
472 #define SQLITE_SOURCE_ID "2025-12-06 11:54:43 b3da6a8728641a0c9ca2f3b20c9817c0a2be6c5bf05f020590547480d2aff0e0"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS ""
475 #define SQLITE_SCM_DATETIME "2025-12-06T11:54:43.371Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -30650,18 +30650,10 @@
30650 # define SQLITE_OS_WINCE 1
30651 #else
30652 # define SQLITE_OS_WINCE 0
30653 #endif
30654
30655 /*
30656 ** Determine if we are dealing with WinRT, which provides only a subset of
30657 ** the full Win32 API.
30658 */
30659 #if !defined(SQLITE_OS_WINRT)
30660 # define SQLITE_OS_WINRT 0
30661 #endif
30662
30663 /*
30664 ** For WinCE, some API function parameters do not appear to be declared as
30665 ** volatile.
30666 */
30667 #if SQLITE_OS_WINCE
@@ -30672,11 +30664,11 @@
30672
30673 /*
30674 ** For some Windows sub-platforms, the _beginthreadex() / _endthreadex()
30675 ** functions are not available (e.g. those not using MSVC, Cygwin, etc).
30676 */
30677 #if SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \
30678 SQLITE_THREADSAFE>0 && !defined(__CYGWIN__)
30679 # define SQLITE_OS_WIN_THREADS 1
30680 #else
30681 # define SQLITE_OS_WIN_THREADS 0
30682 #endif
@@ -30789,15 +30781,11 @@
30789 static int winMutexInit(void){
30790 /* The first to increment to 1 does actual initialization */
30791 if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){
30792 int i;
30793 for(i=0; i<ArraySize(winMutex_staticMutexes); i++){
30794 #if SQLITE_OS_WINRT
30795 InitializeCriticalSectionEx(&winMutex_staticMutexes[i].mutex, 0, 0);
30796 #else
30797 InitializeCriticalSection(&winMutex_staticMutexes[i].mutex);
30798 #endif
30799 }
30800 winMutex_isInit = 1;
30801 }else{
30802 /* Another thread is (in the process of) initializing the static
30803 ** mutexes */
@@ -30883,15 +30871,11 @@
30883 #ifdef SQLITE_DEBUG
30884 #ifdef SQLITE_WIN32_MUTEX_TRACE_DYNAMIC
30885 p->trace = 1;
30886 #endif
30887 #endif
30888 #if SQLITE_OS_WINRT
30889 InitializeCriticalSectionEx(&p->mutex, 0, 0);
30890 #else
30891 InitializeCriticalSection(&p->mutex);
30892 #endif
30893 }
30894 break;
30895 }
30896 default: {
30897 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -38300,11 +38284,11 @@
38300
38301 /*****************************************************************************
38302 ** Debugging logic
38303 */
38304
38305 /* SQLITE_KV_TRACE() is used for tracing calls to kvstorage routines. */
38306 #if 0
38307 #define SQLITE_KV_TRACE(X) printf X
38308 #else
38309 #define SQLITE_KV_TRACE(X)
38310 #endif
@@ -38314,18 +38298,22 @@
38314 #define SQLITE_KV_LOG(X) printf X
38315 #else
38316 #define SQLITE_KV_LOG(X)
38317 #endif
38318
38319
38320 /*
38321 ** Forward declaration of objects used by this VFS implementation
38322 */
38323 typedef struct KVVfsFile KVVfsFile;
38324
38325 /* A single open file. There are only two files represented by this
38326 ** VFS - the database and the rollback journal.
 
 
 
 
 
38327 */
38328 struct KVVfsFile {
38329 sqlite3_file base; /* IO methods */
38330 const char *zClass; /* Storage class */
38331 int isJournal; /* True if this is a journal file */
@@ -38371,11 +38359,11 @@
38371 static int kvvfsSleep(sqlite3_vfs*, int microseconds);
38372 static int kvvfsCurrentTime(sqlite3_vfs*, double*);
38373 static int kvvfsCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*);
38374
38375 static sqlite3_vfs sqlite3OsKvvfsObject = {
38376 1, /* iVersion */
38377 sizeof(KVVfsFile), /* szOsFile */
38378 1024, /* mxPathname */
38379 0, /* pNext */
38380 "kvvfs", /* zName */
38381 0, /* pAppData */
@@ -38447,42 +38435,56 @@
38447 #include <sys/stat.h>
38448 #include <unistd.h>
38449
38450 /* Forward declarations for the low-level storage engine
38451 */
38452 static int kvstorageWrite(const char*, const char *zKey, const char *zData);
38453 static int kvstorageDelete(const char*, const char *zKey);
38454 static int kvstorageRead(const char*, const char *zKey, char *zBuf, int nBuf);
38455 #define KVSTORAGE_KEY_SZ 32
 
 
 
 
 
38456
38457 /* Expand the key name with an appropriate prefix and put the result
38458 ** in zKeyOut[]. The zKeyOut[] buffer is assumed to hold at least
38459 ** KVSTORAGE_KEY_SZ bytes.
38460 */
38461 static void kvstorageMakeKey(
38462 const char *zClass,
38463 const char *zKeyIn,
38464 char *zKeyOut
38465 ){
38466 sqlite3_snprintf(KVSTORAGE_KEY_SZ, zKeyOut, "kvvfs-%s-%s", zClass, zKeyIn);
 
 
 
 
38467 }
38468
 
 
 
 
 
38469 /* Write content into a key. zClass is the particular namespace of the
38470 ** underlying key/value store to use - either "local" or "session".
38471 **
38472 ** Both zKey and zData are zero-terminated pure text strings.
38473 **
38474 ** Return the number of errors.
38475 */
38476 static int kvstorageWrite(
38477 const char *zClass,
38478 const char *zKey,
38479 const char *zData
38480 ){
38481 FILE *fd;
38482 char zXKey[KVSTORAGE_KEY_SZ];
38483 kvstorageMakeKey(zClass, zKey, zXKey);
38484 fd = fopen(zXKey, "wb");
38485 if( fd ){
38486 SQLITE_KV_TRACE(("KVVFS-WRITE %-15s (%d) %.50s%s\n", zXKey,
38487 (int)strlen(zData), zData,
38488 strlen(zData)>50 ? "..." : ""));
@@ -38496,13 +38498,13 @@
38496
38497 /* Delete a key (with its corresponding data) from the key/value
38498 ** namespace given by zClass. If the key does not previously exist,
38499 ** this routine is a no-op.
38500 */
38501 static int kvstorageDelete(const char *zClass, const char *zKey){
38502 char zXKey[KVSTORAGE_KEY_SZ];
38503 kvstorageMakeKey(zClass, zKey, zXKey);
38504 unlink(zXKey);
38505 SQLITE_KV_TRACE(("KVVFS-DELETE %-15s\n", zXKey));
38506 return 0;
38507 }
38508
@@ -38519,20 +38521,20 @@
38519 ** If nBuf<=0 then this routine simply returns the size of the data
38520 ** without actually reading it. Similarly, if nBuf==1 then it
38521 ** zero-terminates zBuf at zBuf[0] and returns the size of the data
38522 ** without reading it.
38523 */
38524 static int kvstorageRead(
38525 const char *zClass,
38526 const char *zKey,
38527 char *zBuf,
38528 int nBuf
38529 ){
38530 FILE *fd;
38531 struct stat buf;
38532 char zXKey[KVSTORAGE_KEY_SZ];
38533 kvstorageMakeKey(zClass, zKey, zXKey);
38534 if( access(zXKey, R_OK)!=0
38535 || stat(zXKey, &buf)!=0
38536 || !S_ISREG(buf.st_mode)
38537 ){
38538 SQLITE_KV_TRACE(("KVVFS-READ %-15s (-1)\n", zXKey));
@@ -38560,27 +38562,39 @@
38560 SQLITE_KV_TRACE(("KVVFS-READ %-15s (%lld) %.50s%s\n", zXKey,
38561 n, zBuf, n>50 ? "..." : ""));
38562 return (int)n;
38563 }
38564 }
 
 
38565
38566 /*
38567 ** An internal level of indirection which enables us to replace the
38568 ** kvvfs i/o methods with JavaScript implementations in WASM builds.
38569 ** Maintenance reminder: if this struct changes in any way, the JSON
38570 ** rendering of its structure must be updated in
38571 ** sqlite3-wasm.c:sqlite3__wasm_enum_json(). There are no binary
38572 ** compatibility concerns, so it does not need an iVersion
38573 ** member.
38574 */
38575 typedef struct sqlite3_kvvfs_methods sqlite3_kvvfs_methods;
38576 struct sqlite3_kvvfs_methods {
38577 int (*xRead)(const char *zClass, const char *zKey, char *zBuf, int nBuf);
38578 int (*xWrite)(const char *zClass, const char *zKey, const char *zData);
38579 int (*xDelete)(const char *zClass, const char *zKey);
38580 const int nKeySize;
 
 
 
 
 
 
 
 
 
 
38581 };
 
38582
38583 /*
38584 ** This object holds the kvvfs I/O methods which may be swapped out
38585 ** for JavaScript-side implementations in WASM builds. In such builds
38586 ** it cannot be const, but in native builds it should be so that
@@ -38592,14 +38606,24 @@
38592 */
38593 #ifndef SQLITE_WASM
38594 const
38595 #endif
38596 SQLITE_PRIVATE sqlite3_kvvfs_methods sqlite3KvvfsMethods = {
38597 kvstorageRead,
38598 kvstorageWrite,
38599 kvstorageDelete,
38600 KVSTORAGE_KEY_SZ
 
 
 
 
 
 
 
 
 
 
38601 };
38602
38603 /****** Utility subroutines ************************************************/
38604
38605 /*
@@ -38622,11 +38646,14 @@
38622 **
38623 ** * Because there is no overlap between the encoding characters
38624 ** of hexadecimal and base-26 numbers, it is always clear where
38625 ** one stops and the next begins.
38626 */
38627 static int kvvfsEncode(const char *aData, int nData, char *aOut){
 
 
 
38628 int i, j;
38629 const unsigned char *a = (const unsigned char*)aData;
38630 for(i=j=0; i<nData; i++){
38631 unsigned char c = a[i];
38632 if( c!=0 ){
@@ -38673,13 +38700,17 @@
38673
38674 /*
38675 ** Decode the text encoding back to binary. The binary content is
38676 ** written into pOut, which must be at least nOut bytes in length.
38677 **
38678 ** The return value is the number of bytes actually written into aOut[].
 
38679 */
38680 static int kvvfsDecode(const char *a, char *aOut, int nOut){
 
 
 
38681 int i, j;
38682 int c;
38683 const unsigned char *aIn = (const unsigned char*)a;
38684 i = 0;
38685 j = 0;
@@ -38700,11 +38731,11 @@
38700 j += n;
38701 if( c==0 || mult==1 ) break; /* progress stalled if mult==1 */
38702 }else{
38703 aOut[j] = c<<4;
38704 c = kvvfsHexValue[aIn[++i]];
38705 if( c<0 ) break;
38706 aOut[j++] += c;
38707 i++;
38708 }
38709 }
38710 return j;
@@ -38753,17 +38784,18 @@
38753 ** Read or write the "sz" element, containing the database file size.
38754 */
38755 static sqlite3_int64 kvvfsReadFileSize(KVVfsFile *pFile){
38756 char zData[50];
38757 zData[0] = 0;
38758 sqlite3KvvfsMethods.xRead(pFile->zClass, "sz", zData, sizeof(zData)-1);
 
38759 return strtoll(zData, 0, 0);
38760 }
38761 static int kvvfsWriteFileSize(KVVfsFile *pFile, sqlite3_int64 sz){
38762 char zData[50];
38763 sqlite3_snprintf(sizeof(zData), zData, "%lld", sz);
38764 return sqlite3KvvfsMethods.xWrite(pFile->zClass, "sz", zData);
38765 }
38766
38767 /****** sqlite3_io_methods methods ******************************************/
38768
38769 /*
@@ -38774,10 +38806,13 @@
38774
38775 SQLITE_KV_LOG(("xClose %s %s\n", pFile->zClass,
38776 pFile->isJournal ? "journal" : "db"));
38777 sqlite3_free(pFile->aJrnl);
38778 sqlite3_free(pFile->aData);
 
 
 
38779 return SQLITE_OK;
38780 }
38781
38782 /*
38783 ** Read from the -journal file.
@@ -38790,20 +38825,26 @@
38790 ){
38791 KVVfsFile *pFile = (KVVfsFile*)pProtoFile;
38792 assert( pFile->isJournal );
38793 SQLITE_KV_LOG(("xRead('%s-journal',%d,%lld)\n", pFile->zClass, iAmt, iOfst));
38794 if( pFile->aJrnl==0 ){
38795 int szTxt = kvstorageRead(pFile->zClass, "jrnl", 0, 0);
 
 
38796 char *aTxt;
38797 if( szTxt<=4 ){
38798 return SQLITE_IOERR;
38799 }
38800 aTxt = sqlite3_malloc64( szTxt+1 );
38801 if( aTxt==0 ) return SQLITE_NOMEM;
38802 kvstorageRead(pFile->zClass, "jrnl", aTxt, szTxt+1);
38803 kvvfsDecodeJournal(pFile, aTxt, szTxt);
 
 
 
38804 sqlite3_free(aTxt);
 
38805 if( pFile->aJrnl==0 ) return SQLITE_IOERR;
38806 }
38807 if( iOfst+iAmt>pFile->nJrnl ){
38808 return SQLITE_IOERR_SHORT_READ;
38809 }
@@ -38839,12 +38880,12 @@
38839 pgno = 1 + iOfst/iAmt;
38840 }else{
38841 pgno = 1;
38842 }
38843 sqlite3_snprintf(sizeof(zKey), zKey, "%u", pgno);
38844 got = sqlite3KvvfsMethods.xRead(pFile->zClass, zKey,
38845 aData, SQLITE_KVOS_SZ-1);
38846 if( got<0 ){
38847 n = 0;
38848 }else{
38849 aData[got] = 0;
38850 if( iOfst+iAmt<512 ){
@@ -38908,35 +38949,36 @@
38908 ){
38909 KVVfsFile *pFile = (KVVfsFile*)pProtoFile;
38910 unsigned int pgno;
38911 char zKey[30];
38912 char *aData = pFile->aData;
 
38913 SQLITE_KV_LOG(("xWrite('%s-db',%d,%lld)\n", pFile->zClass, iAmt, iOfst));
38914 assert( iAmt>=512 && iAmt<=65536 );
38915 assert( (iAmt & (iAmt-1))==0 );
38916 assert( pFile->szPage<0 || pFile->szPage==iAmt );
38917 pFile->szPage = iAmt;
38918 pgno = 1 + iOfst/iAmt;
38919 sqlite3_snprintf(sizeof(zKey), zKey, "%u", pgno);
38920 kvvfsEncode(zBuf, iAmt, aData);
38921 if( sqlite3KvvfsMethods.xWrite(pFile->zClass, zKey, aData) ){
38922 return SQLITE_IOERR;
 
 
 
38923 }
38924 if( iOfst+iAmt > pFile->szDb ){
38925 pFile->szDb = iOfst + iAmt;
38926 }
38927 return SQLITE_OK;
38928 }
38929
38930 /*
38931 ** Truncate an kvvfs-file.
38932 */
38933 static int kvvfsTruncateJrnl(sqlite3_file *pProtoFile, sqlite_int64 size){
38934 KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
38935 SQLITE_KV_LOG(("xTruncate('%s-journal',%lld)\n", pFile->zClass, size));
38936 assert( size==0 );
38937 sqlite3KvvfsMethods.xDelete(pFile->zClass, "jrnl");
38938 sqlite3_free(pFile->aJrnl);
38939 pFile->aJrnl = 0;
38940 pFile->nJrnl = 0;
38941 return SQLITE_OK;
38942 }
@@ -38951,11 +38993,11 @@
38951 SQLITE_KV_LOG(("xTruncate('%s-db',%lld)\n", pFile->zClass, size));
38952 pgno = 1 + size/pFile->szPage;
38953 pgnoMax = 2 + pFile->szDb/pFile->szPage;
38954 while( pgno<=pgnoMax ){
38955 sqlite3_snprintf(sizeof(zKey), zKey, "%u", pgno);
38956 sqlite3KvvfsMethods.xDelete(pFile->zClass, zKey);
38957 pgno++;
38958 }
38959 pFile->szDb = size;
38960 return kvvfsWriteFileSize(pFile, size) ? SQLITE_IOERR : SQLITE_OK;
38961 }
@@ -38983,11 +39025,11 @@
38983 zOut[i++] = 'a' + (n%26);
38984 n /= 26;
38985 }while( n>0 );
38986 zOut[i++] = ' ';
38987 kvvfsEncode(pFile->aJrnl, pFile->nJrnl, &zOut[i]);
38988 i = sqlite3KvvfsMethods.xWrite(pFile->zClass, "jrnl", zOut);
38989 sqlite3_free(zOut);
38990 return i ? SQLITE_IOERR : SQLITE_OK;
38991 }
38992 static int kvvfsSyncDb(sqlite3_file *pProtoFile, int flags){
38993 return SQLITE_OK;
@@ -39097,53 +39139,56 @@
39097 int *pOutFlags
39098 ){
39099 KVVfsFile *pFile = (KVVfsFile*)pProtoFile;
39100 if( zName==0 ) zName = "";
39101 SQLITE_KV_LOG(("xOpen(\"%s\")\n", zName));
39102 if( strcmp(zName, "local")==0
39103 || strcmp(zName, "session")==0
39104 ){
39105 pFile->isJournal = 0;
39106 pFile->base.pMethods = &kvvfs_db_io_methods;
39107 }else
39108 if( strcmp(zName, "local-journal")==0
39109 || strcmp(zName, "session-journal")==0
39110 ){
39111 pFile->isJournal = 1;
39112 pFile->base.pMethods = &kvvfs_jrnl_io_methods;
 
 
 
 
 
39113 }else{
39114 return SQLITE_CANTOPEN;
 
39115 }
39116 if( zName[0]=='s' ){
39117 pFile->zClass = "session";
39118 }else{
39119 pFile->zClass = "local";
39120 }
39121 pFile->aData = sqlite3_malloc64(SQLITE_KVOS_SZ);
39122 if( pFile->aData==0 ){
39123 return SQLITE_NOMEM;
39124 }
39125 pFile->aJrnl = 0;
39126 pFile->nJrnl = 0;
39127 pFile->szPage = -1;
39128 pFile->szDb = -1;
39129 return SQLITE_OK;
39130 }
39131
39132 /*
39133 ** Delete the file located at zPath. If the dirSync argument is true,
39134 ** ensure the file-system modifications are synced to disk before
39135 ** returning.
39136 */
39137 static int kvvfsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
 
39138 if( strcmp(zPath, "local-journal")==0 ){
39139 sqlite3KvvfsMethods.xDelete("local", "jrnl");
39140 }else
39141 if( strcmp(zPath, "session-journal")==0 ){
39142 sqlite3KvvfsMethods.xDelete("session", "jrnl");
39143 }
39144 return SQLITE_OK;
 
 
 
39145 }
39146
39147 /*
39148 ** Test for access permissions. Return true if the requested permission
39149 ** is available, or false otherwise.
@@ -39153,25 +39198,46 @@
39153 const char *zPath,
39154 int flags,
39155 int *pResOut
39156 ){
39157 SQLITE_KV_LOG(("xAccess(\"%s\")\n", zPath));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39158 if( strcmp(zPath, "local-journal")==0 ){
39159 *pResOut = sqlite3KvvfsMethods.xRead("local", "jrnl", 0, 0)>0;
 
39160 }else
39161 if( strcmp(zPath, "session-journal")==0 ){
39162 *pResOut = sqlite3KvvfsMethods.xRead("session", "jrnl", 0, 0)>0;
 
39163 }else
39164 if( strcmp(zPath, "local")==0 ){
39165 *pResOut = sqlite3KvvfsMethods.xRead("local", "sz", 0, 0)>0;
 
39166 }else
39167 if( strcmp(zPath, "session")==0 ){
39168 *pResOut = sqlite3KvvfsMethods.xRead("session", "sz", 0, 0)>0;
 
39169 }else
39170 {
39171 *pResOut = 0;
39172 }
 
 
39173 SQLITE_KV_LOG(("xAccess returns %d\n",*pResOut));
39174 return SQLITE_OK;
39175 }
39176
39177 /*
@@ -47896,19 +47962,19 @@
47896
47897 /*
47898 ** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
47899 ** based on the sub-platform)?
47900 */
47901 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(SQLITE_WIN32_NO_ANSI)
47902 # define SQLITE_WIN32_HAS_ANSI
47903 #endif
47904
47905 /*
47906 ** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
47907 ** based on the sub-platform)?
47908 */
47909 #if (SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT) && \
47910 !defined(SQLITE_WIN32_NO_WIDE)
47911 # define SQLITE_WIN32_HAS_WIDE
47912 #endif
47913
47914 /*
@@ -48043,20 +48109,11 @@
48043 ** mode or memory mapped files (e.g. these APIs are available in the Windows
48044 ** CE SDK; however, they are not present in the header file)?
48045 */
48046 #if SQLITE_WIN32_FILEMAPPING_API && \
48047 (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
48048 /*
48049 ** Two of the file mapping APIs are different under WinRT. Figure out which
48050 ** set we need.
48051 */
48052 #if SQLITE_OS_WINRT
48053 WINBASEAPI HANDLE WINAPI CreateFileMappingFromApp(HANDLE, \
48054 LPSECURITY_ATTRIBUTES, ULONG, ULONG64, LPCWSTR);
48055
48056 WINBASEAPI LPVOID WINAPI MapViewOfFileFromApp(HANDLE, ULONG, ULONG64, SIZE_T);
48057 #else
48058 #if defined(SQLITE_WIN32_HAS_ANSI)
48059 WINBASEAPI HANDLE WINAPI CreateFileMappingA(HANDLE, LPSECURITY_ATTRIBUTES, \
48060 DWORD, DWORD, DWORD, LPCSTR);
48061 #endif /* defined(SQLITE_WIN32_HAS_ANSI) */
48062
@@ -48064,11 +48121,10 @@
48064 WINBASEAPI HANDLE WINAPI CreateFileMappingW(HANDLE, LPSECURITY_ATTRIBUTES, \
48065 DWORD, DWORD, DWORD, LPCWSTR);
48066 #endif /* defined(SQLITE_WIN32_HAS_WIDE) */
48067
48068 WINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T);
48069 #endif /* SQLITE_OS_WINRT */
48070
48071 /*
48072 ** These file mapping APIs are common to both Win32 and WinRT.
48073 */
48074
@@ -48355,11 +48411,11 @@
48355
48356 /*
48357 ** This function is not available on Windows CE or WinRT.
48358 */
48359
48360 #if SQLITE_OS_WINCE || SQLITE_OS_WINRT
48361 # define osAreFileApisANSI() 1
48362 #endif
48363
48364 /*
48365 ** Many system calls are accessed through pointer-to-functions so that
@@ -48370,11 +48426,11 @@
48370 static struct win_syscall {
48371 const char *zName; /* Name of the system call */
48372 sqlite3_syscall_ptr pCurrent; /* Current value of the system call */
48373 sqlite3_syscall_ptr pDefault; /* Default value */
48374 } aSyscall[] = {
48375 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
48376 { "AreFileApisANSI", (SYSCALL)AreFileApisANSI, 0 },
48377 #else
48378 { "AreFileApisANSI", (SYSCALL)0, 0 },
48379 #endif
48380
@@ -48409,20 +48465,20 @@
48409 #endif
48410
48411 #define osCreateFileA ((HANDLE(WINAPI*)(LPCSTR,DWORD,DWORD, \
48412 LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[4].pCurrent)
48413
48414 #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
48415 { "CreateFileW", (SYSCALL)CreateFileW, 0 },
48416 #else
48417 { "CreateFileW", (SYSCALL)0, 0 },
48418 #endif
48419
48420 #define osCreateFileW ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD, \
48421 LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[5].pCurrent)
48422
48423 #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_ANSI) && \
48424 (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) && \
48425 SQLITE_WIN32_CREATEFILEMAPPINGA
48426 { "CreateFileMappingA", (SYSCALL)CreateFileMappingA, 0 },
48427 #else
48428 { "CreateFileMappingA", (SYSCALL)0, 0 },
@@ -48429,21 +48485,21 @@
48429 #endif
48430
48431 #define osCreateFileMappingA ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \
48432 DWORD,DWORD,DWORD,LPCSTR))aSyscall[6].pCurrent)
48433
48434 #if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \
48435 (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0))
48436 { "CreateFileMappingW", (SYSCALL)CreateFileMappingW, 0 },
48437 #else
48438 { "CreateFileMappingW", (SYSCALL)0, 0 },
48439 #endif
48440
48441 #define osCreateFileMappingW ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \
48442 DWORD,DWORD,DWORD,LPCWSTR))aSyscall[7].pCurrent)
48443
48444 #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
48445 { "CreateMutexW", (SYSCALL)CreateMutexW, 0 },
48446 #else
48447 { "CreateMutexW", (SYSCALL)0, 0 },
48448 #endif
48449
@@ -48525,11 +48581,11 @@
48525 #endif
48526
48527 #define osGetDiskFreeSpaceA ((BOOL(WINAPI*)(LPCSTR,LPDWORD,LPDWORD,LPDWORD, \
48528 LPDWORD))aSyscall[18].pCurrent)
48529
48530 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
48531 { "GetDiskFreeSpaceW", (SYSCALL)GetDiskFreeSpaceW, 0 },
48532 #else
48533 { "GetDiskFreeSpaceW", (SYSCALL)0, 0 },
48534 #endif
48535
@@ -48542,11 +48598,11 @@
48542 { "GetFileAttributesA", (SYSCALL)0, 0 },
48543 #endif
48544
48545 #define osGetFileAttributesA ((DWORD(WINAPI*)(LPCSTR))aSyscall[20].pCurrent)
48546
48547 #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
48548 { "GetFileAttributesW", (SYSCALL)GetFileAttributesW, 0 },
48549 #else
48550 { "GetFileAttributesW", (SYSCALL)0, 0 },
48551 #endif
48552
@@ -48559,15 +48615,11 @@
48559 #endif
48560
48561 #define osGetFileAttributesExW ((BOOL(WINAPI*)(LPCWSTR,GET_FILEEX_INFO_LEVELS, \
48562 LPVOID))aSyscall[22].pCurrent)
48563
48564 #if !SQLITE_OS_WINRT
48565 { "GetFileSize", (SYSCALL)GetFileSize, 0 },
48566 #else
48567 { "GetFileSize", (SYSCALL)0, 0 },
48568 #endif
48569
48570 #define osGetFileSize ((DWORD(WINAPI*)(HANDLE,LPDWORD))aSyscall[23].pCurrent)
48571
48572 #if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_ANSI)
48573 { "GetFullPathNameA", (SYSCALL)GetFullPathNameA, 0 },
@@ -48576,11 +48628,11 @@
48576 #endif
48577
48578 #define osGetFullPathNameA ((DWORD(WINAPI*)(LPCSTR,DWORD,LPSTR, \
48579 LPSTR*))aSyscall[24].pCurrent)
48580
48581 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
48582 { "GetFullPathNameW", (SYSCALL)GetFullPathNameW, 0 },
48583 #else
48584 { "GetFullPathNameW", (SYSCALL)0, 0 },
48585 #endif
48586
@@ -48611,20 +48663,14 @@
48611 #endif
48612
48613 #define osGetProcAddressA ((FARPROC(WINAPI*)(HMODULE, \
48614 LPCSTR))aSyscall[27].pCurrent)
48615
48616 #if !SQLITE_OS_WINRT
48617 { "GetSystemInfo", (SYSCALL)GetSystemInfo, 0 },
48618 #else
48619 { "GetSystemInfo", (SYSCALL)0, 0 },
48620 #endif
48621
48622 #define osGetSystemInfo ((VOID(WINAPI*)(LPSYSTEM_INFO))aSyscall[28].pCurrent)
48623
48624 { "GetSystemTime", (SYSCALL)GetSystemTime, 0 },
48625
48626 #define osGetSystemTime ((VOID(WINAPI*)(LPSYSTEMTIME))aSyscall[29].pCurrent)
48627
48628 #if !SQLITE_OS_WINCE
48629 { "GetSystemTimeAsFileTime", (SYSCALL)GetSystemTimeAsFileTime, 0 },
48630 #else
@@ -48640,23 +48686,19 @@
48640 { "GetTempPathA", (SYSCALL)0, 0 },
48641 #endif
48642
48643 #define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent)
48644
48645 #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
48646 { "GetTempPathW", (SYSCALL)GetTempPathW, 0 },
48647 #else
48648 { "GetTempPathW", (SYSCALL)0, 0 },
48649 #endif
48650
48651 #define osGetTempPathW ((DWORD(WINAPI*)(DWORD,LPWSTR))aSyscall[32].pCurrent)
48652
48653 #if !SQLITE_OS_WINRT
48654 { "GetTickCount", (SYSCALL)GetTickCount, 0 },
48655 #else
48656 { "GetTickCount", (SYSCALL)0, 0 },
48657 #endif
48658
48659 #define osGetTickCount ((DWORD(WINAPI*)(VOID))aSyscall[33].pCurrent)
48660
48661 #if defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_GETVERSIONEX
48662 { "GetVersionExA", (SYSCALL)GetVersionExA, 0 },
@@ -48665,11 +48707,11 @@
48665 #endif
48666
48667 #define osGetVersionExA ((BOOL(WINAPI*)( \
48668 LPOSVERSIONINFOA))aSyscall[34].pCurrent)
48669
48670 #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \
48671 SQLITE_WIN32_GETVERSIONEX
48672 { "GetVersionExW", (SYSCALL)GetVersionExW, 0 },
48673 #else
48674 { "GetVersionExW", (SYSCALL)0, 0 },
48675 #endif
@@ -48680,24 +48722,16 @@
48680 { "HeapAlloc", (SYSCALL)HeapAlloc, 0 },
48681
48682 #define osHeapAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD, \
48683 SIZE_T))aSyscall[36].pCurrent)
48684
48685 #if !SQLITE_OS_WINRT
48686 { "HeapCreate", (SYSCALL)HeapCreate, 0 },
48687 #else
48688 { "HeapCreate", (SYSCALL)0, 0 },
48689 #endif
48690
48691 #define osHeapCreate ((HANDLE(WINAPI*)(DWORD,SIZE_T, \
48692 SIZE_T))aSyscall[37].pCurrent)
48693
48694 #if !SQLITE_OS_WINRT
48695 { "HeapDestroy", (SYSCALL)HeapDestroy, 0 },
48696 #else
48697 { "HeapDestroy", (SYSCALL)0, 0 },
48698 #endif
48699
48700 #define osHeapDestroy ((BOOL(WINAPI*)(HANDLE))aSyscall[38].pCurrent)
48701
48702 { "HeapFree", (SYSCALL)HeapFree, 0 },
48703
@@ -48711,20 +48745,16 @@
48711 { "HeapSize", (SYSCALL)HeapSize, 0 },
48712
48713 #define osHeapSize ((SIZE_T(WINAPI*)(HANDLE,DWORD, \
48714 LPCVOID))aSyscall[41].pCurrent)
48715
48716 #if !SQLITE_OS_WINRT
48717 { "HeapValidate", (SYSCALL)HeapValidate, 0 },
48718 #else
48719 { "HeapValidate", (SYSCALL)0, 0 },
48720 #endif
48721
48722 #define osHeapValidate ((BOOL(WINAPI*)(HANDLE,DWORD, \
48723 LPCVOID))aSyscall[42].pCurrent)
48724
48725 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
48726 { "HeapCompact", (SYSCALL)HeapCompact, 0 },
48727 #else
48728 { "HeapCompact", (SYSCALL)0, 0 },
48729 #endif
48730
@@ -48736,28 +48766,24 @@
48736 { "LoadLibraryA", (SYSCALL)0, 0 },
48737 #endif
48738
48739 #define osLoadLibraryA ((HMODULE(WINAPI*)(LPCSTR))aSyscall[44].pCurrent)
48740
48741 #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \
48742 !defined(SQLITE_OMIT_LOAD_EXTENSION)
48743 { "LoadLibraryW", (SYSCALL)LoadLibraryW, 0 },
48744 #else
48745 { "LoadLibraryW", (SYSCALL)0, 0 },
48746 #endif
48747
48748 #define osLoadLibraryW ((HMODULE(WINAPI*)(LPCWSTR))aSyscall[45].pCurrent)
48749
48750 #if !SQLITE_OS_WINRT
48751 { "LocalFree", (SYSCALL)LocalFree, 0 },
48752 #else
48753 { "LocalFree", (SYSCALL)0, 0 },
48754 #endif
48755
48756 #define osLocalFree ((HLOCAL(WINAPI*)(HLOCAL))aSyscall[46].pCurrent)
48757
48758 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
48759 { "LockFile", (SYSCALL)LockFile, 0 },
48760 #else
48761 { "LockFile", (SYSCALL)0, 0 },
48762 #endif
48763
@@ -48775,12 +48801,11 @@
48775 #ifndef osLockFileEx
48776 #define osLockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,DWORD, \
48777 LPOVERLAPPED))aSyscall[48].pCurrent)
48778 #endif
48779
48780 #if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && \
48781 (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0))
48782 { "MapViewOfFile", (SYSCALL)MapViewOfFile, 0 },
48783 #else
48784 { "MapViewOfFile", (SYSCALL)0, 0 },
48785 #endif
48786
@@ -48804,33 +48829,25 @@
48804
48805 { "SetEndOfFile", (SYSCALL)SetEndOfFile, 0 },
48806
48807 #define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[53].pCurrent)
48808
48809 #if !SQLITE_OS_WINRT
48810 { "SetFilePointer", (SYSCALL)SetFilePointer, 0 },
48811 #else
48812 { "SetFilePointer", (SYSCALL)0, 0 },
48813 #endif
48814
48815 #define osSetFilePointer ((DWORD(WINAPI*)(HANDLE,LONG,PLONG, \
48816 DWORD))aSyscall[54].pCurrent)
48817
48818 #if !SQLITE_OS_WINRT
48819 { "Sleep", (SYSCALL)Sleep, 0 },
48820 #else
48821 { "Sleep", (SYSCALL)0, 0 },
48822 #endif
48823
48824 #define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[55].pCurrent)
48825
48826 { "SystemTimeToFileTime", (SYSCALL)SystemTimeToFileTime, 0 },
48827
48828 #define osSystemTimeToFileTime ((BOOL(WINAPI*)(const SYSTEMTIME*, \
48829 LPFILETIME))aSyscall[56].pCurrent)
48830
48831 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
48832 { "UnlockFile", (SYSCALL)UnlockFile, 0 },
48833 #else
48834 { "UnlockFile", (SYSCALL)0, 0 },
48835 #endif
48836
@@ -48864,15 +48881,11 @@
48864 { "WriteFile", (SYSCALL)WriteFile, 0 },
48865
48866 #define osWriteFile ((BOOL(WINAPI*)(HANDLE,LPCVOID,DWORD,LPDWORD, \
48867 LPOVERLAPPED))aSyscall[61].pCurrent)
48868
48869 #if SQLITE_OS_WINRT
48870 { "CreateEventExW", (SYSCALL)CreateEventExW, 0 },
48871 #else
48872 { "CreateEventExW", (SYSCALL)0, 0 },
48873 #endif
48874
48875 #define osCreateEventExW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,LPCWSTR, \
48876 DWORD,DWORD))aSyscall[62].pCurrent)
48877
48878 /*
@@ -48893,68 +48906,30 @@
48893 #endif
48894
48895 #define osWaitForSingleObjectEx ((DWORD(WINAPI*)(HANDLE,DWORD, \
48896 BOOL))aSyscall[64].pCurrent)
48897
48898 #if SQLITE_OS_WINRT
48899 { "SetFilePointerEx", (SYSCALL)SetFilePointerEx, 0 },
48900 #else
48901 { "SetFilePointerEx", (SYSCALL)0, 0 },
48902 #endif
48903
48904 #define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \
48905 PLARGE_INTEGER,DWORD))aSyscall[65].pCurrent)
48906
48907 #if SQLITE_OS_WINRT
48908 { "GetFileInformationByHandleEx", (SYSCALL)GetFileInformationByHandleEx, 0 },
48909 #else
48910 { "GetFileInformationByHandleEx", (SYSCALL)0, 0 },
48911 #endif
48912
48913 #define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \
48914 FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[66].pCurrent)
48915
48916 #if SQLITE_OS_WINRT && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
48917 { "MapViewOfFileFromApp", (SYSCALL)MapViewOfFileFromApp, 0 },
48918 #else
48919 { "MapViewOfFileFromApp", (SYSCALL)0, 0 },
48920 #endif
48921
48922 #define osMapViewOfFileFromApp ((LPVOID(WINAPI*)(HANDLE,ULONG,ULONG64, \
48923 SIZE_T))aSyscall[67].pCurrent)
48924
48925 #if SQLITE_OS_WINRT
48926 { "CreateFile2", (SYSCALL)CreateFile2, 0 },
48927 #else
48928 { "CreateFile2", (SYSCALL)0, 0 },
48929 #endif
48930
48931 #define osCreateFile2 ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD,DWORD, \
48932 LPCREATEFILE2_EXTENDED_PARAMETERS))aSyscall[68].pCurrent)
48933
48934 #if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_LOAD_EXTENSION)
48935 { "LoadPackagedLibrary", (SYSCALL)LoadPackagedLibrary, 0 },
48936 #else
48937 { "LoadPackagedLibrary", (SYSCALL)0, 0 },
48938 #endif
48939
48940 #define osLoadPackagedLibrary ((HMODULE(WINAPI*)(LPCWSTR, \
48941 DWORD))aSyscall[69].pCurrent)
48942
48943 #if SQLITE_OS_WINRT
48944 { "GetTickCount64", (SYSCALL)GetTickCount64, 0 },
48945 #else
48946 { "GetTickCount64", (SYSCALL)0, 0 },
48947 #endif
48948
48949 #define osGetTickCount64 ((ULONGLONG(WINAPI*)(VOID))aSyscall[70].pCurrent)
48950
48951 #if SQLITE_OS_WINRT
48952 { "GetNativeSystemInfo", (SYSCALL)GetNativeSystemInfo, 0 },
48953 #else
48954 { "GetNativeSystemInfo", (SYSCALL)0, 0 },
48955 #endif
48956
48957 #define osGetNativeSystemInfo ((VOID(WINAPI*)( \
48958 LPSYSTEM_INFO))aSyscall[71].pCurrent)
48959
48960 #if defined(SQLITE_WIN32_HAS_ANSI)
@@ -48975,19 +48950,10 @@
48975
48976 { "GetProcessHeap", (SYSCALL)GetProcessHeap, 0 },
48977
48978 #define osGetProcessHeap ((HANDLE(WINAPI*)(VOID))aSyscall[74].pCurrent)
48979
48980 #if SQLITE_OS_WINRT && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
48981 { "CreateFileMappingFromApp", (SYSCALL)CreateFileMappingFromApp, 0 },
48982 #else
48983 { "CreateFileMappingFromApp", (SYSCALL)0, 0 },
48984 #endif
48985
48986 #define osCreateFileMappingFromApp ((HANDLE(WINAPI*)(HANDLE, \
48987 LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[75].pCurrent)
48988
48989 /*
48990 ** NOTE: On some sub-platforms, the InterlockedCompareExchange "function"
48991 ** is really just a macro that uses a compiler intrinsic (e.g. x64).
48992 ** So do not try to make this is into a redefinable interface.
48993 */
@@ -49000,19 +48966,19 @@
49000
49001 #define osInterlockedCompareExchange ((LONG(WINAPI*)(LONG \
49002 SQLITE_WIN32_VOLATILE*, LONG,LONG))aSyscall[76].pCurrent)
49003 #endif /* defined(InterlockedCompareExchange) */
49004
49005 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID
49006 { "UuidCreate", (SYSCALL)UuidCreate, 0 },
49007 #else
49008 { "UuidCreate", (SYSCALL)0, 0 },
49009 #endif
49010
49011 #define osUuidCreate ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[77].pCurrent)
49012
49013 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID
49014 { "UuidCreateSequential", (SYSCALL)UuidCreateSequential, 0 },
49015 #else
49016 { "UuidCreateSequential", (SYSCALL)0, 0 },
49017 #endif
49018
@@ -49219,14 +49185,14 @@
49219
49220 winMemAssertMagic();
49221 hHeap = winMemGetHeap();
49222 assert( hHeap!=0 );
49223 assert( hHeap!=INVALID_HANDLE_VALUE );
49224 #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)
49225 assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );
49226 #endif
49227 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
49228 if( (nLargest=osHeapCompact(hHeap, SQLITE_WIN32_HEAP_FLAGS))==0 ){
49229 DWORD lastErrno = osGetLastError();
49230 if( lastErrno==NO_ERROR ){
49231 sqlite3_log(SQLITE_NOMEM, "failed to HeapCompact (no space), heap=%p",
49232 (void*)hHeap);
@@ -49335,32 +49301,15 @@
49335 }
49336 #endif
49337 }
49338 #endif /* _WIN32 */
49339
49340 /*
49341 ** The following routine suspends the current thread for at least ms
49342 ** milliseconds. This is equivalent to the Win32 Sleep() interface.
49343 */
49344 #if SQLITE_OS_WINRT
49345 static HANDLE sleepObj = NULL;
49346 #endif
49347
49348 SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds){
49349 #if SQLITE_OS_WINRT
49350 if ( sleepObj==NULL ){
49351 sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET,
49352 SYNCHRONIZE);
49353 }
49354 assert( sleepObj!=NULL );
49355 osWaitForSingleObjectEx(sleepObj, milliseconds, FALSE);
49356 #else
49357 osSleep(milliseconds);
49358 #endif
49359 }
49360
49361 #if SQLITE_MAX_WORKER_THREADS>0 && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \
49362 SQLITE_THREADSAFE>0
49363 SQLITE_PRIVATE DWORD sqlite3Win32Wait(HANDLE hObject){
49364 DWORD rc;
49365 while( (rc = osWaitForSingleObjectEx(hObject, INFINITE,
49366 TRUE))==WAIT_IO_COMPLETION ){}
@@ -49380,11 +49329,11 @@
49380 ** the LockFileEx() API.
49381 */
49382
49383 #if !SQLITE_WIN32_GETVERSIONEX
49384 # define osIsNT() (1)
49385 #elif SQLITE_OS_WINCE || SQLITE_OS_WINRT || !defined(SQLITE_WIN32_HAS_ANSI)
49386 # define osIsNT() (1)
49387 #elif !defined(SQLITE_WIN32_HAS_WIDE)
49388 # define osIsNT() (0)
49389 #else
49390 # define osIsNT() ((sqlite3_os_type==2) || sqlite3_win32_is_nt())
@@ -49393,17 +49342,11 @@
49393 /*
49394 ** This function determines if the machine is running a version of Windows
49395 ** based on the NT kernel.
49396 */
49397 SQLITE_API int sqlite3_win32_is_nt(void){
49398 #if SQLITE_OS_WINRT
49399 /*
49400 ** NOTE: The WinRT sub-platform is always assumed to be based on the NT
49401 ** kernel.
49402 */
49403 return 1;
49404 #elif SQLITE_WIN32_GETVERSIONEX
49405 if( osInterlockedCompareExchange(&sqlite3_os_type, 0, 0)==0 ){
49406 #if defined(SQLITE_WIN32_HAS_ANSI)
49407 OSVERSIONINFOA sInfo;
49408 sInfo.dwOSVersionInfoSize = sizeof(sInfo);
49409 osGetVersionExA(&sInfo);
@@ -49441,11 +49384,11 @@
49441
49442 winMemAssertMagic();
49443 hHeap = winMemGetHeap();
49444 assert( hHeap!=0 );
49445 assert( hHeap!=INVALID_HANDLE_VALUE );
49446 #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)
49447 assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );
49448 #endif
49449 assert( nBytes>=0 );
49450 p = osHeapAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, (SIZE_T)nBytes);
49451 if( !p ){
@@ -49463,11 +49406,11 @@
49463
49464 winMemAssertMagic();
49465 hHeap = winMemGetHeap();
49466 assert( hHeap!=0 );
49467 assert( hHeap!=INVALID_HANDLE_VALUE );
49468 #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)
49469 assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) );
49470 #endif
49471 if( !pPrior ) return; /* Passing NULL to HeapFree is undefined. */
49472 if( !osHeapFree(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ){
49473 sqlite3_log(SQLITE_NOMEM, "failed to HeapFree block %p (%lu), heap=%p",
@@ -49484,11 +49427,11 @@
49484
49485 winMemAssertMagic();
49486 hHeap = winMemGetHeap();
49487 assert( hHeap!=0 );
49488 assert( hHeap!=INVALID_HANDLE_VALUE );
49489 #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)
49490 assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) );
49491 #endif
49492 assert( nBytes>=0 );
49493 if( !pPrior ){
49494 p = osHeapAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, (SIZE_T)nBytes);
@@ -49512,11 +49455,11 @@
49512
49513 winMemAssertMagic();
49514 hHeap = winMemGetHeap();
49515 assert( hHeap!=0 );
49516 assert( hHeap!=INVALID_HANDLE_VALUE );
49517 #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)
49518 assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, p) );
49519 #endif
49520 if( !p ) return 0;
49521 n = osHeapSize(hHeap, SQLITE_WIN32_HEAP_FLAGS, p);
49522 if( n==(SIZE_T)-1 ){
@@ -49542,11 +49485,11 @@
49542
49543 if( !pWinMemData ) return SQLITE_ERROR;
49544 assert( pWinMemData->magic1==WINMEM_MAGIC1 );
49545 assert( pWinMemData->magic2==WINMEM_MAGIC2 );
49546
49547 #if !SQLITE_OS_WINRT && SQLITE_WIN32_HEAP_CREATE
49548 if( !pWinMemData->hHeap ){
49549 DWORD dwInitialSize = SQLITE_WIN32_HEAP_INIT_SIZE;
49550 DWORD dwMaximumSize = (DWORD)sqlite3GlobalConfig.nHeap;
49551 if( dwMaximumSize==0 ){
49552 dwMaximumSize = SQLITE_WIN32_HEAP_MAX_SIZE;
@@ -49575,11 +49518,11 @@
49575 pWinMemData->bOwned = FALSE;
49576 assert( !pWinMemData->bOwned );
49577 #endif
49578 assert( pWinMemData->hHeap!=0 );
49579 assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE );
49580 #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)
49581 assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );
49582 #endif
49583 return SQLITE_OK;
49584 }
49585
@@ -49593,11 +49536,11 @@
49593 assert( pWinMemData->magic1==WINMEM_MAGIC1 );
49594 assert( pWinMemData->magic2==WINMEM_MAGIC2 );
49595
49596 if( pWinMemData->hHeap ){
49597 assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE );
49598 #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)
49599 assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );
49600 #endif
49601 if( pWinMemData->bOwned ){
49602 if( !osHeapDestroy(pWinMemData->hHeap) ){
49603 sqlite3_log(SQLITE_NOMEM, "failed to HeapDestroy (%lu), heap=%p",
@@ -49974,21 +49917,10 @@
49974 */
49975 DWORD dwLen = 0;
49976 char *zOut = 0;
49977
49978 if( osIsNT() ){
49979 #if SQLITE_OS_WINRT
49980 WCHAR zTempWide[SQLITE_WIN32_MAX_ERRMSG_CHARS+1];
49981 dwLen = osFormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
49982 FORMAT_MESSAGE_IGNORE_INSERTS,
49983 NULL,
49984 lastErrno,
49985 0,
49986 zTempWide,
49987 SQLITE_WIN32_MAX_ERRMSG_CHARS,
49988 0);
49989 #else
49990 LPWSTR zTempWide = NULL;
49991 dwLen = osFormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
49992 FORMAT_MESSAGE_FROM_SYSTEM |
49993 FORMAT_MESSAGE_IGNORE_INSERTS,
49994 NULL,
@@ -49995,20 +49927,17 @@
49995 lastErrno,
49996 0,
49997 (LPWSTR) &zTempWide,
49998 0,
49999 0);
50000 #endif
50001 if( dwLen > 0 ){
50002 /* allocate a buffer and convert to UTF8 */
50003 sqlite3BeginBenignMalloc();
50004 zOut = winUnicodeToUtf8(zTempWide);
50005 sqlite3EndBenignMalloc();
50006 #if !SQLITE_OS_WINRT
50007 /* free the system buffer allocated by FormatMessage */
50008 osLocalFree(zTempWide);
50009 #endif
50010 }
50011 }
50012 #ifdef SQLITE_WIN32_HAS_ANSI
50013 else{
50014 char *zTemp = NULL;
@@ -50665,11 +50594,10 @@
50665 ** error code.
50666 */
50667 static int winHandleSeek(HANDLE h, sqlite3_int64 iOffset){
50668 int rc = SQLITE_OK; /* Return value */
50669
50670 #if !SQLITE_OS_WINRT
50671 LONG upperBits; /* Most sig. 32 bits of new offset */
50672 LONG lowerBits; /* Least sig. 32 bits of new offset */
50673 DWORD dwRet; /* Value returned by SetFilePointer() */
50674
50675 upperBits = (LONG)((iOffset>>32) & 0x7fffffff);
@@ -50687,24 +50615,11 @@
50687 DWORD lastErrno = osGetLastError();
50688 if( lastErrno!=NO_ERROR ){
50689 rc = SQLITE_IOERR_SEEK;
50690 }
50691 }
50692 #else
50693 /* This implementation works for WinRT. */
50694 LARGE_INTEGER x; /* The new offset */
50695 BOOL bRet; /* Value returned by SetFilePointerEx() */
50696
50697 x.QuadPart = iOffset;
50698 bRet = osSetFilePointerEx(h, x, 0, FILE_BEGIN);
50699
50700 if(!bRet){
50701 rc = SQLITE_IOERR_SEEK;
50702 }
50703 #endif
50704
50705 OSTRACE(("SEEK file=%p, offset=%lld rc=%s\n", h, iOffset, sqlite3ErrName(rc)));
50706 return rc;
50707 }
50708
50709 /*
50710 ** Move the current position of the file handle passed as the first
@@ -51001,32 +50916,19 @@
51001 ** Determine the size in bytes of the file opened by the handle passed as
51002 ** the first argument.
51003 */
51004 static int winHandleSize(HANDLE h, sqlite3_int64 *pnByte){
51005 int rc = SQLITE_OK;
51006
51007 #if SQLITE_OS_WINRT
51008 FILE_STANDARD_INFO info;
51009 BOOL b;
51010 b = osGetFileInformationByHandleEx(h, FileStandardInfo, &info, sizeof(info));
51011 if( b ){
51012 *pnByte = info.EndOfFile.QuadPart;
51013 }else{
51014 rc = SQLITE_IOERR_FSTAT;
51015 }
51016 #else
51017 DWORD upperBits = 0;
51018 DWORD lowerBits = 0;
51019
51020 assert( pnByte );
51021 lowerBits = osGetFileSize(h, &upperBits);
51022 *pnByte = (((sqlite3_int64)upperBits)<<32) + lowerBits;
51023 if( lowerBits==INVALID_FILE_SIZE && osGetLastError()!=NO_ERROR ){
51024 rc = SQLITE_IOERR_FSTAT;
51025 }
51026 #endif
51027
51028 return rc;
51029 }
51030
51031 /*
51032 ** Close the handle passed as the only argument.
@@ -51221,24 +51123,10 @@
51221
51222 assert( id!=0 );
51223 assert( pSize!=0 );
51224 SimulateIOError(return SQLITE_IOERR_FSTAT);
51225 OSTRACE(("SIZE file=%p, pSize=%p\n", pFile->h, pSize));
51226
51227 #if SQLITE_OS_WINRT
51228 {
51229 FILE_STANDARD_INFO info;
51230 if( osGetFileInformationByHandleEx(pFile->h, FileStandardInfo,
51231 &info, sizeof(info)) ){
51232 *pSize = info.EndOfFile.QuadPart;
51233 }else{
51234 pFile->lastErrno = osGetLastError();
51235 rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,
51236 "winFileSize", pFile->zPath);
51237 }
51238 }
51239 #else
51240 {
51241 DWORD upperBits;
51242 DWORD lowerBits;
51243 DWORD lastErrno;
51244
@@ -51249,11 +51137,10 @@
51249 pFile->lastErrno = lastErrno;
51250 rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,
51251 "winFileSize", pFile->zPath);
51252 }
51253 }
51254 #endif
51255 OSTRACE(("SIZE file=%p, pSize=%p, *pSize=%lld, rc=%s\n",
51256 pFile->h, pSize, *pSize, sqlite3ErrName(rc)));
51257 return rc;
51258 }
51259
@@ -52211,33 +52098,18 @@
52211
52212 /* TODO: platforms.
52213 ** TODO: retry-on-ioerr.
52214 */
52215 if( osIsNT() ){
52216 #if SQLITE_OS_WINRT
52217 CREATEFILE2_EXTENDED_PARAMETERS extendedParameters;
52218 memset(&extendedParameters, 0, sizeof(extendedParameters));
52219 extendedParameters.dwSize = sizeof(extendedParameters);
52220 extendedParameters.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
52221 extendedParameters.dwFileFlags = flag_overlapped;
52222 extendedParameters.dwSecurityQosFlags = SECURITY_ANONYMOUS;
52223 h = osCreateFile2((LPCWSTR)zConverted,
52224 (GENERIC_READ | (bReadonly ? 0 : GENERIC_WRITE)),/* dwDesiredAccess */
52225 FILE_SHARE_READ | FILE_SHARE_WRITE, /* dwShareMode */
52226 OPEN_ALWAYS, /* dwCreationDisposition */
52227 &extendedParameters
52228 );
52229 #else
52230 h = osCreateFileW((LPCWSTR)zConverted, /* lpFileName */
52231 (GENERIC_READ | (bReadonly ? 0 : GENERIC_WRITE)), /* dwDesiredAccess */
52232 FILE_SHARE_READ | FILE_SHARE_WRITE, /* dwShareMode */
52233 NULL, /* lpSecurityAttributes */
52234 OPEN_ALWAYS, /* dwCreationDisposition */
52235 FILE_ATTRIBUTE_NORMAL|flag_overlapped,
52236 NULL
52237 );
52238 #endif
52239 }else{
52240 /* Due to pre-processor directives earlier in this file,
52241 ** SQLITE_WIN32_HAS_ANSI is always defined if osIsNT() is false. */
52242 #ifdef SQLITE_WIN32_HAS_ANSI
52243 h = osCreateFileA((LPCSTR)zConverted,
@@ -52701,13 +52573,11 @@
52701
52702 while( pShmNode->nRegion<=iRegion ){
52703 HANDLE hMap = NULL; /* file-mapping handle */
52704 void *pMap = 0; /* Mapped memory region */
52705
52706 #if SQLITE_OS_WINRT
52707 hMap = osCreateFileMappingFromApp(hShared, NULL, protect, nByte, NULL);
52708 #elif defined(SQLITE_WIN32_HAS_WIDE)
52709 hMap = osCreateFileMappingW(hShared, NULL, protect, 0, nByte, NULL);
52710 #elif defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_CREATEFILEMAPPINGA
52711 hMap = osCreateFileMappingA(hShared, NULL, protect, 0, nByte, NULL);
52712 #endif
52713
@@ -52715,19 +52585,13 @@
52715 osGetCurrentProcessId(), pShmNode->nRegion, nByte,
52716 hMap ? "ok" : "failed"));
52717 if( hMap ){
52718 int iOffset = pShmNode->nRegion*szRegion;
52719 int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity;
52720 #if SQLITE_OS_WINRT
52721 pMap = osMapViewOfFileFromApp(hMap, flags,
52722 iOffset - iOffsetShift, szRegion + iOffsetShift
52723 );
52724 #else
52725 pMap = osMapViewOfFile(hMap, flags,
52726 0, iOffset - iOffsetShift, szRegion + iOffsetShift
52727 );
52728 #endif
52729 OSTRACE(("SHM-MAP-MAP pid=%lu, region=%d, offset=%d, size=%d, rc=%s\n",
52730 osGetCurrentProcessId(), pShmNode->nRegion, iOffset,
52731 szRegion, pMap ? "ok" : "failed"));
52732 }
52733 if( !pMap ){
@@ -52856,13 +52720,11 @@
52856 if( (pFd->ctrlFlags & WINFILE_RDONLY)==0 ){
52857 protect = PAGE_READWRITE;
52858 flags |= FILE_MAP_WRITE;
52859 }
52860 #endif
52861 #if SQLITE_OS_WINRT
52862 pFd->hMap = osCreateFileMappingFromApp(pFd->h, NULL, protect, nMap, NULL);
52863 #elif defined(SQLITE_WIN32_HAS_WIDE)
52864 pFd->hMap = osCreateFileMappingW(pFd->h, NULL, protect,
52865 (DWORD)((nMap>>32) & 0xffffffff),
52866 (DWORD)(nMap & 0xffffffff), NULL);
52867 #elif defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_CREATEFILEMAPPINGA
52868 pFd->hMap = osCreateFileMappingA(pFd->h, NULL, protect,
@@ -52878,15 +52740,11 @@
52878 osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
52879 return SQLITE_OK;
52880 }
52881 assert( (nMap % winSysInfo.dwPageSize)==0 );
52882 assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
52883 #if SQLITE_OS_WINRT
52884 pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);
52885 #else
52886 pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
52887 #endif
52888 if( pNew==NULL ){
52889 osCloseHandle(pFd->hMap);
52890 pFd->hMap = NULL;
52891 pFd->lastErrno = osGetLastError();
52892 rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
@@ -53217,11 +53075,10 @@
53217 }
53218 }
53219 }
53220 #endif
53221
53222 #if !SQLITE_OS_WINRT && defined(_WIN32)
53223 else if( osIsNT() ){
53224 char *zMulti;
53225 LPWSTR zWidePath = sqlite3MallocZero( nMax*sizeof(WCHAR) );
53226 if( !zWidePath ){
53227 sqlite3_free(zBuf);
@@ -53271,11 +53128,10 @@
53271 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
53272 return SQLITE_IOERR_NOMEM_BKPT;
53273 }
53274 }
53275 #endif /* SQLITE_WIN32_HAS_ANSI */
53276 #endif /* !SQLITE_OS_WINRT */
53277
53278 /*
53279 ** Check to make sure the temporary directory ends with an appropriate
53280 ** separator. If it does not and there is not enough space left to add
53281 ** one, fail.
@@ -53446,17 +53302,10 @@
53446
53447 assert( pFile!=0 );
53448 memset(pFile, 0, sizeof(winFile));
53449 pFile->h = INVALID_HANDLE_VALUE;
53450
53451 #if SQLITE_OS_WINRT
53452 if( !zUtf8Name && !sqlite3_temp_directory ){
53453 sqlite3_log(SQLITE_ERROR,
53454 "sqlite3_temp_directory variable should be set for WinRT");
53455 }
53456 #endif
53457
53458 /* If the second argument to this function is NULL, generate a
53459 ** temporary file name to use
53460 */
53461 if( !zUtf8Name ){
53462 assert( isDelete && !isOpenJournal );
@@ -53535,35 +53384,10 @@
53535 #if SQLITE_OS_WINCE
53536 dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
53537 #endif
53538
53539 if( osIsNT() ){
53540 #if SQLITE_OS_WINRT
53541 CREATEFILE2_EXTENDED_PARAMETERS extendedParameters;
53542 extendedParameters.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
53543 extendedParameters.dwFileAttributes =
53544 dwFlagsAndAttributes & FILE_ATTRIBUTE_MASK;
53545 extendedParameters.dwFileFlags = dwFlagsAndAttributes & FILE_FLAG_MASK;
53546 extendedParameters.dwSecurityQosFlags = SECURITY_ANONYMOUS;
53547 extendedParameters.lpSecurityAttributes = NULL;
53548 extendedParameters.hTemplateFile = NULL;
53549 do{
53550 h = osCreateFile2((LPCWSTR)zConverted,
53551 dwDesiredAccess,
53552 dwShareMode,
53553 dwCreationDisposition,
53554 &extendedParameters);
53555 if( h!=INVALID_HANDLE_VALUE ) break;
53556 if( isReadWrite ){
53557 int rc2;
53558 sqlite3BeginBenignMalloc();
53559 rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ|NORETRY, &isRO);
53560 sqlite3EndBenignMalloc();
53561 if( rc2==SQLITE_OK && isRO ) break;
53562 }
53563 }while( winRetryIoerr(&cnt, &lastErrno) );
53564 #else
53565 do{
53566 h = osCreateFileW((LPCWSTR)zConverted,
53567 dwDesiredAccess,
53568 dwShareMode, NULL,
53569 dwCreationDisposition,
@@ -53576,11 +53400,10 @@
53576 rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ|NORETRY, &isRO);
53577 sqlite3EndBenignMalloc();
53578 if( rc2==SQLITE_OK && isRO ) break;
53579 }
53580 }while( winRetryIoerr(&cnt, &lastErrno) );
53581 #endif
53582 }
53583 #ifdef SQLITE_WIN32_HAS_ANSI
53584 else{
53585 do{
53586 h = osCreateFileA((LPCSTR)zConverted,
@@ -53713,29 +53536,11 @@
53713 OSTRACE(("DELETE name=%s, rc=SQLITE_IOERR_NOMEM\n", zFilename));
53714 return SQLITE_IOERR_NOMEM_BKPT;
53715 }
53716 if( osIsNT() ){
53717 do {
53718 #if SQLITE_OS_WINRT
53719 WIN32_FILE_ATTRIBUTE_DATA sAttrData;
53720 memset(&sAttrData, 0, sizeof(sAttrData));
53721 if ( osGetFileAttributesExW(zConverted, GetFileExInfoStandard,
53722 &sAttrData) ){
53723 attr = sAttrData.dwFileAttributes;
53724 }else{
53725 lastErrno = osGetLastError();
53726 if( lastErrno==ERROR_FILE_NOT_FOUND
53727 || lastErrno==ERROR_PATH_NOT_FOUND ){
53728 rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */
53729 }else{
53730 rc = SQLITE_ERROR;
53731 }
53732 break;
53733 }
53734 #else
53735 attr = osGetFileAttributesW(zConverted);
53736 #endif
53737 if ( attr==INVALID_FILE_ATTRIBUTES ){
53738 lastErrno = osGetLastError();
53739 if( lastErrno==ERROR_FILE_NOT_FOUND
53740 || lastErrno==ERROR_PATH_NOT_FOUND ){
53741 rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */
@@ -54022,11 +53827,11 @@
54022 sqlite3_vfs *pVfs, /* Pointer to vfs object */
54023 const char *zRelative, /* Possibly relative input path */
54024 int nFull, /* Size of output buffer in bytes */
54025 char *zFull /* Output buffer */
54026 ){
54027 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
54028 int nByte;
54029 void *zConverted;
54030 char *zOut;
54031 #endif
54032
@@ -54111,11 +53916,11 @@
54111 return rc;
54112 }
54113 }
54114 #endif /* __CYGWIN__ */
54115
54116 #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && defined(_WIN32)
54117 SimulateIOError( return SQLITE_ERROR );
54118 /* WinCE has no concept of a relative pathname, or so I am told. */
54119 /* WinRT has no way to convert a relative path to an absolute one. */
54120 if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
54121 /*
@@ -54130,11 +53935,11 @@
54130 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative);
54131 }
54132 return SQLITE_OK;
54133 #endif
54134
54135 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
54136 #if defined(_WIN32)
54137 /* It's odd to simulate an io-error here, but really this is just
54138 ** using the io-error infrastructure to test that SQLite handles this
54139 ** function failing. This function could fail if, for example, the
54140 ** current working directory has been unlinked.
@@ -54262,15 +54067,11 @@
54262 if( zConverted==0 ){
54263 OSTRACE(("DLOPEN name=%s, handle=%p\n", zFilename, (void*)0));
54264 return 0;
54265 }
54266 if( osIsNT() ){
54267 #if SQLITE_OS_WINRT
54268 h = osLoadPackagedLibrary((LPCWSTR)zConverted, 0);
54269 #else
54270 h = osLoadLibraryW((LPCWSTR)zConverted);
54271 #endif
54272 }
54273 #ifdef SQLITE_WIN32_HAS_ANSI
54274 else{
54275 h = osLoadLibraryA((char*)zConverted);
54276 }
@@ -54348,37 +54149,30 @@
54348 }
54349 {
54350 DWORD pid = osGetCurrentProcessId();
54351 xorMemory(&e, (unsigned char*)&pid, sizeof(DWORD));
54352 }
54353 #if SQLITE_OS_WINRT
54354 {
54355 ULONGLONG cnt = osGetTickCount64();
54356 xorMemory(&e, (unsigned char*)&cnt, sizeof(ULONGLONG));
54357 }
54358 #else
54359 {
54360 DWORD cnt = osGetTickCount();
54361 xorMemory(&e, (unsigned char*)&cnt, sizeof(DWORD));
54362 }
54363 #endif /* SQLITE_OS_WINRT */
54364 {
54365 LARGE_INTEGER i;
54366 osQueryPerformanceCounter(&i);
54367 xorMemory(&e, (unsigned char*)&i, sizeof(LARGE_INTEGER));
54368 }
54369 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID
54370 {
54371 UUID id;
54372 memset(&id, 0, sizeof(UUID));
54373 osUuidCreate(&id);
54374 xorMemory(&e, (unsigned char*)&id, sizeof(UUID));
54375 memset(&id, 0, sizeof(UUID));
54376 osUuidCreateSequential(&id);
54377 xorMemory(&e, (unsigned char*)&id, sizeof(UUID));
54378 }
54379 #endif /* !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID */
54380 return e.nXor>nBuf ? nBuf : e.nXor;
54381 #endif /* defined(SQLITE_TEST) || defined(SQLITE_OMIT_RANDOMNESS) */
54382 }
54383
54384
@@ -54605,19 +54399,15 @@
54605 };
54606 #endif
54607
54608 /* Double-check that the aSyscall[] array has been constructed
54609 ** correctly. See ticket [bb3a86e890c8e96ab] */
54610 assert( ArraySize(aSyscall)==89 );
54611
54612 /* get memory map allocation granularity */
54613 memset(&winSysInfo, 0, sizeof(SYSTEM_INFO));
54614 #if SQLITE_OS_WINRT
54615 osGetNativeSystemInfo(&winSysInfo);
54616 #else
54617 osGetSystemInfo(&winSysInfo);
54618 #endif
54619 assert( winSysInfo.dwAllocationGranularity>0 );
54620 assert( winSysInfo.dwPageSize>0 );
54621
54622 sqlite3_vfs_register(&winVfs, 1);
54623
@@ -54637,21 +54427,13 @@
54637
54638 return SQLITE_OK;
54639 }
54640
54641 SQLITE_API int sqlite3_os_end(void){
54642 #if SQLITE_OS_WINRT
54643 if( sleepObj!=NULL ){
54644 osCloseHandle(sleepObj);
54645 sleepObj = NULL;
54646 }
54647 #endif
54648
54649 #ifndef SQLITE_OMIT_WAL
54650 winBigLock = 0;
54651 #endif
54652
54653 return SQLITE_OK;
54654 }
54655
54656 #endif /* SQLITE_OS_WIN */
54657
@@ -188384,15 +188166,16 @@
188384
188385 /* Initialize the output variables to -1 in case an error occurs. */
188386 if( pnLog ) *pnLog = -1;
188387 if( pnCkpt ) *pnCkpt = -1;
188388
 
188389 assert( SQLITE_CHECKPOINT_PASSIVE==0 );
188390 assert( SQLITE_CHECKPOINT_FULL==1 );
188391 assert( SQLITE_CHECKPOINT_RESTART==2 );
188392 assert( SQLITE_CHECKPOINT_TRUNCATE==3 );
188393 if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_TRUNCATE ){
188394 /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint
188395 ** mode: */
188396 return SQLITE_MISUSE_BKPT;
188397 }
188398
@@ -203418,11 +203201,12 @@
203418 PendingList *pList;
203419 int rc = SQLITE_OK;
203420
203421 pList = (PendingList *)fts3HashFind(pHash, zToken, nToken);
203422 if( pList ){
203423 assert( pList->nData+nToken+sizeof(Fts3HashElem) <= (i64)p->nPendingData );
 
203424 p->nPendingData -= (int)(pList->nData + nToken + sizeof(Fts3HashElem));
203425 }
203426 if( fts3PendingListAppend(&pList, p->iPrevDocid, iCol, iPos, &rc) ){
203427 if( pList==fts3HashInsert(pHash, zToken, nToken, pList) ){
203428 /* Malloc failed while inserting the new entry. This can only
@@ -225114,11 +224898,11 @@
225114 total += cnt;
225115 if( total>limit ){
225116 /* ERROR: copy exceeds output file size */
225117 return -1;
225118 }
225119 if( (int)(ofst+cnt) > lenSrc ){
225120 /* ERROR: copy extends past end of input */
225121 return -1;
225122 }
225123 memcpy(zOut, &zSrc[ofst], cnt);
225124 zOut += cnt;
@@ -259795,10 +259579,11 @@
259795 }
259796 }
259797 }
259798
259799 update_out:
 
259800 pTab->p.pConfig->pzErrmsg = 0;
259801 return rc;
259802 }
259803
259804 /*
@@ -261312,11 +261097,11 @@
261312 int nArg, /* Number of args */
261313 sqlite3_value **apUnused /* Function arguments */
261314 ){
261315 assert( nArg==0 );
261316 UNUSED_PARAM2(nArg, apUnused);
261317 sqlite3_result_text(pCtx, "fts5: 2025-12-06 11:54:43 b3da6a8728641a0c9ca2f3b20c9817c0a2be6c5bf05f020590547480d2aff0e0", -1, SQLITE_TRANSIENT);
261318 }
261319
261320 /*
261321 ** Implementation of fts5_locale(LOCALE, TEXT) function.
261322 **
261323
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** 01409738afc2c0d5bdaa248ffb508aa5f36a with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -467,14 +467,14 @@
467 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468 ** [sqlite_version()] and [sqlite_source_id()].
469 */
470 #define SQLITE_VERSION "3.52.0"
471 #define SQLITE_VERSION_NUMBER 3052000
472 #define SQLITE_SOURCE_ID "2025-12-11 23:24:05 01409738afc2c0d5bdaa248ffb508aa5f36a66390f6b8e4834734529ee8ed2fa"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS ""
475 #define SQLITE_SCM_DATETIME "2025-12-11T23:24:05.667Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -30650,18 +30650,10 @@
30650 # define SQLITE_OS_WINCE 1
30651 #else
30652 # define SQLITE_OS_WINCE 0
30653 #endif
30654
 
 
 
 
 
 
 
 
30655 /*
30656 ** For WinCE, some API function parameters do not appear to be declared as
30657 ** volatile.
30658 */
30659 #if SQLITE_OS_WINCE
@@ -30672,11 +30664,11 @@
30664
30665 /*
30666 ** For some Windows sub-platforms, the _beginthreadex() / _endthreadex()
30667 ** functions are not available (e.g. those not using MSVC, Cygwin, etc).
30668 */
30669 #if SQLITE_OS_WIN && !SQLITE_OS_WINCE && \
30670 SQLITE_THREADSAFE>0 && !defined(__CYGWIN__)
30671 # define SQLITE_OS_WIN_THREADS 1
30672 #else
30673 # define SQLITE_OS_WIN_THREADS 0
30674 #endif
@@ -30789,15 +30781,11 @@
30781 static int winMutexInit(void){
30782 /* The first to increment to 1 does actual initialization */
30783 if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){
30784 int i;
30785 for(i=0; i<ArraySize(winMutex_staticMutexes); i++){
 
 
 
30786 InitializeCriticalSection(&winMutex_staticMutexes[i].mutex);
 
30787 }
30788 winMutex_isInit = 1;
30789 }else{
30790 /* Another thread is (in the process of) initializing the static
30791 ** mutexes */
@@ -30883,15 +30871,11 @@
30871 #ifdef SQLITE_DEBUG
30872 #ifdef SQLITE_WIN32_MUTEX_TRACE_DYNAMIC
30873 p->trace = 1;
30874 #endif
30875 #endif
 
 
 
30876 InitializeCriticalSection(&p->mutex);
 
30877 }
30878 break;
30879 }
30880 default: {
30881 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -38300,11 +38284,11 @@
38284
38285 /*****************************************************************************
38286 ** Debugging logic
38287 */
38288
38289 /* SQLITE_KV_TRACE() is used for tracing calls to kvrecord routines. */
38290 #if 0
38291 #define SQLITE_KV_TRACE(X) printf X
38292 #else
38293 #define SQLITE_KV_TRACE(X)
38294 #endif
@@ -38314,18 +38298,22 @@
38298 #define SQLITE_KV_LOG(X) printf X
38299 #else
38300 #define SQLITE_KV_LOG(X)
38301 #endif
38302
 
38303 /*
38304 ** Forward declaration of objects used by this VFS implementation
38305 */
38306 typedef struct KVVfsFile KVVfsFile;
38307
38308 /* A single open file. There are only two files represented by this
38309 ** VFS - the database and the rollback journal.
38310 **
38311 ** Maintenance reminder: if this struct changes in any way, the JSON
38312 ** rendering of its structure must be updated in
38313 ** sqlite3-wasm.c:sqlite3__wasm_enum_json(). There are no binary
38314 ** compatibility concerns, so it does not need an iVersion member.
38315 */
38316 struct KVVfsFile {
38317 sqlite3_file base; /* IO methods */
38318 const char *zClass; /* Storage class */
38319 int isJournal; /* True if this is a journal file */
@@ -38371,11 +38359,11 @@
38359 static int kvvfsSleep(sqlite3_vfs*, int microseconds);
38360 static int kvvfsCurrentTime(sqlite3_vfs*, double*);
38361 static int kvvfsCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*);
38362
38363 static sqlite3_vfs sqlite3OsKvvfsObject = {
38364 2, /* iVersion */
38365 sizeof(KVVfsFile), /* szOsFile */
38366 1024, /* mxPathname */
38367 0, /* pNext */
38368 "kvvfs", /* zName */
38369 0, /* pAppData */
@@ -38447,42 +38435,56 @@
38435 #include <sys/stat.h>
38436 #include <unistd.h>
38437
38438 /* Forward declarations for the low-level storage engine
38439 */
38440 #ifndef SQLITE_WASM
38441 /* In WASM builds these are implemented in JS. */
38442 static int kvrecordWrite(const char*, const char *zKey, const char *zData);
38443 static int kvrecordDelete(const char*, const char *zKey);
38444 static int kvrecordRead(const char*, const char *zKey, char *zBuf, int nBuf);
38445 #endif
38446 #ifndef KVRECORD_KEY_SZ
38447 #define KVRECORD_KEY_SZ 32
38448 #endif
38449
38450 /* Expand the key name with an appropriate prefix and put the result
38451 ** in zKeyOut[]. The zKeyOut[] buffer is assumed to hold at least
38452 ** KVRECORD_KEY_SZ bytes.
38453 */
38454 static void kvrecordMakeKey(
38455 const char *zClass,
38456 const char *zKeyIn,
38457 char *zKeyOut
38458 ){
38459 assert( zKeyIn );
38460 assert( zKeyOut );
38461 assert( zClass );
38462 sqlite3_snprintf(KVRECORD_KEY_SZ, zKeyOut, "kvvfs-%s-%s",
38463 zClass, zKeyIn);
38464 }
38465
38466 #ifndef SQLITE_WASM
38467 /* In WASM builds do not define APIs which use fopen(), fwrite(),
38468 ** and the like because those APIs are a portability issue for
38469 ** WASM.
38470 */
38471 /* Write content into a key. zClass is the particular namespace of the
38472 ** underlying key/value store to use - either "local" or "session".
38473 **
38474 ** Both zKey and zData are zero-terminated pure text strings.
38475 **
38476 ** Return the number of errors.
38477 */
38478 static int kvrecordWrite(
38479 const char *zClass,
38480 const char *zKey,
38481 const char *zData
38482 ){
38483 FILE *fd;
38484 char zXKey[KVRECORD_KEY_SZ];
38485 kvrecordMakeKey(zClass, zKey, zXKey);
38486 fd = fopen(zXKey, "wb");
38487 if( fd ){
38488 SQLITE_KV_TRACE(("KVVFS-WRITE %-15s (%d) %.50s%s\n", zXKey,
38489 (int)strlen(zData), zData,
38490 strlen(zData)>50 ? "..." : ""));
@@ -38496,13 +38498,13 @@
38498
38499 /* Delete a key (with its corresponding data) from the key/value
38500 ** namespace given by zClass. If the key does not previously exist,
38501 ** this routine is a no-op.
38502 */
38503 static int kvrecordDelete(const char *zClass, const char *zKey){
38504 char zXKey[KVRECORD_KEY_SZ];
38505 kvrecordMakeKey(zClass, zKey, zXKey);
38506 unlink(zXKey);
38507 SQLITE_KV_TRACE(("KVVFS-DELETE %-15s\n", zXKey));
38508 return 0;
38509 }
38510
@@ -38519,20 +38521,20 @@
38521 ** If nBuf<=0 then this routine simply returns the size of the data
38522 ** without actually reading it. Similarly, if nBuf==1 then it
38523 ** zero-terminates zBuf at zBuf[0] and returns the size of the data
38524 ** without reading it.
38525 */
38526 static int kvrecordRead(
38527 const char *zClass,
38528 const char *zKey,
38529 char *zBuf,
38530 int nBuf
38531 ){
38532 FILE *fd;
38533 struct stat buf;
38534 char zXKey[KVRECORD_KEY_SZ];
38535 kvrecordMakeKey(zClass, zKey, zXKey);
38536 if( access(zXKey, R_OK)!=0
38537 || stat(zXKey, &buf)!=0
38538 || !S_ISREG(buf.st_mode)
38539 ){
38540 SQLITE_KV_TRACE(("KVVFS-READ %-15s (-1)\n", zXKey));
@@ -38560,27 +38562,39 @@
38562 SQLITE_KV_TRACE(("KVVFS-READ %-15s (%lld) %.50s%s\n", zXKey,
38563 n, zBuf, n>50 ? "..." : ""));
38564 return (int)n;
38565 }
38566 }
38567 #endif /* #ifndef SQLITE_WASM */
38568
38569
38570 /*
38571 ** An internal level of indirection which enables us to replace the
38572 ** kvvfs i/o methods with JavaScript implementations in WASM builds.
38573 ** Maintenance reminder: if this struct changes in any way, the JSON
38574 ** rendering of its structure must be updated in
38575 ** sqlite3-wasm.c:sqlite3__wasm_enum_json(). There are no binary
38576 ** compatibility concerns, so it does not need an iVersion member.
 
38577 */
38578 typedef struct sqlite3_kvvfs_methods sqlite3_kvvfs_methods;
38579 struct sqlite3_kvvfs_methods {
38580 int (*xRcrdRead)(const char*, const char *zKey, char *zBuf, int nBuf);
38581 int (*xRcrdWrite)(const char*, const char *zKey, const char *zData);
38582 int (*xRcrdDelete)(const char*, const char *zKey);
38583 const int nKeySize;
38584 const int nBufferSize;
38585 #ifndef SQLITE_WASM
38586 # define MAYBE_CONST const
38587 #else
38588 # define MAYBE_CONST
38589 #endif
38590 MAYBE_CONST sqlite3_vfs * pVfs;
38591 MAYBE_CONST sqlite3_io_methods *pIoDb;
38592 MAYBE_CONST sqlite3_io_methods *pIoJrnl;
38593 #undef MAYBE_CONST
38594 };
38595
38596
38597 /*
38598 ** This object holds the kvvfs I/O methods which may be swapped out
38599 ** for JavaScript-side implementations in WASM builds. In such builds
38600 ** it cannot be const, but in native builds it should be so that
@@ -38592,14 +38606,24 @@
38606 */
38607 #ifndef SQLITE_WASM
38608 const
38609 #endif
38610 SQLITE_PRIVATE sqlite3_kvvfs_methods sqlite3KvvfsMethods = {
38611 #ifndef SQLITE_WASM
38612 .xRcrdRead = kvrecordRead,
38613 .xRcrdWrite = kvrecordWrite,
38614 .xRcrdDelete = kvrecordDelete,
38615 #else
38616 .xRcrdRead = 0,
38617 .xRcrdWrite = 0,
38618 .xRcrdDelete = 0,
38619 #endif
38620 .nKeySize = KVRECORD_KEY_SZ,
38621 .nBufferSize = SQLITE_KVOS_SZ,
38622 .pVfs = &sqlite3OsKvvfsObject,
38623 .pIoDb = &kvvfs_db_io_methods,
38624 .pIoJrnl = &kvvfs_jrnl_io_methods
38625 };
38626
38627 /****** Utility subroutines ************************************************/
38628
38629 /*
@@ -38622,11 +38646,14 @@
38646 **
38647 ** * Because there is no overlap between the encoding characters
38648 ** of hexadecimal and base-26 numbers, it is always clear where
38649 ** one stops and the next begins.
38650 */
38651 #ifndef SQLITE_WASM
38652 static
38653 #endif
38654 int kvvfsEncode(const char *aData, int nData, char *aOut){
38655 int i, j;
38656 const unsigned char *a = (const unsigned char*)aData;
38657 for(i=j=0; i<nData; i++){
38658 unsigned char c = a[i];
38659 if( c!=0 ){
@@ -38673,13 +38700,17 @@
38700
38701 /*
38702 ** Decode the text encoding back to binary. The binary content is
38703 ** written into pOut, which must be at least nOut bytes in length.
38704 **
38705 ** The return value is the number of bytes actually written into aOut[], or
38706 ** -1 for malformed inputs.
38707 */
38708 #ifndef SQLITE_WASM
38709 static
38710 #endif
38711 int kvvfsDecode(const char *a, char *aOut, int nOut){
38712 int i, j;
38713 int c;
38714 const unsigned char *aIn = (const unsigned char*)a;
38715 i = 0;
38716 j = 0;
@@ -38700,11 +38731,11 @@
38731 j += n;
38732 if( c==0 || mult==1 ) break; /* progress stalled if mult==1 */
38733 }else{
38734 aOut[j] = c<<4;
38735 c = kvvfsHexValue[aIn[++i]];
38736 if( c<0 ) return -1 /* hex bytes are always in pairs */;
38737 aOut[j++] += c;
38738 i++;
38739 }
38740 }
38741 return j;
@@ -38753,17 +38784,18 @@
38784 ** Read or write the "sz" element, containing the database file size.
38785 */
38786 static sqlite3_int64 kvvfsReadFileSize(KVVfsFile *pFile){
38787 char zData[50];
38788 zData[0] = 0;
38789 sqlite3KvvfsMethods.xRcrdRead(pFile->zClass, "sz", zData,
38790 sizeof(zData)-1);
38791 return strtoll(zData, 0, 0);
38792 }
38793 static int kvvfsWriteFileSize(KVVfsFile *pFile, sqlite3_int64 sz){
38794 char zData[50];
38795 sqlite3_snprintf(sizeof(zData), zData, "%lld", sz);
38796 return sqlite3KvvfsMethods.xRcrdWrite(pFile->zClass, "sz", zData);
38797 }
38798
38799 /****** sqlite3_io_methods methods ******************************************/
38800
38801 /*
@@ -38774,10 +38806,13 @@
38806
38807 SQLITE_KV_LOG(("xClose %s %s\n", pFile->zClass,
38808 pFile->isJournal ? "journal" : "db"));
38809 sqlite3_free(pFile->aJrnl);
38810 sqlite3_free(pFile->aData);
38811 #ifdef SQLITE_WASM
38812 memset(pFile, 0, sizeof(*pFile));
38813 #endif
38814 return SQLITE_OK;
38815 }
38816
38817 /*
38818 ** Read from the -journal file.
@@ -38790,20 +38825,26 @@
38825 ){
38826 KVVfsFile *pFile = (KVVfsFile*)pProtoFile;
38827 assert( pFile->isJournal );
38828 SQLITE_KV_LOG(("xRead('%s-journal',%d,%lld)\n", pFile->zClass, iAmt, iOfst));
38829 if( pFile->aJrnl==0 ){
38830 int rc;
38831 int szTxt = sqlite3KvvfsMethods.xRcrdRead(pFile->zClass, "jrnl",
38832 0, 0);
38833 char *aTxt;
38834 if( szTxt<=4 ){
38835 return SQLITE_IOERR;
38836 }
38837 aTxt = sqlite3_malloc64( szTxt+1 );
38838 if( aTxt==0 ) return SQLITE_NOMEM;
38839 rc = sqlite3KvvfsMethods.xRcrdRead(pFile->zClass, "jrnl",
38840 aTxt, szTxt+1);
38841 if( rc>=0 ){
38842 kvvfsDecodeJournal(pFile, aTxt, szTxt);
38843 }
38844 sqlite3_free(aTxt);
38845 if( rc ) return rc;
38846 if( pFile->aJrnl==0 ) return SQLITE_IOERR;
38847 }
38848 if( iOfst+iAmt>pFile->nJrnl ){
38849 return SQLITE_IOERR_SHORT_READ;
38850 }
@@ -38839,12 +38880,12 @@
38880 pgno = 1 + iOfst/iAmt;
38881 }else{
38882 pgno = 1;
38883 }
38884 sqlite3_snprintf(sizeof(zKey), zKey, "%u", pgno);
38885 got = sqlite3KvvfsMethods.xRcrdRead(pFile->zClass, zKey,
38886 aData, SQLITE_KVOS_SZ-1);
38887 if( got<0 ){
38888 n = 0;
38889 }else{
38890 aData[got] = 0;
38891 if( iOfst+iAmt<512 ){
@@ -38908,35 +38949,36 @@
38949 ){
38950 KVVfsFile *pFile = (KVVfsFile*)pProtoFile;
38951 unsigned int pgno;
38952 char zKey[30];
38953 char *aData = pFile->aData;
38954 int rc;
38955 SQLITE_KV_LOG(("xWrite('%s-db',%d,%lld)\n", pFile->zClass, iAmt, iOfst));
38956 assert( iAmt>=512 && iAmt<=65536 );
38957 assert( (iAmt & (iAmt-1))==0 );
38958 assert( pFile->szPage<0 || pFile->szPage==iAmt );
38959 pFile->szPage = iAmt;
38960 pgno = 1 + iOfst/iAmt;
38961 sqlite3_snprintf(sizeof(zKey), zKey, "%u", pgno);
38962 kvvfsEncode(zBuf, iAmt, aData);
38963 rc = sqlite3KvvfsMethods.xRcrdWrite(pFile->zClass, zKey, aData);
38964 if( 0==rc ){
38965 if( iOfst+iAmt > pFile->szDb ){
38966 pFile->szDb = iOfst + iAmt;
38967 }
38968 }
38969 return rc;
 
 
 
38970 }
38971
38972 /*
38973 ** Truncate an kvvfs-file.
38974 */
38975 static int kvvfsTruncateJrnl(sqlite3_file *pProtoFile, sqlite_int64 size){
38976 KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
38977 SQLITE_KV_LOG(("xTruncate('%s-journal',%lld)\n", pFile->zClass, size));
38978 assert( size==0 );
38979 sqlite3KvvfsMethods.xRcrdDelete(pFile->zClass, "jrnl");
38980 sqlite3_free(pFile->aJrnl);
38981 pFile->aJrnl = 0;
38982 pFile->nJrnl = 0;
38983 return SQLITE_OK;
38984 }
@@ -38951,11 +38993,11 @@
38993 SQLITE_KV_LOG(("xTruncate('%s-db',%lld)\n", pFile->zClass, size));
38994 pgno = 1 + size/pFile->szPage;
38995 pgnoMax = 2 + pFile->szDb/pFile->szPage;
38996 while( pgno<=pgnoMax ){
38997 sqlite3_snprintf(sizeof(zKey), zKey, "%u", pgno);
38998 sqlite3KvvfsMethods.xRcrdDelete(pFile->zClass, zKey);
38999 pgno++;
39000 }
39001 pFile->szDb = size;
39002 return kvvfsWriteFileSize(pFile, size) ? SQLITE_IOERR : SQLITE_OK;
39003 }
@@ -38983,11 +39025,11 @@
39025 zOut[i++] = 'a' + (n%26);
39026 n /= 26;
39027 }while( n>0 );
39028 zOut[i++] = ' ';
39029 kvvfsEncode(pFile->aJrnl, pFile->nJrnl, &zOut[i]);
39030 i = sqlite3KvvfsMethods.xRcrdWrite(pFile->zClass, "jrnl", zOut);
39031 sqlite3_free(zOut);
39032 return i ? SQLITE_IOERR : SQLITE_OK;
39033 }
39034 static int kvvfsSyncDb(sqlite3_file *pProtoFile, int flags){
39035 return SQLITE_OK;
@@ -39097,53 +39139,56 @@
39139 int *pOutFlags
39140 ){
39141 KVVfsFile *pFile = (KVVfsFile*)pProtoFile;
39142 if( zName==0 ) zName = "";
39143 SQLITE_KV_LOG(("xOpen(\"%s\")\n", zName));
39144 assert(!pFile->zClass);
39145 assert(!pFile->aData);
39146 assert(!pFile->aJrnl);
39147 assert(!pFile->nJrnl);
39148 assert(!pFile->base.pMethods);
39149 pFile->szPage = -1;
39150 pFile->szDb = -1;
39151 if( 0==sqlite3_strglob("*-journal", zName) ){
 
39152 pFile->isJournal = 1;
39153 pFile->base.pMethods = &kvvfs_jrnl_io_methods;
39154 if( 0==strcmp("session-journal",zName) ){
39155 pFile->zClass = "session";
39156 }else if( 0==strcmp("local-journal",zName) ){
39157 pFile->zClass = "local";
39158 }
39159 }else{
39160 pFile->isJournal = 0;
39161 pFile->base.pMethods = &kvvfs_db_io_methods;
39162 }
39163 if( !pFile->zClass ){
39164 pFile->zClass = zName;
 
 
39165 }
39166 pFile->aData = sqlite3_malloc64(SQLITE_KVOS_SZ);
39167 if( pFile->aData==0 ){
39168 return SQLITE_NOMEM;
39169 }
 
 
 
 
39170 return SQLITE_OK;
39171 }
39172
39173 /*
39174 ** Delete the file located at zPath. If the dirSync argument is true,
39175 ** ensure the file-system modifications are synced to disk before
39176 ** returning.
39177 */
39178 static int kvvfsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
39179 int rc /* The JS impl can fail with OOM in argument conversion */;
39180 if( strcmp(zPath, "local-journal")==0 ){
39181 rc = sqlite3KvvfsMethods.xRcrdDelete("local", "jrnl");
39182 }else
39183 if( strcmp(zPath, "session-journal")==0 ){
39184 rc = sqlite3KvvfsMethods.xRcrdDelete("session", "jrnl");
39185 }
39186 else{
39187 rc = 0;
39188 }
39189 return rc;
39190 }
39191
39192 /*
39193 ** Test for access permissions. Return true if the requested permission
39194 ** is available, or false otherwise.
@@ -39153,25 +39198,46 @@
39198 const char *zPath,
39199 int flags,
39200 int *pResOut
39201 ){
39202 SQLITE_KV_LOG(("xAccess(\"%s\")\n", zPath));
39203 #if 0 && defined(SQLITE_WASM)
39204 /*
39205 ** This is not having the desired effect in the JS bindings.
39206 ** It's ostensibly the same logic as the #else block, but
39207 ** it's not behaving that way.
39208 **
39209 ** In JS we map all zPaths to Storage objects, and -journal files
39210 ** are mapped to the storage for the main db (which is is exactly
39211 ** what the mapping of "local-journal" -> "local" is doing).
39212 */
39213 const char *zKey = (0==sqlite3_strglob("*-journal", zPath))
39214 ? "jrnl" : "sz";
39215 *pResOut =
39216 sqlite3KvvfsMethods.xRcrdRead(zPath, zKey, 0, 0)>0;
39217 #else
39218 if( strcmp(zPath, "local-journal")==0 ){
39219 *pResOut =
39220 sqlite3KvvfsMethods.xRcrdRead("local", "jrnl", 0, 0)>0;
39221 }else
39222 if( strcmp(zPath, "session-journal")==0 ){
39223 *pResOut =
39224 sqlite3KvvfsMethods.xRcrdRead("session", "jrnl", 0, 0)>0;
39225 }else
39226 if( strcmp(zPath, "local")==0 ){
39227 *pResOut =
39228 sqlite3KvvfsMethods.xRcrdRead("local", "sz", 0, 0)>0;
39229 }else
39230 if( strcmp(zPath, "session")==0 ){
39231 *pResOut =
39232 sqlite3KvvfsMethods.xRcrdRead("session", "sz", 0, 0)>0;
39233 }else
39234 {
39235 *pResOut = 0;
39236 }
39237 /*all current JS tests avoid triggering: assert( *pResOut == 0 ); */
39238 #endif
39239 SQLITE_KV_LOG(("xAccess returns %d\n",*pResOut));
39240 return SQLITE_OK;
39241 }
39242
39243 /*
@@ -47896,19 +47962,19 @@
47962
47963 /*
47964 ** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
47965 ** based on the sub-platform)?
47966 */
47967 #if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_ANSI)
47968 # define SQLITE_WIN32_HAS_ANSI
47969 #endif
47970
47971 /*
47972 ** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
47973 ** based on the sub-platform)?
47974 */
47975 #if (SQLITE_OS_WINCE || SQLITE_OS_WINNT) && \
47976 !defined(SQLITE_WIN32_NO_WIDE)
47977 # define SQLITE_WIN32_HAS_WIDE
47978 #endif
47979
47980 /*
@@ -48043,20 +48109,11 @@
48109 ** mode or memory mapped files (e.g. these APIs are available in the Windows
48110 ** CE SDK; however, they are not present in the header file)?
48111 */
48112 #if SQLITE_WIN32_FILEMAPPING_API && \
48113 (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
48114
 
 
 
 
 
 
 
 
 
48115 #if defined(SQLITE_WIN32_HAS_ANSI)
48116 WINBASEAPI HANDLE WINAPI CreateFileMappingA(HANDLE, LPSECURITY_ATTRIBUTES, \
48117 DWORD, DWORD, DWORD, LPCSTR);
48118 #endif /* defined(SQLITE_WIN32_HAS_ANSI) */
48119
@@ -48064,11 +48121,10 @@
48121 WINBASEAPI HANDLE WINAPI CreateFileMappingW(HANDLE, LPSECURITY_ATTRIBUTES, \
48122 DWORD, DWORD, DWORD, LPCWSTR);
48123 #endif /* defined(SQLITE_WIN32_HAS_WIDE) */
48124
48125 WINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T);
 
48126
48127 /*
48128 ** These file mapping APIs are common to both Win32 and WinRT.
48129 */
48130
@@ -48355,11 +48411,11 @@
48411
48412 /*
48413 ** This function is not available on Windows CE or WinRT.
48414 */
48415
48416 #if SQLITE_OS_WINCE
48417 # define osAreFileApisANSI() 1
48418 #endif
48419
48420 /*
48421 ** Many system calls are accessed through pointer-to-functions so that
@@ -48370,11 +48426,11 @@
48426 static struct win_syscall {
48427 const char *zName; /* Name of the system call */
48428 sqlite3_syscall_ptr pCurrent; /* Current value of the system call */
48429 sqlite3_syscall_ptr pDefault; /* Default value */
48430 } aSyscall[] = {
48431 #if !SQLITE_OS_WINCE
48432 { "AreFileApisANSI", (SYSCALL)AreFileApisANSI, 0 },
48433 #else
48434 { "AreFileApisANSI", (SYSCALL)0, 0 },
48435 #endif
48436
@@ -48409,20 +48465,20 @@
48465 #endif
48466
48467 #define osCreateFileA ((HANDLE(WINAPI*)(LPCSTR,DWORD,DWORD, \
48468 LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[4].pCurrent)
48469
48470 #if defined(SQLITE_WIN32_HAS_WIDE)
48471 { "CreateFileW", (SYSCALL)CreateFileW, 0 },
48472 #else
48473 { "CreateFileW", (SYSCALL)0, 0 },
48474 #endif
48475
48476 #define osCreateFileW ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD, \
48477 LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[5].pCurrent)
48478
48479 #if defined(SQLITE_WIN32_HAS_ANSI) && \
48480 (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) && \
48481 SQLITE_WIN32_CREATEFILEMAPPINGA
48482 { "CreateFileMappingA", (SYSCALL)CreateFileMappingA, 0 },
48483 #else
48484 { "CreateFileMappingA", (SYSCALL)0, 0 },
@@ -48429,21 +48485,21 @@
48485 #endif
48486
48487 #define osCreateFileMappingA ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \
48488 DWORD,DWORD,DWORD,LPCSTR))aSyscall[6].pCurrent)
48489
48490 #if (SQLITE_OS_WINCE || defined(SQLITE_WIN32_HAS_WIDE)) && \
48491 (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
48492 { "CreateFileMappingW", (SYSCALL)CreateFileMappingW, 0 },
48493 #else
48494 { "CreateFileMappingW", (SYSCALL)0, 0 },
48495 #endif
48496
48497 #define osCreateFileMappingW ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \
48498 DWORD,DWORD,DWORD,LPCWSTR))aSyscall[7].pCurrent)
48499
48500 #if defined(SQLITE_WIN32_HAS_WIDE)
48501 { "CreateMutexW", (SYSCALL)CreateMutexW, 0 },
48502 #else
48503 { "CreateMutexW", (SYSCALL)0, 0 },
48504 #endif
48505
@@ -48525,11 +48581,11 @@
48581 #endif
48582
48583 #define osGetDiskFreeSpaceA ((BOOL(WINAPI*)(LPCSTR,LPDWORD,LPDWORD,LPDWORD, \
48584 LPDWORD))aSyscall[18].pCurrent)
48585
48586 #if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE)
48587 { "GetDiskFreeSpaceW", (SYSCALL)GetDiskFreeSpaceW, 0 },
48588 #else
48589 { "GetDiskFreeSpaceW", (SYSCALL)0, 0 },
48590 #endif
48591
@@ -48542,11 +48598,11 @@
48598 { "GetFileAttributesA", (SYSCALL)0, 0 },
48599 #endif
48600
48601 #define osGetFileAttributesA ((DWORD(WINAPI*)(LPCSTR))aSyscall[20].pCurrent)
48602
48603 #if defined(SQLITE_WIN32_HAS_WIDE)
48604 { "GetFileAttributesW", (SYSCALL)GetFileAttributesW, 0 },
48605 #else
48606 { "GetFileAttributesW", (SYSCALL)0, 0 },
48607 #endif
48608
@@ -48559,15 +48615,11 @@
48615 #endif
48616
48617 #define osGetFileAttributesExW ((BOOL(WINAPI*)(LPCWSTR,GET_FILEEX_INFO_LEVELS, \
48618 LPVOID))aSyscall[22].pCurrent)
48619
 
48620 { "GetFileSize", (SYSCALL)GetFileSize, 0 },
 
 
 
48621
48622 #define osGetFileSize ((DWORD(WINAPI*)(HANDLE,LPDWORD))aSyscall[23].pCurrent)
48623
48624 #if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_ANSI)
48625 { "GetFullPathNameA", (SYSCALL)GetFullPathNameA, 0 },
@@ -48576,11 +48628,11 @@
48628 #endif
48629
48630 #define osGetFullPathNameA ((DWORD(WINAPI*)(LPCSTR,DWORD,LPSTR, \
48631 LPSTR*))aSyscall[24].pCurrent)
48632
48633 #if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE)
48634 { "GetFullPathNameW", (SYSCALL)GetFullPathNameW, 0 },
48635 #else
48636 { "GetFullPathNameW", (SYSCALL)0, 0 },
48637 #endif
48638
@@ -48611,20 +48663,14 @@
48663 #endif
48664
48665 #define osGetProcAddressA ((FARPROC(WINAPI*)(HMODULE, \
48666 LPCSTR))aSyscall[27].pCurrent)
48667
 
48668 { "GetSystemInfo", (SYSCALL)GetSystemInfo, 0 },
 
 
 
 
48669 #define osGetSystemInfo ((VOID(WINAPI*)(LPSYSTEM_INFO))aSyscall[28].pCurrent)
48670
48671 { "GetSystemTime", (SYSCALL)GetSystemTime, 0 },
 
48672 #define osGetSystemTime ((VOID(WINAPI*)(LPSYSTEMTIME))aSyscall[29].pCurrent)
48673
48674 #if !SQLITE_OS_WINCE
48675 { "GetSystemTimeAsFileTime", (SYSCALL)GetSystemTimeAsFileTime, 0 },
48676 #else
@@ -48640,23 +48686,19 @@
48686 { "GetTempPathA", (SYSCALL)0, 0 },
48687 #endif
48688
48689 #define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent)
48690
48691 #if defined(SQLITE_WIN32_HAS_WIDE)
48692 { "GetTempPathW", (SYSCALL)GetTempPathW, 0 },
48693 #else
48694 { "GetTempPathW", (SYSCALL)0, 0 },
48695 #endif
48696
48697 #define osGetTempPathW ((DWORD(WINAPI*)(DWORD,LPWSTR))aSyscall[32].pCurrent)
48698
 
48699 { "GetTickCount", (SYSCALL)GetTickCount, 0 },
 
 
 
48700
48701 #define osGetTickCount ((DWORD(WINAPI*)(VOID))aSyscall[33].pCurrent)
48702
48703 #if defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_GETVERSIONEX
48704 { "GetVersionExA", (SYSCALL)GetVersionExA, 0 },
@@ -48665,11 +48707,11 @@
48707 #endif
48708
48709 #define osGetVersionExA ((BOOL(WINAPI*)( \
48710 LPOSVERSIONINFOA))aSyscall[34].pCurrent)
48711
48712 #if defined(SQLITE_WIN32_HAS_WIDE) && \
48713 SQLITE_WIN32_GETVERSIONEX
48714 { "GetVersionExW", (SYSCALL)GetVersionExW, 0 },
48715 #else
48716 { "GetVersionExW", (SYSCALL)0, 0 },
48717 #endif
@@ -48680,24 +48722,16 @@
48722 { "HeapAlloc", (SYSCALL)HeapAlloc, 0 },
48723
48724 #define osHeapAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD, \
48725 SIZE_T))aSyscall[36].pCurrent)
48726
 
48727 { "HeapCreate", (SYSCALL)HeapCreate, 0 },
 
 
 
48728
48729 #define osHeapCreate ((HANDLE(WINAPI*)(DWORD,SIZE_T, \
48730 SIZE_T))aSyscall[37].pCurrent)
48731
 
48732 { "HeapDestroy", (SYSCALL)HeapDestroy, 0 },
 
 
 
48733
48734 #define osHeapDestroy ((BOOL(WINAPI*)(HANDLE))aSyscall[38].pCurrent)
48735
48736 { "HeapFree", (SYSCALL)HeapFree, 0 },
48737
@@ -48711,20 +48745,16 @@
48745 { "HeapSize", (SYSCALL)HeapSize, 0 },
48746
48747 #define osHeapSize ((SIZE_T(WINAPI*)(HANDLE,DWORD, \
48748 LPCVOID))aSyscall[41].pCurrent)
48749
 
48750 { "HeapValidate", (SYSCALL)HeapValidate, 0 },
 
 
 
48751
48752 #define osHeapValidate ((BOOL(WINAPI*)(HANDLE,DWORD, \
48753 LPCVOID))aSyscall[42].pCurrent)
48754
48755 #if !SQLITE_OS_WINCE
48756 { "HeapCompact", (SYSCALL)HeapCompact, 0 },
48757 #else
48758 { "HeapCompact", (SYSCALL)0, 0 },
48759 #endif
48760
@@ -48736,28 +48766,24 @@
48766 { "LoadLibraryA", (SYSCALL)0, 0 },
48767 #endif
48768
48769 #define osLoadLibraryA ((HMODULE(WINAPI*)(LPCSTR))aSyscall[44].pCurrent)
48770
48771 #if defined(SQLITE_WIN32_HAS_WIDE) && \
48772 !defined(SQLITE_OMIT_LOAD_EXTENSION)
48773 { "LoadLibraryW", (SYSCALL)LoadLibraryW, 0 },
48774 #else
48775 { "LoadLibraryW", (SYSCALL)0, 0 },
48776 #endif
48777
48778 #define osLoadLibraryW ((HMODULE(WINAPI*)(LPCWSTR))aSyscall[45].pCurrent)
48779
 
48780 { "LocalFree", (SYSCALL)LocalFree, 0 },
 
 
 
48781
48782 #define osLocalFree ((HLOCAL(WINAPI*)(HLOCAL))aSyscall[46].pCurrent)
48783
48784 #if !SQLITE_OS_WINCE
48785 { "LockFile", (SYSCALL)LockFile, 0 },
48786 #else
48787 { "LockFile", (SYSCALL)0, 0 },
48788 #endif
48789
@@ -48775,12 +48801,11 @@
48801 #ifndef osLockFileEx
48802 #define osLockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,DWORD, \
48803 LPOVERLAPPED))aSyscall[48].pCurrent)
48804 #endif
48805
48806 #if SQLITE_OS_WINCE || !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
 
48807 { "MapViewOfFile", (SYSCALL)MapViewOfFile, 0 },
48808 #else
48809 { "MapViewOfFile", (SYSCALL)0, 0 },
48810 #endif
48811
@@ -48804,33 +48829,25 @@
48829
48830 { "SetEndOfFile", (SYSCALL)SetEndOfFile, 0 },
48831
48832 #define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[53].pCurrent)
48833
 
48834 { "SetFilePointer", (SYSCALL)SetFilePointer, 0 },
 
 
 
48835
48836 #define osSetFilePointer ((DWORD(WINAPI*)(HANDLE,LONG,PLONG, \
48837 DWORD))aSyscall[54].pCurrent)
48838
 
48839 { "Sleep", (SYSCALL)Sleep, 0 },
 
 
 
48840
48841 #define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[55].pCurrent)
48842
48843 { "SystemTimeToFileTime", (SYSCALL)SystemTimeToFileTime, 0 },
48844
48845 #define osSystemTimeToFileTime ((BOOL(WINAPI*)(const SYSTEMTIME*, \
48846 LPFILETIME))aSyscall[56].pCurrent)
48847
48848 #if !SQLITE_OS_WINCE
48849 { "UnlockFile", (SYSCALL)UnlockFile, 0 },
48850 #else
48851 { "UnlockFile", (SYSCALL)0, 0 },
48852 #endif
48853
@@ -48864,15 +48881,11 @@
48881 { "WriteFile", (SYSCALL)WriteFile, 0 },
48882
48883 #define osWriteFile ((BOOL(WINAPI*)(HANDLE,LPCVOID,DWORD,LPDWORD, \
48884 LPOVERLAPPED))aSyscall[61].pCurrent)
48885
 
48886 { "CreateEventExW", (SYSCALL)CreateEventExW, 0 },
 
 
 
48887
48888 #define osCreateEventExW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,LPCWSTR, \
48889 DWORD,DWORD))aSyscall[62].pCurrent)
48890
48891 /*
@@ -48893,68 +48906,30 @@
48906 #endif
48907
48908 #define osWaitForSingleObjectEx ((DWORD(WINAPI*)(HANDLE,DWORD, \
48909 BOOL))aSyscall[64].pCurrent)
48910
 
48911 { "SetFilePointerEx", (SYSCALL)SetFilePointerEx, 0 },
 
 
 
48912
48913 #define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \
48914 PLARGE_INTEGER,DWORD))aSyscall[65].pCurrent)
48915
 
48916 { "GetFileInformationByHandleEx", (SYSCALL)GetFileInformationByHandleEx, 0 },
 
 
 
48917
48918 #define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \
48919 FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[66].pCurrent)
48920
 
 
 
 
 
 
 
 
 
 
48921 { "CreateFile2", (SYSCALL)CreateFile2, 0 },
 
 
 
48922
48923 #define osCreateFile2 ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD,DWORD, \
48924 LPCREATEFILE2_EXTENDED_PARAMETERS))aSyscall[68].pCurrent)
48925
 
 
 
 
 
 
 
 
 
 
48926 { "GetTickCount64", (SYSCALL)GetTickCount64, 0 },
 
 
 
48927
48928 #define osGetTickCount64 ((ULONGLONG(WINAPI*)(VOID))aSyscall[70].pCurrent)
48929
 
48930 { "GetNativeSystemInfo", (SYSCALL)GetNativeSystemInfo, 0 },
 
 
 
48931
48932 #define osGetNativeSystemInfo ((VOID(WINAPI*)( \
48933 LPSYSTEM_INFO))aSyscall[71].pCurrent)
48934
48935 #if defined(SQLITE_WIN32_HAS_ANSI)
@@ -48975,19 +48950,10 @@
48950
48951 { "GetProcessHeap", (SYSCALL)GetProcessHeap, 0 },
48952
48953 #define osGetProcessHeap ((HANDLE(WINAPI*)(VOID))aSyscall[74].pCurrent)
48954
 
 
 
 
 
 
 
 
 
48955 /*
48956 ** NOTE: On some sub-platforms, the InterlockedCompareExchange "function"
48957 ** is really just a macro that uses a compiler intrinsic (e.g. x64).
48958 ** So do not try to make this is into a redefinable interface.
48959 */
@@ -49000,19 +48966,19 @@
48966
48967 #define osInterlockedCompareExchange ((LONG(WINAPI*)(LONG \
48968 SQLITE_WIN32_VOLATILE*, LONG,LONG))aSyscall[76].pCurrent)
48969 #endif /* defined(InterlockedCompareExchange) */
48970
48971 #if !SQLITE_OS_WINCE && SQLITE_WIN32_USE_UUID
48972 { "UuidCreate", (SYSCALL)UuidCreate, 0 },
48973 #else
48974 { "UuidCreate", (SYSCALL)0, 0 },
48975 #endif
48976
48977 #define osUuidCreate ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[77].pCurrent)
48978
48979 #if !SQLITE_OS_WINCE && SQLITE_WIN32_USE_UUID
48980 { "UuidCreateSequential", (SYSCALL)UuidCreateSequential, 0 },
48981 #else
48982 { "UuidCreateSequential", (SYSCALL)0, 0 },
48983 #endif
48984
@@ -49219,14 +49185,14 @@
49185
49186 winMemAssertMagic();
49187 hHeap = winMemGetHeap();
49188 assert( hHeap!=0 );
49189 assert( hHeap!=INVALID_HANDLE_VALUE );
49190 #if defined(SQLITE_WIN32_MALLOC_VALIDATE)
49191 assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );
49192 #endif
49193 #if !SQLITE_OS_WINCE
49194 if( (nLargest=osHeapCompact(hHeap, SQLITE_WIN32_HEAP_FLAGS))==0 ){
49195 DWORD lastErrno = osGetLastError();
49196 if( lastErrno==NO_ERROR ){
49197 sqlite3_log(SQLITE_NOMEM, "failed to HeapCompact (no space), heap=%p",
49198 (void*)hHeap);
@@ -49335,32 +49301,15 @@
49301 }
49302 #endif
49303 }
49304 #endif /* _WIN32 */
49305
 
 
 
 
 
 
 
 
49306 SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds){
 
 
 
 
 
 
 
 
49307 osSleep(milliseconds);
 
49308 }
49309
49310 #if SQLITE_MAX_WORKER_THREADS>0 && !SQLITE_OS_WINCE && \
49311 SQLITE_THREADSAFE>0
49312 SQLITE_PRIVATE DWORD sqlite3Win32Wait(HANDLE hObject){
49313 DWORD rc;
49314 while( (rc = osWaitForSingleObjectEx(hObject, INFINITE,
49315 TRUE))==WAIT_IO_COMPLETION ){}
@@ -49380,11 +49329,11 @@
49329 ** the LockFileEx() API.
49330 */
49331
49332 #if !SQLITE_WIN32_GETVERSIONEX
49333 # define osIsNT() (1)
49334 #elif SQLITE_OS_WINCE || !defined(SQLITE_WIN32_HAS_ANSI)
49335 # define osIsNT() (1)
49336 #elif !defined(SQLITE_WIN32_HAS_WIDE)
49337 # define osIsNT() (0)
49338 #else
49339 # define osIsNT() ((sqlite3_os_type==2) || sqlite3_win32_is_nt())
@@ -49393,17 +49342,11 @@
49342 /*
49343 ** This function determines if the machine is running a version of Windows
49344 ** based on the NT kernel.
49345 */
49346 SQLITE_API int sqlite3_win32_is_nt(void){
49347 #if SQLITE_WIN32_GETVERSIONEX
 
 
 
 
 
 
49348 if( osInterlockedCompareExchange(&sqlite3_os_type, 0, 0)==0 ){
49349 #if defined(SQLITE_WIN32_HAS_ANSI)
49350 OSVERSIONINFOA sInfo;
49351 sInfo.dwOSVersionInfoSize = sizeof(sInfo);
49352 osGetVersionExA(&sInfo);
@@ -49441,11 +49384,11 @@
49384
49385 winMemAssertMagic();
49386 hHeap = winMemGetHeap();
49387 assert( hHeap!=0 );
49388 assert( hHeap!=INVALID_HANDLE_VALUE );
49389 #if defined(SQLITE_WIN32_MALLOC_VALIDATE)
49390 assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );
49391 #endif
49392 assert( nBytes>=0 );
49393 p = osHeapAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, (SIZE_T)nBytes);
49394 if( !p ){
@@ -49463,11 +49406,11 @@
49406
49407 winMemAssertMagic();
49408 hHeap = winMemGetHeap();
49409 assert( hHeap!=0 );
49410 assert( hHeap!=INVALID_HANDLE_VALUE );
49411 #if defined(SQLITE_WIN32_MALLOC_VALIDATE)
49412 assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) );
49413 #endif
49414 if( !pPrior ) return; /* Passing NULL to HeapFree is undefined. */
49415 if( !osHeapFree(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ){
49416 sqlite3_log(SQLITE_NOMEM, "failed to HeapFree block %p (%lu), heap=%p",
@@ -49484,11 +49427,11 @@
49427
49428 winMemAssertMagic();
49429 hHeap = winMemGetHeap();
49430 assert( hHeap!=0 );
49431 assert( hHeap!=INVALID_HANDLE_VALUE );
49432 #if defined(SQLITE_WIN32_MALLOC_VALIDATE)
49433 assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) );
49434 #endif
49435 assert( nBytes>=0 );
49436 if( !pPrior ){
49437 p = osHeapAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, (SIZE_T)nBytes);
@@ -49512,11 +49455,11 @@
49455
49456 winMemAssertMagic();
49457 hHeap = winMemGetHeap();
49458 assert( hHeap!=0 );
49459 assert( hHeap!=INVALID_HANDLE_VALUE );
49460 #if defined(SQLITE_WIN32_MALLOC_VALIDATE)
49461 assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, p) );
49462 #endif
49463 if( !p ) return 0;
49464 n = osHeapSize(hHeap, SQLITE_WIN32_HEAP_FLAGS, p);
49465 if( n==(SIZE_T)-1 ){
@@ -49542,11 +49485,11 @@
49485
49486 if( !pWinMemData ) return SQLITE_ERROR;
49487 assert( pWinMemData->magic1==WINMEM_MAGIC1 );
49488 assert( pWinMemData->magic2==WINMEM_MAGIC2 );
49489
49490 #if SQLITE_WIN32_HEAP_CREATE
49491 if( !pWinMemData->hHeap ){
49492 DWORD dwInitialSize = SQLITE_WIN32_HEAP_INIT_SIZE;
49493 DWORD dwMaximumSize = (DWORD)sqlite3GlobalConfig.nHeap;
49494 if( dwMaximumSize==0 ){
49495 dwMaximumSize = SQLITE_WIN32_HEAP_MAX_SIZE;
@@ -49575,11 +49518,11 @@
49518 pWinMemData->bOwned = FALSE;
49519 assert( !pWinMemData->bOwned );
49520 #endif
49521 assert( pWinMemData->hHeap!=0 );
49522 assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE );
49523 #if defined(SQLITE_WIN32_MALLOC_VALIDATE)
49524 assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );
49525 #endif
49526 return SQLITE_OK;
49527 }
49528
@@ -49593,11 +49536,11 @@
49536 assert( pWinMemData->magic1==WINMEM_MAGIC1 );
49537 assert( pWinMemData->magic2==WINMEM_MAGIC2 );
49538
49539 if( pWinMemData->hHeap ){
49540 assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE );
49541 #if defined(SQLITE_WIN32_MALLOC_VALIDATE)
49542 assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );
49543 #endif
49544 if( pWinMemData->bOwned ){
49545 if( !osHeapDestroy(pWinMemData->hHeap) ){
49546 sqlite3_log(SQLITE_NOMEM, "failed to HeapDestroy (%lu), heap=%p",
@@ -49974,21 +49917,10 @@
49917 */
49918 DWORD dwLen = 0;
49919 char *zOut = 0;
49920
49921 if( osIsNT() ){
 
 
 
 
 
 
 
 
 
 
 
49922 LPWSTR zTempWide = NULL;
49923 dwLen = osFormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
49924 FORMAT_MESSAGE_FROM_SYSTEM |
49925 FORMAT_MESSAGE_IGNORE_INSERTS,
49926 NULL,
@@ -49995,20 +49927,17 @@
49927 lastErrno,
49928 0,
49929 (LPWSTR) &zTempWide,
49930 0,
49931 0);
 
49932 if( dwLen > 0 ){
49933 /* allocate a buffer and convert to UTF8 */
49934 sqlite3BeginBenignMalloc();
49935 zOut = winUnicodeToUtf8(zTempWide);
49936 sqlite3EndBenignMalloc();
 
49937 /* free the system buffer allocated by FormatMessage */
49938 osLocalFree(zTempWide);
 
49939 }
49940 }
49941 #ifdef SQLITE_WIN32_HAS_ANSI
49942 else{
49943 char *zTemp = NULL;
@@ -50665,11 +50594,10 @@
50594 ** error code.
50595 */
50596 static int winHandleSeek(HANDLE h, sqlite3_int64 iOffset){
50597 int rc = SQLITE_OK; /* Return value */
50598
 
50599 LONG upperBits; /* Most sig. 32 bits of new offset */
50600 LONG lowerBits; /* Least sig. 32 bits of new offset */
50601 DWORD dwRet; /* Value returned by SetFilePointer() */
50602
50603 upperBits = (LONG)((iOffset>>32) & 0x7fffffff);
@@ -50687,24 +50615,11 @@
50615 DWORD lastErrno = osGetLastError();
50616 if( lastErrno!=NO_ERROR ){
50617 rc = SQLITE_IOERR_SEEK;
50618 }
50619 }
50620 OSTRACE(("SEEK file=%p, offset=%lld rc=%s\n", h, iOffset,sqlite3ErrName(rc)));
 
 
 
 
 
 
 
 
 
 
 
 
 
50621 return rc;
50622 }
50623
50624 /*
50625 ** Move the current position of the file handle passed as the first
@@ -51001,32 +50916,19 @@
50916 ** Determine the size in bytes of the file opened by the handle passed as
50917 ** the first argument.
50918 */
50919 static int winHandleSize(HANDLE h, sqlite3_int64 *pnByte){
50920 int rc = SQLITE_OK;
 
 
 
 
 
 
 
 
 
 
 
50921 DWORD upperBits = 0;
50922 DWORD lowerBits = 0;
50923
50924 assert( pnByte );
50925 lowerBits = osGetFileSize(h, &upperBits);
50926 *pnByte = (((sqlite3_int64)upperBits)<<32) + lowerBits;
50927 if( lowerBits==INVALID_FILE_SIZE && osGetLastError()!=NO_ERROR ){
50928 rc = SQLITE_IOERR_FSTAT;
50929 }
 
 
50930 return rc;
50931 }
50932
50933 /*
50934 ** Close the handle passed as the only argument.
@@ -51221,24 +51123,10 @@
51123
51124 assert( id!=0 );
51125 assert( pSize!=0 );
51126 SimulateIOError(return SQLITE_IOERR_FSTAT);
51127 OSTRACE(("SIZE file=%p, pSize=%p\n", pFile->h, pSize));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51128 {
51129 DWORD upperBits;
51130 DWORD lowerBits;
51131 DWORD lastErrno;
51132
@@ -51249,11 +51137,10 @@
51137 pFile->lastErrno = lastErrno;
51138 rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,
51139 "winFileSize", pFile->zPath);
51140 }
51141 }
 
51142 OSTRACE(("SIZE file=%p, pSize=%p, *pSize=%lld, rc=%s\n",
51143 pFile->h, pSize, *pSize, sqlite3ErrName(rc)));
51144 return rc;
51145 }
51146
@@ -52211,33 +52098,18 @@
52098
52099 /* TODO: platforms.
52100 ** TODO: retry-on-ioerr.
52101 */
52102 if( osIsNT() ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52103 h = osCreateFileW((LPCWSTR)zConverted, /* lpFileName */
52104 (GENERIC_READ | (bReadonly ? 0 : GENERIC_WRITE)), /* dwDesiredAccess */
52105 FILE_SHARE_READ | FILE_SHARE_WRITE, /* dwShareMode */
52106 NULL, /* lpSecurityAttributes */
52107 OPEN_ALWAYS, /* dwCreationDisposition */
52108 FILE_ATTRIBUTE_NORMAL|flag_overlapped,
52109 NULL
52110 );
 
52111 }else{
52112 /* Due to pre-processor directives earlier in this file,
52113 ** SQLITE_WIN32_HAS_ANSI is always defined if osIsNT() is false. */
52114 #ifdef SQLITE_WIN32_HAS_ANSI
52115 h = osCreateFileA((LPCSTR)zConverted,
@@ -52701,13 +52573,11 @@
52573
52574 while( pShmNode->nRegion<=iRegion ){
52575 HANDLE hMap = NULL; /* file-mapping handle */
52576 void *pMap = 0; /* Mapped memory region */
52577
52578 #if defined(SQLITE_WIN32_HAS_WIDE)
 
 
52579 hMap = osCreateFileMappingW(hShared, NULL, protect, 0, nByte, NULL);
52580 #elif defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_CREATEFILEMAPPINGA
52581 hMap = osCreateFileMappingA(hShared, NULL, protect, 0, nByte, NULL);
52582 #endif
52583
@@ -52715,19 +52585,13 @@
52585 osGetCurrentProcessId(), pShmNode->nRegion, nByte,
52586 hMap ? "ok" : "failed"));
52587 if( hMap ){
52588 int iOffset = pShmNode->nRegion*szRegion;
52589 int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity;
 
 
 
 
 
52590 pMap = osMapViewOfFile(hMap, flags,
52591 0, iOffset - iOffsetShift, szRegion + iOffsetShift
52592 );
 
52593 OSTRACE(("SHM-MAP-MAP pid=%lu, region=%d, offset=%d, size=%d, rc=%s\n",
52594 osGetCurrentProcessId(), pShmNode->nRegion, iOffset,
52595 szRegion, pMap ? "ok" : "failed"));
52596 }
52597 if( !pMap ){
@@ -52856,13 +52720,11 @@
52720 if( (pFd->ctrlFlags & WINFILE_RDONLY)==0 ){
52721 protect = PAGE_READWRITE;
52722 flags |= FILE_MAP_WRITE;
52723 }
52724 #endif
52725 #if defined(SQLITE_WIN32_HAS_WIDE)
 
 
52726 pFd->hMap = osCreateFileMappingW(pFd->h, NULL, protect,
52727 (DWORD)((nMap>>32) & 0xffffffff),
52728 (DWORD)(nMap & 0xffffffff), NULL);
52729 #elif defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_CREATEFILEMAPPINGA
52730 pFd->hMap = osCreateFileMappingA(pFd->h, NULL, protect,
@@ -52878,15 +52740,11 @@
52740 osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
52741 return SQLITE_OK;
52742 }
52743 assert( (nMap % winSysInfo.dwPageSize)==0 );
52744 assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
 
 
 
52745 pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
 
52746 if( pNew==NULL ){
52747 osCloseHandle(pFd->hMap);
52748 pFd->hMap = NULL;
52749 pFd->lastErrno = osGetLastError();
52750 rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
@@ -53217,11 +53075,10 @@
53075 }
53076 }
53077 }
53078 #endif
53079
 
53080 else if( osIsNT() ){
53081 char *zMulti;
53082 LPWSTR zWidePath = sqlite3MallocZero( nMax*sizeof(WCHAR) );
53083 if( !zWidePath ){
53084 sqlite3_free(zBuf);
@@ -53271,11 +53128,10 @@
53128 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
53129 return SQLITE_IOERR_NOMEM_BKPT;
53130 }
53131 }
53132 #endif /* SQLITE_WIN32_HAS_ANSI */
 
53133
53134 /*
53135 ** Check to make sure the temporary directory ends with an appropriate
53136 ** separator. If it does not and there is not enough space left to add
53137 ** one, fail.
@@ -53446,17 +53302,10 @@
53302
53303 assert( pFile!=0 );
53304 memset(pFile, 0, sizeof(winFile));
53305 pFile->h = INVALID_HANDLE_VALUE;
53306
 
 
 
 
 
 
 
53307 /* If the second argument to this function is NULL, generate a
53308 ** temporary file name to use
53309 */
53310 if( !zUtf8Name ){
53311 assert( isDelete && !isOpenJournal );
@@ -53535,35 +53384,10 @@
53384 #if SQLITE_OS_WINCE
53385 dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
53386 #endif
53387
53388 if( osIsNT() ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53389 do{
53390 h = osCreateFileW((LPCWSTR)zConverted,
53391 dwDesiredAccess,
53392 dwShareMode, NULL,
53393 dwCreationDisposition,
@@ -53576,11 +53400,10 @@
53400 rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ|NORETRY, &isRO);
53401 sqlite3EndBenignMalloc();
53402 if( rc2==SQLITE_OK && isRO ) break;
53403 }
53404 }while( winRetryIoerr(&cnt, &lastErrno) );
 
53405 }
53406 #ifdef SQLITE_WIN32_HAS_ANSI
53407 else{
53408 do{
53409 h = osCreateFileA((LPCSTR)zConverted,
@@ -53713,29 +53536,11 @@
53536 OSTRACE(("DELETE name=%s, rc=SQLITE_IOERR_NOMEM\n", zFilename));
53537 return SQLITE_IOERR_NOMEM_BKPT;
53538 }
53539 if( osIsNT() ){
53540 do {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53541 attr = osGetFileAttributesW(zConverted);
 
53542 if ( attr==INVALID_FILE_ATTRIBUTES ){
53543 lastErrno = osGetLastError();
53544 if( lastErrno==ERROR_FILE_NOT_FOUND
53545 || lastErrno==ERROR_PATH_NOT_FOUND ){
53546 rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */
@@ -54022,11 +53827,11 @@
53827 sqlite3_vfs *pVfs, /* Pointer to vfs object */
53828 const char *zRelative, /* Possibly relative input path */
53829 int nFull, /* Size of output buffer in bytes */
53830 char *zFull /* Output buffer */
53831 ){
53832 #if !SQLITE_OS_WINCE
53833 int nByte;
53834 void *zConverted;
53835 char *zOut;
53836 #endif
53837
@@ -54111,11 +53916,11 @@
53916 return rc;
53917 }
53918 }
53919 #endif /* __CYGWIN__ */
53920
53921 #if SQLITE_OS_WINCE && defined(_WIN32)
53922 SimulateIOError( return SQLITE_ERROR );
53923 /* WinCE has no concept of a relative pathname, or so I am told. */
53924 /* WinRT has no way to convert a relative path to an absolute one. */
53925 if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
53926 /*
@@ -54130,11 +53935,11 @@
53935 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative);
53936 }
53937 return SQLITE_OK;
53938 #endif
53939
53940 #if !SQLITE_OS_WINCE
53941 #if defined(_WIN32)
53942 /* It's odd to simulate an io-error here, but really this is just
53943 ** using the io-error infrastructure to test that SQLite handles this
53944 ** function failing. This function could fail if, for example, the
53945 ** current working directory has been unlinked.
@@ -54262,15 +54067,11 @@
54067 if( zConverted==0 ){
54068 OSTRACE(("DLOPEN name=%s, handle=%p\n", zFilename, (void*)0));
54069 return 0;
54070 }
54071 if( osIsNT() ){
 
 
 
54072 h = osLoadLibraryW((LPCWSTR)zConverted);
 
54073 }
54074 #ifdef SQLITE_WIN32_HAS_ANSI
54075 else{
54076 h = osLoadLibraryA((char*)zConverted);
54077 }
@@ -54348,37 +54149,30 @@
54149 }
54150 {
54151 DWORD pid = osGetCurrentProcessId();
54152 xorMemory(&e, (unsigned char*)&pid, sizeof(DWORD));
54153 }
 
 
 
 
 
 
54154 {
54155 DWORD cnt = osGetTickCount();
54156 xorMemory(&e, (unsigned char*)&cnt, sizeof(DWORD));
54157 }
 
54158 {
54159 LARGE_INTEGER i;
54160 osQueryPerformanceCounter(&i);
54161 xorMemory(&e, (unsigned char*)&i, sizeof(LARGE_INTEGER));
54162 }
54163 #if !SQLITE_OS_WINCE && SQLITE_WIN32_USE_UUID
54164 {
54165 UUID id;
54166 memset(&id, 0, sizeof(UUID));
54167 osUuidCreate(&id);
54168 xorMemory(&e, (unsigned char*)&id, sizeof(UUID));
54169 memset(&id, 0, sizeof(UUID));
54170 osUuidCreateSequential(&id);
54171 xorMemory(&e, (unsigned char*)&id, sizeof(UUID));
54172 }
54173 #endif /* !SQLITE_OS_WINCE && SQLITE_WIN32_USE_UUID */
54174 return e.nXor>nBuf ? nBuf : e.nXor;
54175 #endif /* defined(SQLITE_TEST) || defined(SQLITE_OMIT_RANDOMNESS) */
54176 }
54177
54178
@@ -54605,19 +54399,15 @@
54399 };
54400 #endif
54401
54402 /* Double-check that the aSyscall[] array has been constructed
54403 ** correctly. See ticket [bb3a86e890c8e96ab] */
54404 assert( ArraySize(aSyscall)==86 );
54405
54406 /* get memory map allocation granularity */
54407 memset(&winSysInfo, 0, sizeof(SYSTEM_INFO));
 
 
 
54408 osGetSystemInfo(&winSysInfo);
 
54409 assert( winSysInfo.dwAllocationGranularity>0 );
54410 assert( winSysInfo.dwPageSize>0 );
54411
54412 sqlite3_vfs_register(&winVfs, 1);
54413
@@ -54637,21 +54427,13 @@
54427
54428 return SQLITE_OK;
54429 }
54430
54431 SQLITE_API int sqlite3_os_end(void){
 
 
 
 
 
 
 
54432 #ifndef SQLITE_OMIT_WAL
54433 winBigLock = 0;
54434 #endif
 
54435 return SQLITE_OK;
54436 }
54437
54438 #endif /* SQLITE_OS_WIN */
54439
@@ -188384,15 +188166,16 @@
188166
188167 /* Initialize the output variables to -1 in case an error occurs. */
188168 if( pnLog ) *pnLog = -1;
188169 if( pnCkpt ) *pnCkpt = -1;
188170
188171 assert( SQLITE_CHECKPOINT_NOOP==-1 );
188172 assert( SQLITE_CHECKPOINT_PASSIVE==0 );
188173 assert( SQLITE_CHECKPOINT_FULL==1 );
188174 assert( SQLITE_CHECKPOINT_RESTART==2 );
188175 assert( SQLITE_CHECKPOINT_TRUNCATE==3 );
188176 if( eMode<SQLITE_CHECKPOINT_NOOP || eMode>SQLITE_CHECKPOINT_TRUNCATE ){
188177 /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint
188178 ** mode: */
188179 return SQLITE_MISUSE_BKPT;
188180 }
188181
@@ -203418,11 +203201,12 @@
203201 PendingList *pList;
203202 int rc = SQLITE_OK;
203203
203204 pList = (PendingList *)fts3HashFind(pHash, zToken, nToken);
203205 if( pList ){
203206 assert( (i64)pList->nData+(i64)nToken+(i64)sizeof(Fts3HashElem)
203207 <= (i64)p->nPendingData );
203208 p->nPendingData -= (int)(pList->nData + nToken + sizeof(Fts3HashElem));
203209 }
203210 if( fts3PendingListAppend(&pList, p->iPrevDocid, iCol, iPos, &rc) ){
203211 if( pList==fts3HashInsert(pHash, zToken, nToken, pList) ){
203212 /* Malloc failed while inserting the new entry. This can only
@@ -225114,11 +224898,11 @@
224898 total += cnt;
224899 if( total>limit ){
224900 /* ERROR: copy exceeds output file size */
224901 return -1;
224902 }
224903 if( (u64)ofst+(u64)cnt > (u64)lenSrc ){
224904 /* ERROR: copy extends past end of input */
224905 return -1;
224906 }
224907 memcpy(zOut, &zSrc[ofst], cnt);
224908 zOut += cnt;
@@ -259795,10 +259579,11 @@
259579 }
259580 }
259581 }
259582
259583 update_out:
259584 sqlite3Fts5IndexCloseReader(pTab->p.pIndex);
259585 pTab->p.pConfig->pzErrmsg = 0;
259586 return rc;
259587 }
259588
259589 /*
@@ -261312,11 +261097,11 @@
261097 int nArg, /* Number of args */
261098 sqlite3_value **apUnused /* Function arguments */
261099 ){
261100 assert( nArg==0 );
261101 UNUSED_PARAM2(nArg, apUnused);
261102 sqlite3_result_text(pCtx, "fts5: 2025-12-11 18:16:39 e785a80e4100c368dca8d73cb662cff4d0fd76734fa0f3fa9b5754a380f7c746", -1, SQLITE_TRANSIENT);
261103 }
261104
261105 /*
261106 ** Implementation of fts5_locale(LOCALE, TEXT) function.
261107 **
261108
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,14 +146,14 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.52.0"
150150
#define SQLITE_VERSION_NUMBER 3052000
151
-#define SQLITE_SOURCE_ID "2025-12-06 11:54:43 b3da6a8728641a0c9ca2f3b20c9817c0a2be6c5bf05f020590547480d2aff0e0"
151
+#define SQLITE_SOURCE_ID "2025-12-11 23:24:05 01409738afc2c0d5bdaa248ffb508aa5f36a66390f6b8e4834734529ee8ed2fa"
152152
#define SQLITE_SCM_BRANCH "trunk"
153153
#define SQLITE_SCM_TAGS ""
154
-#define SQLITE_SCM_DATETIME "2025-12-06T11:54:43.371Z"
154
+#define SQLITE_SCM_DATETIME "2025-12-11T23:24:05.667Z"
155155
156156
/*
157157
** CAPI3REF: Run-Time Library Version Numbers
158158
** KEYWORDS: sqlite3_version sqlite3_sourceid
159159
**
160160
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,14 +146,14 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.52.0"
150 #define SQLITE_VERSION_NUMBER 3052000
151 #define SQLITE_SOURCE_ID "2025-12-06 11:54:43 b3da6a8728641a0c9ca2f3b20c9817c0a2be6c5bf05f020590547480d2aff0e0"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS ""
154 #define SQLITE_SCM_DATETIME "2025-12-06T11:54:43.371Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
160
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,14 +146,14 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.52.0"
150 #define SQLITE_VERSION_NUMBER 3052000
151 #define SQLITE_SOURCE_ID "2025-12-11 23:24:05 01409738afc2c0d5bdaa248ffb508aa5f36a66390f6b8e4834734529ee8ed2fa"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS ""
154 #define SQLITE_SCM_DATETIME "2025-12-11T23:24:05.667Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
160

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button