Merge trunk changes into this branch.

FossilOrigin-Name: 03ade4a810516ff84bc5c1a716b0e454cc8a89374100415ff21a82449112811b
This commit is contained in:
dan 2024-01-20 18:45:30 +00:00
commit b75dc61a53
10 changed files with 104 additions and 58 deletions

View File

@ -1,5 +1,5 @@
C Add\stest\scases\sfor\sthe\snew\scode\son\sthis\sbranch.
D 2024-01-20T16:46:25.186
C Merge\strunk\schanges\sinto\sthis\sbranch.
D 2024-01-20T18:45:30.244
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -684,7 +684,7 @@ F src/build.c e7d9044592eeeea8e78d8ae53ca8d31fd6e92ca0d4f53e2f2e8ccf7352e0b04b
F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b
F src/date.c 35ea61eb7ab5b918db7a96725346234bf8fb5bc161c7b868c20a7f24f351a2da
F src/date.c 48a110a2a267398ad9b04fe3db69dfa194f91719f94fa55cd560e03510f963e6
F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782
F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43
F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500
@ -708,7 +708,7 @@ F src/mem1.c 3bb59158c38e05f6270e761a9f435bf19827a264c13d1631c58b84bdc96d73b2
F src/mem2.c c8bfc9446fd0798bddd495eb5d9dbafa7d4b7287d8c22d50a83ac9daa26d8a75
F src/mem3.c 30301196cace2a085cbedee1326a49f4b26deff0af68774ca82c1f7c06fda4f6
F src/mem5.c b7da5c10a726aacacc9ad7cdcb0667deec643e117591cc69cf9b4b9e7f3e96ff
F src/memdb.c 559c42e61eb70cd6d4bc692b042497133c6d96c09a3d514d92f3dac72268e223
F src/memdb.c 16679def118b5fd75292a253166d3feba3ec9c6189205bf209643ecdb2174ecc
F src/memjournal.c c283c6c95d940eb9dc70f1863eef3ee40382dbd35e5a1108026e7817c206e8a0
F src/msvc.h 80b35f95d93bf996ccb3e498535255f2ef1118c78764719a7cd15ab4106ccac9
F src/mutex.c 1b4c7e5e3621b510e0c18397210be27cd54c8084141144fbbafd003fde948e88
@ -814,7 +814,7 @@ F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c
F src/vdbeapi.c 8f57d60c89da0b60e6d4e272358c511f6bae4e24330bdb11f8b42f986d1bf21b
F src/vdbeaux.c c5a471b34e9c4cfc0295a3e10734fd197670ffaebcb742f284c8e17e8026ceea
F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5
F src/vdbemem.c bbe87b3e851bcc5cad2a9329ad0387432e41ddf2f98f2682c524ad676b739987
F src/vdbemem.c 3e37dab421b74e9ce55c1e88fbc7bc6fead590b5ab258bc684f8b70abb1d6e71
F src/vdbesort.c 237840ca1947511fa59bd4e18b9eeae93f2af2468c34d2427b059f896230a547
F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823
F src/vdbevtab.c 2143db7db0ceed69b21422581f434baffc507a08d831565193a7a02882a1b6a7
@ -838,7 +838,7 @@ F test/aggorderby.test cc3abf5de64d46ff66395ca8c2346b66c2576d5aedb7bffc5b0742508
F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
F test/all.test 2ecb8bbd52416642e41c9081182a8df05d42c75637afd4488aace78cc4b69e13
F test/alter.test 3c00eff1e2036b9f93e9cd0f3d3e63750ac87ecb5bc71b9d7bd07cbf2ac4c494
F test/alter2.test a966ccfcddf9ce0a4e0e6ff1aca9e6e7948e0e242cd7e43fc091948521807687
F test/alter2.test 7e3d26ab409df52df887b366a63902c3429b935c41cb962fd58ffc25784f2f19
F test/alter3.test ffc4ab29ce78a3517a66afd69b2730667e3471622509c283b2bd4c46f680fba3
F test/alter4.test 716caa071dd8a3c6d57225778d15d3c3cbf5e34b2e84ae44199aeb2bbf50a707
F test/alterauth.test 63442ba61ceb0c1eeb63aac1f4f5cebfa509d352276059d27106ae256bafc959
@ -1033,7 +1033,7 @@ F test/dataversion1.test 6e5e86ac681f0782e766ebcb56c019ae001522d114e0e111e5ebf68
F test/date.test b1a5208e6a9c390cf1d1fa4e38a910386b427b0e27046901c6b0fb995d19800e
F test/date2.test 7e12ec14aaf4d5e6294b4ba140445b0eca06ea50062a9c3a69c4ee13d0b6f8b1
F test/date3.test a1b77abf05c6772fe5ca2337cac1398892f2a41e62bce7e6be0f4a08a0e64ae5
F test/date4.test 77b3781c28d3a5e181c6474315aa58e1f6cf79f5171a4e46e248837b506e7adf
F test/date4.test 75dc8401e8c0639a228cd26a6eaa4ff5ea8ccda912b9853d1c9462c476670e17
F test/dbdata.test 042f49acff3438f940eeba5868d3af080ae64ddf26ae78f80c92bec3ca7d8603
F test/dbfuzz.c 73047c920d6210e5912c87cdffd9a1c281d4252e
F test/dbfuzz001.test 6c9a4622029d69dc38926f115864b055cb2f39badd25ec22cbfb130c8ba8e9c3
@ -1355,7 +1355,7 @@ F test/like2.test d3be15fefee3e02fc88942a9b98f26c5339bbdef7783c90023c092c4955fe3
F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de98745c
F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf
F test/limit2.test 9409b033284642a859fafc95f29a5a6a557bd57c1f0d7c3f554bd64ed69df77e
F test/literal.test 62415688179c0d586f3633482e6c8e441edb805cd73c306964cf39912a6bff0e
F test/literal.test 17d21dda2f877018a02c28e2a85947b82ed638f2ca5ef3fa47c92359f02520a3
F test/loadext.test faa4f6eed07a5aac35d57fdd7bc07f8fc82464cfd327567c10cf0ba3c86cde04
F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7
F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db
@ -1396,7 +1396,7 @@ F test/malloctraceviewer.tcl 3e3ddf11e30d2b20f53aa16aa6615082fb24a100bea61cca721
F test/manydb.test 28385ae2087967aa05c38624cec7d96ec74feb3e
F test/mem5.test c6460fba403c5703141348cd90de1c294188c68f
F test/memdb.test c1f2a343ad14398d5d6debda6ea33e80d0dafcc7
F test/memdb1.test 2c4e9cc10d21c6bf4e217d72b7f6b8ba9b2605971bb2c5e6df76018e189f98f5
F test/memdb1.test cd6b6b1632cf2f76c8a6f35be013f4011f3ab2c8d74d3d1424576f29bfa4a9a1
F test/memdb2.test 4ba1fc09e2f51df80d148a540e4a3fa66d0462e91167b27497084de4d1f6b5b4
F test/memjournal.test 70f3a00c7f84ee2978ad14e831231caa1e7f23915a2c54b4f775a021d5740c6c
F test/memjournal2.test dbc2c5cb5f7b38950f4f6dc3e73fcecf0fcbed3fc32c7ce913bba164d288da1e
@ -1715,7 +1715,7 @@ F test/tkt-7a31705a7e6.test 9e9c057b6a9497c8f7ba7b16871029414ccf6550e7345d9085d6
F test/tkt-7bbfb7d442.test e87b59e620700b5a52ecd92f05d56686c1cad9e1aa17456eada55e0bb821b698
F test/tkt-80ba201079.test 105a721e6aad0ae3c5946d7615d1e4d03f6145b8
F test/tkt-80e031a00f.test 7c93af53f43527f50020983a4bcc39b077e77c7362d7af8e04a5fd155fe5e829
F test/tkt-8454a207b9.test aff2e76143cfa443ddce6f7d85968a2e9b57a3deb0b881b730120740555f9e2f
F test/tkt-8454a207b9.test ead80b7a01438ca1436cee029694a96c821346cf1e24f06de12f8172e139ddbb
F test/tkt-868145d012.test a5f941107ece6a64410ca4755c6329b7eb57a356
F test/tkt-8c63ff0ec.test 258b7fc8d7e4e1cb5362c7d65c143528b9c4cbed
F test/tkt-91e2e8ba6f.test 08c4f94ae07696b05c9b822da0b4e5337a2f54c5
@ -2159,8 +2159,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 401650aaccbc99246bd4e1ff37a28b78f528178aee2f294d87b9f7fecd7432bb
R f613ae2f01e87601e8fa7113cad6d125
P 49f29a7b4f44f691ecf7a57b26477971e6ffaf2a0b1690b4926ffbb43fa3929b 298d6977285c71be917896bc875a8a26d985dcf0a74069b7c4d290e8ff0ac618
R d4f77c6633329aa6323323954676adb8
U dan
Z 0deb0f7f0bb54434edd39b41a13f24b4
Z 02dbf9257e243f2009f448d2d8147299
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
49f29a7b4f44f691ecf7a57b26477971e6ffaf2a0b1690b4926ffbb43fa3929b
03ade4a810516ff84bc5c1a716b0e454cc8a89374100415ff21a82449112811b

View File

@ -1237,10 +1237,14 @@ static void dateFunc(
}
/*
** Compute the one-based day of the year for the DateTime pDate.
** Jan01 = 1, Jan02 = 2, ... Dec31 = 356 or 366.
** Compute the number of days after the most recent January 1.
**
** In other words, compute the zero-based day number for the
** current year:
**
** Jan01 = 0, Jan02 = 2, ... Dec31 = 364 or 365.
*/
static int dayOfYear(DateTime *pDate){
static int daysAfterJan01(DateTime *pDate){
DateTime jan01 = *pDate;
assert( jan01.validYMD );
assert( jan01.validHMS );
@ -1249,18 +1253,33 @@ static int dayOfYear(DateTime *pDate){
jan01.M = 1;
jan01.D = 1;
computeJD(&jan01);
return (int)((pDate->iJD-jan01.iJD+43200000)/86400000) + 1;
return (int)((pDate->iJD-jan01.iJD+43200000)/86400000);
}
/*
** Return the day of the week. 1==Monday, 2=Tues, ..., 7=Sunday.
** Return the number of days after the most recent Monday.
**
** In other words, return the day of the week according
** to this code:
**
** 0=Monday, 1=Tuesday, 2=Wednesday, ..., 6=Sunday.
*/
static int dayOfWeek(DateTime *pDate){
int w;
static int daysAfterMonday(DateTime *pDate){
assert( pDate->validJD );
w = ((pDate->iJD+129600000)/86400000) % 7;
if( w==0 ) w = 7;
return w;
return (int)((pDate->iJD+43200000)/86400000) % 7;
}
/*
** Return the number of days after the most recent Sunday.
**
** In other words, return the day of the week according
** to this code:
**
** 0=Sunday, 1=Monday, 2=Tues, ..., 6=Saturday
*/
static int daysAfterSunday(DateTime *pDate){
assert( pDate->validJD );
return (int)((pDate->iJD+129600000)/86400000) % 7;
}
/*
@ -1344,7 +1363,7 @@ static void strftimeFunc(
DateTime y = x;
assert( y.validJD );
/* Move y so that it is the Thursday in the same week as x */
y.iJD += (4 - dayOfWeek(&x))*86400000;
y.iJD += (3 - daysAfterMonday(&x))*86400000;
y.validYMD = 0;
computeYMD(&y);
if( cf=='g' ){
@ -1368,8 +1387,7 @@ static void strftimeFunc(
break;
}
case 'j': { /* Day of year. Jan01==1, Jan02==2, and so forth */
int nDay = dayOfYear(&x);
sqlite3_str_appendf(&sRes,"%03d",nDay);
sqlite3_str_appendf(&sRes,"%03d",daysAfterJan01(&x)+1);
break;
}
case 'J': { /* Julian day number. (Non-standard) */
@ -1417,35 +1435,29 @@ static void strftimeFunc(
}
case 'u': /* Day of week. 1 to 7. Monday==1, Sunday==7 */
case 'w': { /* Day of week. 0 to 6. Sunday==0, Monday==1 */
char c = (char)(((x.iJD+129600000)/86400000) % 7) + '0';
char c = (char)daysAfterSunday(&x) + '0';
if( c=='0' && cf=='u' ) c = '7';
sqlite3_str_appendchar(&sRes, 1, c);
break;
}
case 'U': { /* Week num. 00-53. First Sun of the year is week 01 */
int wd; /* 0=Sunday, 1=Monday, 2=Tuesday, ... 7=Saturday */
int nDay; /* Day of the year. 0..364 or 0..365 for leapyears */
nDay = dayOfYear(&x);
wd = (int)(((x.iJD+43200000)/86400000 + 1)%7);
sqlite3_str_appendf(&sRes,"%02d",(nDay+6-wd)/7);
sqlite3_str_appendf(&sRes,"%02d",
(daysAfterJan01(&x)-daysAfterSunday(&x)+7)/7);
break;
}
case 'V': { /* Week num. 01-53. First week with a Thur is week 01 */
DateTime y = x;
/* Adjust y so that is the Thursday in the same week as x */
assert( y.validJD );
y.iJD += (4 - dayOfWeek(&x))*86400000;
y.iJD += (3 - daysAfterMonday(&x))*86400000;
y.validYMD = 0;
computeYMD(&y);
sqlite3_str_appendf(&sRes,"%02d", (dayOfYear(&y)-1)/7+1);
sqlite3_str_appendf(&sRes,"%02d", daysAfterJan01(&y)/7+1);
break;
}
case 'W': { /* Week num. 00-53. First Mon of the year is week 01 */
int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */
int nDay; /* Day of the year. 0..364 or 0..365 for leapyears */
nDay = dayOfYear(&x);
wd = (int)(((x.iJD+43200000)/86400000)%7);
sqlite3_str_appendf(&sRes,"%02d",(nDay+6-wd)/7);
sqlite3_str_appendf(&sRes,"%02d",
(daysAfterJan01(&x)-daysAfterMonday(&x)+7)/7);
break;
}
case 'Y': {

View File

@ -799,6 +799,14 @@ unsigned char *sqlite3_serialize(
pOut = 0;
}else{
sz = sqlite3_column_int64(pStmt, 0)*szPage;
if( sz==0 ){
sqlite3_reset(pStmt);
sqlite3_exec(db, "BEGIN IMMEDIATE; COMMIT;", 0, 0, 0);
rc = sqlite3_step(pStmt);
if( rc==SQLITE_ROW ){
sz = sqlite3_column_int64(pStmt, 0)*szPage;
}
}
if( piSize ) *piSize = sz;
if( mFlags & SQLITE_SERIALIZE_NOCOPY ){
pOut = 0;

View File

@ -1662,8 +1662,17 @@ static int valueFromExpr(
sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC);
}
}
if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_BLOB ){
sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8);
if( affinity==SQLITE_AFF_BLOB ){
if( op==TK_FLOAT ){
assert( pVal && pVal->z && pVal->flags==(MEM_Str|MEM_Term) );
sqlite3AtoF(pVal->z, &pVal->u.r, pVal->n, SQLITE_UTF8);
pVal->flags = MEM_Real;
}else if( op==TK_INTEGER ){
/* This case is required by -9223372036854775808 and other strings
** that look like integers but cannot be handled by the
** sqlite3DecOrHexToI64() call above. */
sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8);
}
}else{
sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8);
}

View File

@ -371,7 +371,7 @@ do_test alter2-7.5 {
execsql {
SELECT a, typeof(a), b, typeof(b), c, typeof(c) FROM t1 LIMIT 1;
}
} {1 integer -123 integer 5 text}
} {1 integer -123.0 real 5 text}
#-----------------------------------------------------------------------
# Test that UPDATE trigger tables work with default values, and that when
@ -397,11 +397,11 @@ do_test alter2-8.2 {
UPDATE t1 SET c = 10 WHERE a = 1;
SELECT a, typeof(a), b, typeof(b), c, typeof(c) FROM t1 LIMIT 1;
}
} {1 integer -123 integer 10 text}
} {1 integer -123.0 real 10 text}
ifcapable trigger {
do_test alter2-8.3 {
set ::val
} {-123 integer 5 text -123 integer 10 text}
} {-123.0 real 5 text -123.0 real 10 text}
}
#-----------------------------------------------------------------------
@ -425,7 +425,7 @@ ifcapable trigger {
DELETE FROM t1 WHERE a = 2;
}
set ::val
} {-123 integer 5 text}
} {-123.0 real 5 text}
}
#-----------------------------------------------------------------------

View File

@ -28,8 +28,8 @@ if {$tcl_platform(os)=="Linux"} {
} else {
set FMT {%d,%e,%F,%H,%I,%j,%p,%R,%u,%w,%W,%%}
}
for {set i 0} {$i<=24854} {incr i} {
set TS [expr {$i*86401}]
for {set i 0} {$i<=24858} {incr i} {
set TS [expr {$i*86390}]
do_execsql_test date4-$i {
SELECT strftime($::FMT,$::TS,'unixepoch');
} [list [strftime $FMT $TS]]

View File

@ -42,16 +42,20 @@ test_literal 1.10 -45 integer -45
test_literal 1.11 '0xFF' text 0xFF
test_literal 1.12 '-0xFF' text -0xFF
test_literal 1.13 -'0xFF' integer 0
test_literal 1.14 -9223372036854775808 integer -9223372036854775808
test_literal 2.1 1_000 integer 1000
test_literal 2.2 1.1_1 real 1.11
test_literal 2.3 1_0.1_1 real 10.11
test_literal 2.4 1e1_000 real Inf
test_literal 2.5 123______456.7_8__9_ real 123456.789
test_literal 2.6 9_223_372_036_854_775_807 integer 9223372036854775807
test_literal 2.7 9_223_372_036_854_775_808 real 9.22337203685478e+18
test_literal 2.8 -9_223_372_036_854_775_808 integer -9223372036854775808
test_literal 2.1 1e12 real 1000000000000.0
test_literal 2.2 1.0 real 1.0
test_literal 2.3 1e1000 real Inf
test_literal 2.4 -1e1000 real -Inf
test_literal 3.3 1e12 real 1000000000000.0
test_literal 3.1 1_000 integer 1000
test_literal 3.2 1.1_1 real 1.11
test_literal 3.3 1_0.1_1 real 10.11
test_literal 3.4 1e1_000 real Inf
test_literal 3.5 123______456.7_8__9_ real 123456.789
test_literal 3.6 9_223_372_036_854_775_807 integer 9223372036854775807
test_literal 3.7 9_223_372_036_854_775_808 real 9.22337203685478e+18
test_literal 3.8 -9_223_372_036_854_775_808 integer -9223372036854775808
finish_test

View File

@ -267,4 +267,17 @@ if {[wal_is_capable]} {
} {1 {database disk image is malformed}}
}
# 2024-01-20
# https://sqlite.org/forum/forumpost/498777780e16880a
#
# Make sure a database is initialized before serializing it.
#
reset_db
sqlite3 dbempty :memory:
do_test 900 {
set len [string length [dbempty serialize]]
expr {$len>0}
} 1
dbempty close
finish_test

View File

@ -49,7 +49,7 @@ do_test tkt-8454a207b9.4 {
ALTER TABLE t1 ADD COLUMN e DEFAULT -123.0;
SELECT e, typeof(e) FROM t1;
}
} {-123 integer}
} {-123.0 real}
do_test tkt-8454a207b9.5 {
db eval {
ALTER TABLE t1 ADD COLUMN f DEFAULT -123.5;