Fossil SCM

Update to the latest version of SQLite.

drh 2009-10-13 16:25 trunk
Commit 076f7adff24d807321e9ae5c2adff6575ec64f9b
2 files changed +3037 -1234 +11 -7
+3037 -1234
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.6.18. By combining all the individual C code files into this
3
+** version 3.6.19. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a one translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% are more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -15,11 +15,11 @@
1515
** of the embedded sqlite3.h header file.) Additional code files may be needed
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
**
20
-** This amalgamation was generated on 2009-09-11 14:16:13 UTC.
20
+** This amalgamation was generated on 2009-10-13 16:22:00 UTC.
2121
*/
2222
#define SQLITE_CORE 1
2323
#define SQLITE_AMALGAMATION 1
2424
#ifndef SQLITE_PRIVATE
2525
# define SQLITE_PRIVATE static
@@ -273,10 +273,14 @@
273273
# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000
274274
#endif
275275
276276
/*
277277
** Maximum depth of recursion for triggers.
278
+**
279
+** A value of 1 means that a trigger program will not be able to itself
280
+** fire any triggers. A value of 0 means that no trigger programs at all
281
+** may be executed.
278282
*/
279283
#ifndef SQLITE_MAX_TRIGGER_DEPTH
280284
#if defined(SQLITE_SMALL_STACK)
281285
# define SQLITE_MAX_TRIGGER_DEPTH 10
282286
#else
@@ -645,13 +649,13 @@
645649
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
646650
** [sqlite_version()] and [sqlite_source_id()].
647651
**
648652
** Requirements: [H10011] [H10014]
649653
*/
650
-#define SQLITE_VERSION "3.6.18"
651
-#define SQLITE_VERSION_NUMBER 3006018
652
-#define SQLITE_SOURCE_ID "2009-09-11 14:05:07 b084828a771ec40be85f07c590ca99de4f6c24ee"
654
+#define SQLITE_VERSION "3.6.19"
655
+#define SQLITE_VERSION_NUMBER 3006019
656
+#define SQLITE_SOURCE_ID "2009-10-13 15:42:49 f894ebf86d6bafcd1461f104f5f677b3b6a3aa1a"
653657
654658
/*
655659
** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
656660
** KEYWORDS: sqlite3_version
657661
**
@@ -1842,12 +1846,13 @@
18421846
** This function returns the number of database rows that were changed
18431847
** or inserted or deleted by the most recently completed SQL statement
18441848
** on the [database connection] specified by the first parameter.
18451849
** Only changes that are directly specified by the [INSERT], [UPDATE],
18461850
** or [DELETE] statement are counted. Auxiliary changes caused by
1847
-** triggers are not counted. Use the [sqlite3_total_changes()] function
1848
-** to find the total number of changes including changes caused by triggers.
1851
+** triggers or [foreign key actions] are not counted. Use the
1852
+** [sqlite3_total_changes()] function to find the total number of changes
1853
+** including changes caused by triggers and foreign key actions.
18491854
**
18501855
** Changes to a view that are simulated by an [INSTEAD OF trigger]
18511856
** are not counted. Only real table changes are counted.
18521857
**
18531858
** A "row change" is a change to a single row of a single table
@@ -1895,12 +1900,12 @@
18951900
/*
18961901
** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600>
18971902
**
18981903
** This function returns the number of row changes caused by [INSERT],
18991904
** [UPDATE] or [DELETE] statements since the [database connection] was opened.
1900
-** The count includes all changes from all
1901
-** [CREATE TRIGGER | trigger] contexts. However,
1905
+** The count includes all changes from all [CREATE TRIGGER | trigger]
1906
+** contexts and changes made by [foreign key actions]. However,
19021907
** the count does not include changes used to implement [REPLACE] constraints,
19031908
** do rollbacks or ABORT processing, or [DROP TABLE] processing. The
19041909
** count does not include rows of views that fire an [INSTEAD OF trigger],
19051910
** though if the INSTEAD OF trigger makes changes of its own, those changes
19061911
** are counted.
@@ -5037,10 +5042,13 @@
50375042
** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
50385043
** </pre> {END}
50395044
**
50405045
** If the flags parameter is non-zero, then the BLOB is opened for read
50415046
** and write access. If it is zero, the BLOB is opened for read access.
5047
+** It is not possible to open a column that is part of an index or primary
5048
+** key for writing. ^If [foreign key constraints] are enabled, it is
5049
+** not possible to open a column that is part of a [child key] for writing.
50425050
**
50435051
** Note that the database name is not the filename that contains
50445052
** the database but rather the symbolic name of the database that
50455053
** is assigned when the database is connected using [ATTACH].
50465054
** For the main database file, the database name is "main".
@@ -6419,74 +6427,74 @@
64196427
#define TK_AS 24
64206428
#define TK_COMMA 25
64216429
#define TK_ID 26
64226430
#define TK_INDEXED 27
64236431
#define TK_ABORT 28
6424
-#define TK_AFTER 29
6425
-#define TK_ANALYZE 30
6426
-#define TK_ASC 31
6427
-#define TK_ATTACH 32
6428
-#define TK_BEFORE 33
6429
-#define TK_BY 34
6430
-#define TK_CASCADE 35
6431
-#define TK_CAST 36
6432
-#define TK_COLUMNKW 37
6433
-#define TK_CONFLICT 38
6434
-#define TK_DATABASE 39
6435
-#define TK_DESC 40
6436
-#define TK_DETACH 41
6437
-#define TK_EACH 42
6438
-#define TK_FAIL 43
6439
-#define TK_FOR 44
6440
-#define TK_IGNORE 45
6441
-#define TK_INITIALLY 46
6442
-#define TK_INSTEAD 47
6443
-#define TK_LIKE_KW 48
6444
-#define TK_MATCH 49
6445
-#define TK_KEY 50
6446
-#define TK_OF 51
6447
-#define TK_OFFSET 52
6448
-#define TK_PRAGMA 53
6449
-#define TK_RAISE 54
6450
-#define TK_REPLACE 55
6451
-#define TK_RESTRICT 56
6452
-#define TK_ROW 57
6453
-#define TK_TRIGGER 58
6454
-#define TK_VACUUM 59
6455
-#define TK_VIEW 60
6456
-#define TK_VIRTUAL 61
6457
-#define TK_REINDEX 62
6458
-#define TK_RENAME 63
6459
-#define TK_CTIME_KW 64
6460
-#define TK_ANY 65
6461
-#define TK_OR 66
6462
-#define TK_AND 67
6463
-#define TK_IS 68
6464
-#define TK_BETWEEN 69
6465
-#define TK_IN 70
6466
-#define TK_ISNULL 71
6467
-#define TK_NOTNULL 72
6468
-#define TK_NE 73
6469
-#define TK_EQ 74
6470
-#define TK_GT 75
6471
-#define TK_LE 76
6472
-#define TK_LT 77
6473
-#define TK_GE 78
6474
-#define TK_ESCAPE 79
6475
-#define TK_BITAND 80
6476
-#define TK_BITOR 81
6477
-#define TK_LSHIFT 82
6478
-#define TK_RSHIFT 83
6479
-#define TK_PLUS 84
6480
-#define TK_MINUS 85
6481
-#define TK_STAR 86
6482
-#define TK_SLASH 87
6483
-#define TK_REM 88
6484
-#define TK_CONCAT 89
6485
-#define TK_COLLATE 90
6486
-#define TK_UMINUS 91
6487
-#define TK_UPLUS 92
6432
+#define TK_ACTION 29
6433
+#define TK_AFTER 30
6434
+#define TK_ANALYZE 31
6435
+#define TK_ASC 32
6436
+#define TK_ATTACH 33
6437
+#define TK_BEFORE 34
6438
+#define TK_BY 35
6439
+#define TK_CASCADE 36
6440
+#define TK_CAST 37
6441
+#define TK_COLUMNKW 38
6442
+#define TK_CONFLICT 39
6443
+#define TK_DATABASE 40
6444
+#define TK_DESC 41
6445
+#define TK_DETACH 42
6446
+#define TK_EACH 43
6447
+#define TK_FAIL 44
6448
+#define TK_FOR 45
6449
+#define TK_IGNORE 46
6450
+#define TK_INITIALLY 47
6451
+#define TK_INSTEAD 48
6452
+#define TK_LIKE_KW 49
6453
+#define TK_MATCH 50
6454
+#define TK_NO 51
6455
+#define TK_KEY 52
6456
+#define TK_OF 53
6457
+#define TK_OFFSET 54
6458
+#define TK_PRAGMA 55
6459
+#define TK_RAISE 56
6460
+#define TK_REPLACE 57
6461
+#define TK_RESTRICT 58
6462
+#define TK_ROW 59
6463
+#define TK_TRIGGER 60
6464
+#define TK_VACUUM 61
6465
+#define TK_VIEW 62
6466
+#define TK_VIRTUAL 63
6467
+#define TK_REINDEX 64
6468
+#define TK_RENAME 65
6469
+#define TK_CTIME_KW 66
6470
+#define TK_ANY 67
6471
+#define TK_OR 68
6472
+#define TK_AND 69
6473
+#define TK_IS 70
6474
+#define TK_BETWEEN 71
6475
+#define TK_IN 72
6476
+#define TK_ISNULL 73
6477
+#define TK_NOTNULL 74
6478
+#define TK_NE 75
6479
+#define TK_EQ 76
6480
+#define TK_GT 77
6481
+#define TK_LE 78
6482
+#define TK_LT 79
6483
+#define TK_GE 80
6484
+#define TK_ESCAPE 81
6485
+#define TK_BITAND 82
6486
+#define TK_BITOR 83
6487
+#define TK_LSHIFT 84
6488
+#define TK_RSHIFT 85
6489
+#define TK_PLUS 86
6490
+#define TK_MINUS 87
6491
+#define TK_STAR 88
6492
+#define TK_SLASH 89
6493
+#define TK_REM 90
6494
+#define TK_CONCAT 91
6495
+#define TK_COLLATE 92
64886496
#define TK_BITNOT 93
64896497
#define TK_STRING 94
64906498
#define TK_JOIN_KW 95
64916499
#define TK_CONSTRAINT 96
64926500
#define TK_DEFAULT 97
@@ -6497,32 +6505,32 @@
64976505
#define TK_REFERENCES 102
64986506
#define TK_AUTOINCR 103
64996507
#define TK_ON 104
65006508
#define TK_DELETE 105
65016509
#define TK_UPDATE 106
6502
-#define TK_INSERT 107
6503
-#define TK_SET 108
6504
-#define TK_DEFERRABLE 109
6505
-#define TK_FOREIGN 110
6506
-#define TK_DROP 111
6507
-#define TK_UNION 112
6508
-#define TK_ALL 113
6509
-#define TK_EXCEPT 114
6510
-#define TK_INTERSECT 115
6511
-#define TK_SELECT 116
6512
-#define TK_DISTINCT 117
6513
-#define TK_DOT 118
6514
-#define TK_FROM 119
6515
-#define TK_JOIN 120
6516
-#define TK_USING 121
6517
-#define TK_ORDER 122
6518
-#define TK_GROUP 123
6519
-#define TK_HAVING 124
6520
-#define TK_LIMIT 125
6521
-#define TK_WHERE 126
6522
-#define TK_INTO 127
6523
-#define TK_VALUES 128
6510
+#define TK_SET 107
6511
+#define TK_DEFERRABLE 108
6512
+#define TK_FOREIGN 109
6513
+#define TK_DROP 110
6514
+#define TK_UNION 111
6515
+#define TK_ALL 112
6516
+#define TK_EXCEPT 113
6517
+#define TK_INTERSECT 114
6518
+#define TK_SELECT 115
6519
+#define TK_DISTINCT 116
6520
+#define TK_DOT 117
6521
+#define TK_FROM 118
6522
+#define TK_JOIN 119
6523
+#define TK_USING 120
6524
+#define TK_ORDER 121
6525
+#define TK_GROUP 122
6526
+#define TK_HAVING 123
6527
+#define TK_LIMIT 124
6528
+#define TK_WHERE 125
6529
+#define TK_INTO 126
6530
+#define TK_VALUES 127
6531
+#define TK_INSERT 128
65246532
#define TK_INTEGER 129
65256533
#define TK_FLOAT 130
65266534
#define TK_BLOB 131
65276535
#define TK_REGISTER 132
65286536
#define TK_VARIABLE 133
@@ -6536,19 +6544,22 @@
65366544
#define TK_TO_TEXT 141
65376545
#define TK_TO_BLOB 142
65386546
#define TK_TO_NUMERIC 143
65396547
#define TK_TO_INT 144
65406548
#define TK_TO_REAL 145
6541
-#define TK_END_OF_FILE 146
6542
-#define TK_ILLEGAL 147
6543
-#define TK_SPACE 148
6544
-#define TK_UNCLOSED_STRING 149
6545
-#define TK_FUNCTION 150
6546
-#define TK_COLUMN 151
6547
-#define TK_AGG_FUNCTION 152
6548
-#define TK_AGG_COLUMN 153
6549
-#define TK_CONST_FUNC 154
6549
+#define TK_ISNOT 146
6550
+#define TK_END_OF_FILE 147
6551
+#define TK_ILLEGAL 148
6552
+#define TK_SPACE 149
6553
+#define TK_UNCLOSED_STRING 150
6554
+#define TK_FUNCTION 151
6555
+#define TK_COLUMN 152
6556
+#define TK_AGG_FUNCTION 153
6557
+#define TK_AGG_COLUMN 154
6558
+#define TK_CONST_FUNC 155
6559
+#define TK_UMINUS 156
6560
+#define TK_UPLUS 157
65506561
65516562
/************** End of parse.h ***********************************************/
65526563
/************** Continuing where we left off in sqliteInt.h ******************/
65536564
#include <stdio.h>
65546565
#include <stdlib.h>
@@ -7308,142 +7319,142 @@
73087319
#define OP_SetCookie 4
73097320
#define OP_Seek 5
73107321
#define OP_Real 130 /* same as TK_FLOAT */
73117322
#define OP_Sequence 6
73127323
#define OP_Savepoint 7
7313
-#define OP_Ge 78 /* same as TK_GE */
7324
+#define OP_Ge 80 /* same as TK_GE */
73147325
#define OP_RowKey 8
73157326
#define OP_SCopy 9
7316
-#define OP_Eq 74 /* same as TK_EQ */
7327
+#define OP_Eq 76 /* same as TK_EQ */
73177328
#define OP_OpenWrite 10
7318
-#define OP_NotNull 72 /* same as TK_NOTNULL */
7329
+#define OP_NotNull 74 /* same as TK_NOTNULL */
73197330
#define OP_If 11
73207331
#define OP_ToInt 144 /* same as TK_TO_INT */
73217332
#define OP_String8 94 /* same as TK_STRING */
73227333
#define OP_CollSeq 12
73237334
#define OP_OpenRead 13
73247335
#define OP_Expire 14
73257336
#define OP_AutoCommit 15
7326
-#define OP_Gt 75 /* same as TK_GT */
7337
+#define OP_Gt 77 /* same as TK_GT */
73277338
#define OP_Pagecount 16
73287339
#define OP_IntegrityCk 17
73297340
#define OP_Sort 18
73307341
#define OP_Copy 20
73317342
#define OP_Trace 21
73327343
#define OP_Function 22
73337344
#define OP_IfNeg 23
7334
-#define OP_And 67 /* same as TK_AND */
7335
-#define OP_Subtract 85 /* same as TK_MINUS */
7345
+#define OP_And 69 /* same as TK_AND */
7346
+#define OP_Subtract 87 /* same as TK_MINUS */
73367347
#define OP_Noop 24
73377348
#define OP_Program 25
73387349
#define OP_Return 26
7339
-#define OP_Remainder 88 /* same as TK_REM */
7350
+#define OP_Remainder 90 /* same as TK_REM */
73407351
#define OP_NewRowid 27
7341
-#define OP_Multiply 86 /* same as TK_STAR */
7342
-#define OP_Variable 28
7343
-#define OP_String 29
7344
-#define OP_RealAffinity 30
7345
-#define OP_VRename 31
7346
-#define OP_ParseSchema 32
7347
-#define OP_VOpen 33
7348
-#define OP_Close 34
7349
-#define OP_CreateIndex 35
7350
-#define OP_IsUnique 36
7351
-#define OP_NotFound 37
7352
-#define OP_Int64 38
7353
-#define OP_MustBeInt 39
7354
-#define OP_Halt 40
7355
-#define OP_Rowid 41
7356
-#define OP_IdxLT 42
7357
-#define OP_AddImm 43
7358
-#define OP_RowData 44
7359
-#define OP_MemMax 45
7360
-#define OP_Or 66 /* same as TK_OR */
7361
-#define OP_NotExists 46
7362
-#define OP_Gosub 47
7363
-#define OP_Divide 87 /* same as TK_SLASH */
7364
-#define OP_Integer 48
7352
+#define OP_Multiply 88 /* same as TK_STAR */
7353
+#define OP_FkCounter 28
7354
+#define OP_Variable 29
7355
+#define OP_String 30
7356
+#define OP_RealAffinity 31
7357
+#define OP_VRename 32
7358
+#define OP_ParseSchema 33
7359
+#define OP_VOpen 34
7360
+#define OP_Close 35
7361
+#define OP_CreateIndex 36
7362
+#define OP_IsUnique 37
7363
+#define OP_NotFound 38
7364
+#define OP_Int64 39
7365
+#define OP_MustBeInt 40
7366
+#define OP_Halt 41
7367
+#define OP_Rowid 42
7368
+#define OP_IdxLT 43
7369
+#define OP_AddImm 44
7370
+#define OP_RowData 45
7371
+#define OP_MemMax 46
7372
+#define OP_Or 68 /* same as TK_OR */
7373
+#define OP_NotExists 47
7374
+#define OP_Gosub 48
7375
+#define OP_Divide 89 /* same as TK_SLASH */
7376
+#define OP_Integer 49
73657377
#define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/
7366
-#define OP_Prev 49
7367
-#define OP_RowSetRead 50
7368
-#define OP_Concat 89 /* same as TK_CONCAT */
7369
-#define OP_RowSetAdd 51
7370
-#define OP_BitAnd 80 /* same as TK_BITAND */
7371
-#define OP_VColumn 52
7372
-#define OP_CreateTable 53
7373
-#define OP_Last 54
7374
-#define OP_SeekLe 55
7375
-#define OP_IsNull 71 /* same as TK_ISNULL */
7376
-#define OP_IncrVacuum 56
7377
-#define OP_IdxRowid 57
7378
-#define OP_ShiftRight 83 /* same as TK_RSHIFT */
7379
-#define OP_ResetCount 58
7380
-#define OP_Yield 59
7381
-#define OP_DropTrigger 60
7382
-#define OP_DropIndex 61
7383
-#define OP_Param 62
7384
-#define OP_IdxGE 63
7385
-#define OP_IdxDelete 64
7386
-#define OP_Vacuum 65
7387
-#define OP_IfNot 68
7388
-#define OP_DropTable 69
7389
-#define OP_SeekLt 70
7390
-#define OP_MakeRecord 79
7378
+#define OP_Prev 50
7379
+#define OP_RowSetRead 51
7380
+#define OP_Concat 91 /* same as TK_CONCAT */
7381
+#define OP_RowSetAdd 52
7382
+#define OP_BitAnd 82 /* same as TK_BITAND */
7383
+#define OP_VColumn 53
7384
+#define OP_CreateTable 54
7385
+#define OP_Last 55
7386
+#define OP_SeekLe 56
7387
+#define OP_IsNull 73 /* same as TK_ISNULL */
7388
+#define OP_IncrVacuum 57
7389
+#define OP_IdxRowid 58
7390
+#define OP_ShiftRight 85 /* same as TK_RSHIFT */
7391
+#define OP_ResetCount 59
7392
+#define OP_Yield 60
7393
+#define OP_DropTrigger 61
7394
+#define OP_DropIndex 62
7395
+#define OP_Param 63
7396
+#define OP_IdxGE 64
7397
+#define OP_IdxDelete 65
7398
+#define OP_Vacuum 66
7399
+#define OP_IfNot 67
7400
+#define OP_DropTable 70
7401
+#define OP_SeekLt 71
7402
+#define OP_MakeRecord 72
73917403
#define OP_ToBlob 142 /* same as TK_TO_BLOB */
7392
-#define OP_ResultRow 90
7393
-#define OP_Delete 91
7394
-#define OP_AggFinal 92
7395
-#define OP_Compare 95
7396
-#define OP_ShiftLeft 82 /* same as TK_LSHIFT */
7397
-#define OP_Goto 96
7398
-#define OP_TableLock 97
7399
-#define OP_Clear 98
7400
-#define OP_Le 76 /* same as TK_LE */
7401
-#define OP_VerifyCookie 99
7402
-#define OP_AggStep 100
7404
+#define OP_ResultRow 81
7405
+#define OP_Delete 92
7406
+#define OP_AggFinal 95
7407
+#define OP_Compare 96
7408
+#define OP_ShiftLeft 84 /* same as TK_LSHIFT */
7409
+#define OP_Goto 97
7410
+#define OP_TableLock 98
7411
+#define OP_Clear 99
7412
+#define OP_Le 78 /* same as TK_LE */
7413
+#define OP_VerifyCookie 100
7414
+#define OP_AggStep 101
74037415
#define OP_ToText 141 /* same as TK_TO_TEXT */
74047416
#define OP_Not 19 /* same as TK_NOT */
74057417
#define OP_ToReal 145 /* same as TK_TO_REAL */
7406
-#define OP_Transaction 101
7407
-#define OP_VFilter 102
7408
-#define OP_Ne 73 /* same as TK_NE */
7409
-#define OP_VDestroy 103
7410
-#define OP_BitOr 81 /* same as TK_BITOR */
7411
-#define OP_Next 104
7412
-#define OP_Count 105
7413
-#define OP_IdxInsert 106
7414
-#define OP_Lt 77 /* same as TK_LT */
7415
-#define OP_SeekGe 107
7416
-#define OP_Insert 108
7417
-#define OP_Destroy 109
7418
-#define OP_ReadCookie 110
7419
-#define OP_RowSetTest 111
7420
-#define OP_LoadAnalysis 112
7421
-#define OP_Explain 113
7422
-#define OP_HaltIfNull 114
7423
-#define OP_OpenPseudo 115
7424
-#define OP_OpenEphemeral 116
7425
-#define OP_Null 117
7426
-#define OP_Move 118
7427
-#define OP_Blob 119
7428
-#define OP_Add 84 /* same as TK_PLUS */
7429
-#define OP_Rewind 120
7430
-#define OP_SeekGt 121
7431
-#define OP_VBegin 122
7432
-#define OP_VUpdate 123
7433
-#define OP_IfZero 124
7418
+#define OP_Transaction 102
7419
+#define OP_VFilter 103
7420
+#define OP_Ne 75 /* same as TK_NE */
7421
+#define OP_VDestroy 104
7422
+#define OP_BitOr 83 /* same as TK_BITOR */
7423
+#define OP_Next 105
7424
+#define OP_Count 106
7425
+#define OP_IdxInsert 107
7426
+#define OP_Lt 79 /* same as TK_LT */
7427
+#define OP_FkIfZero 108
7428
+#define OP_SeekGe 109
7429
+#define OP_Insert 110
7430
+#define OP_Destroy 111
7431
+#define OP_ReadCookie 112
7432
+#define OP_RowSetTest 113
7433
+#define OP_LoadAnalysis 114
7434
+#define OP_Explain 115
7435
+#define OP_HaltIfNull 116
7436
+#define OP_OpenPseudo 117
7437
+#define OP_OpenEphemeral 118
7438
+#define OP_Null 119
7439
+#define OP_Move 120
7440
+#define OP_Blob 121
7441
+#define OP_Add 86 /* same as TK_PLUS */
7442
+#define OP_Rewind 122
7443
+#define OP_SeekGt 123
7444
+#define OP_VBegin 124
7445
+#define OP_VUpdate 125
7446
+#define OP_IfZero 126
74347447
#define OP_BitNot 93 /* same as TK_BITNOT */
7435
-#define OP_VCreate 125
7436
-#define OP_Found 126
7437
-#define OP_IfPos 127
7438
-#define OP_NullRow 128
7439
-#define OP_Jump 129
7440
-#define OP_Permutation 131
7448
+#define OP_VCreate 127
7449
+#define OP_Found 128
7450
+#define OP_IfPos 129
7451
+#define OP_NullRow 131
7452
+#define OP_Jump 132
7453
+#define OP_Permutation 133
74417454
74427455
/* The following opcode values are never used */
7443
-#define OP_NotUsed_132 132
7444
-#define OP_NotUsed_133 133
74457456
#define OP_NotUsed_134 134
74467457
#define OP_NotUsed_135 135
74477458
#define OP_NotUsed_136 136
74487459
#define OP_NotUsed_137 137
74497460
#define OP_NotUsed_138 138
@@ -7463,24 +7474,24 @@
74637474
#define OPFLG_OUT3 0x0020 /* out3: P3 is an output */
74647475
#define OPFLG_INITIALIZER {\
74657476
/* 0 */ 0x00, 0x01, 0x00, 0x00, 0x10, 0x08, 0x02, 0x00,\
74667477
/* 8 */ 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00,\
74677478
/* 16 */ 0x02, 0x00, 0x01, 0x04, 0x04, 0x00, 0x00, 0x05,\
7468
-/* 24 */ 0x00, 0x01, 0x04, 0x02, 0x00, 0x02, 0x04, 0x00,\
7469
-/* 32 */ 0x00, 0x00, 0x00, 0x02, 0x11, 0x11, 0x02, 0x05,\
7470
-/* 40 */ 0x00, 0x02, 0x11, 0x04, 0x00, 0x08, 0x11, 0x01,\
7471
-/* 48 */ 0x02, 0x01, 0x21, 0x08, 0x00, 0x02, 0x01, 0x11,\
7472
-/* 56 */ 0x01, 0x02, 0x00, 0x04, 0x00, 0x00, 0x02, 0x11,\
7473
-/* 64 */ 0x00, 0x00, 0x2c, 0x2c, 0x05, 0x00, 0x11, 0x05,\
7474
-/* 72 */ 0x05, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x00,\
7475
-/* 80 */ 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c,\
7476
-/* 88 */ 0x2c, 0x2c, 0x00, 0x00, 0x00, 0x04, 0x02, 0x00,\
7477
-/* 96 */ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,\
7478
-/* 104 */ 0x01, 0x02, 0x08, 0x11, 0x00, 0x02, 0x02, 0x15,\
7479
-/* 112 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x00, 0x02,\
7480
-/* 120 */ 0x01, 0x11, 0x00, 0x00, 0x05, 0x00, 0x11, 0x05,\
7481
-/* 128 */ 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,\
7479
+/* 24 */ 0x00, 0x01, 0x04, 0x02, 0x00, 0x00, 0x02, 0x04,\
7480
+/* 32 */ 0x00, 0x00, 0x00, 0x00, 0x02, 0x11, 0x11, 0x02,\
7481
+/* 40 */ 0x05, 0x00, 0x02, 0x11, 0x04, 0x00, 0x08, 0x11,\
7482
+/* 48 */ 0x01, 0x02, 0x01, 0x21, 0x08, 0x00, 0x02, 0x01,\
7483
+/* 56 */ 0x11, 0x01, 0x02, 0x00, 0x04, 0x00, 0x00, 0x02,\
7484
+/* 64 */ 0x11, 0x00, 0x00, 0x05, 0x2c, 0x2c, 0x00, 0x11,\
7485
+/* 72 */ 0x00, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
7486
+/* 80 */ 0x15, 0x00, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c,\
7487
+/* 88 */ 0x2c, 0x2c, 0x2c, 0x2c, 0x00, 0x04, 0x02, 0x00,\
7488
+/* 96 */ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,\
7489
+/* 104 */ 0x00, 0x01, 0x02, 0x08, 0x01, 0x11, 0x00, 0x02,\
7490
+/* 112 */ 0x02, 0x15, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02,\
7491
+/* 120 */ 0x00, 0x02, 0x01, 0x11, 0x00, 0x00, 0x05, 0x00,\
7492
+/* 128 */ 0x11, 0x05, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00,\
74827493
/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04,\
74837494
/* 144 */ 0x04, 0x04,}
74847495
74857496
/************** End of opcodes.h *********************************************/
74867497
/************** Continuing where we left off in vdbe.h ***********************/
@@ -8233,11 +8244,11 @@
82338244
#define sqlite3_mutex_held(X) 1
82348245
#define sqlite3_mutex_notheld(X) 1
82358246
#define sqlite3MutexAlloc(X) ((sqlite3_mutex*)8)
82368247
#define sqlite3MutexInit() SQLITE_OK
82378248
#define sqlite3MutexEnd()
8238
-#endif /* defined(SQLITE_OMIT_MUTEX) */
8249
+#endif /* defined(SQLITE_MUTEX_OMIT) */
82398250
82408251
/************** End of mutex.h ***********************************************/
82418252
/************** Continuing where we left off in sqliteInt.h ******************/
82428253
82438254
@@ -8270,10 +8281,11 @@
82708281
struct Schema {
82718282
int schema_cookie; /* Database schema version number for this file */
82728283
Hash tblHash; /* All tables indexed by name */
82738284
Hash idxHash; /* All (named) indices indexed by name */
82748285
Hash trigHash; /* All triggers indexed by name */
8286
+ Hash fkeyHash; /* All foreign keys by referenced table name */
82758287
Table *pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */
82768288
u8 file_format; /* Schema format version for this file */
82778289
u8 enc; /* Text encoding used by this database */
82788290
u16 flags; /* Flags associated with this schema */
82798291
int cache_size; /* Number of pages to use in the cache */
@@ -8460,10 +8472,11 @@
84608472
Db aDbStatic[2]; /* Static space for the 2 default backends */
84618473
Savepoint *pSavepoint; /* List of active savepoints */
84628474
int nSavepoint; /* Number of non-transaction savepoints */
84638475
int nStatement; /* Number of nested statement-transactions */
84648476
u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
8477
+ i64 nDeferredCons; /* Net deferred constraints this transaction. */
84658478
84668479
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
84678480
/* The following variables are all protected by the STATIC_MASTER
84688481
** mutex, not by sqlite3.mutex. They are used by code in notify.c.
84698482
**
@@ -8516,10 +8529,11 @@
85168529
#define SQLITE_LoadExtension 0x00020000 /* Enable load_extension */
85178530
85188531
#define SQLITE_RecoveryMode 0x00040000 /* Ignore schema errors */
85198532
#define SQLITE_ReverseOrder 0x00100000 /* Reverse unordered SELECTs */
85208533
#define SQLITE_RecTriggers 0x00200000 /* Enable recursive triggers */
8534
+#define SQLITE_ForeignKeys 0x00400000 /* Enforce foreign key constraints */
85218535
85228536
/*
85238537
** Possible values for the sqlite.magic field.
85248538
** The numbers are obtained at random and have no special meaning, other
85258539
** than being distinct from one another.
@@ -8602,10 +8616,11 @@
86028616
** opened savepoint. Savepoints are added to the list by the vdbe
86038617
** OP_Savepoint instruction.
86048618
*/
86058619
struct Savepoint {
86068620
char *zName; /* Savepoint name (nul-terminated) */
8621
+ int nDeferredCons; /* Number of deferred fk violations */
86078622
Savepoint *pNext; /* Parent savepoint (if any) */
86088623
};
86098624
86108625
/*
86118626
** The following are used as the second parameter to sqlite3Savepoint(),
@@ -8722,10 +8737,11 @@
87228737
** Additional bit values that can be ORed with an affinity without
87238738
** changing the affinity.
87248739
*/
87258740
#define SQLITE_JUMPIFNULL 0x08 /* jumps if either operand is NULL */
87268741
#define SQLITE_STOREP2 0x10 /* Store result in reg[P2] rather than jump */
8742
+#define SQLITE_NULLEQ 0x80 /* NULL=NULL */
87278743
87288744
/*
87298745
** An object of this type is created for each virtual table present in
87308746
** the database schema.
87318747
**
@@ -8878,18 +8894,20 @@
88788894
** Each REFERENCES clause generates an instance of the following structure
88798895
** which is attached to the from-table. The to-table need not exist when
88808896
** the from-table is created. The existence of the to-table is not checked.
88818897
*/
88828898
struct FKey {
8883
- Table *pFrom; /* The table that contains the REFERENCES clause */
8899
+ Table *pFrom; /* Table containing the REFERENCES clause (aka: Child) */
88848900
FKey *pNextFrom; /* Next foreign key in pFrom */
8885
- char *zTo; /* Name of table that the key points to */
8901
+ char *zTo; /* Name of table that the key points to (aka: Parent) */
8902
+ FKey *pNextTo; /* Next foreign key on table named zTo */
8903
+ FKey *pPrevTo; /* Previous foreign key on table named zTo */
88868904
int nCol; /* Number of columns in this key */
8905
+ /* EV: R-30323-21917 */
88878906
u8 isDeferred; /* True if constraint checking is deferred till COMMIT */
8888
- u8 updateConf; /* How to resolve conflicts that occur on UPDATE */
8889
- u8 deleteConf; /* How to resolve conflicts that occur on DELETE */
8890
- u8 insertConf; /* How to resolve conflicts that occur on INSERT */
8907
+ u8 aAction[2]; /* ON DELETE and ON UPDATE actions, respectively */
8908
+ Trigger *apTrigger[2]; /* Triggers for aAction[] actions */
88918909
struct sColMap { /* Mapping of columns in pFrom to columns in zTo */
88928910
int iFrom; /* Index of column in pFrom */
88938911
char *zCol; /* Name of column in zTo. If 0 use PRIMARY KEY */
88948912
} aCol[1]; /* One entry for each of nCol column s */
88958913
};
@@ -9716,10 +9734,11 @@
97169734
Parse *pToplevel; /* Parse structure for main program (or NULL) */
97179735
Table *pTriggerTab; /* Table triggers are being coded for */
97189736
u32 oldmask; /* Mask of old.* columns referenced */
97199737
u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */
97209738
u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */
9739
+ u8 disableTriggers; /* True to disable triggers */
97219740
97229741
/* Above is constant between recursions. Below is reset before and after
97239742
** each recursion */
97249743
97259744
int nVar; /* Number of '?' variables seen in the SQL so far */
@@ -10186,11 +10205,11 @@
1018610205
SQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *, struct SrcList_item *);
1018710206
SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
1018810207
SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
1018910208
SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);
1019010209
SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);
10191
-SQLITE_PRIVATE void sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
10210
+SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
1019210211
Token*, int, int);
1019310212
SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
1019410213
SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
1019510214
SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
1019610215
Expr*,ExprList*,int,Expr*,Expr*);
@@ -10257,11 +10276,12 @@
1025710276
SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int,
1025810277
int*,int,int,int,int,int*);
1025910278
SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int);
1026010279
SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int);
1026110280
SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
10262
-SQLITE_PRIVATE void sqlite3MayAbort(Parse *);
10281
+SQLITE_PRIVATE void sqlite3MultiWrite(Parse*);
10282
+SQLITE_PRIVATE void sqlite3MayAbort(Parse*);
1026310283
SQLITE_PRIVATE void sqlite3HaltConstraint(Parse*, int, char*, int);
1026410284
SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int);
1026510285
SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);
1026610286
SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
1026710287
SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);
@@ -10293,31 +10313,33 @@
1029310313
SQLITE_PRIVATE void sqlite3DropTrigger(Parse*, SrcList*, int);
1029410314
SQLITE_PRIVATE void sqlite3DropTriggerPtr(Parse*, Trigger*);
1029510315
SQLITE_PRIVATE Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask);
1029610316
SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *, Table *);
1029710317
SQLITE_PRIVATE void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *,
10298
- int, int, int, int);
10318
+ int, int, int);
10319
+SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);
1029910320
void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);
1030010321
SQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);
1030110322
SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*);
1030210323
SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*,
1030310324
ExprList*,Select*,u8);
1030410325
SQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8);
1030510326
SQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*);
1030610327
SQLITE_PRIVATE void sqlite3DeleteTrigger(sqlite3*, Trigger*);
1030710328
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
10308
-SQLITE_PRIVATE u32 sqlite3TriggerOldmask(Parse*,Trigger*,int,ExprList*,Table*,int);
10329
+SQLITE_PRIVATE u32 sqlite3TriggerOldmask(Parse*,Trigger*,ExprList*,Table*,int);
1030910330
# define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p))
1031010331
#else
1031110332
# define sqlite3TriggersExist(B,C,D,E,F) 0
1031210333
# define sqlite3DeleteTrigger(A,B)
1031310334
# define sqlite3DropTriggerPtr(A,B)
1031410335
# define sqlite3UnlinkAndDeleteTrigger(A,B,C)
10315
-# define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I,J)
10336
+# define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I)
10337
+# define sqlite3CodeRowTriggerDirect(A,B,C,D,E,F)
1031610338
# define sqlite3TriggerList(X, Y) 0
1031710339
# define sqlite3ParseToplevel(p) p
10318
-# define sqlite3TriggerOldmask(A,B,C,D,E,F) 0
10340
+# define sqlite3TriggerOldmask(A,B,C,D,E) 0
1031910341
#endif
1032010342
1032110343
SQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*);
1032210344
SQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);
1032310345
SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int);
@@ -10324,10 +10346,11 @@
1032410346
#ifndef SQLITE_OMIT_AUTHORIZATION
1032510347
SQLITE_PRIVATE void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*);
1032610348
SQLITE_PRIVATE int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*);
1032710349
SQLITE_PRIVATE void sqlite3AuthContextPush(Parse*, AuthContext*, const char*);
1032810350
SQLITE_PRIVATE void sqlite3AuthContextPop(AuthContext*);
10351
+SQLITE_PRIVATE int sqlite3AuthReadCol(Parse*, const char *, const char *, int);
1032910352
#else
1033010353
# define sqlite3AuthRead(a,b,c,d)
1033110354
# define sqlite3AuthCheck(a,b,c,d,e) SQLITE_OK
1033210355
# define sqlite3AuthContextPush(a,b,c)
1033310356
# define sqlite3AuthContextPop(a) ((void)(a))
@@ -10531,10 +10554,36 @@
1053110554
SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
1053210555
SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
1053310556
SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*);
1053410557
SQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3*, Table*);
1053510558
10559
+/* Declarations for functions in fkey.c. All of these are replaced by
10560
+** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign
10561
+** key functionality is available. If OMIT_TRIGGER is defined but
10562
+** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In
10563
+** this case foreign keys are parsed, but no other functionality is
10564
+** provided (enforcement of FK constraints requires the triggers sub-system).
10565
+*/
10566
+#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
10567
+SQLITE_PRIVATE void sqlite3FkCheck(Parse*, Table*, int, int);
10568
+SQLITE_PRIVATE void sqlite3FkDropTable(Parse*, SrcList *, Table*);
10569
+SQLITE_PRIVATE void sqlite3FkActions(Parse*, Table*, ExprList*, int);
10570
+SQLITE_PRIVATE int sqlite3FkRequired(Parse*, Table*, int*, int);
10571
+SQLITE_PRIVATE u32 sqlite3FkOldmask(Parse*, Table*);
10572
+SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
10573
+#else
10574
+ #define sqlite3FkActions(a,b,c,d)
10575
+ #define sqlite3FkCheck(a,b,c,d)
10576
+ #define sqlite3FkDropTable(a,b,c)
10577
+ #define sqlite3FkOldmask(a,b) 0
10578
+ #define sqlite3FkRequired(a,b,c,d) 0
10579
+#endif
10580
+#ifndef SQLITE_OMIT_FOREIGN_KEY
10581
+SQLITE_PRIVATE void sqlite3FkDelete(Table*);
10582
+#else
10583
+ #define sqlite3FkDelete(a)
10584
+#endif
1053610585
1053710586
1053810587
/*
1053910588
** Available fault injectors. Should be numbered beginning with 0.
1054010589
*/
@@ -11389,11 +11438,11 @@
1138911438
y.D = sLocal.tm_mday;
1139011439
y.h = sLocal.tm_hour;
1139111440
y.m = sLocal.tm_min;
1139211441
y.s = sLocal.tm_sec;
1139311442
}
11394
-#elif defined(HAVE_LOCALTIME_S)
11443
+#elif defined(HAVE_LOCALTIME_S) && HAVE_LOCALTIME_S
1139511444
{
1139611445
struct tm sLocal;
1139711446
localtime_s(&sLocal, &t);
1139811447
y.Y = sLocal.tm_year + 1900;
1139911448
y.M = sLocal.tm_mon + 1;
@@ -13665,10 +13714,11 @@
1366513714
/*
1366613715
** Deinitialize this module.
1366713716
*/
1366813717
static void memsys3Shutdown(void *NotUsed){
1366913718
UNUSED_PARAMETER(NotUsed);
13719
+ mem3.mutex = 0;
1367013720
return;
1367113721
}
1367213722
1367313723
1367413724
@@ -14505,11 +14555,11 @@
1450514555
SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){
1450614556
return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);
1450714557
}
1450814558
#endif
1450914559
14510
-#endif /* SQLITE_OMIT_MUTEX */
14560
+#endif /* SQLITE_MUTEX_OMIT */
1451114561
1451214562
/************** End of mutex.c ***********************************************/
1451314563
/************** Begin file mutex_noop.c **************************************/
1451414564
/*
1451514565
** 2008 October 07
@@ -17770,10 +17820,12 @@
1777017820
i64 startTime; /* Time when query started - used for profiling */
1777117821
BtreeMutexArray aMutex; /* An array of Btree used here and needing locks */
1777217822
int aCounter[2]; /* Counters used by sqlite3_stmt_status() */
1777317823
char *zSql; /* Text of the SQL statement that generated this */
1777417824
void *pFree; /* Free this when deleting the vdbe */
17825
+ i64 nFkConstraint; /* Number of imm. FK constraints this VM */
17826
+ i64 nStmtDefCons; /* Number of def. constraints when stmt started */
1777517827
int iStatement; /* Statement number (or 0 if has not opened stmt) */
1777617828
#ifdef SQLITE_DEBUG
1777717829
FILE *trace; /* Write an execution trace here, if not NULL */
1777817830
#endif
1777917831
VdbeFrame *pFrame; /* Parent frame */
@@ -17841,10 +17893,16 @@
1784117893
SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*);
1784217894
SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);
1784317895
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
1784417896
SQLITE_PRIVATE int sqlite3VdbeReleaseBuffers(Vdbe *p);
1784517897
#endif
17898
+
17899
+#ifndef SQLITE_OMIT_FOREIGN_KEY
17900
+SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *, int);
17901
+#else
17902
+# define sqlite3VdbeCheckFk(p,i) 0
17903
+#endif
1784617904
1784717905
#ifndef SQLITE_OMIT_SHARED_CACHE
1784817906
SQLITE_PRIVATE void sqlite3VdbeMutexArrayEnter(Vdbe *p);
1784917907
#else
1785017908
# define sqlite3VdbeMutexArrayEnter(p)
@@ -19803,116 +19861,116 @@
1980319861
/* 23 */ "IfNeg",
1980419862
/* 24 */ "Noop",
1980519863
/* 25 */ "Program",
1980619864
/* 26 */ "Return",
1980719865
/* 27 */ "NewRowid",
19808
- /* 28 */ "Variable",
19809
- /* 29 */ "String",
19810
- /* 30 */ "RealAffinity",
19811
- /* 31 */ "VRename",
19812
- /* 32 */ "ParseSchema",
19813
- /* 33 */ "VOpen",
19814
- /* 34 */ "Close",
19815
- /* 35 */ "CreateIndex",
19816
- /* 36 */ "IsUnique",
19817
- /* 37 */ "NotFound",
19818
- /* 38 */ "Int64",
19819
- /* 39 */ "MustBeInt",
19820
- /* 40 */ "Halt",
19821
- /* 41 */ "Rowid",
19822
- /* 42 */ "IdxLT",
19823
- /* 43 */ "AddImm",
19824
- /* 44 */ "RowData",
19825
- /* 45 */ "MemMax",
19826
- /* 46 */ "NotExists",
19827
- /* 47 */ "Gosub",
19828
- /* 48 */ "Integer",
19829
- /* 49 */ "Prev",
19830
- /* 50 */ "RowSetRead",
19831
- /* 51 */ "RowSetAdd",
19832
- /* 52 */ "VColumn",
19833
- /* 53 */ "CreateTable",
19834
- /* 54 */ "Last",
19835
- /* 55 */ "SeekLe",
19836
- /* 56 */ "IncrVacuum",
19837
- /* 57 */ "IdxRowid",
19838
- /* 58 */ "ResetCount",
19839
- /* 59 */ "Yield",
19840
- /* 60 */ "DropTrigger",
19841
- /* 61 */ "DropIndex",
19842
- /* 62 */ "Param",
19843
- /* 63 */ "IdxGE",
19844
- /* 64 */ "IdxDelete",
19845
- /* 65 */ "Vacuum",
19846
- /* 66 */ "Or",
19847
- /* 67 */ "And",
19848
- /* 68 */ "IfNot",
19849
- /* 69 */ "DropTable",
19850
- /* 70 */ "SeekLt",
19851
- /* 71 */ "IsNull",
19852
- /* 72 */ "NotNull",
19853
- /* 73 */ "Ne",
19854
- /* 74 */ "Eq",
19855
- /* 75 */ "Gt",
19856
- /* 76 */ "Le",
19857
- /* 77 */ "Lt",
19858
- /* 78 */ "Ge",
19859
- /* 79 */ "MakeRecord",
19860
- /* 80 */ "BitAnd",
19861
- /* 81 */ "BitOr",
19862
- /* 82 */ "ShiftLeft",
19863
- /* 83 */ "ShiftRight",
19864
- /* 84 */ "Add",
19865
- /* 85 */ "Subtract",
19866
- /* 86 */ "Multiply",
19867
- /* 87 */ "Divide",
19868
- /* 88 */ "Remainder",
19869
- /* 89 */ "Concat",
19870
- /* 90 */ "ResultRow",
19871
- /* 91 */ "Delete",
19872
- /* 92 */ "AggFinal",
19866
+ /* 28 */ "FkCounter",
19867
+ /* 29 */ "Variable",
19868
+ /* 30 */ "String",
19869
+ /* 31 */ "RealAffinity",
19870
+ /* 32 */ "VRename",
19871
+ /* 33 */ "ParseSchema",
19872
+ /* 34 */ "VOpen",
19873
+ /* 35 */ "Close",
19874
+ /* 36 */ "CreateIndex",
19875
+ /* 37 */ "IsUnique",
19876
+ /* 38 */ "NotFound",
19877
+ /* 39 */ "Int64",
19878
+ /* 40 */ "MustBeInt",
19879
+ /* 41 */ "Halt",
19880
+ /* 42 */ "Rowid",
19881
+ /* 43 */ "IdxLT",
19882
+ /* 44 */ "AddImm",
19883
+ /* 45 */ "RowData",
19884
+ /* 46 */ "MemMax",
19885
+ /* 47 */ "NotExists",
19886
+ /* 48 */ "Gosub",
19887
+ /* 49 */ "Integer",
19888
+ /* 50 */ "Prev",
19889
+ /* 51 */ "RowSetRead",
19890
+ /* 52 */ "RowSetAdd",
19891
+ /* 53 */ "VColumn",
19892
+ /* 54 */ "CreateTable",
19893
+ /* 55 */ "Last",
19894
+ /* 56 */ "SeekLe",
19895
+ /* 57 */ "IncrVacuum",
19896
+ /* 58 */ "IdxRowid",
19897
+ /* 59 */ "ResetCount",
19898
+ /* 60 */ "Yield",
19899
+ /* 61 */ "DropTrigger",
19900
+ /* 62 */ "DropIndex",
19901
+ /* 63 */ "Param",
19902
+ /* 64 */ "IdxGE",
19903
+ /* 65 */ "IdxDelete",
19904
+ /* 66 */ "Vacuum",
19905
+ /* 67 */ "IfNot",
19906
+ /* 68 */ "Or",
19907
+ /* 69 */ "And",
19908
+ /* 70 */ "DropTable",
19909
+ /* 71 */ "SeekLt",
19910
+ /* 72 */ "MakeRecord",
19911
+ /* 73 */ "IsNull",
19912
+ /* 74 */ "NotNull",
19913
+ /* 75 */ "Ne",
19914
+ /* 76 */ "Eq",
19915
+ /* 77 */ "Gt",
19916
+ /* 78 */ "Le",
19917
+ /* 79 */ "Lt",
19918
+ /* 80 */ "Ge",
19919
+ /* 81 */ "ResultRow",
19920
+ /* 82 */ "BitAnd",
19921
+ /* 83 */ "BitOr",
19922
+ /* 84 */ "ShiftLeft",
19923
+ /* 85 */ "ShiftRight",
19924
+ /* 86 */ "Add",
19925
+ /* 87 */ "Subtract",
19926
+ /* 88 */ "Multiply",
19927
+ /* 89 */ "Divide",
19928
+ /* 90 */ "Remainder",
19929
+ /* 91 */ "Concat",
19930
+ /* 92 */ "Delete",
1987319931
/* 93 */ "BitNot",
1987419932
/* 94 */ "String8",
19875
- /* 95 */ "Compare",
19876
- /* 96 */ "Goto",
19877
- /* 97 */ "TableLock",
19878
- /* 98 */ "Clear",
19879
- /* 99 */ "VerifyCookie",
19880
- /* 100 */ "AggStep",
19881
- /* 101 */ "Transaction",
19882
- /* 102 */ "VFilter",
19883
- /* 103 */ "VDestroy",
19884
- /* 104 */ "Next",
19885
- /* 105 */ "Count",
19886
- /* 106 */ "IdxInsert",
19887
- /* 107 */ "SeekGe",
19888
- /* 108 */ "Insert",
19889
- /* 109 */ "Destroy",
19890
- /* 110 */ "ReadCookie",
19891
- /* 111 */ "RowSetTest",
19892
- /* 112 */ "LoadAnalysis",
19893
- /* 113 */ "Explain",
19894
- /* 114 */ "HaltIfNull",
19895
- /* 115 */ "OpenPseudo",
19896
- /* 116 */ "OpenEphemeral",
19897
- /* 117 */ "Null",
19898
- /* 118 */ "Move",
19899
- /* 119 */ "Blob",
19900
- /* 120 */ "Rewind",
19901
- /* 121 */ "SeekGt",
19902
- /* 122 */ "VBegin",
19903
- /* 123 */ "VUpdate",
19904
- /* 124 */ "IfZero",
19905
- /* 125 */ "VCreate",
19906
- /* 126 */ "Found",
19907
- /* 127 */ "IfPos",
19908
- /* 128 */ "NullRow",
19909
- /* 129 */ "Jump",
19933
+ /* 95 */ "AggFinal",
19934
+ /* 96 */ "Compare",
19935
+ /* 97 */ "Goto",
19936
+ /* 98 */ "TableLock",
19937
+ /* 99 */ "Clear",
19938
+ /* 100 */ "VerifyCookie",
19939
+ /* 101 */ "AggStep",
19940
+ /* 102 */ "Transaction",
19941
+ /* 103 */ "VFilter",
19942
+ /* 104 */ "VDestroy",
19943
+ /* 105 */ "Next",
19944
+ /* 106 */ "Count",
19945
+ /* 107 */ "IdxInsert",
19946
+ /* 108 */ "FkIfZero",
19947
+ /* 109 */ "SeekGe",
19948
+ /* 110 */ "Insert",
19949
+ /* 111 */ "Destroy",
19950
+ /* 112 */ "ReadCookie",
19951
+ /* 113 */ "RowSetTest",
19952
+ /* 114 */ "LoadAnalysis",
19953
+ /* 115 */ "Explain",
19954
+ /* 116 */ "HaltIfNull",
19955
+ /* 117 */ "OpenPseudo",
19956
+ /* 118 */ "OpenEphemeral",
19957
+ /* 119 */ "Null",
19958
+ /* 120 */ "Move",
19959
+ /* 121 */ "Blob",
19960
+ /* 122 */ "Rewind",
19961
+ /* 123 */ "SeekGt",
19962
+ /* 124 */ "VBegin",
19963
+ /* 125 */ "VUpdate",
19964
+ /* 126 */ "IfZero",
19965
+ /* 127 */ "VCreate",
19966
+ /* 128 */ "Found",
19967
+ /* 129 */ "IfPos",
1991019968
/* 130 */ "Real",
19911
- /* 131 */ "Permutation",
19912
- /* 132 */ "NotUsed_132",
19913
- /* 133 */ "NotUsed_133",
19969
+ /* 131 */ "NullRow",
19970
+ /* 132 */ "Jump",
19971
+ /* 133 */ "Permutation",
1991419972
/* 134 */ "NotUsed_134",
1991519973
/* 135 */ "NotUsed_135",
1991619974
/* 136 */ "NotUsed_136",
1991719975
/* 137 */ "NotUsed_137",
1991819976
/* 138 */ "NotUsed_138",
@@ -22530,11 +22588,11 @@
2253022588
pLock = sqlite3_malloc( sizeof(*pLock) );
2253122589
if( pLock==0 ){
2253222590
rc = SQLITE_NOMEM;
2253322591
goto exit_findlockinfo;
2253422592
}
22535
- pLock->lockKey = lockKey;
22593
+ memcpy(&pLock->lockKey,&lockKey,sizeof(lockKey));
2253622594
pLock->nRef = 1;
2253722595
pLock->cnt = 0;
2253822596
pLock->locktype = 0;
2253922597
pLock->pNext = lockList;
2254022598
pLock->pPrev = 0;
@@ -47336,11 +47394,11 @@
4733647394
if( p->aLabel ){
4733747395
p->aLabel[j] = p->nOp;
4733847396
}
4733947397
}
4734047398
47341
-#ifdef SQLITE_DEBUG
47399
+#ifdef SQLITE_DEBUG /* sqlite3AssertMayAbort() logic */
4734247400
4734347401
/*
4734447402
** The following type and function are used to iterate through all opcodes
4734547403
** in a Vdbe main program and each of the sub-programs (triggers) it may
4734647404
** invoke directly or indirectly. It should be used as follows:
@@ -47408,19 +47466,20 @@
4740847466
return pRet;
4740947467
}
4741047468
4741147469
/*
4741247470
** Check if the program stored in the VM associated with pParse may
47413
-** throw an ABORT exception (causing the statement, but not transaction
47471
+** throw an ABORT exception (causing the statement, but not entire transaction
4741447472
** to be rolled back). This condition is true if the main program or any
4741547473
** sub-programs contains any of the following:
4741647474
**
4741747475
** * OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
4741847476
** * OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
4741947477
** * OP_Destroy
4742047478
** * OP_VUpdate
4742147479
** * OP_VRename
47480
+** * OP_FkCounter with P2==0 (immediate foreign key constraint)
4742247481
**
4742347482
** Then check that the value of Parse.mayAbort is true if an
4742447483
** ABORT may be thrown, or false otherwise. Return true if it does
4742547484
** match, or false otherwise. This function is intended to be used as
4742647485
** part of an assert statement in the compiler. Similar to:
@@ -47435,10 +47494,13 @@
4743547494
sIter.v = v;
4743647495
4743747496
while( (pOp = opIterNext(&sIter))!=0 ){
4743847497
int opcode = pOp->opcode;
4743947498
if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename
47499
+#ifndef SQLITE_OMIT_FOREIGN_KEY
47500
+ || (opcode==OP_FkCounter && pOp->p1==0 && pOp->p2==1)
47501
+#endif
4744047502
|| ((opcode==OP_Halt || opcode==OP_HaltIfNull)
4744147503
&& (pOp->p1==SQLITE_CONSTRAINT && pOp->p2==OE_Abort))
4744247504
){
4744347505
hasAbort = 1;
4744447506
break;
@@ -47451,11 +47513,11 @@
4745147513
** through all opcodes and hasAbort may be set incorrectly. Return
4745247514
** true for this case to prevent the assert() in the callers frame
4745347515
** from failing. */
4745447516
return ( v->db->mallocFailed || hasAbort==mayAbort );
4745547517
}
47456
-#endif
47518
+#endif /* SQLITE_DEBUG - the sqlite3AssertMayAbort() function */
4745747519
4745847520
/*
4745947521
** Loop through the program looking for P2 values that are negative
4746047522
** on jump instructions. Each such value is a label. Resolve the
4746147523
** label by setting the P2 value to its correct non-zero value.
@@ -48991,10 +49053,17 @@
4899149053
}
4899249054
}
4899349055
}
4899449056
db->nStatement--;
4899549057
p->iStatement = 0;
49058
+
49059
+ /* If the statement transaction is being rolled back, also restore the
49060
+ ** database handles deferred constraint counter to the value it had when
49061
+ ** the statement transaction was opened. */
49062
+ if( eOp==SAVEPOINT_ROLLBACK ){
49063
+ db->nDeferredCons = p->nStmtDefCons;
49064
+ }
4899649065
}
4899749066
return rc;
4899849067
}
4899949068
4900049069
/*
@@ -49022,10 +49091,33 @@
4902249091
sqlite3BtreeEnterAll(p->db);
4902349092
#endif
4902449093
}
4902549094
#endif
4902649095
49096
+/*
49097
+** This function is called when a transaction opened by the database
49098
+** handle associated with the VM passed as an argument is about to be
49099
+** committed. If there are outstanding deferred foreign key constraint
49100
+** violations, return SQLITE_ERROR. Otherwise, SQLITE_OK.
49101
+**
49102
+** If there are outstanding FK violations and this function returns
49103
+** SQLITE_ERROR, set the result of the VM to SQLITE_CONSTRAINT and write
49104
+** an error message to it. Then return SQLITE_ERROR.
49105
+*/
49106
+#ifndef SQLITE_OMIT_FOREIGN_KEY
49107
+SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *p, int deferred){
49108
+ sqlite3 *db = p->db;
49109
+ if( (deferred && db->nDeferredCons>0) || (!deferred && p->nFkConstraint>0) ){
49110
+ p->rc = SQLITE_CONSTRAINT;
49111
+ p->errorAction = OE_Abort;
49112
+ sqlite3SetString(&p->zErrMsg, db, "foreign key constraint failed");
49113
+ return SQLITE_ERROR;
49114
+ }
49115
+ return SQLITE_OK;
49116
+}
49117
+#endif
49118
+
4902749119
/*
4902849120
** This routine is called the when a VDBE tries to halt. If the VDBE
4902949121
** has made changes and is in autocommit mode, then commit those
4903049122
** changes. If a rollback is needed, then do the rollback.
4903149123
**
@@ -49096,10 +49188,15 @@
4909649188
sqlite3CloseSavepoints(db);
4909749189
db->autoCommit = 1;
4909849190
}
4909949191
}
4910049192
}
49193
+
49194
+ /* Check for immediate foreign key violations. */
49195
+ if( p->rc==SQLITE_OK ){
49196
+ sqlite3VdbeCheckFk(p, 0);
49197
+ }
4910149198
4910249199
/* If the auto-commit flag is set and this is the only active writer
4910349200
** VM, then we do either a commit or rollback of the current transaction.
4910449201
**
4910549202
** Note: This block also runs if one of the special errors handled
@@ -49108,22 +49205,27 @@
4910849205
if( !sqlite3VtabInSync(db)
4910949206
&& db->autoCommit
4911049207
&& db->writeVdbeCnt==(p->readOnly==0)
4911149208
){
4911249209
if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){
49113
- /* The auto-commit flag is true, and the vdbe program was
49114
- ** successful or hit an 'OR FAIL' constraint. This means a commit
49115
- ** is required.
49116
- */
49210
+ if( sqlite3VdbeCheckFk(p, 1) ){
49211
+ sqlite3BtreeMutexArrayLeave(&p->aMutex);
49212
+ return SQLITE_ERROR;
49213
+ }
49214
+ /* The auto-commit flag is true, the vdbe program was successful
49215
+ ** or hit an 'OR FAIL' constraint and there are no deferred foreign
49216
+ ** key constraints to hold up the transaction. This means a commit
49217
+ ** is required. */
4911749218
rc = vdbeCommit(db, p);
4911849219
if( rc==SQLITE_BUSY ){
4911949220
sqlite3BtreeMutexArrayLeave(&p->aMutex);
4912049221
return SQLITE_BUSY;
4912149222
}else if( rc!=SQLITE_OK ){
4912249223
p->rc = rc;
4912349224
sqlite3RollbackAll(db);
4912449225
}else{
49226
+ db->nDeferredCons = 0;
4912549227
sqlite3CommitInternalChanges(db);
4912649228
}
4912749229
}else{
4912849230
sqlite3RollbackAll(db);
4912949231
}
@@ -50400,10 +50502,12 @@
5040050502
*/
5040150503
if( db->activeVdbeCnt==0 ){
5040250504
db->u1.isInterrupted = 0;
5040350505
}
5040450506
50507
+ assert( db->writeVdbeCnt>0 || db->autoCommit==0 || db->nDeferredCons==0 );
50508
+
5040550509
#ifndef SQLITE_OMIT_TRACE
5040650510
if( db->xProfile && !db->init.busy ){
5040750511
double rNow;
5040850512
sqlite3OsCurrentTime(db->pVfs, &rNow);
5040950513
p->startTime = (u64)((rNow - (int)rNow)*3600.0*24.0*1000000000.0);
@@ -51381,10 +51485,21 @@
5138151485
sqlite3_max_blobsize = p->n;
5138251486
}
5138351487
}
5138451488
#endif
5138551489
51490
+/*
51491
+** The next global variable is incremented each type the OP_Found opcode
51492
+** is executed. This is used to test whether or not the foreign key
51493
+** operation implemented using OP_FkIsZero is working. This variable
51494
+** has no function other than to help verify the correct operation of the
51495
+** library.
51496
+*/
51497
+#ifdef SQLITE_TEST
51498
+SQLITE_API int sqlite3_found_count = 0;
51499
+#endif
51500
+
5138651501
/*
5138751502
** Test a register to see if it exceeds the current maximum blob size.
5138851503
** If it does, record the new maximum blob size.
5138951504
*/
5139051505
#if defined(SQLITE_TEST) && !defined(SQLITE_OMIT_BUILTIN_TEST)
@@ -51990,13 +52105,12 @@
5199052105
struct OP_ShiftRight_stack_vars {
5199152106
i64 a;
5199252107
i64 b;
5199352108
} ah;
5199452109
struct OP_Ge_stack_vars {
51995
- int flags;
51996
- int res;
51997
- char affinity;
52110
+ int res; /* Result of the comparison of pIn1 against pIn3 */
52111
+ char affinity; /* Affinity to use for comparison */
5199852112
} ai;
5199952113
struct OP_Compare_stack_vars {
5200052114
int n;
5200152115
int i;
5200252116
int p1;
@@ -52653,14 +52767,16 @@
5265352767
p->pc = pc;
5265452768
if( pOp->p4.z ){
5265552769
sqlite3SetString(&p->zErrMsg, db, "%s", pOp->p4.z);
5265652770
}
5265752771
rc = sqlite3VdbeHalt(p);
52658
- assert( rc==SQLITE_BUSY || rc==SQLITE_OK );
52772
+ assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR );
5265952773
if( rc==SQLITE_BUSY ){
5266052774
p->rc = rc = SQLITE_BUSY;
5266152775
}else{
52776
+ assert( rc==SQLITE_OK || p->rc==SQLITE_CONSTRAINT );
52777
+ assert( rc==SQLITE_OK || db->nDeferredCons>0 );
5266252778
rc = p->rc ? SQLITE_ERROR : SQLITE_DONE;
5266352779
}
5266452780
goto vdbe_return;
5266552781
}
5266652782
@@ -52901,10 +53017,19 @@
5290153017
int i;
5290253018
#endif /* local variables moved into u.ad */
5290353019
assert( p->nResColumn==pOp->p2 );
5290453020
assert( pOp->p1>0 );
5290553021
assert( pOp->p1+pOp->p2<=p->nMem+1 );
53022
+
53023
+ /* If this statement has violated immediate foreign key constraints, do
53024
+ ** not return the number of rows modified. And do not RELEASE the statement
53025
+ ** transaction. It needs to be rolled back. */
53026
+ if( SQLITE_OK!=(rc = sqlite3VdbeCheckFk(p, 0)) ){
53027
+ assert( db->flags&SQLITE_CountRows );
53028
+ assert( p->usesStmtJournal );
53029
+ break;
53030
+ }
5290653031
5290753032
/* If the SQLITE_CountRows flag is set in sqlite3.flags mask, then
5290853033
** DML statements invoke this opcode to return the number of rows
5290953034
** modified to the user. This is the only way that a VM that
5291053035
** opens a statement transaction may invoke this opcode.
@@ -53473,16 +53598,28 @@
5347353598
/* Opcode: Ne P1 P2 P3 P4 P5
5347453599
**
5347553600
** This works just like the Lt opcode except that the jump is taken if
5347653601
** the operands in registers P1 and P3 are not equal. See the Lt opcode for
5347753602
** additional information.
53603
+**
53604
+** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
53605
+** true or false and is never NULL. If both operands are NULL then the result
53606
+** of comparison is false. If either operand is NULL then the result is true.
53607
+** If neither operand is NULL the the result is the same as it would be if
53608
+** the SQLITE_NULLEQ flag were omitted from P5.
5347853609
*/
5347953610
/* Opcode: Eq P1 P2 P3 P4 P5
5348053611
**
5348153612
** This works just like the Lt opcode except that the jump is taken if
5348253613
** the operands in registers P1 and P3 are equal.
5348353614
** See the Lt opcode for additional information.
53615
+**
53616
+** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
53617
+** true or false and is never NULL. If both operands are NULL then the result
53618
+** of comparison is true. If either operand is NULL then the result is false.
53619
+** If neither operand is NULL the the result is the same as it would be if
53620
+** the SQLITE_NULLEQ flag were omitted from P5.
5348453621
*/
5348553622
/* Opcode: Le P1 P2 P3 P4 P5
5348653623
**
5348753624
** This works just like the Lt opcode except that the jump is taken if
5348853625
** the content of register P3 is less than or equal to the content of
@@ -53505,42 +53642,51 @@
5350553642
case OP_Lt: /* same as TK_LT, jump, in1, in3 */
5350653643
case OP_Le: /* same as TK_LE, jump, in1, in3 */
5350753644
case OP_Gt: /* same as TK_GT, jump, in1, in3 */
5350853645
case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
5350953646
#if 0 /* local variables moved into u.ai */
53510
- int flags;
53511
- int res;
53512
- char affinity;
53647
+ int res; /* Result of the comparison of pIn1 against pIn3 */
53648
+ char affinity; /* Affinity to use for comparison */
5351353649
#endif /* local variables moved into u.ai */
5351453650
53515
- u.ai.flags = pIn1->flags|pIn3->flags;
53516
-
53517
- if( u.ai.flags&MEM_Null ){
53518
- /* If either operand is NULL then the result is always NULL.
53519
- ** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
53520
- */
53521
- if( pOp->p5 & SQLITE_STOREP2 ){
53522
- pOut = &p->aMem[pOp->p2];
53523
- MemSetTypeFlag(pOut, MEM_Null);
53524
- REGISTER_TRACE(pOp->p2, pOut);
53525
- }else if( pOp->p5 & SQLITE_JUMPIFNULL ){
53526
- pc = pOp->p2-1;
53527
- }
53528
- break;
53529
- }
53530
-
53531
- u.ai.affinity = pOp->p5 & SQLITE_AFF_MASK;
53532
- if( u.ai.affinity ){
53533
- applyAffinity(pIn1, u.ai.affinity, encoding);
53534
- applyAffinity(pIn3, u.ai.affinity, encoding);
53535
- if( db->mallocFailed ) goto no_mem;
53536
- }
53537
-
53538
- assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
53539
- ExpandBlob(pIn1);
53540
- ExpandBlob(pIn3);
53541
- u.ai.res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
53651
+ if( (pIn1->flags | pIn3->flags)&MEM_Null ){
53652
+ /* One or both operands are NULL */
53653
+ if( pOp->p5 & SQLITE_NULLEQ ){
53654
+ /* If SQLITE_NULLEQ is set (which will only happen if the operator is
53655
+ ** OP_Eq or OP_Ne) then take the jump or not depending on whether
53656
+ ** or not both operands are null.
53657
+ */
53658
+ assert( pOp->opcode==OP_Eq || pOp->opcode==OP_Ne );
53659
+ u.ai.res = (pIn1->flags & pIn3->flags & MEM_Null)==0;
53660
+ }else{
53661
+ /* SQLITE_NULLEQ is clear and at least one operand is NULL,
53662
+ ** then the result is always NULL.
53663
+ ** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
53664
+ */
53665
+ if( pOp->p5 & SQLITE_STOREP2 ){
53666
+ pOut = &p->aMem[pOp->p2];
53667
+ MemSetTypeFlag(pOut, MEM_Null);
53668
+ REGISTER_TRACE(pOp->p2, pOut);
53669
+ }else if( pOp->p5 & SQLITE_JUMPIFNULL ){
53670
+ pc = pOp->p2-1;
53671
+ }
53672
+ break;
53673
+ }
53674
+ }else{
53675
+ /* Neither operand is NULL. Do a comparison. */
53676
+ u.ai.affinity = pOp->p5 & SQLITE_AFF_MASK;
53677
+ if( u.ai.affinity ){
53678
+ applyAffinity(pIn1, u.ai.affinity, encoding);
53679
+ applyAffinity(pIn3, u.ai.affinity, encoding);
53680
+ if( db->mallocFailed ) goto no_mem;
53681
+ }
53682
+
53683
+ assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
53684
+ ExpandBlob(pIn1);
53685
+ ExpandBlob(pIn3);
53686
+ u.ai.res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
53687
+ }
5354253688
switch( pOp->opcode ){
5354353689
case OP_Eq: u.ai.res = u.ai.res==0; break;
5354453690
case OP_Ne: u.ai.res = u.ai.res!=0; break;
5354553691
case OP_Lt: u.ai.res = u.ai.res<0; break;
5354653692
case OP_Le: u.ai.res = u.ai.res<=0; break;
@@ -53604,13 +53750,22 @@
5360453750
u.aj.n = pOp->p3;
5360553751
u.aj.pKeyInfo = pOp->p4.pKeyInfo;
5360653752
assert( u.aj.n>0 );
5360753753
assert( u.aj.pKeyInfo!=0 );
5360853754
u.aj.p1 = pOp->p1;
53609
- assert( u.aj.p1>0 && u.aj.p1+u.aj.n<=p->nMem+1 );
5361053755
u.aj.p2 = pOp->p2;
53611
- assert( u.aj.p2>0 && u.aj.p2+u.aj.n<=p->nMem+1 );
53756
+#if SQLITE_DEBUG
53757
+ if( aPermute ){
53758
+ int k, mx = 0;
53759
+ for(k=0; k<u.aj.n; k++) if( aPermute[k]>mx ) mx = aPermute[k];
53760
+ assert( u.aj.p1>0 && u.aj.p1+mx<=p->nMem+1 );
53761
+ assert( u.aj.p2>0 && u.aj.p2+mx<=p->nMem+1 );
53762
+ }else{
53763
+ assert( u.aj.p1>0 && u.aj.p1+u.aj.n<=p->nMem+1 );
53764
+ assert( u.aj.p2>0 && u.aj.p2+u.aj.n<=p->nMem+1 );
53765
+ }
53766
+#endif /* SQLITE_DEBUG */
5361253767
for(u.aj.i=0; u.aj.i<u.aj.n; u.aj.i++){
5361353768
u.aj.idx = aPermute ? aPermute[u.aj.i] : u.aj.i;
5361453769
REGISTER_TRACE(u.aj.p1+u.aj.idx, &p->aMem[u.aj.p1+u.aj.idx]);
5361553770
REGISTER_TRACE(u.aj.p2+u.aj.idx, &p->aMem[u.aj.p2+u.aj.idx]);
5361653771
assert( u.aj.i<u.aj.pKeyInfo->nField );
@@ -54321,10 +54476,11 @@
5432154476
}
5432254477
5432354478
/* Link the new savepoint into the database handle's list. */
5432454479
u.aq.pNew->pNext = db->pSavepoint;
5432554480
db->pSavepoint = u.aq.pNew;
54481
+ u.aq.pNew->nDeferredCons = db->nDeferredCons;
5432654482
}
5432754483
}
5432854484
}else{
5432954485
u.aq.iSavepoint = 0;
5433054486
@@ -54358,10 +54514,13 @@
5435854514
** and this is a RELEASE command, then the current transaction
5435954515
** is committed.
5436054516
*/
5436154517
int isTransaction = u.aq.pSavepoint->pNext==0 && db->isTransactionSavepoint;
5436254518
if( isTransaction && u.aq.p1==SAVEPOINT_RELEASE ){
54519
+ if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
54520
+ goto vdbe_return;
54521
+ }
5436354522
db->autoCommit = 1;
5436454523
if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
5436554524
p->pc = pc;
5436654525
db->autoCommit = 0;
5436754526
p->rc = rc = SQLITE_BUSY;
@@ -54390,18 +54549,23 @@
5439054549
db->pSavepoint = u.aq.pTmp->pNext;
5439154550
sqlite3DbFree(db, u.aq.pTmp);
5439254551
db->nSavepoint--;
5439354552
}
5439454553
54395
- /* If it is a RELEASE, then destroy the savepoint being operated on too */
54554
+ /* If it is a RELEASE, then destroy the savepoint being operated on
54555
+ ** too. If it is a ROLLBACK TO, then set the number of deferred
54556
+ ** constraint violations present in the database to the value stored
54557
+ ** when the savepoint was created. */
5439654558
if( u.aq.p1==SAVEPOINT_RELEASE ){
5439754559
assert( u.aq.pSavepoint==db->pSavepoint );
5439854560
db->pSavepoint = u.aq.pSavepoint->pNext;
5439954561
sqlite3DbFree(db, u.aq.pSavepoint);
5440054562
if( !isTransaction ){
5440154563
db->nSavepoint--;
5440254564
}
54565
+ }else{
54566
+ db->nDeferredCons = u.aq.pSavepoint->nDeferredCons;
5440354567
}
5440454568
}
5440554569
}
5440654570
5440754571
break;
@@ -54448,10 +54612,12 @@
5444854612
}else if( u.ar.desiredAutoCommit!=db->autoCommit ){
5444954613
if( u.ar.iRollback ){
5445054614
assert( u.ar.desiredAutoCommit==1 );
5445154615
sqlite3RollbackAll(db);
5445254616
db->autoCommit = 1;
54617
+ }else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
54618
+ goto vdbe_return;
5445354619
}else{
5445454620
db->autoCommit = (u8)u.ar.desiredAutoCommit;
5445554621
if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
5445654622
p->pc = pc;
5445754623
db->autoCommit = (u8)(1-u.ar.desiredAutoCommit);
@@ -54523,11 +54689,11 @@
5452354689
if( rc==SQLITE_BUSY ){
5452454690
p->pc = pc;
5452554691
p->rc = rc = SQLITE_BUSY;
5452654692
goto vdbe_return;
5452754693
}
54528
- if( rc!=SQLITE_OK && rc!=SQLITE_READONLY /* && rc!=SQLITE_BUSY */ ){
54694
+ if( rc!=SQLITE_OK ){
5452954695
goto abort_due_to_error;
5453054696
}
5453154697
5453254698
if( pOp->p2 && p->usesStmtJournal
5453354699
&& (db->autoCommit==0 || db->activeVdbeCnt>1)
@@ -54537,10 +54703,15 @@
5453754703
assert( db->nStatement>=0 && db->nSavepoint>=0 );
5453854704
db->nStatement++;
5453954705
p->iStatement = db->nSavepoint + db->nStatement;
5454054706
}
5454154707
rc = sqlite3BtreeBeginStmt(u.as.pBt, p->iStatement);
54708
+
54709
+ /* Store the current value of the database handles deferred constraint
54710
+ ** counter. If the statement transaction needs to be rolled back,
54711
+ ** the value of this counter needs to be restored too. */
54712
+ p->nStmtDefCons = db->nDeferredCons;
5454254713
}
5454354714
}
5454454715
break;
5454554716
}
5454654717
@@ -55156,10 +55327,14 @@
5515655327
VdbeCursor *pC;
5515755328
int res;
5515855329
UnpackedRecord *pIdxKey;
5515955330
char aTempRec[ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*3 + 7];
5516055331
#endif /* local variables moved into u.bb */
55332
+
55333
+#ifdef SQLITE_TEST
55334
+ sqlite3_found_count++;
55335
+#endif
5516155336
5516255337
u.bb.alreadyExists = 0;
5516355338
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
5516455339
u.bb.pC = p->apCsr[pOp->p1];
5516555340
assert( u.bb.pC!=0 );
@@ -56616,28 +56791,28 @@
5661656791
5661756792
u.bz.pProgram = pOp->p4.pProgram;
5661856793
u.bz.pRt = &p->aMem[pOp->p3];
5661956794
assert( u.bz.pProgram->nOp>0 );
5662056795
56621
- /* If the SQLITE_RecTriggers flag is clear, then recursive invocation of
56622
- ** triggers is disabled for backwards compatibility (flag set/cleared by
56623
- ** the "PRAGMA recursive_triggers" command).
56796
+ /* If the p5 flag is clear, then recursive invocation of triggers is
56797
+ ** disabled for backwards compatibility (p5 is set if this sub-program
56798
+ ** is really a trigger, not a foreign key action, and the flag set
56799
+ ** and cleared by the "PRAGMA recursive_triggers" command is clear).
5662456800
**
5662556801
** It is recursive invocation of triggers, at the SQL level, that is
5662656802
** disabled. In some cases a single trigger may generate more than one
5662756803
** SubProgram (if the trigger may be executed with more than one different
5662856804
** ON CONFLICT algorithm). SubProgram structures associated with a
5662956805
** single trigger all have the same value for the SubProgram.token
56630
- ** variable.
56631
- */
56632
- if( 0==(db->flags&SQLITE_RecTriggers) ){
56806
+ ** variable. */
56807
+ if( pOp->p5 ){
5663356808
u.bz.t = u.bz.pProgram->token;
5663456809
for(u.bz.pFrame=p->pFrame; u.bz.pFrame && u.bz.pFrame->token!=u.bz.t; u.bz.pFrame=u.bz.pFrame->pParent);
5663556810
if( u.bz.pFrame ) break;
5663656811
}
5663756812
56638
- if( p->nFrame>db->aLimit[SQLITE_LIMIT_TRIGGER_DEPTH] ){
56813
+ if( p->nFrame>=db->aLimit[SQLITE_LIMIT_TRIGGER_DEPTH] ){
5663956814
rc = SQLITE_ERROR;
5664056815
sqlite3SetString(&p->zErrMsg, db, "too many levels of trigger recursion");
5664156816
break;
5664256817
}
5664356818
@@ -56727,10 +56902,48 @@
5672756902
break;
5672856903
}
5672956904
5673056905
#endif /* #ifndef SQLITE_OMIT_TRIGGER */
5673156906
56907
+#ifndef SQLITE_OMIT_FOREIGN_KEY
56908
+/* Opcode: FkCounter P1 P2 * * *
56909
+**
56910
+** Increment a "constraint counter" by P2 (P2 may be negative or positive).
56911
+** If P1 is non-zero, the database constraint counter is incremented
56912
+** (deferred foreign key constraints). Otherwise, if P1 is zero, the
56913
+** statement counter is incremented (immediate foreign key constraints).
56914
+*/
56915
+case OP_FkCounter: {
56916
+ if( pOp->p1 ){
56917
+ db->nDeferredCons += pOp->p2;
56918
+ }else{
56919
+ p->nFkConstraint += pOp->p2;
56920
+ }
56921
+ break;
56922
+}
56923
+
56924
+/* Opcode: FkIfZero P1 P2 * * *
56925
+**
56926
+** This opcode tests if a foreign key constraint-counter is currently zero.
56927
+** If so, jump to instruction P2. Otherwise, fall through to the next
56928
+** instruction.
56929
+**
56930
+** If P1 is non-zero, then the jump is taken if the database constraint-counter
56931
+** is zero (the one that counts deferred constraint violations). If P1 is
56932
+** zero, the jump is taken if the statement constraint-counter is zero
56933
+** (immediate foreign key constraint violations).
56934
+*/
56935
+case OP_FkIfZero: { /* jump */
56936
+ if( pOp->p1 ){
56937
+ if( db->nDeferredCons==0 ) pc = pOp->p2-1;
56938
+ }else{
56939
+ if( p->nFkConstraint==0 ) pc = pOp->p2-1;
56940
+ }
56941
+ break;
56942
+}
56943
+#endif /* #ifndef SQLITE_OMIT_FOREIGN_KEY */
56944
+
5673256945
#ifndef SQLITE_OMIT_AUTOINCREMENT
5673356946
/* Opcode: MemMax P1 P2 * * *
5673456947
**
5673556948
** P1 is a register in the root frame of this VM (the root frame is
5673656949
** different from the current frame if this instruction is being executed
@@ -57677,29 +57890,49 @@
5767757890
sqlite3BtreeLeaveAll(db);
5767857891
goto blob_open_out;
5767957892
}
5768057893
5768157894
/* If the value is being opened for writing, check that the
57682
- ** column is not indexed. It is against the rules to open an
57683
- ** indexed column for writing.
57684
- */
57895
+ ** column is not indexed, and that it is not part of a foreign key.
57896
+ ** It is against the rules to open a column to which either of these
57897
+ ** descriptions applies for writing. */
5768557898
if( flags ){
57899
+ const char *zFault = 0;
5768657900
Index *pIdx;
57901
+#ifndef SQLITE_OMIT_FOREIGN_KEY
57902
+ if( db->flags&SQLITE_ForeignKeys ){
57903
+ /* Check that the column is not part of an FK child key definition. It
57904
+ ** is not necessary to check if it is part of a parent key, as parent
57905
+ ** key columns must be indexed. The check below will pick up this
57906
+ ** case. */
57907
+ FKey *pFKey;
57908
+ for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
57909
+ int j;
57910
+ for(j=0; j<pFKey->nCol; j++){
57911
+ if( pFKey->aCol[j].iFrom==iCol ){
57912
+ zFault = "foreign key";
57913
+ }
57914
+ }
57915
+ }
57916
+ }
57917
+#endif
5768757918
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
5768857919
int j;
5768957920
for(j=0; j<pIdx->nColumn; j++){
5769057921
if( pIdx->aiColumn[j]==iCol ){
57691
- sqlite3DbFree(db, zErr);
57692
- zErr = sqlite3MPrintf(db,
57693
- "cannot open indexed column for writing");
57694
- rc = SQLITE_ERROR;
57695
- (void)sqlite3SafetyOff(db);
57696
- sqlite3BtreeLeaveAll(db);
57697
- goto blob_open_out;
57922
+ zFault = "indexed";
5769857923
}
5769957924
}
5770057925
}
57926
+ if( zFault ){
57927
+ sqlite3DbFree(db, zErr);
57928
+ zErr = sqlite3MPrintf(db, "cannot open %s column for writing", zFault);
57929
+ rc = SQLITE_ERROR;
57930
+ (void)sqlite3SafetyOff(db);
57931
+ sqlite3BtreeLeaveAll(db);
57932
+ goto blob_open_out;
57933
+ }
5770157934
}
5770257935
5770357936
v = sqlite3VdbeCreate(db);
5770457937
if( v ){
5770557938
int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
@@ -59870,11 +60103,11 @@
5987060103
*/
5987160104
static char comparisonAffinity(Expr *pExpr){
5987260105
char aff;
5987360106
assert( pExpr->op==TK_EQ || pExpr->op==TK_IN || pExpr->op==TK_LT ||
5987460107
pExpr->op==TK_GT || pExpr->op==TK_GE || pExpr->op==TK_LE ||
59875
- pExpr->op==TK_NE );
60108
+ pExpr->op==TK_NE || pExpr->op==TK_IS || pExpr->op==TK_ISNOT );
5987660109
assert( pExpr->pLeft );
5987760110
aff = sqlite3ExprAffinity(pExpr->pLeft);
5987860111
if( pExpr->pRight ){
5987960112
aff = sqlite3CompareAffinity(pExpr->pRight, aff);
5988060113
}else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
@@ -61961,10 +62194,23 @@
6196162194
codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
6196262195
r1, r2, inReg, SQLITE_STOREP2);
6196362196
testcase( regFree1==0 );
6196462197
testcase( regFree2==0 );
6196562198
break;
62199
+ }
62200
+ case TK_IS:
62201
+ case TK_ISNOT: {
62202
+ testcase( op==TK_IS );
62203
+ testcase( op==TK_ISNOT );
62204
+ codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
62205
+ pExpr->pRight, &r2, &regFree2);
62206
+ op = (op==TK_IS) ? TK_EQ : TK_NE;
62207
+ codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
62208
+ r1, r2, inReg, SQLITE_STOREP2 | SQLITE_NULLEQ);
62209
+ testcase( regFree1==0 );
62210
+ testcase( regFree2==0 );
62211
+ break;
6196662212
}
6196762213
case TK_AND:
6196862214
case TK_OR:
6196962215
case TK_PLUS:
6197062216
case TK_STAR:
@@ -62735,10 +62981,23 @@
6273562981
codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
6273662982
r1, r2, dest, jumpIfNull);
6273762983
testcase( regFree1==0 );
6273862984
testcase( regFree2==0 );
6273962985
break;
62986
+ }
62987
+ case TK_IS:
62988
+ case TK_ISNOT: {
62989
+ testcase( op==TK_IS );
62990
+ testcase( op==TK_ISNOT );
62991
+ codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
62992
+ pExpr->pRight, &r2, &regFree2);
62993
+ op = (op==TK_IS) ? TK_EQ : TK_NE;
62994
+ codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
62995
+ r1, r2, dest, SQLITE_NULLEQ);
62996
+ testcase( regFree1==0 );
62997
+ testcase( regFree2==0 );
62998
+ break;
6274062999
}
6274163000
case TK_ISNULL:
6274263001
case TK_NOTNULL: {
6274363002
assert( TK_ISNULL==OP_IsNull );
6274463003
assert( TK_NOTNULL==OP_NotNull );
@@ -62884,10 +63143,23 @@
6288463143
codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
6288563144
r1, r2, dest, jumpIfNull);
6288663145
testcase( regFree1==0 );
6288763146
testcase( regFree2==0 );
6288863147
break;
63148
+ }
63149
+ case TK_IS:
63150
+ case TK_ISNOT: {
63151
+ testcase( pExpr->op==TK_IS );
63152
+ testcase( pExpr->op==TK_ISNOT );
63153
+ codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
63154
+ pExpr->pRight, &r2, &regFree2);
63155
+ op = (pExpr->op==TK_IS) ? TK_NE : TK_EQ;
63156
+ codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
63157
+ r1, r2, dest, SQLITE_NULLEQ);
63158
+ testcase( regFree1==0 );
63159
+ testcase( regFree2==0 );
63160
+ break;
6288963161
}
6289063162
case TK_ISNULL:
6289163163
case TK_NOTNULL: {
6289263164
testcase( op==TK_ISNULL );
6289363165
testcase( op==TK_NOTNULL );
@@ -63346,10 +63618,73 @@
6334663618
zTableName, tname.z+tname.n);
6334763619
sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC);
6334863620
}
6334963621
}
6335063622
63623
+/*
63624
+** This C function implements an SQL user function that is used by SQL code
63625
+** generated by the ALTER TABLE ... RENAME command to modify the definition
63626
+** of any foreign key constraints that use the table being renamed as the
63627
+** parent table. It is passed three arguments:
63628
+**
63629
+** 1) The complete text of the CREATE TABLE statement being modified,
63630
+** 2) The old name of the table being renamed, and
63631
+** 3) The new name of the table being renamed.
63632
+**
63633
+** It returns the new CREATE TABLE statement. For example:
63634
+**
63635
+** sqlite_rename_parent('CREATE TABLE t1(a REFERENCES t2)', 't2', 't3')
63636
+** -> 'CREATE TABLE t1(a REFERENCES t3)'
63637
+*/
63638
+#ifndef SQLITE_OMIT_FOREIGN_KEY
63639
+static void renameParentFunc(
63640
+ sqlite3_context *context,
63641
+ int NotUsed,
63642
+ sqlite3_value **argv
63643
+){
63644
+ sqlite3 *db = sqlite3_context_db_handle(context);
63645
+ char *zOutput = 0;
63646
+ char *zResult;
63647
+ unsigned char const *zInput = sqlite3_value_text(argv[0]);
63648
+ unsigned char const *zOld = sqlite3_value_text(argv[1]);
63649
+ unsigned char const *zNew = sqlite3_value_text(argv[2]);
63650
+
63651
+ unsigned const char *z; /* Pointer to token */
63652
+ int n; /* Length of token z */
63653
+ int token; /* Type of token */
63654
+
63655
+ UNUSED_PARAMETER(NotUsed);
63656
+ for(z=zInput; *z; z=z+n){
63657
+ n = sqlite3GetToken(z, &token);
63658
+ if( token==TK_REFERENCES ){
63659
+ char *zParent;
63660
+ do {
63661
+ z += n;
63662
+ n = sqlite3GetToken(z, &token);
63663
+ }while( token==TK_SPACE );
63664
+
63665
+ zParent = sqlite3DbStrNDup(db, (const char *)z, n);
63666
+ if( zParent==0 ) break;
63667
+ sqlite3Dequote(zParent);
63668
+ if( 0==sqlite3StrICmp((const char *)zOld, zParent) ){
63669
+ char *zOut = sqlite3MPrintf(db, "%s%.*s\"%w\"",
63670
+ (zOutput?zOutput:""), z-zInput, zInput, (const char *)zNew
63671
+ );
63672
+ sqlite3DbFree(db, zOutput);
63673
+ zOutput = zOut;
63674
+ zInput = &z[n];
63675
+ }
63676
+ sqlite3DbFree(db, zParent);
63677
+ }
63678
+ }
63679
+
63680
+ zResult = sqlite3MPrintf(db, "%s%s", (zOutput?zOutput:""), zInput),
63681
+ sqlite3_result_text(context, zResult, -1, SQLITE_DYNAMIC);
63682
+ sqlite3DbFree(db, zOutput);
63683
+}
63684
+#endif
63685
+
6335163686
#ifndef SQLITE_OMIT_TRIGGER
6335263687
/* This function is used by SQL generated to implement the
6335363688
** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER
6335463689
** statement. The second is a table name. The table name in the CREATE
6335563690
** TRIGGER statement is replaced with the third argument and the result
@@ -63433,22 +63768,69 @@
6343363768
renameTableFunc, 0, 0);
6343463769
#ifndef SQLITE_OMIT_TRIGGER
6343563770
sqlite3CreateFunc(db, "sqlite_rename_trigger", 2, SQLITE_UTF8, 0,
6343663771
renameTriggerFunc, 0, 0);
6343763772
#endif
63773
+#ifndef SQLITE_OMIT_FOREIGN_KEY
63774
+ sqlite3CreateFunc(db, "sqlite_rename_parent", 3, SQLITE_UTF8, 0,
63775
+ renameParentFunc, 0, 0);
63776
+#endif
6343863777
}
6343963778
63779
+/*
63780
+** This function is used to create the text of expressions of the form:
63781
+**
63782
+** name=<constant1> OR name=<constant2> OR ...
63783
+**
63784
+** If argument zWhere is NULL, then a pointer string containing the text
63785
+** "name=<constant>" is returned, where <constant> is the quoted version
63786
+** of the string passed as argument zConstant. The returned buffer is
63787
+** allocated using sqlite3DbMalloc(). It is the responsibility of the
63788
+** caller to ensure that it is eventually freed.
63789
+**
63790
+** If argument zWhere is not NULL, then the string returned is
63791
+** "<where> OR name=<constant>", where <where> is the contents of zWhere.
63792
+** In this case zWhere is passed to sqlite3DbFree() before returning.
63793
+**
63794
+*/
63795
+static char *whereOrName(sqlite3 *db, char *zWhere, char *zConstant){
63796
+ char *zNew;
63797
+ if( !zWhere ){
63798
+ zNew = sqlite3MPrintf(db, "name=%Q", zConstant);
63799
+ }else{
63800
+ zNew = sqlite3MPrintf(db, "%s OR name=%Q", zWhere, zConstant);
63801
+ sqlite3DbFree(db, zWhere);
63802
+ }
63803
+ return zNew;
63804
+}
63805
+
63806
+#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
63807
+/*
63808
+** Generate the text of a WHERE expression which can be used to select all
63809
+** tables that have foreign key constraints that refer to table pTab (i.e.
63810
+** constraints for which pTab is the parent table) from the sqlite_master
63811
+** table.
63812
+*/
63813
+static char *whereForeignKeys(Parse *pParse, Table *pTab){
63814
+ FKey *p;
63815
+ char *zWhere = 0;
63816
+ for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){
63817
+ zWhere = whereOrName(pParse->db, zWhere, p->pFrom->zName);
63818
+ }
63819
+ return zWhere;
63820
+}
63821
+#endif
63822
+
6344063823
/*
6344163824
** Generate the text of a WHERE expression which can be used to select all
6344263825
** temporary triggers on table pTab from the sqlite_temp_master table. If
6344363826
** table pTab has no temporary triggers, or is itself stored in the
6344463827
** temporary database, NULL is returned.
6344563828
*/
6344663829
static char *whereTempTriggers(Parse *pParse, Table *pTab){
6344763830
Trigger *pTrig;
6344863831
char *zWhere = 0;
63449
- char *tmp = 0;
6345063832
const Schema *pTempSchema = pParse->db->aDb[1].pSchema; /* Temp db schema */
6345163833
6345263834
/* If the table is not located in the temp-db (in which case NULL is
6345363835
** returned, loop through the tables list of triggers. For each trigger
6345463836
** that is not part of the temp-db schema, add a clause to the WHERE
@@ -63456,17 +63838,11 @@
6345663838
*/
6345763839
if( pTab->pSchema!=pTempSchema ){
6345863840
sqlite3 *db = pParse->db;
6345963841
for(pTrig=sqlite3TriggerList(pParse, pTab); pTrig; pTrig=pTrig->pNext){
6346063842
if( pTrig->pSchema==pTempSchema ){
63461
- if( !zWhere ){
63462
- zWhere = sqlite3MPrintf(db, "name=%Q", pTrig->zName);
63463
- }else{
63464
- tmp = zWhere;
63465
- zWhere = sqlite3MPrintf(db, "%s OR name=%Q", zWhere, pTrig->zName);
63466
- sqlite3DbFree(db, tmp);
63467
- }
63843
+ zWhere = whereOrName(db, zWhere, pTrig->zName);
6346863844
}
6346963845
}
6347063846
}
6347163847
return zWhere;
6347263848
}
@@ -63500,11 +63876,11 @@
6350063876
assert( iTrigDb==iDb || iTrigDb==1 );
6350163877
sqlite3VdbeAddOp4(v, OP_DropTrigger, iTrigDb, 0, 0, pTrig->zName, 0);
6350263878
}
6350363879
#endif
6350463880
63505
- /* Drop the table and index from the internal schema */
63881
+ /* Drop the table and index from the internal schema. */
6350663882
sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);
6350763883
6350863884
/* Reload the table, index and permanent trigger schemas. */
6350963885
zWhere = sqlite3MPrintf(pParse->db, "tbl_name=%Q", zName);
6351063886
if( !zWhere ) return;
@@ -63630,10 +64006,25 @@
6363064006
#endif
6363164007
6363264008
/* figure out how many UTF-8 characters are in zName */
6363364009
zTabName = pTab->zName;
6363464010
nTabName = sqlite3Utf8CharLen(zTabName, -1);
64011
+
64012
+#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
64013
+ if( db->flags&SQLITE_ForeignKeys ){
64014
+ /* If foreign-key support is enabled, rewrite the CREATE TABLE
64015
+ ** statements corresponding to all child tables of foreign key constraints
64016
+ ** for which the renamed table is the parent table. */
64017
+ if( (zWhere=whereForeignKeys(pParse, pTab))!=0 ){
64018
+ sqlite3NestedParse(pParse,
64019
+ "UPDATE sqlite_master SET "
64020
+ "sql = sqlite_rename_parent(sql, %Q, %Q) "
64021
+ "WHERE %s;", zTabName, zName, zWhere);
64022
+ sqlite3DbFree(db, zWhere);
64023
+ }
64024
+ }
64025
+#endif
6363564026
6363664027
/* Modify the sqlite_master table to use the new table name. */
6363764028
sqlite3NestedParse(pParse,
6363864029
"UPDATE %Q.%s SET "
6363964030
#ifdef SQLITE_OMIT_TRIGGER
@@ -63679,10 +64070,22 @@
6367964070
"UPDATE sqlite_temp_master SET "
6368064071
"sql = sqlite_rename_trigger(sql, %Q), "
6368164072
"tbl_name = %Q "
6368264073
"WHERE %s;", zName, zName, zWhere);
6368364074
sqlite3DbFree(db, zWhere);
64075
+ }
64076
+#endif
64077
+
64078
+#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
64079
+ if( db->flags&SQLITE_ForeignKeys ){
64080
+ FKey *p;
64081
+ for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){
64082
+ Table *pFrom = p->pFrom;
64083
+ if( pFrom!=pTab ){
64084
+ reloadTableSchema(pParse, p->pFrom, pFrom->zName);
64085
+ }
64086
+ }
6368464087
}
6368564088
#endif
6368664089
6368764090
/* Drop and reload the internal table schema. */
6368864091
reloadTableSchema(pParse, pTab, zName);
@@ -63775,10 +64178,15 @@
6377564178
return;
6377664179
}
6377764180
if( pNew->pIndex ){
6377864181
sqlite3ErrorMsg(pParse, "Cannot add a UNIQUE column");
6377964182
return;
64183
+ }
64184
+ if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){
64185
+ sqlite3ErrorMsg(pParse,
64186
+ "Cannot add a REFERENCES column with non-NULL default value");
64187
+ return;
6378064188
}
6378164189
if( pCol->notNull && !pDflt ){
6378264190
sqlite3ErrorMsg(pParse,
6378364191
"Cannot add a NOT NULL column with default value NULL");
6378464192
return;
@@ -65206,10 +65614,43 @@
6520665614
*/
6520765615
static void sqliteAuthBadReturnCode(Parse *pParse){
6520865616
sqlite3ErrorMsg(pParse, "authorizer malfunction");
6520965617
pParse->rc = SQLITE_ERROR;
6521065618
}
65619
+
65620
+/*
65621
+** Invoke the authorization callback for permission to read column zCol from
65622
+** table zTab in database zDb. This function assumes that an authorization
65623
+** callback has been registered (i.e. that sqlite3.xAuth is not NULL).
65624
+**
65625
+** If SQLITE_IGNORE is returned and pExpr is not NULL, then pExpr is changed
65626
+** to an SQL NULL expression. Otherwise, if pExpr is NULL, then SQLITE_IGNORE
65627
+** is treated as SQLITE_DENY. In this case an error is left in pParse.
65628
+*/
65629
+SQLITE_PRIVATE int sqlite3AuthReadCol(
65630
+ Parse *pParse, /* The parser context */
65631
+ const char *zTab, /* Table name */
65632
+ const char *zCol, /* Column name */
65633
+ int iDb /* Index of containing database. */
65634
+){
65635
+ sqlite3 *db = pParse->db; /* Database handle */
65636
+ char *zDb = db->aDb[iDb].zName; /* Name of attached database */
65637
+ int rc; /* Auth callback return code */
65638
+
65639
+ rc = db->xAuth(db->pAuthArg, SQLITE_READ, zTab,zCol,zDb,pParse->zAuthContext);
65640
+ if( rc==SQLITE_DENY ){
65641
+ if( db->nDb>2 || iDb!=0 ){
65642
+ sqlite3ErrorMsg(pParse, "access to %s.%s.%s is prohibited",zDb,zTab,zCol);
65643
+ }else{
65644
+ sqlite3ErrorMsg(pParse, "access to %s.%s is prohibited", zTab, zCol);
65645
+ }
65646
+ pParse->rc = SQLITE_AUTH;
65647
+ }else if( rc!=SQLITE_IGNORE && rc!=SQLITE_OK ){
65648
+ sqliteAuthBadReturnCode(pParse);
65649
+ }
65650
+ return rc;
65651
+}
6521165652
6521265653
/*
6521365654
** The pExpr should be a TK_COLUMN expression. The table referred to
6521465655
** is in pTabList or else it is the NEW or OLD table of a trigger.
6521565656
** Check to see if it is OK to read this particular column.
@@ -65223,15 +65664,13 @@
6522365664
Expr *pExpr, /* The expression to check authorization on */
6522465665
Schema *pSchema, /* The schema of the expression */
6522565666
SrcList *pTabList /* All table that pExpr might refer to */
6522665667
){
6522765668
sqlite3 *db = pParse->db;
65228
- int rc;
6522965669
Table *pTab = 0; /* The table being read */
6523065670
const char *zCol; /* Name of the column of the table */
6523165671
int iSrc; /* Index in pTabList->a[] of table being read */
65232
- const char *zDBase; /* Name of database being accessed */
6523365672
int iDb; /* The index of the database the expression refers to */
6523465673
int iCol; /* Index of column in table */
6523565674
6523665675
if( db->xAuth==0 ) return;
6523765676
iDb = sqlite3SchemaToIndex(pParse->db, pSchema);
@@ -65264,25 +65703,12 @@
6526465703
zCol = pTab->aCol[pTab->iPKey].zName;
6526565704
}else{
6526665705
zCol = "ROWID";
6526765706
}
6526865707
assert( iDb>=0 && iDb<db->nDb );
65269
- zDBase = db->aDb[iDb].zName;
65270
- rc = db->xAuth(db->pAuthArg, SQLITE_READ, pTab->zName, zCol, zDBase,
65271
- pParse->zAuthContext);
65272
- if( rc==SQLITE_IGNORE ){
65708
+ if( SQLITE_IGNORE==sqlite3AuthReadCol(pParse, pTab->zName, zCol, iDb) ){
6527365709
pExpr->op = TK_NULL;
65274
- }else if( rc==SQLITE_DENY ){
65275
- if( db->nDb>2 || iDb!=0 ){
65276
- sqlite3ErrorMsg(pParse, "access to %s.%s.%s is prohibited",
65277
- zDBase, pTab->zName, zCol);
65278
- }else{
65279
- sqlite3ErrorMsg(pParse, "access to %s.%s is prohibited",pTab->zName,zCol);
65280
- }
65281
- pParse->rc = SQLITE_AUTH;
65282
- }else if( rc!=SQLITE_OK ){
65283
- sqliteAuthBadReturnCode(pParse);
6528465710
}
6528565711
}
6528665712
6528765713
/*
6528865714
** Do an authorization check using the code and arguments given. Return
@@ -65547,10 +65973,13 @@
6554765973
#ifdef SQLITE_DEBUG
6554865974
FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stdout : 0;
6554965975
sqlite3VdbeTrace(v, trace);
6555065976
#endif
6555165977
assert( pParse->iCacheLevel==0 ); /* Disables and re-enables match */
65978
+ /* A minimum of one cursor is required if autoincrement is used
65979
+ * See ticket [a696379c1f08866] */
65980
+ if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;
6555265981
sqlite3VdbeMakeReady(v, pParse->nVar, pParse->nMem,
6555365982
pParse->nTab, pParse->nMaxArg, pParse->explain,
6555465983
pParse->isMultiWrite && pParse->mayAbort);
6555565984
pParse->rc = SQLITE_DONE;
6555665985
pParse->colNamesSet = 0;
@@ -65852,11 +66281,10 @@
6585266281
** memory structures of the indices and foreign keys associated with
6585366282
** the table.
6585466283
*/
6585566284
SQLITE_PRIVATE void sqlite3DeleteTable(Table *pTable){
6585666285
Index *pIndex, *pNext;
65857
- FKey *pFKey, *pNextFKey;
6585866286
sqlite3 *db;
6585966287
6586066288
if( pTable==0 ) return;
6586166289
db = pTable->dbMem;
6586266290
testcase( db==0 );
@@ -65874,17 +66302,12 @@
6587466302
pNext = pIndex->pNext;
6587566303
assert( pIndex->pSchema==pTable->pSchema );
6587666304
sqlite3DeleteIndex(pIndex);
6587766305
}
6587866306
65879
-#ifndef SQLITE_OMIT_FOREIGN_KEY
65880
- /* Delete all foreign keys associated with this table. */
65881
- for(pFKey=pTable->pFKey; pFKey; pFKey=pNextFKey){
65882
- pNextFKey = pFKey->pNextFrom;
65883
- sqlite3DbFree(db, pFKey);
65884
- }
65885
-#endif
66307
+ /* Delete any foreign keys attached to this table. */
66308
+ sqlite3FkDelete(pTable);
6588666309
6588766310
/* Delete the Table structure itself.
6588866311
*/
6588966312
sqliteResetColumnNames(pTable);
6589066313
sqlite3DbFree(db, pTable->zName);
@@ -66522,11 +66945,15 @@
6652266945
#ifndef SQLITE_OMIT_AUTOINCREMENT
6652366946
sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
6652466947
"INTEGER PRIMARY KEY");
6652566948
#endif
6652666949
}else{
66527
- sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0);
66950
+ Index *p;
66951
+ p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0);
66952
+ if( p ){
66953
+ p->autoIndex = 2;
66954
+ }
6652866955
pList = 0;
6652966956
}
6653066957
6653166958
primary_key_exit:
6653266959
sqlite3ExprListDelete(pParse->db, pList);
@@ -67411,10 +67838,11 @@
6741167838
#ifndef SQLITE_OMIT_VIRTUALTABLE
6741267839
if( IsVirtual(pTab) ){
6741367840
sqlite3VdbeAddOp0(v, OP_VBegin);
6741467841
}
6741567842
#endif
67843
+ sqlite3FkDropTable(pParse, pName, pTab);
6741667844
6741767845
/* Drop all triggers associated with the table being dropped. Code
6741867846
** is generated to remove entries from sqlite_master and/or
6741967847
** sqlite_temp_master if required.
6742067848
*/
@@ -67501,10 +67929,11 @@
6750167929
int flags /* Conflict resolution algorithms. */
6750267930
){
6750367931
sqlite3 *db = pParse->db;
6750467932
#ifndef SQLITE_OMIT_FOREIGN_KEY
6750567933
FKey *pFKey = 0;
67934
+ FKey *pNextTo;
6750667935
Table *p = pParse->pNewTable;
6750767936
int nByte;
6750867937
int i;
6750967938
int nCol;
6751067939
char *z;
@@ -67575,13 +68004,25 @@
6757568004
z[n] = 0;
6757668005
z += n+1;
6757768006
}
6757868007
}
6757968008
pFKey->isDeferred = 0;
67580
- pFKey->deleteConf = (u8)(flags & 0xff);
67581
- pFKey->updateConf = (u8)((flags >> 8 ) & 0xff);
67582
- pFKey->insertConf = (u8)((flags >> 16 ) & 0xff);
68009
+ pFKey->aAction[0] = (u8)(flags & 0xff); /* ON DELETE action */
68010
+ pFKey->aAction[1] = (u8)((flags >> 8 ) & 0xff); /* ON UPDATE action */
68011
+
68012
+ pNextTo = (FKey *)sqlite3HashInsert(&p->pSchema->fkeyHash,
68013
+ pFKey->zTo, sqlite3Strlen30(pFKey->zTo), (void *)pFKey
68014
+ );
68015
+ if( pNextTo==pFKey ){
68016
+ db->mallocFailed = 1;
68017
+ goto fk_end;
68018
+ }
68019
+ if( pNextTo ){
68020
+ assert( pNextTo->pPrevTo==0 );
68021
+ pFKey->pNextTo = pNextTo;
68022
+ pNextTo->pPrevTo = pFKey;
68023
+ }
6758368024
6758468025
/* Link the foreign key to the table as the last step.
6758568026
*/
6758668027
p->pFKey = pFKey;
6758768028
pFKey = 0;
@@ -67603,11 +68044,11 @@
6760368044
SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse *pParse, int isDeferred){
6760468045
#ifndef SQLITE_OMIT_FOREIGN_KEY
6760568046
Table *pTab;
6760668047
FKey *pFKey;
6760768048
if( (pTab = pParse->pNewTable)==0 || (pFKey = pTab->pFKey)==0 ) return;
67608
- assert( isDeferred==0 || isDeferred==1 );
68049
+ assert( isDeferred==0 || isDeferred==1 ); /* EV: R-30323-21917 */
6760968050
pFKey->isDeferred = (u8)isDeferred;
6761068051
#endif
6761168052
}
6761268053
6761368054
/*
@@ -67698,12 +68139,16 @@
6769868139
** currently being constructed by a CREATE TABLE statement.
6769968140
**
6770068141
** pList is a list of columns to be indexed. pList will be NULL if this
6770168142
** is a primary key or unique-constraint on the most recent column added
6770268143
** to the table currently under construction.
68144
+**
68145
+** If the index is created successfully, return a pointer to the new Index
68146
+** structure. This is used by sqlite3AddPrimaryKey() to mark the index
68147
+** as the tables primary key (Index.autoIndex==2).
6770368148
*/
67704
-SQLITE_PRIVATE void sqlite3CreateIndex(
68149
+SQLITE_PRIVATE Index *sqlite3CreateIndex(
6770568150
Parse *pParse, /* All information about this parse */
6770668151
Token *pName1, /* First part of index name. May be NULL */
6770768152
Token *pName2, /* Second part of index name. May be NULL */
6770868153
SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
6770968154
ExprList *pList, /* A list of columns to be indexed */
@@ -67711,10 +68156,11 @@
6771168156
Token *pStart, /* The CREATE token that begins this statement */
6771268157
Token *pEnd, /* The ")" that closes the CREATE INDEX statement */
6771368158
int sortOrder, /* Sort order of primary key when pList==NULL */
6771468159
int ifNotExist /* Omit error if index already exists */
6771568160
){
68161
+ Index *pRet = 0; /* Pointer to return */
6771668162
Table *pTab = 0; /* Table to be indexed */
6771768163
Index *pIndex = 0; /* The index to be created */
6771868164
char *zName = 0; /* Name of the index */
6771968165
int nName; /* Number of characters in zName */
6772068166
int i, j;
@@ -68146,10 +68592,11 @@
6814668592
pOther = pOther->pNext;
6814768593
}
6814868594
pIndex->pNext = pOther->pNext;
6814968595
pOther->pNext = pIndex;
6815068596
}
68597
+ pRet = pIndex;
6815168598
pIndex = 0;
6815268599
}
6815368600
6815468601
/* Clean up before exiting */
6815568602
exit_create_index:
@@ -68158,11 +68605,11 @@
6815868605
sqlite3DbFree(db, pIndex);
6815968606
}
6816068607
sqlite3ExprListDelete(db, pList);
6816168608
sqlite3SrcListDelete(db, pTblName);
6816268609
sqlite3DbFree(db, zName);
68163
- return;
68610
+ return pRet;
6816468611
}
6816568612
6816668613
/*
6816768614
** Fill the Index.aiRowEst[] array with default information - information
6816868615
** to be used when we have not run the ANALYZE command.
@@ -68823,14 +69270,38 @@
6882369270
Parse *pToplevel = sqlite3ParseToplevel(pParse);
6882469271
sqlite3CodeVerifySchema(pParse, iDb);
6882569272
pToplevel->writeMask |= 1<<iDb;
6882669273
pToplevel->isMultiWrite |= setStatement;
6882769274
}
69275
+
69276
+/*
69277
+** Indicate that the statement currently under construction might write
69278
+** more than one entry (example: deleting one row then inserting another,
69279
+** inserting multiple rows in a table, or inserting a row and index entries.)
69280
+** If an abort occurs after some of these writes have completed, then it will
69281
+** be necessary to undo the completed writes.
69282
+*/
69283
+SQLITE_PRIVATE void sqlite3MultiWrite(Parse *pParse){
69284
+ Parse *pToplevel = sqlite3ParseToplevel(pParse);
69285
+ pToplevel->isMultiWrite = 1;
69286
+}
6882869287
6882969288
/*
68830
-** Set the "may throw abort exception" flag for the statement currently
68831
-** being coded.
69289
+** The code generator calls this routine if is discovers that it is
69290
+** possible to abort a statement prior to completion. In order to
69291
+** perform this abort without corrupting the database, we need to make
69292
+** sure that the statement is protected by a statement transaction.
69293
+**
69294
+** Technically, we only need to set the mayAbort flag if the
69295
+** isMultiWrite flag was previously set. There is a time dependency
69296
+** such that the abort must occur after the multiwrite. This makes
69297
+** some statements involving the REPLACE conflict resolution algorithm
69298
+** go a little faster. But taking advantage of this time dependency
69299
+** makes it more difficult to prove that the code is correct (in
69300
+** particular, it prevents us from writing an effective
69301
+** implementation of sqlite3AssertMayAbort()) and so we have chosen
69302
+** to take the safe route and skip the optimization.
6883269303
*/
6883369304
SQLITE_PRIVATE void sqlite3MayAbort(Parse *pParse){
6883469305
Parse *pToplevel = sqlite3ParseToplevel(pParse);
6883569306
pToplevel->mayAbort = 1;
6883669307
}
@@ -69437,10 +69908,11 @@
6943769908
Table *pTab = sqliteHashData(pElem);
6943869909
assert( pTab->dbMem==0 );
6943969910
sqlite3DeleteTable(pTab);
6944069911
}
6944169912
sqlite3HashClear(&temp1);
69913
+ sqlite3HashClear(&pSchema->fkeyHash);
6944269914
pSchema->pSeqTab = 0;
6944369915
pSchema->flags &= ~DB_SchemaLoaded;
6944469916
}
6944569917
6944669918
/*
@@ -69458,10 +69930,11 @@
6945869930
db->mallocFailed = 1;
6945969931
}else if ( 0==p->file_format ){
6946069932
sqlite3HashInit(&p->tblHash);
6946169933
sqlite3HashInit(&p->idxHash);
6946269934
sqlite3HashInit(&p->trigHash);
69935
+ sqlite3HashInit(&p->fkeyHash);
6946369936
p->enc = SQLITE_UTF8;
6946469937
}
6946569938
return p;
6946669939
}
6946769940
@@ -69774,11 +70247,11 @@
6977470247
v = sqlite3GetVdbe(pParse);
6977570248
if( v==0 ){
6977670249
goto delete_from_cleanup;
6977770250
}
6977870251
if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);
69779
- sqlite3BeginWriteOperation(pParse, (pTrigger?1:0), iDb);
70252
+ sqlite3BeginWriteOperation(pParse, 1, iDb);
6978070253
6978170254
/* If we are trying to delete from a view, realize that view into
6978270255
** a ephemeral table.
6978370256
*/
6978470257
#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
@@ -69807,11 +70280,13 @@
6980770280
#ifndef SQLITE_OMIT_TRUNCATE_OPTIMIZATION
6980870281
/* Special case: A DELETE without a WHERE clause deletes everything.
6980970282
** It is easier just to erase the whole table. Prior to version 3.6.5,
6981070283
** this optimization caused the row change count (the value returned by
6981170284
** API function sqlite3_count_changes) to be set incorrectly. */
69812
- if( rcauth==SQLITE_OK && pWhere==0 && !pTrigger && !IsVirtual(pTab) ){
70285
+ if( rcauth==SQLITE_OK && pWhere==0 && !pTrigger && !IsVirtual(pTab)
70286
+ && 0==sqlite3FkRequired(pParse, pTab, 0, 0)
70287
+ ){
6981370288
assert( !isView );
6981470289
sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt,
6981570290
pTab->zName, P4_STATIC);
6981670291
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
6981770292
assert( pIdx->pSchema==pTab->pSchema );
@@ -69903,20 +70378,29 @@
6990370378
sqlite3AuthContextPop(&sContext);
6990470379
sqlite3SrcListDelete(db, pTabList);
6990570380
sqlite3ExprDelete(db, pWhere);
6990670381
return;
6990770382
}
70383
+/* Make sure "isView" and other macros defined above are undefined. Otherwise
70384
+** thely may interfere with compilation of other functions in this file
70385
+** (or in another file, if this file becomes part of the amalgamation). */
70386
+#ifdef isView
70387
+ #undef isView
70388
+#endif
70389
+#ifdef pTrigger
70390
+ #undef pTrigger
70391
+#endif
6990870392
6990970393
/*
6991070394
** This routine generates VDBE code that causes a single row of a
6991170395
** single table to be deleted.
6991270396
**
6991370397
** The VDBE must be in a particular state when this routine is called.
6991470398
** These are the requirements:
6991570399
**
6991670400
** 1. A read/write cursor pointing to pTab, the table containing the row
69917
-** to be deleted, must be opened as cursor number "base".
70401
+** to be deleted, must be opened as cursor number $iCur.
6991870402
**
6991970403
** 2. Read/write cursors for all indices of pTab must be open as
6992070404
** cursor number base+i for the i-th index.
6992170405
**
6992270406
** 3. The record number of the row to be deleted must be stored in
@@ -69947,17 +70431,18 @@
6994770431
iLabel = sqlite3VdbeMakeLabel(v);
6994870432
sqlite3VdbeAddOp3(v, OP_NotExists, iCur, iLabel, iRowid);
6994970433
6995070434
/* If there are any triggers to fire, allocate a range of registers to
6995170435
** use for the old.* references in the triggers. */
69952
- if( pTrigger ){
70436
+ if( sqlite3FkRequired(pParse, pTab, 0, 0) || pTrigger ){
6995370437
u32 mask; /* Mask of OLD.* columns in use */
6995470438
int iCol; /* Iterator used while populating OLD.* */
6995570439
6995670440
/* TODO: Could use temporary registers here. Also could attempt to
6995770441
** avoid copying the contents of the rowid register. */
69958
- mask = sqlite3TriggerOldmask(pParse, pTrigger, TK_DELETE, 0, pTab, onconf);
70442
+ mask = sqlite3TriggerOldmask(pParse, pTrigger, 0, pTab, onconf);
70443
+ mask |= sqlite3FkOldmask(pParse, pTab);
6995970444
iOld = pParse->nMem+1;
6996070445
pParse->nMem += (1 + pTab->nCol);
6996170446
6996270447
/* Populate the OLD.* pseudo-table register array. These values will be
6996370448
** used by any BEFORE and AFTER triggers that exist. */
@@ -69968,20 +70453,25 @@
6996870453
sqlite3VdbeAddOp3(v, OP_Column, iCur, iCol, iTarget);
6996970454
sqlite3ColumnDefault(v, pTab, iCol, iTarget);
6997070455
}
6997170456
}
6997270457
69973
- /* Invoke any BEFORE trigger programs */
70458
+ /* Invoke BEFORE DELETE trigger programs. */
6997470459
sqlite3CodeRowTrigger(pParse, pTrigger,
69975
- TK_DELETE, 0, TRIGGER_BEFORE, pTab, -1, iOld, onconf, iLabel
70460
+ TK_DELETE, 0, TRIGGER_BEFORE, pTab, iOld, onconf, iLabel
6997670461
);
6997770462
6997870463
/* Seek the cursor to the row to be deleted again. It may be that
6997970464
** the BEFORE triggers coded above have already removed the row
6998070465
** being deleted. Do not attempt to delete the row a second time, and
6998170466
** do not fire AFTER triggers. */
6998270467
sqlite3VdbeAddOp3(v, OP_NotExists, iCur, iLabel, iRowid);
70468
+
70469
+ /* Do FK processing. This call checks that any FK constraints that
70470
+ ** refer to this table (i.e. constraints attached to other tables)
70471
+ ** are not violated by deleting this row. */
70472
+ sqlite3FkCheck(pParse, pTab, iOld, 0);
6998370473
}
6998470474
6998570475
/* Delete the index and table entries. Skip this step if pTab is really
6998670476
** a view (in which case the only effect of the DELETE statement is to
6998770477
** fire the INSTEAD OF triggers). */
@@ -69991,16 +70481,19 @@
6999170481
if( count ){
6999270482
sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_STATIC);
6999370483
}
6999470484
}
6999570485
69996
- /* Invoke AFTER triggers. */
69997
- if( pTrigger ){
69998
- sqlite3CodeRowTrigger(pParse, pTrigger,
69999
- TK_DELETE, 0, TRIGGER_AFTER, pTab, -1, iOld, onconf, iLabel
70000
- );
70001
- }
70486
+ /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to
70487
+ ** handle rows (possibly in other tables) that refer via a foreign key
70488
+ ** to the row just deleted. */
70489
+ sqlite3FkActions(pParse, pTab, 0, iOld);
70490
+
70491
+ /* Invoke AFTER DELETE trigger programs. */
70492
+ sqlite3CodeRowTrigger(pParse, pTrigger,
70493
+ TK_DELETE, 0, TRIGGER_AFTER, pTab, iOld, onconf, iLabel
70494
+ );
7000270495
7000370496
/* Jump here if the row had already been deleted before any BEFORE
7000470497
** trigger programs were invoked. Or if a trigger program throws a
7000570498
** RAISE(IGNORE) exception. */
7000670499
sqlite3VdbeResolveLabel(v, iLabel);
@@ -70082,14 +70575,10 @@
7008270575
}
7008370576
sqlite3ReleaseTempRange(pParse, regBase, nCol+1);
7008470577
return regBase;
7008570578
}
7008670579
70087
-/* Make sure "isView" gets undefined in case this file becomes part of
70088
-** the amalgamation - so that subsequent files do not see isView as a
70089
-** macro. */
70090
-#undef isView
7009170580
7009270581
/************** End of delete.c **********************************************/
7009370582
/************** Begin file func.c ********************************************/
7009470583
/*
7009570584
** 2002 February 23
@@ -71576,10 +72065,1203 @@
7157672065
}
7157772066
sqlite3RegisterDateTimeFunctions();
7157872067
}
7157972068
7158072069
/************** End of func.c ************************************************/
72070
+/************** Begin file fkey.c ********************************************/
72071
+/*
72072
+**
72073
+** The author disclaims copyright to this source code. In place of
72074
+** a legal notice, here is a blessing:
72075
+**
72076
+** May you do good and not evil.
72077
+** May you find forgiveness for yourself and forgive others.
72078
+** May you share freely, never taking more than you give.
72079
+**
72080
+*************************************************************************
72081
+** This file contains code used by the compiler to add foreign key
72082
+** support to compiled SQL statements.
72083
+*/
72084
+
72085
+#ifndef SQLITE_OMIT_FOREIGN_KEY
72086
+#ifndef SQLITE_OMIT_TRIGGER
72087
+
72088
+/*
72089
+** Deferred and Immediate FKs
72090
+** --------------------------
72091
+**
72092
+** Foreign keys in SQLite come in two flavours: deferred and immediate.
72093
+** If an immediate foreign key constraint is violated, SQLITE_CONSTRAINT
72094
+** is returned and the current statement transaction rolled back. If a
72095
+** deferred foreign key constraint is violated, no action is taken
72096
+** immediately. However if the application attempts to commit the
72097
+** transaction before fixing the constraint violation, the attempt fails.
72098
+**
72099
+** Deferred constraints are implemented using a simple counter associated
72100
+** with the database handle. The counter is set to zero each time a
72101
+** database transaction is opened. Each time a statement is executed
72102
+** that causes a foreign key violation, the counter is incremented. Each
72103
+** time a statement is executed that removes an existing violation from
72104
+** the database, the counter is decremented. When the transaction is
72105
+** committed, the commit fails if the current value of the counter is
72106
+** greater than zero. This scheme has two big drawbacks:
72107
+**
72108
+** * When a commit fails due to a deferred foreign key constraint,
72109
+** there is no way to tell which foreign constraint is not satisfied,
72110
+** or which row it is not satisfied for.
72111
+**
72112
+** * If the database contains foreign key violations when the
72113
+** transaction is opened, this may cause the mechanism to malfunction.
72114
+**
72115
+** Despite these problems, this approach is adopted as it seems simpler
72116
+** than the alternatives.
72117
+**
72118
+** INSERT operations:
72119
+**
72120
+** I.1) For each FK for which the table is the child table, search
72121
+** the parent table for a match. If none is found increment the
72122
+** constraint counter.
72123
+**
72124
+** I.2) For each FK for which the table is the parent table,
72125
+** search the child table for rows that correspond to the new
72126
+** row in the parent table. Decrement the counter for each row
72127
+** found (as the constraint is now satisfied).
72128
+**
72129
+** DELETE operations:
72130
+**
72131
+** D.1) For each FK for which the table is the child table,
72132
+** search the parent table for a row that corresponds to the
72133
+** deleted row in the child table. If such a row is not found,
72134
+** decrement the counter.
72135
+**
72136
+** D.2) For each FK for which the table is the parent table, search
72137
+** the child table for rows that correspond to the deleted row
72138
+** in the parent table. For each found increment the counter.
72139
+**
72140
+** UPDATE operations:
72141
+**
72142
+** An UPDATE command requires that all 4 steps above are taken, but only
72143
+** for FK constraints for which the affected columns are actually
72144
+** modified (values must be compared at runtime).
72145
+**
72146
+** Note that I.1 and D.1 are very similar operations, as are I.2 and D.2.
72147
+** This simplifies the implementation a bit.
72148
+**
72149
+** For the purposes of immediate FK constraints, the OR REPLACE conflict
72150
+** resolution is considered to delete rows before the new row is inserted.
72151
+** If a delete caused by OR REPLACE violates an FK constraint, an exception
72152
+** is thrown, even if the FK constraint would be satisfied after the new
72153
+** row is inserted.
72154
+**
72155
+** Immediate constraints are usually handled similarly. The only difference
72156
+** is that the counter used is stored as part of each individual statement
72157
+** object (struct Vdbe). If, after the statement has run, its immediate
72158
+** constraint counter is greater than zero, it returns SQLITE_CONSTRAINT
72159
+** and the statement transaction is rolled back. An exception is an INSERT
72160
+** statement that inserts a single row only (no triggers). In this case,
72161
+** instead of using a counter, an exception is thrown immediately if the
72162
+** INSERT violates a foreign key constraint. This is necessary as such
72163
+** an INSERT does not open a statement transaction.
72164
+**
72165
+** TODO: How should dropping a table be handled? How should renaming a
72166
+** table be handled?
72167
+**
72168
+**
72169
+** Query API Notes
72170
+** ---------------
72171
+**
72172
+** Before coding an UPDATE or DELETE row operation, the code-generator
72173
+** for those two operations needs to know whether or not the operation
72174
+** requires any FK processing and, if so, which columns of the original
72175
+** row are required by the FK processing VDBE code (i.e. if FKs were
72176
+** implemented using triggers, which of the old.* columns would be
72177
+** accessed). No information is required by the code-generator before
72178
+** coding an INSERT operation. The functions used by the UPDATE/DELETE
72179
+** generation code to query for this information are:
72180
+**
72181
+** sqlite3FkRequired() - Test to see if FK processing is required.
72182
+** sqlite3FkOldmask() - Query for the set of required old.* columns.
72183
+**
72184
+**
72185
+** Externally accessible module functions
72186
+** --------------------------------------
72187
+**
72188
+** sqlite3FkCheck() - Check for foreign key violations.
72189
+** sqlite3FkActions() - Code triggers for ON UPDATE/ON DELETE actions.
72190
+** sqlite3FkDelete() - Delete an FKey structure.
72191
+*/
72192
+
72193
+/*
72194
+** VDBE Calling Convention
72195
+** -----------------------
72196
+**
72197
+** Example:
72198
+**
72199
+** For the following INSERT statement:
72200
+**
72201
+** CREATE TABLE t1(a, b INTEGER PRIMARY KEY, c);
72202
+** INSERT INTO t1 VALUES(1, 2, 3.1);
72203
+**
72204
+** Register (x): 2 (type integer)
72205
+** Register (x+1): 1 (type integer)
72206
+** Register (x+2): NULL (type NULL)
72207
+** Register (x+3): 3.1 (type real)
72208
+*/
72209
+
72210
+/*
72211
+** A foreign key constraint requires that the key columns in the parent
72212
+** table are collectively subject to a UNIQUE or PRIMARY KEY constraint.
72213
+** Given that pParent is the parent table for foreign key constraint pFKey,
72214
+** search the schema a unique index on the parent key columns.
72215
+**
72216
+** If successful, zero is returned. If the parent key is an INTEGER PRIMARY
72217
+** KEY column, then output variable *ppIdx is set to NULL. Otherwise, *ppIdx
72218
+** is set to point to the unique index.
72219
+**
72220
+** If the parent key consists of a single column (the foreign key constraint
72221
+** is not a composite foreign key), output variable *paiCol is set to NULL.
72222
+** Otherwise, it is set to point to an allocated array of size N, where
72223
+** N is the number of columns in the parent key. The first element of the
72224
+** array is the index of the child table column that is mapped by the FK
72225
+** constraint to the parent table column stored in the left-most column
72226
+** of index *ppIdx. The second element of the array is the index of the
72227
+** child table column that corresponds to the second left-most column of
72228
+** *ppIdx, and so on.
72229
+**
72230
+** If the required index cannot be found, either because:
72231
+**
72232
+** 1) The named parent key columns do not exist, or
72233
+**
72234
+** 2) The named parent key columns do exist, but are not subject to a
72235
+** UNIQUE or PRIMARY KEY constraint, or
72236
+**
72237
+** 3) No parent key columns were provided explicitly as part of the
72238
+** foreign key definition, and the parent table does not have a
72239
+** PRIMARY KEY, or
72240
+**
72241
+** 4) No parent key columns were provided explicitly as part of the
72242
+** foreign key definition, and the PRIMARY KEY of the parent table
72243
+** consists of a a different number of columns to the child key in
72244
+** the child table.
72245
+**
72246
+** then non-zero is returned, and a "foreign key mismatch" error loaded
72247
+** into pParse. If an OOM error occurs, non-zero is returned and the
72248
+** pParse->db->mallocFailed flag is set.
72249
+*/
72250
+static int locateFkeyIndex(
72251
+ Parse *pParse, /* Parse context to store any error in */
72252
+ Table *pParent, /* Parent table of FK constraint pFKey */
72253
+ FKey *pFKey, /* Foreign key to find index for */
72254
+ Index **ppIdx, /* OUT: Unique index on parent table */
72255
+ int **paiCol /* OUT: Map of index columns in pFKey */
72256
+){
72257
+ Index *pIdx = 0; /* Value to return via *ppIdx */
72258
+ int *aiCol = 0; /* Value to return via *paiCol */
72259
+ int nCol = pFKey->nCol; /* Number of columns in parent key */
72260
+ char *zKey = pFKey->aCol[0].zCol; /* Name of left-most parent key column */
72261
+
72262
+ /* The caller is responsible for zeroing output parameters. */
72263
+ assert( ppIdx && *ppIdx==0 );
72264
+ assert( !paiCol || *paiCol==0 );
72265
+ assert( pParse );
72266
+
72267
+ /* If this is a non-composite (single column) foreign key, check if it
72268
+ ** maps to the INTEGER PRIMARY KEY of table pParent. If so, leave *ppIdx
72269
+ ** and *paiCol set to zero and return early.
72270
+ **
72271
+ ** Otherwise, for a composite foreign key (more than one column), allocate
72272
+ ** space for the aiCol array (returned via output parameter *paiCol).
72273
+ ** Non-composite foreign keys do not require the aiCol array.
72274
+ */
72275
+ if( nCol==1 ){
72276
+ /* The FK maps to the IPK if any of the following are true:
72277
+ **
72278
+ ** 1) There is an INTEGER PRIMARY KEY column and the FK is implicitly
72279
+ ** mapped to the primary key of table pParent, or
72280
+ ** 2) The FK is explicitly mapped to a column declared as INTEGER
72281
+ ** PRIMARY KEY.
72282
+ */
72283
+ if( pParent->iPKey>=0 ){
72284
+ if( !zKey ) return 0;
72285
+ if( !sqlite3StrICmp(pParent->aCol[pParent->iPKey].zName, zKey) ) return 0;
72286
+ }
72287
+ }else if( paiCol ){
72288
+ assert( nCol>1 );
72289
+ aiCol = (int *)sqlite3DbMallocRaw(pParse->db, nCol*sizeof(int));
72290
+ if( !aiCol ) return 1;
72291
+ *paiCol = aiCol;
72292
+ }
72293
+
72294
+ for(pIdx=pParent->pIndex; pIdx; pIdx=pIdx->pNext){
72295
+ if( pIdx->nColumn==nCol && pIdx->onError!=OE_None ){
72296
+ /* pIdx is a UNIQUE index (or a PRIMARY KEY) and has the right number
72297
+ ** of columns. If each indexed column corresponds to a foreign key
72298
+ ** column of pFKey, then this index is a winner. */
72299
+
72300
+ if( zKey==0 ){
72301
+ /* If zKey is NULL, then this foreign key is implicitly mapped to
72302
+ ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be
72303
+ ** identified by the test (Index.autoIndex==2). */
72304
+ if( pIdx->autoIndex==2 ){
72305
+ if( aiCol ){
72306
+ int i;
72307
+ for(i=0; i<nCol; i++) aiCol[i] = pFKey->aCol[i].iFrom;
72308
+ }
72309
+ break;
72310
+ }
72311
+ }else{
72312
+ /* If zKey is non-NULL, then this foreign key was declared to
72313
+ ** map to an explicit list of columns in table pParent. Check if this
72314
+ ** index matches those columns. Also, check that the index uses
72315
+ ** the default collation sequences for each column. */
72316
+ int i, j;
72317
+ for(i=0; i<nCol; i++){
72318
+ int iCol = pIdx->aiColumn[i]; /* Index of column in parent tbl */
72319
+ char *zDfltColl; /* Def. collation for column */
72320
+ char *zIdxCol; /* Name of indexed column */
72321
+
72322
+ /* If the index uses a collation sequence that is different from
72323
+ ** the default collation sequence for the column, this index is
72324
+ ** unusable. Bail out early in this case. */
72325
+ zDfltColl = pParent->aCol[iCol].zColl;
72326
+ if( !zDfltColl ){
72327
+ zDfltColl = "BINARY";
72328
+ }
72329
+ if( sqlite3StrICmp(pIdx->azColl[i], zDfltColl) ) break;
72330
+
72331
+ zIdxCol = pParent->aCol[iCol].zName;
72332
+ for(j=0; j<nCol; j++){
72333
+ if( sqlite3StrICmp(pFKey->aCol[j].zCol, zIdxCol)==0 ){
72334
+ if( aiCol ) aiCol[i] = pFKey->aCol[j].iFrom;
72335
+ break;
72336
+ }
72337
+ }
72338
+ if( j==nCol ) break;
72339
+ }
72340
+ if( i==nCol ) break; /* pIdx is usable */
72341
+ }
72342
+ }
72343
+ }
72344
+
72345
+ if( !pIdx ){
72346
+ if( !pParse->disableTriggers ){
72347
+ sqlite3ErrorMsg(pParse, "foreign key mismatch");
72348
+ }
72349
+ sqlite3DbFree(pParse->db, aiCol);
72350
+ return 1;
72351
+ }
72352
+
72353
+ *ppIdx = pIdx;
72354
+ return 0;
72355
+}
72356
+
72357
+/*
72358
+** This function is called when a row is inserted into or deleted from the
72359
+** child table of foreign key constraint pFKey. If an SQL UPDATE is executed
72360
+** on the child table of pFKey, this function is invoked twice for each row
72361
+** affected - once to "delete" the old row, and then again to "insert" the
72362
+** new row.
72363
+**
72364
+** Each time it is called, this function generates VDBE code to locate the
72365
+** row in the parent table that corresponds to the row being inserted into
72366
+** or deleted from the child table. If the parent row can be found, no
72367
+** special action is taken. Otherwise, if the parent row can *not* be
72368
+** found in the parent table:
72369
+**
72370
+** Operation | FK type | Action taken
72371
+** --------------------------------------------------------------------------
72372
+** INSERT immediate Increment the "immediate constraint counter".
72373
+**
72374
+** DELETE immediate Decrement the "immediate constraint counter".
72375
+**
72376
+** INSERT deferred Increment the "deferred constraint counter".
72377
+**
72378
+** DELETE deferred Decrement the "deferred constraint counter".
72379
+**
72380
+** These operations are identified in the comment at the top of this file
72381
+** (fkey.c) as "I.1" and "D.1".
72382
+*/
72383
+static void fkLookupParent(
72384
+ Parse *pParse, /* Parse context */
72385
+ int iDb, /* Index of database housing pTab */
72386
+ Table *pTab, /* Parent table of FK pFKey */
72387
+ Index *pIdx, /* Unique index on parent key columns in pTab */
72388
+ FKey *pFKey, /* Foreign key constraint */
72389
+ int *aiCol, /* Map from parent key columns to child table columns */
72390
+ int regData, /* Address of array containing child table row */
72391
+ int nIncr, /* Increment constraint counter by this */
72392
+ int isIgnore /* If true, pretend pTab contains all NULL values */
72393
+){
72394
+ int i; /* Iterator variable */
72395
+ Vdbe *v = sqlite3GetVdbe(pParse); /* Vdbe to add code to */
72396
+ int iCur = pParse->nTab - 1; /* Cursor number to use */
72397
+ int iOk = sqlite3VdbeMakeLabel(v); /* jump here if parent key found */
72398
+
72399
+ /* If nIncr is less than zero, then check at runtime if there are any
72400
+ ** outstanding constraints to resolve. If there are not, there is no need
72401
+ ** to check if deleting this row resolves any outstanding violations.
72402
+ **
72403
+ ** Check if any of the key columns in the child table row are NULL. If
72404
+ ** any are, then the constraint is considered satisfied. No need to
72405
+ ** search for a matching row in the parent table. */
72406
+ if( nIncr<0 ){
72407
+ sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey->isDeferred, iOk);
72408
+ }
72409
+ for(i=0; i<pFKey->nCol; i++){
72410
+ int iReg = aiCol[i] + regData + 1;
72411
+ sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iOk);
72412
+ }
72413
+
72414
+ if( isIgnore==0 ){
72415
+ if( pIdx==0 ){
72416
+ /* If pIdx is NULL, then the parent key is the INTEGER PRIMARY KEY
72417
+ ** column of the parent table (table pTab). */
72418
+ int iMustBeInt; /* Address of MustBeInt instruction */
72419
+ int regTemp = sqlite3GetTempReg(pParse);
72420
+
72421
+ /* Invoke MustBeInt to coerce the child key value to an integer (i.e.
72422
+ ** apply the affinity of the parent key). If this fails, then there
72423
+ ** is no matching parent key. Before using MustBeInt, make a copy of
72424
+ ** the value. Otherwise, the value inserted into the child key column
72425
+ ** will have INTEGER affinity applied to it, which may not be correct. */
72426
+ sqlite3VdbeAddOp2(v, OP_SCopy, aiCol[0]+1+regData, regTemp);
72427
+ iMustBeInt = sqlite3VdbeAddOp2(v, OP_MustBeInt, regTemp, 0);
72428
+
72429
+ /* If the parent table is the same as the child table, and we are about
72430
+ ** to increment the constraint-counter (i.e. this is an INSERT operation),
72431
+ ** then check if the row being inserted matches itself. If so, do not
72432
+ ** increment the constraint-counter. */
72433
+ if( pTab==pFKey->pFrom && nIncr==1 ){
72434
+ sqlite3VdbeAddOp3(v, OP_Eq, regData, iOk, regTemp);
72435
+ }
72436
+
72437
+ sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenRead);
72438
+ sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regTemp);
72439
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, iOk);
72440
+ sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
72441
+ sqlite3VdbeJumpHere(v, iMustBeInt);
72442
+ sqlite3ReleaseTempReg(pParse, regTemp);
72443
+ }else{
72444
+ int nCol = pFKey->nCol;
72445
+ int regTemp = sqlite3GetTempRange(pParse, nCol);
72446
+ int regRec = sqlite3GetTempReg(pParse);
72447
+ KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx);
72448
+
72449
+ sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb);
72450
+ sqlite3VdbeChangeP4(v, -1, (char*)pKey, P4_KEYINFO_HANDOFF);
72451
+ for(i=0; i<nCol; i++){
72452
+ sqlite3VdbeAddOp2(v, OP_SCopy, aiCol[i]+1+regData, regTemp+i);
72453
+ }
72454
+
72455
+ /* If the parent table is the same as the child table, and we are about
72456
+ ** to increment the constraint-counter (i.e. this is an INSERT operation),
72457
+ ** then check if the row being inserted matches itself. If so, do not
72458
+ ** increment the constraint-counter. */
72459
+ if( pTab==pFKey->pFrom && nIncr==1 ){
72460
+ int iJump = sqlite3VdbeCurrentAddr(v) + nCol + 1;
72461
+ for(i=0; i<nCol; i++){
72462
+ int iChild = aiCol[i]+1+regData;
72463
+ int iParent = pIdx->aiColumn[i]+1+regData;
72464
+ sqlite3VdbeAddOp3(v, OP_Ne, iChild, iJump, iParent);
72465
+ }
72466
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, iOk);
72467
+ }
72468
+
72469
+ sqlite3VdbeAddOp3(v, OP_MakeRecord, regTemp, nCol, regRec);
72470
+ sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), 0);
72471
+ sqlite3VdbeAddOp3(v, OP_Found, iCur, iOk, regRec);
72472
+
72473
+ sqlite3ReleaseTempReg(pParse, regRec);
72474
+ sqlite3ReleaseTempRange(pParse, regTemp, nCol);
72475
+ }
72476
+ }
72477
+
72478
+ if( !pFKey->isDeferred && !pParse->pToplevel && !pParse->isMultiWrite ){
72479
+ /* Special case: If this is an INSERT statement that will insert exactly
72480
+ ** one row into the table, raise a constraint immediately instead of
72481
+ ** incrementing a counter. This is necessary as the VM code is being
72482
+ ** generated for will not open a statement transaction. */
72483
+ assert( nIncr==1 );
72484
+ sqlite3HaltConstraint(
72485
+ pParse, OE_Abort, "foreign key constraint failed", P4_STATIC
72486
+ );
72487
+ }else{
72488
+ if( nIncr>0 && pFKey->isDeferred==0 ){
72489
+ sqlite3ParseToplevel(pParse)->mayAbort = 1;
72490
+ }
72491
+ sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);
72492
+ }
72493
+
72494
+ sqlite3VdbeResolveLabel(v, iOk);
72495
+ sqlite3VdbeAddOp1(v, OP_Close, iCur);
72496
+}
72497
+
72498
+/*
72499
+** This function is called to generate code executed when a row is deleted
72500
+** from the parent table of foreign key constraint pFKey and, if pFKey is
72501
+** deferred, when a row is inserted into the same table. When generating
72502
+** code for an SQL UPDATE operation, this function may be called twice -
72503
+** once to "delete" the old row and once to "insert" the new row.
72504
+**
72505
+** The code generated by this function scans through the rows in the child
72506
+** table that correspond to the parent table row being deleted or inserted.
72507
+** For each child row found, one of the following actions is taken:
72508
+**
72509
+** Operation | FK type | Action taken
72510
+** --------------------------------------------------------------------------
72511
+** DELETE immediate Increment the "immediate constraint counter".
72512
+** Or, if the ON (UPDATE|DELETE) action is RESTRICT,
72513
+** throw a "foreign key constraint failed" exception.
72514
+**
72515
+** INSERT immediate Decrement the "immediate constraint counter".
72516
+**
72517
+** DELETE deferred Increment the "deferred constraint counter".
72518
+** Or, if the ON (UPDATE|DELETE) action is RESTRICT,
72519
+** throw a "foreign key constraint failed" exception.
72520
+**
72521
+** INSERT deferred Decrement the "deferred constraint counter".
72522
+**
72523
+** These operations are identified in the comment at the top of this file
72524
+** (fkey.c) as "I.2" and "D.2".
72525
+*/
72526
+static void fkScanChildren(
72527
+ Parse *pParse, /* Parse context */
72528
+ SrcList *pSrc, /* SrcList containing the table to scan */
72529
+ Table *pTab,
72530
+ Index *pIdx, /* Foreign key index */
72531
+ FKey *pFKey, /* Foreign key relationship */
72532
+ int *aiCol, /* Map from pIdx cols to child table cols */
72533
+ int regData, /* Referenced table data starts here */
72534
+ int nIncr /* Amount to increment deferred counter by */
72535
+){
72536
+ sqlite3 *db = pParse->db; /* Database handle */
72537
+ int i; /* Iterator variable */
72538
+ Expr *pWhere = 0; /* WHERE clause to scan with */
72539
+ NameContext sNameContext; /* Context used to resolve WHERE clause */
72540
+ WhereInfo *pWInfo; /* Context used by sqlite3WhereXXX() */
72541
+ int iFkIfZero = 0; /* Address of OP_FkIfZero */
72542
+ Vdbe *v = sqlite3GetVdbe(pParse);
72543
+
72544
+ assert( !pIdx || pIdx->pTable==pTab );
72545
+
72546
+ if( nIncr<0 ){
72547
+ iFkIfZero = sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey->isDeferred, 0);
72548
+ }
72549
+
72550
+ /* Create an Expr object representing an SQL expression like:
72551
+ **
72552
+ ** <parent-key1> = <child-key1> AND <parent-key2> = <child-key2> ...
72553
+ **
72554
+ ** The collation sequence used for the comparison should be that of
72555
+ ** the parent key columns. The affinity of the parent key column should
72556
+ ** be applied to each child key value before the comparison takes place.
72557
+ */
72558
+ for(i=0; i<pFKey->nCol; i++){
72559
+ Expr *pLeft; /* Value from parent table row */
72560
+ Expr *pRight; /* Column ref to child table */
72561
+ Expr *pEq; /* Expression (pLeft = pRight) */
72562
+ int iCol; /* Index of column in child table */
72563
+ const char *zCol; /* Name of column in child table */
72564
+
72565
+ pLeft = sqlite3Expr(db, TK_REGISTER, 0);
72566
+ if( pLeft ){
72567
+ /* Set the collation sequence and affinity of the LHS of each TK_EQ
72568
+ ** expression to the parent key column defaults. */
72569
+ if( pIdx ){
72570
+ Column *pCol;
72571
+ iCol = pIdx->aiColumn[i];
72572
+ pCol = &pIdx->pTable->aCol[iCol];
72573
+ pLeft->iTable = regData+iCol+1;
72574
+ pLeft->affinity = pCol->affinity;
72575
+ pLeft->pColl = sqlite3LocateCollSeq(pParse, pCol->zColl);
72576
+ }else{
72577
+ pLeft->iTable = regData;
72578
+ pLeft->affinity = SQLITE_AFF_INTEGER;
72579
+ }
72580
+ }
72581
+ iCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom;
72582
+ assert( iCol>=0 );
72583
+ zCol = pFKey->pFrom->aCol[iCol].zName;
72584
+ pRight = sqlite3Expr(db, TK_ID, zCol);
72585
+ pEq = sqlite3PExpr(pParse, TK_EQ, pLeft, pRight, 0);
72586
+ pWhere = sqlite3ExprAnd(db, pWhere, pEq);
72587
+ }
72588
+
72589
+ /* If the child table is the same as the parent table, and this scan
72590
+ ** is taking place as part of a DELETE operation (operation D.2), omit the
72591
+ ** row being deleted from the scan by adding ($rowid != rowid) to the WHERE
72592
+ ** clause, where $rowid is the rowid of the row being deleted. */
72593
+ if( pTab==pFKey->pFrom && nIncr>0 ){
72594
+ Expr *pEq; /* Expression (pLeft = pRight) */
72595
+ Expr *pLeft; /* Value from parent table row */
72596
+ Expr *pRight; /* Column ref to child table */
72597
+ pLeft = sqlite3Expr(db, TK_REGISTER, 0);
72598
+ pRight = sqlite3Expr(db, TK_COLUMN, 0);
72599
+ if( pLeft && pRight ){
72600
+ pLeft->iTable = regData;
72601
+ pLeft->affinity = SQLITE_AFF_INTEGER;
72602
+ pRight->iTable = pSrc->a[0].iCursor;
72603
+ pRight->iColumn = -1;
72604
+ }
72605
+ pEq = sqlite3PExpr(pParse, TK_NE, pLeft, pRight, 0);
72606
+ pWhere = sqlite3ExprAnd(db, pWhere, pEq);
72607
+ }
72608
+
72609
+ /* Resolve the references in the WHERE clause. */
72610
+ memset(&sNameContext, 0, sizeof(NameContext));
72611
+ sNameContext.pSrcList = pSrc;
72612
+ sNameContext.pParse = pParse;
72613
+ sqlite3ResolveExprNames(&sNameContext, pWhere);
72614
+
72615
+ /* Create VDBE to loop through the entries in pSrc that match the WHERE
72616
+ ** clause. If the constraint is not deferred, throw an exception for
72617
+ ** each row found. Otherwise, for deferred constraints, increment the
72618
+ ** deferred constraint counter by nIncr for each row selected. */
72619
+ pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0);
72620
+ if( nIncr>0 && pFKey->isDeferred==0 ){
72621
+ sqlite3ParseToplevel(pParse)->mayAbort = 1;
72622
+ }
72623
+ sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);
72624
+ if( pWInfo ){
72625
+ sqlite3WhereEnd(pWInfo);
72626
+ }
72627
+
72628
+ /* Clean up the WHERE clause constructed above. */
72629
+ sqlite3ExprDelete(db, pWhere);
72630
+ if( iFkIfZero ){
72631
+ sqlite3VdbeJumpHere(v, iFkIfZero);
72632
+ }
72633
+}
72634
+
72635
+/*
72636
+** This function returns a pointer to the head of a linked list of FK
72637
+** constraints for which table pTab is the parent table. For example,
72638
+** given the following schema:
72639
+**
72640
+** CREATE TABLE t1(a PRIMARY KEY);
72641
+** CREATE TABLE t2(b REFERENCES t1(a);
72642
+**
72643
+** Calling this function with table "t1" as an argument returns a pointer
72644
+** to the FKey structure representing the foreign key constraint on table
72645
+** "t2". Calling this function with "t2" as the argument would return a
72646
+** NULL pointer (as there are no FK constraints for which t2 is the parent
72647
+** table).
72648
+*/
72649
+SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *pTab){
72650
+ int nName = sqlite3Strlen30(pTab->zName);
72651
+ return (FKey *)sqlite3HashFind(&pTab->pSchema->fkeyHash, pTab->zName, nName);
72652
+}
72653
+
72654
+/*
72655
+** The second argument is a Trigger structure allocated by the
72656
+** fkActionTrigger() routine. This function deletes the Trigger structure
72657
+** and all of its sub-components.
72658
+**
72659
+** The Trigger structure or any of its sub-components may be allocated from
72660
+** the lookaside buffer belonging to database handle dbMem.
72661
+*/
72662
+static void fkTriggerDelete(sqlite3 *dbMem, Trigger *p){
72663
+ if( p ){
72664
+ TriggerStep *pStep = p->step_list;
72665
+ sqlite3ExprDelete(dbMem, pStep->pWhere);
72666
+ sqlite3ExprListDelete(dbMem, pStep->pExprList);
72667
+ sqlite3SelectDelete(dbMem, pStep->pSelect);
72668
+ sqlite3ExprDelete(dbMem, p->pWhen);
72669
+ sqlite3DbFree(dbMem, p);
72670
+ }
72671
+}
72672
+
72673
+/*
72674
+** This function is called to generate code that runs when table pTab is
72675
+** being dropped from the database. The SrcList passed as the second argument
72676
+** to this function contains a single entry guaranteed to resolve to
72677
+** table pTab.
72678
+**
72679
+** Normally, no code is required. However, if either
72680
+**
72681
+** (a) The table is the parent table of a FK constraint, or
72682
+** (b) The table is the child table of a deferred FK constraint and it is
72683
+** determined at runtime that there are outstanding deferred FK
72684
+** constraint violations in the database,
72685
+**
72686
+** then the equivalent of "DELETE FROM <tbl>" is executed before dropping
72687
+** the table from the database. Triggers are disabled while running this
72688
+** DELETE, but foreign key actions are not.
72689
+*/
72690
+SQLITE_PRIVATE void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){
72691
+ sqlite3 *db = pParse->db;
72692
+ if( (db->flags&SQLITE_ForeignKeys) && !IsVirtual(pTab) && !pTab->pSelect ){
72693
+ int iSkip = 0;
72694
+ Vdbe *v = sqlite3GetVdbe(pParse);
72695
+
72696
+ assert( v ); /* VDBE has already been allocated */
72697
+ if( sqlite3FkReferences(pTab)==0 ){
72698
+ /* Search for a deferred foreign key constraint for which this table
72699
+ ** is the child table. If one cannot be found, return without
72700
+ ** generating any VDBE code. If one can be found, then jump over
72701
+ ** the entire DELETE if there are no outstanding deferred constraints
72702
+ ** when this statement is run. */
72703
+ FKey *p;
72704
+ for(p=pTab->pFKey; p; p=p->pNextFrom){
72705
+ if( p->isDeferred ) break;
72706
+ }
72707
+ if( !p ) return;
72708
+ iSkip = sqlite3VdbeMakeLabel(v);
72709
+ sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip);
72710
+ }
72711
+
72712
+ pParse->disableTriggers = 1;
72713
+ sqlite3DeleteFrom(pParse, sqlite3SrcListDup(db, pName, 0), 0);
72714
+ pParse->disableTriggers = 0;
72715
+
72716
+ /* If the DELETE has generated immediate foreign key constraint
72717
+ ** violations, halt the VDBE and return an error at this point, before
72718
+ ** any modifications to the schema are made. This is because statement
72719
+ ** transactions are not able to rollback schema changes. */
72720
+ sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);
72721
+ sqlite3HaltConstraint(
72722
+ pParse, OE_Abort, "foreign key constraint failed", P4_STATIC
72723
+ );
72724
+
72725
+ if( iSkip ){
72726
+ sqlite3VdbeResolveLabel(v, iSkip);
72727
+ }
72728
+ }
72729
+}
72730
+
72731
+/*
72732
+** This function is called when inserting, deleting or updating a row of
72733
+** table pTab to generate VDBE code to perform foreign key constraint
72734
+** processing for the operation.
72735
+**
72736
+** For a DELETE operation, parameter regOld is passed the index of the
72737
+** first register in an array of (pTab->nCol+1) registers containing the
72738
+** rowid of the row being deleted, followed by each of the column values
72739
+** of the row being deleted, from left to right. Parameter regNew is passed
72740
+** zero in this case.
72741
+**
72742
+** For an INSERT operation, regOld is passed zero and regNew is passed the
72743
+** first register of an array of (pTab->nCol+1) registers containing the new
72744
+** row data.
72745
+**
72746
+** For an UPDATE operation, this function is called twice. Once before
72747
+** the original record is deleted from the table using the calling convention
72748
+** described for DELETE. Then again after the original record is deleted
72749
+** but before the new record is inserted using the INSERT convention.
72750
+*/
72751
+SQLITE_PRIVATE void sqlite3FkCheck(
72752
+ Parse *pParse, /* Parse context */
72753
+ Table *pTab, /* Row is being deleted from this table */
72754
+ int regOld, /* Previous row data is stored here */
72755
+ int regNew /* New row data is stored here */
72756
+){
72757
+ sqlite3 *db = pParse->db; /* Database handle */
72758
+ Vdbe *v; /* VM to write code to */
72759
+ FKey *pFKey; /* Used to iterate through FKs */
72760
+ int iDb; /* Index of database containing pTab */
72761
+ const char *zDb; /* Name of database containing pTab */
72762
+ int isIgnoreErrors = pParse->disableTriggers;
72763
+
72764
+ /* Exactly one of regOld and regNew should be non-zero. */
72765
+ assert( (regOld==0)!=(regNew==0) );
72766
+
72767
+ /* If foreign-keys are disabled, this function is a no-op. */
72768
+ if( (db->flags&SQLITE_ForeignKeys)==0 ) return;
72769
+
72770
+ v = sqlite3GetVdbe(pParse);
72771
+ iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
72772
+ zDb = db->aDb[iDb].zName;
72773
+
72774
+ /* Loop through all the foreign key constraints for which pTab is the
72775
+ ** child table (the table that the foreign key definition is part of). */
72776
+ for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
72777
+ Table *pTo; /* Parent table of foreign key pFKey */
72778
+ Index *pIdx = 0; /* Index on key columns in pTo */
72779
+ int *aiFree = 0;
72780
+ int *aiCol;
72781
+ int iCol;
72782
+ int i;
72783
+ int isIgnore = 0;
72784
+
72785
+ /* Find the parent table of this foreign key. Also find a unique index
72786
+ ** on the parent key columns in the parent table. If either of these
72787
+ ** schema items cannot be located, set an error in pParse and return
72788
+ ** early. */
72789
+ if( pParse->disableTriggers ){
72790
+ pTo = sqlite3FindTable(db, pFKey->zTo, zDb);
72791
+ }else{
72792
+ pTo = sqlite3LocateTable(pParse, 0, pFKey->zTo, zDb);
72793
+ }
72794
+ if( !pTo || locateFkeyIndex(pParse, pTo, pFKey, &pIdx, &aiFree) ){
72795
+ if( !isIgnoreErrors || db->mallocFailed ) return;
72796
+ continue;
72797
+ }
72798
+ assert( pFKey->nCol==1 || (aiFree && pIdx) );
72799
+
72800
+ if( aiFree ){
72801
+ aiCol = aiFree;
72802
+ }else{
72803
+ iCol = pFKey->aCol[0].iFrom;
72804
+ aiCol = &iCol;
72805
+ }
72806
+ for(i=0; i<pFKey->nCol; i++){
72807
+ if( aiCol[i]==pTab->iPKey ){
72808
+ aiCol[i] = -1;
72809
+ }
72810
+#ifndef SQLITE_OMIT_AUTHORIZATION
72811
+ /* Request permission to read the parent key columns. If the
72812
+ ** authorization callback returns SQLITE_IGNORE, behave as if any
72813
+ ** values read from the parent table are NULL. */
72814
+ if( db->xAuth ){
72815
+ int rcauth;
72816
+ char *zCol = pTo->aCol[pIdx ? pIdx->aiColumn[i] : pTo->iPKey].zName;
72817
+ rcauth = sqlite3AuthReadCol(pParse, pTo->zName, zCol, iDb);
72818
+ isIgnore = (rcauth==SQLITE_IGNORE);
72819
+ }
72820
+#endif
72821
+ }
72822
+
72823
+ /* Take a shared-cache advisory read-lock on the parent table. Allocate
72824
+ ** a cursor to use to search the unique index on the parent key columns
72825
+ ** in the parent table. */
72826
+ sqlite3TableLock(pParse, iDb, pTo->tnum, 0, pTo->zName);
72827
+ pParse->nTab++;
72828
+
72829
+ if( regOld!=0 ){
72830
+ /* A row is being removed from the child table. Search for the parent.
72831
+ ** If the parent does not exist, removing the child row resolves an
72832
+ ** outstanding foreign key constraint violation. */
72833
+ fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regOld, -1,isIgnore);
72834
+ }
72835
+ if( regNew!=0 ){
72836
+ /* A row is being added to the child table. If a parent row cannot
72837
+ ** be found, adding the child row has violated the FK constraint. */
72838
+ fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regNew, +1,isIgnore);
72839
+ }
72840
+
72841
+ sqlite3DbFree(db, aiFree);
72842
+ }
72843
+
72844
+ /* Loop through all the foreign key constraints that refer to this table */
72845
+ for(pFKey = sqlite3FkReferences(pTab); pFKey; pFKey=pFKey->pNextTo){
72846
+ Index *pIdx = 0; /* Foreign key index for pFKey */
72847
+ SrcList *pSrc;
72848
+ int *aiCol = 0;
72849
+
72850
+ if( !pFKey->isDeferred && !pParse->pToplevel && !pParse->isMultiWrite ){
72851
+ assert( regOld==0 && regNew!=0 );
72852
+ /* Inserting a single row into a parent table cannot cause an immediate
72853
+ ** foreign key violation. So do nothing in this case. */
72854
+ continue;
72855
+ }
72856
+
72857
+ if( locateFkeyIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ){
72858
+ if( !isIgnoreErrors || db->mallocFailed ) return;
72859
+ continue;
72860
+ }
72861
+ assert( aiCol || pFKey->nCol==1 );
72862
+
72863
+ /* Create a SrcList structure containing a single table (the table
72864
+ ** the foreign key that refers to this table is attached to). This
72865
+ ** is required for the sqlite3WhereXXX() interface. */
72866
+ pSrc = sqlite3SrcListAppend(db, 0, 0, 0);
72867
+ if( pSrc ){
72868
+ struct SrcList_item *pItem = pSrc->a;
72869
+ pItem->pTab = pFKey->pFrom;
72870
+ pItem->zName = pFKey->pFrom->zName;
72871
+ pItem->pTab->nRef++;
72872
+ pItem->iCursor = pParse->nTab++;
72873
+
72874
+ if( regNew!=0 ){
72875
+ fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1);
72876
+ }
72877
+ if( regOld!=0 ){
72878
+ /* If there is a RESTRICT action configured for the current operation
72879
+ ** on the parent table of this FK, then throw an exception
72880
+ ** immediately if the FK constraint is violated, even if this is a
72881
+ ** deferred trigger. That's what RESTRICT means. To defer checking
72882
+ ** the constraint, the FK should specify NO ACTION (represented
72883
+ ** using OE_None). NO ACTION is the default. */
72884
+ fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1);
72885
+ }
72886
+ pItem->zName = 0;
72887
+ sqlite3SrcListDelete(db, pSrc);
72888
+ }
72889
+ sqlite3DbFree(db, aiCol);
72890
+ }
72891
+}
72892
+
72893
+#define COLUMN_MASK(x) (((x)>31) ? 0xffffffff : ((u32)1<<(x)))
72894
+
72895
+/*
72896
+** This function is called before generating code to update or delete a
72897
+** row contained in table pTab.
72898
+*/
72899
+SQLITE_PRIVATE u32 sqlite3FkOldmask(
72900
+ Parse *pParse, /* Parse context */
72901
+ Table *pTab /* Table being modified */
72902
+){
72903
+ u32 mask = 0;
72904
+ if( pParse->db->flags&SQLITE_ForeignKeys ){
72905
+ FKey *p;
72906
+ int i;
72907
+ for(p=pTab->pFKey; p; p=p->pNextFrom){
72908
+ for(i=0; i<p->nCol; i++) mask |= COLUMN_MASK(p->aCol[i].iFrom);
72909
+ }
72910
+ for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){
72911
+ Index *pIdx = 0;
72912
+ locateFkeyIndex(pParse, pTab, p, &pIdx, 0);
72913
+ if( pIdx ){
72914
+ for(i=0; i<pIdx->nColumn; i++) mask |= COLUMN_MASK(pIdx->aiColumn[i]);
72915
+ }
72916
+ }
72917
+ }
72918
+ return mask;
72919
+}
72920
+
72921
+/*
72922
+** This function is called before generating code to update or delete a
72923
+** row contained in table pTab. If the operation is a DELETE, then
72924
+** parameter aChange is passed a NULL value. For an UPDATE, aChange points
72925
+** to an array of size N, where N is the number of columns in table pTab.
72926
+** If the i'th column is not modified by the UPDATE, then the corresponding
72927
+** entry in the aChange[] array is set to -1. If the column is modified,
72928
+** the value is 0 or greater. Parameter chngRowid is set to true if the
72929
+** UPDATE statement modifies the rowid fields of the table.
72930
+**
72931
+** If any foreign key processing will be required, this function returns
72932
+** true. If there is no foreign key related processing, this function
72933
+** returns false.
72934
+*/
72935
+SQLITE_PRIVATE int sqlite3FkRequired(
72936
+ Parse *pParse, /* Parse context */
72937
+ Table *pTab, /* Table being modified */
72938
+ int *aChange, /* Non-NULL for UPDATE operations */
72939
+ int chngRowid /* True for UPDATE that affects rowid */
72940
+){
72941
+ if( pParse->db->flags&SQLITE_ForeignKeys ){
72942
+ if( !aChange ){
72943
+ /* A DELETE operation. Foreign key processing is required if the
72944
+ ** table in question is either the child or parent table for any
72945
+ ** foreign key constraint. */
72946
+ return (sqlite3FkReferences(pTab) || pTab->pFKey);
72947
+ }else{
72948
+ /* This is an UPDATE. Foreign key processing is only required if the
72949
+ ** operation modifies one or more child or parent key columns. */
72950
+ int i;
72951
+ FKey *p;
72952
+
72953
+ /* Check if any child key columns are being modified. */
72954
+ for(p=pTab->pFKey; p; p=p->pNextFrom){
72955
+ for(i=0; i<p->nCol; i++){
72956
+ int iChildKey = p->aCol[i].iFrom;
72957
+ if( aChange[iChildKey]>=0 ) return 1;
72958
+ if( iChildKey==pTab->iPKey && chngRowid ) return 1;
72959
+ }
72960
+ }
72961
+
72962
+ /* Check if any parent key columns are being modified. */
72963
+ for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){
72964
+ for(i=0; i<p->nCol; i++){
72965
+ char *zKey = p->aCol[i].zCol;
72966
+ int iKey;
72967
+ for(iKey=0; iKey<pTab->nCol; iKey++){
72968
+ Column *pCol = &pTab->aCol[iKey];
72969
+ if( (zKey ? !sqlite3StrICmp(pCol->zName, zKey) : pCol->isPrimKey) ){
72970
+ if( aChange[iKey]>=0 ) return 1;
72971
+ if( iKey==pTab->iPKey && chngRowid ) return 1;
72972
+ }
72973
+ }
72974
+ }
72975
+ }
72976
+ }
72977
+ }
72978
+ return 0;
72979
+}
72980
+
72981
+/*
72982
+** This function is called when an UPDATE or DELETE operation is being
72983
+** compiled on table pTab, which is the parent table of foreign-key pFKey.
72984
+** If the current operation is an UPDATE, then the pChanges parameter is
72985
+** passed a pointer to the list of columns being modified. If it is a
72986
+** DELETE, pChanges is passed a NULL pointer.
72987
+**
72988
+** It returns a pointer to a Trigger structure containing a trigger
72989
+** equivalent to the ON UPDATE or ON DELETE action specified by pFKey.
72990
+** If the action is "NO ACTION" or "RESTRICT", then a NULL pointer is
72991
+** returned (these actions require no special handling by the triggers
72992
+** sub-system, code for them is created by fkScanChildren()).
72993
+**
72994
+** For example, if pFKey is the foreign key and pTab is table "p" in
72995
+** the following schema:
72996
+**
72997
+** CREATE TABLE p(pk PRIMARY KEY);
72998
+** CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE);
72999
+**
73000
+** then the returned trigger structure is equivalent to:
73001
+**
73002
+** CREATE TRIGGER ... DELETE ON p BEGIN
73003
+** DELETE FROM c WHERE ck = old.pk;
73004
+** END;
73005
+**
73006
+** The returned pointer is cached as part of the foreign key object. It
73007
+** is eventually freed along with the rest of the foreign key object by
73008
+** sqlite3FkDelete().
73009
+*/
73010
+static Trigger *fkActionTrigger(
73011
+ Parse *pParse, /* Parse context */
73012
+ Table *pTab, /* Table being updated or deleted from */
73013
+ FKey *pFKey, /* Foreign key to get action for */
73014
+ ExprList *pChanges /* Change-list for UPDATE, NULL for DELETE */
73015
+){
73016
+ sqlite3 *db = pParse->db; /* Database handle */
73017
+ int action; /* One of OE_None, OE_Cascade etc. */
73018
+ Trigger *pTrigger; /* Trigger definition to return */
73019
+ int iAction = (pChanges!=0); /* 1 for UPDATE, 0 for DELETE */
73020
+
73021
+ action = pFKey->aAction[iAction];
73022
+ pTrigger = pFKey->apTrigger[iAction];
73023
+
73024
+ if( action!=OE_None && !pTrigger ){
73025
+ u8 enableLookaside; /* Copy of db->lookaside.bEnabled */
73026
+ char const *zFrom; /* Name of child table */
73027
+ int nFrom; /* Length in bytes of zFrom */
73028
+ Index *pIdx = 0; /* Parent key index for this FK */
73029
+ int *aiCol = 0; /* child table cols -> parent key cols */
73030
+ TriggerStep *pStep = 0; /* First (only) step of trigger program */
73031
+ Expr *pWhere = 0; /* WHERE clause of trigger step */
73032
+ ExprList *pList = 0; /* Changes list if ON UPDATE CASCADE */
73033
+ Select *pSelect = 0; /* If RESTRICT, "SELECT RAISE(...)" */
73034
+ int i; /* Iterator variable */
73035
+ Expr *pWhen = 0; /* WHEN clause for the trigger */
73036
+
73037
+ if( locateFkeyIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ) return 0;
73038
+ assert( aiCol || pFKey->nCol==1 );
73039
+
73040
+ for(i=0; i<pFKey->nCol; i++){
73041
+ Token tOld = { "old", 3 }; /* Literal "old" token */
73042
+ Token tNew = { "new", 3 }; /* Literal "new" token */
73043
+ Token tFromCol; /* Name of column in child table */
73044
+ Token tToCol; /* Name of column in parent table */
73045
+ int iFromCol; /* Idx of column in child table */
73046
+ Expr *pEq; /* tFromCol = OLD.tToCol */
73047
+
73048
+ iFromCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom;
73049
+ assert( iFromCol>=0 );
73050
+ tToCol.z = pIdx ? pTab->aCol[pIdx->aiColumn[i]].zName : "oid";
73051
+ tFromCol.z = pFKey->pFrom->aCol[iFromCol].zName;
73052
+
73053
+ tToCol.n = sqlite3Strlen30(tToCol.z);
73054
+ tFromCol.n = sqlite3Strlen30(tFromCol.z);
73055
+
73056
+ /* Create the expression "OLD.zToCol = zFromCol". It is important
73057
+ ** that the "OLD.zToCol" term is on the LHS of the = operator, so
73058
+ ** that the affinity and collation sequence associated with the
73059
+ ** parent table are used for the comparison. */
73060
+ pEq = sqlite3PExpr(pParse, TK_EQ,
73061
+ sqlite3PExpr(pParse, TK_DOT,
73062
+ sqlite3PExpr(pParse, TK_ID, 0, 0, &tOld),
73063
+ sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol)
73064
+ , 0),
73065
+ sqlite3PExpr(pParse, TK_ID, 0, 0, &tFromCol)
73066
+ , 0);
73067
+ pWhere = sqlite3ExprAnd(db, pWhere, pEq);
73068
+
73069
+ /* For ON UPDATE, construct the next term of the WHEN clause.
73070
+ ** The final WHEN clause will be like this:
73071
+ **
73072
+ ** WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN)
73073
+ */
73074
+ if( pChanges ){
73075
+ pEq = sqlite3PExpr(pParse, TK_IS,
73076
+ sqlite3PExpr(pParse, TK_DOT,
73077
+ sqlite3PExpr(pParse, TK_ID, 0, 0, &tOld),
73078
+ sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol),
73079
+ 0),
73080
+ sqlite3PExpr(pParse, TK_DOT,
73081
+ sqlite3PExpr(pParse, TK_ID, 0, 0, &tNew),
73082
+ sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol),
73083
+ 0),
73084
+ 0);
73085
+ pWhen = sqlite3ExprAnd(db, pWhen, pEq);
73086
+ }
73087
+
73088
+ if( action!=OE_Restrict && (action!=OE_Cascade || pChanges) ){
73089
+ Expr *pNew;
73090
+ if( action==OE_Cascade ){
73091
+ pNew = sqlite3PExpr(pParse, TK_DOT,
73092
+ sqlite3PExpr(pParse, TK_ID, 0, 0, &tNew),
73093
+ sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol)
73094
+ , 0);
73095
+ }else if( action==OE_SetDflt ){
73096
+ Expr *pDflt = pFKey->pFrom->aCol[iFromCol].pDflt;
73097
+ if( pDflt ){
73098
+ pNew = sqlite3ExprDup(db, pDflt, 0);
73099
+ }else{
73100
+ pNew = sqlite3PExpr(pParse, TK_NULL, 0, 0, 0);
73101
+ }
73102
+ }else{
73103
+ pNew = sqlite3PExpr(pParse, TK_NULL, 0, 0, 0);
73104
+ }
73105
+ pList = sqlite3ExprListAppend(pParse, pList, pNew);
73106
+ sqlite3ExprListSetName(pParse, pList, &tFromCol, 0);
73107
+ }
73108
+ }
73109
+ sqlite3DbFree(db, aiCol);
73110
+
73111
+ zFrom = pFKey->pFrom->zName;
73112
+ nFrom = sqlite3Strlen30(zFrom);
73113
+
73114
+ if( action==OE_Restrict ){
73115
+ Token tFrom;
73116
+ Expr *pRaise;
73117
+
73118
+ tFrom.z = zFrom;
73119
+ tFrom.n = nFrom;
73120
+ pRaise = sqlite3Expr(db, TK_RAISE, "foreign key constraint failed");
73121
+ if( pRaise ){
73122
+ pRaise->affinity = OE_Abort;
73123
+ }
73124
+ pSelect = sqlite3SelectNew(pParse,
73125
+ sqlite3ExprListAppend(pParse, 0, pRaise),
73126
+ sqlite3SrcListAppend(db, 0, &tFrom, 0),
73127
+ pWhere,
73128
+ 0, 0, 0, 0, 0, 0
73129
+ );
73130
+ pWhere = 0;
73131
+ }
73132
+
73133
+ /* In the current implementation, pTab->dbMem==0 for all tables except
73134
+ ** for temporary tables used to describe subqueries. And temporary
73135
+ ** tables do not have foreign key constraints. Hence, pTab->dbMem
73136
+ ** should always be 0 there.
73137
+ */
73138
+ enableLookaside = db->lookaside.bEnabled;
73139
+ db->lookaside.bEnabled = 0;
73140
+
73141
+ pTrigger = (Trigger *)sqlite3DbMallocZero(db,
73142
+ sizeof(Trigger) + /* struct Trigger */
73143
+ sizeof(TriggerStep) + /* Single step in trigger program */
73144
+ nFrom + 1 /* Space for pStep->target.z */
73145
+ );
73146
+ if( pTrigger ){
73147
+ pStep = pTrigger->step_list = (TriggerStep *)&pTrigger[1];
73148
+ pStep->target.z = (char *)&pStep[1];
73149
+ pStep->target.n = nFrom;
73150
+ memcpy((char *)pStep->target.z, zFrom, nFrom);
73151
+
73152
+ pStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
73153
+ pStep->pExprList = sqlite3ExprListDup(db, pList, EXPRDUP_REDUCE);
73154
+ pStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
73155
+ if( pWhen ){
73156
+ pWhen = sqlite3PExpr(pParse, TK_NOT, pWhen, 0, 0);
73157
+ pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);
73158
+ }
73159
+ }
73160
+
73161
+ /* Re-enable the lookaside buffer, if it was disabled earlier. */
73162
+ db->lookaside.bEnabled = enableLookaside;
73163
+
73164
+ sqlite3ExprDelete(db, pWhere);
73165
+ sqlite3ExprDelete(db, pWhen);
73166
+ sqlite3ExprListDelete(db, pList);
73167
+ sqlite3SelectDelete(db, pSelect);
73168
+ if( db->mallocFailed==1 ){
73169
+ fkTriggerDelete(db, pTrigger);
73170
+ return 0;
73171
+ }
73172
+
73173
+ switch( action ){
73174
+ case OE_Restrict:
73175
+ pStep->op = TK_SELECT;
73176
+ break;
73177
+ case OE_Cascade:
73178
+ if( !pChanges ){
73179
+ pStep->op = TK_DELETE;
73180
+ break;
73181
+ }
73182
+ default:
73183
+ pStep->op = TK_UPDATE;
73184
+ }
73185
+ pStep->pTrig = pTrigger;
73186
+ pTrigger->pSchema = pTab->pSchema;
73187
+ pTrigger->pTabSchema = pTab->pSchema;
73188
+ pFKey->apTrigger[iAction] = pTrigger;
73189
+ pTrigger->op = (pChanges ? TK_UPDATE : TK_DELETE);
73190
+ }
73191
+
73192
+ return pTrigger;
73193
+}
73194
+
73195
+/*
73196
+** This function is called when deleting or updating a row to implement
73197
+** any required CASCADE, SET NULL or SET DEFAULT actions.
73198
+*/
73199
+SQLITE_PRIVATE void sqlite3FkActions(
73200
+ Parse *pParse, /* Parse context */
73201
+ Table *pTab, /* Table being updated or deleted from */
73202
+ ExprList *pChanges, /* Change-list for UPDATE, NULL for DELETE */
73203
+ int regOld /* Address of array containing old row */
73204
+){
73205
+ /* If foreign-key support is enabled, iterate through all FKs that
73206
+ ** refer to table pTab. If there is an action associated with the FK
73207
+ ** for this operation (either update or delete), invoke the associated
73208
+ ** trigger sub-program. */
73209
+ if( pParse->db->flags&SQLITE_ForeignKeys ){
73210
+ FKey *pFKey; /* Iterator variable */
73211
+ for(pFKey = sqlite3FkReferences(pTab); pFKey; pFKey=pFKey->pNextTo){
73212
+ Trigger *pAction = fkActionTrigger(pParse, pTab, pFKey, pChanges);
73213
+ if( pAction ){
73214
+ sqlite3CodeRowTriggerDirect(pParse, pAction, pTab, regOld, OE_Abort, 0);
73215
+ }
73216
+ }
73217
+ }
73218
+}
73219
+
73220
+#endif /* ifndef SQLITE_OMIT_TRIGGER */
73221
+
73222
+/*
73223
+** Free all memory associated with foreign key definitions attached to
73224
+** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash
73225
+** hash table.
73226
+*/
73227
+SQLITE_PRIVATE void sqlite3FkDelete(Table *pTab){
73228
+ FKey *pFKey; /* Iterator variable */
73229
+ FKey *pNext; /* Copy of pFKey->pNextFrom */
73230
+
73231
+ for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){
73232
+
73233
+ /* Remove the FK from the fkeyHash hash table. */
73234
+ if( pFKey->pPrevTo ){
73235
+ pFKey->pPrevTo->pNextTo = pFKey->pNextTo;
73236
+ }else{
73237
+ void *data = (void *)pFKey->pNextTo;
73238
+ const char *z = (data ? pFKey->pNextTo->zTo : pFKey->zTo);
73239
+ sqlite3HashInsert(&pTab->pSchema->fkeyHash, z, sqlite3Strlen30(z), data);
73240
+ }
73241
+ if( pFKey->pNextTo ){
73242
+ pFKey->pNextTo->pPrevTo = pFKey->pPrevTo;
73243
+ }
73244
+
73245
+ /* Delete any triggers created to implement actions for this FK. */
73246
+#ifndef SQLITE_OMIT_TRIGGER
73247
+ fkTriggerDelete(pTab->dbMem, pFKey->apTrigger[0]);
73248
+ fkTriggerDelete(pTab->dbMem, pFKey->apTrigger[1]);
73249
+#endif
73250
+
73251
+ /* EV: R-30323-21917 Each foreign key constraint in SQLite is
73252
+ ** classified as either immediate or deferred.
73253
+ */
73254
+ assert( pFKey->isDeferred==0 || pFKey->isDeferred==1 );
73255
+
73256
+ pNext = pFKey->pNextFrom;
73257
+ sqlite3DbFree(pTab->dbMem, pFKey);
73258
+ }
73259
+}
73260
+#endif /* ifndef SQLITE_OMIT_FOREIGN_KEY */
73261
+
73262
+/************** End of fkey.c ************************************************/
7158173263
/************** Begin file insert.c ******************************************/
7158273264
/*
7158373265
** 2001 September 15
7158473266
**
7158573267
** The author disclaims copyright to this source code. In place of
@@ -72448,11 +74130,11 @@
7244874130
sqlite3TableAffinityStr(v, pTab);
7244974131
}
7245074132
7245174133
/* Fire BEFORE or INSTEAD OF triggers */
7245274134
sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_BEFORE,
72453
- pTab, -1, regCols-pTab->nCol-1, onError, endOfLoop);
74135
+ pTab, regCols-pTab->nCol-1, onError, endOfLoop);
7245474136
7245574137
sqlite3ReleaseTempRange(pParse, regCols, pTab->nCol+1);
7245674138
}
7245774139
7245874140
/* Push the record number for the new entry onto the stack. The
@@ -72557,10 +74239,11 @@
7255774239
{
7255874240
int isReplace; /* Set to true if constraints may cause a replace */
7255974241
sqlite3GenerateConstraintChecks(pParse, pTab, baseCur, regIns, aRegIdx,
7256074242
keyColumn>=0, 0, onError, endOfLoop, &isReplace
7256174243
);
74244
+ sqlite3FkCheck(pParse, pTab, 0, regIns);
7256274245
sqlite3CompleteInsertion(
7256374246
pParse, pTab, baseCur, regIns, aRegIdx, 0, appendFlag, isReplace==0
7256474247
);
7256574248
}
7256674249
}
@@ -72572,11 +74255,11 @@
7257274255
}
7257374256
7257474257
if( pTrigger ){
7257574258
/* Code AFTER triggers */
7257674259
sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_AFTER,
72577
- pTab, -1, regData-2-pTab->nCol, onError, endOfLoop);
74260
+ pTab, regData-2-pTab->nCol, onError, endOfLoop);
7257874261
}
7257974262
7258074263
/* The bottom of the main insertion loop, if the data source
7258174264
** is a SELECT statement.
7258274265
*/
@@ -72623,10 +74306,24 @@
7262374306
sqlite3ExprListDelete(db, pList);
7262474307
sqlite3SelectDelete(db, pSelect);
7262574308
sqlite3IdListDelete(db, pColumn);
7262674309
sqlite3DbFree(db, aRegIdx);
7262774310
}
74311
+
74312
+/* Make sure "isView" and other macros defined above are undefined. Otherwise
74313
+** thely may interfere with compilation of other functions in this file
74314
+** (or in another file, if this file becomes part of the amalgamation). */
74315
+#ifdef isView
74316
+ #undef isView
74317
+#endif
74318
+#ifdef pTrigger
74319
+ #undef pTrigger
74320
+#endif
74321
+#ifdef tmask
74322
+ #undef tmask
74323
+#endif
74324
+
7262874325
7262974326
/*
7263074327
** Generate code to do constraint checks prior to an INSERT or an UPDATE.
7263174328
**
7263274329
** The input is a range of consecutive registers as follows:
@@ -72803,61 +74500,60 @@
7280374500
onError = overrideError;
7280474501
}else if( onError==OE_Default ){
7280574502
onError = OE_Abort;
7280674503
}
7280774504
72808
- if( onError!=OE_Replace || pTab->pIndex ){
72809
- if( isUpdate ){
72810
- j2 = sqlite3VdbeAddOp3(v, OP_Eq, regRowid, 0, rowidChng);
72811
- }
72812
- j3 = sqlite3VdbeAddOp3(v, OP_NotExists, baseCur, 0, regRowid);
72813
- switch( onError ){
72814
- default: {
72815
- onError = OE_Abort;
72816
- /* Fall thru into the next case */
72817
- }
72818
- case OE_Rollback:
72819
- case OE_Abort:
72820
- case OE_Fail: {
72821
- sqlite3HaltConstraint(
72822
- pParse, onError, "PRIMARY KEY must be unique", P4_STATIC);
72823
- break;
72824
- }
72825
- case OE_Replace: {
72826
- /* If there are DELETE triggers on this table and the
72827
- ** recursive-triggers flag is set, call GenerateRowDelete() to
72828
- ** remove the conflicting row from the the table. This will fire
72829
- ** the triggers and remove both the table and index b-tree entries.
72830
- **
72831
- ** Otherwise, if there are no triggers or the recursive-triggers
72832
- ** flag is not set, call GenerateRowIndexDelete(). This removes
72833
- ** the index b-tree entries only. The table b-tree entry will be
72834
- ** replaced by the new entry when it is inserted. */
72835
- Trigger *pTrigger = 0;
72836
- if( pParse->db->flags&SQLITE_RecTriggers ){
72837
- pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
72838
- }
72839
- if( pTrigger ){
72840
- sqlite3GenerateRowDelete(
72841
- pParse, pTab, baseCur, regRowid, 0, pTrigger, OE_Replace
72842
- );
72843
- }else{
72844
- sqlite3GenerateRowIndexDelete(pParse, pTab, baseCur, 0);
72845
- }
72846
- seenReplace = 1;
72847
- break;
72848
- }
72849
- case OE_Ignore: {
72850
- assert( seenReplace==0 );
72851
- sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
72852
- break;
72853
- }
72854
- }
72855
- sqlite3VdbeJumpHere(v, j3);
72856
- if( isUpdate ){
72857
- sqlite3VdbeJumpHere(v, j2);
72858
- }
74505
+ if( isUpdate ){
74506
+ j2 = sqlite3VdbeAddOp3(v, OP_Eq, regRowid, 0, rowidChng);
74507
+ }
74508
+ j3 = sqlite3VdbeAddOp3(v, OP_NotExists, baseCur, 0, regRowid);
74509
+ switch( onError ){
74510
+ default: {
74511
+ onError = OE_Abort;
74512
+ /* Fall thru into the next case */
74513
+ }
74514
+ case OE_Rollback:
74515
+ case OE_Abort:
74516
+ case OE_Fail: {
74517
+ sqlite3HaltConstraint(
74518
+ pParse, onError, "PRIMARY KEY must be unique", P4_STATIC);
74519
+ break;
74520
+ }
74521
+ case OE_Replace: {
74522
+ /* If there are DELETE triggers on this table and the
74523
+ ** recursive-triggers flag is set, call GenerateRowDelete() to
74524
+ ** remove the conflicting row from the the table. This will fire
74525
+ ** the triggers and remove both the table and index b-tree entries.
74526
+ **
74527
+ ** Otherwise, if there are no triggers or the recursive-triggers
74528
+ ** flag is not set, call GenerateRowIndexDelete(). This removes
74529
+ ** the index b-tree entries only. The table b-tree entry will be
74530
+ ** replaced by the new entry when it is inserted. */
74531
+ Trigger *pTrigger = 0;
74532
+ if( pParse->db->flags&SQLITE_RecTriggers ){
74533
+ pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
74534
+ }
74535
+ sqlite3MultiWrite(pParse);
74536
+ if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
74537
+ sqlite3GenerateRowDelete(
74538
+ pParse, pTab, baseCur, regRowid, 0, pTrigger, OE_Replace
74539
+ );
74540
+ }else{
74541
+ sqlite3GenerateRowIndexDelete(pParse, pTab, baseCur, 0);
74542
+ }
74543
+ seenReplace = 1;
74544
+ break;
74545
+ }
74546
+ case OE_Ignore: {
74547
+ assert( seenReplace==0 );
74548
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
74549
+ break;
74550
+ }
74551
+ }
74552
+ sqlite3VdbeJumpHere(v, j3);
74553
+ if( isUpdate ){
74554
+ sqlite3VdbeJumpHere(v, j2);
7285974555
}
7286074556
}
7286174557
7286274558
/* Test all UNIQUE constraints by creating entries for each UNIQUE
7286374559
** index and making sure that duplicate entries do not already exist.
@@ -72942,10 +74638,11 @@
7294274638
break;
7294374639
}
7294474640
default: {
7294574641
Trigger *pTrigger = 0;
7294674642
assert( onError==OE_Replace );
74643
+ sqlite3MultiWrite(pParse);
7294774644
if( pParse->db->flags&SQLITE_RecTriggers ){
7294874645
pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
7294974646
}
7295074647
sqlite3GenerateRowDelete(
7295174648
pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace
@@ -72955,11 +74652,11 @@
7295574652
}
7295674653
}
7295774654
sqlite3VdbeJumpHere(v, j3);
7295874655
sqlite3ReleaseTempReg(pParse, regR);
7295974656
}
72960
-
74657
+
7296174658
if( pbMayReplace ){
7296274659
*pbMayReplace = seenReplace;
7296374660
}
7296474661
}
7296574662
@@ -73379,15 +75076,10 @@
7337975076
return 1;
7338075077
}
7338175078
}
7338275079
#endif /* SQLITE_OMIT_XFER_OPT */
7338375080
73384
-/* Make sure "isView" gets undefined in case this file becomes part of
73385
-** the amalgamation - so that subsequent files do not see isView as a
73386
-** macro. */
73387
-#undef isView
73388
-
7338975081
/************** End of insert.c **********************************************/
7339075082
/************** Begin file legacy.c ******************************************/
7339175083
/*
7339275084
** 2001 September 15
7339375085
**
@@ -74721,10 +76413,16 @@
7472176413
7472276414
/* TODO: Maybe it shouldn't be possible to change the ReadUncommitted
7472376415
** flag if there are any active statements. */
7472476416
{ "read_uncommitted", SQLITE_ReadUncommitted },
7472576417
{ "recursive_triggers", SQLITE_RecTriggers },
76418
+
76419
+ /* This flag may only be set if both foreign-key and trigger support
76420
+ ** are present in the build. */
76421
+#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
76422
+ { "foreign_keys", SQLITE_ForeignKeys },
76423
+#endif
7472676424
};
7472776425
int i;
7472876426
const struct sPragmaType *p;
7472976427
for(i=0, p=aPragma; i<ArraySize(aPragma); i++, p++){
7473076428
if( sqlite3StrICmp(zLeft, p->zName)==0 ){
@@ -74734,14 +76432,21 @@
7473476432
assert( v!=0 ); /* Already allocated by sqlite3Pragma() */
7473576433
if( ALWAYS(v) ){
7473676434
if( zRight==0 ){
7473776435
returnSingleInt(pParse, p->zName, (db->flags & p->mask)!=0 );
7473876436
}else{
76437
+ int mask = p->mask; /* Mask of bits to set or clear. */
76438
+ if( db->autoCommit==0 ){
76439
+ /* Foreign key support may not be enabled or disabled while not
76440
+ ** in auto-commit mode. */
76441
+ mask &= ~(SQLITE_ForeignKeys);
76442
+ }
76443
+
7473976444
if( getBoolean(zRight) ){
74740
- db->flags |= p->mask;
76445
+ db->flags |= mask;
7474176446
}else{
74742
- db->flags &= ~p->mask;
76447
+ db->flags &= ~mask;
7474376448
}
7474476449
7474576450
/* Many of the flag-pragmas modify the code generated by the SQL
7474676451
** compiler (eg. count_changes). So add an opcode to expire all
7474776452
** compiled SQL statements after modifying a pragma value.
@@ -74758,21 +76463,24 @@
7475876463
#endif /* SQLITE_OMIT_FLAG_PRAGMAS */
7475976464
7476076465
/*
7476176466
** Return a human-readable name for a constraint resolution action.
7476276467
*/
76468
+#ifndef SQLITE_OMIT_FOREIGN_KEY
7476376469
static const char *actionName(u8 action){
7476476470
const char *zName;
7476576471
switch( action ){
74766
- case OE_SetNull: zName = "SET NULL"; break;
74767
- case OE_SetDflt: zName = "SET DEFAULT"; break;
74768
- case OE_Cascade: zName = "CASCADE"; break;
74769
- default: zName = "RESTRICT";
74770
- assert( action==OE_Restrict ); break;
76472
+ case OE_SetNull: zName = "SET NULL"; break;
76473
+ case OE_SetDflt: zName = "SET DEFAULT"; break;
76474
+ case OE_Cascade: zName = "CASCADE"; break;
76475
+ case OE_Restrict: zName = "RESTRICT"; break;
76476
+ default: zName = "NO ACTION";
76477
+ assert( action==OE_None ); break;
7477176478
}
7477276479
return zName;
7477376480
}
76481
+#endif
7477476482
7477576483
/*
7477676484
** Process a pragma statement.
7477776485
**
7477876486
** Pragmas are of this form:
@@ -75495,12 +77203,12 @@
7549577203
sqlite3VdbeSetColName(v, 7, COLNAME_NAME, "match", SQLITE_STATIC);
7549677204
while(pFK){
7549777205
int j;
7549877206
for(j=0; j<pFK->nCol; j++){
7549977207
char *zCol = pFK->aCol[j].zCol;
75500
- char *zOnUpdate = (char *)actionName(pFK->updateConf);
75501
- char *zOnDelete = (char *)actionName(pFK->deleteConf);
77208
+ char *zOnDelete = (char *)actionName(pFK->aAction[0]);
77209
+ char *zOnUpdate = (char *)actionName(pFK->aAction[1]);
7550277210
sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
7550377211
sqlite3VdbeAddOp2(v, OP_Integer, j, 2);
7550477212
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pFK->zTo, 0);
7550577213
sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0,
7550677214
pTab->aCol[pFK->aCol[j].iFrom].zName, 0);
@@ -81316,10 +83024,14 @@
8131683024
** pTab as well as the triggers lised in pTab->pTrigger.
8131783025
*/
8131883026
SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){
8131983027
Schema * const pTmpSchema = pParse->db->aDb[1].pSchema;
8132083028
Trigger *pList = 0; /* List of triggers to return */
83029
+
83030
+ if( pParse->disableTriggers ){
83031
+ return 0;
83032
+ }
8132183033
8132283034
if( pTmpSchema!=pTab->pSchema ){
8132383035
HashElem *p;
8132483036
for(p=sqliteHashFirst(&pTmpSchema->trigHash); p; p=sqliteHashNext(p)){
8132583037
Trigger *pTrig = (Trigger *)sqliteHashData(p);
@@ -82062,11 +83774,11 @@
8206283774
NameContext sNC; /* Name context for sub-vdbe */
8206383775
SubProgram *pProgram = 0; /* Sub-vdbe for trigger program */
8206483776
Parse *pSubParse; /* Parse context for sub-vdbe */
8206583777
int iEndTrigger = 0; /* Label to jump to if WHEN is false */
8206683778
82067
- assert( pTab==tableOfTrigger(pTrigger) );
83779
+ assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );
8206883780
8206983781
/* Allocate the TriggerPrg and SubProgram objects. To ensure that they
8207083782
** are freed if an error occurs, link them into the Parse.pTriggerPrg
8207183783
** list of the top-level Parse object sooner rather than later. */
8207283784
pPrg = sqlite3DbMallocZero(db, sizeof(TriggerPrg));
@@ -82076,10 +83788,11 @@
8207683788
pPrg->pProgram = pProgram = sqlite3DbMallocZero(db, sizeof(SubProgram));
8207783789
if( !pProgram ) return 0;
8207883790
pProgram->nRef = 1;
8207983791
pPrg->pTrigger = pTrigger;
8208083792
pPrg->orconf = orconf;
83793
+ pPrg->oldmask = 0xffffffff;
8208183794
8208283795
/* Allocate and populate a new Parse context to use for coding the
8208383796
** trigger sub-program. */
8208483797
pSubParse = sqlite3StackAllocZero(db, sizeof(Parse));
8208583798
if( !pSubParse ) return 0;
@@ -82162,11 +83875,11 @@
8216283875
int orconf /* ON CONFLICT algorithm. */
8216383876
){
8216483877
Parse *pRoot = sqlite3ParseToplevel(pParse);
8216583878
TriggerPrg *pPrg;
8216683879
82167
- assert( pTab==tableOfTrigger(pTrigger) );
83880
+ assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );
8216883881
8216983882
/* It may be that this trigger has already been coded (or is in the
8217083883
** process of being coded). If this is the case, then an entry with
8217183884
** a matching TriggerPrg.pTrigger field will be present somewhere
8217283885
** in the Parse.pTriggerPrg list. Search for such an entry. */
@@ -82182,54 +83895,102 @@
8218283895
8218383896
return pPrg;
8218483897
}
8218583898
8218683899
/*
82187
-** This is called to code FOR EACH ROW triggers.
82188
-**
82189
-** When the code that this function generates is executed, the following
82190
-** must be true:
82191
-**
82192
-** 1. No cursors may be open in the main database. (But newIdx and oldIdx
82193
-** can be indices of cursors in temporary tables. See below.)
82194
-**
82195
-** 2. If the triggers being coded are ON INSERT or ON UPDATE triggers, then
82196
-** a temporary vdbe cursor (index newIdx) must be open and pointing at
82197
-** a row containing values to be substituted for new.* expressions in the
82198
-** trigger program(s).
82199
-**
82200
-** 3. If the triggers being coded are ON DELETE or ON UPDATE triggers, then
82201
-** a temporary vdbe cursor (index oldIdx) must be open and pointing at
82202
-** a row containing values to be substituted for old.* expressions in the
82203
-** trigger program(s).
82204
-**
82205
-** If they are not NULL, the piOldColMask and piNewColMask output variables
82206
-** are set to values that describe the columns used by the trigger program
82207
-** in the OLD.* and NEW.* tables respectively. If column N of the
82208
-** pseudo-table is read at least once, the corresponding bit of the output
82209
-** mask is set. If a column with an index greater than 32 is read, the
82210
-** output mask is set to the special value 0xffffffff.
82211
-**
83900
+** Generate code for the trigger program associated with trigger p on
83901
+** table pTab. The reg, orconf and ignoreJump parameters passed to this
83902
+** function are the same as those described in the header function for
83903
+** sqlite3CodeRowTrigger()
83904
+*/
83905
+SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(
83906
+ Parse *pParse, /* Parse context */
83907
+ Trigger *p, /* Trigger to code */
83908
+ Table *pTab, /* The table to code triggers from */
83909
+ int reg, /* Reg array containing OLD.* and NEW.* values */
83910
+ int orconf, /* ON CONFLICT policy */
83911
+ int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */
83912
+){
83913
+ Vdbe *v = sqlite3GetVdbe(pParse); /* Main VM */
83914
+ TriggerPrg *pPrg;
83915
+ pPrg = getRowTrigger(pParse, p, pTab, orconf);
83916
+ assert( pPrg || pParse->nErr || pParse->db->mallocFailed );
83917
+
83918
+ /* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program
83919
+ ** is a pointer to the sub-vdbe containing the trigger program. */
83920
+ if( pPrg ){
83921
+ sqlite3VdbeAddOp3(v, OP_Program, reg, ignoreJump, ++pParse->nMem);
83922
+ pPrg->pProgram->nRef++;
83923
+ sqlite3VdbeChangeP4(v, -1, (const char *)pPrg->pProgram, P4_SUBPROGRAM);
83924
+ VdbeComment(
83925
+ (v, "Call: %s.%s", (p->zName?p->zName:"fkey"), onErrorText(orconf)));
83926
+
83927
+ /* Set the P5 operand of the OP_Program instruction to non-zero if
83928
+ ** recursive invocation of this trigger program is disallowed. Recursive
83929
+ ** invocation is disallowed if (a) the sub-program is really a trigger,
83930
+ ** not a foreign key action, and (b) the flag to enable recursive triggers
83931
+ ** is clear. */
83932
+ sqlite3VdbeChangeP5(v, p->zName && !(pParse->db->flags&SQLITE_RecTriggers));
83933
+ }
83934
+}
83935
+
83936
+/*
83937
+** This is called to code the required FOR EACH ROW triggers for an operation
83938
+** on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE)
83939
+** is given by the op paramater. The tr_tm parameter determines whether the
83940
+** BEFORE or AFTER triggers are coded. If the operation is an UPDATE, then
83941
+** parameter pChanges is passed the list of columns being modified.
83942
+**
83943
+** If there are no triggers that fire at the specified time for the specified
83944
+** operation on pTab, this function is a no-op.
83945
+**
83946
+** The reg argument is the address of the first in an array of registers
83947
+** that contain the values substituted for the new.* and old.* references
83948
+** in the trigger program. If N is the number of columns in table pTab
83949
+** (a copy of pTab->nCol), then registers are populated as follows:
83950
+**
83951
+** Register Contains
83952
+** ------------------------------------------------------
83953
+** reg+0 OLD.rowid
83954
+** reg+1 OLD.* value of left-most column of pTab
83955
+** ... ...
83956
+** reg+N OLD.* value of right-most column of pTab
83957
+** reg+N+1 NEW.rowid
83958
+** reg+N+2 OLD.* value of left-most column of pTab
83959
+** ... ...
83960
+** reg+N+N+1 NEW.* value of right-most column of pTab
83961
+**
83962
+** For ON DELETE triggers, the registers containing the NEW.* values will
83963
+** never be accessed by the trigger program, so they are not allocated or
83964
+** populated by the caller (there is no data to populate them with anyway).
83965
+** Similarly, for ON INSERT triggers the values stored in the OLD.* registers
83966
+** are never accessed, and so are not allocated by the caller. So, for an
83967
+** ON INSERT trigger, the value passed to this function as parameter reg
83968
+** is not a readable register, although registers (reg+N) through
83969
+** (reg+N+N+1) are.
83970
+**
83971
+** Parameter orconf is the default conflict resolution algorithm for the
83972
+** trigger program to use (REPLACE, IGNORE etc.). Parameter ignoreJump
83973
+** is the instruction that control should jump to if a trigger program
83974
+** raises an IGNORE exception.
8221283975
*/
8221383976
SQLITE_PRIVATE void sqlite3CodeRowTrigger(
8221483977
Parse *pParse, /* Parse context */
8221583978
Trigger *pTrigger, /* List of triggers on table pTab */
8221683979
int op, /* One of TK_UPDATE, TK_INSERT, TK_DELETE */
8221783980
ExprList *pChanges, /* Changes list for any UPDATE OF triggers */
8221883981
int tr_tm, /* One of TRIGGER_BEFORE, TRIGGER_AFTER */
8221983982
Table *pTab, /* The table to code triggers from */
82220
- int newIdx, /* The indice of the "new" row to access */
82221
- int oldIdx, /* The indice of the "old" row to access */
83983
+ int reg, /* The first in an array of registers (see above) */
8222283984
int orconf, /* ON CONFLICT policy */
8222383985
int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */
8222483986
){
82225
- Trigger *p;
83987
+ Trigger *p; /* Used to iterate through pTrigger list */
8222683988
82227
- UNUSED_PARAMETER(newIdx);
82228
-
82229
- assert(op == TK_UPDATE || op == TK_INSERT || op == TK_DELETE);
82230
- assert(tr_tm == TRIGGER_BEFORE || tr_tm == TRIGGER_AFTER );
83989
+ assert( op==TK_UPDATE || op==TK_INSERT || op==TK_DELETE );
83990
+ assert( tr_tm==TRIGGER_BEFORE || tr_tm==TRIGGER_AFTER );
83991
+ assert( (op==TK_UPDATE)==(pChanges!=0) );
8223183992
8223283993
for(p=pTrigger; p; p=p->pNext){
8223383994
8223483995
/* Sanity checking: The schema for the trigger and for the table are
8223583996
** always defined. The trigger must be in the same schema as the table
@@ -82240,25 +84001,13 @@
8224084001
|| p->pSchema==pParse->db->aDb[1].pSchema );
8224184002
8224284003
/* Determine whether we should code this trigger */
8224384004
if( p->op==op
8224484005
&& p->tr_tm==tr_tm
82245
- && checkColumnOverlap(p->pColumns,pChanges)
84006
+ && checkColumnOverlap(p->pColumns, pChanges)
8224684007
){
82247
- Vdbe *v = sqlite3GetVdbe(pParse); /* Main VM */
82248
- TriggerPrg *pPrg;
82249
- pPrg = getRowTrigger(pParse, p, pTab, orconf);
82250
- assert( pPrg || pParse->nErr || pParse->db->mallocFailed );
82251
-
82252
- /* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program
82253
- ** is a pointer to the sub-vdbe containing the trigger program. */
82254
- if( pPrg ){
82255
- sqlite3VdbeAddOp3(v, OP_Program, oldIdx, ignoreJump, ++pParse->nMem);
82256
- pPrg->pProgram->nRef++;
82257
- sqlite3VdbeChangeP4(v, -1, (const char *)pPrg->pProgram, P4_SUBPROGRAM);
82258
- VdbeComment((v, "Call: %s.%s", p->zName, onErrorText(orconf)));
82259
- }
84008
+ sqlite3CodeRowTriggerDirect(pParse, p, pTab, reg, orconf, ignoreJump);
8226084009
}
8226184010
}
8226284011
}
8226384012
8226484013
/*
@@ -82281,19 +84030,18 @@
8228184030
** There is no equivalent function for new.* references.
8228284031
*/
8228384032
SQLITE_PRIVATE u32 sqlite3TriggerOldmask(
8228484033
Parse *pParse, /* Parse context */
8228584034
Trigger *pTrigger, /* List of triggers on table pTab */
82286
- int op, /* Either TK_UPDATE or TK_DELETE */
8228784035
ExprList *pChanges, /* Changes list for any UPDATE OF triggers */
8228884036
Table *pTab, /* The table to code triggers from */
8228984037
int orconf /* Default ON CONFLICT policy for trigger steps */
8229084038
){
84039
+ const int op = pChanges ? TK_UPDATE : TK_DELETE;
8229184040
u32 mask = 0;
8229284041
Trigger *p;
8229384042
82294
- assert(op==TK_UPDATE || op==TK_DELETE);
8229584043
for(p=pTrigger; p; p=p->pNext){
8229684044
if( p->op==op && checkColumnOverlap(p->pColumns,pChanges) ){
8229784045
TriggerPrg *pPrg;
8229884046
pPrg = getRowTrigger(pParse, p, pTab, orconf);
8229984047
if( pPrg ){
@@ -82423,16 +84171,16 @@
8242384171
AuthContext sContext; /* The authorization context */
8242484172
NameContext sNC; /* The name-context to resolve expressions in */
8242584173
int iDb; /* Database containing the table being updated */
8242684174
int j1; /* Addresses of jump instructions */
8242784175
int okOnePass; /* True for one-pass algorithm without the FIFO */
84176
+ int hasFK; /* True if foreign key processing is required */
8242884177
8242984178
#ifndef SQLITE_OMIT_TRIGGER
8243084179
int isView; /* Trying to update a view */
8243184180
Trigger *pTrigger; /* List of triggers on pTab, if required */
8243284181
#endif
82433
- u32 oldmask = 0; /* Mask of OLD.* columns in use */
8243484182
8243584183
/* Register Allocations */
8243684184
int regRowCount = 0; /* A count of rows changed */
8243784185
int regOldRowid; /* The old rowid */
8243884186
int regNewRowid; /* The new rowid */
@@ -82535,10 +84283,12 @@
8253584283
aXRef[j] = -1;
8253684284
}
8253784285
}
8253884286
#endif
8253984287
}
84288
+
84289
+ hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngRowid);
8254084290
8254184291
/* Allocate memory for the array aRegIdx[]. There is one entry in the
8254284292
** array for each index associated with table being updated. Fill in
8254384293
** the value with a register number for indices that are to be used
8254484294
** and with zero for unused indices.
@@ -82581,15 +84331,15 @@
8258184331
}
8258284332
#endif
8258384333
8258484334
/* Allocate required registers. */
8258584335
regOldRowid = regNewRowid = ++pParse->nMem;
82586
- if( pTrigger ){
84336
+ if( pTrigger || hasFK ){
8258784337
regOld = pParse->nMem + 1;
8258884338
pParse->nMem += pTab->nCol;
8258984339
}
82590
- if( chngRowid || pTrigger ){
84340
+ if( chngRowid || pTrigger || hasFK ){
8259184341
regNewRowid = ++pParse->nMem;
8259284342
}
8259384343
regNew = pParse->nMem + 1;
8259484344
pParse->nMem += pTab->nCol;
8259584345
regRec = ++pParse->nMem;
@@ -82597,14 +84347,10 @@
8259784347
/* Start the view context. */
8259884348
if( isView ){
8259984349
sqlite3AuthContextPush(pParse, &sContext, pTab->zName);
8260084350
}
8260184351
82602
- /* If there are any triggers, set oldmask and new_col_mask. */
82603
- oldmask = sqlite3TriggerOldmask(
82604
- pParse, pTrigger, TK_UPDATE, pChanges, pTab, onError);
82605
-
8260684352
/* If we are trying to update a view, realize that view into
8260784353
** a ephemeral table.
8260884354
*/
8260984355
#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
8261084356
if( isView ){
@@ -82685,34 +84431,37 @@
8268584431
8268684432
/* Make cursor iCur point to the record that is being updated. If
8268784433
** this record does not exist for some reason (deleted by a trigger,
8268884434
** for example, then jump to the next iteration of the RowSet loop. */
8268984435
sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid);
84436
+
84437
+ /* If the record number will change, set register regNewRowid to
84438
+ ** contain the new value. If the record number is not being modified,
84439
+ ** then regNewRowid is the same register as regOldRowid, which is
84440
+ ** already populated. */
84441
+ assert( chngRowid || pTrigger || hasFK || regOldRowid==regNewRowid );
84442
+ if( chngRowid ){
84443
+ sqlite3ExprCode(pParse, pRowidExpr, regNewRowid);
84444
+ sqlite3VdbeAddOp1(v, OP_MustBeInt, regNewRowid);
84445
+ }
8269084446
8269184447
/* If there are triggers on this table, populate an array of registers
8269284448
** with the required old.* column data. */
82693
- if( pTrigger ){
84449
+ if( hasFK || pTrigger ){
84450
+ u32 oldmask = (hasFK ? sqlite3FkOldmask(pParse, pTab) : 0);
84451
+ oldmask |= sqlite3TriggerOldmask(pParse, pTrigger, pChanges, pTab, onError);
8269484452
for(i=0; i<pTab->nCol; i++){
8269584453
if( aXRef[i]<0 || oldmask==0xffffffff || (oldmask & (1<<i)) ){
8269684454
sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regOld+i);
8269784455
sqlite3ColumnDefault(v, pTab, i, regOld+i);
8269884456
}else{
8269984457
sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i);
8270084458
}
8270184459
}
82702
- }
82703
-
82704
- /* If the record number will change, set register regNewRowid to
82705
- ** contain the new value. If the record number is not being modified,
82706
- ** then regNewRowid is the same register as regOldRowid, which is
82707
- ** already populated. */
82708
- assert( chngRowid || pTrigger || regOldRowid==regNewRowid );
82709
- if( chngRowid ){
82710
- sqlite3ExprCode(pParse, pRowidExpr, regNewRowid);
82711
- sqlite3VdbeAddOp1(v, OP_MustBeInt, regNewRowid);
82712
- }else if( pTrigger ){
82713
- sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid);
84460
+ if( chngRowid==0 ){
84461
+ sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid);
84462
+ }
8271484463
}
8271584464
8271684465
/* Populate the array of registers beginning at regNew with the new
8271784466
** row data. This array is used to check constaints, create the new
8271884467
** table and index records, and as the values for any new.* references
@@ -82735,11 +84484,11 @@
8273584484
** verified. One could argue that this is wrong. */
8273684485
if( pTrigger ){
8273784486
sqlite3VdbeAddOp2(v, OP_Affinity, regNew, pTab->nCol);
8273884487
sqlite3TableAffinityStr(v, pTab);
8273984488
sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges,
82740
- TRIGGER_BEFORE, pTab, -1, regOldRowid, onError, addr);
84489
+ TRIGGER_BEFORE, pTab, regOldRowid, onError, addr);
8274184490
8274284491
/* The row-trigger may have deleted the row being updated. In this
8274384492
** case, jump to the next row. No updates or AFTER triggers are
8274484493
** required. This behaviour - what happens when the row being updated
8274584494
** is deleted or renamed by a BEFORE trigger - is left undefined in the
@@ -82750,33 +84499,49 @@
8275084499
if( !isView ){
8275184500
8275284501
/* Do constraint checks. */
8275384502
sqlite3GenerateConstraintChecks(pParse, pTab, iCur, regNewRowid,
8275484503
aRegIdx, (chngRowid?regOldRowid:0), 1, onError, addr, 0);
84504
+
84505
+ /* Do FK constraint checks. */
84506
+ if( hasFK ){
84507
+ sqlite3FkCheck(pParse, pTab, regOldRowid, 0);
84508
+ }
8275584509
8275684510
/* Delete the index entries associated with the current record. */
8275784511
j1 = sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regOldRowid);
8275884512
sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, aRegIdx);
8275984513
8276084514
/* If changing the record number, delete the old record. */
82761
- if( chngRowid ){
84515
+ if( hasFK || chngRowid ){
8276284516
sqlite3VdbeAddOp2(v, OP_Delete, iCur, 0);
8276384517
}
8276484518
sqlite3VdbeJumpHere(v, j1);
84519
+
84520
+ if( hasFK ){
84521
+ sqlite3FkCheck(pParse, pTab, 0, regNewRowid);
84522
+ }
8276584523
8276684524
/* Insert the new index entries and the new record. */
8276784525
sqlite3CompleteInsertion(pParse, pTab, iCur, regNewRowid, aRegIdx, 1, 0, 0);
84526
+
84527
+ /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to
84528
+ ** handle rows (possibly in other tables) that refer via a foreign key
84529
+ ** to the row just updated. */
84530
+ if( hasFK ){
84531
+ sqlite3FkActions(pParse, pTab, pChanges, regOldRowid);
84532
+ }
8276884533
}
8276984534
8277084535
/* Increment the row counter
8277184536
*/
8277284537
if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab){
8277384538
sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);
8277484539
}
8277584540
8277684541
sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges,
82777
- TRIGGER_AFTER, pTab, -1, regOldRowid, onError, addr);
84542
+ TRIGGER_AFTER, pTab, regOldRowid, onError, addr);
8277884543
8277984544
/* Repeat the above with the next record to be updated, until
8278084545
** all record selected by the WHERE clause have been updated.
8278184546
*/
8278284547
sqlite3VdbeAddOp2(v, OP_Goto, 0, addr);
@@ -82816,10 +84581,19 @@
8281684581
sqlite3SrcListDelete(db, pTabList);
8281784582
sqlite3ExprListDelete(db, pChanges);
8281884583
sqlite3ExprDelete(db, pWhere);
8281984584
return;
8282084585
}
84586
+/* Make sure "isView" and other macros defined above are undefined. Otherwise
84587
+** thely may interfere with compilation of other functions in this file
84588
+** (or in another file, if this file becomes part of the amalgamation). */
84589
+#ifdef isView
84590
+ #undef isView
84591
+#endif
84592
+#ifdef pTrigger
84593
+ #undef pTrigger
84594
+#endif
8282184595
8282284596
#ifndef SQLITE_OMIT_VIRTUALTABLE
8282384597
/*
8282484598
** Generate code for an UPDATE of a virtual table.
8282584599
**
@@ -82911,15 +84685,10 @@
8291184685
/* Cleanup */
8291284686
sqlite3SelectDelete(db, pSelect);
8291384687
}
8291484688
#endif /* SQLITE_OMIT_VIRTUALTABLE */
8291584689
82916
-/* Make sure "isView" gets undefined in case this file becomes part of
82917
-** the amalgamation - so that subsequent files do not see isView as a
82918
-** macro. */
82919
-#undef isView
82920
-
8292184690
/************** End of update.c **********************************************/
8292284691
/************** Begin file vacuum.c ******************************************/
8292384692
/*
8292484693
** 2003 April 6
8292584694
**
@@ -83015,15 +84784,18 @@
8301584784
if( !db->autoCommit ){
8301684785
sqlite3SetString(pzErrMsg, db, "cannot VACUUM from within a transaction");
8301784786
return SQLITE_ERROR;
8301884787
}
8301984788
83020
- /* Save the current value of the write-schema flag before setting it. */
84789
+ /* Save the current value of the database flags so that it can be
84790
+ ** restored before returning. Then set the writable-schema flag, and
84791
+ ** disable CHECK and foreign key constraints. */
8302184792
saved_flags = db->flags;
8302284793
saved_nChange = db->nChange;
8302384794
saved_nTotalChange = db->nTotalChange;
8302484795
db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
84796
+ db->flags &= ~SQLITE_ForeignKeys;
8302584797
8302684798
pMain = db->aDb[0].pBt;
8302784799
isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));
8302884800
8302984801
/* Attach the temporary database as 'vacuum_db'. The synchronous pragma
@@ -86139,13 +87911,12 @@
8613987911
for(i=0; i<SQLITE_INDEX_SAMPLES; i++){
8614087912
int r;
8614187913
int eSampletype = aSample[i].eType;
8614287914
if( eSampletype==SQLITE_NULL || eSampletype<eType ) continue;
8614387915
if( (eSampletype!=eType) ) break;
86144
- if( pColl->enc==SQLITE_UTF8 ){
86145
- r = pColl->xCmp(pColl->pUser, aSample[i].nByte, aSample[i].u.z, n, z);
86146
- }else{
87916
+#ifndef SQLITE_OMIT_UTF16
87917
+ if( pColl->enc!=SQLITE_UTF8 ){
8614787918
int nSample;
8614887919
char *zSample = sqlite3Utf8to16(
8614987920
db, pColl->enc, aSample[i].u.z, aSample[i].nByte, &nSample
8615087921
);
8615187922
if( !zSample ){
@@ -86152,10 +87923,14 @@
8615287923
assert( db->mallocFailed );
8615387924
return SQLITE_NOMEM;
8615487925
}
8615587926
r = pColl->xCmp(pColl->pUser, nSample, zSample, n, z);
8615687927
sqlite3DbFree(db, zSample);
87928
+ }else
87929
+#endif
87930
+ {
87931
+ r = pColl->xCmp(pColl->pUser, aSample[i].nByte, aSample[i].u.z, n, z);
8615787932
}
8615887933
if( r>0 ) break;
8615987934
}
8616087935
}
8616187936
@@ -88304,11 +90079,11 @@
8830490079
** defined, then do no error processing.
8830590080
*/
8830690081
#define YYCODETYPE unsigned char
8830790082
#define YYNOCODE 254
8830890083
#define YYACTIONTYPE unsigned short int
88309
-#define YYWILDCARD 65
90084
+#define YYWILDCARD 67
8831090085
#define sqlite3ParserTOKENTYPE Token
8831190086
typedef union {
8831290087
int yyinit;
8831390088
sqlite3ParserTOKENTYPE yy0;
8831490089
Select* yy3;
@@ -88402,454 +90177,461 @@
8840290177
** yy_reduce_ofst[] For each state, the offset into yy_action for
8840390178
** shifting non-terminals after a reduce.
8840490179
** yy_default[] Default action for each state.
8840590180
*/
8840690181
static const YYACTIONTYPE yy_action[] = {
88407
- /* 0 */ 309, 959, 178, 628, 2, 153, 216, 448, 24, 24,
88408
- /* 10 */ 24, 24, 497, 26, 26, 26, 26, 27, 27, 28,
88409
- /* 20 */ 28, 28, 29, 218, 422, 423, 214, 422, 423, 455,
88410
- /* 30 */ 461, 31, 26, 26, 26, 26, 27, 27, 28, 28,
88411
- /* 40 */ 28, 29, 218, 30, 492, 32, 137, 23, 22, 315,
88412
- /* 50 */ 465, 466, 462, 462, 25, 25, 24, 24, 24, 24,
88413
- /* 60 */ 445, 26, 26, 26, 26, 27, 27, 28, 28, 28,
88414
- /* 70 */ 29, 218, 309, 218, 318, 448, 521, 499, 45, 26,
88415
- /* 80 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 218,
88416
- /* 90 */ 422, 423, 425, 426, 159, 425, 426, 366, 369, 370,
88417
- /* 100 */ 318, 455, 461, 394, 523, 21, 188, 504, 371, 27,
88418
- /* 110 */ 27, 28, 28, 28, 29, 218, 422, 423, 424, 23,
88419
- /* 120 */ 22, 315, 465, 466, 462, 462, 25, 25, 24, 24,
88420
- /* 130 */ 24, 24, 564, 26, 26, 26, 26, 27, 27, 28,
88421
- /* 140 */ 28, 28, 29, 218, 309, 230, 513, 138, 477, 220,
88422
- /* 150 */ 557, 148, 135, 260, 364, 265, 365, 156, 425, 426,
88423
- /* 160 */ 245, 610, 337, 30, 269, 32, 137, 448, 608, 609,
88424
- /* 170 */ 233, 230, 499, 455, 461, 57, 515, 334, 135, 260,
88425
- /* 180 */ 364, 265, 365, 156, 425, 426, 444, 78, 417, 414,
88426
- /* 190 */ 269, 23, 22, 315, 465, 466, 462, 462, 25, 25,
88427
- /* 200 */ 24, 24, 24, 24, 348, 26, 26, 26, 26, 27,
88428
- /* 210 */ 27, 28, 28, 28, 29, 218, 309, 216, 543, 556,
88429
- /* 220 */ 486, 130, 498, 607, 30, 337, 32, 137, 351, 396,
88430
- /* 230 */ 438, 63, 337, 361, 424, 448, 487, 337, 424, 544,
88431
- /* 240 */ 334, 217, 195, 606, 605, 455, 461, 334, 18, 444,
88432
- /* 250 */ 85, 488, 334, 347, 192, 565, 444, 78, 316, 472,
88433
- /* 260 */ 473, 444, 85, 23, 22, 315, 465, 466, 462, 462,
88434
- /* 270 */ 25, 25, 24, 24, 24, 24, 445, 26, 26, 26,
88435
- /* 280 */ 26, 27, 27, 28, 28, 28, 29, 218, 309, 353,
88436
- /* 290 */ 223, 320, 607, 193, 238, 337, 481, 16, 351, 185,
88437
- /* 300 */ 330, 419, 222, 350, 604, 219, 215, 424, 112, 337,
88438
- /* 310 */ 334, 157, 606, 408, 213, 563, 538, 455, 461, 444,
88439
- /* 320 */ 79, 219, 562, 524, 334, 576, 522, 629, 417, 414,
88440
- /* 330 */ 450, 581, 441, 444, 78, 23, 22, 315, 465, 466,
88441
- /* 340 */ 462, 462, 25, 25, 24, 24, 24, 24, 445, 26,
88442
- /* 350 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 218,
88443
- /* 360 */ 309, 452, 452, 452, 159, 399, 311, 366, 369, 370,
88444
- /* 370 */ 337, 251, 404, 407, 219, 355, 556, 4, 371, 422,
88445
- /* 380 */ 423, 397, 286, 285, 244, 334, 540, 566, 63, 455,
88446
- /* 390 */ 461, 424, 216, 478, 444, 93, 28, 28, 28, 29,
88447
- /* 400 */ 218, 413, 477, 220, 578, 40, 545, 23, 22, 315,
88448
- /* 410 */ 465, 466, 462, 462, 25, 25, 24, 24, 24, 24,
88449
- /* 420 */ 582, 26, 26, 26, 26, 27, 27, 28, 28, 28,
88450
- /* 430 */ 29, 218, 309, 546, 337, 30, 517, 32, 137, 378,
88451
- /* 440 */ 326, 337, 874, 153, 194, 448, 1, 425, 426, 334,
88452
- /* 450 */ 422, 423, 422, 423, 29, 218, 334, 613, 444, 71,
88453
- /* 460 */ 210, 455, 461, 66, 581, 444, 93, 422, 423, 626,
88454
- /* 470 */ 949, 303, 949, 500, 479, 555, 202, 43, 445, 23,
88455
- /* 480 */ 22, 315, 465, 466, 462, 462, 25, 25, 24, 24,
88456
- /* 490 */ 24, 24, 436, 26, 26, 26, 26, 27, 27, 28,
88457
- /* 500 */ 28, 28, 29, 218, 309, 187, 211, 360, 520, 440,
88458
- /* 510 */ 246, 327, 622, 448, 397, 286, 285, 551, 425, 426,
88459
- /* 520 */ 425, 426, 334, 159, 337, 216, 366, 369, 370, 494,
88460
- /* 530 */ 556, 444, 9, 455, 461, 425, 426, 371, 495, 334,
88461
- /* 540 */ 445, 618, 63, 504, 198, 424, 501, 449, 444, 72,
88462
- /* 550 */ 474, 23, 22, 315, 465, 466, 462, 462, 25, 25,
88463
- /* 560 */ 24, 24, 24, 24, 395, 26, 26, 26, 26, 27,
88464
- /* 570 */ 27, 28, 28, 28, 29, 218, 309, 486, 445, 337,
88465
- /* 580 */ 537, 60, 224, 479, 343, 202, 398, 337, 439, 554,
88466
- /* 590 */ 199, 140, 337, 487, 334, 526, 527, 551, 516, 508,
88467
- /* 600 */ 456, 457, 334, 444, 67, 455, 461, 334, 488, 476,
88468
- /* 610 */ 528, 444, 76, 39, 424, 41, 444, 97, 579, 527,
88469
- /* 620 */ 529, 459, 460, 23, 22, 315, 465, 466, 462, 462,
88470
- /* 630 */ 25, 25, 24, 24, 24, 24, 337, 26, 26, 26,
88471
- /* 640 */ 26, 27, 27, 28, 28, 28, 29, 218, 309, 337,
88472
- /* 650 */ 458, 334, 272, 621, 307, 337, 312, 337, 374, 64,
88473
- /* 660 */ 444, 96, 317, 448, 334, 342, 472, 473, 469, 337,
88474
- /* 670 */ 334, 508, 334, 444, 101, 359, 252, 455, 461, 444,
88475
- /* 680 */ 99, 444, 104, 358, 334, 345, 424, 340, 157, 468,
88476
- /* 690 */ 468, 424, 493, 444, 105, 23, 22, 315, 465, 466,
88477
- /* 700 */ 462, 462, 25, 25, 24, 24, 24, 24, 337, 26,
88478
- /* 710 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 218,
88479
- /* 720 */ 309, 337, 181, 334, 499, 56, 139, 337, 219, 268,
88480
- /* 730 */ 384, 448, 444, 129, 382, 387, 334, 168, 337, 389,
88481
- /* 740 */ 508, 424, 334, 311, 424, 444, 131, 496, 269, 455,
88482
- /* 750 */ 461, 444, 59, 334, 424, 424, 391, 340, 8, 468,
88483
- /* 760 */ 468, 263, 444, 102, 390, 290, 321, 23, 22, 315,
88484
- /* 770 */ 465, 466, 462, 462, 25, 25, 24, 24, 24, 24,
88485
- /* 780 */ 337, 26, 26, 26, 26, 27, 27, 28, 28, 28,
88486
- /* 790 */ 29, 218, 309, 337, 138, 334, 416, 2, 268, 337,
88487
- /* 800 */ 389, 337, 443, 325, 444, 77, 442, 293, 334, 291,
88488
- /* 810 */ 7, 482, 337, 424, 334, 424, 334, 444, 100, 499,
88489
- /* 820 */ 339, 455, 461, 444, 68, 444, 98, 334, 254, 504,
88490
- /* 830 */ 232, 626, 948, 504, 948, 231, 444, 132, 47, 23,
88491
- /* 840 */ 22, 315, 465, 466, 462, 462, 25, 25, 24, 24,
88492
- /* 850 */ 24, 24, 337, 26, 26, 26, 26, 27, 27, 28,
88493
- /* 860 */ 28, 28, 29, 218, 309, 337, 280, 334, 256, 538,
88494
- /* 870 */ 362, 337, 258, 268, 622, 549, 444, 133, 203, 140,
88495
- /* 880 */ 334, 424, 548, 337, 180, 158, 334, 292, 424, 444,
88496
- /* 890 */ 134, 287, 552, 455, 461, 444, 69, 443, 334, 463,
88497
- /* 900 */ 340, 442, 468, 468, 427, 428, 429, 444, 80, 281,
88498
- /* 910 */ 322, 23, 33, 315, 465, 466, 462, 462, 25, 25,
88499
- /* 920 */ 24, 24, 24, 24, 337, 26, 26, 26, 26, 27,
88500
- /* 930 */ 27, 28, 28, 28, 29, 218, 309, 337, 406, 334,
88501
- /* 940 */ 212, 268, 550, 337, 268, 389, 329, 177, 444, 81,
88502
- /* 950 */ 542, 541, 334, 475, 475, 337, 424, 216, 334, 424,
88503
- /* 960 */ 424, 444, 70, 535, 368, 455, 461, 444, 82, 405,
88504
- /* 970 */ 334, 261, 392, 340, 445, 468, 468, 587, 323, 444,
88505
- /* 980 */ 83, 324, 262, 288, 22, 315, 465, 466, 462, 462,
88506
- /* 990 */ 25, 25, 24, 24, 24, 24, 337, 26, 26, 26,
88507
- /* 1000 */ 26, 27, 27, 28, 28, 28, 29, 218, 309, 337,
88508
- /* 1010 */ 211, 334, 294, 356, 340, 337, 468, 468, 532, 533,
88509
- /* 1020 */ 444, 84, 403, 144, 334, 574, 600, 337, 424, 573,
88510
- /* 1030 */ 334, 337, 420, 444, 86, 253, 234, 455, 461, 444,
88511
- /* 1040 */ 87, 430, 334, 383, 445, 431, 334, 274, 196, 331,
88512
- /* 1050 */ 424, 444, 88, 432, 145, 444, 73, 315, 465, 466,
88513
- /* 1060 */ 462, 462, 25, 25, 24, 24, 24, 24, 395, 26,
88514
- /* 1070 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 218,
88515
- /* 1080 */ 35, 344, 445, 3, 337, 394, 337, 333, 423, 278,
88516
- /* 1090 */ 388, 276, 280, 207, 147, 35, 344, 341, 3, 334,
88517
- /* 1100 */ 424, 334, 333, 423, 308, 623, 280, 424, 444, 74,
88518
- /* 1110 */ 444, 89, 341, 337, 6, 346, 338, 337, 421, 337,
88519
- /* 1120 */ 470, 424, 65, 332, 280, 481, 446, 445, 334, 247,
88520
- /* 1130 */ 346, 424, 334, 424, 334, 594, 280, 444, 90, 424,
88521
- /* 1140 */ 481, 444, 91, 444, 92, 38, 37, 625, 337, 410,
88522
- /* 1150 */ 47, 424, 237, 280, 36, 335, 336, 354, 248, 450,
88523
- /* 1160 */ 38, 37, 514, 334, 572, 381, 572, 596, 424, 36,
88524
- /* 1170 */ 335, 336, 444, 75, 450, 200, 506, 216, 154, 597,
88525
- /* 1180 */ 239, 240, 241, 146, 243, 249, 547, 593, 158, 433,
88526
- /* 1190 */ 452, 452, 452, 453, 454, 10, 598, 280, 20, 46,
88527
- /* 1200 */ 174, 412, 298, 337, 424, 452, 452, 452, 453, 454,
88528
- /* 1210 */ 10, 299, 424, 35, 344, 352, 3, 250, 334, 434,
88529
- /* 1220 */ 333, 423, 337, 172, 280, 581, 208, 444, 17, 171,
88530
- /* 1230 */ 341, 19, 173, 447, 424, 422, 423, 334, 337, 424,
88531
- /* 1240 */ 235, 280, 204, 205, 206, 42, 444, 94, 346, 435,
88532
- /* 1250 */ 136, 451, 221, 334, 308, 624, 424, 349, 481, 490,
88533
- /* 1260 */ 445, 152, 444, 95, 424, 424, 424, 236, 503, 491,
88534
- /* 1270 */ 507, 179, 424, 481, 424, 402, 295, 285, 38, 37,
88535
- /* 1280 */ 271, 310, 158, 424, 296, 424, 216, 36, 335, 336,
88536
- /* 1290 */ 509, 266, 450, 190, 191, 539, 267, 625, 558, 273,
88537
- /* 1300 */ 275, 48, 277, 522, 279, 424, 424, 450, 255, 409,
88538
- /* 1310 */ 424, 424, 257, 424, 424, 424, 284, 424, 386, 424,
88539
- /* 1320 */ 357, 584, 585, 452, 452, 452, 453, 454, 10, 259,
88540
- /* 1330 */ 393, 424, 289, 424, 592, 603, 424, 424, 452, 452,
88541
- /* 1340 */ 452, 297, 300, 301, 505, 424, 617, 424, 363, 424,
88542
- /* 1350 */ 424, 373, 577, 158, 158, 511, 424, 424, 424, 525,
88543
- /* 1360 */ 588, 424, 154, 589, 601, 54, 54, 620, 512, 306,
88544
- /* 1370 */ 319, 530, 531, 535, 264, 107, 228, 536, 534, 375,
88545
- /* 1380 */ 559, 304, 560, 561, 305, 227, 229, 553, 567, 161,
88546
- /* 1390 */ 162, 379, 377, 163, 51, 209, 569, 282, 164, 570,
88547
- /* 1400 */ 385, 143, 580, 116, 119, 183, 400, 590, 401, 121,
88548
- /* 1410 */ 122, 123, 124, 126, 599, 328, 614, 55, 58, 615,
88549
- /* 1420 */ 616, 619, 62, 418, 103, 226, 111, 176, 242, 182,
88550
- /* 1430 */ 437, 313, 201, 314, 670, 671, 672, 149, 150, 467,
88551
- /* 1440 */ 464, 34, 483, 471, 480, 184, 197, 502, 484, 5,
88552
- /* 1450 */ 485, 151, 489, 44, 141, 11, 106, 160, 225, 518,
88553
- /* 1460 */ 519, 49, 510, 108, 367, 270, 12, 155, 109, 50,
88554
- /* 1470 */ 110, 262, 376, 186, 568, 113, 142, 154, 165, 115,
88555
- /* 1480 */ 15, 283, 583, 166, 167, 380, 586, 117, 13, 120,
88556
- /* 1490 */ 372, 52, 53, 118, 591, 169, 114, 170, 595, 125,
88557
- /* 1500 */ 127, 571, 575, 602, 14, 128, 611, 612, 61, 175,
88558
- /* 1510 */ 189, 415, 302, 627, 960, 960, 960, 960, 411,
90182
+ /* 0 */ 312, 959, 182, 628, 2, 157, 219, 450, 24, 24,
90183
+ /* 10 */ 24, 24, 221, 26, 26, 26, 26, 27, 27, 28,
90184
+ /* 20 */ 28, 28, 29, 221, 424, 425, 30, 492, 33, 141,
90185
+ /* 30 */ 457, 463, 31, 26, 26, 26, 26, 27, 27, 28,
90186
+ /* 40 */ 28, 28, 29, 221, 28, 28, 28, 29, 221, 23,
90187
+ /* 50 */ 22, 32, 465, 466, 464, 464, 25, 25, 24, 24,
90188
+ /* 60 */ 24, 24, 293, 26, 26, 26, 26, 27, 27, 28,
90189
+ /* 70 */ 28, 28, 29, 221, 312, 450, 319, 479, 344, 208,
90190
+ /* 80 */ 47, 26, 26, 26, 26, 27, 27, 28, 28, 28,
90191
+ /* 90 */ 29, 221, 427, 428, 163, 339, 543, 368, 371, 372,
90192
+ /* 100 */ 521, 317, 472, 473, 457, 463, 296, 373, 294, 21,
90193
+ /* 110 */ 336, 367, 419, 416, 424, 425, 523, 1, 544, 446,
90194
+ /* 120 */ 80, 424, 425, 23, 22, 32, 465, 466, 464, 464,
90195
+ /* 130 */ 25, 25, 24, 24, 24, 24, 564, 26, 26, 26,
90196
+ /* 140 */ 26, 27, 27, 28, 28, 28, 29, 221, 312, 233,
90197
+ /* 150 */ 319, 441, 554, 152, 139, 263, 365, 268, 366, 160,
90198
+ /* 160 */ 551, 352, 332, 421, 222, 272, 362, 322, 218, 557,
90199
+ /* 170 */ 116, 339, 248, 574, 477, 223, 216, 573, 457, 463,
90200
+ /* 180 */ 450, 59, 427, 428, 295, 610, 336, 563, 538, 427,
90201
+ /* 190 */ 428, 385, 608, 609, 562, 446, 87, 23, 22, 32,
90202
+ /* 200 */ 465, 466, 464, 464, 25, 25, 24, 24, 24, 24,
90203
+ /* 210 */ 447, 26, 26, 26, 26, 27, 27, 28, 28, 28,
90204
+ /* 220 */ 29, 221, 312, 233, 477, 223, 576, 134, 139, 263,
90205
+ /* 230 */ 365, 268, 366, 160, 406, 354, 226, 498, 481, 272,
90206
+ /* 240 */ 339, 27, 27, 28, 28, 28, 29, 221, 450, 442,
90207
+ /* 250 */ 199, 540, 457, 463, 349, 336, 163, 551, 66, 368,
90208
+ /* 260 */ 371, 372, 450, 415, 446, 80, 522, 581, 401, 373,
90209
+ /* 270 */ 452, 23, 22, 32, 465, 466, 464, 464, 25, 25,
90210
+ /* 280 */ 24, 24, 24, 24, 447, 26, 26, 26, 26, 27,
90211
+ /* 290 */ 27, 28, 28, 28, 29, 221, 312, 339, 556, 607,
90212
+ /* 300 */ 197, 454, 454, 454, 546, 578, 352, 198, 607, 440,
90213
+ /* 310 */ 65, 351, 336, 426, 426, 399, 289, 424, 425, 606,
90214
+ /* 320 */ 605, 446, 73, 426, 214, 219, 457, 463, 606, 410,
90215
+ /* 330 */ 450, 241, 306, 196, 565, 479, 555, 208, 288, 29,
90216
+ /* 340 */ 221, 447, 4, 874, 504, 23, 22, 32, 465, 466,
90217
+ /* 350 */ 464, 464, 25, 25, 24, 24, 24, 24, 447, 26,
90218
+ /* 360 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 221,
90219
+ /* 370 */ 312, 163, 582, 339, 368, 371, 372, 314, 424, 425,
90220
+ /* 380 */ 604, 222, 397, 227, 373, 427, 428, 339, 336, 409,
90221
+ /* 390 */ 222, 478, 339, 30, 396, 33, 141, 446, 81, 62,
90222
+ /* 400 */ 457, 463, 336, 157, 400, 450, 504, 336, 438, 426,
90223
+ /* 410 */ 500, 446, 87, 41, 380, 613, 446, 80, 581, 23,
90224
+ /* 420 */ 22, 32, 465, 466, 464, 464, 25, 25, 24, 24,
90225
+ /* 430 */ 24, 24, 213, 26, 26, 26, 26, 27, 27, 28,
90226
+ /* 440 */ 28, 28, 29, 221, 312, 513, 427, 428, 517, 254,
90227
+ /* 450 */ 524, 386, 225, 339, 486, 363, 389, 339, 356, 443,
90228
+ /* 460 */ 494, 236, 30, 497, 33, 141, 399, 289, 336, 495,
90229
+ /* 470 */ 487, 501, 336, 450, 457, 463, 219, 446, 95, 445,
90230
+ /* 480 */ 68, 446, 95, 444, 424, 425, 488, 44, 348, 288,
90231
+ /* 490 */ 504, 424, 425, 23, 22, 32, 465, 466, 464, 464,
90232
+ /* 500 */ 25, 25, 24, 24, 24, 24, 391, 26, 26, 26,
90233
+ /* 510 */ 26, 27, 27, 28, 28, 28, 29, 221, 312, 361,
90234
+ /* 520 */ 556, 426, 520, 328, 191, 271, 339, 329, 247, 259,
90235
+ /* 530 */ 339, 566, 65, 249, 336, 426, 424, 425, 445, 516,
90236
+ /* 540 */ 426, 336, 444, 446, 9, 336, 556, 451, 457, 463,
90237
+ /* 550 */ 446, 74, 427, 428, 446, 69, 192, 618, 65, 427,
90238
+ /* 560 */ 428, 426, 323, 277, 16, 202, 189, 23, 22, 32,
90239
+ /* 570 */ 465, 466, 464, 464, 25, 25, 24, 24, 24, 24,
90240
+ /* 580 */ 255, 26, 26, 26, 26, 27, 27, 28, 28, 28,
90241
+ /* 590 */ 29, 221, 312, 339, 486, 426, 537, 235, 515, 447,
90242
+ /* 600 */ 339, 629, 419, 416, 427, 428, 217, 281, 336, 279,
90243
+ /* 610 */ 487, 203, 144, 526, 527, 336, 391, 446, 78, 429,
90244
+ /* 620 */ 430, 431, 457, 463, 446, 99, 488, 341, 528, 468,
90245
+ /* 630 */ 468, 426, 343, 472, 473, 626, 949, 474, 949, 529,
90246
+ /* 640 */ 447, 23, 22, 32, 465, 466, 464, 464, 25, 25,
90247
+ /* 650 */ 24, 24, 24, 24, 339, 26, 26, 26, 26, 27,
90248
+ /* 660 */ 27, 28, 28, 28, 29, 221, 312, 339, 162, 336,
90249
+ /* 670 */ 275, 283, 476, 376, 339, 579, 527, 346, 446, 98,
90250
+ /* 680 */ 622, 30, 336, 33, 141, 339, 426, 339, 508, 336,
90251
+ /* 690 */ 469, 446, 105, 418, 2, 222, 457, 463, 446, 101,
90252
+ /* 700 */ 336, 219, 336, 426, 161, 626, 948, 290, 948, 446,
90253
+ /* 710 */ 108, 446, 109, 398, 284, 23, 22, 32, 465, 466,
90254
+ /* 720 */ 464, 464, 25, 25, 24, 24, 24, 24, 339, 26,
90255
+ /* 730 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 221,
90256
+ /* 740 */ 312, 339, 271, 336, 339, 58, 535, 482, 143, 339,
90257
+ /* 750 */ 622, 318, 446, 133, 408, 257, 336, 426, 321, 336,
90258
+ /* 760 */ 357, 339, 272, 426, 336, 446, 135, 184, 446, 61,
90259
+ /* 770 */ 457, 463, 219, 446, 106, 426, 336, 493, 341, 234,
90260
+ /* 780 */ 468, 468, 621, 310, 407, 446, 102, 209, 144, 23,
90261
+ /* 790 */ 22, 32, 465, 466, 464, 464, 25, 25, 24, 24,
90262
+ /* 800 */ 24, 24, 339, 26, 26, 26, 26, 27, 27, 28,
90263
+ /* 810 */ 28, 28, 29, 221, 312, 339, 271, 336, 339, 341,
90264
+ /* 820 */ 538, 468, 468, 572, 383, 496, 446, 79, 499, 549,
90265
+ /* 830 */ 336, 426, 508, 336, 508, 341, 339, 468, 468, 446,
90266
+ /* 840 */ 103, 391, 446, 70, 457, 463, 572, 426, 40, 426,
90267
+ /* 850 */ 42, 336, 220, 324, 504, 341, 426, 468, 468, 18,
90268
+ /* 860 */ 446, 100, 266, 23, 22, 32, 465, 466, 464, 464,
90269
+ /* 870 */ 25, 25, 24, 24, 24, 24, 339, 26, 26, 26,
90270
+ /* 880 */ 26, 27, 27, 28, 28, 28, 29, 221, 312, 339,
90271
+ /* 890 */ 283, 336, 339, 261, 548, 384, 339, 327, 142, 550,
90272
+ /* 900 */ 446, 136, 475, 475, 336, 426, 185, 336, 499, 396,
90273
+ /* 910 */ 339, 336, 370, 446, 137, 256, 446, 138, 457, 463,
90274
+ /* 920 */ 446, 71, 499, 360, 426, 336, 161, 311, 623, 215,
90275
+ /* 930 */ 426, 359, 237, 412, 446, 82, 200, 23, 34, 32,
90276
+ /* 940 */ 465, 466, 464, 464, 25, 25, 24, 24, 24, 24,
90277
+ /* 950 */ 339, 26, 26, 26, 26, 27, 27, 28, 28, 28,
90278
+ /* 960 */ 29, 221, 312, 447, 271, 336, 339, 271, 340, 210,
90279
+ /* 970 */ 447, 172, 625, 211, 446, 83, 240, 552, 142, 426,
90280
+ /* 980 */ 321, 336, 426, 426, 339, 414, 331, 181, 458, 459,
90281
+ /* 990 */ 446, 72, 457, 463, 470, 506, 67, 158, 394, 336,
90282
+ /* 1000 */ 587, 325, 499, 447, 326, 311, 624, 447, 446, 84,
90283
+ /* 1010 */ 461, 462, 22, 32, 465, 466, 464, 464, 25, 25,
90284
+ /* 1020 */ 24, 24, 24, 24, 339, 26, 26, 26, 26, 27,
90285
+ /* 1030 */ 27, 28, 28, 28, 29, 221, 312, 460, 339, 336,
90286
+ /* 1040 */ 339, 283, 423, 393, 532, 533, 204, 205, 446, 85,
90287
+ /* 1050 */ 625, 392, 547, 336, 162, 336, 426, 426, 339, 435,
90288
+ /* 1060 */ 436, 339, 446, 104, 446, 86, 457, 463, 264, 291,
90289
+ /* 1070 */ 274, 49, 162, 336, 426, 426, 336, 297, 265, 542,
90290
+ /* 1080 */ 541, 405, 446, 88, 594, 446, 89, 32, 465, 466,
90291
+ /* 1090 */ 464, 464, 25, 25, 24, 24, 24, 24, 600, 26,
90292
+ /* 1100 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 221,
90293
+ /* 1110 */ 36, 345, 339, 3, 214, 8, 422, 335, 425, 437,
90294
+ /* 1120 */ 375, 148, 162, 36, 345, 339, 3, 336, 342, 432,
90295
+ /* 1130 */ 335, 425, 149, 577, 426, 162, 446, 90, 151, 339,
90296
+ /* 1140 */ 336, 342, 434, 339, 283, 433, 333, 347, 447, 446,
90297
+ /* 1150 */ 75, 588, 6, 158, 336, 448, 140, 481, 336, 426,
90298
+ /* 1160 */ 347, 453, 334, 446, 76, 49, 350, 446, 91, 7,
90299
+ /* 1170 */ 481, 426, 397, 283, 355, 250, 426, 39, 38, 251,
90300
+ /* 1180 */ 339, 426, 48, 353, 37, 337, 338, 596, 426, 452,
90301
+ /* 1190 */ 39, 38, 514, 252, 390, 336, 20, 37, 337, 338,
90302
+ /* 1200 */ 253, 43, 452, 206, 446, 92, 219, 449, 242, 243,
90303
+ /* 1210 */ 244, 150, 246, 283, 491, 593, 597, 490, 224, 258,
90304
+ /* 1220 */ 454, 454, 454, 455, 456, 10, 503, 183, 426, 178,
90305
+ /* 1230 */ 156, 301, 426, 454, 454, 454, 455, 456, 10, 339,
90306
+ /* 1240 */ 302, 426, 36, 345, 50, 3, 339, 505, 260, 335,
90307
+ /* 1250 */ 425, 262, 339, 176, 336, 581, 598, 358, 364, 175,
90308
+ /* 1260 */ 342, 336, 177, 446, 93, 46, 345, 336, 3, 339,
90309
+ /* 1270 */ 446, 94, 335, 425, 525, 339, 446, 77, 320, 347,
90310
+ /* 1280 */ 511, 339, 507, 342, 336, 589, 601, 56, 56, 481,
90311
+ /* 1290 */ 336, 512, 283, 446, 17, 531, 336, 426, 530, 446,
90312
+ /* 1300 */ 96, 534, 347, 404, 298, 446, 97, 426, 313, 39,
90313
+ /* 1310 */ 38, 267, 481, 219, 535, 536, 37, 337, 338, 283,
90314
+ /* 1320 */ 620, 452, 309, 283, 111, 19, 288, 509, 269, 424,
90315
+ /* 1330 */ 425, 539, 39, 38, 426, 238, 270, 411, 426, 37,
90316
+ /* 1340 */ 337, 338, 426, 426, 452, 558, 426, 307, 231, 276,
90317
+ /* 1350 */ 278, 426, 454, 454, 454, 455, 456, 10, 553, 280,
90318
+ /* 1360 */ 426, 559, 239, 230, 426, 426, 299, 282, 287, 481,
90319
+ /* 1370 */ 560, 388, 584, 232, 426, 454, 454, 454, 455, 456,
90320
+ /* 1380 */ 10, 561, 426, 426, 585, 395, 426, 426, 292, 194,
90321
+ /* 1390 */ 195, 592, 603, 300, 303, 308, 377, 522, 381, 426,
90322
+ /* 1400 */ 426, 452, 567, 426, 304, 617, 426, 426, 426, 426,
90323
+ /* 1410 */ 379, 53, 147, 165, 166, 167, 580, 212, 569, 426,
90324
+ /* 1420 */ 426, 285, 168, 570, 387, 120, 123, 187, 590, 402,
90325
+ /* 1430 */ 403, 125, 454, 454, 454, 330, 599, 614, 186, 126,
90326
+ /* 1440 */ 127, 128, 615, 616, 57, 60, 619, 107, 229, 64,
90327
+ /* 1450 */ 115, 420, 245, 130, 439, 180, 315, 207, 670, 316,
90328
+ /* 1460 */ 671, 467, 672, 153, 154, 35, 483, 471, 480, 188,
90329
+ /* 1470 */ 201, 155, 484, 5, 485, 489, 12, 502, 45, 11,
90330
+ /* 1480 */ 110, 145, 518, 519, 510, 228, 51, 112, 369, 273,
90331
+ /* 1490 */ 113, 159, 545, 52, 374, 114, 164, 265, 378, 190,
90332
+ /* 1500 */ 146, 568, 117, 158, 286, 382, 169, 119, 15, 583,
90333
+ /* 1510 */ 170, 171, 121, 586, 122, 54, 55, 13, 124, 591,
90334
+ /* 1520 */ 173, 174, 118, 575, 129, 595, 571, 131, 14, 132,
90335
+ /* 1530 */ 611, 63, 612, 193, 602, 179, 305, 413, 417, 960,
90336
+ /* 1540 */ 627,
8855990337
};
8856090338
static const YYCODETYPE yy_lookahead[] = {
88561
- /* 0 */ 19, 142, 143, 144, 145, 24, 116, 26, 75, 76,
88562
- /* 10 */ 77, 78, 25, 80, 81, 82, 83, 84, 85, 86,
88563
- /* 20 */ 87, 88, 89, 90, 26, 27, 160, 26, 27, 48,
88564
- /* 30 */ 49, 79, 80, 81, 82, 83, 84, 85, 86, 87,
88565
- /* 40 */ 88, 89, 90, 222, 223, 224, 225, 66, 67, 68,
90339
+ /* 0 */ 19, 142, 143, 144, 145, 24, 115, 26, 77, 78,
90340
+ /* 10 */ 79, 80, 92, 82, 83, 84, 85, 86, 87, 88,
90341
+ /* 20 */ 89, 90, 91, 92, 26, 27, 222, 223, 224, 225,
90342
+ /* 30 */ 49, 50, 81, 82, 83, 84, 85, 86, 87, 88,
90343
+ /* 40 */ 89, 90, 91, 92, 88, 89, 90, 91, 92, 68,
8856690344
/* 50 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
88567
- /* 60 */ 194, 80, 81, 82, 83, 84, 85, 86, 87, 88,
88568
- /* 70 */ 89, 90, 19, 90, 19, 94, 174, 25, 25, 80,
88569
- /* 80 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
88570
- /* 90 */ 26, 27, 94, 95, 96, 94, 95, 99, 100, 101,
88571
- /* 100 */ 19, 48, 49, 150, 174, 52, 119, 166, 110, 84,
88572
- /* 110 */ 85, 86, 87, 88, 89, 90, 26, 27, 165, 66,
88573
- /* 120 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
88574
- /* 130 */ 77, 78, 186, 80, 81, 82, 83, 84, 85, 86,
88575
- /* 140 */ 87, 88, 89, 90, 19, 90, 205, 95, 84, 85,
88576
- /* 150 */ 186, 96, 97, 98, 99, 100, 101, 102, 94, 95,
88577
- /* 160 */ 195, 97, 150, 222, 109, 224, 225, 26, 104, 105,
88578
- /* 170 */ 217, 90, 120, 48, 49, 50, 86, 165, 97, 98,
88579
- /* 180 */ 99, 100, 101, 102, 94, 95, 174, 175, 1, 2,
88580
- /* 190 */ 109, 66, 67, 68, 69, 70, 71, 72, 73, 74,
88581
- /* 200 */ 75, 76, 77, 78, 191, 80, 81, 82, 83, 84,
88582
- /* 210 */ 85, 86, 87, 88, 89, 90, 19, 116, 35, 150,
88583
- /* 220 */ 12, 24, 208, 150, 222, 150, 224, 225, 216, 128,
88584
- /* 230 */ 161, 162, 150, 221, 165, 94, 28, 150, 165, 56,
88585
- /* 240 */ 165, 197, 160, 170, 171, 48, 49, 165, 204, 174,
88586
- /* 250 */ 175, 43, 165, 45, 185, 186, 174, 175, 169, 170,
88587
- /* 260 */ 171, 174, 175, 66, 67, 68, 69, 70, 71, 72,
88588
- /* 270 */ 73, 74, 75, 76, 77, 78, 194, 80, 81, 82,
88589
- /* 280 */ 83, 84, 85, 86, 87, 88, 89, 90, 19, 214,
88590
- /* 290 */ 215, 108, 150, 25, 148, 150, 64, 22, 216, 24,
88591
- /* 300 */ 146, 147, 215, 221, 231, 232, 152, 165, 154, 150,
88592
- /* 310 */ 165, 49, 170, 171, 160, 181, 182, 48, 49, 174,
88593
- /* 320 */ 175, 232, 188, 165, 165, 21, 94, 0, 1, 2,
88594
- /* 330 */ 98, 55, 174, 174, 175, 66, 67, 68, 69, 70,
88595
- /* 340 */ 71, 72, 73, 74, 75, 76, 77, 78, 194, 80,
88596
- /* 350 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
88597
- /* 360 */ 19, 129, 130, 131, 96, 61, 104, 99, 100, 101,
88598
- /* 370 */ 150, 226, 218, 231, 232, 216, 150, 196, 110, 26,
88599
- /* 380 */ 27, 105, 106, 107, 158, 165, 183, 161, 162, 48,
88600
- /* 390 */ 49, 165, 116, 166, 174, 175, 86, 87, 88, 89,
88601
- /* 400 */ 90, 247, 84, 85, 100, 136, 183, 66, 67, 68,
88602
- /* 410 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
88603
- /* 420 */ 11, 80, 81, 82, 83, 84, 85, 86, 87, 88,
88604
- /* 430 */ 89, 90, 19, 183, 150, 222, 23, 224, 225, 237,
88605
- /* 440 */ 220, 150, 138, 24, 160, 26, 22, 94, 95, 165,
88606
- /* 450 */ 26, 27, 26, 27, 89, 90, 165, 244, 174, 175,
88607
- /* 460 */ 236, 48, 49, 22, 55, 174, 175, 26, 27, 22,
88608
- /* 470 */ 23, 163, 25, 120, 166, 167, 168, 136, 194, 66,
88609
- /* 480 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
88610
- /* 490 */ 77, 78, 153, 80, 81, 82, 83, 84, 85, 86,
88611
- /* 500 */ 87, 88, 89, 90, 19, 196, 160, 150, 23, 173,
88612
- /* 510 */ 198, 220, 65, 94, 105, 106, 107, 181, 94, 95,
88613
- /* 520 */ 94, 95, 165, 96, 150, 116, 99, 100, 101, 31,
88614
- /* 530 */ 150, 174, 175, 48, 49, 94, 95, 110, 40, 165,
88615
- /* 540 */ 194, 161, 162, 166, 160, 165, 120, 166, 174, 175,
88616
- /* 550 */ 233, 66, 67, 68, 69, 70, 71, 72, 73, 74,
88617
- /* 560 */ 75, 76, 77, 78, 218, 80, 81, 82, 83, 84,
88618
- /* 570 */ 85, 86, 87, 88, 89, 90, 19, 12, 194, 150,
88619
- /* 580 */ 23, 235, 205, 166, 167, 168, 240, 150, 172, 173,
88620
- /* 590 */ 206, 207, 150, 28, 165, 190, 191, 181, 23, 150,
88621
- /* 600 */ 48, 49, 165, 174, 175, 48, 49, 165, 43, 233,
88622
- /* 610 */ 45, 174, 175, 135, 165, 137, 174, 175, 190, 191,
88623
- /* 620 */ 55, 69, 70, 66, 67, 68, 69, 70, 71, 72,
88624
- /* 630 */ 73, 74, 75, 76, 77, 78, 150, 80, 81, 82,
88625
- /* 640 */ 83, 84, 85, 86, 87, 88, 89, 90, 19, 150,
88626
- /* 650 */ 98, 165, 23, 250, 251, 150, 155, 150, 19, 22,
88627
- /* 660 */ 174, 175, 213, 26, 165, 169, 170, 171, 23, 150,
88628
- /* 670 */ 165, 150, 165, 174, 175, 19, 150, 48, 49, 174,
88629
- /* 680 */ 175, 174, 175, 27, 165, 228, 165, 112, 49, 114,
88630
- /* 690 */ 115, 165, 177, 174, 175, 66, 67, 68, 69, 70,
88631
- /* 700 */ 71, 72, 73, 74, 75, 76, 77, 78, 150, 80,
88632
- /* 710 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
88633
- /* 720 */ 19, 150, 23, 165, 25, 24, 150, 150, 232, 150,
88634
- /* 730 */ 229, 94, 174, 175, 213, 234, 165, 25, 150, 150,
88635
- /* 740 */ 150, 165, 165, 104, 165, 174, 175, 177, 109, 48,
88636
- /* 750 */ 49, 174, 175, 165, 165, 165, 19, 112, 22, 114,
88637
- /* 760 */ 115, 177, 174, 175, 27, 16, 187, 66, 67, 68,
88638
- /* 770 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
88639
- /* 780 */ 150, 80, 81, 82, 83, 84, 85, 86, 87, 88,
88640
- /* 790 */ 89, 90, 19, 150, 95, 165, 144, 145, 150, 150,
88641
- /* 800 */ 150, 150, 113, 213, 174, 175, 117, 58, 165, 60,
88642
- /* 810 */ 74, 23, 150, 165, 165, 165, 165, 174, 175, 120,
88643
- /* 820 */ 19, 48, 49, 174, 175, 174, 175, 165, 209, 166,
88644
- /* 830 */ 241, 22, 23, 166, 25, 187, 174, 175, 126, 66,
88645
- /* 840 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
88646
- /* 850 */ 77, 78, 150, 80, 81, 82, 83, 84, 85, 86,
88647
- /* 860 */ 87, 88, 89, 90, 19, 150, 150, 165, 205, 182,
88648
- /* 870 */ 86, 150, 205, 150, 65, 166, 174, 175, 206, 207,
88649
- /* 880 */ 165, 165, 177, 150, 23, 25, 165, 138, 165, 174,
88650
- /* 890 */ 175, 241, 166, 48, 49, 174, 175, 113, 165, 98,
88651
- /* 900 */ 112, 117, 114, 115, 7, 8, 9, 174, 175, 193,
88652
- /* 910 */ 187, 66, 67, 68, 69, 70, 71, 72, 73, 74,
88653
- /* 920 */ 75, 76, 77, 78, 150, 80, 81, 82, 83, 84,
88654
- /* 930 */ 85, 86, 87, 88, 89, 90, 19, 150, 97, 165,
88655
- /* 940 */ 160, 150, 177, 150, 150, 150, 248, 249, 174, 175,
88656
- /* 950 */ 97, 98, 165, 129, 130, 150, 165, 116, 165, 165,
88657
- /* 960 */ 165, 174, 175, 103, 178, 48, 49, 174, 175, 128,
88658
- /* 970 */ 165, 98, 242, 112, 194, 114, 115, 199, 187, 174,
88659
- /* 980 */ 175, 187, 109, 242, 67, 68, 69, 70, 71, 72,
88660
- /* 990 */ 73, 74, 75, 76, 77, 78, 150, 80, 81, 82,
88661
- /* 1000 */ 83, 84, 85, 86, 87, 88, 89, 90, 19, 150,
88662
- /* 1010 */ 160, 165, 209, 150, 112, 150, 114, 115, 7, 8,
88663
- /* 1020 */ 174, 175, 209, 6, 165, 29, 199, 150, 165, 33,
88664
- /* 1030 */ 165, 150, 149, 174, 175, 150, 241, 48, 49, 174,
88665
- /* 1040 */ 175, 149, 165, 47, 194, 149, 165, 16, 160, 149,
88666
- /* 1050 */ 165, 174, 175, 13, 151, 174, 175, 68, 69, 70,
88667
- /* 1060 */ 71, 72, 73, 74, 75, 76, 77, 78, 218, 80,
88668
- /* 1070 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
88669
- /* 1080 */ 19, 20, 194, 22, 150, 150, 150, 26, 27, 58,
88670
- /* 1090 */ 240, 60, 150, 160, 151, 19, 20, 36, 22, 165,
88671
- /* 1100 */ 165, 165, 26, 27, 22, 23, 150, 165, 174, 175,
88672
- /* 1110 */ 174, 175, 36, 150, 25, 54, 150, 150, 150, 150,
88673
- /* 1120 */ 23, 165, 25, 159, 150, 64, 194, 194, 165, 199,
88674
- /* 1130 */ 54, 165, 165, 165, 165, 193, 150, 174, 175, 165,
88675
- /* 1140 */ 64, 174, 175, 174, 175, 84, 85, 65, 150, 193,
88676
- /* 1150 */ 126, 165, 217, 150, 93, 94, 95, 123, 200, 98,
88677
- /* 1160 */ 84, 85, 86, 165, 105, 106, 107, 193, 165, 93,
88678
- /* 1170 */ 94, 95, 174, 175, 98, 5, 23, 116, 25, 193,
88679
- /* 1180 */ 10, 11, 12, 13, 14, 201, 23, 17, 25, 150,
88680
- /* 1190 */ 129, 130, 131, 132, 133, 134, 193, 150, 125, 124,
88681
- /* 1200 */ 30, 245, 32, 150, 165, 129, 130, 131, 132, 133,
88682
- /* 1210 */ 134, 41, 165, 19, 20, 122, 22, 202, 165, 150,
88683
- /* 1220 */ 26, 27, 150, 53, 150, 55, 160, 174, 175, 59,
88684
- /* 1230 */ 36, 22, 62, 203, 165, 26, 27, 165, 150, 165,
88685
- /* 1240 */ 193, 150, 105, 106, 107, 135, 174, 175, 54, 150,
88686
- /* 1250 */ 150, 150, 227, 165, 22, 23, 165, 150, 64, 150,
88687
- /* 1260 */ 194, 118, 174, 175, 165, 165, 165, 193, 150, 157,
88688
- /* 1270 */ 150, 157, 165, 64, 165, 105, 106, 107, 84, 85,
88689
- /* 1280 */ 23, 111, 25, 165, 193, 165, 116, 93, 94, 95,
88690
- /* 1290 */ 150, 150, 98, 84, 85, 150, 150, 65, 150, 150,
88691
- /* 1300 */ 150, 104, 150, 94, 150, 165, 165, 98, 210, 139,
88692
- /* 1310 */ 165, 165, 210, 165, 165, 165, 150, 165, 150, 165,
88693
- /* 1320 */ 121, 150, 150, 129, 130, 131, 132, 133, 134, 210,
88694
- /* 1330 */ 150, 165, 150, 165, 150, 150, 165, 165, 129, 130,
88695
- /* 1340 */ 131, 150, 150, 150, 211, 165, 150, 165, 104, 165,
88696
- /* 1350 */ 165, 23, 23, 25, 25, 211, 165, 165, 165, 176,
88697
- /* 1360 */ 23, 165, 25, 23, 23, 25, 25, 23, 211, 25,
88698
- /* 1370 */ 46, 176, 184, 103, 176, 22, 90, 176, 178, 18,
88699
- /* 1380 */ 176, 179, 176, 176, 179, 230, 230, 184, 157, 156,
88700
- /* 1390 */ 156, 44, 157, 156, 135, 157, 157, 238, 156, 239,
88701
- /* 1400 */ 157, 66, 189, 189, 22, 219, 157, 199, 18, 192,
88702
- /* 1410 */ 192, 192, 192, 189, 199, 157, 39, 243, 243, 157,
88703
- /* 1420 */ 157, 37, 246, 1, 164, 180, 180, 249, 15, 219,
88704
- /* 1430 */ 23, 252, 22, 252, 118, 118, 118, 118, 118, 113,
88705
- /* 1440 */ 98, 22, 11, 23, 23, 22, 22, 120, 23, 34,
88706
- /* 1450 */ 23, 25, 23, 25, 118, 25, 22, 102, 50, 23,
88707
- /* 1460 */ 23, 22, 27, 22, 50, 23, 34, 34, 22, 22,
88708
- /* 1470 */ 22, 109, 19, 24, 20, 104, 38, 25, 104, 22,
88709
- /* 1480 */ 5, 138, 1, 118, 34, 42, 27, 108, 22, 119,
88710
- /* 1490 */ 50, 74, 74, 127, 1, 16, 51, 121, 20, 119,
88711
- /* 1500 */ 108, 57, 51, 128, 22, 127, 23, 23, 16, 15,
88712
- /* 1510 */ 22, 3, 140, 4, 253, 253, 253, 253, 63,
90345
+ /* 60 */ 79, 80, 16, 82, 83, 84, 85, 86, 87, 88,
90346
+ /* 70 */ 89, 90, 91, 92, 19, 94, 19, 166, 167, 168,
90347
+ /* 80 */ 25, 82, 83, 84, 85, 86, 87, 88, 89, 90,
90348
+ /* 90 */ 91, 92, 94, 95, 96, 150, 36, 99, 100, 101,
90349
+ /* 100 */ 174, 169, 170, 171, 49, 50, 60, 109, 62, 54,
90350
+ /* 110 */ 165, 51, 1, 2, 26, 27, 174, 22, 58, 174,
90351
+ /* 120 */ 175, 26, 27, 68, 69, 70, 71, 72, 73, 74,
90352
+ /* 130 */ 75, 76, 77, 78, 79, 80, 186, 82, 83, 84,
90353
+ /* 140 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 92,
90354
+ /* 150 */ 19, 172, 173, 96, 97, 98, 99, 100, 101, 102,
90355
+ /* 160 */ 181, 216, 146, 147, 232, 108, 221, 107, 152, 186,
90356
+ /* 170 */ 154, 150, 195, 30, 86, 87, 160, 34, 49, 50,
90357
+ /* 180 */ 26, 52, 94, 95, 138, 97, 165, 181, 182, 94,
90358
+ /* 190 */ 95, 48, 104, 105, 188, 174, 175, 68, 69, 70,
90359
+ /* 200 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
90360
+ /* 210 */ 194, 82, 83, 84, 85, 86, 87, 88, 89, 90,
90361
+ /* 220 */ 91, 92, 19, 92, 86, 87, 21, 24, 97, 98,
90362
+ /* 230 */ 99, 100, 101, 102, 218, 214, 215, 208, 66, 108,
90363
+ /* 240 */ 150, 86, 87, 88, 89, 90, 91, 92, 94, 173,
90364
+ /* 250 */ 160, 183, 49, 50, 191, 165, 96, 181, 22, 99,
90365
+ /* 260 */ 100, 101, 26, 247, 174, 175, 94, 57, 63, 109,
90366
+ /* 270 */ 98, 68, 69, 70, 71, 72, 73, 74, 75, 76,
90367
+ /* 280 */ 77, 78, 79, 80, 194, 82, 83, 84, 85, 86,
90368
+ /* 290 */ 87, 88, 89, 90, 91, 92, 19, 150, 150, 150,
90369
+ /* 300 */ 25, 129, 130, 131, 183, 100, 216, 160, 150, 161,
90370
+ /* 310 */ 162, 221, 165, 165, 165, 105, 106, 26, 27, 170,
90371
+ /* 320 */ 171, 174, 175, 165, 160, 115, 49, 50, 170, 171,
90372
+ /* 330 */ 94, 148, 163, 185, 186, 166, 167, 168, 128, 91,
90373
+ /* 340 */ 92, 194, 196, 138, 166, 68, 69, 70, 71, 72,
90374
+ /* 350 */ 73, 74, 75, 76, 77, 78, 79, 80, 194, 82,
90375
+ /* 360 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
90376
+ /* 370 */ 19, 96, 11, 150, 99, 100, 101, 155, 26, 27,
90377
+ /* 380 */ 231, 232, 218, 205, 109, 94, 95, 150, 165, 231,
90378
+ /* 390 */ 232, 166, 150, 222, 150, 224, 225, 174, 175, 235,
90379
+ /* 400 */ 49, 50, 165, 24, 240, 26, 166, 165, 153, 165,
90380
+ /* 410 */ 119, 174, 175, 136, 237, 244, 174, 175, 57, 68,
90381
+ /* 420 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
90382
+ /* 430 */ 79, 80, 236, 82, 83, 84, 85, 86, 87, 88,
90383
+ /* 440 */ 89, 90, 91, 92, 19, 205, 94, 95, 23, 226,
90384
+ /* 450 */ 165, 229, 215, 150, 12, 88, 234, 150, 216, 174,
90385
+ /* 460 */ 32, 217, 222, 25, 224, 225, 105, 106, 165, 41,
90386
+ /* 470 */ 28, 119, 165, 94, 49, 50, 115, 174, 175, 112,
90387
+ /* 480 */ 22, 174, 175, 116, 26, 27, 44, 136, 46, 128,
90388
+ /* 490 */ 166, 26, 27, 68, 69, 70, 71, 72, 73, 74,
90389
+ /* 500 */ 75, 76, 77, 78, 79, 80, 150, 82, 83, 84,
90390
+ /* 510 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 150,
90391
+ /* 520 */ 150, 165, 23, 220, 196, 150, 150, 220, 158, 205,
90392
+ /* 530 */ 150, 161, 162, 198, 165, 165, 26, 27, 112, 23,
90393
+ /* 540 */ 165, 165, 116, 174, 175, 165, 150, 166, 49, 50,
90394
+ /* 550 */ 174, 175, 94, 95, 174, 175, 118, 161, 162, 94,
90395
+ /* 560 */ 95, 165, 187, 16, 22, 160, 24, 68, 69, 70,
90396
+ /* 570 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
90397
+ /* 580 */ 150, 82, 83, 84, 85, 86, 87, 88, 89, 90,
90398
+ /* 590 */ 91, 92, 19, 150, 12, 165, 23, 241, 88, 194,
90399
+ /* 600 */ 150, 0, 1, 2, 94, 95, 160, 60, 165, 62,
90400
+ /* 610 */ 28, 206, 207, 190, 191, 165, 150, 174, 175, 7,
90401
+ /* 620 */ 8, 9, 49, 50, 174, 175, 44, 111, 46, 113,
90402
+ /* 630 */ 114, 165, 169, 170, 171, 22, 23, 233, 25, 57,
90403
+ /* 640 */ 194, 68, 69, 70, 71, 72, 73, 74, 75, 76,
90404
+ /* 650 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
90405
+ /* 660 */ 87, 88, 89, 90, 91, 92, 19, 150, 25, 165,
90406
+ /* 670 */ 23, 150, 233, 19, 150, 190, 191, 228, 174, 175,
90407
+ /* 680 */ 67, 222, 165, 224, 225, 150, 165, 150, 150, 165,
90408
+ /* 690 */ 23, 174, 175, 144, 145, 232, 49, 50, 174, 175,
90409
+ /* 700 */ 165, 115, 165, 165, 50, 22, 23, 241, 25, 174,
90410
+ /* 710 */ 175, 174, 175, 127, 193, 68, 69, 70, 71, 72,
90411
+ /* 720 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82,
90412
+ /* 730 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
90413
+ /* 740 */ 19, 150, 150, 165, 150, 24, 103, 23, 150, 150,
90414
+ /* 750 */ 67, 213, 174, 175, 97, 209, 165, 165, 104, 165,
90415
+ /* 760 */ 150, 150, 108, 165, 165, 174, 175, 23, 174, 175,
90416
+ /* 770 */ 49, 50, 115, 174, 175, 165, 165, 177, 111, 187,
90417
+ /* 780 */ 113, 114, 250, 251, 127, 174, 175, 206, 207, 68,
90418
+ /* 790 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
90419
+ /* 800 */ 79, 80, 150, 82, 83, 84, 85, 86, 87, 88,
90420
+ /* 810 */ 89, 90, 91, 92, 19, 150, 150, 165, 150, 111,
90421
+ /* 820 */ 182, 113, 114, 105, 106, 177, 174, 175, 25, 166,
90422
+ /* 830 */ 165, 165, 150, 165, 150, 111, 150, 113, 114, 174,
90423
+ /* 840 */ 175, 150, 174, 175, 49, 50, 128, 165, 135, 165,
90424
+ /* 850 */ 137, 165, 197, 187, 166, 111, 165, 113, 114, 204,
90425
+ /* 860 */ 174, 175, 177, 68, 69, 70, 71, 72, 73, 74,
90426
+ /* 870 */ 75, 76, 77, 78, 79, 80, 150, 82, 83, 84,
90427
+ /* 880 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 150,
90428
+ /* 890 */ 150, 165, 150, 205, 177, 213, 150, 213, 95, 177,
90429
+ /* 900 */ 174, 175, 129, 130, 165, 165, 23, 165, 25, 150,
90430
+ /* 910 */ 150, 165, 178, 174, 175, 150, 174, 175, 49, 50,
90431
+ /* 920 */ 174, 175, 119, 19, 165, 165, 50, 22, 23, 160,
90432
+ /* 930 */ 165, 27, 241, 193, 174, 175, 160, 68, 69, 70,
90433
+ /* 940 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
90434
+ /* 950 */ 150, 82, 83, 84, 85, 86, 87, 88, 89, 90,
90435
+ /* 960 */ 91, 92, 19, 194, 150, 165, 150, 150, 150, 160,
90436
+ /* 970 */ 194, 25, 67, 160, 174, 175, 217, 166, 95, 165,
90437
+ /* 980 */ 104, 165, 165, 165, 150, 245, 248, 249, 49, 50,
90438
+ /* 990 */ 174, 175, 49, 50, 23, 23, 25, 25, 242, 165,
90439
+ /* 1000 */ 199, 187, 119, 194, 187, 22, 23, 194, 174, 175,
90440
+ /* 1010 */ 71, 72, 69, 70, 71, 72, 73, 74, 75, 76,
90441
+ /* 1020 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
90442
+ /* 1030 */ 87, 88, 89, 90, 91, 92, 19, 98, 150, 165,
90443
+ /* 1040 */ 150, 150, 150, 19, 7, 8, 105, 106, 174, 175,
90444
+ /* 1050 */ 67, 27, 23, 165, 25, 165, 165, 165, 150, 150,
90445
+ /* 1060 */ 150, 150, 174, 175, 174, 175, 49, 50, 98, 242,
90446
+ /* 1070 */ 23, 125, 25, 165, 165, 165, 165, 209, 108, 97,
90447
+ /* 1080 */ 98, 209, 174, 175, 193, 174, 175, 70, 71, 72,
90448
+ /* 1090 */ 73, 74, 75, 76, 77, 78, 79, 80, 199, 82,
90449
+ /* 1100 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
90450
+ /* 1110 */ 19, 20, 150, 22, 160, 22, 149, 26, 27, 150,
90451
+ /* 1120 */ 23, 6, 25, 19, 20, 150, 22, 165, 37, 149,
90452
+ /* 1130 */ 26, 27, 151, 23, 165, 25, 174, 175, 151, 150,
90453
+ /* 1140 */ 165, 37, 13, 150, 150, 149, 149, 56, 194, 174,
90454
+ /* 1150 */ 175, 23, 25, 25, 165, 194, 150, 66, 165, 165,
90455
+ /* 1160 */ 56, 150, 159, 174, 175, 125, 150, 174, 175, 76,
90456
+ /* 1170 */ 66, 165, 218, 150, 122, 199, 165, 86, 87, 200,
90457
+ /* 1180 */ 150, 165, 123, 121, 93, 94, 95, 193, 165, 98,
90458
+ /* 1190 */ 86, 87, 88, 201, 240, 165, 124, 93, 94, 95,
90459
+ /* 1200 */ 202, 135, 98, 5, 174, 175, 115, 203, 10, 11,
90460
+ /* 1210 */ 12, 13, 14, 150, 157, 17, 193, 150, 227, 210,
90461
+ /* 1220 */ 129, 130, 131, 132, 133, 134, 150, 157, 165, 31,
90462
+ /* 1230 */ 117, 33, 165, 129, 130, 131, 132, 133, 134, 150,
90463
+ /* 1240 */ 42, 165, 19, 20, 104, 22, 150, 211, 210, 26,
90464
+ /* 1250 */ 27, 210, 150, 55, 165, 57, 193, 120, 104, 61,
90465
+ /* 1260 */ 37, 165, 64, 174, 175, 19, 20, 165, 22, 150,
90466
+ /* 1270 */ 174, 175, 26, 27, 176, 150, 174, 175, 47, 56,
90467
+ /* 1280 */ 211, 150, 150, 37, 165, 23, 23, 25, 25, 66,
90468
+ /* 1290 */ 165, 211, 150, 174, 175, 184, 165, 165, 176, 174,
90469
+ /* 1300 */ 175, 178, 56, 105, 106, 174, 175, 165, 110, 86,
90470
+ /* 1310 */ 87, 176, 66, 115, 103, 176, 93, 94, 95, 150,
90471
+ /* 1320 */ 23, 98, 25, 150, 22, 22, 128, 150, 150, 26,
90472
+ /* 1330 */ 27, 150, 86, 87, 165, 193, 150, 139, 165, 93,
90473
+ /* 1340 */ 94, 95, 165, 165, 98, 150, 165, 179, 92, 150,
90474
+ /* 1350 */ 150, 165, 129, 130, 131, 132, 133, 134, 184, 150,
90475
+ /* 1360 */ 165, 176, 193, 230, 165, 165, 193, 150, 150, 66,
90476
+ /* 1370 */ 176, 150, 150, 230, 165, 129, 130, 131, 132, 133,
90477
+ /* 1380 */ 134, 176, 165, 165, 150, 150, 165, 165, 150, 86,
90478
+ /* 1390 */ 87, 150, 150, 150, 150, 179, 18, 94, 45, 165,
90479
+ /* 1400 */ 165, 98, 157, 165, 150, 150, 165, 165, 165, 165,
90480
+ /* 1410 */ 157, 135, 68, 156, 156, 156, 189, 157, 157, 165,
90481
+ /* 1420 */ 165, 238, 156, 239, 157, 189, 22, 219, 199, 157,
90482
+ /* 1430 */ 18, 192, 129, 130, 131, 157, 199, 40, 219, 192,
90483
+ /* 1440 */ 192, 192, 157, 157, 243, 243, 38, 164, 180, 246,
90484
+ /* 1450 */ 180, 1, 15, 189, 23, 249, 252, 22, 117, 252,
90485
+ /* 1460 */ 117, 112, 117, 117, 117, 22, 11, 23, 23, 22,
90486
+ /* 1470 */ 22, 25, 23, 35, 23, 23, 35, 119, 25, 25,
90487
+ /* 1480 */ 22, 117, 23, 23, 27, 52, 22, 22, 52, 23,
90488
+ /* 1490 */ 22, 35, 29, 22, 52, 22, 102, 108, 19, 24,
90489
+ /* 1500 */ 39, 20, 104, 25, 138, 43, 104, 22, 5, 1,
90490
+ /* 1510 */ 117, 35, 107, 27, 126, 76, 76, 22, 118, 1,
90491
+ /* 1520 */ 16, 120, 53, 53, 118, 20, 59, 107, 22, 126,
90492
+ /* 1530 */ 23, 16, 23, 22, 127, 15, 140, 65, 3, 253,
90493
+ /* 1540 */ 4,
8871390494
};
88714
-#define YY_SHIFT_USE_DFLT (-111)
88715
-#define YY_SHIFT_MAX 415
90495
+#define YY_SHIFT_USE_DFLT (-110)
90496
+#define YY_SHIFT_MAX 417
8871690497
static const short yy_shift_ofst[] = {
88717
- /* 0 */ 187, 1061, 1170, 1061, 1194, 1194, -2, 64, 64, -19,
88718
- /* 10 */ 1194, 1194, 1194, 1194, 1194, 276, 1, 125, 1076, 1194,
88719
- /* 20 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194,
88720
- /* 30 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194,
88721
- /* 40 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194,
88722
- /* 50 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, -48,
88723
- /* 60 */ 409, 1, 1, 141, 318, 318, -110, 53, 197, 269,
88724
- /* 70 */ 341, 413, 485, 557, 629, 701, 773, 845, 773, 773,
88725
- /* 80 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773,
88726
- /* 90 */ 773, 773, 773, 773, 773, 773, 917, 989, 989, -67,
88727
- /* 100 */ -67, -1, -1, 55, 25, 310, 1, 1, 1, 1,
88728
- /* 110 */ 1, 639, 304, 1, 1, 1, 1, 1, 1, 1,
88729
- /* 120 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 365,
88730
- /* 130 */ 141, -17, -111, -111, -111, 1209, 81, 424, 353, 426,
88731
- /* 140 */ 441, 90, 565, 565, 1, 1, 1, 1, 1, 1,
88732
- /* 150 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
88733
- /* 160 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
88734
- /* 170 */ 1, 1, 1, 1, 1, 1, 447, 809, 327, 419,
88735
- /* 180 */ 419, 419, 841, 101, -110, -110, -110, -111, -111, -111,
88736
- /* 190 */ 232, 232, 268, 427, 575, 645, 788, 208, 861, 699,
88737
- /* 200 */ 897, 784, 637, 52, 183, 183, 183, 902, 902, 996,
88738
- /* 210 */ 1059, 902, 902, 902, 902, 275, 689, -13, 141, 824,
88739
- /* 220 */ 824, 478, 498, 498, 656, 498, 262, 498, 141, 498,
88740
- /* 230 */ 141, 860, 737, 712, 737, 656, 656, 712, 1017, 1017,
88741
- /* 240 */ 1017, 1017, 1040, 1040, 1089, -110, 1024, 1034, 1075, 1093,
88742
- /* 250 */ 1073, 1110, 1143, 1143, 1197, 1199, 1197, 1199, 1197, 1199,
88743
- /* 260 */ 1244, 1244, 1324, 1244, 1270, 1244, 1353, 1286, 1286, 1324,
88744
- /* 270 */ 1244, 1244, 1244, 1353, 1361, 1143, 1361, 1143, 1361, 1143,
88745
- /* 280 */ 1143, 1347, 1259, 1361, 1143, 1335, 1335, 1382, 1024, 1143,
88746
- /* 290 */ 1390, 1390, 1390, 1390, 1024, 1335, 1382, 1143, 1377, 1377,
88747
- /* 300 */ 1143, 1143, 1384, -111, -111, -111, -111, -111, -111, 552,
88748
- /* 310 */ 749, 1137, 1031, 1082, 1232, 801, 1097, 1153, 873, 1011,
88749
- /* 320 */ 853, 1163, 1257, 1328, 1329, 1337, 1340, 1341, 736, 1344,
88750
- /* 330 */ 1422, 1413, 1407, 1410, 1316, 1317, 1318, 1319, 1320, 1342,
88751
- /* 340 */ 1326, 1419, 1420, 1421, 1423, 1431, 1424, 1425, 1426, 1427,
88752
- /* 350 */ 1429, 1428, 1415, 1430, 1432, 1428, 1327, 1434, 1433, 1435,
88753
- /* 360 */ 1336, 1436, 1437, 1438, 1408, 1439, 1414, 1441, 1442, 1446,
88754
- /* 370 */ 1447, 1440, 1448, 1355, 1362, 1453, 1454, 1449, 1371, 1443,
88755
- /* 380 */ 1444, 1445, 1452, 1451, 1343, 1374, 1457, 1475, 1481, 1365,
88756
- /* 390 */ 1450, 1459, 1379, 1417, 1418, 1366, 1466, 1370, 1493, 1479,
88757
- /* 400 */ 1376, 1478, 1380, 1392, 1378, 1482, 1375, 1483, 1484, 1492,
88758
- /* 410 */ 1455, 1494, 1372, 1488, 1508, 1509,
90498
+ /* 0 */ 111, 1091, 1198, 1091, 1223, 1223, -2, 88, 88, -19,
90499
+ /* 10 */ 1223, 1223, 1223, 1223, 1223, 210, 465, 129, 1104, 1223,
90500
+ /* 20 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223,
90501
+ /* 30 */ 1223, 1223, 1246, 1223, 1223, 1223, 1223, 1223, 1223, 1223,
90502
+ /* 40 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223,
90503
+ /* 50 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223,
90504
+ /* 60 */ 1223, -49, 361, 465, 465, 154, 138, 138, -109, 55,
90505
+ /* 70 */ 203, 277, 351, 425, 499, 573, 647, 721, 795, 869,
90506
+ /* 80 */ 795, 795, 795, 795, 795, 795, 795, 795, 795, 795,
90507
+ /* 90 */ 795, 795, 795, 795, 795, 795, 795, 795, 943, 1017,
90508
+ /* 100 */ 1017, -69, -69, -69, -69, -1, -1, 57, 155, -44,
90509
+ /* 110 */ 465, 465, 465, 465, 465, 654, 205, 465, 465, 465,
90510
+ /* 120 */ 465, 465, 465, 465, 465, 465, 465, 465, 465, 465,
90511
+ /* 130 */ 465, 465, 465, 248, 154, -80, -110, -110, -110, 1303,
90512
+ /* 140 */ 131, 95, 291, 352, 458, 510, 582, 582, 465, 465,
90513
+ /* 150 */ 465, 465, 465, 465, 465, 465, 465, 465, 465, 465,
90514
+ /* 160 */ 465, 465, 465, 465, 465, 465, 465, 465, 465, 465,
90515
+ /* 170 */ 465, 465, 465, 465, 465, 465, 465, 465, 465, 465,
90516
+ /* 180 */ 613, 683, 601, 379, 379, 379, 657, 586, -109, -109,
90517
+ /* 190 */ -109, -110, -110, -110, 172, 172, 275, 160, 516, 667,
90518
+ /* 200 */ 724, 442, 744, 883, 60, 60, 612, 367, 236, 803,
90519
+ /* 210 */ 708, 708, 143, 718, 708, 708, 708, 708, 542, 426,
90520
+ /* 220 */ 438, 154, 773, 773, 713, 428, 428, 904, 428, 876,
90521
+ /* 230 */ 428, 154, 428, 154, 643, 1024, 946, 1024, 904, 904,
90522
+ /* 240 */ 946, 1115, 1115, 1115, 1115, 1129, 1129, 1127, -109, 1040,
90523
+ /* 250 */ 1052, 1059, 1062, 1072, 1066, 1113, 1113, 1140, 1137, 1140,
90524
+ /* 260 */ 1137, 1140, 1137, 1154, 1154, 1231, 1154, 1211, 1154, 1302,
90525
+ /* 270 */ 1256, 1256, 1231, 1154, 1154, 1154, 1302, 1378, 1113, 1378,
90526
+ /* 280 */ 1113, 1378, 1113, 1113, 1353, 1276, 1378, 1113, 1344, 1344,
90527
+ /* 290 */ 1404, 1040, 1113, 1412, 1412, 1412, 1412, 1040, 1344, 1404,
90528
+ /* 300 */ 1113, 1397, 1397, 1113, 1113, 1408, -110, -110, -110, -110,
90529
+ /* 310 */ -110, -110, 939, 46, 547, 905, 983, 971, 972, 970,
90530
+ /* 320 */ 1037, 941, 982, 1029, 1047, 1097, 1110, 1128, 1262, 1263,
90531
+ /* 330 */ 1093, 1297, 1450, 1437, 1431, 1435, 1341, 1343, 1345, 1346,
90532
+ /* 340 */ 1347, 1349, 1443, 1444, 1445, 1447, 1455, 1448, 1449, 1446,
90533
+ /* 350 */ 1451, 1452, 1453, 1438, 1454, 1441, 1453, 1358, 1458, 1456,
90534
+ /* 360 */ 1457, 1364, 1459, 1460, 1461, 1433, 1464, 1463, 1436, 1465,
90535
+ /* 370 */ 1466, 1468, 1471, 1442, 1473, 1394, 1389, 1479, 1481, 1475,
90536
+ /* 380 */ 1398, 1462, 1467, 1469, 1478, 1470, 1366, 1402, 1485, 1503,
90537
+ /* 390 */ 1508, 1393, 1476, 1486, 1405, 1439, 1440, 1388, 1495, 1400,
90538
+ /* 400 */ 1518, 1504, 1401, 1505, 1406, 1420, 1403, 1506, 1407, 1507,
90539
+ /* 410 */ 1509, 1515, 1472, 1520, 1396, 1511, 1535, 1536,
8875990540
};
88760
-#define YY_REDUCE_USE_DFLT (-180)
88761
-#define YY_REDUCE_MAX 308
90541
+#define YY_REDUCE_USE_DFLT (-197)
90542
+#define YY_REDUCE_MAX 311
8876290543
static const short yy_reduce_ofst[] = {
88763
- /* 0 */ -141, 82, 154, 284, 12, 75, 69, 73, 142, -59,
88764
- /* 10 */ 145, 87, 159, 220, 291, 346, 226, 213, 357, 374,
88765
- /* 20 */ 429, 437, 442, 486, 499, 505, 507, 519, 558, 571,
88766
- /* 30 */ 577, 588, 630, 643, 649, 651, 662, 702, 715, 721,
88767
- /* 40 */ 733, 774, 787, 793, 805, 846, 859, 865, 877, 881,
88768
- /* 50 */ 934, 936, 963, 967, 969, 998, 1053, 1072, 1088, -179,
88769
- /* 60 */ 850, 956, 380, 308, 89, 496, 384, 2, 2, 2,
88770
- /* 70 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
88771
- /* 80 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
88772
- /* 90 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
88773
- /* 100 */ 2, 2, 2, 416, 2, 2, 449, 579, 648, 723,
88774
- /* 110 */ 791, 134, 501, 716, 521, 794, 589, -47, 650, 590,
88775
- /* 120 */ 795, 942, 974, 986, 1003, 1047, 1074, 935, 1091, 2,
88776
- /* 130 */ 417, 2, 2, 2, 2, 158, 336, 526, 576, 863,
88777
- /* 140 */ 885, 966, 405, 428, 968, 1039, 1069, 1099, 1100, 966,
88778
- /* 150 */ 1101, 1107, 1109, 1118, 1120, 1140, 1141, 1145, 1146, 1148,
88779
- /* 160 */ 1149, 1150, 1152, 1154, 1166, 1168, 1171, 1172, 1180, 1182,
88780
- /* 170 */ 1184, 1185, 1191, 1192, 1193, 1196, 403, 403, 652, 377,
88781
- /* 180 */ 663, 667, -134, 780, 888, 933, 1066, 44, 672, 698,
88782
- /* 190 */ -98, -70, -54, -36, -35, -35, -35, 13, -35, 14,
88783
- /* 200 */ 146, 181, 227, 14, 203, 223, 250, -35, -35, 224,
88784
- /* 210 */ 202, -35, -35, -35, -35, 339, 309, 312, 381, 317,
88785
- /* 220 */ 376, 457, 515, 570, 619, 584, 687, 705, 709, 765,
88786
- /* 230 */ 726, 786, 730, 778, 741, 803, 813, 827, 883, 892,
88787
- /* 240 */ 896, 900, 903, 943, 964, 932, 930, 958, 984, 1015,
88788
- /* 250 */ 1030, 1025, 1112, 1114, 1098, 1133, 1102, 1144, 1119, 1157,
88789
- /* 260 */ 1183, 1195, 1188, 1198, 1200, 1201, 1202, 1155, 1156, 1203,
88790
- /* 270 */ 1204, 1206, 1207, 1205, 1233, 1231, 1234, 1235, 1237, 1238,
88791
- /* 280 */ 1239, 1159, 1160, 1242, 1243, 1213, 1214, 1186, 1208, 1249,
88792
- /* 290 */ 1217, 1218, 1219, 1220, 1215, 1224, 1210, 1258, 1174, 1175,
88793
- /* 300 */ 1262, 1263, 1176, 1260, 1245, 1246, 1178, 1179, 1181,
90544
+ /* 0 */ -141, 90, 16, 147, -55, 21, 148, 149, 158, 240,
90545
+ /* 10 */ 223, 237, 242, 303, 307, 164, 370, 171, 369, 376,
90546
+ /* 20 */ 380, 443, 450, 504, 517, 524, 535, 537, 578, 591,
90547
+ /* 30 */ 594, 599, 611, 652, 665, 668, 686, 726, 739, 742,
90548
+ /* 40 */ 746, 760, 800, 816, 834, 874, 888, 890, 908, 911,
90549
+ /* 50 */ 962, 975, 989, 993, 1030, 1089, 1096, 1102, 1119, 1125,
90550
+ /* 60 */ 1131, -196, 954, 740, 396, 169, -68, 463, 405, 459,
90551
+ /* 70 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459,
90552
+ /* 80 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459,
90553
+ /* 90 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459,
90554
+ /* 100 */ 459, 459, 459, 459, 459, 459, 459, -21, 459, 459,
90555
+ /* 110 */ 538, 375, 592, 666, 814, 6, 222, 521, 682, 817,
90556
+ /* 120 */ 356, 244, 466, 684, 691, 891, 994, 1023, 1063, 1142,
90557
+ /* 130 */ 1169, 759, 1173, 459, -89, 459, 459, 459, 459, 285,
90558
+ /* 140 */ 76, 430, 598, 610, 765, 818, 423, 485, 892, 909,
90559
+ /* 150 */ 910, 969, 1006, 818, 1011, 1016, 1067, 1076, 1132, 1177,
90560
+ /* 160 */ 1178, 1181, 1186, 1195, 1199, 1200, 1209, 1217, 1218, 1221,
90561
+ /* 170 */ 1222, 1234, 1235, 1238, 1241, 1242, 1243, 1244, 1254, 1255,
90562
+ /* 180 */ 532, 532, 549, 178, 324, 688, 446, 769, 776, 809,
90563
+ /* 190 */ 813, 655, 581, 738, -74, -58, -50, -17, -23, -23,
90564
+ /* 200 */ -23, 63, -23, 29, 68, 121, 183, 146, 225, 29,
90565
+ /* 210 */ -23, -23, 196, 177, -23, -23, -23, -23, 255, 328,
90566
+ /* 220 */ 335, 381, 404, 439, 449, 600, 648, 546, 685, 638,
90567
+ /* 230 */ 717, 663, 722, 811, 734, 756, 801, 827, 868, 872,
90568
+ /* 240 */ 899, 967, 980, 996, 997, 981, 987, 1003, 961, 976,
90569
+ /* 250 */ 979, 992, 998, 1004, 991, 1057, 1070, 1009, 1036, 1038,
90570
+ /* 260 */ 1069, 1041, 1080, 1098, 1122, 1111, 1135, 1123, 1139, 1168,
90571
+ /* 270 */ 1133, 1143, 1174, 1185, 1194, 1205, 1216, 1257, 1245, 1258,
90572
+ /* 280 */ 1253, 1259, 1260, 1261, 1183, 1184, 1266, 1267, 1227, 1236,
90573
+ /* 290 */ 1208, 1229, 1272, 1239, 1247, 1248, 1249, 1237, 1264, 1219,
90574
+ /* 300 */ 1278, 1201, 1202, 1285, 1286, 1203, 1283, 1268, 1270, 1206,
90575
+ /* 310 */ 1204, 1207,
8879490576
};
8879590577
static const YYACTIONTYPE yy_default[] = {
8879690578
/* 0 */ 634, 869, 958, 958, 869, 958, 958, 898, 898, 757,
8879790579
/* 10 */ 867, 958, 958, 958, 958, 958, 958, 932, 958, 958,
8879890580
/* 20 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
8879990581
/* 30 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
8880090582
/* 40 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
88801
- /* 50 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 841,
88802
- /* 60 */ 958, 958, 958, 673, 898, 898, 761, 792, 958, 958,
88803
- /* 70 */ 958, 958, 958, 958, 958, 958, 793, 958, 871, 866,
88804
- /* 80 */ 862, 864, 863, 870, 794, 783, 790, 797, 772, 911,
88805
- /* 90 */ 799, 800, 806, 807, 933, 931, 829, 828, 847, 831,
88806
- /* 100 */ 853, 830, 840, 665, 832, 833, 958, 958, 958, 958,
88807
- /* 110 */ 958, 726, 660, 958, 958, 958, 958, 958, 958, 958,
88808
- /* 120 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 834,
88809
- /* 130 */ 958, 835, 848, 849, 850, 958, 958, 958, 958, 958,
88810
- /* 140 */ 958, 958, 958, 958, 640, 958, 958, 958, 958, 958,
90583
+ /* 50 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
90584
+ /* 60 */ 958, 841, 958, 958, 958, 673, 898, 898, 761, 792,
90585
+ /* 70 */ 958, 958, 958, 958, 958, 958, 958, 958, 793, 958,
90586
+ /* 80 */ 871, 866, 862, 864, 863, 870, 794, 783, 790, 797,
90587
+ /* 90 */ 772, 911, 799, 800, 806, 807, 933, 931, 829, 828,
90588
+ /* 100 */ 847, 831, 845, 853, 846, 830, 840, 665, 832, 833,
90589
+ /* 110 */ 958, 958, 958, 958, 958, 726, 660, 958, 958, 958,
90590
+ /* 120 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
90591
+ /* 130 */ 958, 958, 958, 834, 958, 835, 848, 849, 850, 958,
90592
+ /* 140 */ 958, 958, 958, 958, 958, 958, 958, 958, 640, 958,
8881190593
/* 150 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
8881290594
/* 160 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
88813
- /* 170 */ 958, 882, 958, 936, 938, 958, 958, 958, 634, 757,
88814
- /* 180 */ 757, 757, 958, 958, 958, 958, 958, 751, 761, 950,
88815
- /* 190 */ 958, 958, 717, 958, 958, 958, 958, 958, 958, 958,
88816
- /* 200 */ 642, 749, 675, 759, 958, 958, 958, 662, 738, 904,
88817
- /* 210 */ 958, 923, 921, 740, 802, 958, 749, 758, 958, 958,
88818
- /* 220 */ 958, 865, 786, 786, 774, 786, 696, 786, 958, 786,
88819
- /* 230 */ 958, 699, 916, 796, 916, 774, 774, 796, 639, 639,
88820
- /* 240 */ 639, 639, 650, 650, 716, 958, 796, 787, 789, 779,
88821
- /* 250 */ 791, 958, 765, 765, 773, 778, 773, 778, 773, 778,
88822
- /* 260 */ 728, 728, 713, 728, 699, 728, 875, 879, 879, 713,
88823
- /* 270 */ 728, 728, 728, 875, 657, 765, 657, 765, 657, 765,
88824
- /* 280 */ 765, 908, 910, 657, 765, 730, 730, 808, 796, 765,
88825
- /* 290 */ 737, 737, 737, 737, 796, 730, 808, 765, 935, 935,
88826
- /* 300 */ 765, 765, 943, 683, 701, 701, 950, 955, 955, 958,
88827
- /* 310 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
88828
- /* 320 */ 958, 958, 958, 958, 958, 958, 958, 958, 884, 958,
88829
- /* 330 */ 958, 648, 958, 667, 815, 820, 816, 958, 817, 958,
88830
- /* 340 */ 743, 958, 958, 958, 958, 958, 958, 958, 958, 958,
88831
- /* 350 */ 958, 868, 958, 780, 958, 788, 958, 958, 958, 958,
90595
+ /* 170 */ 958, 958, 958, 958, 958, 882, 958, 936, 938, 958,
90596
+ /* 180 */ 958, 958, 634, 757, 757, 757, 958, 958, 958, 958,
90597
+ /* 190 */ 958, 751, 761, 950, 958, 958, 717, 958, 958, 958,
90598
+ /* 200 */ 958, 958, 958, 958, 958, 958, 642, 749, 675, 759,
90599
+ /* 210 */ 662, 738, 904, 958, 923, 921, 740, 802, 958, 749,
90600
+ /* 220 */ 758, 958, 958, 958, 865, 786, 786, 774, 786, 696,
90601
+ /* 230 */ 786, 958, 786, 958, 699, 916, 796, 916, 774, 774,
90602
+ /* 240 */ 796, 639, 639, 639, 639, 650, 650, 716, 958, 796,
90603
+ /* 250 */ 787, 789, 779, 791, 958, 765, 765, 773, 778, 773,
90604
+ /* 260 */ 778, 773, 778, 728, 728, 713, 728, 699, 728, 875,
90605
+ /* 270 */ 879, 879, 713, 728, 728, 728, 875, 657, 765, 657,
90606
+ /* 280 */ 765, 657, 765, 765, 908, 910, 657, 765, 730, 730,
90607
+ /* 290 */ 808, 796, 765, 737, 737, 737, 737, 796, 730, 808,
90608
+ /* 300 */ 765, 935, 935, 765, 765, 943, 683, 701, 701, 950,
90609
+ /* 310 */ 955, 955, 958, 958, 958, 958, 958, 958, 958, 958,
90610
+ /* 320 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
90611
+ /* 330 */ 884, 958, 958, 648, 958, 667, 815, 820, 816, 958,
90612
+ /* 340 */ 817, 743, 958, 958, 958, 958, 958, 958, 958, 958,
90613
+ /* 350 */ 958, 958, 868, 958, 780, 958, 788, 958, 958, 958,
8883290614
/* 360 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
8883390615
/* 370 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
88834
- /* 380 */ 958, 906, 907, 958, 958, 958, 958, 958, 958, 914,
88835
- /* 390 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
90616
+ /* 380 */ 958, 958, 958, 906, 907, 958, 958, 958, 958, 958,
90617
+ /* 390 */ 958, 914, 958, 958, 958, 958, 958, 958, 958, 958,
8883690618
/* 400 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
88837
- /* 410 */ 942, 958, 958, 945, 635, 958, 630, 632, 633, 637,
88838
- /* 420 */ 638, 641, 667, 668, 670, 671, 672, 643, 644, 645,
88839
- /* 430 */ 646, 647, 649, 653, 651, 652, 654, 661, 663, 682,
88840
- /* 440 */ 684, 686, 747, 748, 812, 741, 742, 746, 669, 823,
88841
- /* 450 */ 814, 818, 819, 821, 822, 836, 837, 839, 845, 852,
88842
- /* 460 */ 855, 838, 843, 844, 846, 851, 854, 744, 745, 858,
90619
+ /* 410 */ 958, 958, 942, 958, 958, 945, 635, 958, 630, 632,
90620
+ /* 420 */ 633, 637, 638, 641, 667, 668, 670, 671, 672, 643,
90621
+ /* 430 */ 644, 645, 646, 647, 649, 653, 651, 652, 654, 661,
90622
+ /* 440 */ 663, 682, 684, 686, 747, 748, 812, 741, 742, 746,
90623
+ /* 450 */ 669, 823, 814, 818, 819, 821, 822, 836, 837, 839,
90624
+ /* 460 */ 844, 852, 855, 838, 843, 851, 854, 744, 745, 858,
8884390625
/* 470 */ 676, 677, 680, 681, 894, 896, 895, 897, 679, 678,
8884490626
/* 480 */ 824, 827, 860, 861, 924, 925, 926, 927, 928, 856,
8884590627
/* 490 */ 766, 859, 842, 781, 784, 785, 782, 750, 760, 768,
8884690628
/* 500 */ 769, 770, 771, 755, 756, 762, 777, 810, 811, 775,
8884790629
/* 510 */ 776, 763, 764, 752, 753, 754, 857, 813, 825, 826,
8884890630
/* 520 */ 687, 688, 820, 689, 690, 691, 729, 732, 733, 734,
8884990631
/* 530 */ 692, 711, 714, 715, 693, 700, 694, 695, 702, 703,
88850
- /* 540 */ 704, 707, 708, 709, 710, 705, 706, 876, 877, 880,
90632
+ /* 540 */ 704, 706, 707, 708, 709, 710, 705, 876, 877, 880,
8885190633
/* 550 */ 878, 697, 698, 712, 685, 674, 666, 718, 721, 722,
8885290634
/* 560 */ 723, 724, 725, 727, 719, 720, 664, 655, 658, 767,
8885390635
/* 570 */ 900, 909, 905, 901, 902, 903, 659, 872, 873, 731,
8885490636
/* 580 */ 804, 805, 899, 912, 915, 917, 918, 919, 809, 920,
8885590637
/* 590 */ 922, 913, 947, 656, 735, 736, 739, 881, 929, 795,
@@ -88898,10 +90680,11 @@
8889890680
0, /* AS => nothing */
8889990681
0, /* COMMA => nothing */
8890090682
0, /* ID => nothing */
8890190683
0, /* INDEXED => nothing */
8890290684
26, /* ABORT => ID */
90685
+ 26, /* ACTION => ID */
8890390686
26, /* AFTER => ID */
8890490687
26, /* ANALYZE => ID */
8890590688
26, /* ASC => ID */
8890690689
26, /* ATTACH => ID */
8890790690
26, /* BEFORE => ID */
@@ -88919,10 +90702,11 @@
8891990702
26, /* IGNORE => ID */
8892090703
26, /* INITIALLY => ID */
8892190704
26, /* INSTEAD => ID */
8892290705
26, /* LIKE_KW => ID */
8892390706
26, /* MATCH => ID */
90707
+ 26, /* NO => ID */
8892490708
26, /* KEY => ID */
8892590709
26, /* OF => ID */
8892690710
26, /* OFFSET => ID */
8892790711
26, /* PRAGMA => ID */
8892890712
26, /* RAISE => ID */
@@ -89018,36 +90802,36 @@
8901890802
"IMMEDIATE", "EXCLUSIVE", "COMMIT", "END",
8901990803
"ROLLBACK", "SAVEPOINT", "RELEASE", "TO",
8902090804
"TABLE", "CREATE", "IF", "NOT",
8902190805
"EXISTS", "TEMP", "LP", "RP",
8902290806
"AS", "COMMA", "ID", "INDEXED",
89023
- "ABORT", "AFTER", "ANALYZE", "ASC",
89024
- "ATTACH", "BEFORE", "BY", "CASCADE",
89025
- "CAST", "COLUMNKW", "CONFLICT", "DATABASE",
89026
- "DESC", "DETACH", "EACH", "FAIL",
89027
- "FOR", "IGNORE", "INITIALLY", "INSTEAD",
89028
- "LIKE_KW", "MATCH", "KEY", "OF",
89029
- "OFFSET", "PRAGMA", "RAISE", "REPLACE",
89030
- "RESTRICT", "ROW", "TRIGGER", "VACUUM",
89031
- "VIEW", "VIRTUAL", "REINDEX", "RENAME",
89032
- "CTIME_KW", "ANY", "OR", "AND",
89033
- "IS", "BETWEEN", "IN", "ISNULL",
89034
- "NOTNULL", "NE", "EQ", "GT",
89035
- "LE", "LT", "GE", "ESCAPE",
89036
- "BITAND", "BITOR", "LSHIFT", "RSHIFT",
89037
- "PLUS", "MINUS", "STAR", "SLASH",
89038
- "REM", "CONCAT", "COLLATE", "UMINUS",
89039
- "UPLUS", "BITNOT", "STRING", "JOIN_KW",
90807
+ "ABORT", "ACTION", "AFTER", "ANALYZE",
90808
+ "ASC", "ATTACH", "BEFORE", "BY",
90809
+ "CASCADE", "CAST", "COLUMNKW", "CONFLICT",
90810
+ "DATABASE", "DESC", "DETACH", "EACH",
90811
+ "FAIL", "FOR", "IGNORE", "INITIALLY",
90812
+ "INSTEAD", "LIKE_KW", "MATCH", "NO",
90813
+ "KEY", "OF", "OFFSET", "PRAGMA",
90814
+ "RAISE", "REPLACE", "RESTRICT", "ROW",
90815
+ "TRIGGER", "VACUUM", "VIEW", "VIRTUAL",
90816
+ "REINDEX", "RENAME", "CTIME_KW", "ANY",
90817
+ "OR", "AND", "IS", "BETWEEN",
90818
+ "IN", "ISNULL", "NOTNULL", "NE",
90819
+ "EQ", "GT", "LE", "LT",
90820
+ "GE", "ESCAPE", "BITAND", "BITOR",
90821
+ "LSHIFT", "RSHIFT", "PLUS", "MINUS",
90822
+ "STAR", "SLASH", "REM", "CONCAT",
90823
+ "COLLATE", "BITNOT", "STRING", "JOIN_KW",
8904090824
"CONSTRAINT", "DEFAULT", "NULL", "PRIMARY",
8904190825
"UNIQUE", "CHECK", "REFERENCES", "AUTOINCR",
89042
- "ON", "DELETE", "UPDATE", "INSERT",
89043
- "SET", "DEFERRABLE", "FOREIGN", "DROP",
89044
- "UNION", "ALL", "EXCEPT", "INTERSECT",
89045
- "SELECT", "DISTINCT", "DOT", "FROM",
89046
- "JOIN", "USING", "ORDER", "GROUP",
89047
- "HAVING", "LIMIT", "WHERE", "INTO",
89048
- "VALUES", "INTEGER", "FLOAT", "BLOB",
90826
+ "ON", "DELETE", "UPDATE", "SET",
90827
+ "DEFERRABLE", "FOREIGN", "DROP", "UNION",
90828
+ "ALL", "EXCEPT", "INTERSECT", "SELECT",
90829
+ "DISTINCT", "DOT", "FROM", "JOIN",
90830
+ "USING", "ORDER", "GROUP", "HAVING",
90831
+ "LIMIT", "WHERE", "INTO", "VALUES",
90832
+ "INSERT", "INTEGER", "FLOAT", "BLOB",
8904990833
"REGISTER", "VARIABLE", "CASE", "WHEN",
8905090834
"THEN", "ELSE", "INDEX", "ALTER",
8905190835
"ADD", "error", "input", "cmdlist",
8905290836
"ecmd", "explain", "cmdx", "cmd",
8905390837
"transtype", "trans_opt", "nm", "savepoint_opt",
@@ -89159,15 +90943,15 @@
8915990943
/* 72 */ "refargs ::=",
8916090944
/* 73 */ "refargs ::= refargs refarg",
8916190945
/* 74 */ "refarg ::= MATCH nm",
8916290946
/* 75 */ "refarg ::= ON DELETE refact",
8916390947
/* 76 */ "refarg ::= ON UPDATE refact",
89164
- /* 77 */ "refarg ::= ON INSERT refact",
89165
- /* 78 */ "refact ::= SET NULL",
89166
- /* 79 */ "refact ::= SET DEFAULT",
89167
- /* 80 */ "refact ::= CASCADE",
89168
- /* 81 */ "refact ::= RESTRICT",
90948
+ /* 77 */ "refact ::= SET NULL",
90949
+ /* 78 */ "refact ::= SET DEFAULT",
90950
+ /* 79 */ "refact ::= CASCADE",
90951
+ /* 80 */ "refact ::= RESTRICT",
90952
+ /* 81 */ "refact ::= NO ACTION",
8916990953
/* 82 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
8917090954
/* 83 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
8917190955
/* 84 */ "init_deferred_pred_opt ::=",
8917290956
/* 85 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
8917390957
/* 86 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
@@ -89297,13 +91081,13 @@
8929791081
/* 210 */ "likeop ::= NOT MATCH",
8929891082
/* 211 */ "escape ::= ESCAPE expr",
8929991083
/* 212 */ "escape ::=",
8930091084
/* 213 */ "expr ::= expr likeop expr escape",
8930191085
/* 214 */ "expr ::= expr ISNULL|NOTNULL",
89302
- /* 215 */ "expr ::= expr IS NULL",
89303
- /* 216 */ "expr ::= expr NOT NULL",
89304
- /* 217 */ "expr ::= expr IS NOT NULL",
91086
+ /* 215 */ "expr ::= expr NOT NULL",
91087
+ /* 216 */ "expr ::= expr IS expr",
91088
+ /* 217 */ "expr ::= expr IS NOT expr",
8930591089
/* 218 */ "expr ::= NOT expr",
8930691090
/* 219 */ "expr ::= BITNOT expr",
8930791091
/* 220 */ "expr ::= MINUS expr",
8930891092
/* 221 */ "expr ::= PLUS expr",
8930991093
/* 222 */ "between_op ::= BETWEEN",
@@ -89869,15 +91653,15 @@
8986991653
{ 180, 0 },
8987091654
{ 180, 2 },
8987191655
{ 182, 2 },
8987291656
{ 182, 3 },
8987391657
{ 182, 3 },
89874
- { 182, 3 },
8987591658
{ 183, 2 },
8987691659
{ 183, 2 },
8987791660
{ 183, 1 },
8987891661
{ 183, 1 },
91662
+ { 183, 2 },
8987991663
{ 181, 3 },
8988091664
{ 181, 2 },
8988191665
{ 184, 0 },
8988291666
{ 184, 2 },
8988391667
{ 184, 2 },
@@ -90236,10 +92020,11 @@
9023692020
}
9023792021
break;
9023892022
case 28: /* ifnotexists ::= */
9023992023
case 31: /* temp ::= */ yytestcase(yyruleno==31);
9024092024
case 70: /* autoinc ::= */ yytestcase(yyruleno==70);
92025
+ case 82: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==82);
9024192026
case 84: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==84);
9024292027
case 86: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==86);
9024392028
case 97: /* defer_subclause_opt ::= */ yytestcase(yyruleno==97);
9024492029
case 108: /* ifexists ::= */ yytestcase(yyruleno==108);
9024592030
case 119: /* distinct ::= ALL */ yytestcase(yyruleno==119);
@@ -90366,11 +92151,11 @@
9036692151
break;
9036792152
case 69: /* ccons ::= COLLATE ids */
9036892153
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
9036992154
break;
9037092155
case 72: /* refargs ::= */
90371
-{ yygotominor.yy328 = OE_Restrict * 0x010101; }
92156
+{ yygotominor.yy328 = OE_None * 0x000101; }
9037292157
break;
9037392158
case 73: /* refargs ::= refargs refarg */
9037492159
{ yygotominor.yy328 = (yymsp[-1].minor.yy328 & ~yymsp[0].minor.yy429.mask) | yymsp[0].minor.yy429.value; }
9037592160
break;
9037692161
case 74: /* refarg ::= MATCH nm */
@@ -90380,27 +92165,26 @@
9038092165
{ yygotominor.yy429.value = yymsp[0].minor.yy328; yygotominor.yy429.mask = 0x0000ff; }
9038192166
break;
9038292167
case 76: /* refarg ::= ON UPDATE refact */
9038392168
{ yygotominor.yy429.value = yymsp[0].minor.yy328<<8; yygotominor.yy429.mask = 0x00ff00; }
9038492169
break;
90385
- case 77: /* refarg ::= ON INSERT refact */
90386
-{ yygotominor.yy429.value = yymsp[0].minor.yy328<<16; yygotominor.yy429.mask = 0xff0000; }
90387
- break;
90388
- case 78: /* refact ::= SET NULL */
92170
+ case 77: /* refact ::= SET NULL */
9038992171
{ yygotominor.yy328 = OE_SetNull; }
9039092172
break;
90391
- case 79: /* refact ::= SET DEFAULT */
92173
+ case 78: /* refact ::= SET DEFAULT */
9039292174
{ yygotominor.yy328 = OE_SetDflt; }
9039392175
break;
90394
- case 80: /* refact ::= CASCADE */
92176
+ case 79: /* refact ::= CASCADE */
9039592177
{ yygotominor.yy328 = OE_Cascade; }
9039692178
break;
90397
- case 81: /* refact ::= RESTRICT */
92179
+ case 80: /* refact ::= RESTRICT */
9039892180
{ yygotominor.yy328 = OE_Restrict; }
9039992181
break;
90400
- case 82: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
90401
- case 83: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==83);
92182
+ case 81: /* refact ::= NO ACTION */
92183
+{ yygotominor.yy328 = OE_None; }
92184
+ break;
92185
+ case 83: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
9040292186
case 98: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==98);
9040392187
case 100: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==100);
9040492188
case 103: /* resolvetype ::= raisetype */ yytestcase(yyruleno==103);
9040592189
{yygotominor.yy328 = yymsp[0].minor.yy328;}
9040692190
break;
@@ -90830,18 +92614,28 @@
9083092614
}
9083192615
break;
9083292616
case 214: /* expr ::= expr ISNULL|NOTNULL */
9083392617
{spanUnaryPostfix(&yygotominor.yy346,pParse,yymsp[0].major,&yymsp[-1].minor.yy346,&yymsp[0].minor.yy0);}
9083492618
break;
90835
- case 215: /* expr ::= expr IS NULL */
90836
-{spanUnaryPostfix(&yygotominor.yy346,pParse,TK_ISNULL,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy0);}
90837
- break;
90838
- case 216: /* expr ::= expr NOT NULL */
92619
+ case 215: /* expr ::= expr NOT NULL */
9083992620
{spanUnaryPostfix(&yygotominor.yy346,pParse,TK_NOTNULL,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy0);}
9084092621
break;
90841
- case 217: /* expr ::= expr IS NOT NULL */
90842
-{spanUnaryPostfix(&yygotominor.yy346,pParse,TK_NOTNULL,&yymsp[-3].minor.yy346,&yymsp[0].minor.yy0);}
92622
+ case 216: /* expr ::= expr IS expr */
92623
+{
92624
+ spanBinaryExpr(&yygotominor.yy346,pParse,TK_IS,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy346);
92625
+ if( pParse->db->mallocFailed==0 && yymsp[0].minor.yy346.pExpr->op==TK_NULL ){
92626
+ yygotominor.yy346.pExpr->op = TK_ISNULL;
92627
+ }
92628
+}
92629
+ break;
92630
+ case 217: /* expr ::= expr IS NOT expr */
92631
+{
92632
+ spanBinaryExpr(&yygotominor.yy346,pParse,TK_ISNOT,&yymsp[-3].minor.yy346,&yymsp[0].minor.yy346);
92633
+ if( pParse->db->mallocFailed==0 && yymsp[0].minor.yy346.pExpr->op==TK_NULL ){
92634
+ yygotominor.yy346.pExpr->op = TK_NOTNULL;
92635
+ }
92636
+}
9084392637
break;
9084492638
case 218: /* expr ::= NOT expr */
9084592639
case 219: /* expr ::= BITNOT expr */ yytestcase(yyruleno==219);
9084692640
{spanUnaryPrefix(&yygotominor.yy346,pParse,yymsp[-1].major,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
9084792641
break;
@@ -91583,13 +93377,13 @@
9158393377
** might be implemented more directly using a hand-written hash table.
9158493378
** But by using this automatically generated code, the size of the code
9158593379
** is substantially reduced. This is important for embedded applications
9158693380
** on platforms with limited memory.
9158793381
*/
91588
-/* Hash score: 171 */
93382
+/* Hash score: 175 */
9158993383
static int keywordCode(const char *z, int n){
91590
- /* zText[] encodes 801 bytes of keywords in 541 bytes */
93384
+ /* zText[] encodes 811 bytes of keywords in 541 bytes */
9159193385
/* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
9159293386
/* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */
9159393387
/* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */
9159493388
/* UNIQUERYATTACHAVINGROUPDATEBEGINNERELEASEBETWEENOTNULLIKE */
9159593389
/* CASCADELETECASECOLLATECREATECURRENT_DATEDETACHIMMEDIATEJOIN */
@@ -91629,82 +93423,83 @@
9162993423
'T','R','I','C','T','O','U','T','E','R','I','G','H','T','R','O','L','L',
9163093424
'B','A','C','K','R','O','W','U','N','I','O','N','U','S','I','N','G','V',
9163193425
'A','C','U','U','M','V','I','E','W','I','N','I','T','I','A','L','L','Y',
9163293426
};
9163393427
static const unsigned char aHash[127] = {
91634
- 70, 99, 112, 68, 0, 43, 0, 0, 76, 0, 71, 0, 0,
91635
- 41, 12, 72, 15, 0, 111, 79, 49, 106, 0, 19, 0, 0,
91636
- 116, 0, 114, 109, 0, 22, 87, 0, 9, 0, 0, 64, 65,
91637
- 0, 63, 6, 0, 47, 84, 96, 0, 113, 95, 0, 0, 44,
91638
- 0, 97, 24, 0, 17, 0, 117, 48, 23, 0, 5, 104, 25,
91639
- 90, 0, 0, 119, 100, 55, 118, 52, 7, 50, 0, 85, 0,
91640
- 94, 26, 0, 93, 0, 0, 0, 89, 86, 91, 82, 103, 14,
91641
- 38, 102, 0, 75, 0, 18, 83, 105, 31, 0, 115, 74, 107,
91642
- 57, 45, 78, 0, 0, 88, 39, 0, 110, 0, 35, 0, 0,
91643
- 28, 0, 80, 53, 58, 0, 20, 56, 0, 51,
93428
+ 72, 101, 114, 70, 0, 44, 0, 0, 78, 0, 73, 0, 0,
93429
+ 42, 12, 74, 15, 0, 113, 81, 50, 108, 0, 19, 0, 0,
93430
+ 118, 0, 116, 111, 0, 22, 89, 0, 9, 0, 0, 66, 67,
93431
+ 0, 65, 6, 0, 48, 86, 98, 0, 115, 97, 0, 0, 45,
93432
+ 0, 99, 24, 0, 17, 0, 119, 49, 23, 0, 5, 106, 25,
93433
+ 92, 0, 0, 121, 102, 56, 120, 53, 28, 51, 0, 87, 0,
93434
+ 96, 26, 0, 95, 0, 0, 0, 91, 88, 93, 84, 105, 14,
93435
+ 39, 104, 0, 77, 0, 18, 85, 107, 32, 0, 117, 76, 109,
93436
+ 59, 46, 80, 0, 0, 90, 40, 0, 112, 0, 36, 0, 0,
93437
+ 29, 0, 82, 58, 60, 0, 20, 57, 0, 52,
9164493438
};
91645
- static const unsigned char aNext[119] = {
93439
+ static const unsigned char aNext[121] = {
9164693440
0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
9164793441
0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
91648
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
91649
- 0, 0, 0, 0, 32, 21, 0, 0, 0, 42, 3, 46, 0,
91650
- 0, 0, 0, 29, 0, 0, 37, 0, 0, 0, 1, 60, 0,
91651
- 0, 61, 0, 40, 0, 0, 0, 0, 0, 0, 0, 59, 0,
91652
- 0, 0, 0, 30, 54, 16, 33, 10, 0, 0, 0, 0, 0,
91653
- 0, 0, 11, 66, 73, 0, 8, 0, 98, 92, 0, 101, 0,
91654
- 81, 0, 69, 0, 0, 108, 27, 36, 67, 77, 0, 34, 62,
91655
- 0, 0,
93442
+ 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
93443
+ 0, 0, 0, 0, 0, 33, 21, 0, 0, 0, 43, 3, 47,
93444
+ 0, 0, 0, 0, 30, 54, 0, 0, 38, 0, 0, 0, 1,
93445
+ 62, 0, 0, 63, 0, 41, 0, 0, 0, 0, 0, 0, 0,
93446
+ 61, 0, 0, 0, 0, 31, 55, 16, 34, 10, 0, 0, 0,
93447
+ 0, 0, 0, 0, 11, 68, 75, 0, 8, 0, 100, 94, 0,
93448
+ 103, 0, 83, 0, 71, 0, 0, 110, 27, 37, 69, 79, 0,
93449
+ 35, 64, 0, 0,
9165693450
};
91657
- static const unsigned char aLen[119] = {
93451
+ static const unsigned char aLen[121] = {
9165893452
7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
9165993453
7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6,
91660
- 11, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10, 4,
91661
- 6, 2, 3, 4, 9, 2, 6, 5, 6, 6, 5, 6, 5,
91662
- 5, 7, 7, 7, 3, 4, 4, 7, 3, 6, 4, 7, 6,
91663
- 12, 6, 9, 4, 6, 5, 4, 7, 6, 5, 6, 7, 5,
91664
- 4, 5, 6, 5, 7, 3, 7, 13, 2, 2, 4, 6, 6,
91665
- 8, 5, 17, 12, 7, 8, 8, 2, 4, 4, 4, 4, 4,
91666
- 2, 2, 6, 5, 8, 5, 5, 8, 3, 5, 5, 6, 4,
91667
- 9, 3,
93454
+ 11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10,
93455
+ 4, 6, 2, 3, 4, 9, 2, 6, 5, 6, 6, 5, 6,
93456
+ 5, 5, 7, 7, 7, 2, 3, 4, 4, 7, 3, 6, 4,
93457
+ 7, 6, 12, 6, 9, 4, 6, 5, 4, 7, 6, 5, 6,
93458
+ 7, 5, 4, 5, 6, 5, 7, 3, 7, 13, 2, 2, 4,
93459
+ 6, 6, 8, 5, 17, 12, 7, 8, 8, 2, 4, 4, 4,
93460
+ 4, 4, 2, 2, 6, 5, 8, 5, 5, 8, 3, 5, 5,
93461
+ 6, 4, 9, 3,
9166893462
};
91669
- static const unsigned short int aOffset[119] = {
93463
+ static const unsigned short int aOffset[121] = {
9167093464
0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
9167193465
36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
91672
- 86, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152, 159,
91673
- 162, 162, 165, 167, 167, 171, 176, 179, 184, 189, 194, 197, 203,
91674
- 206, 210, 217, 223, 223, 226, 229, 233, 234, 238, 244, 248, 255,
91675
- 261, 273, 279, 288, 290, 296, 301, 303, 310, 315, 320, 326, 332,
91676
- 337, 341, 344, 350, 354, 361, 363, 370, 372, 374, 383, 387, 393,
91677
- 399, 407, 412, 412, 428, 435, 442, 443, 450, 454, 458, 462, 466,
91678
- 469, 471, 473, 479, 483, 491, 495, 500, 508, 511, 516, 521, 527,
91679
- 531, 536,
93466
+ 86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152,
93467
+ 159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 189, 194, 197,
93468
+ 203, 206, 210, 217, 223, 223, 223, 226, 229, 233, 234, 238, 244,
93469
+ 248, 255, 261, 273, 279, 288, 290, 296, 301, 303, 310, 315, 320,
93470
+ 326, 332, 337, 341, 344, 350, 354, 361, 363, 370, 372, 374, 383,
93471
+ 387, 393, 399, 407, 412, 412, 428, 435, 442, 443, 450, 454, 458,
93472
+ 462, 466, 469, 471, 473, 479, 483, 491, 495, 500, 508, 511, 516,
93473
+ 521, 527, 531, 536,
9168093474
};
91681
- static const unsigned char aCode[119] = {
93475
+ static const unsigned char aCode[121] = {
9168293476
TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
9168393477
TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
9168493478
TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
9168593479
TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
9168693480
TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
91687
- TK_EXCEPT, TK_TRANSACTION,TK_ON, TK_JOIN_KW, TK_ALTER,
91688
- TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT, TK_INTERSECT,
91689
- TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO, TK_OFFSET,
91690
- TK_OF, TK_SET, TK_TEMP, TK_TEMP, TK_OR,
91691
- TK_UNIQUE, TK_QUERY, TK_ATTACH, TK_HAVING, TK_GROUP,
91692
- TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RELEASE, TK_BETWEEN,
91693
- TK_NOTNULL, TK_NOT, TK_NULL, TK_LIKE_KW, TK_CASCADE,
91694
- TK_ASC, TK_DELETE, TK_CASE, TK_COLLATE, TK_CREATE,
91695
- TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, TK_JOIN, TK_INSERT,
91696
- TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT,
91697
- TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN, TK_WHERE,
91698
- TK_RENAME, TK_AFTER, TK_REPLACE, TK_AND, TK_DEFAULT,
91699
- TK_AUTOINCR, TK_TO, TK_IN, TK_CAST, TK_COLUMNKW,
91700
- TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW,
91701
- TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DROP,
91702
- TK_FAIL, TK_FROM, TK_JOIN_KW, TK_LIKE_KW, TK_BY,
91703
- TK_IF, TK_ISNULL, TK_ORDER, TK_RESTRICT, TK_JOIN_KW,
91704
- TK_JOIN_KW, TK_ROLLBACK, TK_ROW, TK_UNION, TK_USING,
91705
- TK_VACUUM, TK_VIEW, TK_INITIALLY, TK_ALL,
93481
+ TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW,
93482
+ TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT,
93483
+ TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO,
93484
+ TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP,
93485
+ TK_OR, TK_UNIQUE, TK_QUERY, TK_ATTACH, TK_HAVING,
93486
+ TK_GROUP, TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RELEASE,
93487
+ TK_BETWEEN, TK_NOTNULL, TK_NO, TK_NOT, TK_NULL,
93488
+ TK_LIKE_KW, TK_CASCADE, TK_ASC, TK_DELETE, TK_CASE,
93489
+ TK_COLLATE, TK_CREATE, TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE,
93490
+ TK_JOIN, TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE,
93491
+ TK_PRAGMA, TK_ABORT, TK_VALUES, TK_VIRTUAL, TK_LIMIT,
93492
+ TK_WHEN, TK_WHERE, TK_RENAME, TK_AFTER, TK_REPLACE,
93493
+ TK_AND, TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN,
93494
+ TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW,
93495
+ TK_CTIME_KW, TK_CTIME_KW, TK_PRIMARY, TK_DEFERRED, TK_DISTINCT,
93496
+ TK_IS, TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW,
93497
+ TK_LIKE_KW, TK_BY, TK_IF, TK_ISNULL, TK_ORDER,
93498
+ TK_RESTRICT, TK_JOIN_KW, TK_JOIN_KW, TK_ROLLBACK, TK_ROW,
93499
+ TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_INITIALLY,
93500
+ TK_ALL,
9170693501
};
9170793502
int h, i;
9170893503
if( n<2 ) return TK_ID;
9170993504
h = ((charMap(z[0])*4) ^
9171093505
(charMap(z[n-1])*3) ^
@@ -91736,102 +93531,104 @@
9173693531
testcase( i==22 ); /* END */
9173793532
testcase( i==23 ); /* DEFERRABLE */
9173893533
testcase( i==24 ); /* ELSE */
9173993534
testcase( i==25 ); /* EXCEPT */
9174093535
testcase( i==26 ); /* TRANSACTION */
91741
- testcase( i==27 ); /* ON */
91742
- testcase( i==28 ); /* NATURAL */
91743
- testcase( i==29 ); /* ALTER */
91744
- testcase( i==30 ); /* RAISE */
91745
- testcase( i==31 ); /* EXCLUSIVE */
91746
- testcase( i==32 ); /* EXISTS */
91747
- testcase( i==33 ); /* SAVEPOINT */
91748
- testcase( i==34 ); /* INTERSECT */
91749
- testcase( i==35 ); /* TRIGGER */
91750
- testcase( i==36 ); /* REFERENCES */
91751
- testcase( i==37 ); /* CONSTRAINT */
91752
- testcase( i==38 ); /* INTO */
91753
- testcase( i==39 ); /* OFFSET */
91754
- testcase( i==40 ); /* OF */
91755
- testcase( i==41 ); /* SET */
91756
- testcase( i==42 ); /* TEMP */
91757
- testcase( i==43 ); /* TEMPORARY */
91758
- testcase( i==44 ); /* OR */
91759
- testcase( i==45 ); /* UNIQUE */
91760
- testcase( i==46 ); /* QUERY */
91761
- testcase( i==47 ); /* ATTACH */
91762
- testcase( i==48 ); /* HAVING */
91763
- testcase( i==49 ); /* GROUP */
91764
- testcase( i==50 ); /* UPDATE */
91765
- testcase( i==51 ); /* BEGIN */
91766
- testcase( i==52 ); /* INNER */
91767
- testcase( i==53 ); /* RELEASE */
91768
- testcase( i==54 ); /* BETWEEN */
91769
- testcase( i==55 ); /* NOTNULL */
91770
- testcase( i==56 ); /* NOT */
91771
- testcase( i==57 ); /* NULL */
91772
- testcase( i==58 ); /* LIKE */
91773
- testcase( i==59 ); /* CASCADE */
91774
- testcase( i==60 ); /* ASC */
91775
- testcase( i==61 ); /* DELETE */
91776
- testcase( i==62 ); /* CASE */
91777
- testcase( i==63 ); /* COLLATE */
91778
- testcase( i==64 ); /* CREATE */
91779
- testcase( i==65 ); /* CURRENT_DATE */
91780
- testcase( i==66 ); /* DETACH */
91781
- testcase( i==67 ); /* IMMEDIATE */
91782
- testcase( i==68 ); /* JOIN */
91783
- testcase( i==69 ); /* INSERT */
91784
- testcase( i==70 ); /* MATCH */
91785
- testcase( i==71 ); /* PLAN */
91786
- testcase( i==72 ); /* ANALYZE */
91787
- testcase( i==73 ); /* PRAGMA */
91788
- testcase( i==74 ); /* ABORT */
91789
- testcase( i==75 ); /* VALUES */
91790
- testcase( i==76 ); /* VIRTUAL */
91791
- testcase( i==77 ); /* LIMIT */
91792
- testcase( i==78 ); /* WHEN */
91793
- testcase( i==79 ); /* WHERE */
91794
- testcase( i==80 ); /* RENAME */
91795
- testcase( i==81 ); /* AFTER */
91796
- testcase( i==82 ); /* REPLACE */
91797
- testcase( i==83 ); /* AND */
91798
- testcase( i==84 ); /* DEFAULT */
91799
- testcase( i==85 ); /* AUTOINCREMENT */
91800
- testcase( i==86 ); /* TO */
91801
- testcase( i==87 ); /* IN */
91802
- testcase( i==88 ); /* CAST */
91803
- testcase( i==89 ); /* COLUMN */
91804
- testcase( i==90 ); /* COMMIT */
91805
- testcase( i==91 ); /* CONFLICT */
91806
- testcase( i==92 ); /* CROSS */
91807
- testcase( i==93 ); /* CURRENT_TIMESTAMP */
91808
- testcase( i==94 ); /* CURRENT_TIME */
91809
- testcase( i==95 ); /* PRIMARY */
91810
- testcase( i==96 ); /* DEFERRED */
91811
- testcase( i==97 ); /* DISTINCT */
91812
- testcase( i==98 ); /* IS */
91813
- testcase( i==99 ); /* DROP */
91814
- testcase( i==100 ); /* FAIL */
91815
- testcase( i==101 ); /* FROM */
91816
- testcase( i==102 ); /* FULL */
91817
- testcase( i==103 ); /* GLOB */
91818
- testcase( i==104 ); /* BY */
91819
- testcase( i==105 ); /* IF */
91820
- testcase( i==106 ); /* ISNULL */
91821
- testcase( i==107 ); /* ORDER */
91822
- testcase( i==108 ); /* RESTRICT */
91823
- testcase( i==109 ); /* OUTER */
91824
- testcase( i==110 ); /* RIGHT */
91825
- testcase( i==111 ); /* ROLLBACK */
91826
- testcase( i==112 ); /* ROW */
91827
- testcase( i==113 ); /* UNION */
91828
- testcase( i==114 ); /* USING */
91829
- testcase( i==115 ); /* VACUUM */
91830
- testcase( i==116 ); /* VIEW */
91831
- testcase( i==117 ); /* INITIALLY */
91832
- testcase( i==118 ); /* ALL */
93536
+ testcase( i==27 ); /* ACTION */
93537
+ testcase( i==28 ); /* ON */
93538
+ testcase( i==29 ); /* NATURAL */
93539
+ testcase( i==30 ); /* ALTER */
93540
+ testcase( i==31 ); /* RAISE */
93541
+ testcase( i==32 ); /* EXCLUSIVE */
93542
+ testcase( i==33 ); /* EXISTS */
93543
+ testcase( i==34 ); /* SAVEPOINT */
93544
+ testcase( i==35 ); /* INTERSECT */
93545
+ testcase( i==36 ); /* TRIGGER */
93546
+ testcase( i==37 ); /* REFERENCES */
93547
+ testcase( i==38 ); /* CONSTRAINT */
93548
+ testcase( i==39 ); /* INTO */
93549
+ testcase( i==40 ); /* OFFSET */
93550
+ testcase( i==41 ); /* OF */
93551
+ testcase( i==42 ); /* SET */
93552
+ testcase( i==43 ); /* TEMP */
93553
+ testcase( i==44 ); /* TEMPORARY */
93554
+ testcase( i==45 ); /* OR */
93555
+ testcase( i==46 ); /* UNIQUE */
93556
+ testcase( i==47 ); /* QUERY */
93557
+ testcase( i==48 ); /* ATTACH */
93558
+ testcase( i==49 ); /* HAVING */
93559
+ testcase( i==50 ); /* GROUP */
93560
+ testcase( i==51 ); /* UPDATE */
93561
+ testcase( i==52 ); /* BEGIN */
93562
+ testcase( i==53 ); /* INNER */
93563
+ testcase( i==54 ); /* RELEASE */
93564
+ testcase( i==55 ); /* BETWEEN */
93565
+ testcase( i==56 ); /* NOTNULL */
93566
+ testcase( i==57 ); /* NO */
93567
+ testcase( i==58 ); /* NOT */
93568
+ testcase( i==59 ); /* NULL */
93569
+ testcase( i==60 ); /* LIKE */
93570
+ testcase( i==61 ); /* CASCADE */
93571
+ testcase( i==62 ); /* ASC */
93572
+ testcase( i==63 ); /* DELETE */
93573
+ testcase( i==64 ); /* CASE */
93574
+ testcase( i==65 ); /* COLLATE */
93575
+ testcase( i==66 ); /* CREATE */
93576
+ testcase( i==67 ); /* CURRENT_DATE */
93577
+ testcase( i==68 ); /* DETACH */
93578
+ testcase( i==69 ); /* IMMEDIATE */
93579
+ testcase( i==70 ); /* JOIN */
93580
+ testcase( i==71 ); /* INSERT */
93581
+ testcase( i==72 ); /* MATCH */
93582
+ testcase( i==73 ); /* PLAN */
93583
+ testcase( i==74 ); /* ANALYZE */
93584
+ testcase( i==75 ); /* PRAGMA */
93585
+ testcase( i==76 ); /* ABORT */
93586
+ testcase( i==77 ); /* VALUES */
93587
+ testcase( i==78 ); /* VIRTUAL */
93588
+ testcase( i==79 ); /* LIMIT */
93589
+ testcase( i==80 ); /* WHEN */
93590
+ testcase( i==81 ); /* WHERE */
93591
+ testcase( i==82 ); /* RENAME */
93592
+ testcase( i==83 ); /* AFTER */
93593
+ testcase( i==84 ); /* REPLACE */
93594
+ testcase( i==85 ); /* AND */
93595
+ testcase( i==86 ); /* DEFAULT */
93596
+ testcase( i==87 ); /* AUTOINCREMENT */
93597
+ testcase( i==88 ); /* TO */
93598
+ testcase( i==89 ); /* IN */
93599
+ testcase( i==90 ); /* CAST */
93600
+ testcase( i==91 ); /* COLUMN */
93601
+ testcase( i==92 ); /* COMMIT */
93602
+ testcase( i==93 ); /* CONFLICT */
93603
+ testcase( i==94 ); /* CROSS */
93604
+ testcase( i==95 ); /* CURRENT_TIMESTAMP */
93605
+ testcase( i==96 ); /* CURRENT_TIME */
93606
+ testcase( i==97 ); /* PRIMARY */
93607
+ testcase( i==98 ); /* DEFERRED */
93608
+ testcase( i==99 ); /* DISTINCT */
93609
+ testcase( i==100 ); /* IS */
93610
+ testcase( i==101 ); /* DROP */
93611
+ testcase( i==102 ); /* FAIL */
93612
+ testcase( i==103 ); /* FROM */
93613
+ testcase( i==104 ); /* FULL */
93614
+ testcase( i==105 ); /* GLOB */
93615
+ testcase( i==106 ); /* BY */
93616
+ testcase( i==107 ); /* IF */
93617
+ testcase( i==108 ); /* ISNULL */
93618
+ testcase( i==109 ); /* ORDER */
93619
+ testcase( i==110 ); /* RESTRICT */
93620
+ testcase( i==111 ); /* OUTER */
93621
+ testcase( i==112 ); /* RIGHT */
93622
+ testcase( i==113 ); /* ROLLBACK */
93623
+ testcase( i==114 ); /* ROW */
93624
+ testcase( i==115 ); /* UNION */
93625
+ testcase( i==116 ); /* USING */
93626
+ testcase( i==117 ); /* VACUUM */
93627
+ testcase( i==118 ); /* VIEW */
93628
+ testcase( i==119 ); /* INITIALLY */
93629
+ testcase( i==120 ); /* ALL */
9183393630
return aCode[i];
9183493631
}
9183593632
}
9183693633
return TK_ID;
9183793634
}
@@ -93408,10 +95205,13 @@
9340895205
9340995206
if( db->flags&SQLITE_InternChanges ){
9341095207
sqlite3ExpirePreparedStatements(db);
9341195208
sqlite3ResetInternalSchema(db, 0);
9341295209
}
95210
+
95211
+ /* Any deferred constraint violations have now been resolved. */
95212
+ db->nDeferredCons = 0;
9341395213
9341495214
/* If one has been configured, invoke the rollback-hook callback */
9341595215
if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){
9341695216
db->xRollbackCallback(db->pRollbackArg);
9341795217
}
@@ -106670,22 +108470,22 @@
106670108470
** here is the LinearPickSeeds algorithm from Gutman[1984]. The
106671108471
** indices of the two seed cells in the array are stored in local
106672108472
** variables iLeftSeek and iRightSeed.
106673108473
*/
106674108474
for(i=0; i<pRtree->nDim; i++){
106675
- float x1 = aCell[0].aCoord[i*2];
106676
- float x2 = aCell[0].aCoord[i*2+1];
108475
+ float x1 = DCOORD(aCell[0].aCoord[i*2]);
108476
+ float x2 = DCOORD(aCell[0].aCoord[i*2+1]);
106677108477
float x3 = x1;
106678108478
float x4 = x2;
106679108479
int jj;
106680108480
106681108481
int iCellLeft = 0;
106682108482
int iCellRight = 0;
106683108483
106684108484
for(jj=1; jj<nCell; jj++){
106685
- float left = aCell[jj].aCoord[i*2];
106686
- float right = aCell[jj].aCoord[i*2+1];
108485
+ float left = DCOORD(aCell[jj].aCoord[i*2]);
108486
+ float right = DCOORD(aCell[jj].aCoord[i*2+1]);
106687108487
106688108488
if( left<x1 ) x1 = left;
106689108489
if( right>x4 ) x4 = right;
106690108490
if( left>x3 ){
106691108491
x3 = left;
@@ -107039,10 +108839,13 @@
107039108839
int iRightSeed = 1;
107040108840
int *aiUsed;
107041108841
int i;
107042108842
107043108843
aiUsed = sqlite3_malloc(sizeof(int)*nCell);
108844
+ if( !aiUsed ){
108845
+ return SQLITE_NOMEM;
108846
+ }
107044108847
memset(aiUsed, 0, sizeof(int)*nCell);
107045108848
107046108849
PickSeeds(pRtree, aCell, nCell, &iLeftSeed, &iRightSeed);
107047108850
107048108851
memcpy(pBboxLeft, &aCell[iLeftSeed], sizeof(RtreeCell));
107049108852
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.6.18. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a one translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% are more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -15,11 +15,11 @@
15 ** of the embedded sqlite3.h header file.) Additional code files may be needed
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 ** This amalgamation was generated on 2009-09-11 14:16:13 UTC.
21 */
22 #define SQLITE_CORE 1
23 #define SQLITE_AMALGAMATION 1
24 #ifndef SQLITE_PRIVATE
25 # define SQLITE_PRIVATE static
@@ -273,10 +273,14 @@
273 # define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000
274 #endif
275
276 /*
277 ** Maximum depth of recursion for triggers.
 
 
 
 
278 */
279 #ifndef SQLITE_MAX_TRIGGER_DEPTH
280 #if defined(SQLITE_SMALL_STACK)
281 # define SQLITE_MAX_TRIGGER_DEPTH 10
282 #else
@@ -645,13 +649,13 @@
645 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
646 ** [sqlite_version()] and [sqlite_source_id()].
647 **
648 ** Requirements: [H10011] [H10014]
649 */
650 #define SQLITE_VERSION "3.6.18"
651 #define SQLITE_VERSION_NUMBER 3006018
652 #define SQLITE_SOURCE_ID "2009-09-11 14:05:07 b084828a771ec40be85f07c590ca99de4f6c24ee"
653
654 /*
655 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
656 ** KEYWORDS: sqlite3_version
657 **
@@ -1842,12 +1846,13 @@
1842 ** This function returns the number of database rows that were changed
1843 ** or inserted or deleted by the most recently completed SQL statement
1844 ** on the [database connection] specified by the first parameter.
1845 ** Only changes that are directly specified by the [INSERT], [UPDATE],
1846 ** or [DELETE] statement are counted. Auxiliary changes caused by
1847 ** triggers are not counted. Use the [sqlite3_total_changes()] function
1848 ** to find the total number of changes including changes caused by triggers.
 
1849 **
1850 ** Changes to a view that are simulated by an [INSTEAD OF trigger]
1851 ** are not counted. Only real table changes are counted.
1852 **
1853 ** A "row change" is a change to a single row of a single table
@@ -1895,12 +1900,12 @@
1895 /*
1896 ** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600>
1897 **
1898 ** This function returns the number of row changes caused by [INSERT],
1899 ** [UPDATE] or [DELETE] statements since the [database connection] was opened.
1900 ** The count includes all changes from all
1901 ** [CREATE TRIGGER | trigger] contexts. However,
1902 ** the count does not include changes used to implement [REPLACE] constraints,
1903 ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The
1904 ** count does not include rows of views that fire an [INSTEAD OF trigger],
1905 ** though if the INSTEAD OF trigger makes changes of its own, those changes
1906 ** are counted.
@@ -5037,10 +5042,13 @@
5037 ** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
5038 ** </pre> {END}
5039 **
5040 ** If the flags parameter is non-zero, then the BLOB is opened for read
5041 ** and write access. If it is zero, the BLOB is opened for read access.
 
 
 
5042 **
5043 ** Note that the database name is not the filename that contains
5044 ** the database but rather the symbolic name of the database that
5045 ** is assigned when the database is connected using [ATTACH].
5046 ** For the main database file, the database name is "main".
@@ -6419,74 +6427,74 @@
6419 #define TK_AS 24
6420 #define TK_COMMA 25
6421 #define TK_ID 26
6422 #define TK_INDEXED 27
6423 #define TK_ABORT 28
6424 #define TK_AFTER 29
6425 #define TK_ANALYZE 30
6426 #define TK_ASC 31
6427 #define TK_ATTACH 32
6428 #define TK_BEFORE 33
6429 #define TK_BY 34
6430 #define TK_CASCADE 35
6431 #define TK_CAST 36
6432 #define TK_COLUMNKW 37
6433 #define TK_CONFLICT 38
6434 #define TK_DATABASE 39
6435 #define TK_DESC 40
6436 #define TK_DETACH 41
6437 #define TK_EACH 42
6438 #define TK_FAIL 43
6439 #define TK_FOR 44
6440 #define TK_IGNORE 45
6441 #define TK_INITIALLY 46
6442 #define TK_INSTEAD 47
6443 #define TK_LIKE_KW 48
6444 #define TK_MATCH 49
6445 #define TK_KEY 50
6446 #define TK_OF 51
6447 #define TK_OFFSET 52
6448 #define TK_PRAGMA 53
6449 #define TK_RAISE 54
6450 #define TK_REPLACE 55
6451 #define TK_RESTRICT 56
6452 #define TK_ROW 57
6453 #define TK_TRIGGER 58
6454 #define TK_VACUUM 59
6455 #define TK_VIEW 60
6456 #define TK_VIRTUAL 61
6457 #define TK_REINDEX 62
6458 #define TK_RENAME 63
6459 #define TK_CTIME_KW 64
6460 #define TK_ANY 65
6461 #define TK_OR 66
6462 #define TK_AND 67
6463 #define TK_IS 68
6464 #define TK_BETWEEN 69
6465 #define TK_IN 70
6466 #define TK_ISNULL 71
6467 #define TK_NOTNULL 72
6468 #define TK_NE 73
6469 #define TK_EQ 74
6470 #define TK_GT 75
6471 #define TK_LE 76
6472 #define TK_LT 77
6473 #define TK_GE 78
6474 #define TK_ESCAPE 79
6475 #define TK_BITAND 80
6476 #define TK_BITOR 81
6477 #define TK_LSHIFT 82
6478 #define TK_RSHIFT 83
6479 #define TK_PLUS 84
6480 #define TK_MINUS 85
6481 #define TK_STAR 86
6482 #define TK_SLASH 87
6483 #define TK_REM 88
6484 #define TK_CONCAT 89
6485 #define TK_COLLATE 90
6486 #define TK_UMINUS 91
6487 #define TK_UPLUS 92
6488 #define TK_BITNOT 93
6489 #define TK_STRING 94
6490 #define TK_JOIN_KW 95
6491 #define TK_CONSTRAINT 96
6492 #define TK_DEFAULT 97
@@ -6497,32 +6505,32 @@
6497 #define TK_REFERENCES 102
6498 #define TK_AUTOINCR 103
6499 #define TK_ON 104
6500 #define TK_DELETE 105
6501 #define TK_UPDATE 106
6502 #define TK_INSERT 107
6503 #define TK_SET 108
6504 #define TK_DEFERRABLE 109
6505 #define TK_FOREIGN 110
6506 #define TK_DROP 111
6507 #define TK_UNION 112
6508 #define TK_ALL 113
6509 #define TK_EXCEPT 114
6510 #define TK_INTERSECT 115
6511 #define TK_SELECT 116
6512 #define TK_DISTINCT 117
6513 #define TK_DOT 118
6514 #define TK_FROM 119
6515 #define TK_JOIN 120
6516 #define TK_USING 121
6517 #define TK_ORDER 122
6518 #define TK_GROUP 123
6519 #define TK_HAVING 124
6520 #define TK_LIMIT 125
6521 #define TK_WHERE 126
6522 #define TK_INTO 127
6523 #define TK_VALUES 128
6524 #define TK_INTEGER 129
6525 #define TK_FLOAT 130
6526 #define TK_BLOB 131
6527 #define TK_REGISTER 132
6528 #define TK_VARIABLE 133
@@ -6536,19 +6544,22 @@
6536 #define TK_TO_TEXT 141
6537 #define TK_TO_BLOB 142
6538 #define TK_TO_NUMERIC 143
6539 #define TK_TO_INT 144
6540 #define TK_TO_REAL 145
6541 #define TK_END_OF_FILE 146
6542 #define TK_ILLEGAL 147
6543 #define TK_SPACE 148
6544 #define TK_UNCLOSED_STRING 149
6545 #define TK_FUNCTION 150
6546 #define TK_COLUMN 151
6547 #define TK_AGG_FUNCTION 152
6548 #define TK_AGG_COLUMN 153
6549 #define TK_CONST_FUNC 154
 
 
 
6550
6551 /************** End of parse.h ***********************************************/
6552 /************** Continuing where we left off in sqliteInt.h ******************/
6553 #include <stdio.h>
6554 #include <stdlib.h>
@@ -7308,142 +7319,142 @@
7308 #define OP_SetCookie 4
7309 #define OP_Seek 5
7310 #define OP_Real 130 /* same as TK_FLOAT */
7311 #define OP_Sequence 6
7312 #define OP_Savepoint 7
7313 #define OP_Ge 78 /* same as TK_GE */
7314 #define OP_RowKey 8
7315 #define OP_SCopy 9
7316 #define OP_Eq 74 /* same as TK_EQ */
7317 #define OP_OpenWrite 10
7318 #define OP_NotNull 72 /* same as TK_NOTNULL */
7319 #define OP_If 11
7320 #define OP_ToInt 144 /* same as TK_TO_INT */
7321 #define OP_String8 94 /* same as TK_STRING */
7322 #define OP_CollSeq 12
7323 #define OP_OpenRead 13
7324 #define OP_Expire 14
7325 #define OP_AutoCommit 15
7326 #define OP_Gt 75 /* same as TK_GT */
7327 #define OP_Pagecount 16
7328 #define OP_IntegrityCk 17
7329 #define OP_Sort 18
7330 #define OP_Copy 20
7331 #define OP_Trace 21
7332 #define OP_Function 22
7333 #define OP_IfNeg 23
7334 #define OP_And 67 /* same as TK_AND */
7335 #define OP_Subtract 85 /* same as TK_MINUS */
7336 #define OP_Noop 24
7337 #define OP_Program 25
7338 #define OP_Return 26
7339 #define OP_Remainder 88 /* same as TK_REM */
7340 #define OP_NewRowid 27
7341 #define OP_Multiply 86 /* same as TK_STAR */
7342 #define OP_Variable 28
7343 #define OP_String 29
7344 #define OP_RealAffinity 30
7345 #define OP_VRename 31
7346 #define OP_ParseSchema 32
7347 #define OP_VOpen 33
7348 #define OP_Close 34
7349 #define OP_CreateIndex 35
7350 #define OP_IsUnique 36
7351 #define OP_NotFound 37
7352 #define OP_Int64 38
7353 #define OP_MustBeInt 39
7354 #define OP_Halt 40
7355 #define OP_Rowid 41
7356 #define OP_IdxLT 42
7357 #define OP_AddImm 43
7358 #define OP_RowData 44
7359 #define OP_MemMax 45
7360 #define OP_Or 66 /* same as TK_OR */
7361 #define OP_NotExists 46
7362 #define OP_Gosub 47
7363 #define OP_Divide 87 /* same as TK_SLASH */
7364 #define OP_Integer 48
 
7365 #define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/
7366 #define OP_Prev 49
7367 #define OP_RowSetRead 50
7368 #define OP_Concat 89 /* same as TK_CONCAT */
7369 #define OP_RowSetAdd 51
7370 #define OP_BitAnd 80 /* same as TK_BITAND */
7371 #define OP_VColumn 52
7372 #define OP_CreateTable 53
7373 #define OP_Last 54
7374 #define OP_SeekLe 55
7375 #define OP_IsNull 71 /* same as TK_ISNULL */
7376 #define OP_IncrVacuum 56
7377 #define OP_IdxRowid 57
7378 #define OP_ShiftRight 83 /* same as TK_RSHIFT */
7379 #define OP_ResetCount 58
7380 #define OP_Yield 59
7381 #define OP_DropTrigger 60
7382 #define OP_DropIndex 61
7383 #define OP_Param 62
7384 #define OP_IdxGE 63
7385 #define OP_IdxDelete 64
7386 #define OP_Vacuum 65
7387 #define OP_IfNot 68
7388 #define OP_DropTable 69
7389 #define OP_SeekLt 70
7390 #define OP_MakeRecord 79
7391 #define OP_ToBlob 142 /* same as TK_TO_BLOB */
7392 #define OP_ResultRow 90
7393 #define OP_Delete 91
7394 #define OP_AggFinal 92
7395 #define OP_Compare 95
7396 #define OP_ShiftLeft 82 /* same as TK_LSHIFT */
7397 #define OP_Goto 96
7398 #define OP_TableLock 97
7399 #define OP_Clear 98
7400 #define OP_Le 76 /* same as TK_LE */
7401 #define OP_VerifyCookie 99
7402 #define OP_AggStep 100
7403 #define OP_ToText 141 /* same as TK_TO_TEXT */
7404 #define OP_Not 19 /* same as TK_NOT */
7405 #define OP_ToReal 145 /* same as TK_TO_REAL */
7406 #define OP_Transaction 101
7407 #define OP_VFilter 102
7408 #define OP_Ne 73 /* same as TK_NE */
7409 #define OP_VDestroy 103
7410 #define OP_BitOr 81 /* same as TK_BITOR */
7411 #define OP_Next 104
7412 #define OP_Count 105
7413 #define OP_IdxInsert 106
7414 #define OP_Lt 77 /* same as TK_LT */
7415 #define OP_SeekGe 107
7416 #define OP_Insert 108
7417 #define OP_Destroy 109
7418 #define OP_ReadCookie 110
7419 #define OP_RowSetTest 111
7420 #define OP_LoadAnalysis 112
7421 #define OP_Explain 113
7422 #define OP_HaltIfNull 114
7423 #define OP_OpenPseudo 115
7424 #define OP_OpenEphemeral 116
7425 #define OP_Null 117
7426 #define OP_Move 118
7427 #define OP_Blob 119
7428 #define OP_Add 84 /* same as TK_PLUS */
7429 #define OP_Rewind 120
7430 #define OP_SeekGt 121
7431 #define OP_VBegin 122
7432 #define OP_VUpdate 123
7433 #define OP_IfZero 124
 
7434 #define OP_BitNot 93 /* same as TK_BITNOT */
7435 #define OP_VCreate 125
7436 #define OP_Found 126
7437 #define OP_IfPos 127
7438 #define OP_NullRow 128
7439 #define OP_Jump 129
7440 #define OP_Permutation 131
7441
7442 /* The following opcode values are never used */
7443 #define OP_NotUsed_132 132
7444 #define OP_NotUsed_133 133
7445 #define OP_NotUsed_134 134
7446 #define OP_NotUsed_135 135
7447 #define OP_NotUsed_136 136
7448 #define OP_NotUsed_137 137
7449 #define OP_NotUsed_138 138
@@ -7463,24 +7474,24 @@
7463 #define OPFLG_OUT3 0x0020 /* out3: P3 is an output */
7464 #define OPFLG_INITIALIZER {\
7465 /* 0 */ 0x00, 0x01, 0x00, 0x00, 0x10, 0x08, 0x02, 0x00,\
7466 /* 8 */ 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00,\
7467 /* 16 */ 0x02, 0x00, 0x01, 0x04, 0x04, 0x00, 0x00, 0x05,\
7468 /* 24 */ 0x00, 0x01, 0x04, 0x02, 0x00, 0x02, 0x04, 0x00,\
7469 /* 32 */ 0x00, 0x00, 0x00, 0x02, 0x11, 0x11, 0x02, 0x05,\
7470 /* 40 */ 0x00, 0x02, 0x11, 0x04, 0x00, 0x08, 0x11, 0x01,\
7471 /* 48 */ 0x02, 0x01, 0x21, 0x08, 0x00, 0x02, 0x01, 0x11,\
7472 /* 56 */ 0x01, 0x02, 0x00, 0x04, 0x00, 0x00, 0x02, 0x11,\
7473 /* 64 */ 0x00, 0x00, 0x2c, 0x2c, 0x05, 0x00, 0x11, 0x05,\
7474 /* 72 */ 0x05, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x00,\
7475 /* 80 */ 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c,\
7476 /* 88 */ 0x2c, 0x2c, 0x00, 0x00, 0x00, 0x04, 0x02, 0x00,\
7477 /* 96 */ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,\
7478 /* 104 */ 0x01, 0x02, 0x08, 0x11, 0x00, 0x02, 0x02, 0x15,\
7479 /* 112 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x00, 0x02,\
7480 /* 120 */ 0x01, 0x11, 0x00, 0x00, 0x05, 0x00, 0x11, 0x05,\
7481 /* 128 */ 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,\
7482 /* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04,\
7483 /* 144 */ 0x04, 0x04,}
7484
7485 /************** End of opcodes.h *********************************************/
7486 /************** Continuing where we left off in vdbe.h ***********************/
@@ -8233,11 +8244,11 @@
8233 #define sqlite3_mutex_held(X) 1
8234 #define sqlite3_mutex_notheld(X) 1
8235 #define sqlite3MutexAlloc(X) ((sqlite3_mutex*)8)
8236 #define sqlite3MutexInit() SQLITE_OK
8237 #define sqlite3MutexEnd()
8238 #endif /* defined(SQLITE_OMIT_MUTEX) */
8239
8240 /************** End of mutex.h ***********************************************/
8241 /************** Continuing where we left off in sqliteInt.h ******************/
8242
8243
@@ -8270,10 +8281,11 @@
8270 struct Schema {
8271 int schema_cookie; /* Database schema version number for this file */
8272 Hash tblHash; /* All tables indexed by name */
8273 Hash idxHash; /* All (named) indices indexed by name */
8274 Hash trigHash; /* All triggers indexed by name */
 
8275 Table *pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */
8276 u8 file_format; /* Schema format version for this file */
8277 u8 enc; /* Text encoding used by this database */
8278 u16 flags; /* Flags associated with this schema */
8279 int cache_size; /* Number of pages to use in the cache */
@@ -8460,10 +8472,11 @@
8460 Db aDbStatic[2]; /* Static space for the 2 default backends */
8461 Savepoint *pSavepoint; /* List of active savepoints */
8462 int nSavepoint; /* Number of non-transaction savepoints */
8463 int nStatement; /* Number of nested statement-transactions */
8464 u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
 
8465
8466 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
8467 /* The following variables are all protected by the STATIC_MASTER
8468 ** mutex, not by sqlite3.mutex. They are used by code in notify.c.
8469 **
@@ -8516,10 +8529,11 @@
8516 #define SQLITE_LoadExtension 0x00020000 /* Enable load_extension */
8517
8518 #define SQLITE_RecoveryMode 0x00040000 /* Ignore schema errors */
8519 #define SQLITE_ReverseOrder 0x00100000 /* Reverse unordered SELECTs */
8520 #define SQLITE_RecTriggers 0x00200000 /* Enable recursive triggers */
 
8521
8522 /*
8523 ** Possible values for the sqlite.magic field.
8524 ** The numbers are obtained at random and have no special meaning, other
8525 ** than being distinct from one another.
@@ -8602,10 +8616,11 @@
8602 ** opened savepoint. Savepoints are added to the list by the vdbe
8603 ** OP_Savepoint instruction.
8604 */
8605 struct Savepoint {
8606 char *zName; /* Savepoint name (nul-terminated) */
 
8607 Savepoint *pNext; /* Parent savepoint (if any) */
8608 };
8609
8610 /*
8611 ** The following are used as the second parameter to sqlite3Savepoint(),
@@ -8722,10 +8737,11 @@
8722 ** Additional bit values that can be ORed with an affinity without
8723 ** changing the affinity.
8724 */
8725 #define SQLITE_JUMPIFNULL 0x08 /* jumps if either operand is NULL */
8726 #define SQLITE_STOREP2 0x10 /* Store result in reg[P2] rather than jump */
 
8727
8728 /*
8729 ** An object of this type is created for each virtual table present in
8730 ** the database schema.
8731 **
@@ -8878,18 +8894,20 @@
8878 ** Each REFERENCES clause generates an instance of the following structure
8879 ** which is attached to the from-table. The to-table need not exist when
8880 ** the from-table is created. The existence of the to-table is not checked.
8881 */
8882 struct FKey {
8883 Table *pFrom; /* The table that contains the REFERENCES clause */
8884 FKey *pNextFrom; /* Next foreign key in pFrom */
8885 char *zTo; /* Name of table that the key points to */
 
 
8886 int nCol; /* Number of columns in this key */
 
8887 u8 isDeferred; /* True if constraint checking is deferred till COMMIT */
8888 u8 updateConf; /* How to resolve conflicts that occur on UPDATE */
8889 u8 deleteConf; /* How to resolve conflicts that occur on DELETE */
8890 u8 insertConf; /* How to resolve conflicts that occur on INSERT */
8891 struct sColMap { /* Mapping of columns in pFrom to columns in zTo */
8892 int iFrom; /* Index of column in pFrom */
8893 char *zCol; /* Name of column in zTo. If 0 use PRIMARY KEY */
8894 } aCol[1]; /* One entry for each of nCol column s */
8895 };
@@ -9716,10 +9734,11 @@
9716 Parse *pToplevel; /* Parse structure for main program (or NULL) */
9717 Table *pTriggerTab; /* Table triggers are being coded for */
9718 u32 oldmask; /* Mask of old.* columns referenced */
9719 u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */
9720 u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */
 
9721
9722 /* Above is constant between recursions. Below is reset before and after
9723 ** each recursion */
9724
9725 int nVar; /* Number of '?' variables seen in the SQL so far */
@@ -10186,11 +10205,11 @@
10186 SQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *, struct SrcList_item *);
10187 SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
10188 SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
10189 SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);
10190 SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);
10191 SQLITE_PRIVATE void sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
10192 Token*, int, int);
10193 SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
10194 SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
10195 SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
10196 Expr*,ExprList*,int,Expr*,Expr*);
@@ -10257,11 +10276,12 @@
10257 SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int,
10258 int*,int,int,int,int,int*);
10259 SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int);
10260 SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int);
10261 SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
10262 SQLITE_PRIVATE void sqlite3MayAbort(Parse *);
 
10263 SQLITE_PRIVATE void sqlite3HaltConstraint(Parse*, int, char*, int);
10264 SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int);
10265 SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);
10266 SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
10267 SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);
@@ -10293,31 +10313,33 @@
10293 SQLITE_PRIVATE void sqlite3DropTrigger(Parse*, SrcList*, int);
10294 SQLITE_PRIVATE void sqlite3DropTriggerPtr(Parse*, Trigger*);
10295 SQLITE_PRIVATE Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask);
10296 SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *, Table *);
10297 SQLITE_PRIVATE void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *,
10298 int, int, int, int);
 
10299 void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);
10300 SQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);
10301 SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*);
10302 SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*,
10303 ExprList*,Select*,u8);
10304 SQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8);
10305 SQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*);
10306 SQLITE_PRIVATE void sqlite3DeleteTrigger(sqlite3*, Trigger*);
10307 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
10308 SQLITE_PRIVATE u32 sqlite3TriggerOldmask(Parse*,Trigger*,int,ExprList*,Table*,int);
10309 # define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p))
10310 #else
10311 # define sqlite3TriggersExist(B,C,D,E,F) 0
10312 # define sqlite3DeleteTrigger(A,B)
10313 # define sqlite3DropTriggerPtr(A,B)
10314 # define sqlite3UnlinkAndDeleteTrigger(A,B,C)
10315 # define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I,J)
 
10316 # define sqlite3TriggerList(X, Y) 0
10317 # define sqlite3ParseToplevel(p) p
10318 # define sqlite3TriggerOldmask(A,B,C,D,E,F) 0
10319 #endif
10320
10321 SQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*);
10322 SQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);
10323 SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int);
@@ -10324,10 +10346,11 @@
10324 #ifndef SQLITE_OMIT_AUTHORIZATION
10325 SQLITE_PRIVATE void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*);
10326 SQLITE_PRIVATE int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*);
10327 SQLITE_PRIVATE void sqlite3AuthContextPush(Parse*, AuthContext*, const char*);
10328 SQLITE_PRIVATE void sqlite3AuthContextPop(AuthContext*);
 
10329 #else
10330 # define sqlite3AuthRead(a,b,c,d)
10331 # define sqlite3AuthCheck(a,b,c,d,e) SQLITE_OK
10332 # define sqlite3AuthContextPush(a,b,c)
10333 # define sqlite3AuthContextPop(a) ((void)(a))
@@ -10531,10 +10554,36 @@
10531 SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
10532 SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
10533 SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*);
10534 SQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3*, Table*);
10535
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10536
10537
10538 /*
10539 ** Available fault injectors. Should be numbered beginning with 0.
10540 */
@@ -11389,11 +11438,11 @@
11389 y.D = sLocal.tm_mday;
11390 y.h = sLocal.tm_hour;
11391 y.m = sLocal.tm_min;
11392 y.s = sLocal.tm_sec;
11393 }
11394 #elif defined(HAVE_LOCALTIME_S)
11395 {
11396 struct tm sLocal;
11397 localtime_s(&sLocal, &t);
11398 y.Y = sLocal.tm_year + 1900;
11399 y.M = sLocal.tm_mon + 1;
@@ -13665,10 +13714,11 @@
13665 /*
13666 ** Deinitialize this module.
13667 */
13668 static void memsys3Shutdown(void *NotUsed){
13669 UNUSED_PARAMETER(NotUsed);
 
13670 return;
13671 }
13672
13673
13674
@@ -14505,11 +14555,11 @@
14505 SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){
14506 return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);
14507 }
14508 #endif
14509
14510 #endif /* SQLITE_OMIT_MUTEX */
14511
14512 /************** End of mutex.c ***********************************************/
14513 /************** Begin file mutex_noop.c **************************************/
14514 /*
14515 ** 2008 October 07
@@ -17770,10 +17820,12 @@
17770 i64 startTime; /* Time when query started - used for profiling */
17771 BtreeMutexArray aMutex; /* An array of Btree used here and needing locks */
17772 int aCounter[2]; /* Counters used by sqlite3_stmt_status() */
17773 char *zSql; /* Text of the SQL statement that generated this */
17774 void *pFree; /* Free this when deleting the vdbe */
 
 
17775 int iStatement; /* Statement number (or 0 if has not opened stmt) */
17776 #ifdef SQLITE_DEBUG
17777 FILE *trace; /* Write an execution trace here, if not NULL */
17778 #endif
17779 VdbeFrame *pFrame; /* Parent frame */
@@ -17841,10 +17893,16 @@
17841 SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*);
17842 SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);
17843 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
17844 SQLITE_PRIVATE int sqlite3VdbeReleaseBuffers(Vdbe *p);
17845 #endif
 
 
 
 
 
 
17846
17847 #ifndef SQLITE_OMIT_SHARED_CACHE
17848 SQLITE_PRIVATE void sqlite3VdbeMutexArrayEnter(Vdbe *p);
17849 #else
17850 # define sqlite3VdbeMutexArrayEnter(p)
@@ -19803,116 +19861,116 @@
19803 /* 23 */ "IfNeg",
19804 /* 24 */ "Noop",
19805 /* 25 */ "Program",
19806 /* 26 */ "Return",
19807 /* 27 */ "NewRowid",
19808 /* 28 */ "Variable",
19809 /* 29 */ "String",
19810 /* 30 */ "RealAffinity",
19811 /* 31 */ "VRename",
19812 /* 32 */ "ParseSchema",
19813 /* 33 */ "VOpen",
19814 /* 34 */ "Close",
19815 /* 35 */ "CreateIndex",
19816 /* 36 */ "IsUnique",
19817 /* 37 */ "NotFound",
19818 /* 38 */ "Int64",
19819 /* 39 */ "MustBeInt",
19820 /* 40 */ "Halt",
19821 /* 41 */ "Rowid",
19822 /* 42 */ "IdxLT",
19823 /* 43 */ "AddImm",
19824 /* 44 */ "RowData",
19825 /* 45 */ "MemMax",
19826 /* 46 */ "NotExists",
19827 /* 47 */ "Gosub",
19828 /* 48 */ "Integer",
19829 /* 49 */ "Prev",
19830 /* 50 */ "RowSetRead",
19831 /* 51 */ "RowSetAdd",
19832 /* 52 */ "VColumn",
19833 /* 53 */ "CreateTable",
19834 /* 54 */ "Last",
19835 /* 55 */ "SeekLe",
19836 /* 56 */ "IncrVacuum",
19837 /* 57 */ "IdxRowid",
19838 /* 58 */ "ResetCount",
19839 /* 59 */ "Yield",
19840 /* 60 */ "DropTrigger",
19841 /* 61 */ "DropIndex",
19842 /* 62 */ "Param",
19843 /* 63 */ "IdxGE",
19844 /* 64 */ "IdxDelete",
19845 /* 65 */ "Vacuum",
19846 /* 66 */ "Or",
19847 /* 67 */ "And",
19848 /* 68 */ "IfNot",
19849 /* 69 */ "DropTable",
19850 /* 70 */ "SeekLt",
19851 /* 71 */ "IsNull",
19852 /* 72 */ "NotNull",
19853 /* 73 */ "Ne",
19854 /* 74 */ "Eq",
19855 /* 75 */ "Gt",
19856 /* 76 */ "Le",
19857 /* 77 */ "Lt",
19858 /* 78 */ "Ge",
19859 /* 79 */ "MakeRecord",
19860 /* 80 */ "BitAnd",
19861 /* 81 */ "BitOr",
19862 /* 82 */ "ShiftLeft",
19863 /* 83 */ "ShiftRight",
19864 /* 84 */ "Add",
19865 /* 85 */ "Subtract",
19866 /* 86 */ "Multiply",
19867 /* 87 */ "Divide",
19868 /* 88 */ "Remainder",
19869 /* 89 */ "Concat",
19870 /* 90 */ "ResultRow",
19871 /* 91 */ "Delete",
19872 /* 92 */ "AggFinal",
19873 /* 93 */ "BitNot",
19874 /* 94 */ "String8",
19875 /* 95 */ "Compare",
19876 /* 96 */ "Goto",
19877 /* 97 */ "TableLock",
19878 /* 98 */ "Clear",
19879 /* 99 */ "VerifyCookie",
19880 /* 100 */ "AggStep",
19881 /* 101 */ "Transaction",
19882 /* 102 */ "VFilter",
19883 /* 103 */ "VDestroy",
19884 /* 104 */ "Next",
19885 /* 105 */ "Count",
19886 /* 106 */ "IdxInsert",
19887 /* 107 */ "SeekGe",
19888 /* 108 */ "Insert",
19889 /* 109 */ "Destroy",
19890 /* 110 */ "ReadCookie",
19891 /* 111 */ "RowSetTest",
19892 /* 112 */ "LoadAnalysis",
19893 /* 113 */ "Explain",
19894 /* 114 */ "HaltIfNull",
19895 /* 115 */ "OpenPseudo",
19896 /* 116 */ "OpenEphemeral",
19897 /* 117 */ "Null",
19898 /* 118 */ "Move",
19899 /* 119 */ "Blob",
19900 /* 120 */ "Rewind",
19901 /* 121 */ "SeekGt",
19902 /* 122 */ "VBegin",
19903 /* 123 */ "VUpdate",
19904 /* 124 */ "IfZero",
19905 /* 125 */ "VCreate",
19906 /* 126 */ "Found",
19907 /* 127 */ "IfPos",
19908 /* 128 */ "NullRow",
19909 /* 129 */ "Jump",
19910 /* 130 */ "Real",
19911 /* 131 */ "Permutation",
19912 /* 132 */ "NotUsed_132",
19913 /* 133 */ "NotUsed_133",
19914 /* 134 */ "NotUsed_134",
19915 /* 135 */ "NotUsed_135",
19916 /* 136 */ "NotUsed_136",
19917 /* 137 */ "NotUsed_137",
19918 /* 138 */ "NotUsed_138",
@@ -22530,11 +22588,11 @@
22530 pLock = sqlite3_malloc( sizeof(*pLock) );
22531 if( pLock==0 ){
22532 rc = SQLITE_NOMEM;
22533 goto exit_findlockinfo;
22534 }
22535 pLock->lockKey = lockKey;
22536 pLock->nRef = 1;
22537 pLock->cnt = 0;
22538 pLock->locktype = 0;
22539 pLock->pNext = lockList;
22540 pLock->pPrev = 0;
@@ -47336,11 +47394,11 @@
47336 if( p->aLabel ){
47337 p->aLabel[j] = p->nOp;
47338 }
47339 }
47340
47341 #ifdef SQLITE_DEBUG
47342
47343 /*
47344 ** The following type and function are used to iterate through all opcodes
47345 ** in a Vdbe main program and each of the sub-programs (triggers) it may
47346 ** invoke directly or indirectly. It should be used as follows:
@@ -47408,19 +47466,20 @@
47408 return pRet;
47409 }
47410
47411 /*
47412 ** Check if the program stored in the VM associated with pParse may
47413 ** throw an ABORT exception (causing the statement, but not transaction
47414 ** to be rolled back). This condition is true if the main program or any
47415 ** sub-programs contains any of the following:
47416 **
47417 ** * OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
47418 ** * OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
47419 ** * OP_Destroy
47420 ** * OP_VUpdate
47421 ** * OP_VRename
 
47422 **
47423 ** Then check that the value of Parse.mayAbort is true if an
47424 ** ABORT may be thrown, or false otherwise. Return true if it does
47425 ** match, or false otherwise. This function is intended to be used as
47426 ** part of an assert statement in the compiler. Similar to:
@@ -47435,10 +47494,13 @@
47435 sIter.v = v;
47436
47437 while( (pOp = opIterNext(&sIter))!=0 ){
47438 int opcode = pOp->opcode;
47439 if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename
 
 
 
47440 || ((opcode==OP_Halt || opcode==OP_HaltIfNull)
47441 && (pOp->p1==SQLITE_CONSTRAINT && pOp->p2==OE_Abort))
47442 ){
47443 hasAbort = 1;
47444 break;
@@ -47451,11 +47513,11 @@
47451 ** through all opcodes and hasAbort may be set incorrectly. Return
47452 ** true for this case to prevent the assert() in the callers frame
47453 ** from failing. */
47454 return ( v->db->mallocFailed || hasAbort==mayAbort );
47455 }
47456 #endif
47457
47458 /*
47459 ** Loop through the program looking for P2 values that are negative
47460 ** on jump instructions. Each such value is a label. Resolve the
47461 ** label by setting the P2 value to its correct non-zero value.
@@ -48991,10 +49053,17 @@
48991 }
48992 }
48993 }
48994 db->nStatement--;
48995 p->iStatement = 0;
 
 
 
 
 
 
 
48996 }
48997 return rc;
48998 }
48999
49000 /*
@@ -49022,10 +49091,33 @@
49022 sqlite3BtreeEnterAll(p->db);
49023 #endif
49024 }
49025 #endif
49026
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49027 /*
49028 ** This routine is called the when a VDBE tries to halt. If the VDBE
49029 ** has made changes and is in autocommit mode, then commit those
49030 ** changes. If a rollback is needed, then do the rollback.
49031 **
@@ -49096,10 +49188,15 @@
49096 sqlite3CloseSavepoints(db);
49097 db->autoCommit = 1;
49098 }
49099 }
49100 }
 
 
 
 
 
49101
49102 /* If the auto-commit flag is set and this is the only active writer
49103 ** VM, then we do either a commit or rollback of the current transaction.
49104 **
49105 ** Note: This block also runs if one of the special errors handled
@@ -49108,22 +49205,27 @@
49108 if( !sqlite3VtabInSync(db)
49109 && db->autoCommit
49110 && db->writeVdbeCnt==(p->readOnly==0)
49111 ){
49112 if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){
49113 /* The auto-commit flag is true, and the vdbe program was
49114 ** successful or hit an 'OR FAIL' constraint. This means a commit
49115 ** is required.
49116 */
 
 
 
 
49117 rc = vdbeCommit(db, p);
49118 if( rc==SQLITE_BUSY ){
49119 sqlite3BtreeMutexArrayLeave(&p->aMutex);
49120 return SQLITE_BUSY;
49121 }else if( rc!=SQLITE_OK ){
49122 p->rc = rc;
49123 sqlite3RollbackAll(db);
49124 }else{
 
49125 sqlite3CommitInternalChanges(db);
49126 }
49127 }else{
49128 sqlite3RollbackAll(db);
49129 }
@@ -50400,10 +50502,12 @@
50400 */
50401 if( db->activeVdbeCnt==0 ){
50402 db->u1.isInterrupted = 0;
50403 }
50404
 
 
50405 #ifndef SQLITE_OMIT_TRACE
50406 if( db->xProfile && !db->init.busy ){
50407 double rNow;
50408 sqlite3OsCurrentTime(db->pVfs, &rNow);
50409 p->startTime = (u64)((rNow - (int)rNow)*3600.0*24.0*1000000000.0);
@@ -51381,10 +51485,21 @@
51381 sqlite3_max_blobsize = p->n;
51382 }
51383 }
51384 #endif
51385
 
 
 
 
 
 
 
 
 
 
 
51386 /*
51387 ** Test a register to see if it exceeds the current maximum blob size.
51388 ** If it does, record the new maximum blob size.
51389 */
51390 #if defined(SQLITE_TEST) && !defined(SQLITE_OMIT_BUILTIN_TEST)
@@ -51990,13 +52105,12 @@
51990 struct OP_ShiftRight_stack_vars {
51991 i64 a;
51992 i64 b;
51993 } ah;
51994 struct OP_Ge_stack_vars {
51995 int flags;
51996 int res;
51997 char affinity;
51998 } ai;
51999 struct OP_Compare_stack_vars {
52000 int n;
52001 int i;
52002 int p1;
@@ -52653,14 +52767,16 @@
52653 p->pc = pc;
52654 if( pOp->p4.z ){
52655 sqlite3SetString(&p->zErrMsg, db, "%s", pOp->p4.z);
52656 }
52657 rc = sqlite3VdbeHalt(p);
52658 assert( rc==SQLITE_BUSY || rc==SQLITE_OK );
52659 if( rc==SQLITE_BUSY ){
52660 p->rc = rc = SQLITE_BUSY;
52661 }else{
 
 
52662 rc = p->rc ? SQLITE_ERROR : SQLITE_DONE;
52663 }
52664 goto vdbe_return;
52665 }
52666
@@ -52901,10 +53017,19 @@
52901 int i;
52902 #endif /* local variables moved into u.ad */
52903 assert( p->nResColumn==pOp->p2 );
52904 assert( pOp->p1>0 );
52905 assert( pOp->p1+pOp->p2<=p->nMem+1 );
 
 
 
 
 
 
 
 
 
52906
52907 /* If the SQLITE_CountRows flag is set in sqlite3.flags mask, then
52908 ** DML statements invoke this opcode to return the number of rows
52909 ** modified to the user. This is the only way that a VM that
52910 ** opens a statement transaction may invoke this opcode.
@@ -53473,16 +53598,28 @@
53473 /* Opcode: Ne P1 P2 P3 P4 P5
53474 **
53475 ** This works just like the Lt opcode except that the jump is taken if
53476 ** the operands in registers P1 and P3 are not equal. See the Lt opcode for
53477 ** additional information.
 
 
 
 
 
 
53478 */
53479 /* Opcode: Eq P1 P2 P3 P4 P5
53480 **
53481 ** This works just like the Lt opcode except that the jump is taken if
53482 ** the operands in registers P1 and P3 are equal.
53483 ** See the Lt opcode for additional information.
 
 
 
 
 
 
53484 */
53485 /* Opcode: Le P1 P2 P3 P4 P5
53486 **
53487 ** This works just like the Lt opcode except that the jump is taken if
53488 ** the content of register P3 is less than or equal to the content of
@@ -53505,42 +53642,51 @@
53505 case OP_Lt: /* same as TK_LT, jump, in1, in3 */
53506 case OP_Le: /* same as TK_LE, jump, in1, in3 */
53507 case OP_Gt: /* same as TK_GT, jump, in1, in3 */
53508 case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
53509 #if 0 /* local variables moved into u.ai */
53510 int flags;
53511 int res;
53512 char affinity;
53513 #endif /* local variables moved into u.ai */
53514
53515 u.ai.flags = pIn1->flags|pIn3->flags;
53516
53517 if( u.ai.flags&MEM_Null ){
53518 /* If either operand is NULL then the result is always NULL.
53519 ** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
53520 */
53521 if( pOp->p5 & SQLITE_STOREP2 ){
53522 pOut = &p->aMem[pOp->p2];
53523 MemSetTypeFlag(pOut, MEM_Null);
53524 REGISTER_TRACE(pOp->p2, pOut);
53525 }else if( pOp->p5 & SQLITE_JUMPIFNULL ){
53526 pc = pOp->p2-1;
53527 }
53528 break;
53529 }
53530
53531 u.ai.affinity = pOp->p5 & SQLITE_AFF_MASK;
53532 if( u.ai.affinity ){
53533 applyAffinity(pIn1, u.ai.affinity, encoding);
53534 applyAffinity(pIn3, u.ai.affinity, encoding);
53535 if( db->mallocFailed ) goto no_mem;
53536 }
53537
53538 assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
53539 ExpandBlob(pIn1);
53540 ExpandBlob(pIn3);
53541 u.ai.res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
 
 
 
 
 
 
 
 
 
 
53542 switch( pOp->opcode ){
53543 case OP_Eq: u.ai.res = u.ai.res==0; break;
53544 case OP_Ne: u.ai.res = u.ai.res!=0; break;
53545 case OP_Lt: u.ai.res = u.ai.res<0; break;
53546 case OP_Le: u.ai.res = u.ai.res<=0; break;
@@ -53604,13 +53750,22 @@
53604 u.aj.n = pOp->p3;
53605 u.aj.pKeyInfo = pOp->p4.pKeyInfo;
53606 assert( u.aj.n>0 );
53607 assert( u.aj.pKeyInfo!=0 );
53608 u.aj.p1 = pOp->p1;
53609 assert( u.aj.p1>0 && u.aj.p1+u.aj.n<=p->nMem+1 );
53610 u.aj.p2 = pOp->p2;
53611 assert( u.aj.p2>0 && u.aj.p2+u.aj.n<=p->nMem+1 );
 
 
 
 
 
 
 
 
 
 
53612 for(u.aj.i=0; u.aj.i<u.aj.n; u.aj.i++){
53613 u.aj.idx = aPermute ? aPermute[u.aj.i] : u.aj.i;
53614 REGISTER_TRACE(u.aj.p1+u.aj.idx, &p->aMem[u.aj.p1+u.aj.idx]);
53615 REGISTER_TRACE(u.aj.p2+u.aj.idx, &p->aMem[u.aj.p2+u.aj.idx]);
53616 assert( u.aj.i<u.aj.pKeyInfo->nField );
@@ -54321,10 +54476,11 @@
54321 }
54322
54323 /* Link the new savepoint into the database handle's list. */
54324 u.aq.pNew->pNext = db->pSavepoint;
54325 db->pSavepoint = u.aq.pNew;
 
54326 }
54327 }
54328 }else{
54329 u.aq.iSavepoint = 0;
54330
@@ -54358,10 +54514,13 @@
54358 ** and this is a RELEASE command, then the current transaction
54359 ** is committed.
54360 */
54361 int isTransaction = u.aq.pSavepoint->pNext==0 && db->isTransactionSavepoint;
54362 if( isTransaction && u.aq.p1==SAVEPOINT_RELEASE ){
 
 
 
54363 db->autoCommit = 1;
54364 if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
54365 p->pc = pc;
54366 db->autoCommit = 0;
54367 p->rc = rc = SQLITE_BUSY;
@@ -54390,18 +54549,23 @@
54390 db->pSavepoint = u.aq.pTmp->pNext;
54391 sqlite3DbFree(db, u.aq.pTmp);
54392 db->nSavepoint--;
54393 }
54394
54395 /* If it is a RELEASE, then destroy the savepoint being operated on too */
 
 
 
54396 if( u.aq.p1==SAVEPOINT_RELEASE ){
54397 assert( u.aq.pSavepoint==db->pSavepoint );
54398 db->pSavepoint = u.aq.pSavepoint->pNext;
54399 sqlite3DbFree(db, u.aq.pSavepoint);
54400 if( !isTransaction ){
54401 db->nSavepoint--;
54402 }
 
 
54403 }
54404 }
54405 }
54406
54407 break;
@@ -54448,10 +54612,12 @@
54448 }else if( u.ar.desiredAutoCommit!=db->autoCommit ){
54449 if( u.ar.iRollback ){
54450 assert( u.ar.desiredAutoCommit==1 );
54451 sqlite3RollbackAll(db);
54452 db->autoCommit = 1;
 
 
54453 }else{
54454 db->autoCommit = (u8)u.ar.desiredAutoCommit;
54455 if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
54456 p->pc = pc;
54457 db->autoCommit = (u8)(1-u.ar.desiredAutoCommit);
@@ -54523,11 +54689,11 @@
54523 if( rc==SQLITE_BUSY ){
54524 p->pc = pc;
54525 p->rc = rc = SQLITE_BUSY;
54526 goto vdbe_return;
54527 }
54528 if( rc!=SQLITE_OK && rc!=SQLITE_READONLY /* && rc!=SQLITE_BUSY */ ){
54529 goto abort_due_to_error;
54530 }
54531
54532 if( pOp->p2 && p->usesStmtJournal
54533 && (db->autoCommit==0 || db->activeVdbeCnt>1)
@@ -54537,10 +54703,15 @@
54537 assert( db->nStatement>=0 && db->nSavepoint>=0 );
54538 db->nStatement++;
54539 p->iStatement = db->nSavepoint + db->nStatement;
54540 }
54541 rc = sqlite3BtreeBeginStmt(u.as.pBt, p->iStatement);
 
 
 
 
 
54542 }
54543 }
54544 break;
54545 }
54546
@@ -55156,10 +55327,14 @@
55156 VdbeCursor *pC;
55157 int res;
55158 UnpackedRecord *pIdxKey;
55159 char aTempRec[ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*3 + 7];
55160 #endif /* local variables moved into u.bb */
 
 
 
 
55161
55162 u.bb.alreadyExists = 0;
55163 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
55164 u.bb.pC = p->apCsr[pOp->p1];
55165 assert( u.bb.pC!=0 );
@@ -56616,28 +56791,28 @@
56616
56617 u.bz.pProgram = pOp->p4.pProgram;
56618 u.bz.pRt = &p->aMem[pOp->p3];
56619 assert( u.bz.pProgram->nOp>0 );
56620
56621 /* If the SQLITE_RecTriggers flag is clear, then recursive invocation of
56622 ** triggers is disabled for backwards compatibility (flag set/cleared by
56623 ** the "PRAGMA recursive_triggers" command).
 
56624 **
56625 ** It is recursive invocation of triggers, at the SQL level, that is
56626 ** disabled. In some cases a single trigger may generate more than one
56627 ** SubProgram (if the trigger may be executed with more than one different
56628 ** ON CONFLICT algorithm). SubProgram structures associated with a
56629 ** single trigger all have the same value for the SubProgram.token
56630 ** variable.
56631 */
56632 if( 0==(db->flags&SQLITE_RecTriggers) ){
56633 u.bz.t = u.bz.pProgram->token;
56634 for(u.bz.pFrame=p->pFrame; u.bz.pFrame && u.bz.pFrame->token!=u.bz.t; u.bz.pFrame=u.bz.pFrame->pParent);
56635 if( u.bz.pFrame ) break;
56636 }
56637
56638 if( p->nFrame>db->aLimit[SQLITE_LIMIT_TRIGGER_DEPTH] ){
56639 rc = SQLITE_ERROR;
56640 sqlite3SetString(&p->zErrMsg, db, "too many levels of trigger recursion");
56641 break;
56642 }
56643
@@ -56727,10 +56902,48 @@
56727 break;
56728 }
56729
56730 #endif /* #ifndef SQLITE_OMIT_TRIGGER */
56731
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56732 #ifndef SQLITE_OMIT_AUTOINCREMENT
56733 /* Opcode: MemMax P1 P2 * * *
56734 **
56735 ** P1 is a register in the root frame of this VM (the root frame is
56736 ** different from the current frame if this instruction is being executed
@@ -57677,29 +57890,49 @@
57677 sqlite3BtreeLeaveAll(db);
57678 goto blob_open_out;
57679 }
57680
57681 /* If the value is being opened for writing, check that the
57682 ** column is not indexed. It is against the rules to open an
57683 ** indexed column for writing.
57684 */
57685 if( flags ){
 
57686 Index *pIdx;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57687 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
57688 int j;
57689 for(j=0; j<pIdx->nColumn; j++){
57690 if( pIdx->aiColumn[j]==iCol ){
57691 sqlite3DbFree(db, zErr);
57692 zErr = sqlite3MPrintf(db,
57693 "cannot open indexed column for writing");
57694 rc = SQLITE_ERROR;
57695 (void)sqlite3SafetyOff(db);
57696 sqlite3BtreeLeaveAll(db);
57697 goto blob_open_out;
57698 }
57699 }
57700 }
 
 
 
 
 
 
 
 
57701 }
57702
57703 v = sqlite3VdbeCreate(db);
57704 if( v ){
57705 int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
@@ -59870,11 +60103,11 @@
59870 */
59871 static char comparisonAffinity(Expr *pExpr){
59872 char aff;
59873 assert( pExpr->op==TK_EQ || pExpr->op==TK_IN || pExpr->op==TK_LT ||
59874 pExpr->op==TK_GT || pExpr->op==TK_GE || pExpr->op==TK_LE ||
59875 pExpr->op==TK_NE );
59876 assert( pExpr->pLeft );
59877 aff = sqlite3ExprAffinity(pExpr->pLeft);
59878 if( pExpr->pRight ){
59879 aff = sqlite3CompareAffinity(pExpr->pRight, aff);
59880 }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
@@ -61961,10 +62194,23 @@
61961 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
61962 r1, r2, inReg, SQLITE_STOREP2);
61963 testcase( regFree1==0 );
61964 testcase( regFree2==0 );
61965 break;
 
 
 
 
 
 
 
 
 
 
 
 
 
61966 }
61967 case TK_AND:
61968 case TK_OR:
61969 case TK_PLUS:
61970 case TK_STAR:
@@ -62735,10 +62981,23 @@
62735 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
62736 r1, r2, dest, jumpIfNull);
62737 testcase( regFree1==0 );
62738 testcase( regFree2==0 );
62739 break;
 
 
 
 
 
 
 
 
 
 
 
 
 
62740 }
62741 case TK_ISNULL:
62742 case TK_NOTNULL: {
62743 assert( TK_ISNULL==OP_IsNull );
62744 assert( TK_NOTNULL==OP_NotNull );
@@ -62884,10 +63143,23 @@
62884 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
62885 r1, r2, dest, jumpIfNull);
62886 testcase( regFree1==0 );
62887 testcase( regFree2==0 );
62888 break;
 
 
 
 
 
 
 
 
 
 
 
 
 
62889 }
62890 case TK_ISNULL:
62891 case TK_NOTNULL: {
62892 testcase( op==TK_ISNULL );
62893 testcase( op==TK_NOTNULL );
@@ -63346,10 +63618,73 @@
63346 zTableName, tname.z+tname.n);
63347 sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC);
63348 }
63349 }
63350
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63351 #ifndef SQLITE_OMIT_TRIGGER
63352 /* This function is used by SQL generated to implement the
63353 ** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER
63354 ** statement. The second is a table name. The table name in the CREATE
63355 ** TRIGGER statement is replaced with the third argument and the result
@@ -63433,22 +63768,69 @@
63433 renameTableFunc, 0, 0);
63434 #ifndef SQLITE_OMIT_TRIGGER
63435 sqlite3CreateFunc(db, "sqlite_rename_trigger", 2, SQLITE_UTF8, 0,
63436 renameTriggerFunc, 0, 0);
63437 #endif
 
 
 
 
63438 }
63439
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63440 /*
63441 ** Generate the text of a WHERE expression which can be used to select all
63442 ** temporary triggers on table pTab from the sqlite_temp_master table. If
63443 ** table pTab has no temporary triggers, or is itself stored in the
63444 ** temporary database, NULL is returned.
63445 */
63446 static char *whereTempTriggers(Parse *pParse, Table *pTab){
63447 Trigger *pTrig;
63448 char *zWhere = 0;
63449 char *tmp = 0;
63450 const Schema *pTempSchema = pParse->db->aDb[1].pSchema; /* Temp db schema */
63451
63452 /* If the table is not located in the temp-db (in which case NULL is
63453 ** returned, loop through the tables list of triggers. For each trigger
63454 ** that is not part of the temp-db schema, add a clause to the WHERE
@@ -63456,17 +63838,11 @@
63456 */
63457 if( pTab->pSchema!=pTempSchema ){
63458 sqlite3 *db = pParse->db;
63459 for(pTrig=sqlite3TriggerList(pParse, pTab); pTrig; pTrig=pTrig->pNext){
63460 if( pTrig->pSchema==pTempSchema ){
63461 if( !zWhere ){
63462 zWhere = sqlite3MPrintf(db, "name=%Q", pTrig->zName);
63463 }else{
63464 tmp = zWhere;
63465 zWhere = sqlite3MPrintf(db, "%s OR name=%Q", zWhere, pTrig->zName);
63466 sqlite3DbFree(db, tmp);
63467 }
63468 }
63469 }
63470 }
63471 return zWhere;
63472 }
@@ -63500,11 +63876,11 @@
63500 assert( iTrigDb==iDb || iTrigDb==1 );
63501 sqlite3VdbeAddOp4(v, OP_DropTrigger, iTrigDb, 0, 0, pTrig->zName, 0);
63502 }
63503 #endif
63504
63505 /* Drop the table and index from the internal schema */
63506 sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);
63507
63508 /* Reload the table, index and permanent trigger schemas. */
63509 zWhere = sqlite3MPrintf(pParse->db, "tbl_name=%Q", zName);
63510 if( !zWhere ) return;
@@ -63630,10 +64006,25 @@
63630 #endif
63631
63632 /* figure out how many UTF-8 characters are in zName */
63633 zTabName = pTab->zName;
63634 nTabName = sqlite3Utf8CharLen(zTabName, -1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63635
63636 /* Modify the sqlite_master table to use the new table name. */
63637 sqlite3NestedParse(pParse,
63638 "UPDATE %Q.%s SET "
63639 #ifdef SQLITE_OMIT_TRIGGER
@@ -63679,10 +64070,22 @@
63679 "UPDATE sqlite_temp_master SET "
63680 "sql = sqlite_rename_trigger(sql, %Q), "
63681 "tbl_name = %Q "
63682 "WHERE %s;", zName, zName, zWhere);
63683 sqlite3DbFree(db, zWhere);
 
 
 
 
 
 
 
 
 
 
 
 
63684 }
63685 #endif
63686
63687 /* Drop and reload the internal table schema. */
63688 reloadTableSchema(pParse, pTab, zName);
@@ -63775,10 +64178,15 @@
63775 return;
63776 }
63777 if( pNew->pIndex ){
63778 sqlite3ErrorMsg(pParse, "Cannot add a UNIQUE column");
63779 return;
 
 
 
 
 
63780 }
63781 if( pCol->notNull && !pDflt ){
63782 sqlite3ErrorMsg(pParse,
63783 "Cannot add a NOT NULL column with default value NULL");
63784 return;
@@ -65206,10 +65614,43 @@
65206 */
65207 static void sqliteAuthBadReturnCode(Parse *pParse){
65208 sqlite3ErrorMsg(pParse, "authorizer malfunction");
65209 pParse->rc = SQLITE_ERROR;
65210 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65211
65212 /*
65213 ** The pExpr should be a TK_COLUMN expression. The table referred to
65214 ** is in pTabList or else it is the NEW or OLD table of a trigger.
65215 ** Check to see if it is OK to read this particular column.
@@ -65223,15 +65664,13 @@
65223 Expr *pExpr, /* The expression to check authorization on */
65224 Schema *pSchema, /* The schema of the expression */
65225 SrcList *pTabList /* All table that pExpr might refer to */
65226 ){
65227 sqlite3 *db = pParse->db;
65228 int rc;
65229 Table *pTab = 0; /* The table being read */
65230 const char *zCol; /* Name of the column of the table */
65231 int iSrc; /* Index in pTabList->a[] of table being read */
65232 const char *zDBase; /* Name of database being accessed */
65233 int iDb; /* The index of the database the expression refers to */
65234 int iCol; /* Index of column in table */
65235
65236 if( db->xAuth==0 ) return;
65237 iDb = sqlite3SchemaToIndex(pParse->db, pSchema);
@@ -65264,25 +65703,12 @@
65264 zCol = pTab->aCol[pTab->iPKey].zName;
65265 }else{
65266 zCol = "ROWID";
65267 }
65268 assert( iDb>=0 && iDb<db->nDb );
65269 zDBase = db->aDb[iDb].zName;
65270 rc = db->xAuth(db->pAuthArg, SQLITE_READ, pTab->zName, zCol, zDBase,
65271 pParse->zAuthContext);
65272 if( rc==SQLITE_IGNORE ){
65273 pExpr->op = TK_NULL;
65274 }else if( rc==SQLITE_DENY ){
65275 if( db->nDb>2 || iDb!=0 ){
65276 sqlite3ErrorMsg(pParse, "access to %s.%s.%s is prohibited",
65277 zDBase, pTab->zName, zCol);
65278 }else{
65279 sqlite3ErrorMsg(pParse, "access to %s.%s is prohibited",pTab->zName,zCol);
65280 }
65281 pParse->rc = SQLITE_AUTH;
65282 }else if( rc!=SQLITE_OK ){
65283 sqliteAuthBadReturnCode(pParse);
65284 }
65285 }
65286
65287 /*
65288 ** Do an authorization check using the code and arguments given. Return
@@ -65547,10 +65973,13 @@
65547 #ifdef SQLITE_DEBUG
65548 FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stdout : 0;
65549 sqlite3VdbeTrace(v, trace);
65550 #endif
65551 assert( pParse->iCacheLevel==0 ); /* Disables and re-enables match */
 
 
 
65552 sqlite3VdbeMakeReady(v, pParse->nVar, pParse->nMem,
65553 pParse->nTab, pParse->nMaxArg, pParse->explain,
65554 pParse->isMultiWrite && pParse->mayAbort);
65555 pParse->rc = SQLITE_DONE;
65556 pParse->colNamesSet = 0;
@@ -65852,11 +66281,10 @@
65852 ** memory structures of the indices and foreign keys associated with
65853 ** the table.
65854 */
65855 SQLITE_PRIVATE void sqlite3DeleteTable(Table *pTable){
65856 Index *pIndex, *pNext;
65857 FKey *pFKey, *pNextFKey;
65858 sqlite3 *db;
65859
65860 if( pTable==0 ) return;
65861 db = pTable->dbMem;
65862 testcase( db==0 );
@@ -65874,17 +66302,12 @@
65874 pNext = pIndex->pNext;
65875 assert( pIndex->pSchema==pTable->pSchema );
65876 sqlite3DeleteIndex(pIndex);
65877 }
65878
65879 #ifndef SQLITE_OMIT_FOREIGN_KEY
65880 /* Delete all foreign keys associated with this table. */
65881 for(pFKey=pTable->pFKey; pFKey; pFKey=pNextFKey){
65882 pNextFKey = pFKey->pNextFrom;
65883 sqlite3DbFree(db, pFKey);
65884 }
65885 #endif
65886
65887 /* Delete the Table structure itself.
65888 */
65889 sqliteResetColumnNames(pTable);
65890 sqlite3DbFree(db, pTable->zName);
@@ -66522,11 +66945,15 @@
66522 #ifndef SQLITE_OMIT_AUTOINCREMENT
66523 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
66524 "INTEGER PRIMARY KEY");
66525 #endif
66526 }else{
66527 sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0);
 
 
 
 
66528 pList = 0;
66529 }
66530
66531 primary_key_exit:
66532 sqlite3ExprListDelete(pParse->db, pList);
@@ -67411,10 +67838,11 @@
67411 #ifndef SQLITE_OMIT_VIRTUALTABLE
67412 if( IsVirtual(pTab) ){
67413 sqlite3VdbeAddOp0(v, OP_VBegin);
67414 }
67415 #endif
 
67416
67417 /* Drop all triggers associated with the table being dropped. Code
67418 ** is generated to remove entries from sqlite_master and/or
67419 ** sqlite_temp_master if required.
67420 */
@@ -67501,10 +67929,11 @@
67501 int flags /* Conflict resolution algorithms. */
67502 ){
67503 sqlite3 *db = pParse->db;
67504 #ifndef SQLITE_OMIT_FOREIGN_KEY
67505 FKey *pFKey = 0;
 
67506 Table *p = pParse->pNewTable;
67507 int nByte;
67508 int i;
67509 int nCol;
67510 char *z;
@@ -67575,13 +68004,25 @@
67575 z[n] = 0;
67576 z += n+1;
67577 }
67578 }
67579 pFKey->isDeferred = 0;
67580 pFKey->deleteConf = (u8)(flags & 0xff);
67581 pFKey->updateConf = (u8)((flags >> 8 ) & 0xff);
67582 pFKey->insertConf = (u8)((flags >> 16 ) & 0xff);
 
 
 
 
 
 
 
 
 
 
 
 
67583
67584 /* Link the foreign key to the table as the last step.
67585 */
67586 p->pFKey = pFKey;
67587 pFKey = 0;
@@ -67603,11 +68044,11 @@
67603 SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse *pParse, int isDeferred){
67604 #ifndef SQLITE_OMIT_FOREIGN_KEY
67605 Table *pTab;
67606 FKey *pFKey;
67607 if( (pTab = pParse->pNewTable)==0 || (pFKey = pTab->pFKey)==0 ) return;
67608 assert( isDeferred==0 || isDeferred==1 );
67609 pFKey->isDeferred = (u8)isDeferred;
67610 #endif
67611 }
67612
67613 /*
@@ -67698,12 +68139,16 @@
67698 ** currently being constructed by a CREATE TABLE statement.
67699 **
67700 ** pList is a list of columns to be indexed. pList will be NULL if this
67701 ** is a primary key or unique-constraint on the most recent column added
67702 ** to the table currently under construction.
 
 
 
 
67703 */
67704 SQLITE_PRIVATE void sqlite3CreateIndex(
67705 Parse *pParse, /* All information about this parse */
67706 Token *pName1, /* First part of index name. May be NULL */
67707 Token *pName2, /* Second part of index name. May be NULL */
67708 SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
67709 ExprList *pList, /* A list of columns to be indexed */
@@ -67711,10 +68156,11 @@
67711 Token *pStart, /* The CREATE token that begins this statement */
67712 Token *pEnd, /* The ")" that closes the CREATE INDEX statement */
67713 int sortOrder, /* Sort order of primary key when pList==NULL */
67714 int ifNotExist /* Omit error if index already exists */
67715 ){
 
67716 Table *pTab = 0; /* Table to be indexed */
67717 Index *pIndex = 0; /* The index to be created */
67718 char *zName = 0; /* Name of the index */
67719 int nName; /* Number of characters in zName */
67720 int i, j;
@@ -68146,10 +68592,11 @@
68146 pOther = pOther->pNext;
68147 }
68148 pIndex->pNext = pOther->pNext;
68149 pOther->pNext = pIndex;
68150 }
 
68151 pIndex = 0;
68152 }
68153
68154 /* Clean up before exiting */
68155 exit_create_index:
@@ -68158,11 +68605,11 @@
68158 sqlite3DbFree(db, pIndex);
68159 }
68160 sqlite3ExprListDelete(db, pList);
68161 sqlite3SrcListDelete(db, pTblName);
68162 sqlite3DbFree(db, zName);
68163 return;
68164 }
68165
68166 /*
68167 ** Fill the Index.aiRowEst[] array with default information - information
68168 ** to be used when we have not run the ANALYZE command.
@@ -68823,14 +69270,38 @@
68823 Parse *pToplevel = sqlite3ParseToplevel(pParse);
68824 sqlite3CodeVerifySchema(pParse, iDb);
68825 pToplevel->writeMask |= 1<<iDb;
68826 pToplevel->isMultiWrite |= setStatement;
68827 }
 
 
 
 
 
 
 
 
 
 
 
 
68828
68829 /*
68830 ** Set the "may throw abort exception" flag for the statement currently
68831 ** being coded.
 
 
 
 
 
 
 
 
 
 
 
 
68832 */
68833 SQLITE_PRIVATE void sqlite3MayAbort(Parse *pParse){
68834 Parse *pToplevel = sqlite3ParseToplevel(pParse);
68835 pToplevel->mayAbort = 1;
68836 }
@@ -69437,10 +69908,11 @@
69437 Table *pTab = sqliteHashData(pElem);
69438 assert( pTab->dbMem==0 );
69439 sqlite3DeleteTable(pTab);
69440 }
69441 sqlite3HashClear(&temp1);
 
69442 pSchema->pSeqTab = 0;
69443 pSchema->flags &= ~DB_SchemaLoaded;
69444 }
69445
69446 /*
@@ -69458,10 +69930,11 @@
69458 db->mallocFailed = 1;
69459 }else if ( 0==p->file_format ){
69460 sqlite3HashInit(&p->tblHash);
69461 sqlite3HashInit(&p->idxHash);
69462 sqlite3HashInit(&p->trigHash);
 
69463 p->enc = SQLITE_UTF8;
69464 }
69465 return p;
69466 }
69467
@@ -69774,11 +70247,11 @@
69774 v = sqlite3GetVdbe(pParse);
69775 if( v==0 ){
69776 goto delete_from_cleanup;
69777 }
69778 if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);
69779 sqlite3BeginWriteOperation(pParse, (pTrigger?1:0), iDb);
69780
69781 /* If we are trying to delete from a view, realize that view into
69782 ** a ephemeral table.
69783 */
69784 #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
@@ -69807,11 +70280,13 @@
69807 #ifndef SQLITE_OMIT_TRUNCATE_OPTIMIZATION
69808 /* Special case: A DELETE without a WHERE clause deletes everything.
69809 ** It is easier just to erase the whole table. Prior to version 3.6.5,
69810 ** this optimization caused the row change count (the value returned by
69811 ** API function sqlite3_count_changes) to be set incorrectly. */
69812 if( rcauth==SQLITE_OK && pWhere==0 && !pTrigger && !IsVirtual(pTab) ){
 
 
69813 assert( !isView );
69814 sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt,
69815 pTab->zName, P4_STATIC);
69816 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
69817 assert( pIdx->pSchema==pTab->pSchema );
@@ -69903,20 +70378,29 @@
69903 sqlite3AuthContextPop(&sContext);
69904 sqlite3SrcListDelete(db, pTabList);
69905 sqlite3ExprDelete(db, pWhere);
69906 return;
69907 }
 
 
 
 
 
 
 
 
 
69908
69909 /*
69910 ** This routine generates VDBE code that causes a single row of a
69911 ** single table to be deleted.
69912 **
69913 ** The VDBE must be in a particular state when this routine is called.
69914 ** These are the requirements:
69915 **
69916 ** 1. A read/write cursor pointing to pTab, the table containing the row
69917 ** to be deleted, must be opened as cursor number "base".
69918 **
69919 ** 2. Read/write cursors for all indices of pTab must be open as
69920 ** cursor number base+i for the i-th index.
69921 **
69922 ** 3. The record number of the row to be deleted must be stored in
@@ -69947,17 +70431,18 @@
69947 iLabel = sqlite3VdbeMakeLabel(v);
69948 sqlite3VdbeAddOp3(v, OP_NotExists, iCur, iLabel, iRowid);
69949
69950 /* If there are any triggers to fire, allocate a range of registers to
69951 ** use for the old.* references in the triggers. */
69952 if( pTrigger ){
69953 u32 mask; /* Mask of OLD.* columns in use */
69954 int iCol; /* Iterator used while populating OLD.* */
69955
69956 /* TODO: Could use temporary registers here. Also could attempt to
69957 ** avoid copying the contents of the rowid register. */
69958 mask = sqlite3TriggerOldmask(pParse, pTrigger, TK_DELETE, 0, pTab, onconf);
 
69959 iOld = pParse->nMem+1;
69960 pParse->nMem += (1 + pTab->nCol);
69961
69962 /* Populate the OLD.* pseudo-table register array. These values will be
69963 ** used by any BEFORE and AFTER triggers that exist. */
@@ -69968,20 +70453,25 @@
69968 sqlite3VdbeAddOp3(v, OP_Column, iCur, iCol, iTarget);
69969 sqlite3ColumnDefault(v, pTab, iCol, iTarget);
69970 }
69971 }
69972
69973 /* Invoke any BEFORE trigger programs */
69974 sqlite3CodeRowTrigger(pParse, pTrigger,
69975 TK_DELETE, 0, TRIGGER_BEFORE, pTab, -1, iOld, onconf, iLabel
69976 );
69977
69978 /* Seek the cursor to the row to be deleted again. It may be that
69979 ** the BEFORE triggers coded above have already removed the row
69980 ** being deleted. Do not attempt to delete the row a second time, and
69981 ** do not fire AFTER triggers. */
69982 sqlite3VdbeAddOp3(v, OP_NotExists, iCur, iLabel, iRowid);
 
 
 
 
 
69983 }
69984
69985 /* Delete the index and table entries. Skip this step if pTab is really
69986 ** a view (in which case the only effect of the DELETE statement is to
69987 ** fire the INSTEAD OF triggers). */
@@ -69991,16 +70481,19 @@
69991 if( count ){
69992 sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_STATIC);
69993 }
69994 }
69995
69996 /* Invoke AFTER triggers. */
69997 if( pTrigger ){
69998 sqlite3CodeRowTrigger(pParse, pTrigger,
69999 TK_DELETE, 0, TRIGGER_AFTER, pTab, -1, iOld, onconf, iLabel
70000 );
70001 }
 
 
 
70002
70003 /* Jump here if the row had already been deleted before any BEFORE
70004 ** trigger programs were invoked. Or if a trigger program throws a
70005 ** RAISE(IGNORE) exception. */
70006 sqlite3VdbeResolveLabel(v, iLabel);
@@ -70082,14 +70575,10 @@
70082 }
70083 sqlite3ReleaseTempRange(pParse, regBase, nCol+1);
70084 return regBase;
70085 }
70086
70087 /* Make sure "isView" gets undefined in case this file becomes part of
70088 ** the amalgamation - so that subsequent files do not see isView as a
70089 ** macro. */
70090 #undef isView
70091
70092 /************** End of delete.c **********************************************/
70093 /************** Begin file func.c ********************************************/
70094 /*
70095 ** 2002 February 23
@@ -71576,10 +72065,1203 @@
71576 }
71577 sqlite3RegisterDateTimeFunctions();
71578 }
71579
71580 /************** End of func.c ************************************************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71581 /************** Begin file insert.c ******************************************/
71582 /*
71583 ** 2001 September 15
71584 **
71585 ** The author disclaims copyright to this source code. In place of
@@ -72448,11 +74130,11 @@
72448 sqlite3TableAffinityStr(v, pTab);
72449 }
72450
72451 /* Fire BEFORE or INSTEAD OF triggers */
72452 sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_BEFORE,
72453 pTab, -1, regCols-pTab->nCol-1, onError, endOfLoop);
72454
72455 sqlite3ReleaseTempRange(pParse, regCols, pTab->nCol+1);
72456 }
72457
72458 /* Push the record number for the new entry onto the stack. The
@@ -72557,10 +74239,11 @@
72557 {
72558 int isReplace; /* Set to true if constraints may cause a replace */
72559 sqlite3GenerateConstraintChecks(pParse, pTab, baseCur, regIns, aRegIdx,
72560 keyColumn>=0, 0, onError, endOfLoop, &isReplace
72561 );
 
72562 sqlite3CompleteInsertion(
72563 pParse, pTab, baseCur, regIns, aRegIdx, 0, appendFlag, isReplace==0
72564 );
72565 }
72566 }
@@ -72572,11 +74255,11 @@
72572 }
72573
72574 if( pTrigger ){
72575 /* Code AFTER triggers */
72576 sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_AFTER,
72577 pTab, -1, regData-2-pTab->nCol, onError, endOfLoop);
72578 }
72579
72580 /* The bottom of the main insertion loop, if the data source
72581 ** is a SELECT statement.
72582 */
@@ -72623,10 +74306,24 @@
72623 sqlite3ExprListDelete(db, pList);
72624 sqlite3SelectDelete(db, pSelect);
72625 sqlite3IdListDelete(db, pColumn);
72626 sqlite3DbFree(db, aRegIdx);
72627 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72628
72629 /*
72630 ** Generate code to do constraint checks prior to an INSERT or an UPDATE.
72631 **
72632 ** The input is a range of consecutive registers as follows:
@@ -72803,61 +74500,60 @@
72803 onError = overrideError;
72804 }else if( onError==OE_Default ){
72805 onError = OE_Abort;
72806 }
72807
72808 if( onError!=OE_Replace || pTab->pIndex ){
72809 if( isUpdate ){
72810 j2 = sqlite3VdbeAddOp3(v, OP_Eq, regRowid, 0, rowidChng);
72811 }
72812 j3 = sqlite3VdbeAddOp3(v, OP_NotExists, baseCur, 0, regRowid);
72813 switch( onError ){
72814 default: {
72815 onError = OE_Abort;
72816 /* Fall thru into the next case */
72817 }
72818 case OE_Rollback:
72819 case OE_Abort:
72820 case OE_Fail: {
72821 sqlite3HaltConstraint(
72822 pParse, onError, "PRIMARY KEY must be unique", P4_STATIC);
72823 break;
72824 }
72825 case OE_Replace: {
72826 /* If there are DELETE triggers on this table and the
72827 ** recursive-triggers flag is set, call GenerateRowDelete() to
72828 ** remove the conflicting row from the the table. This will fire
72829 ** the triggers and remove both the table and index b-tree entries.
72830 **
72831 ** Otherwise, if there are no triggers or the recursive-triggers
72832 ** flag is not set, call GenerateRowIndexDelete(). This removes
72833 ** the index b-tree entries only. The table b-tree entry will be
72834 ** replaced by the new entry when it is inserted. */
72835 Trigger *pTrigger = 0;
72836 if( pParse->db->flags&SQLITE_RecTriggers ){
72837 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
72838 }
72839 if( pTrigger ){
72840 sqlite3GenerateRowDelete(
72841 pParse, pTab, baseCur, regRowid, 0, pTrigger, OE_Replace
72842 );
72843 }else{
72844 sqlite3GenerateRowIndexDelete(pParse, pTab, baseCur, 0);
72845 }
72846 seenReplace = 1;
72847 break;
72848 }
72849 case OE_Ignore: {
72850 assert( seenReplace==0 );
72851 sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
72852 break;
72853 }
72854 }
72855 sqlite3VdbeJumpHere(v, j3);
72856 if( isUpdate ){
72857 sqlite3VdbeJumpHere(v, j2);
72858 }
72859 }
72860 }
72861
72862 /* Test all UNIQUE constraints by creating entries for each UNIQUE
72863 ** index and making sure that duplicate entries do not already exist.
@@ -72942,10 +74638,11 @@
72942 break;
72943 }
72944 default: {
72945 Trigger *pTrigger = 0;
72946 assert( onError==OE_Replace );
 
72947 if( pParse->db->flags&SQLITE_RecTriggers ){
72948 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
72949 }
72950 sqlite3GenerateRowDelete(
72951 pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace
@@ -72955,11 +74652,11 @@
72955 }
72956 }
72957 sqlite3VdbeJumpHere(v, j3);
72958 sqlite3ReleaseTempReg(pParse, regR);
72959 }
72960
72961 if( pbMayReplace ){
72962 *pbMayReplace = seenReplace;
72963 }
72964 }
72965
@@ -73379,15 +75076,10 @@
73379 return 1;
73380 }
73381 }
73382 #endif /* SQLITE_OMIT_XFER_OPT */
73383
73384 /* Make sure "isView" gets undefined in case this file becomes part of
73385 ** the amalgamation - so that subsequent files do not see isView as a
73386 ** macro. */
73387 #undef isView
73388
73389 /************** End of insert.c **********************************************/
73390 /************** Begin file legacy.c ******************************************/
73391 /*
73392 ** 2001 September 15
73393 **
@@ -74721,10 +76413,16 @@
74721
74722 /* TODO: Maybe it shouldn't be possible to change the ReadUncommitted
74723 ** flag if there are any active statements. */
74724 { "read_uncommitted", SQLITE_ReadUncommitted },
74725 { "recursive_triggers", SQLITE_RecTriggers },
 
 
 
 
 
 
74726 };
74727 int i;
74728 const struct sPragmaType *p;
74729 for(i=0, p=aPragma; i<ArraySize(aPragma); i++, p++){
74730 if( sqlite3StrICmp(zLeft, p->zName)==0 ){
@@ -74734,14 +76432,21 @@
74734 assert( v!=0 ); /* Already allocated by sqlite3Pragma() */
74735 if( ALWAYS(v) ){
74736 if( zRight==0 ){
74737 returnSingleInt(pParse, p->zName, (db->flags & p->mask)!=0 );
74738 }else{
 
 
 
 
 
 
 
74739 if( getBoolean(zRight) ){
74740 db->flags |= p->mask;
74741 }else{
74742 db->flags &= ~p->mask;
74743 }
74744
74745 /* Many of the flag-pragmas modify the code generated by the SQL
74746 ** compiler (eg. count_changes). So add an opcode to expire all
74747 ** compiled SQL statements after modifying a pragma value.
@@ -74758,21 +76463,24 @@
74758 #endif /* SQLITE_OMIT_FLAG_PRAGMAS */
74759
74760 /*
74761 ** Return a human-readable name for a constraint resolution action.
74762 */
 
74763 static const char *actionName(u8 action){
74764 const char *zName;
74765 switch( action ){
74766 case OE_SetNull: zName = "SET NULL"; break;
74767 case OE_SetDflt: zName = "SET DEFAULT"; break;
74768 case OE_Cascade: zName = "CASCADE"; break;
74769 default: zName = "RESTRICT";
74770 assert( action==OE_Restrict ); break;
 
74771 }
74772 return zName;
74773 }
 
74774
74775 /*
74776 ** Process a pragma statement.
74777 **
74778 ** Pragmas are of this form:
@@ -75495,12 +77203,12 @@
75495 sqlite3VdbeSetColName(v, 7, COLNAME_NAME, "match", SQLITE_STATIC);
75496 while(pFK){
75497 int j;
75498 for(j=0; j<pFK->nCol; j++){
75499 char *zCol = pFK->aCol[j].zCol;
75500 char *zOnUpdate = (char *)actionName(pFK->updateConf);
75501 char *zOnDelete = (char *)actionName(pFK->deleteConf);
75502 sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
75503 sqlite3VdbeAddOp2(v, OP_Integer, j, 2);
75504 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pFK->zTo, 0);
75505 sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0,
75506 pTab->aCol[pFK->aCol[j].iFrom].zName, 0);
@@ -81316,10 +83024,14 @@
81316 ** pTab as well as the triggers lised in pTab->pTrigger.
81317 */
81318 SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){
81319 Schema * const pTmpSchema = pParse->db->aDb[1].pSchema;
81320 Trigger *pList = 0; /* List of triggers to return */
 
 
 
 
81321
81322 if( pTmpSchema!=pTab->pSchema ){
81323 HashElem *p;
81324 for(p=sqliteHashFirst(&pTmpSchema->trigHash); p; p=sqliteHashNext(p)){
81325 Trigger *pTrig = (Trigger *)sqliteHashData(p);
@@ -82062,11 +83774,11 @@
82062 NameContext sNC; /* Name context for sub-vdbe */
82063 SubProgram *pProgram = 0; /* Sub-vdbe for trigger program */
82064 Parse *pSubParse; /* Parse context for sub-vdbe */
82065 int iEndTrigger = 0; /* Label to jump to if WHEN is false */
82066
82067 assert( pTab==tableOfTrigger(pTrigger) );
82068
82069 /* Allocate the TriggerPrg and SubProgram objects. To ensure that they
82070 ** are freed if an error occurs, link them into the Parse.pTriggerPrg
82071 ** list of the top-level Parse object sooner rather than later. */
82072 pPrg = sqlite3DbMallocZero(db, sizeof(TriggerPrg));
@@ -82076,10 +83788,11 @@
82076 pPrg->pProgram = pProgram = sqlite3DbMallocZero(db, sizeof(SubProgram));
82077 if( !pProgram ) return 0;
82078 pProgram->nRef = 1;
82079 pPrg->pTrigger = pTrigger;
82080 pPrg->orconf = orconf;
 
82081
82082 /* Allocate and populate a new Parse context to use for coding the
82083 ** trigger sub-program. */
82084 pSubParse = sqlite3StackAllocZero(db, sizeof(Parse));
82085 if( !pSubParse ) return 0;
@@ -82162,11 +83875,11 @@
82162 int orconf /* ON CONFLICT algorithm. */
82163 ){
82164 Parse *pRoot = sqlite3ParseToplevel(pParse);
82165 TriggerPrg *pPrg;
82166
82167 assert( pTab==tableOfTrigger(pTrigger) );
82168
82169 /* It may be that this trigger has already been coded (or is in the
82170 ** process of being coded). If this is the case, then an entry with
82171 ** a matching TriggerPrg.pTrigger field will be present somewhere
82172 ** in the Parse.pTriggerPrg list. Search for such an entry. */
@@ -82182,54 +83895,102 @@
82182
82183 return pPrg;
82184 }
82185
82186 /*
82187 ** This is called to code FOR EACH ROW triggers.
82188 **
82189 ** When the code that this function generates is executed, the following
82190 ** must be true:
82191 **
82192 ** 1. No cursors may be open in the main database. (But newIdx and oldIdx
82193 ** can be indices of cursors in temporary tables. See below.)
82194 **
82195 ** 2. If the triggers being coded are ON INSERT or ON UPDATE triggers, then
82196 ** a temporary vdbe cursor (index newIdx) must be open and pointing at
82197 ** a row containing values to be substituted for new.* expressions in the
82198 ** trigger program(s).
82199 **
82200 ** 3. If the triggers being coded are ON DELETE or ON UPDATE triggers, then
82201 ** a temporary vdbe cursor (index oldIdx) must be open and pointing at
82202 ** a row containing values to be substituted for old.* expressions in the
82203 ** trigger program(s).
82204 **
82205 ** If they are not NULL, the piOldColMask and piNewColMask output variables
82206 ** are set to values that describe the columns used by the trigger program
82207 ** in the OLD.* and NEW.* tables respectively. If column N of the
82208 ** pseudo-table is read at least once, the corresponding bit of the output
82209 ** mask is set. If a column with an index greater than 32 is read, the
82210 ** output mask is set to the special value 0xffffffff.
82211 **
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82212 */
82213 SQLITE_PRIVATE void sqlite3CodeRowTrigger(
82214 Parse *pParse, /* Parse context */
82215 Trigger *pTrigger, /* List of triggers on table pTab */
82216 int op, /* One of TK_UPDATE, TK_INSERT, TK_DELETE */
82217 ExprList *pChanges, /* Changes list for any UPDATE OF triggers */
82218 int tr_tm, /* One of TRIGGER_BEFORE, TRIGGER_AFTER */
82219 Table *pTab, /* The table to code triggers from */
82220 int newIdx, /* The indice of the "new" row to access */
82221 int oldIdx, /* The indice of the "old" row to access */
82222 int orconf, /* ON CONFLICT policy */
82223 int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */
82224 ){
82225 Trigger *p;
82226
82227 UNUSED_PARAMETER(newIdx);
82228
82229 assert(op == TK_UPDATE || op == TK_INSERT || op == TK_DELETE);
82230 assert(tr_tm == TRIGGER_BEFORE || tr_tm == TRIGGER_AFTER );
82231
82232 for(p=pTrigger; p; p=p->pNext){
82233
82234 /* Sanity checking: The schema for the trigger and for the table are
82235 ** always defined. The trigger must be in the same schema as the table
@@ -82240,25 +84001,13 @@
82240 || p->pSchema==pParse->db->aDb[1].pSchema );
82241
82242 /* Determine whether we should code this trigger */
82243 if( p->op==op
82244 && p->tr_tm==tr_tm
82245 && checkColumnOverlap(p->pColumns,pChanges)
82246 ){
82247 Vdbe *v = sqlite3GetVdbe(pParse); /* Main VM */
82248 TriggerPrg *pPrg;
82249 pPrg = getRowTrigger(pParse, p, pTab, orconf);
82250 assert( pPrg || pParse->nErr || pParse->db->mallocFailed );
82251
82252 /* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program
82253 ** is a pointer to the sub-vdbe containing the trigger program. */
82254 if( pPrg ){
82255 sqlite3VdbeAddOp3(v, OP_Program, oldIdx, ignoreJump, ++pParse->nMem);
82256 pPrg->pProgram->nRef++;
82257 sqlite3VdbeChangeP4(v, -1, (const char *)pPrg->pProgram, P4_SUBPROGRAM);
82258 VdbeComment((v, "Call: %s.%s", p->zName, onErrorText(orconf)));
82259 }
82260 }
82261 }
82262 }
82263
82264 /*
@@ -82281,19 +84030,18 @@
82281 ** There is no equivalent function for new.* references.
82282 */
82283 SQLITE_PRIVATE u32 sqlite3TriggerOldmask(
82284 Parse *pParse, /* Parse context */
82285 Trigger *pTrigger, /* List of triggers on table pTab */
82286 int op, /* Either TK_UPDATE or TK_DELETE */
82287 ExprList *pChanges, /* Changes list for any UPDATE OF triggers */
82288 Table *pTab, /* The table to code triggers from */
82289 int orconf /* Default ON CONFLICT policy for trigger steps */
82290 ){
 
82291 u32 mask = 0;
82292 Trigger *p;
82293
82294 assert(op==TK_UPDATE || op==TK_DELETE);
82295 for(p=pTrigger; p; p=p->pNext){
82296 if( p->op==op && checkColumnOverlap(p->pColumns,pChanges) ){
82297 TriggerPrg *pPrg;
82298 pPrg = getRowTrigger(pParse, p, pTab, orconf);
82299 if( pPrg ){
@@ -82423,16 +84171,16 @@
82423 AuthContext sContext; /* The authorization context */
82424 NameContext sNC; /* The name-context to resolve expressions in */
82425 int iDb; /* Database containing the table being updated */
82426 int j1; /* Addresses of jump instructions */
82427 int okOnePass; /* True for one-pass algorithm without the FIFO */
 
82428
82429 #ifndef SQLITE_OMIT_TRIGGER
82430 int isView; /* Trying to update a view */
82431 Trigger *pTrigger; /* List of triggers on pTab, if required */
82432 #endif
82433 u32 oldmask = 0; /* Mask of OLD.* columns in use */
82434
82435 /* Register Allocations */
82436 int regRowCount = 0; /* A count of rows changed */
82437 int regOldRowid; /* The old rowid */
82438 int regNewRowid; /* The new rowid */
@@ -82535,10 +84283,12 @@
82535 aXRef[j] = -1;
82536 }
82537 }
82538 #endif
82539 }
 
 
82540
82541 /* Allocate memory for the array aRegIdx[]. There is one entry in the
82542 ** array for each index associated with table being updated. Fill in
82543 ** the value with a register number for indices that are to be used
82544 ** and with zero for unused indices.
@@ -82581,15 +84331,15 @@
82581 }
82582 #endif
82583
82584 /* Allocate required registers. */
82585 regOldRowid = regNewRowid = ++pParse->nMem;
82586 if( pTrigger ){
82587 regOld = pParse->nMem + 1;
82588 pParse->nMem += pTab->nCol;
82589 }
82590 if( chngRowid || pTrigger ){
82591 regNewRowid = ++pParse->nMem;
82592 }
82593 regNew = pParse->nMem + 1;
82594 pParse->nMem += pTab->nCol;
82595 regRec = ++pParse->nMem;
@@ -82597,14 +84347,10 @@
82597 /* Start the view context. */
82598 if( isView ){
82599 sqlite3AuthContextPush(pParse, &sContext, pTab->zName);
82600 }
82601
82602 /* If there are any triggers, set oldmask and new_col_mask. */
82603 oldmask = sqlite3TriggerOldmask(
82604 pParse, pTrigger, TK_UPDATE, pChanges, pTab, onError);
82605
82606 /* If we are trying to update a view, realize that view into
82607 ** a ephemeral table.
82608 */
82609 #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
82610 if( isView ){
@@ -82685,34 +84431,37 @@
82685
82686 /* Make cursor iCur point to the record that is being updated. If
82687 ** this record does not exist for some reason (deleted by a trigger,
82688 ** for example, then jump to the next iteration of the RowSet loop. */
82689 sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid);
 
 
 
 
 
 
 
 
 
 
82690
82691 /* If there are triggers on this table, populate an array of registers
82692 ** with the required old.* column data. */
82693 if( pTrigger ){
 
 
82694 for(i=0; i<pTab->nCol; i++){
82695 if( aXRef[i]<0 || oldmask==0xffffffff || (oldmask & (1<<i)) ){
82696 sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regOld+i);
82697 sqlite3ColumnDefault(v, pTab, i, regOld+i);
82698 }else{
82699 sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i);
82700 }
82701 }
82702 }
82703
82704 /* If the record number will change, set register regNewRowid to
82705 ** contain the new value. If the record number is not being modified,
82706 ** then regNewRowid is the same register as regOldRowid, which is
82707 ** already populated. */
82708 assert( chngRowid || pTrigger || regOldRowid==regNewRowid );
82709 if( chngRowid ){
82710 sqlite3ExprCode(pParse, pRowidExpr, regNewRowid);
82711 sqlite3VdbeAddOp1(v, OP_MustBeInt, regNewRowid);
82712 }else if( pTrigger ){
82713 sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid);
82714 }
82715
82716 /* Populate the array of registers beginning at regNew with the new
82717 ** row data. This array is used to check constaints, create the new
82718 ** table and index records, and as the values for any new.* references
@@ -82735,11 +84484,11 @@
82735 ** verified. One could argue that this is wrong. */
82736 if( pTrigger ){
82737 sqlite3VdbeAddOp2(v, OP_Affinity, regNew, pTab->nCol);
82738 sqlite3TableAffinityStr(v, pTab);
82739 sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges,
82740 TRIGGER_BEFORE, pTab, -1, regOldRowid, onError, addr);
82741
82742 /* The row-trigger may have deleted the row being updated. In this
82743 ** case, jump to the next row. No updates or AFTER triggers are
82744 ** required. This behaviour - what happens when the row being updated
82745 ** is deleted or renamed by a BEFORE trigger - is left undefined in the
@@ -82750,33 +84499,49 @@
82750 if( !isView ){
82751
82752 /* Do constraint checks. */
82753 sqlite3GenerateConstraintChecks(pParse, pTab, iCur, regNewRowid,
82754 aRegIdx, (chngRowid?regOldRowid:0), 1, onError, addr, 0);
 
 
 
 
 
82755
82756 /* Delete the index entries associated with the current record. */
82757 j1 = sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regOldRowid);
82758 sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, aRegIdx);
82759
82760 /* If changing the record number, delete the old record. */
82761 if( chngRowid ){
82762 sqlite3VdbeAddOp2(v, OP_Delete, iCur, 0);
82763 }
82764 sqlite3VdbeJumpHere(v, j1);
 
 
 
 
82765
82766 /* Insert the new index entries and the new record. */
82767 sqlite3CompleteInsertion(pParse, pTab, iCur, regNewRowid, aRegIdx, 1, 0, 0);
 
 
 
 
 
 
 
82768 }
82769
82770 /* Increment the row counter
82771 */
82772 if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab){
82773 sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);
82774 }
82775
82776 sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges,
82777 TRIGGER_AFTER, pTab, -1, regOldRowid, onError, addr);
82778
82779 /* Repeat the above with the next record to be updated, until
82780 ** all record selected by the WHERE clause have been updated.
82781 */
82782 sqlite3VdbeAddOp2(v, OP_Goto, 0, addr);
@@ -82816,10 +84581,19 @@
82816 sqlite3SrcListDelete(db, pTabList);
82817 sqlite3ExprListDelete(db, pChanges);
82818 sqlite3ExprDelete(db, pWhere);
82819 return;
82820 }
 
 
 
 
 
 
 
 
 
82821
82822 #ifndef SQLITE_OMIT_VIRTUALTABLE
82823 /*
82824 ** Generate code for an UPDATE of a virtual table.
82825 **
@@ -82911,15 +84685,10 @@
82911 /* Cleanup */
82912 sqlite3SelectDelete(db, pSelect);
82913 }
82914 #endif /* SQLITE_OMIT_VIRTUALTABLE */
82915
82916 /* Make sure "isView" gets undefined in case this file becomes part of
82917 ** the amalgamation - so that subsequent files do not see isView as a
82918 ** macro. */
82919 #undef isView
82920
82921 /************** End of update.c **********************************************/
82922 /************** Begin file vacuum.c ******************************************/
82923 /*
82924 ** 2003 April 6
82925 **
@@ -83015,15 +84784,18 @@
83015 if( !db->autoCommit ){
83016 sqlite3SetString(pzErrMsg, db, "cannot VACUUM from within a transaction");
83017 return SQLITE_ERROR;
83018 }
83019
83020 /* Save the current value of the write-schema flag before setting it. */
 
 
83021 saved_flags = db->flags;
83022 saved_nChange = db->nChange;
83023 saved_nTotalChange = db->nTotalChange;
83024 db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
 
83025
83026 pMain = db->aDb[0].pBt;
83027 isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));
83028
83029 /* Attach the temporary database as 'vacuum_db'. The synchronous pragma
@@ -86139,13 +87911,12 @@
86139 for(i=0; i<SQLITE_INDEX_SAMPLES; i++){
86140 int r;
86141 int eSampletype = aSample[i].eType;
86142 if( eSampletype==SQLITE_NULL || eSampletype<eType ) continue;
86143 if( (eSampletype!=eType) ) break;
86144 if( pColl->enc==SQLITE_UTF8 ){
86145 r = pColl->xCmp(pColl->pUser, aSample[i].nByte, aSample[i].u.z, n, z);
86146 }else{
86147 int nSample;
86148 char *zSample = sqlite3Utf8to16(
86149 db, pColl->enc, aSample[i].u.z, aSample[i].nByte, &nSample
86150 );
86151 if( !zSample ){
@@ -86152,10 +87923,14 @@
86152 assert( db->mallocFailed );
86153 return SQLITE_NOMEM;
86154 }
86155 r = pColl->xCmp(pColl->pUser, nSample, zSample, n, z);
86156 sqlite3DbFree(db, zSample);
 
 
 
 
86157 }
86158 if( r>0 ) break;
86159 }
86160 }
86161
@@ -88304,11 +90079,11 @@
88304 ** defined, then do no error processing.
88305 */
88306 #define YYCODETYPE unsigned char
88307 #define YYNOCODE 254
88308 #define YYACTIONTYPE unsigned short int
88309 #define YYWILDCARD 65
88310 #define sqlite3ParserTOKENTYPE Token
88311 typedef union {
88312 int yyinit;
88313 sqlite3ParserTOKENTYPE yy0;
88314 Select* yy3;
@@ -88402,454 +90177,461 @@
88402 ** yy_reduce_ofst[] For each state, the offset into yy_action for
88403 ** shifting non-terminals after a reduce.
88404 ** yy_default[] Default action for each state.
88405 */
88406 static const YYACTIONTYPE yy_action[] = {
88407 /* 0 */ 309, 959, 178, 628, 2, 153, 216, 448, 24, 24,
88408 /* 10 */ 24, 24, 497, 26, 26, 26, 26, 27, 27, 28,
88409 /* 20 */ 28, 28, 29, 218, 422, 423, 214, 422, 423, 455,
88410 /* 30 */ 461, 31, 26, 26, 26, 26, 27, 27, 28, 28,
88411 /* 40 */ 28, 29, 218, 30, 492, 32, 137, 23, 22, 315,
88412 /* 50 */ 465, 466, 462, 462, 25, 25, 24, 24, 24, 24,
88413 /* 60 */ 445, 26, 26, 26, 26, 27, 27, 28, 28, 28,
88414 /* 70 */ 29, 218, 309, 218, 318, 448, 521, 499, 45, 26,
88415 /* 80 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 218,
88416 /* 90 */ 422, 423, 425, 426, 159, 425, 426, 366, 369, 370,
88417 /* 100 */ 318, 455, 461, 394, 523, 21, 188, 504, 371, 27,
88418 /* 110 */ 27, 28, 28, 28, 29, 218, 422, 423, 424, 23,
88419 /* 120 */ 22, 315, 465, 466, 462, 462, 25, 25, 24, 24,
88420 /* 130 */ 24, 24, 564, 26, 26, 26, 26, 27, 27, 28,
88421 /* 140 */ 28, 28, 29, 218, 309, 230, 513, 138, 477, 220,
88422 /* 150 */ 557, 148, 135, 260, 364, 265, 365, 156, 425, 426,
88423 /* 160 */ 245, 610, 337, 30, 269, 32, 137, 448, 608, 609,
88424 /* 170 */ 233, 230, 499, 455, 461, 57, 515, 334, 135, 260,
88425 /* 180 */ 364, 265, 365, 156, 425, 426, 444, 78, 417, 414,
88426 /* 190 */ 269, 23, 22, 315, 465, 466, 462, 462, 25, 25,
88427 /* 200 */ 24, 24, 24, 24, 348, 26, 26, 26, 26, 27,
88428 /* 210 */ 27, 28, 28, 28, 29, 218, 309, 216, 543, 556,
88429 /* 220 */ 486, 130, 498, 607, 30, 337, 32, 137, 351, 396,
88430 /* 230 */ 438, 63, 337, 361, 424, 448, 487, 337, 424, 544,
88431 /* 240 */ 334, 217, 195, 606, 605, 455, 461, 334, 18, 444,
88432 /* 250 */ 85, 488, 334, 347, 192, 565, 444, 78, 316, 472,
88433 /* 260 */ 473, 444, 85, 23, 22, 315, 465, 466, 462, 462,
88434 /* 270 */ 25, 25, 24, 24, 24, 24, 445, 26, 26, 26,
88435 /* 280 */ 26, 27, 27, 28, 28, 28, 29, 218, 309, 353,
88436 /* 290 */ 223, 320, 607, 193, 238, 337, 481, 16, 351, 185,
88437 /* 300 */ 330, 419, 222, 350, 604, 219, 215, 424, 112, 337,
88438 /* 310 */ 334, 157, 606, 408, 213, 563, 538, 455, 461, 444,
88439 /* 320 */ 79, 219, 562, 524, 334, 576, 522, 629, 417, 414,
88440 /* 330 */ 450, 581, 441, 444, 78, 23, 22, 315, 465, 466,
88441 /* 340 */ 462, 462, 25, 25, 24, 24, 24, 24, 445, 26,
88442 /* 350 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 218,
88443 /* 360 */ 309, 452, 452, 452, 159, 399, 311, 366, 369, 370,
88444 /* 370 */ 337, 251, 404, 407, 219, 355, 556, 4, 371, 422,
88445 /* 380 */ 423, 397, 286, 285, 244, 334, 540, 566, 63, 455,
88446 /* 390 */ 461, 424, 216, 478, 444, 93, 28, 28, 28, 29,
88447 /* 400 */ 218, 413, 477, 220, 578, 40, 545, 23, 22, 315,
88448 /* 410 */ 465, 466, 462, 462, 25, 25, 24, 24, 24, 24,
88449 /* 420 */ 582, 26, 26, 26, 26, 27, 27, 28, 28, 28,
88450 /* 430 */ 29, 218, 309, 546, 337, 30, 517, 32, 137, 378,
88451 /* 440 */ 326, 337, 874, 153, 194, 448, 1, 425, 426, 334,
88452 /* 450 */ 422, 423, 422, 423, 29, 218, 334, 613, 444, 71,
88453 /* 460 */ 210, 455, 461, 66, 581, 444, 93, 422, 423, 626,
88454 /* 470 */ 949, 303, 949, 500, 479, 555, 202, 43, 445, 23,
88455 /* 480 */ 22, 315, 465, 466, 462, 462, 25, 25, 24, 24,
88456 /* 490 */ 24, 24, 436, 26, 26, 26, 26, 27, 27, 28,
88457 /* 500 */ 28, 28, 29, 218, 309, 187, 211, 360, 520, 440,
88458 /* 510 */ 246, 327, 622, 448, 397, 286, 285, 551, 425, 426,
88459 /* 520 */ 425, 426, 334, 159, 337, 216, 366, 369, 370, 494,
88460 /* 530 */ 556, 444, 9, 455, 461, 425, 426, 371, 495, 334,
88461 /* 540 */ 445, 618, 63, 504, 198, 424, 501, 449, 444, 72,
88462 /* 550 */ 474, 23, 22, 315, 465, 466, 462, 462, 25, 25,
88463 /* 560 */ 24, 24, 24, 24, 395, 26, 26, 26, 26, 27,
88464 /* 570 */ 27, 28, 28, 28, 29, 218, 309, 486, 445, 337,
88465 /* 580 */ 537, 60, 224, 479, 343, 202, 398, 337, 439, 554,
88466 /* 590 */ 199, 140, 337, 487, 334, 526, 527, 551, 516, 508,
88467 /* 600 */ 456, 457, 334, 444, 67, 455, 461, 334, 488, 476,
88468 /* 610 */ 528, 444, 76, 39, 424, 41, 444, 97, 579, 527,
88469 /* 620 */ 529, 459, 460, 23, 22, 315, 465, 466, 462, 462,
88470 /* 630 */ 25, 25, 24, 24, 24, 24, 337, 26, 26, 26,
88471 /* 640 */ 26, 27, 27, 28, 28, 28, 29, 218, 309, 337,
88472 /* 650 */ 458, 334, 272, 621, 307, 337, 312, 337, 374, 64,
88473 /* 660 */ 444, 96, 317, 448, 334, 342, 472, 473, 469, 337,
88474 /* 670 */ 334, 508, 334, 444, 101, 359, 252, 455, 461, 444,
88475 /* 680 */ 99, 444, 104, 358, 334, 345, 424, 340, 157, 468,
88476 /* 690 */ 468, 424, 493, 444, 105, 23, 22, 315, 465, 466,
88477 /* 700 */ 462, 462, 25, 25, 24, 24, 24, 24, 337, 26,
88478 /* 710 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 218,
88479 /* 720 */ 309, 337, 181, 334, 499, 56, 139, 337, 219, 268,
88480 /* 730 */ 384, 448, 444, 129, 382, 387, 334, 168, 337, 389,
88481 /* 740 */ 508, 424, 334, 311, 424, 444, 131, 496, 269, 455,
88482 /* 750 */ 461, 444, 59, 334, 424, 424, 391, 340, 8, 468,
88483 /* 760 */ 468, 263, 444, 102, 390, 290, 321, 23, 22, 315,
88484 /* 770 */ 465, 466, 462, 462, 25, 25, 24, 24, 24, 24,
88485 /* 780 */ 337, 26, 26, 26, 26, 27, 27, 28, 28, 28,
88486 /* 790 */ 29, 218, 309, 337, 138, 334, 416, 2, 268, 337,
88487 /* 800 */ 389, 337, 443, 325, 444, 77, 442, 293, 334, 291,
88488 /* 810 */ 7, 482, 337, 424, 334, 424, 334, 444, 100, 499,
88489 /* 820 */ 339, 455, 461, 444, 68, 444, 98, 334, 254, 504,
88490 /* 830 */ 232, 626, 948, 504, 948, 231, 444, 132, 47, 23,
88491 /* 840 */ 22, 315, 465, 466, 462, 462, 25, 25, 24, 24,
88492 /* 850 */ 24, 24, 337, 26, 26, 26, 26, 27, 27, 28,
88493 /* 860 */ 28, 28, 29, 218, 309, 337, 280, 334, 256, 538,
88494 /* 870 */ 362, 337, 258, 268, 622, 549, 444, 133, 203, 140,
88495 /* 880 */ 334, 424, 548, 337, 180, 158, 334, 292, 424, 444,
88496 /* 890 */ 134, 287, 552, 455, 461, 444, 69, 443, 334, 463,
88497 /* 900 */ 340, 442, 468, 468, 427, 428, 429, 444, 80, 281,
88498 /* 910 */ 322, 23, 33, 315, 465, 466, 462, 462, 25, 25,
88499 /* 920 */ 24, 24, 24, 24, 337, 26, 26, 26, 26, 27,
88500 /* 930 */ 27, 28, 28, 28, 29, 218, 309, 337, 406, 334,
88501 /* 940 */ 212, 268, 550, 337, 268, 389, 329, 177, 444, 81,
88502 /* 950 */ 542, 541, 334, 475, 475, 337, 424, 216, 334, 424,
88503 /* 960 */ 424, 444, 70, 535, 368, 455, 461, 444, 82, 405,
88504 /* 970 */ 334, 261, 392, 340, 445, 468, 468, 587, 323, 444,
88505 /* 980 */ 83, 324, 262, 288, 22, 315, 465, 466, 462, 462,
88506 /* 990 */ 25, 25, 24, 24, 24, 24, 337, 26, 26, 26,
88507 /* 1000 */ 26, 27, 27, 28, 28, 28, 29, 218, 309, 337,
88508 /* 1010 */ 211, 334, 294, 356, 340, 337, 468, 468, 532, 533,
88509 /* 1020 */ 444, 84, 403, 144, 334, 574, 600, 337, 424, 573,
88510 /* 1030 */ 334, 337, 420, 444, 86, 253, 234, 455, 461, 444,
88511 /* 1040 */ 87, 430, 334, 383, 445, 431, 334, 274, 196, 331,
88512 /* 1050 */ 424, 444, 88, 432, 145, 444, 73, 315, 465, 466,
88513 /* 1060 */ 462, 462, 25, 25, 24, 24, 24, 24, 395, 26,
88514 /* 1070 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 218,
88515 /* 1080 */ 35, 344, 445, 3, 337, 394, 337, 333, 423, 278,
88516 /* 1090 */ 388, 276, 280, 207, 147, 35, 344, 341, 3, 334,
88517 /* 1100 */ 424, 334, 333, 423, 308, 623, 280, 424, 444, 74,
88518 /* 1110 */ 444, 89, 341, 337, 6, 346, 338, 337, 421, 337,
88519 /* 1120 */ 470, 424, 65, 332, 280, 481, 446, 445, 334, 247,
88520 /* 1130 */ 346, 424, 334, 424, 334, 594, 280, 444, 90, 424,
88521 /* 1140 */ 481, 444, 91, 444, 92, 38, 37, 625, 337, 410,
88522 /* 1150 */ 47, 424, 237, 280, 36, 335, 336, 354, 248, 450,
88523 /* 1160 */ 38, 37, 514, 334, 572, 381, 572, 596, 424, 36,
88524 /* 1170 */ 335, 336, 444, 75, 450, 200, 506, 216, 154, 597,
88525 /* 1180 */ 239, 240, 241, 146, 243, 249, 547, 593, 158, 433,
88526 /* 1190 */ 452, 452, 452, 453, 454, 10, 598, 280, 20, 46,
88527 /* 1200 */ 174, 412, 298, 337, 424, 452, 452, 452, 453, 454,
88528 /* 1210 */ 10, 299, 424, 35, 344, 352, 3, 250, 334, 434,
88529 /* 1220 */ 333, 423, 337, 172, 280, 581, 208, 444, 17, 171,
88530 /* 1230 */ 341, 19, 173, 447, 424, 422, 423, 334, 337, 424,
88531 /* 1240 */ 235, 280, 204, 205, 206, 42, 444, 94, 346, 435,
88532 /* 1250 */ 136, 451, 221, 334, 308, 624, 424, 349, 481, 490,
88533 /* 1260 */ 445, 152, 444, 95, 424, 424, 424, 236, 503, 491,
88534 /* 1270 */ 507, 179, 424, 481, 424, 402, 295, 285, 38, 37,
88535 /* 1280 */ 271, 310, 158, 424, 296, 424, 216, 36, 335, 336,
88536 /* 1290 */ 509, 266, 450, 190, 191, 539, 267, 625, 558, 273,
88537 /* 1300 */ 275, 48, 277, 522, 279, 424, 424, 450, 255, 409,
88538 /* 1310 */ 424, 424, 257, 424, 424, 424, 284, 424, 386, 424,
88539 /* 1320 */ 357, 584, 585, 452, 452, 452, 453, 454, 10, 259,
88540 /* 1330 */ 393, 424, 289, 424, 592, 603, 424, 424, 452, 452,
88541 /* 1340 */ 452, 297, 300, 301, 505, 424, 617, 424, 363, 424,
88542 /* 1350 */ 424, 373, 577, 158, 158, 511, 424, 424, 424, 525,
88543 /* 1360 */ 588, 424, 154, 589, 601, 54, 54, 620, 512, 306,
88544 /* 1370 */ 319, 530, 531, 535, 264, 107, 228, 536, 534, 375,
88545 /* 1380 */ 559, 304, 560, 561, 305, 227, 229, 553, 567, 161,
88546 /* 1390 */ 162, 379, 377, 163, 51, 209, 569, 282, 164, 570,
88547 /* 1400 */ 385, 143, 580, 116, 119, 183, 400, 590, 401, 121,
88548 /* 1410 */ 122, 123, 124, 126, 599, 328, 614, 55, 58, 615,
88549 /* 1420 */ 616, 619, 62, 418, 103, 226, 111, 176, 242, 182,
88550 /* 1430 */ 437, 313, 201, 314, 670, 671, 672, 149, 150, 467,
88551 /* 1440 */ 464, 34, 483, 471, 480, 184, 197, 502, 484, 5,
88552 /* 1450 */ 485, 151, 489, 44, 141, 11, 106, 160, 225, 518,
88553 /* 1460 */ 519, 49, 510, 108, 367, 270, 12, 155, 109, 50,
88554 /* 1470 */ 110, 262, 376, 186, 568, 113, 142, 154, 165, 115,
88555 /* 1480 */ 15, 283, 583, 166, 167, 380, 586, 117, 13, 120,
88556 /* 1490 */ 372, 52, 53, 118, 591, 169, 114, 170, 595, 125,
88557 /* 1500 */ 127, 571, 575, 602, 14, 128, 611, 612, 61, 175,
88558 /* 1510 */ 189, 415, 302, 627, 960, 960, 960, 960, 411,
 
 
 
88559 };
88560 static const YYCODETYPE yy_lookahead[] = {
88561 /* 0 */ 19, 142, 143, 144, 145, 24, 116, 26, 75, 76,
88562 /* 10 */ 77, 78, 25, 80, 81, 82, 83, 84, 85, 86,
88563 /* 20 */ 87, 88, 89, 90, 26, 27, 160, 26, 27, 48,
88564 /* 30 */ 49, 79, 80, 81, 82, 83, 84, 85, 86, 87,
88565 /* 40 */ 88, 89, 90, 222, 223, 224, 225, 66, 67, 68,
88566 /* 50 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
88567 /* 60 */ 194, 80, 81, 82, 83, 84, 85, 86, 87, 88,
88568 /* 70 */ 89, 90, 19, 90, 19, 94, 174, 25, 25, 80,
88569 /* 80 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
88570 /* 90 */ 26, 27, 94, 95, 96, 94, 95, 99, 100, 101,
88571 /* 100 */ 19, 48, 49, 150, 174, 52, 119, 166, 110, 84,
88572 /* 110 */ 85, 86, 87, 88, 89, 90, 26, 27, 165, 66,
88573 /* 120 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
88574 /* 130 */ 77, 78, 186, 80, 81, 82, 83, 84, 85, 86,
88575 /* 140 */ 87, 88, 89, 90, 19, 90, 205, 95, 84, 85,
88576 /* 150 */ 186, 96, 97, 98, 99, 100, 101, 102, 94, 95,
88577 /* 160 */ 195, 97, 150, 222, 109, 224, 225, 26, 104, 105,
88578 /* 170 */ 217, 90, 120, 48, 49, 50, 86, 165, 97, 98,
88579 /* 180 */ 99, 100, 101, 102, 94, 95, 174, 175, 1, 2,
88580 /* 190 */ 109, 66, 67, 68, 69, 70, 71, 72, 73, 74,
88581 /* 200 */ 75, 76, 77, 78, 191, 80, 81, 82, 83, 84,
88582 /* 210 */ 85, 86, 87, 88, 89, 90, 19, 116, 35, 150,
88583 /* 220 */ 12, 24, 208, 150, 222, 150, 224, 225, 216, 128,
88584 /* 230 */ 161, 162, 150, 221, 165, 94, 28, 150, 165, 56,
88585 /* 240 */ 165, 197, 160, 170, 171, 48, 49, 165, 204, 174,
88586 /* 250 */ 175, 43, 165, 45, 185, 186, 174, 175, 169, 170,
88587 /* 260 */ 171, 174, 175, 66, 67, 68, 69, 70, 71, 72,
88588 /* 270 */ 73, 74, 75, 76, 77, 78, 194, 80, 81, 82,
88589 /* 280 */ 83, 84, 85, 86, 87, 88, 89, 90, 19, 214,
88590 /* 290 */ 215, 108, 150, 25, 148, 150, 64, 22, 216, 24,
88591 /* 300 */ 146, 147, 215, 221, 231, 232, 152, 165, 154, 150,
88592 /* 310 */ 165, 49, 170, 171, 160, 181, 182, 48, 49, 174,
88593 /* 320 */ 175, 232, 188, 165, 165, 21, 94, 0, 1, 2,
88594 /* 330 */ 98, 55, 174, 174, 175, 66, 67, 68, 69, 70,
88595 /* 340 */ 71, 72, 73, 74, 75, 76, 77, 78, 194, 80,
88596 /* 350 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
88597 /* 360 */ 19, 129, 130, 131, 96, 61, 104, 99, 100, 101,
88598 /* 370 */ 150, 226, 218, 231, 232, 216, 150, 196, 110, 26,
88599 /* 380 */ 27, 105, 106, 107, 158, 165, 183, 161, 162, 48,
88600 /* 390 */ 49, 165, 116, 166, 174, 175, 86, 87, 88, 89,
88601 /* 400 */ 90, 247, 84, 85, 100, 136, 183, 66, 67, 68,
88602 /* 410 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
88603 /* 420 */ 11, 80, 81, 82, 83, 84, 85, 86, 87, 88,
88604 /* 430 */ 89, 90, 19, 183, 150, 222, 23, 224, 225, 237,
88605 /* 440 */ 220, 150, 138, 24, 160, 26, 22, 94, 95, 165,
88606 /* 450 */ 26, 27, 26, 27, 89, 90, 165, 244, 174, 175,
88607 /* 460 */ 236, 48, 49, 22, 55, 174, 175, 26, 27, 22,
88608 /* 470 */ 23, 163, 25, 120, 166, 167, 168, 136, 194, 66,
88609 /* 480 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
88610 /* 490 */ 77, 78, 153, 80, 81, 82, 83, 84, 85, 86,
88611 /* 500 */ 87, 88, 89, 90, 19, 196, 160, 150, 23, 173,
88612 /* 510 */ 198, 220, 65, 94, 105, 106, 107, 181, 94, 95,
88613 /* 520 */ 94, 95, 165, 96, 150, 116, 99, 100, 101, 31,
88614 /* 530 */ 150, 174, 175, 48, 49, 94, 95, 110, 40, 165,
88615 /* 540 */ 194, 161, 162, 166, 160, 165, 120, 166, 174, 175,
88616 /* 550 */ 233, 66, 67, 68, 69, 70, 71, 72, 73, 74,
88617 /* 560 */ 75, 76, 77, 78, 218, 80, 81, 82, 83, 84,
88618 /* 570 */ 85, 86, 87, 88, 89, 90, 19, 12, 194, 150,
88619 /* 580 */ 23, 235, 205, 166, 167, 168, 240, 150, 172, 173,
88620 /* 590 */ 206, 207, 150, 28, 165, 190, 191, 181, 23, 150,
88621 /* 600 */ 48, 49, 165, 174, 175, 48, 49, 165, 43, 233,
88622 /* 610 */ 45, 174, 175, 135, 165, 137, 174, 175, 190, 191,
88623 /* 620 */ 55, 69, 70, 66, 67, 68, 69, 70, 71, 72,
88624 /* 630 */ 73, 74, 75, 76, 77, 78, 150, 80, 81, 82,
88625 /* 640 */ 83, 84, 85, 86, 87, 88, 89, 90, 19, 150,
88626 /* 650 */ 98, 165, 23, 250, 251, 150, 155, 150, 19, 22,
88627 /* 660 */ 174, 175, 213, 26, 165, 169, 170, 171, 23, 150,
88628 /* 670 */ 165, 150, 165, 174, 175, 19, 150, 48, 49, 174,
88629 /* 680 */ 175, 174, 175, 27, 165, 228, 165, 112, 49, 114,
88630 /* 690 */ 115, 165, 177, 174, 175, 66, 67, 68, 69, 70,
88631 /* 700 */ 71, 72, 73, 74, 75, 76, 77, 78, 150, 80,
88632 /* 710 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
88633 /* 720 */ 19, 150, 23, 165, 25, 24, 150, 150, 232, 150,
88634 /* 730 */ 229, 94, 174, 175, 213, 234, 165, 25, 150, 150,
88635 /* 740 */ 150, 165, 165, 104, 165, 174, 175, 177, 109, 48,
88636 /* 750 */ 49, 174, 175, 165, 165, 165, 19, 112, 22, 114,
88637 /* 760 */ 115, 177, 174, 175, 27, 16, 187, 66, 67, 68,
88638 /* 770 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
88639 /* 780 */ 150, 80, 81, 82, 83, 84, 85, 86, 87, 88,
88640 /* 790 */ 89, 90, 19, 150, 95, 165, 144, 145, 150, 150,
88641 /* 800 */ 150, 150, 113, 213, 174, 175, 117, 58, 165, 60,
88642 /* 810 */ 74, 23, 150, 165, 165, 165, 165, 174, 175, 120,
88643 /* 820 */ 19, 48, 49, 174, 175, 174, 175, 165, 209, 166,
88644 /* 830 */ 241, 22, 23, 166, 25, 187, 174, 175, 126, 66,
88645 /* 840 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
88646 /* 850 */ 77, 78, 150, 80, 81, 82, 83, 84, 85, 86,
88647 /* 860 */ 87, 88, 89, 90, 19, 150, 150, 165, 205, 182,
88648 /* 870 */ 86, 150, 205, 150, 65, 166, 174, 175, 206, 207,
88649 /* 880 */ 165, 165, 177, 150, 23, 25, 165, 138, 165, 174,
88650 /* 890 */ 175, 241, 166, 48, 49, 174, 175, 113, 165, 98,
88651 /* 900 */ 112, 117, 114, 115, 7, 8, 9, 174, 175, 193,
88652 /* 910 */ 187, 66, 67, 68, 69, 70, 71, 72, 73, 74,
88653 /* 920 */ 75, 76, 77, 78, 150, 80, 81, 82, 83, 84,
88654 /* 930 */ 85, 86, 87, 88, 89, 90, 19, 150, 97, 165,
88655 /* 940 */ 160, 150, 177, 150, 150, 150, 248, 249, 174, 175,
88656 /* 950 */ 97, 98, 165, 129, 130, 150, 165, 116, 165, 165,
88657 /* 960 */ 165, 174, 175, 103, 178, 48, 49, 174, 175, 128,
88658 /* 970 */ 165, 98, 242, 112, 194, 114, 115, 199, 187, 174,
88659 /* 980 */ 175, 187, 109, 242, 67, 68, 69, 70, 71, 72,
88660 /* 990 */ 73, 74, 75, 76, 77, 78, 150, 80, 81, 82,
88661 /* 1000 */ 83, 84, 85, 86, 87, 88, 89, 90, 19, 150,
88662 /* 1010 */ 160, 165, 209, 150, 112, 150, 114, 115, 7, 8,
88663 /* 1020 */ 174, 175, 209, 6, 165, 29, 199, 150, 165, 33,
88664 /* 1030 */ 165, 150, 149, 174, 175, 150, 241, 48, 49, 174,
88665 /* 1040 */ 175, 149, 165, 47, 194, 149, 165, 16, 160, 149,
88666 /* 1050 */ 165, 174, 175, 13, 151, 174, 175, 68, 69, 70,
88667 /* 1060 */ 71, 72, 73, 74, 75, 76, 77, 78, 218, 80,
88668 /* 1070 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
88669 /* 1080 */ 19, 20, 194, 22, 150, 150, 150, 26, 27, 58,
88670 /* 1090 */ 240, 60, 150, 160, 151, 19, 20, 36, 22, 165,
88671 /* 1100 */ 165, 165, 26, 27, 22, 23, 150, 165, 174, 175,
88672 /* 1110 */ 174, 175, 36, 150, 25, 54, 150, 150, 150, 150,
88673 /* 1120 */ 23, 165, 25, 159, 150, 64, 194, 194, 165, 199,
88674 /* 1130 */ 54, 165, 165, 165, 165, 193, 150, 174, 175, 165,
88675 /* 1140 */ 64, 174, 175, 174, 175, 84, 85, 65, 150, 193,
88676 /* 1150 */ 126, 165, 217, 150, 93, 94, 95, 123, 200, 98,
88677 /* 1160 */ 84, 85, 86, 165, 105, 106, 107, 193, 165, 93,
88678 /* 1170 */ 94, 95, 174, 175, 98, 5, 23, 116, 25, 193,
88679 /* 1180 */ 10, 11, 12, 13, 14, 201, 23, 17, 25, 150,
88680 /* 1190 */ 129, 130, 131, 132, 133, 134, 193, 150, 125, 124,
88681 /* 1200 */ 30, 245, 32, 150, 165, 129, 130, 131, 132, 133,
88682 /* 1210 */ 134, 41, 165, 19, 20, 122, 22, 202, 165, 150,
88683 /* 1220 */ 26, 27, 150, 53, 150, 55, 160, 174, 175, 59,
88684 /* 1230 */ 36, 22, 62, 203, 165, 26, 27, 165, 150, 165,
88685 /* 1240 */ 193, 150, 105, 106, 107, 135, 174, 175, 54, 150,
88686 /* 1250 */ 150, 150, 227, 165, 22, 23, 165, 150, 64, 150,
88687 /* 1260 */ 194, 118, 174, 175, 165, 165, 165, 193, 150, 157,
88688 /* 1270 */ 150, 157, 165, 64, 165, 105, 106, 107, 84, 85,
88689 /* 1280 */ 23, 111, 25, 165, 193, 165, 116, 93, 94, 95,
88690 /* 1290 */ 150, 150, 98, 84, 85, 150, 150, 65, 150, 150,
88691 /* 1300 */ 150, 104, 150, 94, 150, 165, 165, 98, 210, 139,
88692 /* 1310 */ 165, 165, 210, 165, 165, 165, 150, 165, 150, 165,
88693 /* 1320 */ 121, 150, 150, 129, 130, 131, 132, 133, 134, 210,
88694 /* 1330 */ 150, 165, 150, 165, 150, 150, 165, 165, 129, 130,
88695 /* 1340 */ 131, 150, 150, 150, 211, 165, 150, 165, 104, 165,
88696 /* 1350 */ 165, 23, 23, 25, 25, 211, 165, 165, 165, 176,
88697 /* 1360 */ 23, 165, 25, 23, 23, 25, 25, 23, 211, 25,
88698 /* 1370 */ 46, 176, 184, 103, 176, 22, 90, 176, 178, 18,
88699 /* 1380 */ 176, 179, 176, 176, 179, 230, 230, 184, 157, 156,
88700 /* 1390 */ 156, 44, 157, 156, 135, 157, 157, 238, 156, 239,
88701 /* 1400 */ 157, 66, 189, 189, 22, 219, 157, 199, 18, 192,
88702 /* 1410 */ 192, 192, 192, 189, 199, 157, 39, 243, 243, 157,
88703 /* 1420 */ 157, 37, 246, 1, 164, 180, 180, 249, 15, 219,
88704 /* 1430 */ 23, 252, 22, 252, 118, 118, 118, 118, 118, 113,
88705 /* 1440 */ 98, 22, 11, 23, 23, 22, 22, 120, 23, 34,
88706 /* 1450 */ 23, 25, 23, 25, 118, 25, 22, 102, 50, 23,
88707 /* 1460 */ 23, 22, 27, 22, 50, 23, 34, 34, 22, 22,
88708 /* 1470 */ 22, 109, 19, 24, 20, 104, 38, 25, 104, 22,
88709 /* 1480 */ 5, 138, 1, 118, 34, 42, 27, 108, 22, 119,
88710 /* 1490 */ 50, 74, 74, 127, 1, 16, 51, 121, 20, 119,
88711 /* 1500 */ 108, 57, 51, 128, 22, 127, 23, 23, 16, 15,
88712 /* 1510 */ 22, 3, 140, 4, 253, 253, 253, 253, 63,
 
 
 
88713 };
88714 #define YY_SHIFT_USE_DFLT (-111)
88715 #define YY_SHIFT_MAX 415
88716 static const short yy_shift_ofst[] = {
88717 /* 0 */ 187, 1061, 1170, 1061, 1194, 1194, -2, 64, 64, -19,
88718 /* 10 */ 1194, 1194, 1194, 1194, 1194, 276, 1, 125, 1076, 1194,
88719 /* 20 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194,
88720 /* 30 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194,
88721 /* 40 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194,
88722 /* 50 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, -48,
88723 /* 60 */ 409, 1, 1, 141, 318, 318, -110, 53, 197, 269,
88724 /* 70 */ 341, 413, 485, 557, 629, 701, 773, 845, 773, 773,
88725 /* 80 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773,
88726 /* 90 */ 773, 773, 773, 773, 773, 773, 917, 989, 989, -67,
88727 /* 100 */ -67, -1, -1, 55, 25, 310, 1, 1, 1, 1,
88728 /* 110 */ 1, 639, 304, 1, 1, 1, 1, 1, 1, 1,
88729 /* 120 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 365,
88730 /* 130 */ 141, -17, -111, -111, -111, 1209, 81, 424, 353, 426,
88731 /* 140 */ 441, 90, 565, 565, 1, 1, 1, 1, 1, 1,
88732 /* 150 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
88733 /* 160 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
88734 /* 170 */ 1, 1, 1, 1, 1, 1, 447, 809, 327, 419,
88735 /* 180 */ 419, 419, 841, 101, -110, -110, -110, -111, -111, -111,
88736 /* 190 */ 232, 232, 268, 427, 575, 645, 788, 208, 861, 699,
88737 /* 200 */ 897, 784, 637, 52, 183, 183, 183, 902, 902, 996,
88738 /* 210 */ 1059, 902, 902, 902, 902, 275, 689, -13, 141, 824,
88739 /* 220 */ 824, 478, 498, 498, 656, 498, 262, 498, 141, 498,
88740 /* 230 */ 141, 860, 737, 712, 737, 656, 656, 712, 1017, 1017,
88741 /* 240 */ 1017, 1017, 1040, 1040, 1089, -110, 1024, 1034, 1075, 1093,
88742 /* 250 */ 1073, 1110, 1143, 1143, 1197, 1199, 1197, 1199, 1197, 1199,
88743 /* 260 */ 1244, 1244, 1324, 1244, 1270, 1244, 1353, 1286, 1286, 1324,
88744 /* 270 */ 1244, 1244, 1244, 1353, 1361, 1143, 1361, 1143, 1361, 1143,
88745 /* 280 */ 1143, 1347, 1259, 1361, 1143, 1335, 1335, 1382, 1024, 1143,
88746 /* 290 */ 1390, 1390, 1390, 1390, 1024, 1335, 1382, 1143, 1377, 1377,
88747 /* 300 */ 1143, 1143, 1384, -111, -111, -111, -111, -111, -111, 552,
88748 /* 310 */ 749, 1137, 1031, 1082, 1232, 801, 1097, 1153, 873, 1011,
88749 /* 320 */ 853, 1163, 1257, 1328, 1329, 1337, 1340, 1341, 736, 1344,
88750 /* 330 */ 1422, 1413, 1407, 1410, 1316, 1317, 1318, 1319, 1320, 1342,
88751 /* 340 */ 1326, 1419, 1420, 1421, 1423, 1431, 1424, 1425, 1426, 1427,
88752 /* 350 */ 1429, 1428, 1415, 1430, 1432, 1428, 1327, 1434, 1433, 1435,
88753 /* 360 */ 1336, 1436, 1437, 1438, 1408, 1439, 1414, 1441, 1442, 1446,
88754 /* 370 */ 1447, 1440, 1448, 1355, 1362, 1453, 1454, 1449, 1371, 1443,
88755 /* 380 */ 1444, 1445, 1452, 1451, 1343, 1374, 1457, 1475, 1481, 1365,
88756 /* 390 */ 1450, 1459, 1379, 1417, 1418, 1366, 1466, 1370, 1493, 1479,
88757 /* 400 */ 1376, 1478, 1380, 1392, 1378, 1482, 1375, 1483, 1484, 1492,
88758 /* 410 */ 1455, 1494, 1372, 1488, 1508, 1509,
88759 };
88760 #define YY_REDUCE_USE_DFLT (-180)
88761 #define YY_REDUCE_MAX 308
88762 static const short yy_reduce_ofst[] = {
88763 /* 0 */ -141, 82, 154, 284, 12, 75, 69, 73, 142, -59,
88764 /* 10 */ 145, 87, 159, 220, 291, 346, 226, 213, 357, 374,
88765 /* 20 */ 429, 437, 442, 486, 499, 505, 507, 519, 558, 571,
88766 /* 30 */ 577, 588, 630, 643, 649, 651, 662, 702, 715, 721,
88767 /* 40 */ 733, 774, 787, 793, 805, 846, 859, 865, 877, 881,
88768 /* 50 */ 934, 936, 963, 967, 969, 998, 1053, 1072, 1088, -179,
88769 /* 60 */ 850, 956, 380, 308, 89, 496, 384, 2, 2, 2,
88770 /* 70 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
88771 /* 80 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
88772 /* 90 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
88773 /* 100 */ 2, 2, 2, 416, 2, 2, 449, 579, 648, 723,
88774 /* 110 */ 791, 134, 501, 716, 521, 794, 589, -47, 650, 590,
88775 /* 120 */ 795, 942, 974, 986, 1003, 1047, 1074, 935, 1091, 2,
88776 /* 130 */ 417, 2, 2, 2, 2, 158, 336, 526, 576, 863,
88777 /* 140 */ 885, 966, 405, 428, 968, 1039, 1069, 1099, 1100, 966,
88778 /* 150 */ 1101, 1107, 1109, 1118, 1120, 1140, 1141, 1145, 1146, 1148,
88779 /* 160 */ 1149, 1150, 1152, 1154, 1166, 1168, 1171, 1172, 1180, 1182,
88780 /* 170 */ 1184, 1185, 1191, 1192, 1193, 1196, 403, 403, 652, 377,
88781 /* 180 */ 663, 667, -134, 780, 888, 933, 1066, 44, 672, 698,
88782 /* 190 */ -98, -70, -54, -36, -35, -35, -35, 13, -35, 14,
88783 /* 200 */ 146, 181, 227, 14, 203, 223, 250, -35, -35, 224,
88784 /* 210 */ 202, -35, -35, -35, -35, 339, 309, 312, 381, 317,
88785 /* 220 */ 376, 457, 515, 570, 619, 584, 687, 705, 709, 765,
88786 /* 230 */ 726, 786, 730, 778, 741, 803, 813, 827, 883, 892,
88787 /* 240 */ 896, 900, 903, 943, 964, 932, 930, 958, 984, 1015,
88788 /* 250 */ 1030, 1025, 1112, 1114, 1098, 1133, 1102, 1144, 1119, 1157,
88789 /* 260 */ 1183, 1195, 1188, 1198, 1200, 1201, 1202, 1155, 1156, 1203,
88790 /* 270 */ 1204, 1206, 1207, 1205, 1233, 1231, 1234, 1235, 1237, 1238,
88791 /* 280 */ 1239, 1159, 1160, 1242, 1243, 1213, 1214, 1186, 1208, 1249,
88792 /* 290 */ 1217, 1218, 1219, 1220, 1215, 1224, 1210, 1258, 1174, 1175,
88793 /* 300 */ 1262, 1263, 1176, 1260, 1245, 1246, 1178, 1179, 1181,
 
88794 };
88795 static const YYACTIONTYPE yy_default[] = {
88796 /* 0 */ 634, 869, 958, 958, 869, 958, 958, 898, 898, 757,
88797 /* 10 */ 867, 958, 958, 958, 958, 958, 958, 932, 958, 958,
88798 /* 20 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
88799 /* 30 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
88800 /* 40 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
88801 /* 50 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 841,
88802 /* 60 */ 958, 958, 958, 673, 898, 898, 761, 792, 958, 958,
88803 /* 70 */ 958, 958, 958, 958, 958, 958, 793, 958, 871, 866,
88804 /* 80 */ 862, 864, 863, 870, 794, 783, 790, 797, 772, 911,
88805 /* 90 */ 799, 800, 806, 807, 933, 931, 829, 828, 847, 831,
88806 /* 100 */ 853, 830, 840, 665, 832, 833, 958, 958, 958, 958,
88807 /* 110 */ 958, 726, 660, 958, 958, 958, 958, 958, 958, 958,
88808 /* 120 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 834,
88809 /* 130 */ 958, 835, 848, 849, 850, 958, 958, 958, 958, 958,
88810 /* 140 */ 958, 958, 958, 958, 640, 958, 958, 958, 958, 958,
88811 /* 150 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
88812 /* 160 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
88813 /* 170 */ 958, 882, 958, 936, 938, 958, 958, 958, 634, 757,
88814 /* 180 */ 757, 757, 958, 958, 958, 958, 958, 751, 761, 950,
88815 /* 190 */ 958, 958, 717, 958, 958, 958, 958, 958, 958, 958,
88816 /* 200 */ 642, 749, 675, 759, 958, 958, 958, 662, 738, 904,
88817 /* 210 */ 958, 923, 921, 740, 802, 958, 749, 758, 958, 958,
88818 /* 220 */ 958, 865, 786, 786, 774, 786, 696, 786, 958, 786,
88819 /* 230 */ 958, 699, 916, 796, 916, 774, 774, 796, 639, 639,
88820 /* 240 */ 639, 639, 650, 650, 716, 958, 796, 787, 789, 779,
88821 /* 250 */ 791, 958, 765, 765, 773, 778, 773, 778, 773, 778,
88822 /* 260 */ 728, 728, 713, 728, 699, 728, 875, 879, 879, 713,
88823 /* 270 */ 728, 728, 728, 875, 657, 765, 657, 765, 657, 765,
88824 /* 280 */ 765, 908, 910, 657, 765, 730, 730, 808, 796, 765,
88825 /* 290 */ 737, 737, 737, 737, 796, 730, 808, 765, 935, 935,
88826 /* 300 */ 765, 765, 943, 683, 701, 701, 950, 955, 955, 958,
88827 /* 310 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
88828 /* 320 */ 958, 958, 958, 958, 958, 958, 958, 958, 884, 958,
88829 /* 330 */ 958, 648, 958, 667, 815, 820, 816, 958, 817, 958,
88830 /* 340 */ 743, 958, 958, 958, 958, 958, 958, 958, 958, 958,
88831 /* 350 */ 958, 868, 958, 780, 958, 788, 958, 958, 958, 958,
88832 /* 360 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
88833 /* 370 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
88834 /* 380 */ 958, 906, 907, 958, 958, 958, 958, 958, 958, 914,
88835 /* 390 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
88836 /* 400 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
88837 /* 410 */ 942, 958, 958, 945, 635, 958, 630, 632, 633, 637,
88838 /* 420 */ 638, 641, 667, 668, 670, 671, 672, 643, 644, 645,
88839 /* 430 */ 646, 647, 649, 653, 651, 652, 654, 661, 663, 682,
88840 /* 440 */ 684, 686, 747, 748, 812, 741, 742, 746, 669, 823,
88841 /* 450 */ 814, 818, 819, 821, 822, 836, 837, 839, 845, 852,
88842 /* 460 */ 855, 838, 843, 844, 846, 851, 854, 744, 745, 858,
88843 /* 470 */ 676, 677, 680, 681, 894, 896, 895, 897, 679, 678,
88844 /* 480 */ 824, 827, 860, 861, 924, 925, 926, 927, 928, 856,
88845 /* 490 */ 766, 859, 842, 781, 784, 785, 782, 750, 760, 768,
88846 /* 500 */ 769, 770, 771, 755, 756, 762, 777, 810, 811, 775,
88847 /* 510 */ 776, 763, 764, 752, 753, 754, 857, 813, 825, 826,
88848 /* 520 */ 687, 688, 820, 689, 690, 691, 729, 732, 733, 734,
88849 /* 530 */ 692, 711, 714, 715, 693, 700, 694, 695, 702, 703,
88850 /* 540 */ 704, 707, 708, 709, 710, 705, 706, 876, 877, 880,
88851 /* 550 */ 878, 697, 698, 712, 685, 674, 666, 718, 721, 722,
88852 /* 560 */ 723, 724, 725, 727, 719, 720, 664, 655, 658, 767,
88853 /* 570 */ 900, 909, 905, 901, 902, 903, 659, 872, 873, 731,
88854 /* 580 */ 804, 805, 899, 912, 915, 917, 918, 919, 809, 920,
88855 /* 590 */ 922, 913, 947, 656, 735, 736, 739, 881, 929, 795,
@@ -88898,10 +90680,11 @@
88898 0, /* AS => nothing */
88899 0, /* COMMA => nothing */
88900 0, /* ID => nothing */
88901 0, /* INDEXED => nothing */
88902 26, /* ABORT => ID */
 
88903 26, /* AFTER => ID */
88904 26, /* ANALYZE => ID */
88905 26, /* ASC => ID */
88906 26, /* ATTACH => ID */
88907 26, /* BEFORE => ID */
@@ -88919,10 +90702,11 @@
88919 26, /* IGNORE => ID */
88920 26, /* INITIALLY => ID */
88921 26, /* INSTEAD => ID */
88922 26, /* LIKE_KW => ID */
88923 26, /* MATCH => ID */
 
88924 26, /* KEY => ID */
88925 26, /* OF => ID */
88926 26, /* OFFSET => ID */
88927 26, /* PRAGMA => ID */
88928 26, /* RAISE => ID */
@@ -89018,36 +90802,36 @@
89018 "IMMEDIATE", "EXCLUSIVE", "COMMIT", "END",
89019 "ROLLBACK", "SAVEPOINT", "RELEASE", "TO",
89020 "TABLE", "CREATE", "IF", "NOT",
89021 "EXISTS", "TEMP", "LP", "RP",
89022 "AS", "COMMA", "ID", "INDEXED",
89023 "ABORT", "AFTER", "ANALYZE", "ASC",
89024 "ATTACH", "BEFORE", "BY", "CASCADE",
89025 "CAST", "COLUMNKW", "CONFLICT", "DATABASE",
89026 "DESC", "DETACH", "EACH", "FAIL",
89027 "FOR", "IGNORE", "INITIALLY", "INSTEAD",
89028 "LIKE_KW", "MATCH", "KEY", "OF",
89029 "OFFSET", "PRAGMA", "RAISE", "REPLACE",
89030 "RESTRICT", "ROW", "TRIGGER", "VACUUM",
89031 "VIEW", "VIRTUAL", "REINDEX", "RENAME",
89032 "CTIME_KW", "ANY", "OR", "AND",
89033 "IS", "BETWEEN", "IN", "ISNULL",
89034 "NOTNULL", "NE", "EQ", "GT",
89035 "LE", "LT", "GE", "ESCAPE",
89036 "BITAND", "BITOR", "LSHIFT", "RSHIFT",
89037 "PLUS", "MINUS", "STAR", "SLASH",
89038 "REM", "CONCAT", "COLLATE", "UMINUS",
89039 "UPLUS", "BITNOT", "STRING", "JOIN_KW",
89040 "CONSTRAINT", "DEFAULT", "NULL", "PRIMARY",
89041 "UNIQUE", "CHECK", "REFERENCES", "AUTOINCR",
89042 "ON", "DELETE", "UPDATE", "INSERT",
89043 "SET", "DEFERRABLE", "FOREIGN", "DROP",
89044 "UNION", "ALL", "EXCEPT", "INTERSECT",
89045 "SELECT", "DISTINCT", "DOT", "FROM",
89046 "JOIN", "USING", "ORDER", "GROUP",
89047 "HAVING", "LIMIT", "WHERE", "INTO",
89048 "VALUES", "INTEGER", "FLOAT", "BLOB",
89049 "REGISTER", "VARIABLE", "CASE", "WHEN",
89050 "THEN", "ELSE", "INDEX", "ALTER",
89051 "ADD", "error", "input", "cmdlist",
89052 "ecmd", "explain", "cmdx", "cmd",
89053 "transtype", "trans_opt", "nm", "savepoint_opt",
@@ -89159,15 +90943,15 @@
89159 /* 72 */ "refargs ::=",
89160 /* 73 */ "refargs ::= refargs refarg",
89161 /* 74 */ "refarg ::= MATCH nm",
89162 /* 75 */ "refarg ::= ON DELETE refact",
89163 /* 76 */ "refarg ::= ON UPDATE refact",
89164 /* 77 */ "refarg ::= ON INSERT refact",
89165 /* 78 */ "refact ::= SET NULL",
89166 /* 79 */ "refact ::= SET DEFAULT",
89167 /* 80 */ "refact ::= CASCADE",
89168 /* 81 */ "refact ::= RESTRICT",
89169 /* 82 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
89170 /* 83 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
89171 /* 84 */ "init_deferred_pred_opt ::=",
89172 /* 85 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
89173 /* 86 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
@@ -89297,13 +91081,13 @@
89297 /* 210 */ "likeop ::= NOT MATCH",
89298 /* 211 */ "escape ::= ESCAPE expr",
89299 /* 212 */ "escape ::=",
89300 /* 213 */ "expr ::= expr likeop expr escape",
89301 /* 214 */ "expr ::= expr ISNULL|NOTNULL",
89302 /* 215 */ "expr ::= expr IS NULL",
89303 /* 216 */ "expr ::= expr NOT NULL",
89304 /* 217 */ "expr ::= expr IS NOT NULL",
89305 /* 218 */ "expr ::= NOT expr",
89306 /* 219 */ "expr ::= BITNOT expr",
89307 /* 220 */ "expr ::= MINUS expr",
89308 /* 221 */ "expr ::= PLUS expr",
89309 /* 222 */ "between_op ::= BETWEEN",
@@ -89869,15 +91653,15 @@
89869 { 180, 0 },
89870 { 180, 2 },
89871 { 182, 2 },
89872 { 182, 3 },
89873 { 182, 3 },
89874 { 182, 3 },
89875 { 183, 2 },
89876 { 183, 2 },
89877 { 183, 1 },
89878 { 183, 1 },
 
89879 { 181, 3 },
89880 { 181, 2 },
89881 { 184, 0 },
89882 { 184, 2 },
89883 { 184, 2 },
@@ -90236,10 +92020,11 @@
90236 }
90237 break;
90238 case 28: /* ifnotexists ::= */
90239 case 31: /* temp ::= */ yytestcase(yyruleno==31);
90240 case 70: /* autoinc ::= */ yytestcase(yyruleno==70);
 
90241 case 84: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==84);
90242 case 86: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==86);
90243 case 97: /* defer_subclause_opt ::= */ yytestcase(yyruleno==97);
90244 case 108: /* ifexists ::= */ yytestcase(yyruleno==108);
90245 case 119: /* distinct ::= ALL */ yytestcase(yyruleno==119);
@@ -90366,11 +92151,11 @@
90366 break;
90367 case 69: /* ccons ::= COLLATE ids */
90368 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
90369 break;
90370 case 72: /* refargs ::= */
90371 { yygotominor.yy328 = OE_Restrict * 0x010101; }
90372 break;
90373 case 73: /* refargs ::= refargs refarg */
90374 { yygotominor.yy328 = (yymsp[-1].minor.yy328 & ~yymsp[0].minor.yy429.mask) | yymsp[0].minor.yy429.value; }
90375 break;
90376 case 74: /* refarg ::= MATCH nm */
@@ -90380,27 +92165,26 @@
90380 { yygotominor.yy429.value = yymsp[0].minor.yy328; yygotominor.yy429.mask = 0x0000ff; }
90381 break;
90382 case 76: /* refarg ::= ON UPDATE refact */
90383 { yygotominor.yy429.value = yymsp[0].minor.yy328<<8; yygotominor.yy429.mask = 0x00ff00; }
90384 break;
90385 case 77: /* refarg ::= ON INSERT refact */
90386 { yygotominor.yy429.value = yymsp[0].minor.yy328<<16; yygotominor.yy429.mask = 0xff0000; }
90387 break;
90388 case 78: /* refact ::= SET NULL */
90389 { yygotominor.yy328 = OE_SetNull; }
90390 break;
90391 case 79: /* refact ::= SET DEFAULT */
90392 { yygotominor.yy328 = OE_SetDflt; }
90393 break;
90394 case 80: /* refact ::= CASCADE */
90395 { yygotominor.yy328 = OE_Cascade; }
90396 break;
90397 case 81: /* refact ::= RESTRICT */
90398 { yygotominor.yy328 = OE_Restrict; }
90399 break;
90400 case 82: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
90401 case 83: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==83);
 
 
90402 case 98: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==98);
90403 case 100: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==100);
90404 case 103: /* resolvetype ::= raisetype */ yytestcase(yyruleno==103);
90405 {yygotominor.yy328 = yymsp[0].minor.yy328;}
90406 break;
@@ -90830,18 +92614,28 @@
90830 }
90831 break;
90832 case 214: /* expr ::= expr ISNULL|NOTNULL */
90833 {spanUnaryPostfix(&yygotominor.yy346,pParse,yymsp[0].major,&yymsp[-1].minor.yy346,&yymsp[0].minor.yy0);}
90834 break;
90835 case 215: /* expr ::= expr IS NULL */
90836 {spanUnaryPostfix(&yygotominor.yy346,pParse,TK_ISNULL,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy0);}
90837 break;
90838 case 216: /* expr ::= expr NOT NULL */
90839 {spanUnaryPostfix(&yygotominor.yy346,pParse,TK_NOTNULL,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy0);}
90840 break;
90841 case 217: /* expr ::= expr IS NOT NULL */
90842 {spanUnaryPostfix(&yygotominor.yy346,pParse,TK_NOTNULL,&yymsp[-3].minor.yy346,&yymsp[0].minor.yy0);}
 
 
 
 
 
 
 
 
 
 
 
 
 
90843 break;
90844 case 218: /* expr ::= NOT expr */
90845 case 219: /* expr ::= BITNOT expr */ yytestcase(yyruleno==219);
90846 {spanUnaryPrefix(&yygotominor.yy346,pParse,yymsp[-1].major,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
90847 break;
@@ -91583,13 +93377,13 @@
91583 ** might be implemented more directly using a hand-written hash table.
91584 ** But by using this automatically generated code, the size of the code
91585 ** is substantially reduced. This is important for embedded applications
91586 ** on platforms with limited memory.
91587 */
91588 /* Hash score: 171 */
91589 static int keywordCode(const char *z, int n){
91590 /* zText[] encodes 801 bytes of keywords in 541 bytes */
91591 /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
91592 /* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */
91593 /* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */
91594 /* UNIQUERYATTACHAVINGROUPDATEBEGINNERELEASEBETWEENOTNULLIKE */
91595 /* CASCADELETECASECOLLATECREATECURRENT_DATEDETACHIMMEDIATEJOIN */
@@ -91629,82 +93423,83 @@
91629 'T','R','I','C','T','O','U','T','E','R','I','G','H','T','R','O','L','L',
91630 'B','A','C','K','R','O','W','U','N','I','O','N','U','S','I','N','G','V',
91631 'A','C','U','U','M','V','I','E','W','I','N','I','T','I','A','L','L','Y',
91632 };
91633 static const unsigned char aHash[127] = {
91634 70, 99, 112, 68, 0, 43, 0, 0, 76, 0, 71, 0, 0,
91635 41, 12, 72, 15, 0, 111, 79, 49, 106, 0, 19, 0, 0,
91636 116, 0, 114, 109, 0, 22, 87, 0, 9, 0, 0, 64, 65,
91637 0, 63, 6, 0, 47, 84, 96, 0, 113, 95, 0, 0, 44,
91638 0, 97, 24, 0, 17, 0, 117, 48, 23, 0, 5, 104, 25,
91639 90, 0, 0, 119, 100, 55, 118, 52, 7, 50, 0, 85, 0,
91640 94, 26, 0, 93, 0, 0, 0, 89, 86, 91, 82, 103, 14,
91641 38, 102, 0, 75, 0, 18, 83, 105, 31, 0, 115, 74, 107,
91642 57, 45, 78, 0, 0, 88, 39, 0, 110, 0, 35, 0, 0,
91643 28, 0, 80, 53, 58, 0, 20, 56, 0, 51,
91644 };
91645 static const unsigned char aNext[119] = {
91646 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
91647 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
91648 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
91649 0, 0, 0, 0, 32, 21, 0, 0, 0, 42, 3, 46, 0,
91650 0, 0, 0, 29, 0, 0, 37, 0, 0, 0, 1, 60, 0,
91651 0, 61, 0, 40, 0, 0, 0, 0, 0, 0, 0, 59, 0,
91652 0, 0, 0, 30, 54, 16, 33, 10, 0, 0, 0, 0, 0,
91653 0, 0, 11, 66, 73, 0, 8, 0, 98, 92, 0, 101, 0,
91654 81, 0, 69, 0, 0, 108, 27, 36, 67, 77, 0, 34, 62,
91655 0, 0,
91656 };
91657 static const unsigned char aLen[119] = {
91658 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
91659 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6,
91660 11, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10, 4,
91661 6, 2, 3, 4, 9, 2, 6, 5, 6, 6, 5, 6, 5,
91662 5, 7, 7, 7, 3, 4, 4, 7, 3, 6, 4, 7, 6,
91663 12, 6, 9, 4, 6, 5, 4, 7, 6, 5, 6, 7, 5,
91664 4, 5, 6, 5, 7, 3, 7, 13, 2, 2, 4, 6, 6,
91665 8, 5, 17, 12, 7, 8, 8, 2, 4, 4, 4, 4, 4,
91666 2, 2, 6, 5, 8, 5, 5, 8, 3, 5, 5, 6, 4,
91667 9, 3,
91668 };
91669 static const unsigned short int aOffset[119] = {
91670 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
91671 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
91672 86, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152, 159,
91673 162, 162, 165, 167, 167, 171, 176, 179, 184, 189, 194, 197, 203,
91674 206, 210, 217, 223, 223, 226, 229, 233, 234, 238, 244, 248, 255,
91675 261, 273, 279, 288, 290, 296, 301, 303, 310, 315, 320, 326, 332,
91676 337, 341, 344, 350, 354, 361, 363, 370, 372, 374, 383, 387, 393,
91677 399, 407, 412, 412, 428, 435, 442, 443, 450, 454, 458, 462, 466,
91678 469, 471, 473, 479, 483, 491, 495, 500, 508, 511, 516, 521, 527,
91679 531, 536,
91680 };
91681 static const unsigned char aCode[119] = {
91682 TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
91683 TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
91684 TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
91685 TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
91686 TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
91687 TK_EXCEPT, TK_TRANSACTION,TK_ON, TK_JOIN_KW, TK_ALTER,
91688 TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT, TK_INTERSECT,
91689 TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO, TK_OFFSET,
91690 TK_OF, TK_SET, TK_TEMP, TK_TEMP, TK_OR,
91691 TK_UNIQUE, TK_QUERY, TK_ATTACH, TK_HAVING, TK_GROUP,
91692 TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RELEASE, TK_BETWEEN,
91693 TK_NOTNULL, TK_NOT, TK_NULL, TK_LIKE_KW, TK_CASCADE,
91694 TK_ASC, TK_DELETE, TK_CASE, TK_COLLATE, TK_CREATE,
91695 TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, TK_JOIN, TK_INSERT,
91696 TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT,
91697 TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN, TK_WHERE,
91698 TK_RENAME, TK_AFTER, TK_REPLACE, TK_AND, TK_DEFAULT,
91699 TK_AUTOINCR, TK_TO, TK_IN, TK_CAST, TK_COLUMNKW,
91700 TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW,
91701 TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DROP,
91702 TK_FAIL, TK_FROM, TK_JOIN_KW, TK_LIKE_KW, TK_BY,
91703 TK_IF, TK_ISNULL, TK_ORDER, TK_RESTRICT, TK_JOIN_KW,
91704 TK_JOIN_KW, TK_ROLLBACK, TK_ROW, TK_UNION, TK_USING,
91705 TK_VACUUM, TK_VIEW, TK_INITIALLY, TK_ALL,
 
91706 };
91707 int h, i;
91708 if( n<2 ) return TK_ID;
91709 h = ((charMap(z[0])*4) ^
91710 (charMap(z[n-1])*3) ^
@@ -91736,102 +93531,104 @@
91736 testcase( i==22 ); /* END */
91737 testcase( i==23 ); /* DEFERRABLE */
91738 testcase( i==24 ); /* ELSE */
91739 testcase( i==25 ); /* EXCEPT */
91740 testcase( i==26 ); /* TRANSACTION */
91741 testcase( i==27 ); /* ON */
91742 testcase( i==28 ); /* NATURAL */
91743 testcase( i==29 ); /* ALTER */
91744 testcase( i==30 ); /* RAISE */
91745 testcase( i==31 ); /* EXCLUSIVE */
91746 testcase( i==32 ); /* EXISTS */
91747 testcase( i==33 ); /* SAVEPOINT */
91748 testcase( i==34 ); /* INTERSECT */
91749 testcase( i==35 ); /* TRIGGER */
91750 testcase( i==36 ); /* REFERENCES */
91751 testcase( i==37 ); /* CONSTRAINT */
91752 testcase( i==38 ); /* INTO */
91753 testcase( i==39 ); /* OFFSET */
91754 testcase( i==40 ); /* OF */
91755 testcase( i==41 ); /* SET */
91756 testcase( i==42 ); /* TEMP */
91757 testcase( i==43 ); /* TEMPORARY */
91758 testcase( i==44 ); /* OR */
91759 testcase( i==45 ); /* UNIQUE */
91760 testcase( i==46 ); /* QUERY */
91761 testcase( i==47 ); /* ATTACH */
91762 testcase( i==48 ); /* HAVING */
91763 testcase( i==49 ); /* GROUP */
91764 testcase( i==50 ); /* UPDATE */
91765 testcase( i==51 ); /* BEGIN */
91766 testcase( i==52 ); /* INNER */
91767 testcase( i==53 ); /* RELEASE */
91768 testcase( i==54 ); /* BETWEEN */
91769 testcase( i==55 ); /* NOTNULL */
91770 testcase( i==56 ); /* NOT */
91771 testcase( i==57 ); /* NULL */
91772 testcase( i==58 ); /* LIKE */
91773 testcase( i==59 ); /* CASCADE */
91774 testcase( i==60 ); /* ASC */
91775 testcase( i==61 ); /* DELETE */
91776 testcase( i==62 ); /* CASE */
91777 testcase( i==63 ); /* COLLATE */
91778 testcase( i==64 ); /* CREATE */
91779 testcase( i==65 ); /* CURRENT_DATE */
91780 testcase( i==66 ); /* DETACH */
91781 testcase( i==67 ); /* IMMEDIATE */
91782 testcase( i==68 ); /* JOIN */
91783 testcase( i==69 ); /* INSERT */
91784 testcase( i==70 ); /* MATCH */
91785 testcase( i==71 ); /* PLAN */
91786 testcase( i==72 ); /* ANALYZE */
91787 testcase( i==73 ); /* PRAGMA */
91788 testcase( i==74 ); /* ABORT */
91789 testcase( i==75 ); /* VALUES */
91790 testcase( i==76 ); /* VIRTUAL */
91791 testcase( i==77 ); /* LIMIT */
91792 testcase( i==78 ); /* WHEN */
91793 testcase( i==79 ); /* WHERE */
91794 testcase( i==80 ); /* RENAME */
91795 testcase( i==81 ); /* AFTER */
91796 testcase( i==82 ); /* REPLACE */
91797 testcase( i==83 ); /* AND */
91798 testcase( i==84 ); /* DEFAULT */
91799 testcase( i==85 ); /* AUTOINCREMENT */
91800 testcase( i==86 ); /* TO */
91801 testcase( i==87 ); /* IN */
91802 testcase( i==88 ); /* CAST */
91803 testcase( i==89 ); /* COLUMN */
91804 testcase( i==90 ); /* COMMIT */
91805 testcase( i==91 ); /* CONFLICT */
91806 testcase( i==92 ); /* CROSS */
91807 testcase( i==93 ); /* CURRENT_TIMESTAMP */
91808 testcase( i==94 ); /* CURRENT_TIME */
91809 testcase( i==95 ); /* PRIMARY */
91810 testcase( i==96 ); /* DEFERRED */
91811 testcase( i==97 ); /* DISTINCT */
91812 testcase( i==98 ); /* IS */
91813 testcase( i==99 ); /* DROP */
91814 testcase( i==100 ); /* FAIL */
91815 testcase( i==101 ); /* FROM */
91816 testcase( i==102 ); /* FULL */
91817 testcase( i==103 ); /* GLOB */
91818 testcase( i==104 ); /* BY */
91819 testcase( i==105 ); /* IF */
91820 testcase( i==106 ); /* ISNULL */
91821 testcase( i==107 ); /* ORDER */
91822 testcase( i==108 ); /* RESTRICT */
91823 testcase( i==109 ); /* OUTER */
91824 testcase( i==110 ); /* RIGHT */
91825 testcase( i==111 ); /* ROLLBACK */
91826 testcase( i==112 ); /* ROW */
91827 testcase( i==113 ); /* UNION */
91828 testcase( i==114 ); /* USING */
91829 testcase( i==115 ); /* VACUUM */
91830 testcase( i==116 ); /* VIEW */
91831 testcase( i==117 ); /* INITIALLY */
91832 testcase( i==118 ); /* ALL */
 
 
91833 return aCode[i];
91834 }
91835 }
91836 return TK_ID;
91837 }
@@ -93408,10 +95205,13 @@
93408
93409 if( db->flags&SQLITE_InternChanges ){
93410 sqlite3ExpirePreparedStatements(db);
93411 sqlite3ResetInternalSchema(db, 0);
93412 }
 
 
 
93413
93414 /* If one has been configured, invoke the rollback-hook callback */
93415 if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){
93416 db->xRollbackCallback(db->pRollbackArg);
93417 }
@@ -106670,22 +108470,22 @@
106670 ** here is the LinearPickSeeds algorithm from Gutman[1984]. The
106671 ** indices of the two seed cells in the array are stored in local
106672 ** variables iLeftSeek and iRightSeed.
106673 */
106674 for(i=0; i<pRtree->nDim; i++){
106675 float x1 = aCell[0].aCoord[i*2];
106676 float x2 = aCell[0].aCoord[i*2+1];
106677 float x3 = x1;
106678 float x4 = x2;
106679 int jj;
106680
106681 int iCellLeft = 0;
106682 int iCellRight = 0;
106683
106684 for(jj=1; jj<nCell; jj++){
106685 float left = aCell[jj].aCoord[i*2];
106686 float right = aCell[jj].aCoord[i*2+1];
106687
106688 if( left<x1 ) x1 = left;
106689 if( right>x4 ) x4 = right;
106690 if( left>x3 ){
106691 x3 = left;
@@ -107039,10 +108839,13 @@
107039 int iRightSeed = 1;
107040 int *aiUsed;
107041 int i;
107042
107043 aiUsed = sqlite3_malloc(sizeof(int)*nCell);
 
 
 
107044 memset(aiUsed, 0, sizeof(int)*nCell);
107045
107046 PickSeeds(pRtree, aCell, nCell, &iLeftSeed, &iRightSeed);
107047
107048 memcpy(pBboxLeft, &aCell[iLeftSeed], sizeof(RtreeCell));
107049
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.6.19. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a one translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% are more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -15,11 +15,11 @@
15 ** of the embedded sqlite3.h header file.) Additional code files may be needed
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 ** This amalgamation was generated on 2009-10-13 16:22:00 UTC.
21 */
22 #define SQLITE_CORE 1
23 #define SQLITE_AMALGAMATION 1
24 #ifndef SQLITE_PRIVATE
25 # define SQLITE_PRIVATE static
@@ -273,10 +273,14 @@
273 # define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000
274 #endif
275
276 /*
277 ** Maximum depth of recursion for triggers.
278 **
279 ** A value of 1 means that a trigger program will not be able to itself
280 ** fire any triggers. A value of 0 means that no trigger programs at all
281 ** may be executed.
282 */
283 #ifndef SQLITE_MAX_TRIGGER_DEPTH
284 #if defined(SQLITE_SMALL_STACK)
285 # define SQLITE_MAX_TRIGGER_DEPTH 10
286 #else
@@ -645,13 +649,13 @@
649 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
650 ** [sqlite_version()] and [sqlite_source_id()].
651 **
652 ** Requirements: [H10011] [H10014]
653 */
654 #define SQLITE_VERSION "3.6.19"
655 #define SQLITE_VERSION_NUMBER 3006019
656 #define SQLITE_SOURCE_ID "2009-10-13 15:42:49 f894ebf86d6bafcd1461f104f5f677b3b6a3aa1a"
657
658 /*
659 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
660 ** KEYWORDS: sqlite3_version
661 **
@@ -1842,12 +1846,13 @@
1846 ** This function returns the number of database rows that were changed
1847 ** or inserted or deleted by the most recently completed SQL statement
1848 ** on the [database connection] specified by the first parameter.
1849 ** Only changes that are directly specified by the [INSERT], [UPDATE],
1850 ** or [DELETE] statement are counted. Auxiliary changes caused by
1851 ** triggers or [foreign key actions] are not counted. Use the
1852 ** [sqlite3_total_changes()] function to find the total number of changes
1853 ** including changes caused by triggers and foreign key actions.
1854 **
1855 ** Changes to a view that are simulated by an [INSTEAD OF trigger]
1856 ** are not counted. Only real table changes are counted.
1857 **
1858 ** A "row change" is a change to a single row of a single table
@@ -1895,12 +1900,12 @@
1900 /*
1901 ** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600>
1902 **
1903 ** This function returns the number of row changes caused by [INSERT],
1904 ** [UPDATE] or [DELETE] statements since the [database connection] was opened.
1905 ** The count includes all changes from all [CREATE TRIGGER | trigger]
1906 ** contexts and changes made by [foreign key actions]. However,
1907 ** the count does not include changes used to implement [REPLACE] constraints,
1908 ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The
1909 ** count does not include rows of views that fire an [INSTEAD OF trigger],
1910 ** though if the INSTEAD OF trigger makes changes of its own, those changes
1911 ** are counted.
@@ -5037,10 +5042,13 @@
5042 ** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
5043 ** </pre> {END}
5044 **
5045 ** If the flags parameter is non-zero, then the BLOB is opened for read
5046 ** and write access. If it is zero, the BLOB is opened for read access.
5047 ** It is not possible to open a column that is part of an index or primary
5048 ** key for writing. ^If [foreign key constraints] are enabled, it is
5049 ** not possible to open a column that is part of a [child key] for writing.
5050 **
5051 ** Note that the database name is not the filename that contains
5052 ** the database but rather the symbolic name of the database that
5053 ** is assigned when the database is connected using [ATTACH].
5054 ** For the main database file, the database name is "main".
@@ -6419,74 +6427,74 @@
6427 #define TK_AS 24
6428 #define TK_COMMA 25
6429 #define TK_ID 26
6430 #define TK_INDEXED 27
6431 #define TK_ABORT 28
6432 #define TK_ACTION 29
6433 #define TK_AFTER 30
6434 #define TK_ANALYZE 31
6435 #define TK_ASC 32
6436 #define TK_ATTACH 33
6437 #define TK_BEFORE 34
6438 #define TK_BY 35
6439 #define TK_CASCADE 36
6440 #define TK_CAST 37
6441 #define TK_COLUMNKW 38
6442 #define TK_CONFLICT 39
6443 #define TK_DATABASE 40
6444 #define TK_DESC 41
6445 #define TK_DETACH 42
6446 #define TK_EACH 43
6447 #define TK_FAIL 44
6448 #define TK_FOR 45
6449 #define TK_IGNORE 46
6450 #define TK_INITIALLY 47
6451 #define TK_INSTEAD 48
6452 #define TK_LIKE_KW 49
6453 #define TK_MATCH 50
6454 #define TK_NO 51
6455 #define TK_KEY 52
6456 #define TK_OF 53
6457 #define TK_OFFSET 54
6458 #define TK_PRAGMA 55
6459 #define TK_RAISE 56
6460 #define TK_REPLACE 57
6461 #define TK_RESTRICT 58
6462 #define TK_ROW 59
6463 #define TK_TRIGGER 60
6464 #define TK_VACUUM 61
6465 #define TK_VIEW 62
6466 #define TK_VIRTUAL 63
6467 #define TK_REINDEX 64
6468 #define TK_RENAME 65
6469 #define TK_CTIME_KW 66
6470 #define TK_ANY 67
6471 #define TK_OR 68
6472 #define TK_AND 69
6473 #define TK_IS 70
6474 #define TK_BETWEEN 71
6475 #define TK_IN 72
6476 #define TK_ISNULL 73
6477 #define TK_NOTNULL 74
6478 #define TK_NE 75
6479 #define TK_EQ 76
6480 #define TK_GT 77
6481 #define TK_LE 78
6482 #define TK_LT 79
6483 #define TK_GE 80
6484 #define TK_ESCAPE 81
6485 #define TK_BITAND 82
6486 #define TK_BITOR 83
6487 #define TK_LSHIFT 84
6488 #define TK_RSHIFT 85
6489 #define TK_PLUS 86
6490 #define TK_MINUS 87
6491 #define TK_STAR 88
6492 #define TK_SLASH 89
6493 #define TK_REM 90
6494 #define TK_CONCAT 91
6495 #define TK_COLLATE 92
6496 #define TK_BITNOT 93
6497 #define TK_STRING 94
6498 #define TK_JOIN_KW 95
6499 #define TK_CONSTRAINT 96
6500 #define TK_DEFAULT 97
@@ -6497,32 +6505,32 @@
6505 #define TK_REFERENCES 102
6506 #define TK_AUTOINCR 103
6507 #define TK_ON 104
6508 #define TK_DELETE 105
6509 #define TK_UPDATE 106
6510 #define TK_SET 107
6511 #define TK_DEFERRABLE 108
6512 #define TK_FOREIGN 109
6513 #define TK_DROP 110
6514 #define TK_UNION 111
6515 #define TK_ALL 112
6516 #define TK_EXCEPT 113
6517 #define TK_INTERSECT 114
6518 #define TK_SELECT 115
6519 #define TK_DISTINCT 116
6520 #define TK_DOT 117
6521 #define TK_FROM 118
6522 #define TK_JOIN 119
6523 #define TK_USING 120
6524 #define TK_ORDER 121
6525 #define TK_GROUP 122
6526 #define TK_HAVING 123
6527 #define TK_LIMIT 124
6528 #define TK_WHERE 125
6529 #define TK_INTO 126
6530 #define TK_VALUES 127
6531 #define TK_INSERT 128
6532 #define TK_INTEGER 129
6533 #define TK_FLOAT 130
6534 #define TK_BLOB 131
6535 #define TK_REGISTER 132
6536 #define TK_VARIABLE 133
@@ -6536,19 +6544,22 @@
6544 #define TK_TO_TEXT 141
6545 #define TK_TO_BLOB 142
6546 #define TK_TO_NUMERIC 143
6547 #define TK_TO_INT 144
6548 #define TK_TO_REAL 145
6549 #define TK_ISNOT 146
6550 #define TK_END_OF_FILE 147
6551 #define TK_ILLEGAL 148
6552 #define TK_SPACE 149
6553 #define TK_UNCLOSED_STRING 150
6554 #define TK_FUNCTION 151
6555 #define TK_COLUMN 152
6556 #define TK_AGG_FUNCTION 153
6557 #define TK_AGG_COLUMN 154
6558 #define TK_CONST_FUNC 155
6559 #define TK_UMINUS 156
6560 #define TK_UPLUS 157
6561
6562 /************** End of parse.h ***********************************************/
6563 /************** Continuing where we left off in sqliteInt.h ******************/
6564 #include <stdio.h>
6565 #include <stdlib.h>
@@ -7308,142 +7319,142 @@
7319 #define OP_SetCookie 4
7320 #define OP_Seek 5
7321 #define OP_Real 130 /* same as TK_FLOAT */
7322 #define OP_Sequence 6
7323 #define OP_Savepoint 7
7324 #define OP_Ge 80 /* same as TK_GE */
7325 #define OP_RowKey 8
7326 #define OP_SCopy 9
7327 #define OP_Eq 76 /* same as TK_EQ */
7328 #define OP_OpenWrite 10
7329 #define OP_NotNull 74 /* same as TK_NOTNULL */
7330 #define OP_If 11
7331 #define OP_ToInt 144 /* same as TK_TO_INT */
7332 #define OP_String8 94 /* same as TK_STRING */
7333 #define OP_CollSeq 12
7334 #define OP_OpenRead 13
7335 #define OP_Expire 14
7336 #define OP_AutoCommit 15
7337 #define OP_Gt 77 /* same as TK_GT */
7338 #define OP_Pagecount 16
7339 #define OP_IntegrityCk 17
7340 #define OP_Sort 18
7341 #define OP_Copy 20
7342 #define OP_Trace 21
7343 #define OP_Function 22
7344 #define OP_IfNeg 23
7345 #define OP_And 69 /* same as TK_AND */
7346 #define OP_Subtract 87 /* same as TK_MINUS */
7347 #define OP_Noop 24
7348 #define OP_Program 25
7349 #define OP_Return 26
7350 #define OP_Remainder 90 /* same as TK_REM */
7351 #define OP_NewRowid 27
7352 #define OP_Multiply 88 /* same as TK_STAR */
7353 #define OP_FkCounter 28
7354 #define OP_Variable 29
7355 #define OP_String 30
7356 #define OP_RealAffinity 31
7357 #define OP_VRename 32
7358 #define OP_ParseSchema 33
7359 #define OP_VOpen 34
7360 #define OP_Close 35
7361 #define OP_CreateIndex 36
7362 #define OP_IsUnique 37
7363 #define OP_NotFound 38
7364 #define OP_Int64 39
7365 #define OP_MustBeInt 40
7366 #define OP_Halt 41
7367 #define OP_Rowid 42
7368 #define OP_IdxLT 43
7369 #define OP_AddImm 44
7370 #define OP_RowData 45
7371 #define OP_MemMax 46
7372 #define OP_Or 68 /* same as TK_OR */
7373 #define OP_NotExists 47
7374 #define OP_Gosub 48
7375 #define OP_Divide 89 /* same as TK_SLASH */
7376 #define OP_Integer 49
7377 #define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/
7378 #define OP_Prev 50
7379 #define OP_RowSetRead 51
7380 #define OP_Concat 91 /* same as TK_CONCAT */
7381 #define OP_RowSetAdd 52
7382 #define OP_BitAnd 82 /* same as TK_BITAND */
7383 #define OP_VColumn 53
7384 #define OP_CreateTable 54
7385 #define OP_Last 55
7386 #define OP_SeekLe 56
7387 #define OP_IsNull 73 /* same as TK_ISNULL */
7388 #define OP_IncrVacuum 57
7389 #define OP_IdxRowid 58
7390 #define OP_ShiftRight 85 /* same as TK_RSHIFT */
7391 #define OP_ResetCount 59
7392 #define OP_Yield 60
7393 #define OP_DropTrigger 61
7394 #define OP_DropIndex 62
7395 #define OP_Param 63
7396 #define OP_IdxGE 64
7397 #define OP_IdxDelete 65
7398 #define OP_Vacuum 66
7399 #define OP_IfNot 67
7400 #define OP_DropTable 70
7401 #define OP_SeekLt 71
7402 #define OP_MakeRecord 72
7403 #define OP_ToBlob 142 /* same as TK_TO_BLOB */
7404 #define OP_ResultRow 81
7405 #define OP_Delete 92
7406 #define OP_AggFinal 95
7407 #define OP_Compare 96
7408 #define OP_ShiftLeft 84 /* same as TK_LSHIFT */
7409 #define OP_Goto 97
7410 #define OP_TableLock 98
7411 #define OP_Clear 99
7412 #define OP_Le 78 /* same as TK_LE */
7413 #define OP_VerifyCookie 100
7414 #define OP_AggStep 101
7415 #define OP_ToText 141 /* same as TK_TO_TEXT */
7416 #define OP_Not 19 /* same as TK_NOT */
7417 #define OP_ToReal 145 /* same as TK_TO_REAL */
7418 #define OP_Transaction 102
7419 #define OP_VFilter 103
7420 #define OP_Ne 75 /* same as TK_NE */
7421 #define OP_VDestroy 104
7422 #define OP_BitOr 83 /* same as TK_BITOR */
7423 #define OP_Next 105
7424 #define OP_Count 106
7425 #define OP_IdxInsert 107
7426 #define OP_Lt 79 /* same as TK_LT */
7427 #define OP_FkIfZero 108
7428 #define OP_SeekGe 109
7429 #define OP_Insert 110
7430 #define OP_Destroy 111
7431 #define OP_ReadCookie 112
7432 #define OP_RowSetTest 113
7433 #define OP_LoadAnalysis 114
7434 #define OP_Explain 115
7435 #define OP_HaltIfNull 116
7436 #define OP_OpenPseudo 117
7437 #define OP_OpenEphemeral 118
7438 #define OP_Null 119
7439 #define OP_Move 120
7440 #define OP_Blob 121
7441 #define OP_Add 86 /* same as TK_PLUS */
7442 #define OP_Rewind 122
7443 #define OP_SeekGt 123
7444 #define OP_VBegin 124
7445 #define OP_VUpdate 125
7446 #define OP_IfZero 126
7447 #define OP_BitNot 93 /* same as TK_BITNOT */
7448 #define OP_VCreate 127
7449 #define OP_Found 128
7450 #define OP_IfPos 129
7451 #define OP_NullRow 131
7452 #define OP_Jump 132
7453 #define OP_Permutation 133
7454
7455 /* The following opcode values are never used */
 
 
7456 #define OP_NotUsed_134 134
7457 #define OP_NotUsed_135 135
7458 #define OP_NotUsed_136 136
7459 #define OP_NotUsed_137 137
7460 #define OP_NotUsed_138 138
@@ -7463,24 +7474,24 @@
7474 #define OPFLG_OUT3 0x0020 /* out3: P3 is an output */
7475 #define OPFLG_INITIALIZER {\
7476 /* 0 */ 0x00, 0x01, 0x00, 0x00, 0x10, 0x08, 0x02, 0x00,\
7477 /* 8 */ 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00,\
7478 /* 16 */ 0x02, 0x00, 0x01, 0x04, 0x04, 0x00, 0x00, 0x05,\
7479 /* 24 */ 0x00, 0x01, 0x04, 0x02, 0x00, 0x00, 0x02, 0x04,\
7480 /* 32 */ 0x00, 0x00, 0x00, 0x00, 0x02, 0x11, 0x11, 0x02,\
7481 /* 40 */ 0x05, 0x00, 0x02, 0x11, 0x04, 0x00, 0x08, 0x11,\
7482 /* 48 */ 0x01, 0x02, 0x01, 0x21, 0x08, 0x00, 0x02, 0x01,\
7483 /* 56 */ 0x11, 0x01, 0x02, 0x00, 0x04, 0x00, 0x00, 0x02,\
7484 /* 64 */ 0x11, 0x00, 0x00, 0x05, 0x2c, 0x2c, 0x00, 0x11,\
7485 /* 72 */ 0x00, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
7486 /* 80 */ 0x15, 0x00, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c,\
7487 /* 88 */ 0x2c, 0x2c, 0x2c, 0x2c, 0x00, 0x04, 0x02, 0x00,\
7488 /* 96 */ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,\
7489 /* 104 */ 0x00, 0x01, 0x02, 0x08, 0x01, 0x11, 0x00, 0x02,\
7490 /* 112 */ 0x02, 0x15, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02,\
7491 /* 120 */ 0x00, 0x02, 0x01, 0x11, 0x00, 0x00, 0x05, 0x00,\
7492 /* 128 */ 0x11, 0x05, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00,\
7493 /* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04,\
7494 /* 144 */ 0x04, 0x04,}
7495
7496 /************** End of opcodes.h *********************************************/
7497 /************** Continuing where we left off in vdbe.h ***********************/
@@ -8233,11 +8244,11 @@
8244 #define sqlite3_mutex_held(X) 1
8245 #define sqlite3_mutex_notheld(X) 1
8246 #define sqlite3MutexAlloc(X) ((sqlite3_mutex*)8)
8247 #define sqlite3MutexInit() SQLITE_OK
8248 #define sqlite3MutexEnd()
8249 #endif /* defined(SQLITE_MUTEX_OMIT) */
8250
8251 /************** End of mutex.h ***********************************************/
8252 /************** Continuing where we left off in sqliteInt.h ******************/
8253
8254
@@ -8270,10 +8281,11 @@
8281 struct Schema {
8282 int schema_cookie; /* Database schema version number for this file */
8283 Hash tblHash; /* All tables indexed by name */
8284 Hash idxHash; /* All (named) indices indexed by name */
8285 Hash trigHash; /* All triggers indexed by name */
8286 Hash fkeyHash; /* All foreign keys by referenced table name */
8287 Table *pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */
8288 u8 file_format; /* Schema format version for this file */
8289 u8 enc; /* Text encoding used by this database */
8290 u16 flags; /* Flags associated with this schema */
8291 int cache_size; /* Number of pages to use in the cache */
@@ -8460,10 +8472,11 @@
8472 Db aDbStatic[2]; /* Static space for the 2 default backends */
8473 Savepoint *pSavepoint; /* List of active savepoints */
8474 int nSavepoint; /* Number of non-transaction savepoints */
8475 int nStatement; /* Number of nested statement-transactions */
8476 u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
8477 i64 nDeferredCons; /* Net deferred constraints this transaction. */
8478
8479 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
8480 /* The following variables are all protected by the STATIC_MASTER
8481 ** mutex, not by sqlite3.mutex. They are used by code in notify.c.
8482 **
@@ -8516,10 +8529,11 @@
8529 #define SQLITE_LoadExtension 0x00020000 /* Enable load_extension */
8530
8531 #define SQLITE_RecoveryMode 0x00040000 /* Ignore schema errors */
8532 #define SQLITE_ReverseOrder 0x00100000 /* Reverse unordered SELECTs */
8533 #define SQLITE_RecTriggers 0x00200000 /* Enable recursive triggers */
8534 #define SQLITE_ForeignKeys 0x00400000 /* Enforce foreign key constraints */
8535
8536 /*
8537 ** Possible values for the sqlite.magic field.
8538 ** The numbers are obtained at random and have no special meaning, other
8539 ** than being distinct from one another.
@@ -8602,10 +8616,11 @@
8616 ** opened savepoint. Savepoints are added to the list by the vdbe
8617 ** OP_Savepoint instruction.
8618 */
8619 struct Savepoint {
8620 char *zName; /* Savepoint name (nul-terminated) */
8621 int nDeferredCons; /* Number of deferred fk violations */
8622 Savepoint *pNext; /* Parent savepoint (if any) */
8623 };
8624
8625 /*
8626 ** The following are used as the second parameter to sqlite3Savepoint(),
@@ -8722,10 +8737,11 @@
8737 ** Additional bit values that can be ORed with an affinity without
8738 ** changing the affinity.
8739 */
8740 #define SQLITE_JUMPIFNULL 0x08 /* jumps if either operand is NULL */
8741 #define SQLITE_STOREP2 0x10 /* Store result in reg[P2] rather than jump */
8742 #define SQLITE_NULLEQ 0x80 /* NULL=NULL */
8743
8744 /*
8745 ** An object of this type is created for each virtual table present in
8746 ** the database schema.
8747 **
@@ -8878,18 +8894,20 @@
8894 ** Each REFERENCES clause generates an instance of the following structure
8895 ** which is attached to the from-table. The to-table need not exist when
8896 ** the from-table is created. The existence of the to-table is not checked.
8897 */
8898 struct FKey {
8899 Table *pFrom; /* Table containing the REFERENCES clause (aka: Child) */
8900 FKey *pNextFrom; /* Next foreign key in pFrom */
8901 char *zTo; /* Name of table that the key points to (aka: Parent) */
8902 FKey *pNextTo; /* Next foreign key on table named zTo */
8903 FKey *pPrevTo; /* Previous foreign key on table named zTo */
8904 int nCol; /* Number of columns in this key */
8905 /* EV: R-30323-21917 */
8906 u8 isDeferred; /* True if constraint checking is deferred till COMMIT */
8907 u8 aAction[2]; /* ON DELETE and ON UPDATE actions, respectively */
8908 Trigger *apTrigger[2]; /* Triggers for aAction[] actions */
 
8909 struct sColMap { /* Mapping of columns in pFrom to columns in zTo */
8910 int iFrom; /* Index of column in pFrom */
8911 char *zCol; /* Name of column in zTo. If 0 use PRIMARY KEY */
8912 } aCol[1]; /* One entry for each of nCol column s */
8913 };
@@ -9716,10 +9734,11 @@
9734 Parse *pToplevel; /* Parse structure for main program (or NULL) */
9735 Table *pTriggerTab; /* Table triggers are being coded for */
9736 u32 oldmask; /* Mask of old.* columns referenced */
9737 u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */
9738 u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */
9739 u8 disableTriggers; /* True to disable triggers */
9740
9741 /* Above is constant between recursions. Below is reset before and after
9742 ** each recursion */
9743
9744 int nVar; /* Number of '?' variables seen in the SQL so far */
@@ -10186,11 +10205,11 @@
10205 SQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *, struct SrcList_item *);
10206 SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
10207 SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
10208 SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);
10209 SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);
10210 SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
10211 Token*, int, int);
10212 SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
10213 SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
10214 SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
10215 Expr*,ExprList*,int,Expr*,Expr*);
@@ -10257,11 +10276,12 @@
10276 SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int,
10277 int*,int,int,int,int,int*);
10278 SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int);
10279 SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int);
10280 SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
10281 SQLITE_PRIVATE void sqlite3MultiWrite(Parse*);
10282 SQLITE_PRIVATE void sqlite3MayAbort(Parse*);
10283 SQLITE_PRIVATE void sqlite3HaltConstraint(Parse*, int, char*, int);
10284 SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int);
10285 SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);
10286 SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
10287 SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);
@@ -10293,31 +10313,33 @@
10313 SQLITE_PRIVATE void sqlite3DropTrigger(Parse*, SrcList*, int);
10314 SQLITE_PRIVATE void sqlite3DropTriggerPtr(Parse*, Trigger*);
10315 SQLITE_PRIVATE Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask);
10316 SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *, Table *);
10317 SQLITE_PRIVATE void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *,
10318 int, int, int);
10319 SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);
10320 void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);
10321 SQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);
10322 SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*);
10323 SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*,
10324 ExprList*,Select*,u8);
10325 SQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8);
10326 SQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*);
10327 SQLITE_PRIVATE void sqlite3DeleteTrigger(sqlite3*, Trigger*);
10328 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
10329 SQLITE_PRIVATE u32 sqlite3TriggerOldmask(Parse*,Trigger*,ExprList*,Table*,int);
10330 # define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p))
10331 #else
10332 # define sqlite3TriggersExist(B,C,D,E,F) 0
10333 # define sqlite3DeleteTrigger(A,B)
10334 # define sqlite3DropTriggerPtr(A,B)
10335 # define sqlite3UnlinkAndDeleteTrigger(A,B,C)
10336 # define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I)
10337 # define sqlite3CodeRowTriggerDirect(A,B,C,D,E,F)
10338 # define sqlite3TriggerList(X, Y) 0
10339 # define sqlite3ParseToplevel(p) p
10340 # define sqlite3TriggerOldmask(A,B,C,D,E) 0
10341 #endif
10342
10343 SQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*);
10344 SQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);
10345 SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int);
@@ -10324,10 +10346,11 @@
10346 #ifndef SQLITE_OMIT_AUTHORIZATION
10347 SQLITE_PRIVATE void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*);
10348 SQLITE_PRIVATE int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*);
10349 SQLITE_PRIVATE void sqlite3AuthContextPush(Parse*, AuthContext*, const char*);
10350 SQLITE_PRIVATE void sqlite3AuthContextPop(AuthContext*);
10351 SQLITE_PRIVATE int sqlite3AuthReadCol(Parse*, const char *, const char *, int);
10352 #else
10353 # define sqlite3AuthRead(a,b,c,d)
10354 # define sqlite3AuthCheck(a,b,c,d,e) SQLITE_OK
10355 # define sqlite3AuthContextPush(a,b,c)
10356 # define sqlite3AuthContextPop(a) ((void)(a))
@@ -10531,10 +10554,36 @@
10554 SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
10555 SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
10556 SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*);
10557 SQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3*, Table*);
10558
10559 /* Declarations for functions in fkey.c. All of these are replaced by
10560 ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign
10561 ** key functionality is available. If OMIT_TRIGGER is defined but
10562 ** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In
10563 ** this case foreign keys are parsed, but no other functionality is
10564 ** provided (enforcement of FK constraints requires the triggers sub-system).
10565 */
10566 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
10567 SQLITE_PRIVATE void sqlite3FkCheck(Parse*, Table*, int, int);
10568 SQLITE_PRIVATE void sqlite3FkDropTable(Parse*, SrcList *, Table*);
10569 SQLITE_PRIVATE void sqlite3FkActions(Parse*, Table*, ExprList*, int);
10570 SQLITE_PRIVATE int sqlite3FkRequired(Parse*, Table*, int*, int);
10571 SQLITE_PRIVATE u32 sqlite3FkOldmask(Parse*, Table*);
10572 SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
10573 #else
10574 #define sqlite3FkActions(a,b,c,d)
10575 #define sqlite3FkCheck(a,b,c,d)
10576 #define sqlite3FkDropTable(a,b,c)
10577 #define sqlite3FkOldmask(a,b) 0
10578 #define sqlite3FkRequired(a,b,c,d) 0
10579 #endif
10580 #ifndef SQLITE_OMIT_FOREIGN_KEY
10581 SQLITE_PRIVATE void sqlite3FkDelete(Table*);
10582 #else
10583 #define sqlite3FkDelete(a)
10584 #endif
10585
10586
10587 /*
10588 ** Available fault injectors. Should be numbered beginning with 0.
10589 */
@@ -11389,11 +11438,11 @@
11438 y.D = sLocal.tm_mday;
11439 y.h = sLocal.tm_hour;
11440 y.m = sLocal.tm_min;
11441 y.s = sLocal.tm_sec;
11442 }
11443 #elif defined(HAVE_LOCALTIME_S) && HAVE_LOCALTIME_S
11444 {
11445 struct tm sLocal;
11446 localtime_s(&sLocal, &t);
11447 y.Y = sLocal.tm_year + 1900;
11448 y.M = sLocal.tm_mon + 1;
@@ -13665,10 +13714,11 @@
13714 /*
13715 ** Deinitialize this module.
13716 */
13717 static void memsys3Shutdown(void *NotUsed){
13718 UNUSED_PARAMETER(NotUsed);
13719 mem3.mutex = 0;
13720 return;
13721 }
13722
13723
13724
@@ -14505,11 +14555,11 @@
14555 SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){
14556 return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);
14557 }
14558 #endif
14559
14560 #endif /* SQLITE_MUTEX_OMIT */
14561
14562 /************** End of mutex.c ***********************************************/
14563 /************** Begin file mutex_noop.c **************************************/
14564 /*
14565 ** 2008 October 07
@@ -17770,10 +17820,12 @@
17820 i64 startTime; /* Time when query started - used for profiling */
17821 BtreeMutexArray aMutex; /* An array of Btree used here and needing locks */
17822 int aCounter[2]; /* Counters used by sqlite3_stmt_status() */
17823 char *zSql; /* Text of the SQL statement that generated this */
17824 void *pFree; /* Free this when deleting the vdbe */
17825 i64 nFkConstraint; /* Number of imm. FK constraints this VM */
17826 i64 nStmtDefCons; /* Number of def. constraints when stmt started */
17827 int iStatement; /* Statement number (or 0 if has not opened stmt) */
17828 #ifdef SQLITE_DEBUG
17829 FILE *trace; /* Write an execution trace here, if not NULL */
17830 #endif
17831 VdbeFrame *pFrame; /* Parent frame */
@@ -17841,10 +17893,16 @@
17893 SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*);
17894 SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);
17895 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
17896 SQLITE_PRIVATE int sqlite3VdbeReleaseBuffers(Vdbe *p);
17897 #endif
17898
17899 #ifndef SQLITE_OMIT_FOREIGN_KEY
17900 SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *, int);
17901 #else
17902 # define sqlite3VdbeCheckFk(p,i) 0
17903 #endif
17904
17905 #ifndef SQLITE_OMIT_SHARED_CACHE
17906 SQLITE_PRIVATE void sqlite3VdbeMutexArrayEnter(Vdbe *p);
17907 #else
17908 # define sqlite3VdbeMutexArrayEnter(p)
@@ -19803,116 +19861,116 @@
19861 /* 23 */ "IfNeg",
19862 /* 24 */ "Noop",
19863 /* 25 */ "Program",
19864 /* 26 */ "Return",
19865 /* 27 */ "NewRowid",
19866 /* 28 */ "FkCounter",
19867 /* 29 */ "Variable",
19868 /* 30 */ "String",
19869 /* 31 */ "RealAffinity",
19870 /* 32 */ "VRename",
19871 /* 33 */ "ParseSchema",
19872 /* 34 */ "VOpen",
19873 /* 35 */ "Close",
19874 /* 36 */ "CreateIndex",
19875 /* 37 */ "IsUnique",
19876 /* 38 */ "NotFound",
19877 /* 39 */ "Int64",
19878 /* 40 */ "MustBeInt",
19879 /* 41 */ "Halt",
19880 /* 42 */ "Rowid",
19881 /* 43 */ "IdxLT",
19882 /* 44 */ "AddImm",
19883 /* 45 */ "RowData",
19884 /* 46 */ "MemMax",
19885 /* 47 */ "NotExists",
19886 /* 48 */ "Gosub",
19887 /* 49 */ "Integer",
19888 /* 50 */ "Prev",
19889 /* 51 */ "RowSetRead",
19890 /* 52 */ "RowSetAdd",
19891 /* 53 */ "VColumn",
19892 /* 54 */ "CreateTable",
19893 /* 55 */ "Last",
19894 /* 56 */ "SeekLe",
19895 /* 57 */ "IncrVacuum",
19896 /* 58 */ "IdxRowid",
19897 /* 59 */ "ResetCount",
19898 /* 60 */ "Yield",
19899 /* 61 */ "DropTrigger",
19900 /* 62 */ "DropIndex",
19901 /* 63 */ "Param",
19902 /* 64 */ "IdxGE",
19903 /* 65 */ "IdxDelete",
19904 /* 66 */ "Vacuum",
19905 /* 67 */ "IfNot",
19906 /* 68 */ "Or",
19907 /* 69 */ "And",
19908 /* 70 */ "DropTable",
19909 /* 71 */ "SeekLt",
19910 /* 72 */ "MakeRecord",
19911 /* 73 */ "IsNull",
19912 /* 74 */ "NotNull",
19913 /* 75 */ "Ne",
19914 /* 76 */ "Eq",
19915 /* 77 */ "Gt",
19916 /* 78 */ "Le",
19917 /* 79 */ "Lt",
19918 /* 80 */ "Ge",
19919 /* 81 */ "ResultRow",
19920 /* 82 */ "BitAnd",
19921 /* 83 */ "BitOr",
19922 /* 84 */ "ShiftLeft",
19923 /* 85 */ "ShiftRight",
19924 /* 86 */ "Add",
19925 /* 87 */ "Subtract",
19926 /* 88 */ "Multiply",
19927 /* 89 */ "Divide",
19928 /* 90 */ "Remainder",
19929 /* 91 */ "Concat",
19930 /* 92 */ "Delete",
19931 /* 93 */ "BitNot",
19932 /* 94 */ "String8",
19933 /* 95 */ "AggFinal",
19934 /* 96 */ "Compare",
19935 /* 97 */ "Goto",
19936 /* 98 */ "TableLock",
19937 /* 99 */ "Clear",
19938 /* 100 */ "VerifyCookie",
19939 /* 101 */ "AggStep",
19940 /* 102 */ "Transaction",
19941 /* 103 */ "VFilter",
19942 /* 104 */ "VDestroy",
19943 /* 105 */ "Next",
19944 /* 106 */ "Count",
19945 /* 107 */ "IdxInsert",
19946 /* 108 */ "FkIfZero",
19947 /* 109 */ "SeekGe",
19948 /* 110 */ "Insert",
19949 /* 111 */ "Destroy",
19950 /* 112 */ "ReadCookie",
19951 /* 113 */ "RowSetTest",
19952 /* 114 */ "LoadAnalysis",
19953 /* 115 */ "Explain",
19954 /* 116 */ "HaltIfNull",
19955 /* 117 */ "OpenPseudo",
19956 /* 118 */ "OpenEphemeral",
19957 /* 119 */ "Null",
19958 /* 120 */ "Move",
19959 /* 121 */ "Blob",
19960 /* 122 */ "Rewind",
19961 /* 123 */ "SeekGt",
19962 /* 124 */ "VBegin",
19963 /* 125 */ "VUpdate",
19964 /* 126 */ "IfZero",
19965 /* 127 */ "VCreate",
19966 /* 128 */ "Found",
19967 /* 129 */ "IfPos",
19968 /* 130 */ "Real",
19969 /* 131 */ "NullRow",
19970 /* 132 */ "Jump",
19971 /* 133 */ "Permutation",
19972 /* 134 */ "NotUsed_134",
19973 /* 135 */ "NotUsed_135",
19974 /* 136 */ "NotUsed_136",
19975 /* 137 */ "NotUsed_137",
19976 /* 138 */ "NotUsed_138",
@@ -22530,11 +22588,11 @@
22588 pLock = sqlite3_malloc( sizeof(*pLock) );
22589 if( pLock==0 ){
22590 rc = SQLITE_NOMEM;
22591 goto exit_findlockinfo;
22592 }
22593 memcpy(&pLock->lockKey,&lockKey,sizeof(lockKey));
22594 pLock->nRef = 1;
22595 pLock->cnt = 0;
22596 pLock->locktype = 0;
22597 pLock->pNext = lockList;
22598 pLock->pPrev = 0;
@@ -47336,11 +47394,11 @@
47394 if( p->aLabel ){
47395 p->aLabel[j] = p->nOp;
47396 }
47397 }
47398
47399 #ifdef SQLITE_DEBUG /* sqlite3AssertMayAbort() logic */
47400
47401 /*
47402 ** The following type and function are used to iterate through all opcodes
47403 ** in a Vdbe main program and each of the sub-programs (triggers) it may
47404 ** invoke directly or indirectly. It should be used as follows:
@@ -47408,19 +47466,20 @@
47466 return pRet;
47467 }
47468
47469 /*
47470 ** Check if the program stored in the VM associated with pParse may
47471 ** throw an ABORT exception (causing the statement, but not entire transaction
47472 ** to be rolled back). This condition is true if the main program or any
47473 ** sub-programs contains any of the following:
47474 **
47475 ** * OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
47476 ** * OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
47477 ** * OP_Destroy
47478 ** * OP_VUpdate
47479 ** * OP_VRename
47480 ** * OP_FkCounter with P2==0 (immediate foreign key constraint)
47481 **
47482 ** Then check that the value of Parse.mayAbort is true if an
47483 ** ABORT may be thrown, or false otherwise. Return true if it does
47484 ** match, or false otherwise. This function is intended to be used as
47485 ** part of an assert statement in the compiler. Similar to:
@@ -47435,10 +47494,13 @@
47494 sIter.v = v;
47495
47496 while( (pOp = opIterNext(&sIter))!=0 ){
47497 int opcode = pOp->opcode;
47498 if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename
47499 #ifndef SQLITE_OMIT_FOREIGN_KEY
47500 || (opcode==OP_FkCounter && pOp->p1==0 && pOp->p2==1)
47501 #endif
47502 || ((opcode==OP_Halt || opcode==OP_HaltIfNull)
47503 && (pOp->p1==SQLITE_CONSTRAINT && pOp->p2==OE_Abort))
47504 ){
47505 hasAbort = 1;
47506 break;
@@ -47451,11 +47513,11 @@
47513 ** through all opcodes and hasAbort may be set incorrectly. Return
47514 ** true for this case to prevent the assert() in the callers frame
47515 ** from failing. */
47516 return ( v->db->mallocFailed || hasAbort==mayAbort );
47517 }
47518 #endif /* SQLITE_DEBUG - the sqlite3AssertMayAbort() function */
47519
47520 /*
47521 ** Loop through the program looking for P2 values that are negative
47522 ** on jump instructions. Each such value is a label. Resolve the
47523 ** label by setting the P2 value to its correct non-zero value.
@@ -48991,10 +49053,17 @@
49053 }
49054 }
49055 }
49056 db->nStatement--;
49057 p->iStatement = 0;
49058
49059 /* If the statement transaction is being rolled back, also restore the
49060 ** database handles deferred constraint counter to the value it had when
49061 ** the statement transaction was opened. */
49062 if( eOp==SAVEPOINT_ROLLBACK ){
49063 db->nDeferredCons = p->nStmtDefCons;
49064 }
49065 }
49066 return rc;
49067 }
49068
49069 /*
@@ -49022,10 +49091,33 @@
49091 sqlite3BtreeEnterAll(p->db);
49092 #endif
49093 }
49094 #endif
49095
49096 /*
49097 ** This function is called when a transaction opened by the database
49098 ** handle associated with the VM passed as an argument is about to be
49099 ** committed. If there are outstanding deferred foreign key constraint
49100 ** violations, return SQLITE_ERROR. Otherwise, SQLITE_OK.
49101 **
49102 ** If there are outstanding FK violations and this function returns
49103 ** SQLITE_ERROR, set the result of the VM to SQLITE_CONSTRAINT and write
49104 ** an error message to it. Then return SQLITE_ERROR.
49105 */
49106 #ifndef SQLITE_OMIT_FOREIGN_KEY
49107 SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *p, int deferred){
49108 sqlite3 *db = p->db;
49109 if( (deferred && db->nDeferredCons>0) || (!deferred && p->nFkConstraint>0) ){
49110 p->rc = SQLITE_CONSTRAINT;
49111 p->errorAction = OE_Abort;
49112 sqlite3SetString(&p->zErrMsg, db, "foreign key constraint failed");
49113 return SQLITE_ERROR;
49114 }
49115 return SQLITE_OK;
49116 }
49117 #endif
49118
49119 /*
49120 ** This routine is called the when a VDBE tries to halt. If the VDBE
49121 ** has made changes and is in autocommit mode, then commit those
49122 ** changes. If a rollback is needed, then do the rollback.
49123 **
@@ -49096,10 +49188,15 @@
49188 sqlite3CloseSavepoints(db);
49189 db->autoCommit = 1;
49190 }
49191 }
49192 }
49193
49194 /* Check for immediate foreign key violations. */
49195 if( p->rc==SQLITE_OK ){
49196 sqlite3VdbeCheckFk(p, 0);
49197 }
49198
49199 /* If the auto-commit flag is set and this is the only active writer
49200 ** VM, then we do either a commit or rollback of the current transaction.
49201 **
49202 ** Note: This block also runs if one of the special errors handled
@@ -49108,22 +49205,27 @@
49205 if( !sqlite3VtabInSync(db)
49206 && db->autoCommit
49207 && db->writeVdbeCnt==(p->readOnly==0)
49208 ){
49209 if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){
49210 if( sqlite3VdbeCheckFk(p, 1) ){
49211 sqlite3BtreeMutexArrayLeave(&p->aMutex);
49212 return SQLITE_ERROR;
49213 }
49214 /* The auto-commit flag is true, the vdbe program was successful
49215 ** or hit an 'OR FAIL' constraint and there are no deferred foreign
49216 ** key constraints to hold up the transaction. This means a commit
49217 ** is required. */
49218 rc = vdbeCommit(db, p);
49219 if( rc==SQLITE_BUSY ){
49220 sqlite3BtreeMutexArrayLeave(&p->aMutex);
49221 return SQLITE_BUSY;
49222 }else if( rc!=SQLITE_OK ){
49223 p->rc = rc;
49224 sqlite3RollbackAll(db);
49225 }else{
49226 db->nDeferredCons = 0;
49227 sqlite3CommitInternalChanges(db);
49228 }
49229 }else{
49230 sqlite3RollbackAll(db);
49231 }
@@ -50400,10 +50502,12 @@
50502 */
50503 if( db->activeVdbeCnt==0 ){
50504 db->u1.isInterrupted = 0;
50505 }
50506
50507 assert( db->writeVdbeCnt>0 || db->autoCommit==0 || db->nDeferredCons==0 );
50508
50509 #ifndef SQLITE_OMIT_TRACE
50510 if( db->xProfile && !db->init.busy ){
50511 double rNow;
50512 sqlite3OsCurrentTime(db->pVfs, &rNow);
50513 p->startTime = (u64)((rNow - (int)rNow)*3600.0*24.0*1000000000.0);
@@ -51381,10 +51485,21 @@
51485 sqlite3_max_blobsize = p->n;
51486 }
51487 }
51488 #endif
51489
51490 /*
51491 ** The next global variable is incremented each type the OP_Found opcode
51492 ** is executed. This is used to test whether or not the foreign key
51493 ** operation implemented using OP_FkIsZero is working. This variable
51494 ** has no function other than to help verify the correct operation of the
51495 ** library.
51496 */
51497 #ifdef SQLITE_TEST
51498 SQLITE_API int sqlite3_found_count = 0;
51499 #endif
51500
51501 /*
51502 ** Test a register to see if it exceeds the current maximum blob size.
51503 ** If it does, record the new maximum blob size.
51504 */
51505 #if defined(SQLITE_TEST) && !defined(SQLITE_OMIT_BUILTIN_TEST)
@@ -51990,13 +52105,12 @@
52105 struct OP_ShiftRight_stack_vars {
52106 i64 a;
52107 i64 b;
52108 } ah;
52109 struct OP_Ge_stack_vars {
52110 int res; /* Result of the comparison of pIn1 against pIn3 */
52111 char affinity; /* Affinity to use for comparison */
 
52112 } ai;
52113 struct OP_Compare_stack_vars {
52114 int n;
52115 int i;
52116 int p1;
@@ -52653,14 +52767,16 @@
52767 p->pc = pc;
52768 if( pOp->p4.z ){
52769 sqlite3SetString(&p->zErrMsg, db, "%s", pOp->p4.z);
52770 }
52771 rc = sqlite3VdbeHalt(p);
52772 assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR );
52773 if( rc==SQLITE_BUSY ){
52774 p->rc = rc = SQLITE_BUSY;
52775 }else{
52776 assert( rc==SQLITE_OK || p->rc==SQLITE_CONSTRAINT );
52777 assert( rc==SQLITE_OK || db->nDeferredCons>0 );
52778 rc = p->rc ? SQLITE_ERROR : SQLITE_DONE;
52779 }
52780 goto vdbe_return;
52781 }
52782
@@ -52901,10 +53017,19 @@
53017 int i;
53018 #endif /* local variables moved into u.ad */
53019 assert( p->nResColumn==pOp->p2 );
53020 assert( pOp->p1>0 );
53021 assert( pOp->p1+pOp->p2<=p->nMem+1 );
53022
53023 /* If this statement has violated immediate foreign key constraints, do
53024 ** not return the number of rows modified. And do not RELEASE the statement
53025 ** transaction. It needs to be rolled back. */
53026 if( SQLITE_OK!=(rc = sqlite3VdbeCheckFk(p, 0)) ){
53027 assert( db->flags&SQLITE_CountRows );
53028 assert( p->usesStmtJournal );
53029 break;
53030 }
53031
53032 /* If the SQLITE_CountRows flag is set in sqlite3.flags mask, then
53033 ** DML statements invoke this opcode to return the number of rows
53034 ** modified to the user. This is the only way that a VM that
53035 ** opens a statement transaction may invoke this opcode.
@@ -53473,16 +53598,28 @@
53598 /* Opcode: Ne P1 P2 P3 P4 P5
53599 **
53600 ** This works just like the Lt opcode except that the jump is taken if
53601 ** the operands in registers P1 and P3 are not equal. See the Lt opcode for
53602 ** additional information.
53603 **
53604 ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
53605 ** true or false and is never NULL. If both operands are NULL then the result
53606 ** of comparison is false. If either operand is NULL then the result is true.
53607 ** If neither operand is NULL the the result is the same as it would be if
53608 ** the SQLITE_NULLEQ flag were omitted from P5.
53609 */
53610 /* Opcode: Eq P1 P2 P3 P4 P5
53611 **
53612 ** This works just like the Lt opcode except that the jump is taken if
53613 ** the operands in registers P1 and P3 are equal.
53614 ** See the Lt opcode for additional information.
53615 **
53616 ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
53617 ** true or false and is never NULL. If both operands are NULL then the result
53618 ** of comparison is true. If either operand is NULL then the result is false.
53619 ** If neither operand is NULL the the result is the same as it would be if
53620 ** the SQLITE_NULLEQ flag were omitted from P5.
53621 */
53622 /* Opcode: Le P1 P2 P3 P4 P5
53623 **
53624 ** This works just like the Lt opcode except that the jump is taken if
53625 ** the content of register P3 is less than or equal to the content of
@@ -53505,42 +53642,51 @@
53642 case OP_Lt: /* same as TK_LT, jump, in1, in3 */
53643 case OP_Le: /* same as TK_LE, jump, in1, in3 */
53644 case OP_Gt: /* same as TK_GT, jump, in1, in3 */
53645 case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
53646 #if 0 /* local variables moved into u.ai */
53647 int res; /* Result of the comparison of pIn1 against pIn3 */
53648 char affinity; /* Affinity to use for comparison */
 
53649 #endif /* local variables moved into u.ai */
53650
53651 if( (pIn1->flags | pIn3->flags)&MEM_Null ){
53652 /* One or both operands are NULL */
53653 if( pOp->p5 & SQLITE_NULLEQ ){
53654 /* If SQLITE_NULLEQ is set (which will only happen if the operator is
53655 ** OP_Eq or OP_Ne) then take the jump or not depending on whether
53656 ** or not both operands are null.
53657 */
53658 assert( pOp->opcode==OP_Eq || pOp->opcode==OP_Ne );
53659 u.ai.res = (pIn1->flags & pIn3->flags & MEM_Null)==0;
53660 }else{
53661 /* SQLITE_NULLEQ is clear and at least one operand is NULL,
53662 ** then the result is always NULL.
53663 ** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
53664 */
53665 if( pOp->p5 & SQLITE_STOREP2 ){
53666 pOut = &p->aMem[pOp->p2];
53667 MemSetTypeFlag(pOut, MEM_Null);
53668 REGISTER_TRACE(pOp->p2, pOut);
53669 }else if( pOp->p5 & SQLITE_JUMPIFNULL ){
53670 pc = pOp->p2-1;
53671 }
53672 break;
53673 }
53674 }else{
53675 /* Neither operand is NULL. Do a comparison. */
53676 u.ai.affinity = pOp->p5 & SQLITE_AFF_MASK;
53677 if( u.ai.affinity ){
53678 applyAffinity(pIn1, u.ai.affinity, encoding);
53679 applyAffinity(pIn3, u.ai.affinity, encoding);
53680 if( db->mallocFailed ) goto no_mem;
53681 }
53682
53683 assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
53684 ExpandBlob(pIn1);
53685 ExpandBlob(pIn3);
53686 u.ai.res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
53687 }
53688 switch( pOp->opcode ){
53689 case OP_Eq: u.ai.res = u.ai.res==0; break;
53690 case OP_Ne: u.ai.res = u.ai.res!=0; break;
53691 case OP_Lt: u.ai.res = u.ai.res<0; break;
53692 case OP_Le: u.ai.res = u.ai.res<=0; break;
@@ -53604,13 +53750,22 @@
53750 u.aj.n = pOp->p3;
53751 u.aj.pKeyInfo = pOp->p4.pKeyInfo;
53752 assert( u.aj.n>0 );
53753 assert( u.aj.pKeyInfo!=0 );
53754 u.aj.p1 = pOp->p1;
 
53755 u.aj.p2 = pOp->p2;
53756 #if SQLITE_DEBUG
53757 if( aPermute ){
53758 int k, mx = 0;
53759 for(k=0; k<u.aj.n; k++) if( aPermute[k]>mx ) mx = aPermute[k];
53760 assert( u.aj.p1>0 && u.aj.p1+mx<=p->nMem+1 );
53761 assert( u.aj.p2>0 && u.aj.p2+mx<=p->nMem+1 );
53762 }else{
53763 assert( u.aj.p1>0 && u.aj.p1+u.aj.n<=p->nMem+1 );
53764 assert( u.aj.p2>0 && u.aj.p2+u.aj.n<=p->nMem+1 );
53765 }
53766 #endif /* SQLITE_DEBUG */
53767 for(u.aj.i=0; u.aj.i<u.aj.n; u.aj.i++){
53768 u.aj.idx = aPermute ? aPermute[u.aj.i] : u.aj.i;
53769 REGISTER_TRACE(u.aj.p1+u.aj.idx, &p->aMem[u.aj.p1+u.aj.idx]);
53770 REGISTER_TRACE(u.aj.p2+u.aj.idx, &p->aMem[u.aj.p2+u.aj.idx]);
53771 assert( u.aj.i<u.aj.pKeyInfo->nField );
@@ -54321,10 +54476,11 @@
54476 }
54477
54478 /* Link the new savepoint into the database handle's list. */
54479 u.aq.pNew->pNext = db->pSavepoint;
54480 db->pSavepoint = u.aq.pNew;
54481 u.aq.pNew->nDeferredCons = db->nDeferredCons;
54482 }
54483 }
54484 }else{
54485 u.aq.iSavepoint = 0;
54486
@@ -54358,10 +54514,13 @@
54514 ** and this is a RELEASE command, then the current transaction
54515 ** is committed.
54516 */
54517 int isTransaction = u.aq.pSavepoint->pNext==0 && db->isTransactionSavepoint;
54518 if( isTransaction && u.aq.p1==SAVEPOINT_RELEASE ){
54519 if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
54520 goto vdbe_return;
54521 }
54522 db->autoCommit = 1;
54523 if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
54524 p->pc = pc;
54525 db->autoCommit = 0;
54526 p->rc = rc = SQLITE_BUSY;
@@ -54390,18 +54549,23 @@
54549 db->pSavepoint = u.aq.pTmp->pNext;
54550 sqlite3DbFree(db, u.aq.pTmp);
54551 db->nSavepoint--;
54552 }
54553
54554 /* If it is a RELEASE, then destroy the savepoint being operated on
54555 ** too. If it is a ROLLBACK TO, then set the number of deferred
54556 ** constraint violations present in the database to the value stored
54557 ** when the savepoint was created. */
54558 if( u.aq.p1==SAVEPOINT_RELEASE ){
54559 assert( u.aq.pSavepoint==db->pSavepoint );
54560 db->pSavepoint = u.aq.pSavepoint->pNext;
54561 sqlite3DbFree(db, u.aq.pSavepoint);
54562 if( !isTransaction ){
54563 db->nSavepoint--;
54564 }
54565 }else{
54566 db->nDeferredCons = u.aq.pSavepoint->nDeferredCons;
54567 }
54568 }
54569 }
54570
54571 break;
@@ -54448,10 +54612,12 @@
54612 }else if( u.ar.desiredAutoCommit!=db->autoCommit ){
54613 if( u.ar.iRollback ){
54614 assert( u.ar.desiredAutoCommit==1 );
54615 sqlite3RollbackAll(db);
54616 db->autoCommit = 1;
54617 }else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
54618 goto vdbe_return;
54619 }else{
54620 db->autoCommit = (u8)u.ar.desiredAutoCommit;
54621 if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
54622 p->pc = pc;
54623 db->autoCommit = (u8)(1-u.ar.desiredAutoCommit);
@@ -54523,11 +54689,11 @@
54689 if( rc==SQLITE_BUSY ){
54690 p->pc = pc;
54691 p->rc = rc = SQLITE_BUSY;
54692 goto vdbe_return;
54693 }
54694 if( rc!=SQLITE_OK ){
54695 goto abort_due_to_error;
54696 }
54697
54698 if( pOp->p2 && p->usesStmtJournal
54699 && (db->autoCommit==0 || db->activeVdbeCnt>1)
@@ -54537,10 +54703,15 @@
54703 assert( db->nStatement>=0 && db->nSavepoint>=0 );
54704 db->nStatement++;
54705 p->iStatement = db->nSavepoint + db->nStatement;
54706 }
54707 rc = sqlite3BtreeBeginStmt(u.as.pBt, p->iStatement);
54708
54709 /* Store the current value of the database handles deferred constraint
54710 ** counter. If the statement transaction needs to be rolled back,
54711 ** the value of this counter needs to be restored too. */
54712 p->nStmtDefCons = db->nDeferredCons;
54713 }
54714 }
54715 break;
54716 }
54717
@@ -55156,10 +55327,14 @@
55327 VdbeCursor *pC;
55328 int res;
55329 UnpackedRecord *pIdxKey;
55330 char aTempRec[ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*3 + 7];
55331 #endif /* local variables moved into u.bb */
55332
55333 #ifdef SQLITE_TEST
55334 sqlite3_found_count++;
55335 #endif
55336
55337 u.bb.alreadyExists = 0;
55338 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
55339 u.bb.pC = p->apCsr[pOp->p1];
55340 assert( u.bb.pC!=0 );
@@ -56616,28 +56791,28 @@
56791
56792 u.bz.pProgram = pOp->p4.pProgram;
56793 u.bz.pRt = &p->aMem[pOp->p3];
56794 assert( u.bz.pProgram->nOp>0 );
56795
56796 /* If the p5 flag is clear, then recursive invocation of triggers is
56797 ** disabled for backwards compatibility (p5 is set if this sub-program
56798 ** is really a trigger, not a foreign key action, and the flag set
56799 ** and cleared by the "PRAGMA recursive_triggers" command is clear).
56800 **
56801 ** It is recursive invocation of triggers, at the SQL level, that is
56802 ** disabled. In some cases a single trigger may generate more than one
56803 ** SubProgram (if the trigger may be executed with more than one different
56804 ** ON CONFLICT algorithm). SubProgram structures associated with a
56805 ** single trigger all have the same value for the SubProgram.token
56806 ** variable. */
56807 if( pOp->p5 ){
 
56808 u.bz.t = u.bz.pProgram->token;
56809 for(u.bz.pFrame=p->pFrame; u.bz.pFrame && u.bz.pFrame->token!=u.bz.t; u.bz.pFrame=u.bz.pFrame->pParent);
56810 if( u.bz.pFrame ) break;
56811 }
56812
56813 if( p->nFrame>=db->aLimit[SQLITE_LIMIT_TRIGGER_DEPTH] ){
56814 rc = SQLITE_ERROR;
56815 sqlite3SetString(&p->zErrMsg, db, "too many levels of trigger recursion");
56816 break;
56817 }
56818
@@ -56727,10 +56902,48 @@
56902 break;
56903 }
56904
56905 #endif /* #ifndef SQLITE_OMIT_TRIGGER */
56906
56907 #ifndef SQLITE_OMIT_FOREIGN_KEY
56908 /* Opcode: FkCounter P1 P2 * * *
56909 **
56910 ** Increment a "constraint counter" by P2 (P2 may be negative or positive).
56911 ** If P1 is non-zero, the database constraint counter is incremented
56912 ** (deferred foreign key constraints). Otherwise, if P1 is zero, the
56913 ** statement counter is incremented (immediate foreign key constraints).
56914 */
56915 case OP_FkCounter: {
56916 if( pOp->p1 ){
56917 db->nDeferredCons += pOp->p2;
56918 }else{
56919 p->nFkConstraint += pOp->p2;
56920 }
56921 break;
56922 }
56923
56924 /* Opcode: FkIfZero P1 P2 * * *
56925 **
56926 ** This opcode tests if a foreign key constraint-counter is currently zero.
56927 ** If so, jump to instruction P2. Otherwise, fall through to the next
56928 ** instruction.
56929 **
56930 ** If P1 is non-zero, then the jump is taken if the database constraint-counter
56931 ** is zero (the one that counts deferred constraint violations). If P1 is
56932 ** zero, the jump is taken if the statement constraint-counter is zero
56933 ** (immediate foreign key constraint violations).
56934 */
56935 case OP_FkIfZero: { /* jump */
56936 if( pOp->p1 ){
56937 if( db->nDeferredCons==0 ) pc = pOp->p2-1;
56938 }else{
56939 if( p->nFkConstraint==0 ) pc = pOp->p2-1;
56940 }
56941 break;
56942 }
56943 #endif /* #ifndef SQLITE_OMIT_FOREIGN_KEY */
56944
56945 #ifndef SQLITE_OMIT_AUTOINCREMENT
56946 /* Opcode: MemMax P1 P2 * * *
56947 **
56948 ** P1 is a register in the root frame of this VM (the root frame is
56949 ** different from the current frame if this instruction is being executed
@@ -57677,29 +57890,49 @@
57890 sqlite3BtreeLeaveAll(db);
57891 goto blob_open_out;
57892 }
57893
57894 /* If the value is being opened for writing, check that the
57895 ** column is not indexed, and that it is not part of a foreign key.
57896 ** It is against the rules to open a column to which either of these
57897 ** descriptions applies for writing. */
57898 if( flags ){
57899 const char *zFault = 0;
57900 Index *pIdx;
57901 #ifndef SQLITE_OMIT_FOREIGN_KEY
57902 if( db->flags&SQLITE_ForeignKeys ){
57903 /* Check that the column is not part of an FK child key definition. It
57904 ** is not necessary to check if it is part of a parent key, as parent
57905 ** key columns must be indexed. The check below will pick up this
57906 ** case. */
57907 FKey *pFKey;
57908 for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
57909 int j;
57910 for(j=0; j<pFKey->nCol; j++){
57911 if( pFKey->aCol[j].iFrom==iCol ){
57912 zFault = "foreign key";
57913 }
57914 }
57915 }
57916 }
57917 #endif
57918 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
57919 int j;
57920 for(j=0; j<pIdx->nColumn; j++){
57921 if( pIdx->aiColumn[j]==iCol ){
57922 zFault = "indexed";
 
 
 
 
 
 
57923 }
57924 }
57925 }
57926 if( zFault ){
57927 sqlite3DbFree(db, zErr);
57928 zErr = sqlite3MPrintf(db, "cannot open %s column for writing", zFault);
57929 rc = SQLITE_ERROR;
57930 (void)sqlite3SafetyOff(db);
57931 sqlite3BtreeLeaveAll(db);
57932 goto blob_open_out;
57933 }
57934 }
57935
57936 v = sqlite3VdbeCreate(db);
57937 if( v ){
57938 int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
@@ -59870,11 +60103,11 @@
60103 */
60104 static char comparisonAffinity(Expr *pExpr){
60105 char aff;
60106 assert( pExpr->op==TK_EQ || pExpr->op==TK_IN || pExpr->op==TK_LT ||
60107 pExpr->op==TK_GT || pExpr->op==TK_GE || pExpr->op==TK_LE ||
60108 pExpr->op==TK_NE || pExpr->op==TK_IS || pExpr->op==TK_ISNOT );
60109 assert( pExpr->pLeft );
60110 aff = sqlite3ExprAffinity(pExpr->pLeft);
60111 if( pExpr->pRight ){
60112 aff = sqlite3CompareAffinity(pExpr->pRight, aff);
60113 }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
@@ -61961,10 +62194,23 @@
62194 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
62195 r1, r2, inReg, SQLITE_STOREP2);
62196 testcase( regFree1==0 );
62197 testcase( regFree2==0 );
62198 break;
62199 }
62200 case TK_IS:
62201 case TK_ISNOT: {
62202 testcase( op==TK_IS );
62203 testcase( op==TK_ISNOT );
62204 codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
62205 pExpr->pRight, &r2, &regFree2);
62206 op = (op==TK_IS) ? TK_EQ : TK_NE;
62207 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
62208 r1, r2, inReg, SQLITE_STOREP2 | SQLITE_NULLEQ);
62209 testcase( regFree1==0 );
62210 testcase( regFree2==0 );
62211 break;
62212 }
62213 case TK_AND:
62214 case TK_OR:
62215 case TK_PLUS:
62216 case TK_STAR:
@@ -62735,10 +62981,23 @@
62981 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
62982 r1, r2, dest, jumpIfNull);
62983 testcase( regFree1==0 );
62984 testcase( regFree2==0 );
62985 break;
62986 }
62987 case TK_IS:
62988 case TK_ISNOT: {
62989 testcase( op==TK_IS );
62990 testcase( op==TK_ISNOT );
62991 codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
62992 pExpr->pRight, &r2, &regFree2);
62993 op = (op==TK_IS) ? TK_EQ : TK_NE;
62994 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
62995 r1, r2, dest, SQLITE_NULLEQ);
62996 testcase( regFree1==0 );
62997 testcase( regFree2==0 );
62998 break;
62999 }
63000 case TK_ISNULL:
63001 case TK_NOTNULL: {
63002 assert( TK_ISNULL==OP_IsNull );
63003 assert( TK_NOTNULL==OP_NotNull );
@@ -62884,10 +63143,23 @@
63143 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
63144 r1, r2, dest, jumpIfNull);
63145 testcase( regFree1==0 );
63146 testcase( regFree2==0 );
63147 break;
63148 }
63149 case TK_IS:
63150 case TK_ISNOT: {
63151 testcase( pExpr->op==TK_IS );
63152 testcase( pExpr->op==TK_ISNOT );
63153 codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
63154 pExpr->pRight, &r2, &regFree2);
63155 op = (pExpr->op==TK_IS) ? TK_NE : TK_EQ;
63156 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
63157 r1, r2, dest, SQLITE_NULLEQ);
63158 testcase( regFree1==0 );
63159 testcase( regFree2==0 );
63160 break;
63161 }
63162 case TK_ISNULL:
63163 case TK_NOTNULL: {
63164 testcase( op==TK_ISNULL );
63165 testcase( op==TK_NOTNULL );
@@ -63346,10 +63618,73 @@
63618 zTableName, tname.z+tname.n);
63619 sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC);
63620 }
63621 }
63622
63623 /*
63624 ** This C function implements an SQL user function that is used by SQL code
63625 ** generated by the ALTER TABLE ... RENAME command to modify the definition
63626 ** of any foreign key constraints that use the table being renamed as the
63627 ** parent table. It is passed three arguments:
63628 **
63629 ** 1) The complete text of the CREATE TABLE statement being modified,
63630 ** 2) The old name of the table being renamed, and
63631 ** 3) The new name of the table being renamed.
63632 **
63633 ** It returns the new CREATE TABLE statement. For example:
63634 **
63635 ** sqlite_rename_parent('CREATE TABLE t1(a REFERENCES t2)', 't2', 't3')
63636 ** -> 'CREATE TABLE t1(a REFERENCES t3)'
63637 */
63638 #ifndef SQLITE_OMIT_FOREIGN_KEY
63639 static void renameParentFunc(
63640 sqlite3_context *context,
63641 int NotUsed,
63642 sqlite3_value **argv
63643 ){
63644 sqlite3 *db = sqlite3_context_db_handle(context);
63645 char *zOutput = 0;
63646 char *zResult;
63647 unsigned char const *zInput = sqlite3_value_text(argv[0]);
63648 unsigned char const *zOld = sqlite3_value_text(argv[1]);
63649 unsigned char const *zNew = sqlite3_value_text(argv[2]);
63650
63651 unsigned const char *z; /* Pointer to token */
63652 int n; /* Length of token z */
63653 int token; /* Type of token */
63654
63655 UNUSED_PARAMETER(NotUsed);
63656 for(z=zInput; *z; z=z+n){
63657 n = sqlite3GetToken(z, &token);
63658 if( token==TK_REFERENCES ){
63659 char *zParent;
63660 do {
63661 z += n;
63662 n = sqlite3GetToken(z, &token);
63663 }while( token==TK_SPACE );
63664
63665 zParent = sqlite3DbStrNDup(db, (const char *)z, n);
63666 if( zParent==0 ) break;
63667 sqlite3Dequote(zParent);
63668 if( 0==sqlite3StrICmp((const char *)zOld, zParent) ){
63669 char *zOut = sqlite3MPrintf(db, "%s%.*s\"%w\"",
63670 (zOutput?zOutput:""), z-zInput, zInput, (const char *)zNew
63671 );
63672 sqlite3DbFree(db, zOutput);
63673 zOutput = zOut;
63674 zInput = &z[n];
63675 }
63676 sqlite3DbFree(db, zParent);
63677 }
63678 }
63679
63680 zResult = sqlite3MPrintf(db, "%s%s", (zOutput?zOutput:""), zInput),
63681 sqlite3_result_text(context, zResult, -1, SQLITE_DYNAMIC);
63682 sqlite3DbFree(db, zOutput);
63683 }
63684 #endif
63685
63686 #ifndef SQLITE_OMIT_TRIGGER
63687 /* This function is used by SQL generated to implement the
63688 ** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER
63689 ** statement. The second is a table name. The table name in the CREATE
63690 ** TRIGGER statement is replaced with the third argument and the result
@@ -63433,22 +63768,69 @@
63768 renameTableFunc, 0, 0);
63769 #ifndef SQLITE_OMIT_TRIGGER
63770 sqlite3CreateFunc(db, "sqlite_rename_trigger", 2, SQLITE_UTF8, 0,
63771 renameTriggerFunc, 0, 0);
63772 #endif
63773 #ifndef SQLITE_OMIT_FOREIGN_KEY
63774 sqlite3CreateFunc(db, "sqlite_rename_parent", 3, SQLITE_UTF8, 0,
63775 renameParentFunc, 0, 0);
63776 #endif
63777 }
63778
63779 /*
63780 ** This function is used to create the text of expressions of the form:
63781 **
63782 ** name=<constant1> OR name=<constant2> OR ...
63783 **
63784 ** If argument zWhere is NULL, then a pointer string containing the text
63785 ** "name=<constant>" is returned, where <constant> is the quoted version
63786 ** of the string passed as argument zConstant. The returned buffer is
63787 ** allocated using sqlite3DbMalloc(). It is the responsibility of the
63788 ** caller to ensure that it is eventually freed.
63789 **
63790 ** If argument zWhere is not NULL, then the string returned is
63791 ** "<where> OR name=<constant>", where <where> is the contents of zWhere.
63792 ** In this case zWhere is passed to sqlite3DbFree() before returning.
63793 **
63794 */
63795 static char *whereOrName(sqlite3 *db, char *zWhere, char *zConstant){
63796 char *zNew;
63797 if( !zWhere ){
63798 zNew = sqlite3MPrintf(db, "name=%Q", zConstant);
63799 }else{
63800 zNew = sqlite3MPrintf(db, "%s OR name=%Q", zWhere, zConstant);
63801 sqlite3DbFree(db, zWhere);
63802 }
63803 return zNew;
63804 }
63805
63806 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
63807 /*
63808 ** Generate the text of a WHERE expression which can be used to select all
63809 ** tables that have foreign key constraints that refer to table pTab (i.e.
63810 ** constraints for which pTab is the parent table) from the sqlite_master
63811 ** table.
63812 */
63813 static char *whereForeignKeys(Parse *pParse, Table *pTab){
63814 FKey *p;
63815 char *zWhere = 0;
63816 for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){
63817 zWhere = whereOrName(pParse->db, zWhere, p->pFrom->zName);
63818 }
63819 return zWhere;
63820 }
63821 #endif
63822
63823 /*
63824 ** Generate the text of a WHERE expression which can be used to select all
63825 ** temporary triggers on table pTab from the sqlite_temp_master table. If
63826 ** table pTab has no temporary triggers, or is itself stored in the
63827 ** temporary database, NULL is returned.
63828 */
63829 static char *whereTempTriggers(Parse *pParse, Table *pTab){
63830 Trigger *pTrig;
63831 char *zWhere = 0;
 
63832 const Schema *pTempSchema = pParse->db->aDb[1].pSchema; /* Temp db schema */
63833
63834 /* If the table is not located in the temp-db (in which case NULL is
63835 ** returned, loop through the tables list of triggers. For each trigger
63836 ** that is not part of the temp-db schema, add a clause to the WHERE
@@ -63456,17 +63838,11 @@
63838 */
63839 if( pTab->pSchema!=pTempSchema ){
63840 sqlite3 *db = pParse->db;
63841 for(pTrig=sqlite3TriggerList(pParse, pTab); pTrig; pTrig=pTrig->pNext){
63842 if( pTrig->pSchema==pTempSchema ){
63843 zWhere = whereOrName(db, zWhere, pTrig->zName);
 
 
 
 
 
 
63844 }
63845 }
63846 }
63847 return zWhere;
63848 }
@@ -63500,11 +63876,11 @@
63876 assert( iTrigDb==iDb || iTrigDb==1 );
63877 sqlite3VdbeAddOp4(v, OP_DropTrigger, iTrigDb, 0, 0, pTrig->zName, 0);
63878 }
63879 #endif
63880
63881 /* Drop the table and index from the internal schema. */
63882 sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);
63883
63884 /* Reload the table, index and permanent trigger schemas. */
63885 zWhere = sqlite3MPrintf(pParse->db, "tbl_name=%Q", zName);
63886 if( !zWhere ) return;
@@ -63630,10 +64006,25 @@
64006 #endif
64007
64008 /* figure out how many UTF-8 characters are in zName */
64009 zTabName = pTab->zName;
64010 nTabName = sqlite3Utf8CharLen(zTabName, -1);
64011
64012 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
64013 if( db->flags&SQLITE_ForeignKeys ){
64014 /* If foreign-key support is enabled, rewrite the CREATE TABLE
64015 ** statements corresponding to all child tables of foreign key constraints
64016 ** for which the renamed table is the parent table. */
64017 if( (zWhere=whereForeignKeys(pParse, pTab))!=0 ){
64018 sqlite3NestedParse(pParse,
64019 "UPDATE sqlite_master SET "
64020 "sql = sqlite_rename_parent(sql, %Q, %Q) "
64021 "WHERE %s;", zTabName, zName, zWhere);
64022 sqlite3DbFree(db, zWhere);
64023 }
64024 }
64025 #endif
64026
64027 /* Modify the sqlite_master table to use the new table name. */
64028 sqlite3NestedParse(pParse,
64029 "UPDATE %Q.%s SET "
64030 #ifdef SQLITE_OMIT_TRIGGER
@@ -63679,10 +64070,22 @@
64070 "UPDATE sqlite_temp_master SET "
64071 "sql = sqlite_rename_trigger(sql, %Q), "
64072 "tbl_name = %Q "
64073 "WHERE %s;", zName, zName, zWhere);
64074 sqlite3DbFree(db, zWhere);
64075 }
64076 #endif
64077
64078 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
64079 if( db->flags&SQLITE_ForeignKeys ){
64080 FKey *p;
64081 for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){
64082 Table *pFrom = p->pFrom;
64083 if( pFrom!=pTab ){
64084 reloadTableSchema(pParse, p->pFrom, pFrom->zName);
64085 }
64086 }
64087 }
64088 #endif
64089
64090 /* Drop and reload the internal table schema. */
64091 reloadTableSchema(pParse, pTab, zName);
@@ -63775,10 +64178,15 @@
64178 return;
64179 }
64180 if( pNew->pIndex ){
64181 sqlite3ErrorMsg(pParse, "Cannot add a UNIQUE column");
64182 return;
64183 }
64184 if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){
64185 sqlite3ErrorMsg(pParse,
64186 "Cannot add a REFERENCES column with non-NULL default value");
64187 return;
64188 }
64189 if( pCol->notNull && !pDflt ){
64190 sqlite3ErrorMsg(pParse,
64191 "Cannot add a NOT NULL column with default value NULL");
64192 return;
@@ -65206,10 +65614,43 @@
65614 */
65615 static void sqliteAuthBadReturnCode(Parse *pParse){
65616 sqlite3ErrorMsg(pParse, "authorizer malfunction");
65617 pParse->rc = SQLITE_ERROR;
65618 }
65619
65620 /*
65621 ** Invoke the authorization callback for permission to read column zCol from
65622 ** table zTab in database zDb. This function assumes that an authorization
65623 ** callback has been registered (i.e. that sqlite3.xAuth is not NULL).
65624 **
65625 ** If SQLITE_IGNORE is returned and pExpr is not NULL, then pExpr is changed
65626 ** to an SQL NULL expression. Otherwise, if pExpr is NULL, then SQLITE_IGNORE
65627 ** is treated as SQLITE_DENY. In this case an error is left in pParse.
65628 */
65629 SQLITE_PRIVATE int sqlite3AuthReadCol(
65630 Parse *pParse, /* The parser context */
65631 const char *zTab, /* Table name */
65632 const char *zCol, /* Column name */
65633 int iDb /* Index of containing database. */
65634 ){
65635 sqlite3 *db = pParse->db; /* Database handle */
65636 char *zDb = db->aDb[iDb].zName; /* Name of attached database */
65637 int rc; /* Auth callback return code */
65638
65639 rc = db->xAuth(db->pAuthArg, SQLITE_READ, zTab,zCol,zDb,pParse->zAuthContext);
65640 if( rc==SQLITE_DENY ){
65641 if( db->nDb>2 || iDb!=0 ){
65642 sqlite3ErrorMsg(pParse, "access to %s.%s.%s is prohibited",zDb,zTab,zCol);
65643 }else{
65644 sqlite3ErrorMsg(pParse, "access to %s.%s is prohibited", zTab, zCol);
65645 }
65646 pParse->rc = SQLITE_AUTH;
65647 }else if( rc!=SQLITE_IGNORE && rc!=SQLITE_OK ){
65648 sqliteAuthBadReturnCode(pParse);
65649 }
65650 return rc;
65651 }
65652
65653 /*
65654 ** The pExpr should be a TK_COLUMN expression. The table referred to
65655 ** is in pTabList or else it is the NEW or OLD table of a trigger.
65656 ** Check to see if it is OK to read this particular column.
@@ -65223,15 +65664,13 @@
65664 Expr *pExpr, /* The expression to check authorization on */
65665 Schema *pSchema, /* The schema of the expression */
65666 SrcList *pTabList /* All table that pExpr might refer to */
65667 ){
65668 sqlite3 *db = pParse->db;
 
65669 Table *pTab = 0; /* The table being read */
65670 const char *zCol; /* Name of the column of the table */
65671 int iSrc; /* Index in pTabList->a[] of table being read */
 
65672 int iDb; /* The index of the database the expression refers to */
65673 int iCol; /* Index of column in table */
65674
65675 if( db->xAuth==0 ) return;
65676 iDb = sqlite3SchemaToIndex(pParse->db, pSchema);
@@ -65264,25 +65703,12 @@
65703 zCol = pTab->aCol[pTab->iPKey].zName;
65704 }else{
65705 zCol = "ROWID";
65706 }
65707 assert( iDb>=0 && iDb<db->nDb );
65708 if( SQLITE_IGNORE==sqlite3AuthReadCol(pParse, pTab->zName, zCol, iDb) ){
 
 
 
65709 pExpr->op = TK_NULL;
 
 
 
 
 
 
 
 
 
 
65710 }
65711 }
65712
65713 /*
65714 ** Do an authorization check using the code and arguments given. Return
@@ -65547,10 +65973,13 @@
65973 #ifdef SQLITE_DEBUG
65974 FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stdout : 0;
65975 sqlite3VdbeTrace(v, trace);
65976 #endif
65977 assert( pParse->iCacheLevel==0 ); /* Disables and re-enables match */
65978 /* A minimum of one cursor is required if autoincrement is used
65979 * See ticket [a696379c1f08866] */
65980 if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;
65981 sqlite3VdbeMakeReady(v, pParse->nVar, pParse->nMem,
65982 pParse->nTab, pParse->nMaxArg, pParse->explain,
65983 pParse->isMultiWrite && pParse->mayAbort);
65984 pParse->rc = SQLITE_DONE;
65985 pParse->colNamesSet = 0;
@@ -65852,11 +66281,10 @@
66281 ** memory structures of the indices and foreign keys associated with
66282 ** the table.
66283 */
66284 SQLITE_PRIVATE void sqlite3DeleteTable(Table *pTable){
66285 Index *pIndex, *pNext;
 
66286 sqlite3 *db;
66287
66288 if( pTable==0 ) return;
66289 db = pTable->dbMem;
66290 testcase( db==0 );
@@ -65874,17 +66302,12 @@
66302 pNext = pIndex->pNext;
66303 assert( pIndex->pSchema==pTable->pSchema );
66304 sqlite3DeleteIndex(pIndex);
66305 }
66306
66307 /* Delete any foreign keys attached to this table. */
66308 sqlite3FkDelete(pTable);
 
 
 
 
 
66309
66310 /* Delete the Table structure itself.
66311 */
66312 sqliteResetColumnNames(pTable);
66313 sqlite3DbFree(db, pTable->zName);
@@ -66522,11 +66945,15 @@
66945 #ifndef SQLITE_OMIT_AUTOINCREMENT
66946 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
66947 "INTEGER PRIMARY KEY");
66948 #endif
66949 }else{
66950 Index *p;
66951 p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0);
66952 if( p ){
66953 p->autoIndex = 2;
66954 }
66955 pList = 0;
66956 }
66957
66958 primary_key_exit:
66959 sqlite3ExprListDelete(pParse->db, pList);
@@ -67411,10 +67838,11 @@
67838 #ifndef SQLITE_OMIT_VIRTUALTABLE
67839 if( IsVirtual(pTab) ){
67840 sqlite3VdbeAddOp0(v, OP_VBegin);
67841 }
67842 #endif
67843 sqlite3FkDropTable(pParse, pName, pTab);
67844
67845 /* Drop all triggers associated with the table being dropped. Code
67846 ** is generated to remove entries from sqlite_master and/or
67847 ** sqlite_temp_master if required.
67848 */
@@ -67501,10 +67929,11 @@
67929 int flags /* Conflict resolution algorithms. */
67930 ){
67931 sqlite3 *db = pParse->db;
67932 #ifndef SQLITE_OMIT_FOREIGN_KEY
67933 FKey *pFKey = 0;
67934 FKey *pNextTo;
67935 Table *p = pParse->pNewTable;
67936 int nByte;
67937 int i;
67938 int nCol;
67939 char *z;
@@ -67575,13 +68004,25 @@
68004 z[n] = 0;
68005 z += n+1;
68006 }
68007 }
68008 pFKey->isDeferred = 0;
68009 pFKey->aAction[0] = (u8)(flags & 0xff); /* ON DELETE action */
68010 pFKey->aAction[1] = (u8)((flags >> 8 ) & 0xff); /* ON UPDATE action */
68011
68012 pNextTo = (FKey *)sqlite3HashInsert(&p->pSchema->fkeyHash,
68013 pFKey->zTo, sqlite3Strlen30(pFKey->zTo), (void *)pFKey
68014 );
68015 if( pNextTo==pFKey ){
68016 db->mallocFailed = 1;
68017 goto fk_end;
68018 }
68019 if( pNextTo ){
68020 assert( pNextTo->pPrevTo==0 );
68021 pFKey->pNextTo = pNextTo;
68022 pNextTo->pPrevTo = pFKey;
68023 }
68024
68025 /* Link the foreign key to the table as the last step.
68026 */
68027 p->pFKey = pFKey;
68028 pFKey = 0;
@@ -67603,11 +68044,11 @@
68044 SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse *pParse, int isDeferred){
68045 #ifndef SQLITE_OMIT_FOREIGN_KEY
68046 Table *pTab;
68047 FKey *pFKey;
68048 if( (pTab = pParse->pNewTable)==0 || (pFKey = pTab->pFKey)==0 ) return;
68049 assert( isDeferred==0 || isDeferred==1 ); /* EV: R-30323-21917 */
68050 pFKey->isDeferred = (u8)isDeferred;
68051 #endif
68052 }
68053
68054 /*
@@ -67698,12 +68139,16 @@
68139 ** currently being constructed by a CREATE TABLE statement.
68140 **
68141 ** pList is a list of columns to be indexed. pList will be NULL if this
68142 ** is a primary key or unique-constraint on the most recent column added
68143 ** to the table currently under construction.
68144 **
68145 ** If the index is created successfully, return a pointer to the new Index
68146 ** structure. This is used by sqlite3AddPrimaryKey() to mark the index
68147 ** as the tables primary key (Index.autoIndex==2).
68148 */
68149 SQLITE_PRIVATE Index *sqlite3CreateIndex(
68150 Parse *pParse, /* All information about this parse */
68151 Token *pName1, /* First part of index name. May be NULL */
68152 Token *pName2, /* Second part of index name. May be NULL */
68153 SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
68154 ExprList *pList, /* A list of columns to be indexed */
@@ -67711,10 +68156,11 @@
68156 Token *pStart, /* The CREATE token that begins this statement */
68157 Token *pEnd, /* The ")" that closes the CREATE INDEX statement */
68158 int sortOrder, /* Sort order of primary key when pList==NULL */
68159 int ifNotExist /* Omit error if index already exists */
68160 ){
68161 Index *pRet = 0; /* Pointer to return */
68162 Table *pTab = 0; /* Table to be indexed */
68163 Index *pIndex = 0; /* The index to be created */
68164 char *zName = 0; /* Name of the index */
68165 int nName; /* Number of characters in zName */
68166 int i, j;
@@ -68146,10 +68592,11 @@
68592 pOther = pOther->pNext;
68593 }
68594 pIndex->pNext = pOther->pNext;
68595 pOther->pNext = pIndex;
68596 }
68597 pRet = pIndex;
68598 pIndex = 0;
68599 }
68600
68601 /* Clean up before exiting */
68602 exit_create_index:
@@ -68158,11 +68605,11 @@
68605 sqlite3DbFree(db, pIndex);
68606 }
68607 sqlite3ExprListDelete(db, pList);
68608 sqlite3SrcListDelete(db, pTblName);
68609 sqlite3DbFree(db, zName);
68610 return pRet;
68611 }
68612
68613 /*
68614 ** Fill the Index.aiRowEst[] array with default information - information
68615 ** to be used when we have not run the ANALYZE command.
@@ -68823,14 +69270,38 @@
69270 Parse *pToplevel = sqlite3ParseToplevel(pParse);
69271 sqlite3CodeVerifySchema(pParse, iDb);
69272 pToplevel->writeMask |= 1<<iDb;
69273 pToplevel->isMultiWrite |= setStatement;
69274 }
69275
69276 /*
69277 ** Indicate that the statement currently under construction might write
69278 ** more than one entry (example: deleting one row then inserting another,
69279 ** inserting multiple rows in a table, or inserting a row and index entries.)
69280 ** If an abort occurs after some of these writes have completed, then it will
69281 ** be necessary to undo the completed writes.
69282 */
69283 SQLITE_PRIVATE void sqlite3MultiWrite(Parse *pParse){
69284 Parse *pToplevel = sqlite3ParseToplevel(pParse);
69285 pToplevel->isMultiWrite = 1;
69286 }
69287
69288 /*
69289 ** The code generator calls this routine if is discovers that it is
69290 ** possible to abort a statement prior to completion. In order to
69291 ** perform this abort without corrupting the database, we need to make
69292 ** sure that the statement is protected by a statement transaction.
69293 **
69294 ** Technically, we only need to set the mayAbort flag if the
69295 ** isMultiWrite flag was previously set. There is a time dependency
69296 ** such that the abort must occur after the multiwrite. This makes
69297 ** some statements involving the REPLACE conflict resolution algorithm
69298 ** go a little faster. But taking advantage of this time dependency
69299 ** makes it more difficult to prove that the code is correct (in
69300 ** particular, it prevents us from writing an effective
69301 ** implementation of sqlite3AssertMayAbort()) and so we have chosen
69302 ** to take the safe route and skip the optimization.
69303 */
69304 SQLITE_PRIVATE void sqlite3MayAbort(Parse *pParse){
69305 Parse *pToplevel = sqlite3ParseToplevel(pParse);
69306 pToplevel->mayAbort = 1;
69307 }
@@ -69437,10 +69908,11 @@
69908 Table *pTab = sqliteHashData(pElem);
69909 assert( pTab->dbMem==0 );
69910 sqlite3DeleteTable(pTab);
69911 }
69912 sqlite3HashClear(&temp1);
69913 sqlite3HashClear(&pSchema->fkeyHash);
69914 pSchema->pSeqTab = 0;
69915 pSchema->flags &= ~DB_SchemaLoaded;
69916 }
69917
69918 /*
@@ -69458,10 +69930,11 @@
69930 db->mallocFailed = 1;
69931 }else if ( 0==p->file_format ){
69932 sqlite3HashInit(&p->tblHash);
69933 sqlite3HashInit(&p->idxHash);
69934 sqlite3HashInit(&p->trigHash);
69935 sqlite3HashInit(&p->fkeyHash);
69936 p->enc = SQLITE_UTF8;
69937 }
69938 return p;
69939 }
69940
@@ -69774,11 +70247,11 @@
70247 v = sqlite3GetVdbe(pParse);
70248 if( v==0 ){
70249 goto delete_from_cleanup;
70250 }
70251 if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);
70252 sqlite3BeginWriteOperation(pParse, 1, iDb);
70253
70254 /* If we are trying to delete from a view, realize that view into
70255 ** a ephemeral table.
70256 */
70257 #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
@@ -69807,11 +70280,13 @@
70280 #ifndef SQLITE_OMIT_TRUNCATE_OPTIMIZATION
70281 /* Special case: A DELETE without a WHERE clause deletes everything.
70282 ** It is easier just to erase the whole table. Prior to version 3.6.5,
70283 ** this optimization caused the row change count (the value returned by
70284 ** API function sqlite3_count_changes) to be set incorrectly. */
70285 if( rcauth==SQLITE_OK && pWhere==0 && !pTrigger && !IsVirtual(pTab)
70286 && 0==sqlite3FkRequired(pParse, pTab, 0, 0)
70287 ){
70288 assert( !isView );
70289 sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt,
70290 pTab->zName, P4_STATIC);
70291 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
70292 assert( pIdx->pSchema==pTab->pSchema );
@@ -69903,20 +70378,29 @@
70378 sqlite3AuthContextPop(&sContext);
70379 sqlite3SrcListDelete(db, pTabList);
70380 sqlite3ExprDelete(db, pWhere);
70381 return;
70382 }
70383 /* Make sure "isView" and other macros defined above are undefined. Otherwise
70384 ** thely may interfere with compilation of other functions in this file
70385 ** (or in another file, if this file becomes part of the amalgamation). */
70386 #ifdef isView
70387 #undef isView
70388 #endif
70389 #ifdef pTrigger
70390 #undef pTrigger
70391 #endif
70392
70393 /*
70394 ** This routine generates VDBE code that causes a single row of a
70395 ** single table to be deleted.
70396 **
70397 ** The VDBE must be in a particular state when this routine is called.
70398 ** These are the requirements:
70399 **
70400 ** 1. A read/write cursor pointing to pTab, the table containing the row
70401 ** to be deleted, must be opened as cursor number $iCur.
70402 **
70403 ** 2. Read/write cursors for all indices of pTab must be open as
70404 ** cursor number base+i for the i-th index.
70405 **
70406 ** 3. The record number of the row to be deleted must be stored in
@@ -69947,17 +70431,18 @@
70431 iLabel = sqlite3VdbeMakeLabel(v);
70432 sqlite3VdbeAddOp3(v, OP_NotExists, iCur, iLabel, iRowid);
70433
70434 /* If there are any triggers to fire, allocate a range of registers to
70435 ** use for the old.* references in the triggers. */
70436 if( sqlite3FkRequired(pParse, pTab, 0, 0) || pTrigger ){
70437 u32 mask; /* Mask of OLD.* columns in use */
70438 int iCol; /* Iterator used while populating OLD.* */
70439
70440 /* TODO: Could use temporary registers here. Also could attempt to
70441 ** avoid copying the contents of the rowid register. */
70442 mask = sqlite3TriggerOldmask(pParse, pTrigger, 0, pTab, onconf);
70443 mask |= sqlite3FkOldmask(pParse, pTab);
70444 iOld = pParse->nMem+1;
70445 pParse->nMem += (1 + pTab->nCol);
70446
70447 /* Populate the OLD.* pseudo-table register array. These values will be
70448 ** used by any BEFORE and AFTER triggers that exist. */
@@ -69968,20 +70453,25 @@
70453 sqlite3VdbeAddOp3(v, OP_Column, iCur, iCol, iTarget);
70454 sqlite3ColumnDefault(v, pTab, iCol, iTarget);
70455 }
70456 }
70457
70458 /* Invoke BEFORE DELETE trigger programs. */
70459 sqlite3CodeRowTrigger(pParse, pTrigger,
70460 TK_DELETE, 0, TRIGGER_BEFORE, pTab, iOld, onconf, iLabel
70461 );
70462
70463 /* Seek the cursor to the row to be deleted again. It may be that
70464 ** the BEFORE triggers coded above have already removed the row
70465 ** being deleted. Do not attempt to delete the row a second time, and
70466 ** do not fire AFTER triggers. */
70467 sqlite3VdbeAddOp3(v, OP_NotExists, iCur, iLabel, iRowid);
70468
70469 /* Do FK processing. This call checks that any FK constraints that
70470 ** refer to this table (i.e. constraints attached to other tables)
70471 ** are not violated by deleting this row. */
70472 sqlite3FkCheck(pParse, pTab, iOld, 0);
70473 }
70474
70475 /* Delete the index and table entries. Skip this step if pTab is really
70476 ** a view (in which case the only effect of the DELETE statement is to
70477 ** fire the INSTEAD OF triggers). */
@@ -69991,16 +70481,19 @@
70481 if( count ){
70482 sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_STATIC);
70483 }
70484 }
70485
70486 /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to
70487 ** handle rows (possibly in other tables) that refer via a foreign key
70488 ** to the row just deleted. */
70489 sqlite3FkActions(pParse, pTab, 0, iOld);
70490
70491 /* Invoke AFTER DELETE trigger programs. */
70492 sqlite3CodeRowTrigger(pParse, pTrigger,
70493 TK_DELETE, 0, TRIGGER_AFTER, pTab, iOld, onconf, iLabel
70494 );
70495
70496 /* Jump here if the row had already been deleted before any BEFORE
70497 ** trigger programs were invoked. Or if a trigger program throws a
70498 ** RAISE(IGNORE) exception. */
70499 sqlite3VdbeResolveLabel(v, iLabel);
@@ -70082,14 +70575,10 @@
70575 }
70576 sqlite3ReleaseTempRange(pParse, regBase, nCol+1);
70577 return regBase;
70578 }
70579
 
 
 
 
70580
70581 /************** End of delete.c **********************************************/
70582 /************** Begin file func.c ********************************************/
70583 /*
70584 ** 2002 February 23
@@ -71576,10 +72065,1203 @@
72065 }
72066 sqlite3RegisterDateTimeFunctions();
72067 }
72068
72069 /************** End of func.c ************************************************/
72070 /************** Begin file fkey.c ********************************************/
72071 /*
72072 **
72073 ** The author disclaims copyright to this source code. In place of
72074 ** a legal notice, here is a blessing:
72075 **
72076 ** May you do good and not evil.
72077 ** May you find forgiveness for yourself and forgive others.
72078 ** May you share freely, never taking more than you give.
72079 **
72080 *************************************************************************
72081 ** This file contains code used by the compiler to add foreign key
72082 ** support to compiled SQL statements.
72083 */
72084
72085 #ifndef SQLITE_OMIT_FOREIGN_KEY
72086 #ifndef SQLITE_OMIT_TRIGGER
72087
72088 /*
72089 ** Deferred and Immediate FKs
72090 ** --------------------------
72091 **
72092 ** Foreign keys in SQLite come in two flavours: deferred and immediate.
72093 ** If an immediate foreign key constraint is violated, SQLITE_CONSTRAINT
72094 ** is returned and the current statement transaction rolled back. If a
72095 ** deferred foreign key constraint is violated, no action is taken
72096 ** immediately. However if the application attempts to commit the
72097 ** transaction before fixing the constraint violation, the attempt fails.
72098 **
72099 ** Deferred constraints are implemented using a simple counter associated
72100 ** with the database handle. The counter is set to zero each time a
72101 ** database transaction is opened. Each time a statement is executed
72102 ** that causes a foreign key violation, the counter is incremented. Each
72103 ** time a statement is executed that removes an existing violation from
72104 ** the database, the counter is decremented. When the transaction is
72105 ** committed, the commit fails if the current value of the counter is
72106 ** greater than zero. This scheme has two big drawbacks:
72107 **
72108 ** * When a commit fails due to a deferred foreign key constraint,
72109 ** there is no way to tell which foreign constraint is not satisfied,
72110 ** or which row it is not satisfied for.
72111 **
72112 ** * If the database contains foreign key violations when the
72113 ** transaction is opened, this may cause the mechanism to malfunction.
72114 **
72115 ** Despite these problems, this approach is adopted as it seems simpler
72116 ** than the alternatives.
72117 **
72118 ** INSERT operations:
72119 **
72120 ** I.1) For each FK for which the table is the child table, search
72121 ** the parent table for a match. If none is found increment the
72122 ** constraint counter.
72123 **
72124 ** I.2) For each FK for which the table is the parent table,
72125 ** search the child table for rows that correspond to the new
72126 ** row in the parent table. Decrement the counter for each row
72127 ** found (as the constraint is now satisfied).
72128 **
72129 ** DELETE operations:
72130 **
72131 ** D.1) For each FK for which the table is the child table,
72132 ** search the parent table for a row that corresponds to the
72133 ** deleted row in the child table. If such a row is not found,
72134 ** decrement the counter.
72135 **
72136 ** D.2) For each FK for which the table is the parent table, search
72137 ** the child table for rows that correspond to the deleted row
72138 ** in the parent table. For each found increment the counter.
72139 **
72140 ** UPDATE operations:
72141 **
72142 ** An UPDATE command requires that all 4 steps above are taken, but only
72143 ** for FK constraints for which the affected columns are actually
72144 ** modified (values must be compared at runtime).
72145 **
72146 ** Note that I.1 and D.1 are very similar operations, as are I.2 and D.2.
72147 ** This simplifies the implementation a bit.
72148 **
72149 ** For the purposes of immediate FK constraints, the OR REPLACE conflict
72150 ** resolution is considered to delete rows before the new row is inserted.
72151 ** If a delete caused by OR REPLACE violates an FK constraint, an exception
72152 ** is thrown, even if the FK constraint would be satisfied after the new
72153 ** row is inserted.
72154 **
72155 ** Immediate constraints are usually handled similarly. The only difference
72156 ** is that the counter used is stored as part of each individual statement
72157 ** object (struct Vdbe). If, after the statement has run, its immediate
72158 ** constraint counter is greater than zero, it returns SQLITE_CONSTRAINT
72159 ** and the statement transaction is rolled back. An exception is an INSERT
72160 ** statement that inserts a single row only (no triggers). In this case,
72161 ** instead of using a counter, an exception is thrown immediately if the
72162 ** INSERT violates a foreign key constraint. This is necessary as such
72163 ** an INSERT does not open a statement transaction.
72164 **
72165 ** TODO: How should dropping a table be handled? How should renaming a
72166 ** table be handled?
72167 **
72168 **
72169 ** Query API Notes
72170 ** ---------------
72171 **
72172 ** Before coding an UPDATE or DELETE row operation, the code-generator
72173 ** for those two operations needs to know whether or not the operation
72174 ** requires any FK processing and, if so, which columns of the original
72175 ** row are required by the FK processing VDBE code (i.e. if FKs were
72176 ** implemented using triggers, which of the old.* columns would be
72177 ** accessed). No information is required by the code-generator before
72178 ** coding an INSERT operation. The functions used by the UPDATE/DELETE
72179 ** generation code to query for this information are:
72180 **
72181 ** sqlite3FkRequired() - Test to see if FK processing is required.
72182 ** sqlite3FkOldmask() - Query for the set of required old.* columns.
72183 **
72184 **
72185 ** Externally accessible module functions
72186 ** --------------------------------------
72187 **
72188 ** sqlite3FkCheck() - Check for foreign key violations.
72189 ** sqlite3FkActions() - Code triggers for ON UPDATE/ON DELETE actions.
72190 ** sqlite3FkDelete() - Delete an FKey structure.
72191 */
72192
72193 /*
72194 ** VDBE Calling Convention
72195 ** -----------------------
72196 **
72197 ** Example:
72198 **
72199 ** For the following INSERT statement:
72200 **
72201 ** CREATE TABLE t1(a, b INTEGER PRIMARY KEY, c);
72202 ** INSERT INTO t1 VALUES(1, 2, 3.1);
72203 **
72204 ** Register (x): 2 (type integer)
72205 ** Register (x+1): 1 (type integer)
72206 ** Register (x+2): NULL (type NULL)
72207 ** Register (x+3): 3.1 (type real)
72208 */
72209
72210 /*
72211 ** A foreign key constraint requires that the key columns in the parent
72212 ** table are collectively subject to a UNIQUE or PRIMARY KEY constraint.
72213 ** Given that pParent is the parent table for foreign key constraint pFKey,
72214 ** search the schema a unique index on the parent key columns.
72215 **
72216 ** If successful, zero is returned. If the parent key is an INTEGER PRIMARY
72217 ** KEY column, then output variable *ppIdx is set to NULL. Otherwise, *ppIdx
72218 ** is set to point to the unique index.
72219 **
72220 ** If the parent key consists of a single column (the foreign key constraint
72221 ** is not a composite foreign key), output variable *paiCol is set to NULL.
72222 ** Otherwise, it is set to point to an allocated array of size N, where
72223 ** N is the number of columns in the parent key. The first element of the
72224 ** array is the index of the child table column that is mapped by the FK
72225 ** constraint to the parent table column stored in the left-most column
72226 ** of index *ppIdx. The second element of the array is the index of the
72227 ** child table column that corresponds to the second left-most column of
72228 ** *ppIdx, and so on.
72229 **
72230 ** If the required index cannot be found, either because:
72231 **
72232 ** 1) The named parent key columns do not exist, or
72233 **
72234 ** 2) The named parent key columns do exist, but are not subject to a
72235 ** UNIQUE or PRIMARY KEY constraint, or
72236 **
72237 ** 3) No parent key columns were provided explicitly as part of the
72238 ** foreign key definition, and the parent table does not have a
72239 ** PRIMARY KEY, or
72240 **
72241 ** 4) No parent key columns were provided explicitly as part of the
72242 ** foreign key definition, and the PRIMARY KEY of the parent table
72243 ** consists of a a different number of columns to the child key in
72244 ** the child table.
72245 **
72246 ** then non-zero is returned, and a "foreign key mismatch" error loaded
72247 ** into pParse. If an OOM error occurs, non-zero is returned and the
72248 ** pParse->db->mallocFailed flag is set.
72249 */
72250 static int locateFkeyIndex(
72251 Parse *pParse, /* Parse context to store any error in */
72252 Table *pParent, /* Parent table of FK constraint pFKey */
72253 FKey *pFKey, /* Foreign key to find index for */
72254 Index **ppIdx, /* OUT: Unique index on parent table */
72255 int **paiCol /* OUT: Map of index columns in pFKey */
72256 ){
72257 Index *pIdx = 0; /* Value to return via *ppIdx */
72258 int *aiCol = 0; /* Value to return via *paiCol */
72259 int nCol = pFKey->nCol; /* Number of columns in parent key */
72260 char *zKey = pFKey->aCol[0].zCol; /* Name of left-most parent key column */
72261
72262 /* The caller is responsible for zeroing output parameters. */
72263 assert( ppIdx && *ppIdx==0 );
72264 assert( !paiCol || *paiCol==0 );
72265 assert( pParse );
72266
72267 /* If this is a non-composite (single column) foreign key, check if it
72268 ** maps to the INTEGER PRIMARY KEY of table pParent. If so, leave *ppIdx
72269 ** and *paiCol set to zero and return early.
72270 **
72271 ** Otherwise, for a composite foreign key (more than one column), allocate
72272 ** space for the aiCol array (returned via output parameter *paiCol).
72273 ** Non-composite foreign keys do not require the aiCol array.
72274 */
72275 if( nCol==1 ){
72276 /* The FK maps to the IPK if any of the following are true:
72277 **
72278 ** 1) There is an INTEGER PRIMARY KEY column and the FK is implicitly
72279 ** mapped to the primary key of table pParent, or
72280 ** 2) The FK is explicitly mapped to a column declared as INTEGER
72281 ** PRIMARY KEY.
72282 */
72283 if( pParent->iPKey>=0 ){
72284 if( !zKey ) return 0;
72285 if( !sqlite3StrICmp(pParent->aCol[pParent->iPKey].zName, zKey) ) return 0;
72286 }
72287 }else if( paiCol ){
72288 assert( nCol>1 );
72289 aiCol = (int *)sqlite3DbMallocRaw(pParse->db, nCol*sizeof(int));
72290 if( !aiCol ) return 1;
72291 *paiCol = aiCol;
72292 }
72293
72294 for(pIdx=pParent->pIndex; pIdx; pIdx=pIdx->pNext){
72295 if( pIdx->nColumn==nCol && pIdx->onError!=OE_None ){
72296 /* pIdx is a UNIQUE index (or a PRIMARY KEY) and has the right number
72297 ** of columns. If each indexed column corresponds to a foreign key
72298 ** column of pFKey, then this index is a winner. */
72299
72300 if( zKey==0 ){
72301 /* If zKey is NULL, then this foreign key is implicitly mapped to
72302 ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be
72303 ** identified by the test (Index.autoIndex==2). */
72304 if( pIdx->autoIndex==2 ){
72305 if( aiCol ){
72306 int i;
72307 for(i=0; i<nCol; i++) aiCol[i] = pFKey->aCol[i].iFrom;
72308 }
72309 break;
72310 }
72311 }else{
72312 /* If zKey is non-NULL, then this foreign key was declared to
72313 ** map to an explicit list of columns in table pParent. Check if this
72314 ** index matches those columns. Also, check that the index uses
72315 ** the default collation sequences for each column. */
72316 int i, j;
72317 for(i=0; i<nCol; i++){
72318 int iCol = pIdx->aiColumn[i]; /* Index of column in parent tbl */
72319 char *zDfltColl; /* Def. collation for column */
72320 char *zIdxCol; /* Name of indexed column */
72321
72322 /* If the index uses a collation sequence that is different from
72323 ** the default collation sequence for the column, this index is
72324 ** unusable. Bail out early in this case. */
72325 zDfltColl = pParent->aCol[iCol].zColl;
72326 if( !zDfltColl ){
72327 zDfltColl = "BINARY";
72328 }
72329 if( sqlite3StrICmp(pIdx->azColl[i], zDfltColl) ) break;
72330
72331 zIdxCol = pParent->aCol[iCol].zName;
72332 for(j=0; j<nCol; j++){
72333 if( sqlite3StrICmp(pFKey->aCol[j].zCol, zIdxCol)==0 ){
72334 if( aiCol ) aiCol[i] = pFKey->aCol[j].iFrom;
72335 break;
72336 }
72337 }
72338 if( j==nCol ) break;
72339 }
72340 if( i==nCol ) break; /* pIdx is usable */
72341 }
72342 }
72343 }
72344
72345 if( !pIdx ){
72346 if( !pParse->disableTriggers ){
72347 sqlite3ErrorMsg(pParse, "foreign key mismatch");
72348 }
72349 sqlite3DbFree(pParse->db, aiCol);
72350 return 1;
72351 }
72352
72353 *ppIdx = pIdx;
72354 return 0;
72355 }
72356
72357 /*
72358 ** This function is called when a row is inserted into or deleted from the
72359 ** child table of foreign key constraint pFKey. If an SQL UPDATE is executed
72360 ** on the child table of pFKey, this function is invoked twice for each row
72361 ** affected - once to "delete" the old row, and then again to "insert" the
72362 ** new row.
72363 **
72364 ** Each time it is called, this function generates VDBE code to locate the
72365 ** row in the parent table that corresponds to the row being inserted into
72366 ** or deleted from the child table. If the parent row can be found, no
72367 ** special action is taken. Otherwise, if the parent row can *not* be
72368 ** found in the parent table:
72369 **
72370 ** Operation | FK type | Action taken
72371 ** --------------------------------------------------------------------------
72372 ** INSERT immediate Increment the "immediate constraint counter".
72373 **
72374 ** DELETE immediate Decrement the "immediate constraint counter".
72375 **
72376 ** INSERT deferred Increment the "deferred constraint counter".
72377 **
72378 ** DELETE deferred Decrement the "deferred constraint counter".
72379 **
72380 ** These operations are identified in the comment at the top of this file
72381 ** (fkey.c) as "I.1" and "D.1".
72382 */
72383 static void fkLookupParent(
72384 Parse *pParse, /* Parse context */
72385 int iDb, /* Index of database housing pTab */
72386 Table *pTab, /* Parent table of FK pFKey */
72387 Index *pIdx, /* Unique index on parent key columns in pTab */
72388 FKey *pFKey, /* Foreign key constraint */
72389 int *aiCol, /* Map from parent key columns to child table columns */
72390 int regData, /* Address of array containing child table row */
72391 int nIncr, /* Increment constraint counter by this */
72392 int isIgnore /* If true, pretend pTab contains all NULL values */
72393 ){
72394 int i; /* Iterator variable */
72395 Vdbe *v = sqlite3GetVdbe(pParse); /* Vdbe to add code to */
72396 int iCur = pParse->nTab - 1; /* Cursor number to use */
72397 int iOk = sqlite3VdbeMakeLabel(v); /* jump here if parent key found */
72398
72399 /* If nIncr is less than zero, then check at runtime if there are any
72400 ** outstanding constraints to resolve. If there are not, there is no need
72401 ** to check if deleting this row resolves any outstanding violations.
72402 **
72403 ** Check if any of the key columns in the child table row are NULL. If
72404 ** any are, then the constraint is considered satisfied. No need to
72405 ** search for a matching row in the parent table. */
72406 if( nIncr<0 ){
72407 sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey->isDeferred, iOk);
72408 }
72409 for(i=0; i<pFKey->nCol; i++){
72410 int iReg = aiCol[i] + regData + 1;
72411 sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iOk);
72412 }
72413
72414 if( isIgnore==0 ){
72415 if( pIdx==0 ){
72416 /* If pIdx is NULL, then the parent key is the INTEGER PRIMARY KEY
72417 ** column of the parent table (table pTab). */
72418 int iMustBeInt; /* Address of MustBeInt instruction */
72419 int regTemp = sqlite3GetTempReg(pParse);
72420
72421 /* Invoke MustBeInt to coerce the child key value to an integer (i.e.
72422 ** apply the affinity of the parent key). If this fails, then there
72423 ** is no matching parent key. Before using MustBeInt, make a copy of
72424 ** the value. Otherwise, the value inserted into the child key column
72425 ** will have INTEGER affinity applied to it, which may not be correct. */
72426 sqlite3VdbeAddOp2(v, OP_SCopy, aiCol[0]+1+regData, regTemp);
72427 iMustBeInt = sqlite3VdbeAddOp2(v, OP_MustBeInt, regTemp, 0);
72428
72429 /* If the parent table is the same as the child table, and we are about
72430 ** to increment the constraint-counter (i.e. this is an INSERT operation),
72431 ** then check if the row being inserted matches itself. If so, do not
72432 ** increment the constraint-counter. */
72433 if( pTab==pFKey->pFrom && nIncr==1 ){
72434 sqlite3VdbeAddOp3(v, OP_Eq, regData, iOk, regTemp);
72435 }
72436
72437 sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenRead);
72438 sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regTemp);
72439 sqlite3VdbeAddOp2(v, OP_Goto, 0, iOk);
72440 sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
72441 sqlite3VdbeJumpHere(v, iMustBeInt);
72442 sqlite3ReleaseTempReg(pParse, regTemp);
72443 }else{
72444 int nCol = pFKey->nCol;
72445 int regTemp = sqlite3GetTempRange(pParse, nCol);
72446 int regRec = sqlite3GetTempReg(pParse);
72447 KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx);
72448
72449 sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb);
72450 sqlite3VdbeChangeP4(v, -1, (char*)pKey, P4_KEYINFO_HANDOFF);
72451 for(i=0; i<nCol; i++){
72452 sqlite3VdbeAddOp2(v, OP_SCopy, aiCol[i]+1+regData, regTemp+i);
72453 }
72454
72455 /* If the parent table is the same as the child table, and we are about
72456 ** to increment the constraint-counter (i.e. this is an INSERT operation),
72457 ** then check if the row being inserted matches itself. If so, do not
72458 ** increment the constraint-counter. */
72459 if( pTab==pFKey->pFrom && nIncr==1 ){
72460 int iJump = sqlite3VdbeCurrentAddr(v) + nCol + 1;
72461 for(i=0; i<nCol; i++){
72462 int iChild = aiCol[i]+1+regData;
72463 int iParent = pIdx->aiColumn[i]+1+regData;
72464 sqlite3VdbeAddOp3(v, OP_Ne, iChild, iJump, iParent);
72465 }
72466 sqlite3VdbeAddOp2(v, OP_Goto, 0, iOk);
72467 }
72468
72469 sqlite3VdbeAddOp3(v, OP_MakeRecord, regTemp, nCol, regRec);
72470 sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), 0);
72471 sqlite3VdbeAddOp3(v, OP_Found, iCur, iOk, regRec);
72472
72473 sqlite3ReleaseTempReg(pParse, regRec);
72474 sqlite3ReleaseTempRange(pParse, regTemp, nCol);
72475 }
72476 }
72477
72478 if( !pFKey->isDeferred && !pParse->pToplevel && !pParse->isMultiWrite ){
72479 /* Special case: If this is an INSERT statement that will insert exactly
72480 ** one row into the table, raise a constraint immediately instead of
72481 ** incrementing a counter. This is necessary as the VM code is being
72482 ** generated for will not open a statement transaction. */
72483 assert( nIncr==1 );
72484 sqlite3HaltConstraint(
72485 pParse, OE_Abort, "foreign key constraint failed", P4_STATIC
72486 );
72487 }else{
72488 if( nIncr>0 && pFKey->isDeferred==0 ){
72489 sqlite3ParseToplevel(pParse)->mayAbort = 1;
72490 }
72491 sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);
72492 }
72493
72494 sqlite3VdbeResolveLabel(v, iOk);
72495 sqlite3VdbeAddOp1(v, OP_Close, iCur);
72496 }
72497
72498 /*
72499 ** This function is called to generate code executed when a row is deleted
72500 ** from the parent table of foreign key constraint pFKey and, if pFKey is
72501 ** deferred, when a row is inserted into the same table. When generating
72502 ** code for an SQL UPDATE operation, this function may be called twice -
72503 ** once to "delete" the old row and once to "insert" the new row.
72504 **
72505 ** The code generated by this function scans through the rows in the child
72506 ** table that correspond to the parent table row being deleted or inserted.
72507 ** For each child row found, one of the following actions is taken:
72508 **
72509 ** Operation | FK type | Action taken
72510 ** --------------------------------------------------------------------------
72511 ** DELETE immediate Increment the "immediate constraint counter".
72512 ** Or, if the ON (UPDATE|DELETE) action is RESTRICT,
72513 ** throw a "foreign key constraint failed" exception.
72514 **
72515 ** INSERT immediate Decrement the "immediate constraint counter".
72516 **
72517 ** DELETE deferred Increment the "deferred constraint counter".
72518 ** Or, if the ON (UPDATE|DELETE) action is RESTRICT,
72519 ** throw a "foreign key constraint failed" exception.
72520 **
72521 ** INSERT deferred Decrement the "deferred constraint counter".
72522 **
72523 ** These operations are identified in the comment at the top of this file
72524 ** (fkey.c) as "I.2" and "D.2".
72525 */
72526 static void fkScanChildren(
72527 Parse *pParse, /* Parse context */
72528 SrcList *pSrc, /* SrcList containing the table to scan */
72529 Table *pTab,
72530 Index *pIdx, /* Foreign key index */
72531 FKey *pFKey, /* Foreign key relationship */
72532 int *aiCol, /* Map from pIdx cols to child table cols */
72533 int regData, /* Referenced table data starts here */
72534 int nIncr /* Amount to increment deferred counter by */
72535 ){
72536 sqlite3 *db = pParse->db; /* Database handle */
72537 int i; /* Iterator variable */
72538 Expr *pWhere = 0; /* WHERE clause to scan with */
72539 NameContext sNameContext; /* Context used to resolve WHERE clause */
72540 WhereInfo *pWInfo; /* Context used by sqlite3WhereXXX() */
72541 int iFkIfZero = 0; /* Address of OP_FkIfZero */
72542 Vdbe *v = sqlite3GetVdbe(pParse);
72543
72544 assert( !pIdx || pIdx->pTable==pTab );
72545
72546 if( nIncr<0 ){
72547 iFkIfZero = sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey->isDeferred, 0);
72548 }
72549
72550 /* Create an Expr object representing an SQL expression like:
72551 **
72552 ** <parent-key1> = <child-key1> AND <parent-key2> = <child-key2> ...
72553 **
72554 ** The collation sequence used for the comparison should be that of
72555 ** the parent key columns. The affinity of the parent key column should
72556 ** be applied to each child key value before the comparison takes place.
72557 */
72558 for(i=0; i<pFKey->nCol; i++){
72559 Expr *pLeft; /* Value from parent table row */
72560 Expr *pRight; /* Column ref to child table */
72561 Expr *pEq; /* Expression (pLeft = pRight) */
72562 int iCol; /* Index of column in child table */
72563 const char *zCol; /* Name of column in child table */
72564
72565 pLeft = sqlite3Expr(db, TK_REGISTER, 0);
72566 if( pLeft ){
72567 /* Set the collation sequence and affinity of the LHS of each TK_EQ
72568 ** expression to the parent key column defaults. */
72569 if( pIdx ){
72570 Column *pCol;
72571 iCol = pIdx->aiColumn[i];
72572 pCol = &pIdx->pTable->aCol[iCol];
72573 pLeft->iTable = regData+iCol+1;
72574 pLeft->affinity = pCol->affinity;
72575 pLeft->pColl = sqlite3LocateCollSeq(pParse, pCol->zColl);
72576 }else{
72577 pLeft->iTable = regData;
72578 pLeft->affinity = SQLITE_AFF_INTEGER;
72579 }
72580 }
72581 iCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom;
72582 assert( iCol>=0 );
72583 zCol = pFKey->pFrom->aCol[iCol].zName;
72584 pRight = sqlite3Expr(db, TK_ID, zCol);
72585 pEq = sqlite3PExpr(pParse, TK_EQ, pLeft, pRight, 0);
72586 pWhere = sqlite3ExprAnd(db, pWhere, pEq);
72587 }
72588
72589 /* If the child table is the same as the parent table, and this scan
72590 ** is taking place as part of a DELETE operation (operation D.2), omit the
72591 ** row being deleted from the scan by adding ($rowid != rowid) to the WHERE
72592 ** clause, where $rowid is the rowid of the row being deleted. */
72593 if( pTab==pFKey->pFrom && nIncr>0 ){
72594 Expr *pEq; /* Expression (pLeft = pRight) */
72595 Expr *pLeft; /* Value from parent table row */
72596 Expr *pRight; /* Column ref to child table */
72597 pLeft = sqlite3Expr(db, TK_REGISTER, 0);
72598 pRight = sqlite3Expr(db, TK_COLUMN, 0);
72599 if( pLeft && pRight ){
72600 pLeft->iTable = regData;
72601 pLeft->affinity = SQLITE_AFF_INTEGER;
72602 pRight->iTable = pSrc->a[0].iCursor;
72603 pRight->iColumn = -1;
72604 }
72605 pEq = sqlite3PExpr(pParse, TK_NE, pLeft, pRight, 0);
72606 pWhere = sqlite3ExprAnd(db, pWhere, pEq);
72607 }
72608
72609 /* Resolve the references in the WHERE clause. */
72610 memset(&sNameContext, 0, sizeof(NameContext));
72611 sNameContext.pSrcList = pSrc;
72612 sNameContext.pParse = pParse;
72613 sqlite3ResolveExprNames(&sNameContext, pWhere);
72614
72615 /* Create VDBE to loop through the entries in pSrc that match the WHERE
72616 ** clause. If the constraint is not deferred, throw an exception for
72617 ** each row found. Otherwise, for deferred constraints, increment the
72618 ** deferred constraint counter by nIncr for each row selected. */
72619 pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0);
72620 if( nIncr>0 && pFKey->isDeferred==0 ){
72621 sqlite3ParseToplevel(pParse)->mayAbort = 1;
72622 }
72623 sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);
72624 if( pWInfo ){
72625 sqlite3WhereEnd(pWInfo);
72626 }
72627
72628 /* Clean up the WHERE clause constructed above. */
72629 sqlite3ExprDelete(db, pWhere);
72630 if( iFkIfZero ){
72631 sqlite3VdbeJumpHere(v, iFkIfZero);
72632 }
72633 }
72634
72635 /*
72636 ** This function returns a pointer to the head of a linked list of FK
72637 ** constraints for which table pTab is the parent table. For example,
72638 ** given the following schema:
72639 **
72640 ** CREATE TABLE t1(a PRIMARY KEY);
72641 ** CREATE TABLE t2(b REFERENCES t1(a);
72642 **
72643 ** Calling this function with table "t1" as an argument returns a pointer
72644 ** to the FKey structure representing the foreign key constraint on table
72645 ** "t2". Calling this function with "t2" as the argument would return a
72646 ** NULL pointer (as there are no FK constraints for which t2 is the parent
72647 ** table).
72648 */
72649 SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *pTab){
72650 int nName = sqlite3Strlen30(pTab->zName);
72651 return (FKey *)sqlite3HashFind(&pTab->pSchema->fkeyHash, pTab->zName, nName);
72652 }
72653
72654 /*
72655 ** The second argument is a Trigger structure allocated by the
72656 ** fkActionTrigger() routine. This function deletes the Trigger structure
72657 ** and all of its sub-components.
72658 **
72659 ** The Trigger structure or any of its sub-components may be allocated from
72660 ** the lookaside buffer belonging to database handle dbMem.
72661 */
72662 static void fkTriggerDelete(sqlite3 *dbMem, Trigger *p){
72663 if( p ){
72664 TriggerStep *pStep = p->step_list;
72665 sqlite3ExprDelete(dbMem, pStep->pWhere);
72666 sqlite3ExprListDelete(dbMem, pStep->pExprList);
72667 sqlite3SelectDelete(dbMem, pStep->pSelect);
72668 sqlite3ExprDelete(dbMem, p->pWhen);
72669 sqlite3DbFree(dbMem, p);
72670 }
72671 }
72672
72673 /*
72674 ** This function is called to generate code that runs when table pTab is
72675 ** being dropped from the database. The SrcList passed as the second argument
72676 ** to this function contains a single entry guaranteed to resolve to
72677 ** table pTab.
72678 **
72679 ** Normally, no code is required. However, if either
72680 **
72681 ** (a) The table is the parent table of a FK constraint, or
72682 ** (b) The table is the child table of a deferred FK constraint and it is
72683 ** determined at runtime that there are outstanding deferred FK
72684 ** constraint violations in the database,
72685 **
72686 ** then the equivalent of "DELETE FROM <tbl>" is executed before dropping
72687 ** the table from the database. Triggers are disabled while running this
72688 ** DELETE, but foreign key actions are not.
72689 */
72690 SQLITE_PRIVATE void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){
72691 sqlite3 *db = pParse->db;
72692 if( (db->flags&SQLITE_ForeignKeys) && !IsVirtual(pTab) && !pTab->pSelect ){
72693 int iSkip = 0;
72694 Vdbe *v = sqlite3GetVdbe(pParse);
72695
72696 assert( v ); /* VDBE has already been allocated */
72697 if( sqlite3FkReferences(pTab)==0 ){
72698 /* Search for a deferred foreign key constraint for which this table
72699 ** is the child table. If one cannot be found, return without
72700 ** generating any VDBE code. If one can be found, then jump over
72701 ** the entire DELETE if there are no outstanding deferred constraints
72702 ** when this statement is run. */
72703 FKey *p;
72704 for(p=pTab->pFKey; p; p=p->pNextFrom){
72705 if( p->isDeferred ) break;
72706 }
72707 if( !p ) return;
72708 iSkip = sqlite3VdbeMakeLabel(v);
72709 sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip);
72710 }
72711
72712 pParse->disableTriggers = 1;
72713 sqlite3DeleteFrom(pParse, sqlite3SrcListDup(db, pName, 0), 0);
72714 pParse->disableTriggers = 0;
72715
72716 /* If the DELETE has generated immediate foreign key constraint
72717 ** violations, halt the VDBE and return an error at this point, before
72718 ** any modifications to the schema are made. This is because statement
72719 ** transactions are not able to rollback schema changes. */
72720 sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);
72721 sqlite3HaltConstraint(
72722 pParse, OE_Abort, "foreign key constraint failed", P4_STATIC
72723 );
72724
72725 if( iSkip ){
72726 sqlite3VdbeResolveLabel(v, iSkip);
72727 }
72728 }
72729 }
72730
72731 /*
72732 ** This function is called when inserting, deleting or updating a row of
72733 ** table pTab to generate VDBE code to perform foreign key constraint
72734 ** processing for the operation.
72735 **
72736 ** For a DELETE operation, parameter regOld is passed the index of the
72737 ** first register in an array of (pTab->nCol+1) registers containing the
72738 ** rowid of the row being deleted, followed by each of the column values
72739 ** of the row being deleted, from left to right. Parameter regNew is passed
72740 ** zero in this case.
72741 **
72742 ** For an INSERT operation, regOld is passed zero and regNew is passed the
72743 ** first register of an array of (pTab->nCol+1) registers containing the new
72744 ** row data.
72745 **
72746 ** For an UPDATE operation, this function is called twice. Once before
72747 ** the original record is deleted from the table using the calling convention
72748 ** described for DELETE. Then again after the original record is deleted
72749 ** but before the new record is inserted using the INSERT convention.
72750 */
72751 SQLITE_PRIVATE void sqlite3FkCheck(
72752 Parse *pParse, /* Parse context */
72753 Table *pTab, /* Row is being deleted from this table */
72754 int regOld, /* Previous row data is stored here */
72755 int regNew /* New row data is stored here */
72756 ){
72757 sqlite3 *db = pParse->db; /* Database handle */
72758 Vdbe *v; /* VM to write code to */
72759 FKey *pFKey; /* Used to iterate through FKs */
72760 int iDb; /* Index of database containing pTab */
72761 const char *zDb; /* Name of database containing pTab */
72762 int isIgnoreErrors = pParse->disableTriggers;
72763
72764 /* Exactly one of regOld and regNew should be non-zero. */
72765 assert( (regOld==0)!=(regNew==0) );
72766
72767 /* If foreign-keys are disabled, this function is a no-op. */
72768 if( (db->flags&SQLITE_ForeignKeys)==0 ) return;
72769
72770 v = sqlite3GetVdbe(pParse);
72771 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
72772 zDb = db->aDb[iDb].zName;
72773
72774 /* Loop through all the foreign key constraints for which pTab is the
72775 ** child table (the table that the foreign key definition is part of). */
72776 for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
72777 Table *pTo; /* Parent table of foreign key pFKey */
72778 Index *pIdx = 0; /* Index on key columns in pTo */
72779 int *aiFree = 0;
72780 int *aiCol;
72781 int iCol;
72782 int i;
72783 int isIgnore = 0;
72784
72785 /* Find the parent table of this foreign key. Also find a unique index
72786 ** on the parent key columns in the parent table. If either of these
72787 ** schema items cannot be located, set an error in pParse and return
72788 ** early. */
72789 if( pParse->disableTriggers ){
72790 pTo = sqlite3FindTable(db, pFKey->zTo, zDb);
72791 }else{
72792 pTo = sqlite3LocateTable(pParse, 0, pFKey->zTo, zDb);
72793 }
72794 if( !pTo || locateFkeyIndex(pParse, pTo, pFKey, &pIdx, &aiFree) ){
72795 if( !isIgnoreErrors || db->mallocFailed ) return;
72796 continue;
72797 }
72798 assert( pFKey->nCol==1 || (aiFree && pIdx) );
72799
72800 if( aiFree ){
72801 aiCol = aiFree;
72802 }else{
72803 iCol = pFKey->aCol[0].iFrom;
72804 aiCol = &iCol;
72805 }
72806 for(i=0; i<pFKey->nCol; i++){
72807 if( aiCol[i]==pTab->iPKey ){
72808 aiCol[i] = -1;
72809 }
72810 #ifndef SQLITE_OMIT_AUTHORIZATION
72811 /* Request permission to read the parent key columns. If the
72812 ** authorization callback returns SQLITE_IGNORE, behave as if any
72813 ** values read from the parent table are NULL. */
72814 if( db->xAuth ){
72815 int rcauth;
72816 char *zCol = pTo->aCol[pIdx ? pIdx->aiColumn[i] : pTo->iPKey].zName;
72817 rcauth = sqlite3AuthReadCol(pParse, pTo->zName, zCol, iDb);
72818 isIgnore = (rcauth==SQLITE_IGNORE);
72819 }
72820 #endif
72821 }
72822
72823 /* Take a shared-cache advisory read-lock on the parent table. Allocate
72824 ** a cursor to use to search the unique index on the parent key columns
72825 ** in the parent table. */
72826 sqlite3TableLock(pParse, iDb, pTo->tnum, 0, pTo->zName);
72827 pParse->nTab++;
72828
72829 if( regOld!=0 ){
72830 /* A row is being removed from the child table. Search for the parent.
72831 ** If the parent does not exist, removing the child row resolves an
72832 ** outstanding foreign key constraint violation. */
72833 fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regOld, -1,isIgnore);
72834 }
72835 if( regNew!=0 ){
72836 /* A row is being added to the child table. If a parent row cannot
72837 ** be found, adding the child row has violated the FK constraint. */
72838 fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regNew, +1,isIgnore);
72839 }
72840
72841 sqlite3DbFree(db, aiFree);
72842 }
72843
72844 /* Loop through all the foreign key constraints that refer to this table */
72845 for(pFKey = sqlite3FkReferences(pTab); pFKey; pFKey=pFKey->pNextTo){
72846 Index *pIdx = 0; /* Foreign key index for pFKey */
72847 SrcList *pSrc;
72848 int *aiCol = 0;
72849
72850 if( !pFKey->isDeferred && !pParse->pToplevel && !pParse->isMultiWrite ){
72851 assert( regOld==0 && regNew!=0 );
72852 /* Inserting a single row into a parent table cannot cause an immediate
72853 ** foreign key violation. So do nothing in this case. */
72854 continue;
72855 }
72856
72857 if( locateFkeyIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ){
72858 if( !isIgnoreErrors || db->mallocFailed ) return;
72859 continue;
72860 }
72861 assert( aiCol || pFKey->nCol==1 );
72862
72863 /* Create a SrcList structure containing a single table (the table
72864 ** the foreign key that refers to this table is attached to). This
72865 ** is required for the sqlite3WhereXXX() interface. */
72866 pSrc = sqlite3SrcListAppend(db, 0, 0, 0);
72867 if( pSrc ){
72868 struct SrcList_item *pItem = pSrc->a;
72869 pItem->pTab = pFKey->pFrom;
72870 pItem->zName = pFKey->pFrom->zName;
72871 pItem->pTab->nRef++;
72872 pItem->iCursor = pParse->nTab++;
72873
72874 if( regNew!=0 ){
72875 fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1);
72876 }
72877 if( regOld!=0 ){
72878 /* If there is a RESTRICT action configured for the current operation
72879 ** on the parent table of this FK, then throw an exception
72880 ** immediately if the FK constraint is violated, even if this is a
72881 ** deferred trigger. That's what RESTRICT means. To defer checking
72882 ** the constraint, the FK should specify NO ACTION (represented
72883 ** using OE_None). NO ACTION is the default. */
72884 fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1);
72885 }
72886 pItem->zName = 0;
72887 sqlite3SrcListDelete(db, pSrc);
72888 }
72889 sqlite3DbFree(db, aiCol);
72890 }
72891 }
72892
72893 #define COLUMN_MASK(x) (((x)>31) ? 0xffffffff : ((u32)1<<(x)))
72894
72895 /*
72896 ** This function is called before generating code to update or delete a
72897 ** row contained in table pTab.
72898 */
72899 SQLITE_PRIVATE u32 sqlite3FkOldmask(
72900 Parse *pParse, /* Parse context */
72901 Table *pTab /* Table being modified */
72902 ){
72903 u32 mask = 0;
72904 if( pParse->db->flags&SQLITE_ForeignKeys ){
72905 FKey *p;
72906 int i;
72907 for(p=pTab->pFKey; p; p=p->pNextFrom){
72908 for(i=0; i<p->nCol; i++) mask |= COLUMN_MASK(p->aCol[i].iFrom);
72909 }
72910 for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){
72911 Index *pIdx = 0;
72912 locateFkeyIndex(pParse, pTab, p, &pIdx, 0);
72913 if( pIdx ){
72914 for(i=0; i<pIdx->nColumn; i++) mask |= COLUMN_MASK(pIdx->aiColumn[i]);
72915 }
72916 }
72917 }
72918 return mask;
72919 }
72920
72921 /*
72922 ** This function is called before generating code to update or delete a
72923 ** row contained in table pTab. If the operation is a DELETE, then
72924 ** parameter aChange is passed a NULL value. For an UPDATE, aChange points
72925 ** to an array of size N, where N is the number of columns in table pTab.
72926 ** If the i'th column is not modified by the UPDATE, then the corresponding
72927 ** entry in the aChange[] array is set to -1. If the column is modified,
72928 ** the value is 0 or greater. Parameter chngRowid is set to true if the
72929 ** UPDATE statement modifies the rowid fields of the table.
72930 **
72931 ** If any foreign key processing will be required, this function returns
72932 ** true. If there is no foreign key related processing, this function
72933 ** returns false.
72934 */
72935 SQLITE_PRIVATE int sqlite3FkRequired(
72936 Parse *pParse, /* Parse context */
72937 Table *pTab, /* Table being modified */
72938 int *aChange, /* Non-NULL for UPDATE operations */
72939 int chngRowid /* True for UPDATE that affects rowid */
72940 ){
72941 if( pParse->db->flags&SQLITE_ForeignKeys ){
72942 if( !aChange ){
72943 /* A DELETE operation. Foreign key processing is required if the
72944 ** table in question is either the child or parent table for any
72945 ** foreign key constraint. */
72946 return (sqlite3FkReferences(pTab) || pTab->pFKey);
72947 }else{
72948 /* This is an UPDATE. Foreign key processing is only required if the
72949 ** operation modifies one or more child or parent key columns. */
72950 int i;
72951 FKey *p;
72952
72953 /* Check if any child key columns are being modified. */
72954 for(p=pTab->pFKey; p; p=p->pNextFrom){
72955 for(i=0; i<p->nCol; i++){
72956 int iChildKey = p->aCol[i].iFrom;
72957 if( aChange[iChildKey]>=0 ) return 1;
72958 if( iChildKey==pTab->iPKey && chngRowid ) return 1;
72959 }
72960 }
72961
72962 /* Check if any parent key columns are being modified. */
72963 for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){
72964 for(i=0; i<p->nCol; i++){
72965 char *zKey = p->aCol[i].zCol;
72966 int iKey;
72967 for(iKey=0; iKey<pTab->nCol; iKey++){
72968 Column *pCol = &pTab->aCol[iKey];
72969 if( (zKey ? !sqlite3StrICmp(pCol->zName, zKey) : pCol->isPrimKey) ){
72970 if( aChange[iKey]>=0 ) return 1;
72971 if( iKey==pTab->iPKey && chngRowid ) return 1;
72972 }
72973 }
72974 }
72975 }
72976 }
72977 }
72978 return 0;
72979 }
72980
72981 /*
72982 ** This function is called when an UPDATE or DELETE operation is being
72983 ** compiled on table pTab, which is the parent table of foreign-key pFKey.
72984 ** If the current operation is an UPDATE, then the pChanges parameter is
72985 ** passed a pointer to the list of columns being modified. If it is a
72986 ** DELETE, pChanges is passed a NULL pointer.
72987 **
72988 ** It returns a pointer to a Trigger structure containing a trigger
72989 ** equivalent to the ON UPDATE or ON DELETE action specified by pFKey.
72990 ** If the action is "NO ACTION" or "RESTRICT", then a NULL pointer is
72991 ** returned (these actions require no special handling by the triggers
72992 ** sub-system, code for them is created by fkScanChildren()).
72993 **
72994 ** For example, if pFKey is the foreign key and pTab is table "p" in
72995 ** the following schema:
72996 **
72997 ** CREATE TABLE p(pk PRIMARY KEY);
72998 ** CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE);
72999 **
73000 ** then the returned trigger structure is equivalent to:
73001 **
73002 ** CREATE TRIGGER ... DELETE ON p BEGIN
73003 ** DELETE FROM c WHERE ck = old.pk;
73004 ** END;
73005 **
73006 ** The returned pointer is cached as part of the foreign key object. It
73007 ** is eventually freed along with the rest of the foreign key object by
73008 ** sqlite3FkDelete().
73009 */
73010 static Trigger *fkActionTrigger(
73011 Parse *pParse, /* Parse context */
73012 Table *pTab, /* Table being updated or deleted from */
73013 FKey *pFKey, /* Foreign key to get action for */
73014 ExprList *pChanges /* Change-list for UPDATE, NULL for DELETE */
73015 ){
73016 sqlite3 *db = pParse->db; /* Database handle */
73017 int action; /* One of OE_None, OE_Cascade etc. */
73018 Trigger *pTrigger; /* Trigger definition to return */
73019 int iAction = (pChanges!=0); /* 1 for UPDATE, 0 for DELETE */
73020
73021 action = pFKey->aAction[iAction];
73022 pTrigger = pFKey->apTrigger[iAction];
73023
73024 if( action!=OE_None && !pTrigger ){
73025 u8 enableLookaside; /* Copy of db->lookaside.bEnabled */
73026 char const *zFrom; /* Name of child table */
73027 int nFrom; /* Length in bytes of zFrom */
73028 Index *pIdx = 0; /* Parent key index for this FK */
73029 int *aiCol = 0; /* child table cols -> parent key cols */
73030 TriggerStep *pStep = 0; /* First (only) step of trigger program */
73031 Expr *pWhere = 0; /* WHERE clause of trigger step */
73032 ExprList *pList = 0; /* Changes list if ON UPDATE CASCADE */
73033 Select *pSelect = 0; /* If RESTRICT, "SELECT RAISE(...)" */
73034 int i; /* Iterator variable */
73035 Expr *pWhen = 0; /* WHEN clause for the trigger */
73036
73037 if( locateFkeyIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ) return 0;
73038 assert( aiCol || pFKey->nCol==1 );
73039
73040 for(i=0; i<pFKey->nCol; i++){
73041 Token tOld = { "old", 3 }; /* Literal "old" token */
73042 Token tNew = { "new", 3 }; /* Literal "new" token */
73043 Token tFromCol; /* Name of column in child table */
73044 Token tToCol; /* Name of column in parent table */
73045 int iFromCol; /* Idx of column in child table */
73046 Expr *pEq; /* tFromCol = OLD.tToCol */
73047
73048 iFromCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom;
73049 assert( iFromCol>=0 );
73050 tToCol.z = pIdx ? pTab->aCol[pIdx->aiColumn[i]].zName : "oid";
73051 tFromCol.z = pFKey->pFrom->aCol[iFromCol].zName;
73052
73053 tToCol.n = sqlite3Strlen30(tToCol.z);
73054 tFromCol.n = sqlite3Strlen30(tFromCol.z);
73055
73056 /* Create the expression "OLD.zToCol = zFromCol". It is important
73057 ** that the "OLD.zToCol" term is on the LHS of the = operator, so
73058 ** that the affinity and collation sequence associated with the
73059 ** parent table are used for the comparison. */
73060 pEq = sqlite3PExpr(pParse, TK_EQ,
73061 sqlite3PExpr(pParse, TK_DOT,
73062 sqlite3PExpr(pParse, TK_ID, 0, 0, &tOld),
73063 sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol)
73064 , 0),
73065 sqlite3PExpr(pParse, TK_ID, 0, 0, &tFromCol)
73066 , 0);
73067 pWhere = sqlite3ExprAnd(db, pWhere, pEq);
73068
73069 /* For ON UPDATE, construct the next term of the WHEN clause.
73070 ** The final WHEN clause will be like this:
73071 **
73072 ** WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN)
73073 */
73074 if( pChanges ){
73075 pEq = sqlite3PExpr(pParse, TK_IS,
73076 sqlite3PExpr(pParse, TK_DOT,
73077 sqlite3PExpr(pParse, TK_ID, 0, 0, &tOld),
73078 sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol),
73079 0),
73080 sqlite3PExpr(pParse, TK_DOT,
73081 sqlite3PExpr(pParse, TK_ID, 0, 0, &tNew),
73082 sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol),
73083 0),
73084 0);
73085 pWhen = sqlite3ExprAnd(db, pWhen, pEq);
73086 }
73087
73088 if( action!=OE_Restrict && (action!=OE_Cascade || pChanges) ){
73089 Expr *pNew;
73090 if( action==OE_Cascade ){
73091 pNew = sqlite3PExpr(pParse, TK_DOT,
73092 sqlite3PExpr(pParse, TK_ID, 0, 0, &tNew),
73093 sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol)
73094 , 0);
73095 }else if( action==OE_SetDflt ){
73096 Expr *pDflt = pFKey->pFrom->aCol[iFromCol].pDflt;
73097 if( pDflt ){
73098 pNew = sqlite3ExprDup(db, pDflt, 0);
73099 }else{
73100 pNew = sqlite3PExpr(pParse, TK_NULL, 0, 0, 0);
73101 }
73102 }else{
73103 pNew = sqlite3PExpr(pParse, TK_NULL, 0, 0, 0);
73104 }
73105 pList = sqlite3ExprListAppend(pParse, pList, pNew);
73106 sqlite3ExprListSetName(pParse, pList, &tFromCol, 0);
73107 }
73108 }
73109 sqlite3DbFree(db, aiCol);
73110
73111 zFrom = pFKey->pFrom->zName;
73112 nFrom = sqlite3Strlen30(zFrom);
73113
73114 if( action==OE_Restrict ){
73115 Token tFrom;
73116 Expr *pRaise;
73117
73118 tFrom.z = zFrom;
73119 tFrom.n = nFrom;
73120 pRaise = sqlite3Expr(db, TK_RAISE, "foreign key constraint failed");
73121 if( pRaise ){
73122 pRaise->affinity = OE_Abort;
73123 }
73124 pSelect = sqlite3SelectNew(pParse,
73125 sqlite3ExprListAppend(pParse, 0, pRaise),
73126 sqlite3SrcListAppend(db, 0, &tFrom, 0),
73127 pWhere,
73128 0, 0, 0, 0, 0, 0
73129 );
73130 pWhere = 0;
73131 }
73132
73133 /* In the current implementation, pTab->dbMem==0 for all tables except
73134 ** for temporary tables used to describe subqueries. And temporary
73135 ** tables do not have foreign key constraints. Hence, pTab->dbMem
73136 ** should always be 0 there.
73137 */
73138 enableLookaside = db->lookaside.bEnabled;
73139 db->lookaside.bEnabled = 0;
73140
73141 pTrigger = (Trigger *)sqlite3DbMallocZero(db,
73142 sizeof(Trigger) + /* struct Trigger */
73143 sizeof(TriggerStep) + /* Single step in trigger program */
73144 nFrom + 1 /* Space for pStep->target.z */
73145 );
73146 if( pTrigger ){
73147 pStep = pTrigger->step_list = (TriggerStep *)&pTrigger[1];
73148 pStep->target.z = (char *)&pStep[1];
73149 pStep->target.n = nFrom;
73150 memcpy((char *)pStep->target.z, zFrom, nFrom);
73151
73152 pStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
73153 pStep->pExprList = sqlite3ExprListDup(db, pList, EXPRDUP_REDUCE);
73154 pStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
73155 if( pWhen ){
73156 pWhen = sqlite3PExpr(pParse, TK_NOT, pWhen, 0, 0);
73157 pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);
73158 }
73159 }
73160
73161 /* Re-enable the lookaside buffer, if it was disabled earlier. */
73162 db->lookaside.bEnabled = enableLookaside;
73163
73164 sqlite3ExprDelete(db, pWhere);
73165 sqlite3ExprDelete(db, pWhen);
73166 sqlite3ExprListDelete(db, pList);
73167 sqlite3SelectDelete(db, pSelect);
73168 if( db->mallocFailed==1 ){
73169 fkTriggerDelete(db, pTrigger);
73170 return 0;
73171 }
73172
73173 switch( action ){
73174 case OE_Restrict:
73175 pStep->op = TK_SELECT;
73176 break;
73177 case OE_Cascade:
73178 if( !pChanges ){
73179 pStep->op = TK_DELETE;
73180 break;
73181 }
73182 default:
73183 pStep->op = TK_UPDATE;
73184 }
73185 pStep->pTrig = pTrigger;
73186 pTrigger->pSchema = pTab->pSchema;
73187 pTrigger->pTabSchema = pTab->pSchema;
73188 pFKey->apTrigger[iAction] = pTrigger;
73189 pTrigger->op = (pChanges ? TK_UPDATE : TK_DELETE);
73190 }
73191
73192 return pTrigger;
73193 }
73194
73195 /*
73196 ** This function is called when deleting or updating a row to implement
73197 ** any required CASCADE, SET NULL or SET DEFAULT actions.
73198 */
73199 SQLITE_PRIVATE void sqlite3FkActions(
73200 Parse *pParse, /* Parse context */
73201 Table *pTab, /* Table being updated or deleted from */
73202 ExprList *pChanges, /* Change-list for UPDATE, NULL for DELETE */
73203 int regOld /* Address of array containing old row */
73204 ){
73205 /* If foreign-key support is enabled, iterate through all FKs that
73206 ** refer to table pTab. If there is an action associated with the FK
73207 ** for this operation (either update or delete), invoke the associated
73208 ** trigger sub-program. */
73209 if( pParse->db->flags&SQLITE_ForeignKeys ){
73210 FKey *pFKey; /* Iterator variable */
73211 for(pFKey = sqlite3FkReferences(pTab); pFKey; pFKey=pFKey->pNextTo){
73212 Trigger *pAction = fkActionTrigger(pParse, pTab, pFKey, pChanges);
73213 if( pAction ){
73214 sqlite3CodeRowTriggerDirect(pParse, pAction, pTab, regOld, OE_Abort, 0);
73215 }
73216 }
73217 }
73218 }
73219
73220 #endif /* ifndef SQLITE_OMIT_TRIGGER */
73221
73222 /*
73223 ** Free all memory associated with foreign key definitions attached to
73224 ** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash
73225 ** hash table.
73226 */
73227 SQLITE_PRIVATE void sqlite3FkDelete(Table *pTab){
73228 FKey *pFKey; /* Iterator variable */
73229 FKey *pNext; /* Copy of pFKey->pNextFrom */
73230
73231 for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){
73232
73233 /* Remove the FK from the fkeyHash hash table. */
73234 if( pFKey->pPrevTo ){
73235 pFKey->pPrevTo->pNextTo = pFKey->pNextTo;
73236 }else{
73237 void *data = (void *)pFKey->pNextTo;
73238 const char *z = (data ? pFKey->pNextTo->zTo : pFKey->zTo);
73239 sqlite3HashInsert(&pTab->pSchema->fkeyHash, z, sqlite3Strlen30(z), data);
73240 }
73241 if( pFKey->pNextTo ){
73242 pFKey->pNextTo->pPrevTo = pFKey->pPrevTo;
73243 }
73244
73245 /* Delete any triggers created to implement actions for this FK. */
73246 #ifndef SQLITE_OMIT_TRIGGER
73247 fkTriggerDelete(pTab->dbMem, pFKey->apTrigger[0]);
73248 fkTriggerDelete(pTab->dbMem, pFKey->apTrigger[1]);
73249 #endif
73250
73251 /* EV: R-30323-21917 Each foreign key constraint in SQLite is
73252 ** classified as either immediate or deferred.
73253 */
73254 assert( pFKey->isDeferred==0 || pFKey->isDeferred==1 );
73255
73256 pNext = pFKey->pNextFrom;
73257 sqlite3DbFree(pTab->dbMem, pFKey);
73258 }
73259 }
73260 #endif /* ifndef SQLITE_OMIT_FOREIGN_KEY */
73261
73262 /************** End of fkey.c ************************************************/
73263 /************** Begin file insert.c ******************************************/
73264 /*
73265 ** 2001 September 15
73266 **
73267 ** The author disclaims copyright to this source code. In place of
@@ -72448,11 +74130,11 @@
74130 sqlite3TableAffinityStr(v, pTab);
74131 }
74132
74133 /* Fire BEFORE or INSTEAD OF triggers */
74134 sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_BEFORE,
74135 pTab, regCols-pTab->nCol-1, onError, endOfLoop);
74136
74137 sqlite3ReleaseTempRange(pParse, regCols, pTab->nCol+1);
74138 }
74139
74140 /* Push the record number for the new entry onto the stack. The
@@ -72557,10 +74239,11 @@
74239 {
74240 int isReplace; /* Set to true if constraints may cause a replace */
74241 sqlite3GenerateConstraintChecks(pParse, pTab, baseCur, regIns, aRegIdx,
74242 keyColumn>=0, 0, onError, endOfLoop, &isReplace
74243 );
74244 sqlite3FkCheck(pParse, pTab, 0, regIns);
74245 sqlite3CompleteInsertion(
74246 pParse, pTab, baseCur, regIns, aRegIdx, 0, appendFlag, isReplace==0
74247 );
74248 }
74249 }
@@ -72572,11 +74255,11 @@
74255 }
74256
74257 if( pTrigger ){
74258 /* Code AFTER triggers */
74259 sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_AFTER,
74260 pTab, regData-2-pTab->nCol, onError, endOfLoop);
74261 }
74262
74263 /* The bottom of the main insertion loop, if the data source
74264 ** is a SELECT statement.
74265 */
@@ -72623,10 +74306,24 @@
74306 sqlite3ExprListDelete(db, pList);
74307 sqlite3SelectDelete(db, pSelect);
74308 sqlite3IdListDelete(db, pColumn);
74309 sqlite3DbFree(db, aRegIdx);
74310 }
74311
74312 /* Make sure "isView" and other macros defined above are undefined. Otherwise
74313 ** thely may interfere with compilation of other functions in this file
74314 ** (or in another file, if this file becomes part of the amalgamation). */
74315 #ifdef isView
74316 #undef isView
74317 #endif
74318 #ifdef pTrigger
74319 #undef pTrigger
74320 #endif
74321 #ifdef tmask
74322 #undef tmask
74323 #endif
74324
74325
74326 /*
74327 ** Generate code to do constraint checks prior to an INSERT or an UPDATE.
74328 **
74329 ** The input is a range of consecutive registers as follows:
@@ -72803,61 +74500,60 @@
74500 onError = overrideError;
74501 }else if( onError==OE_Default ){
74502 onError = OE_Abort;
74503 }
74504
74505 if( isUpdate ){
74506 j2 = sqlite3VdbeAddOp3(v, OP_Eq, regRowid, 0, rowidChng);
74507 }
74508 j3 = sqlite3VdbeAddOp3(v, OP_NotExists, baseCur, 0, regRowid);
74509 switch( onError ){
74510 default: {
74511 onError = OE_Abort;
74512 /* Fall thru into the next case */
74513 }
74514 case OE_Rollback:
74515 case OE_Abort:
74516 case OE_Fail: {
74517 sqlite3HaltConstraint(
74518 pParse, onError, "PRIMARY KEY must be unique", P4_STATIC);
74519 break;
74520 }
74521 case OE_Replace: {
74522 /* If there are DELETE triggers on this table and the
74523 ** recursive-triggers flag is set, call GenerateRowDelete() to
74524 ** remove the conflicting row from the the table. This will fire
74525 ** the triggers and remove both the table and index b-tree entries.
74526 **
74527 ** Otherwise, if there are no triggers or the recursive-triggers
74528 ** flag is not set, call GenerateRowIndexDelete(). This removes
74529 ** the index b-tree entries only. The table b-tree entry will be
74530 ** replaced by the new entry when it is inserted. */
74531 Trigger *pTrigger = 0;
74532 if( pParse->db->flags&SQLITE_RecTriggers ){
74533 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
74534 }
74535 sqlite3MultiWrite(pParse);
74536 if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
74537 sqlite3GenerateRowDelete(
74538 pParse, pTab, baseCur, regRowid, 0, pTrigger, OE_Replace
74539 );
74540 }else{
74541 sqlite3GenerateRowIndexDelete(pParse, pTab, baseCur, 0);
74542 }
74543 seenReplace = 1;
74544 break;
74545 }
74546 case OE_Ignore: {
74547 assert( seenReplace==0 );
74548 sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
74549 break;
74550 }
74551 }
74552 sqlite3VdbeJumpHere(v, j3);
74553 if( isUpdate ){
74554 sqlite3VdbeJumpHere(v, j2);
 
74555 }
74556 }
74557
74558 /* Test all UNIQUE constraints by creating entries for each UNIQUE
74559 ** index and making sure that duplicate entries do not already exist.
@@ -72942,10 +74638,11 @@
74638 break;
74639 }
74640 default: {
74641 Trigger *pTrigger = 0;
74642 assert( onError==OE_Replace );
74643 sqlite3MultiWrite(pParse);
74644 if( pParse->db->flags&SQLITE_RecTriggers ){
74645 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
74646 }
74647 sqlite3GenerateRowDelete(
74648 pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace
@@ -72955,11 +74652,11 @@
74652 }
74653 }
74654 sqlite3VdbeJumpHere(v, j3);
74655 sqlite3ReleaseTempReg(pParse, regR);
74656 }
74657
74658 if( pbMayReplace ){
74659 *pbMayReplace = seenReplace;
74660 }
74661 }
74662
@@ -73379,15 +75076,10 @@
75076 return 1;
75077 }
75078 }
75079 #endif /* SQLITE_OMIT_XFER_OPT */
75080
 
 
 
 
 
75081 /************** End of insert.c **********************************************/
75082 /************** Begin file legacy.c ******************************************/
75083 /*
75084 ** 2001 September 15
75085 **
@@ -74721,10 +76413,16 @@
76413
76414 /* TODO: Maybe it shouldn't be possible to change the ReadUncommitted
76415 ** flag if there are any active statements. */
76416 { "read_uncommitted", SQLITE_ReadUncommitted },
76417 { "recursive_triggers", SQLITE_RecTriggers },
76418
76419 /* This flag may only be set if both foreign-key and trigger support
76420 ** are present in the build. */
76421 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
76422 { "foreign_keys", SQLITE_ForeignKeys },
76423 #endif
76424 };
76425 int i;
76426 const struct sPragmaType *p;
76427 for(i=0, p=aPragma; i<ArraySize(aPragma); i++, p++){
76428 if( sqlite3StrICmp(zLeft, p->zName)==0 ){
@@ -74734,14 +76432,21 @@
76432 assert( v!=0 ); /* Already allocated by sqlite3Pragma() */
76433 if( ALWAYS(v) ){
76434 if( zRight==0 ){
76435 returnSingleInt(pParse, p->zName, (db->flags & p->mask)!=0 );
76436 }else{
76437 int mask = p->mask; /* Mask of bits to set or clear. */
76438 if( db->autoCommit==0 ){
76439 /* Foreign key support may not be enabled or disabled while not
76440 ** in auto-commit mode. */
76441 mask &= ~(SQLITE_ForeignKeys);
76442 }
76443
76444 if( getBoolean(zRight) ){
76445 db->flags |= mask;
76446 }else{
76447 db->flags &= ~mask;
76448 }
76449
76450 /* Many of the flag-pragmas modify the code generated by the SQL
76451 ** compiler (eg. count_changes). So add an opcode to expire all
76452 ** compiled SQL statements after modifying a pragma value.
@@ -74758,21 +76463,24 @@
76463 #endif /* SQLITE_OMIT_FLAG_PRAGMAS */
76464
76465 /*
76466 ** Return a human-readable name for a constraint resolution action.
76467 */
76468 #ifndef SQLITE_OMIT_FOREIGN_KEY
76469 static const char *actionName(u8 action){
76470 const char *zName;
76471 switch( action ){
76472 case OE_SetNull: zName = "SET NULL"; break;
76473 case OE_SetDflt: zName = "SET DEFAULT"; break;
76474 case OE_Cascade: zName = "CASCADE"; break;
76475 case OE_Restrict: zName = "RESTRICT"; break;
76476 default: zName = "NO ACTION";
76477 assert( action==OE_None ); break;
76478 }
76479 return zName;
76480 }
76481 #endif
76482
76483 /*
76484 ** Process a pragma statement.
76485 **
76486 ** Pragmas are of this form:
@@ -75495,12 +77203,12 @@
77203 sqlite3VdbeSetColName(v, 7, COLNAME_NAME, "match", SQLITE_STATIC);
77204 while(pFK){
77205 int j;
77206 for(j=0; j<pFK->nCol; j++){
77207 char *zCol = pFK->aCol[j].zCol;
77208 char *zOnDelete = (char *)actionName(pFK->aAction[0]);
77209 char *zOnUpdate = (char *)actionName(pFK->aAction[1]);
77210 sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
77211 sqlite3VdbeAddOp2(v, OP_Integer, j, 2);
77212 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pFK->zTo, 0);
77213 sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0,
77214 pTab->aCol[pFK->aCol[j].iFrom].zName, 0);
@@ -81316,10 +83024,14 @@
83024 ** pTab as well as the triggers lised in pTab->pTrigger.
83025 */
83026 SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){
83027 Schema * const pTmpSchema = pParse->db->aDb[1].pSchema;
83028 Trigger *pList = 0; /* List of triggers to return */
83029
83030 if( pParse->disableTriggers ){
83031 return 0;
83032 }
83033
83034 if( pTmpSchema!=pTab->pSchema ){
83035 HashElem *p;
83036 for(p=sqliteHashFirst(&pTmpSchema->trigHash); p; p=sqliteHashNext(p)){
83037 Trigger *pTrig = (Trigger *)sqliteHashData(p);
@@ -82062,11 +83774,11 @@
83774 NameContext sNC; /* Name context for sub-vdbe */
83775 SubProgram *pProgram = 0; /* Sub-vdbe for trigger program */
83776 Parse *pSubParse; /* Parse context for sub-vdbe */
83777 int iEndTrigger = 0; /* Label to jump to if WHEN is false */
83778
83779 assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );
83780
83781 /* Allocate the TriggerPrg and SubProgram objects. To ensure that they
83782 ** are freed if an error occurs, link them into the Parse.pTriggerPrg
83783 ** list of the top-level Parse object sooner rather than later. */
83784 pPrg = sqlite3DbMallocZero(db, sizeof(TriggerPrg));
@@ -82076,10 +83788,11 @@
83788 pPrg->pProgram = pProgram = sqlite3DbMallocZero(db, sizeof(SubProgram));
83789 if( !pProgram ) return 0;
83790 pProgram->nRef = 1;
83791 pPrg->pTrigger = pTrigger;
83792 pPrg->orconf = orconf;
83793 pPrg->oldmask = 0xffffffff;
83794
83795 /* Allocate and populate a new Parse context to use for coding the
83796 ** trigger sub-program. */
83797 pSubParse = sqlite3StackAllocZero(db, sizeof(Parse));
83798 if( !pSubParse ) return 0;
@@ -82162,11 +83875,11 @@
83875 int orconf /* ON CONFLICT algorithm. */
83876 ){
83877 Parse *pRoot = sqlite3ParseToplevel(pParse);
83878 TriggerPrg *pPrg;
83879
83880 assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );
83881
83882 /* It may be that this trigger has already been coded (or is in the
83883 ** process of being coded). If this is the case, then an entry with
83884 ** a matching TriggerPrg.pTrigger field will be present somewhere
83885 ** in the Parse.pTriggerPrg list. Search for such an entry. */
@@ -82182,54 +83895,102 @@
83895
83896 return pPrg;
83897 }
83898
83899 /*
83900 ** Generate code for the trigger program associated with trigger p on
83901 ** table pTab. The reg, orconf and ignoreJump parameters passed to this
83902 ** function are the same as those described in the header function for
83903 ** sqlite3CodeRowTrigger()
83904 */
83905 SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(
83906 Parse *pParse, /* Parse context */
83907 Trigger *p, /* Trigger to code */
83908 Table *pTab, /* The table to code triggers from */
83909 int reg, /* Reg array containing OLD.* and NEW.* values */
83910 int orconf, /* ON CONFLICT policy */
83911 int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */
83912 ){
83913 Vdbe *v = sqlite3GetVdbe(pParse); /* Main VM */
83914 TriggerPrg *pPrg;
83915 pPrg = getRowTrigger(pParse, p, pTab, orconf);
83916 assert( pPrg || pParse->nErr || pParse->db->mallocFailed );
83917
83918 /* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program
83919 ** is a pointer to the sub-vdbe containing the trigger program. */
83920 if( pPrg ){
83921 sqlite3VdbeAddOp3(v, OP_Program, reg, ignoreJump, ++pParse->nMem);
83922 pPrg->pProgram->nRef++;
83923 sqlite3VdbeChangeP4(v, -1, (const char *)pPrg->pProgram, P4_SUBPROGRAM);
83924 VdbeComment(
83925 (v, "Call: %s.%s", (p->zName?p->zName:"fkey"), onErrorText(orconf)));
83926
83927 /* Set the P5 operand of the OP_Program instruction to non-zero if
83928 ** recursive invocation of this trigger program is disallowed. Recursive
83929 ** invocation is disallowed if (a) the sub-program is really a trigger,
83930 ** not a foreign key action, and (b) the flag to enable recursive triggers
83931 ** is clear. */
83932 sqlite3VdbeChangeP5(v, p->zName && !(pParse->db->flags&SQLITE_RecTriggers));
83933 }
83934 }
83935
83936 /*
83937 ** This is called to code the required FOR EACH ROW triggers for an operation
83938 ** on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE)
83939 ** is given by the op paramater. The tr_tm parameter determines whether the
83940 ** BEFORE or AFTER triggers are coded. If the operation is an UPDATE, then
83941 ** parameter pChanges is passed the list of columns being modified.
83942 **
83943 ** If there are no triggers that fire at the specified time for the specified
83944 ** operation on pTab, this function is a no-op.
83945 **
83946 ** The reg argument is the address of the first in an array of registers
83947 ** that contain the values substituted for the new.* and old.* references
83948 ** in the trigger program. If N is the number of columns in table pTab
83949 ** (a copy of pTab->nCol), then registers are populated as follows:
83950 **
83951 ** Register Contains
83952 ** ------------------------------------------------------
83953 ** reg+0 OLD.rowid
83954 ** reg+1 OLD.* value of left-most column of pTab
83955 ** ... ...
83956 ** reg+N OLD.* value of right-most column of pTab
83957 ** reg+N+1 NEW.rowid
83958 ** reg+N+2 OLD.* value of left-most column of pTab
83959 ** ... ...
83960 ** reg+N+N+1 NEW.* value of right-most column of pTab
83961 **
83962 ** For ON DELETE triggers, the registers containing the NEW.* values will
83963 ** never be accessed by the trigger program, so they are not allocated or
83964 ** populated by the caller (there is no data to populate them with anyway).
83965 ** Similarly, for ON INSERT triggers the values stored in the OLD.* registers
83966 ** are never accessed, and so are not allocated by the caller. So, for an
83967 ** ON INSERT trigger, the value passed to this function as parameter reg
83968 ** is not a readable register, although registers (reg+N) through
83969 ** (reg+N+N+1) are.
83970 **
83971 ** Parameter orconf is the default conflict resolution algorithm for the
83972 ** trigger program to use (REPLACE, IGNORE etc.). Parameter ignoreJump
83973 ** is the instruction that control should jump to if a trigger program
83974 ** raises an IGNORE exception.
83975 */
83976 SQLITE_PRIVATE void sqlite3CodeRowTrigger(
83977 Parse *pParse, /* Parse context */
83978 Trigger *pTrigger, /* List of triggers on table pTab */
83979 int op, /* One of TK_UPDATE, TK_INSERT, TK_DELETE */
83980 ExprList *pChanges, /* Changes list for any UPDATE OF triggers */
83981 int tr_tm, /* One of TRIGGER_BEFORE, TRIGGER_AFTER */
83982 Table *pTab, /* The table to code triggers from */
83983 int reg, /* The first in an array of registers (see above) */
 
83984 int orconf, /* ON CONFLICT policy */
83985 int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */
83986 ){
83987 Trigger *p; /* Used to iterate through pTrigger list */
83988
83989 assert( op==TK_UPDATE || op==TK_INSERT || op==TK_DELETE );
83990 assert( tr_tm==TRIGGER_BEFORE || tr_tm==TRIGGER_AFTER );
83991 assert( (op==TK_UPDATE)==(pChanges!=0) );
 
83992
83993 for(p=pTrigger; p; p=p->pNext){
83994
83995 /* Sanity checking: The schema for the trigger and for the table are
83996 ** always defined. The trigger must be in the same schema as the table
@@ -82240,25 +84001,13 @@
84001 || p->pSchema==pParse->db->aDb[1].pSchema );
84002
84003 /* Determine whether we should code this trigger */
84004 if( p->op==op
84005 && p->tr_tm==tr_tm
84006 && checkColumnOverlap(p->pColumns, pChanges)
84007 ){
84008 sqlite3CodeRowTriggerDirect(pParse, p, pTab, reg, orconf, ignoreJump);
 
 
 
 
 
 
 
 
 
 
 
 
84009 }
84010 }
84011 }
84012
84013 /*
@@ -82281,19 +84030,18 @@
84030 ** There is no equivalent function for new.* references.
84031 */
84032 SQLITE_PRIVATE u32 sqlite3TriggerOldmask(
84033 Parse *pParse, /* Parse context */
84034 Trigger *pTrigger, /* List of triggers on table pTab */
 
84035 ExprList *pChanges, /* Changes list for any UPDATE OF triggers */
84036 Table *pTab, /* The table to code triggers from */
84037 int orconf /* Default ON CONFLICT policy for trigger steps */
84038 ){
84039 const int op = pChanges ? TK_UPDATE : TK_DELETE;
84040 u32 mask = 0;
84041 Trigger *p;
84042
 
84043 for(p=pTrigger; p; p=p->pNext){
84044 if( p->op==op && checkColumnOverlap(p->pColumns,pChanges) ){
84045 TriggerPrg *pPrg;
84046 pPrg = getRowTrigger(pParse, p, pTab, orconf);
84047 if( pPrg ){
@@ -82423,16 +84171,16 @@
84171 AuthContext sContext; /* The authorization context */
84172 NameContext sNC; /* The name-context to resolve expressions in */
84173 int iDb; /* Database containing the table being updated */
84174 int j1; /* Addresses of jump instructions */
84175 int okOnePass; /* True for one-pass algorithm without the FIFO */
84176 int hasFK; /* True if foreign key processing is required */
84177
84178 #ifndef SQLITE_OMIT_TRIGGER
84179 int isView; /* Trying to update a view */
84180 Trigger *pTrigger; /* List of triggers on pTab, if required */
84181 #endif
 
84182
84183 /* Register Allocations */
84184 int regRowCount = 0; /* A count of rows changed */
84185 int regOldRowid; /* The old rowid */
84186 int regNewRowid; /* The new rowid */
@@ -82535,10 +84283,12 @@
84283 aXRef[j] = -1;
84284 }
84285 }
84286 #endif
84287 }
84288
84289 hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngRowid);
84290
84291 /* Allocate memory for the array aRegIdx[]. There is one entry in the
84292 ** array for each index associated with table being updated. Fill in
84293 ** the value with a register number for indices that are to be used
84294 ** and with zero for unused indices.
@@ -82581,15 +84331,15 @@
84331 }
84332 #endif
84333
84334 /* Allocate required registers. */
84335 regOldRowid = regNewRowid = ++pParse->nMem;
84336 if( pTrigger || hasFK ){
84337 regOld = pParse->nMem + 1;
84338 pParse->nMem += pTab->nCol;
84339 }
84340 if( chngRowid || pTrigger || hasFK ){
84341 regNewRowid = ++pParse->nMem;
84342 }
84343 regNew = pParse->nMem + 1;
84344 pParse->nMem += pTab->nCol;
84345 regRec = ++pParse->nMem;
@@ -82597,14 +84347,10 @@
84347 /* Start the view context. */
84348 if( isView ){
84349 sqlite3AuthContextPush(pParse, &sContext, pTab->zName);
84350 }
84351
 
 
 
 
84352 /* If we are trying to update a view, realize that view into
84353 ** a ephemeral table.
84354 */
84355 #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
84356 if( isView ){
@@ -82685,34 +84431,37 @@
84431
84432 /* Make cursor iCur point to the record that is being updated. If
84433 ** this record does not exist for some reason (deleted by a trigger,
84434 ** for example, then jump to the next iteration of the RowSet loop. */
84435 sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid);
84436
84437 /* If the record number will change, set register regNewRowid to
84438 ** contain the new value. If the record number is not being modified,
84439 ** then regNewRowid is the same register as regOldRowid, which is
84440 ** already populated. */
84441 assert( chngRowid || pTrigger || hasFK || regOldRowid==regNewRowid );
84442 if( chngRowid ){
84443 sqlite3ExprCode(pParse, pRowidExpr, regNewRowid);
84444 sqlite3VdbeAddOp1(v, OP_MustBeInt, regNewRowid);
84445 }
84446
84447 /* If there are triggers on this table, populate an array of registers
84448 ** with the required old.* column data. */
84449 if( hasFK || pTrigger ){
84450 u32 oldmask = (hasFK ? sqlite3FkOldmask(pParse, pTab) : 0);
84451 oldmask |= sqlite3TriggerOldmask(pParse, pTrigger, pChanges, pTab, onError);
84452 for(i=0; i<pTab->nCol; i++){
84453 if( aXRef[i]<0 || oldmask==0xffffffff || (oldmask & (1<<i)) ){
84454 sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regOld+i);
84455 sqlite3ColumnDefault(v, pTab, i, regOld+i);
84456 }else{
84457 sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i);
84458 }
84459 }
84460 if( chngRowid==0 ){
84461 sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid);
84462 }
 
 
 
 
 
 
 
 
 
84463 }
84464
84465 /* Populate the array of registers beginning at regNew with the new
84466 ** row data. This array is used to check constaints, create the new
84467 ** table and index records, and as the values for any new.* references
@@ -82735,11 +84484,11 @@
84484 ** verified. One could argue that this is wrong. */
84485 if( pTrigger ){
84486 sqlite3VdbeAddOp2(v, OP_Affinity, regNew, pTab->nCol);
84487 sqlite3TableAffinityStr(v, pTab);
84488 sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges,
84489 TRIGGER_BEFORE, pTab, regOldRowid, onError, addr);
84490
84491 /* The row-trigger may have deleted the row being updated. In this
84492 ** case, jump to the next row. No updates or AFTER triggers are
84493 ** required. This behaviour - what happens when the row being updated
84494 ** is deleted or renamed by a BEFORE trigger - is left undefined in the
@@ -82750,33 +84499,49 @@
84499 if( !isView ){
84500
84501 /* Do constraint checks. */
84502 sqlite3GenerateConstraintChecks(pParse, pTab, iCur, regNewRowid,
84503 aRegIdx, (chngRowid?regOldRowid:0), 1, onError, addr, 0);
84504
84505 /* Do FK constraint checks. */
84506 if( hasFK ){
84507 sqlite3FkCheck(pParse, pTab, regOldRowid, 0);
84508 }
84509
84510 /* Delete the index entries associated with the current record. */
84511 j1 = sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regOldRowid);
84512 sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, aRegIdx);
84513
84514 /* If changing the record number, delete the old record. */
84515 if( hasFK || chngRowid ){
84516 sqlite3VdbeAddOp2(v, OP_Delete, iCur, 0);
84517 }
84518 sqlite3VdbeJumpHere(v, j1);
84519
84520 if( hasFK ){
84521 sqlite3FkCheck(pParse, pTab, 0, regNewRowid);
84522 }
84523
84524 /* Insert the new index entries and the new record. */
84525 sqlite3CompleteInsertion(pParse, pTab, iCur, regNewRowid, aRegIdx, 1, 0, 0);
84526
84527 /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to
84528 ** handle rows (possibly in other tables) that refer via a foreign key
84529 ** to the row just updated. */
84530 if( hasFK ){
84531 sqlite3FkActions(pParse, pTab, pChanges, regOldRowid);
84532 }
84533 }
84534
84535 /* Increment the row counter
84536 */
84537 if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab){
84538 sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);
84539 }
84540
84541 sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges,
84542 TRIGGER_AFTER, pTab, regOldRowid, onError, addr);
84543
84544 /* Repeat the above with the next record to be updated, until
84545 ** all record selected by the WHERE clause have been updated.
84546 */
84547 sqlite3VdbeAddOp2(v, OP_Goto, 0, addr);
@@ -82816,10 +84581,19 @@
84581 sqlite3SrcListDelete(db, pTabList);
84582 sqlite3ExprListDelete(db, pChanges);
84583 sqlite3ExprDelete(db, pWhere);
84584 return;
84585 }
84586 /* Make sure "isView" and other macros defined above are undefined. Otherwise
84587 ** thely may interfere with compilation of other functions in this file
84588 ** (or in another file, if this file becomes part of the amalgamation). */
84589 #ifdef isView
84590 #undef isView
84591 #endif
84592 #ifdef pTrigger
84593 #undef pTrigger
84594 #endif
84595
84596 #ifndef SQLITE_OMIT_VIRTUALTABLE
84597 /*
84598 ** Generate code for an UPDATE of a virtual table.
84599 **
@@ -82911,15 +84685,10 @@
84685 /* Cleanup */
84686 sqlite3SelectDelete(db, pSelect);
84687 }
84688 #endif /* SQLITE_OMIT_VIRTUALTABLE */
84689
 
 
 
 
 
84690 /************** End of update.c **********************************************/
84691 /************** Begin file vacuum.c ******************************************/
84692 /*
84693 ** 2003 April 6
84694 **
@@ -83015,15 +84784,18 @@
84784 if( !db->autoCommit ){
84785 sqlite3SetString(pzErrMsg, db, "cannot VACUUM from within a transaction");
84786 return SQLITE_ERROR;
84787 }
84788
84789 /* Save the current value of the database flags so that it can be
84790 ** restored before returning. Then set the writable-schema flag, and
84791 ** disable CHECK and foreign key constraints. */
84792 saved_flags = db->flags;
84793 saved_nChange = db->nChange;
84794 saved_nTotalChange = db->nTotalChange;
84795 db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
84796 db->flags &= ~SQLITE_ForeignKeys;
84797
84798 pMain = db->aDb[0].pBt;
84799 isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));
84800
84801 /* Attach the temporary database as 'vacuum_db'. The synchronous pragma
@@ -86139,13 +87911,12 @@
87911 for(i=0; i<SQLITE_INDEX_SAMPLES; i++){
87912 int r;
87913 int eSampletype = aSample[i].eType;
87914 if( eSampletype==SQLITE_NULL || eSampletype<eType ) continue;
87915 if( (eSampletype!=eType) ) break;
87916 #ifndef SQLITE_OMIT_UTF16
87917 if( pColl->enc!=SQLITE_UTF8 ){
 
87918 int nSample;
87919 char *zSample = sqlite3Utf8to16(
87920 db, pColl->enc, aSample[i].u.z, aSample[i].nByte, &nSample
87921 );
87922 if( !zSample ){
@@ -86152,10 +87923,14 @@
87923 assert( db->mallocFailed );
87924 return SQLITE_NOMEM;
87925 }
87926 r = pColl->xCmp(pColl->pUser, nSample, zSample, n, z);
87927 sqlite3DbFree(db, zSample);
87928 }else
87929 #endif
87930 {
87931 r = pColl->xCmp(pColl->pUser, aSample[i].nByte, aSample[i].u.z, n, z);
87932 }
87933 if( r>0 ) break;
87934 }
87935 }
87936
@@ -88304,11 +90079,11 @@
90079 ** defined, then do no error processing.
90080 */
90081 #define YYCODETYPE unsigned char
90082 #define YYNOCODE 254
90083 #define YYACTIONTYPE unsigned short int
90084 #define YYWILDCARD 67
90085 #define sqlite3ParserTOKENTYPE Token
90086 typedef union {
90087 int yyinit;
90088 sqlite3ParserTOKENTYPE yy0;
90089 Select* yy3;
@@ -88402,454 +90177,461 @@
90177 ** yy_reduce_ofst[] For each state, the offset into yy_action for
90178 ** shifting non-terminals after a reduce.
90179 ** yy_default[] Default action for each state.
90180 */
90181 static const YYACTIONTYPE yy_action[] = {
90182 /* 0 */ 312, 959, 182, 628, 2, 157, 219, 450, 24, 24,
90183 /* 10 */ 24, 24, 221, 26, 26, 26, 26, 27, 27, 28,
90184 /* 20 */ 28, 28, 29, 221, 424, 425, 30, 492, 33, 141,
90185 /* 30 */ 457, 463, 31, 26, 26, 26, 26, 27, 27, 28,
90186 /* 40 */ 28, 28, 29, 221, 28, 28, 28, 29, 221, 23,
90187 /* 50 */ 22, 32, 465, 466, 464, 464, 25, 25, 24, 24,
90188 /* 60 */ 24, 24, 293, 26, 26, 26, 26, 27, 27, 28,
90189 /* 70 */ 28, 28, 29, 221, 312, 450, 319, 479, 344, 208,
90190 /* 80 */ 47, 26, 26, 26, 26, 27, 27, 28, 28, 28,
90191 /* 90 */ 29, 221, 427, 428, 163, 339, 543, 368, 371, 372,
90192 /* 100 */ 521, 317, 472, 473, 457, 463, 296, 373, 294, 21,
90193 /* 110 */ 336, 367, 419, 416, 424, 425, 523, 1, 544, 446,
90194 /* 120 */ 80, 424, 425, 23, 22, 32, 465, 466, 464, 464,
90195 /* 130 */ 25, 25, 24, 24, 24, 24, 564, 26, 26, 26,
90196 /* 140 */ 26, 27, 27, 28, 28, 28, 29, 221, 312, 233,
90197 /* 150 */ 319, 441, 554, 152, 139, 263, 365, 268, 366, 160,
90198 /* 160 */ 551, 352, 332, 421, 222, 272, 362, 322, 218, 557,
90199 /* 170 */ 116, 339, 248, 574, 477, 223, 216, 573, 457, 463,
90200 /* 180 */ 450, 59, 427, 428, 295, 610, 336, 563, 538, 427,
90201 /* 190 */ 428, 385, 608, 609, 562, 446, 87, 23, 22, 32,
90202 /* 200 */ 465, 466, 464, 464, 25, 25, 24, 24, 24, 24,
90203 /* 210 */ 447, 26, 26, 26, 26, 27, 27, 28, 28, 28,
90204 /* 220 */ 29, 221, 312, 233, 477, 223, 576, 134, 139, 263,
90205 /* 230 */ 365, 268, 366, 160, 406, 354, 226, 498, 481, 272,
90206 /* 240 */ 339, 27, 27, 28, 28, 28, 29, 221, 450, 442,
90207 /* 250 */ 199, 540, 457, 463, 349, 336, 163, 551, 66, 368,
90208 /* 260 */ 371, 372, 450, 415, 446, 80, 522, 581, 401, 373,
90209 /* 270 */ 452, 23, 22, 32, 465, 466, 464, 464, 25, 25,
90210 /* 280 */ 24, 24, 24, 24, 447, 26, 26, 26, 26, 27,
90211 /* 290 */ 27, 28, 28, 28, 29, 221, 312, 339, 556, 607,
90212 /* 300 */ 197, 454, 454, 454, 546, 578, 352, 198, 607, 440,
90213 /* 310 */ 65, 351, 336, 426, 426, 399, 289, 424, 425, 606,
90214 /* 320 */ 605, 446, 73, 426, 214, 219, 457, 463, 606, 410,
90215 /* 330 */ 450, 241, 306, 196, 565, 479, 555, 208, 288, 29,
90216 /* 340 */ 221, 447, 4, 874, 504, 23, 22, 32, 465, 466,
90217 /* 350 */ 464, 464, 25, 25, 24, 24, 24, 24, 447, 26,
90218 /* 360 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 221,
90219 /* 370 */ 312, 163, 582, 339, 368, 371, 372, 314, 424, 425,
90220 /* 380 */ 604, 222, 397, 227, 373, 427, 428, 339, 336, 409,
90221 /* 390 */ 222, 478, 339, 30, 396, 33, 141, 446, 81, 62,
90222 /* 400 */ 457, 463, 336, 157, 400, 450, 504, 336, 438, 426,
90223 /* 410 */ 500, 446, 87, 41, 380, 613, 446, 80, 581, 23,
90224 /* 420 */ 22, 32, 465, 466, 464, 464, 25, 25, 24, 24,
90225 /* 430 */ 24, 24, 213, 26, 26, 26, 26, 27, 27, 28,
90226 /* 440 */ 28, 28, 29, 221, 312, 513, 427, 428, 517, 254,
90227 /* 450 */ 524, 386, 225, 339, 486, 363, 389, 339, 356, 443,
90228 /* 460 */ 494, 236, 30, 497, 33, 141, 399, 289, 336, 495,
90229 /* 470 */ 487, 501, 336, 450, 457, 463, 219, 446, 95, 445,
90230 /* 480 */ 68, 446, 95, 444, 424, 425, 488, 44, 348, 288,
90231 /* 490 */ 504, 424, 425, 23, 22, 32, 465, 466, 464, 464,
90232 /* 500 */ 25, 25, 24, 24, 24, 24, 391, 26, 26, 26,
90233 /* 510 */ 26, 27, 27, 28, 28, 28, 29, 221, 312, 361,
90234 /* 520 */ 556, 426, 520, 328, 191, 271, 339, 329, 247, 259,
90235 /* 530 */ 339, 566, 65, 249, 336, 426, 424, 425, 445, 516,
90236 /* 540 */ 426, 336, 444, 446, 9, 336, 556, 451, 457, 463,
90237 /* 550 */ 446, 74, 427, 428, 446, 69, 192, 618, 65, 427,
90238 /* 560 */ 428, 426, 323, 277, 16, 202, 189, 23, 22, 32,
90239 /* 570 */ 465, 466, 464, 464, 25, 25, 24, 24, 24, 24,
90240 /* 580 */ 255, 26, 26, 26, 26, 27, 27, 28, 28, 28,
90241 /* 590 */ 29, 221, 312, 339, 486, 426, 537, 235, 515, 447,
90242 /* 600 */ 339, 629, 419, 416, 427, 428, 217, 281, 336, 279,
90243 /* 610 */ 487, 203, 144, 526, 527, 336, 391, 446, 78, 429,
90244 /* 620 */ 430, 431, 457, 463, 446, 99, 488, 341, 528, 468,
90245 /* 630 */ 468, 426, 343, 472, 473, 626, 949, 474, 949, 529,
90246 /* 640 */ 447, 23, 22, 32, 465, 466, 464, 464, 25, 25,
90247 /* 650 */ 24, 24, 24, 24, 339, 26, 26, 26, 26, 27,
90248 /* 660 */ 27, 28, 28, 28, 29, 221, 312, 339, 162, 336,
90249 /* 670 */ 275, 283, 476, 376, 339, 579, 527, 346, 446, 98,
90250 /* 680 */ 622, 30, 336, 33, 141, 339, 426, 339, 508, 336,
90251 /* 690 */ 469, 446, 105, 418, 2, 222, 457, 463, 446, 101,
90252 /* 700 */ 336, 219, 336, 426, 161, 626, 948, 290, 948, 446,
90253 /* 710 */ 108, 446, 109, 398, 284, 23, 22, 32, 465, 466,
90254 /* 720 */ 464, 464, 25, 25, 24, 24, 24, 24, 339, 26,
90255 /* 730 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 221,
90256 /* 740 */ 312, 339, 271, 336, 339, 58, 535, 482, 143, 339,
90257 /* 750 */ 622, 318, 446, 133, 408, 257, 336, 426, 321, 336,
90258 /* 760 */ 357, 339, 272, 426, 336, 446, 135, 184, 446, 61,
90259 /* 770 */ 457, 463, 219, 446, 106, 426, 336, 493, 341, 234,
90260 /* 780 */ 468, 468, 621, 310, 407, 446, 102, 209, 144, 23,
90261 /* 790 */ 22, 32, 465, 466, 464, 464, 25, 25, 24, 24,
90262 /* 800 */ 24, 24, 339, 26, 26, 26, 26, 27, 27, 28,
90263 /* 810 */ 28, 28, 29, 221, 312, 339, 271, 336, 339, 341,
90264 /* 820 */ 538, 468, 468, 572, 383, 496, 446, 79, 499, 549,
90265 /* 830 */ 336, 426, 508, 336, 508, 341, 339, 468, 468, 446,
90266 /* 840 */ 103, 391, 446, 70, 457, 463, 572, 426, 40, 426,
90267 /* 850 */ 42, 336, 220, 324, 504, 341, 426, 468, 468, 18,
90268 /* 860 */ 446, 100, 266, 23, 22, 32, 465, 466, 464, 464,
90269 /* 870 */ 25, 25, 24, 24, 24, 24, 339, 26, 26, 26,
90270 /* 880 */ 26, 27, 27, 28, 28, 28, 29, 221, 312, 339,
90271 /* 890 */ 283, 336, 339, 261, 548, 384, 339, 327, 142, 550,
90272 /* 900 */ 446, 136, 475, 475, 336, 426, 185, 336, 499, 396,
90273 /* 910 */ 339, 336, 370, 446, 137, 256, 446, 138, 457, 463,
90274 /* 920 */ 446, 71, 499, 360, 426, 336, 161, 311, 623, 215,
90275 /* 930 */ 426, 359, 237, 412, 446, 82, 200, 23, 34, 32,
90276 /* 940 */ 465, 466, 464, 464, 25, 25, 24, 24, 24, 24,
90277 /* 950 */ 339, 26, 26, 26, 26, 27, 27, 28, 28, 28,
90278 /* 960 */ 29, 221, 312, 447, 271, 336, 339, 271, 340, 210,
90279 /* 970 */ 447, 172, 625, 211, 446, 83, 240, 552, 142, 426,
90280 /* 980 */ 321, 336, 426, 426, 339, 414, 331, 181, 458, 459,
90281 /* 990 */ 446, 72, 457, 463, 470, 506, 67, 158, 394, 336,
90282 /* 1000 */ 587, 325, 499, 447, 326, 311, 624, 447, 446, 84,
90283 /* 1010 */ 461, 462, 22, 32, 465, 466, 464, 464, 25, 25,
90284 /* 1020 */ 24, 24, 24, 24, 339, 26, 26, 26, 26, 27,
90285 /* 1030 */ 27, 28, 28, 28, 29, 221, 312, 460, 339, 336,
90286 /* 1040 */ 339, 283, 423, 393, 532, 533, 204, 205, 446, 85,
90287 /* 1050 */ 625, 392, 547, 336, 162, 336, 426, 426, 339, 435,
90288 /* 1060 */ 436, 339, 446, 104, 446, 86, 457, 463, 264, 291,
90289 /* 1070 */ 274, 49, 162, 336, 426, 426, 336, 297, 265, 542,
90290 /* 1080 */ 541, 405, 446, 88, 594, 446, 89, 32, 465, 466,
90291 /* 1090 */ 464, 464, 25, 25, 24, 24, 24, 24, 600, 26,
90292 /* 1100 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 221,
90293 /* 1110 */ 36, 345, 339, 3, 214, 8, 422, 335, 425, 437,
90294 /* 1120 */ 375, 148, 162, 36, 345, 339, 3, 336, 342, 432,
90295 /* 1130 */ 335, 425, 149, 577, 426, 162, 446, 90, 151, 339,
90296 /* 1140 */ 336, 342, 434, 339, 283, 433, 333, 347, 447, 446,
90297 /* 1150 */ 75, 588, 6, 158, 336, 448, 140, 481, 336, 426,
90298 /* 1160 */ 347, 453, 334, 446, 76, 49, 350, 446, 91, 7,
90299 /* 1170 */ 481, 426, 397, 283, 355, 250, 426, 39, 38, 251,
90300 /* 1180 */ 339, 426, 48, 353, 37, 337, 338, 596, 426, 452,
90301 /* 1190 */ 39, 38, 514, 252, 390, 336, 20, 37, 337, 338,
90302 /* 1200 */ 253, 43, 452, 206, 446, 92, 219, 449, 242, 243,
90303 /* 1210 */ 244, 150, 246, 283, 491, 593, 597, 490, 224, 258,
90304 /* 1220 */ 454, 454, 454, 455, 456, 10, 503, 183, 426, 178,
90305 /* 1230 */ 156, 301, 426, 454, 454, 454, 455, 456, 10, 339,
90306 /* 1240 */ 302, 426, 36, 345, 50, 3, 339, 505, 260, 335,
90307 /* 1250 */ 425, 262, 339, 176, 336, 581, 598, 358, 364, 175,
90308 /* 1260 */ 342, 336, 177, 446, 93, 46, 345, 336, 3, 339,
90309 /* 1270 */ 446, 94, 335, 425, 525, 339, 446, 77, 320, 347,
90310 /* 1280 */ 511, 339, 507, 342, 336, 589, 601, 56, 56, 481,
90311 /* 1290 */ 336, 512, 283, 446, 17, 531, 336, 426, 530, 446,
90312 /* 1300 */ 96, 534, 347, 404, 298, 446, 97, 426, 313, 39,
90313 /* 1310 */ 38, 267, 481, 219, 535, 536, 37, 337, 338, 283,
90314 /* 1320 */ 620, 452, 309, 283, 111, 19, 288, 509, 269, 424,
90315 /* 1330 */ 425, 539, 39, 38, 426, 238, 270, 411, 426, 37,
90316 /* 1340 */ 337, 338, 426, 426, 452, 558, 426, 307, 231, 276,
90317 /* 1350 */ 278, 426, 454, 454, 454, 455, 456, 10, 553, 280,
90318 /* 1360 */ 426, 559, 239, 230, 426, 426, 299, 282, 287, 481,
90319 /* 1370 */ 560, 388, 584, 232, 426, 454, 454, 454, 455, 456,
90320 /* 1380 */ 10, 561, 426, 426, 585, 395, 426, 426, 292, 194,
90321 /* 1390 */ 195, 592, 603, 300, 303, 308, 377, 522, 381, 426,
90322 /* 1400 */ 426, 452, 567, 426, 304, 617, 426, 426, 426, 426,
90323 /* 1410 */ 379, 53, 147, 165, 166, 167, 580, 212, 569, 426,
90324 /* 1420 */ 426, 285, 168, 570, 387, 120, 123, 187, 590, 402,
90325 /* 1430 */ 403, 125, 454, 454, 454, 330, 599, 614, 186, 126,
90326 /* 1440 */ 127, 128, 615, 616, 57, 60, 619, 107, 229, 64,
90327 /* 1450 */ 115, 420, 245, 130, 439, 180, 315, 207, 670, 316,
90328 /* 1460 */ 671, 467, 672, 153, 154, 35, 483, 471, 480, 188,
90329 /* 1470 */ 201, 155, 484, 5, 485, 489, 12, 502, 45, 11,
90330 /* 1480 */ 110, 145, 518, 519, 510, 228, 51, 112, 369, 273,
90331 /* 1490 */ 113, 159, 545, 52, 374, 114, 164, 265, 378, 190,
90332 /* 1500 */ 146, 568, 117, 158, 286, 382, 169, 119, 15, 583,
90333 /* 1510 */ 170, 171, 121, 586, 122, 54, 55, 13, 124, 591,
90334 /* 1520 */ 173, 174, 118, 575, 129, 595, 571, 131, 14, 132,
90335 /* 1530 */ 611, 63, 612, 193, 602, 179, 305, 413, 417, 960,
90336 /* 1540 */ 627,
90337 };
90338 static const YYCODETYPE yy_lookahead[] = {
90339 /* 0 */ 19, 142, 143, 144, 145, 24, 115, 26, 77, 78,
90340 /* 10 */ 79, 80, 92, 82, 83, 84, 85, 86, 87, 88,
90341 /* 20 */ 89, 90, 91, 92, 26, 27, 222, 223, 224, 225,
90342 /* 30 */ 49, 50, 81, 82, 83, 84, 85, 86, 87, 88,
90343 /* 40 */ 89, 90, 91, 92, 88, 89, 90, 91, 92, 68,
90344 /* 50 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
90345 /* 60 */ 79, 80, 16, 82, 83, 84, 85, 86, 87, 88,
90346 /* 70 */ 89, 90, 91, 92, 19, 94, 19, 166, 167, 168,
90347 /* 80 */ 25, 82, 83, 84, 85, 86, 87, 88, 89, 90,
90348 /* 90 */ 91, 92, 94, 95, 96, 150, 36, 99, 100, 101,
90349 /* 100 */ 174, 169, 170, 171, 49, 50, 60, 109, 62, 54,
90350 /* 110 */ 165, 51, 1, 2, 26, 27, 174, 22, 58, 174,
90351 /* 120 */ 175, 26, 27, 68, 69, 70, 71, 72, 73, 74,
90352 /* 130 */ 75, 76, 77, 78, 79, 80, 186, 82, 83, 84,
90353 /* 140 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 92,
90354 /* 150 */ 19, 172, 173, 96, 97, 98, 99, 100, 101, 102,
90355 /* 160 */ 181, 216, 146, 147, 232, 108, 221, 107, 152, 186,
90356 /* 170 */ 154, 150, 195, 30, 86, 87, 160, 34, 49, 50,
90357 /* 180 */ 26, 52, 94, 95, 138, 97, 165, 181, 182, 94,
90358 /* 190 */ 95, 48, 104, 105, 188, 174, 175, 68, 69, 70,
90359 /* 200 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
90360 /* 210 */ 194, 82, 83, 84, 85, 86, 87, 88, 89, 90,
90361 /* 220 */ 91, 92, 19, 92, 86, 87, 21, 24, 97, 98,
90362 /* 230 */ 99, 100, 101, 102, 218, 214, 215, 208, 66, 108,
90363 /* 240 */ 150, 86, 87, 88, 89, 90, 91, 92, 94, 173,
90364 /* 250 */ 160, 183, 49, 50, 191, 165, 96, 181, 22, 99,
90365 /* 260 */ 100, 101, 26, 247, 174, 175, 94, 57, 63, 109,
90366 /* 270 */ 98, 68, 69, 70, 71, 72, 73, 74, 75, 76,
90367 /* 280 */ 77, 78, 79, 80, 194, 82, 83, 84, 85, 86,
90368 /* 290 */ 87, 88, 89, 90, 91, 92, 19, 150, 150, 150,
90369 /* 300 */ 25, 129, 130, 131, 183, 100, 216, 160, 150, 161,
90370 /* 310 */ 162, 221, 165, 165, 165, 105, 106, 26, 27, 170,
90371 /* 320 */ 171, 174, 175, 165, 160, 115, 49, 50, 170, 171,
90372 /* 330 */ 94, 148, 163, 185, 186, 166, 167, 168, 128, 91,
90373 /* 340 */ 92, 194, 196, 138, 166, 68, 69, 70, 71, 72,
90374 /* 350 */ 73, 74, 75, 76, 77, 78, 79, 80, 194, 82,
90375 /* 360 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
90376 /* 370 */ 19, 96, 11, 150, 99, 100, 101, 155, 26, 27,
90377 /* 380 */ 231, 232, 218, 205, 109, 94, 95, 150, 165, 231,
90378 /* 390 */ 232, 166, 150, 222, 150, 224, 225, 174, 175, 235,
90379 /* 400 */ 49, 50, 165, 24, 240, 26, 166, 165, 153, 165,
90380 /* 410 */ 119, 174, 175, 136, 237, 244, 174, 175, 57, 68,
90381 /* 420 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
90382 /* 430 */ 79, 80, 236, 82, 83, 84, 85, 86, 87, 88,
90383 /* 440 */ 89, 90, 91, 92, 19, 205, 94, 95, 23, 226,
90384 /* 450 */ 165, 229, 215, 150, 12, 88, 234, 150, 216, 174,
90385 /* 460 */ 32, 217, 222, 25, 224, 225, 105, 106, 165, 41,
90386 /* 470 */ 28, 119, 165, 94, 49, 50, 115, 174, 175, 112,
90387 /* 480 */ 22, 174, 175, 116, 26, 27, 44, 136, 46, 128,
90388 /* 490 */ 166, 26, 27, 68, 69, 70, 71, 72, 73, 74,
90389 /* 500 */ 75, 76, 77, 78, 79, 80, 150, 82, 83, 84,
90390 /* 510 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 150,
90391 /* 520 */ 150, 165, 23, 220, 196, 150, 150, 220, 158, 205,
90392 /* 530 */ 150, 161, 162, 198, 165, 165, 26, 27, 112, 23,
90393 /* 540 */ 165, 165, 116, 174, 175, 165, 150, 166, 49, 50,
90394 /* 550 */ 174, 175, 94, 95, 174, 175, 118, 161, 162, 94,
90395 /* 560 */ 95, 165, 187, 16, 22, 160, 24, 68, 69, 70,
90396 /* 570 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
90397 /* 580 */ 150, 82, 83, 84, 85, 86, 87, 88, 89, 90,
90398 /* 590 */ 91, 92, 19, 150, 12, 165, 23, 241, 88, 194,
90399 /* 600 */ 150, 0, 1, 2, 94, 95, 160, 60, 165, 62,
90400 /* 610 */ 28, 206, 207, 190, 191, 165, 150, 174, 175, 7,
90401 /* 620 */ 8, 9, 49, 50, 174, 175, 44, 111, 46, 113,
90402 /* 630 */ 114, 165, 169, 170, 171, 22, 23, 233, 25, 57,
90403 /* 640 */ 194, 68, 69, 70, 71, 72, 73, 74, 75, 76,
90404 /* 650 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
90405 /* 660 */ 87, 88, 89, 90, 91, 92, 19, 150, 25, 165,
90406 /* 670 */ 23, 150, 233, 19, 150, 190, 191, 228, 174, 175,
90407 /* 680 */ 67, 222, 165, 224, 225, 150, 165, 150, 150, 165,
90408 /* 690 */ 23, 174, 175, 144, 145, 232, 49, 50, 174, 175,
90409 /* 700 */ 165, 115, 165, 165, 50, 22, 23, 241, 25, 174,
90410 /* 710 */ 175, 174, 175, 127, 193, 68, 69, 70, 71, 72,
90411 /* 720 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82,
90412 /* 730 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
90413 /* 740 */ 19, 150, 150, 165, 150, 24, 103, 23, 150, 150,
90414 /* 750 */ 67, 213, 174, 175, 97, 209, 165, 165, 104, 165,
90415 /* 760 */ 150, 150, 108, 165, 165, 174, 175, 23, 174, 175,
90416 /* 770 */ 49, 50, 115, 174, 175, 165, 165, 177, 111, 187,
90417 /* 780 */ 113, 114, 250, 251, 127, 174, 175, 206, 207, 68,
90418 /* 790 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
90419 /* 800 */ 79, 80, 150, 82, 83, 84, 85, 86, 87, 88,
90420 /* 810 */ 89, 90, 91, 92, 19, 150, 150, 165, 150, 111,
90421 /* 820 */ 182, 113, 114, 105, 106, 177, 174, 175, 25, 166,
90422 /* 830 */ 165, 165, 150, 165, 150, 111, 150, 113, 114, 174,
90423 /* 840 */ 175, 150, 174, 175, 49, 50, 128, 165, 135, 165,
90424 /* 850 */ 137, 165, 197, 187, 166, 111, 165, 113, 114, 204,
90425 /* 860 */ 174, 175, 177, 68, 69, 70, 71, 72, 73, 74,
90426 /* 870 */ 75, 76, 77, 78, 79, 80, 150, 82, 83, 84,
90427 /* 880 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 150,
90428 /* 890 */ 150, 165, 150, 205, 177, 213, 150, 213, 95, 177,
90429 /* 900 */ 174, 175, 129, 130, 165, 165, 23, 165, 25, 150,
90430 /* 910 */ 150, 165, 178, 174, 175, 150, 174, 175, 49, 50,
90431 /* 920 */ 174, 175, 119, 19, 165, 165, 50, 22, 23, 160,
90432 /* 930 */ 165, 27, 241, 193, 174, 175, 160, 68, 69, 70,
90433 /* 940 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
90434 /* 950 */ 150, 82, 83, 84, 85, 86, 87, 88, 89, 90,
90435 /* 960 */ 91, 92, 19, 194, 150, 165, 150, 150, 150, 160,
90436 /* 970 */ 194, 25, 67, 160, 174, 175, 217, 166, 95, 165,
90437 /* 980 */ 104, 165, 165, 165, 150, 245, 248, 249, 49, 50,
90438 /* 990 */ 174, 175, 49, 50, 23, 23, 25, 25, 242, 165,
90439 /* 1000 */ 199, 187, 119, 194, 187, 22, 23, 194, 174, 175,
90440 /* 1010 */ 71, 72, 69, 70, 71, 72, 73, 74, 75, 76,
90441 /* 1020 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
90442 /* 1030 */ 87, 88, 89, 90, 91, 92, 19, 98, 150, 165,
90443 /* 1040 */ 150, 150, 150, 19, 7, 8, 105, 106, 174, 175,
90444 /* 1050 */ 67, 27, 23, 165, 25, 165, 165, 165, 150, 150,
90445 /* 1060 */ 150, 150, 174, 175, 174, 175, 49, 50, 98, 242,
90446 /* 1070 */ 23, 125, 25, 165, 165, 165, 165, 209, 108, 97,
90447 /* 1080 */ 98, 209, 174, 175, 193, 174, 175, 70, 71, 72,
90448 /* 1090 */ 73, 74, 75, 76, 77, 78, 79, 80, 199, 82,
90449 /* 1100 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
90450 /* 1110 */ 19, 20, 150, 22, 160, 22, 149, 26, 27, 150,
90451 /* 1120 */ 23, 6, 25, 19, 20, 150, 22, 165, 37, 149,
90452 /* 1130 */ 26, 27, 151, 23, 165, 25, 174, 175, 151, 150,
90453 /* 1140 */ 165, 37, 13, 150, 150, 149, 149, 56, 194, 174,
90454 /* 1150 */ 175, 23, 25, 25, 165, 194, 150, 66, 165, 165,
90455 /* 1160 */ 56, 150, 159, 174, 175, 125, 150, 174, 175, 76,
90456 /* 1170 */ 66, 165, 218, 150, 122, 199, 165, 86, 87, 200,
90457 /* 1180 */ 150, 165, 123, 121, 93, 94, 95, 193, 165, 98,
90458 /* 1190 */ 86, 87, 88, 201, 240, 165, 124, 93, 94, 95,
90459 /* 1200 */ 202, 135, 98, 5, 174, 175, 115, 203, 10, 11,
90460 /* 1210 */ 12, 13, 14, 150, 157, 17, 193, 150, 227, 210,
90461 /* 1220 */ 129, 130, 131, 132, 133, 134, 150, 157, 165, 31,
90462 /* 1230 */ 117, 33, 165, 129, 130, 131, 132, 133, 134, 150,
90463 /* 1240 */ 42, 165, 19, 20, 104, 22, 150, 211, 210, 26,
90464 /* 1250 */ 27, 210, 150, 55, 165, 57, 193, 120, 104, 61,
90465 /* 1260 */ 37, 165, 64, 174, 175, 19, 20, 165, 22, 150,
90466 /* 1270 */ 174, 175, 26, 27, 176, 150, 174, 175, 47, 56,
90467 /* 1280 */ 211, 150, 150, 37, 165, 23, 23, 25, 25, 66,
90468 /* 1290 */ 165, 211, 150, 174, 175, 184, 165, 165, 176, 174,
90469 /* 1300 */ 175, 178, 56, 105, 106, 174, 175, 165, 110, 86,
90470 /* 1310 */ 87, 176, 66, 115, 103, 176, 93, 94, 95, 150,
90471 /* 1320 */ 23, 98, 25, 150, 22, 22, 128, 150, 150, 26,
90472 /* 1330 */ 27, 150, 86, 87, 165, 193, 150, 139, 165, 93,
90473 /* 1340 */ 94, 95, 165, 165, 98, 150, 165, 179, 92, 150,
90474 /* 1350 */ 150, 165, 129, 130, 131, 132, 133, 134, 184, 150,
90475 /* 1360 */ 165, 176, 193, 230, 165, 165, 193, 150, 150, 66,
90476 /* 1370 */ 176, 150, 150, 230, 165, 129, 130, 131, 132, 133,
90477 /* 1380 */ 134, 176, 165, 165, 150, 150, 165, 165, 150, 86,
90478 /* 1390 */ 87, 150, 150, 150, 150, 179, 18, 94, 45, 165,
90479 /* 1400 */ 165, 98, 157, 165, 150, 150, 165, 165, 165, 165,
90480 /* 1410 */ 157, 135, 68, 156, 156, 156, 189, 157, 157, 165,
90481 /* 1420 */ 165, 238, 156, 239, 157, 189, 22, 219, 199, 157,
90482 /* 1430 */ 18, 192, 129, 130, 131, 157, 199, 40, 219, 192,
90483 /* 1440 */ 192, 192, 157, 157, 243, 243, 38, 164, 180, 246,
90484 /* 1450 */ 180, 1, 15, 189, 23, 249, 252, 22, 117, 252,
90485 /* 1460 */ 117, 112, 117, 117, 117, 22, 11, 23, 23, 22,
90486 /* 1470 */ 22, 25, 23, 35, 23, 23, 35, 119, 25, 25,
90487 /* 1480 */ 22, 117, 23, 23, 27, 52, 22, 22, 52, 23,
90488 /* 1490 */ 22, 35, 29, 22, 52, 22, 102, 108, 19, 24,
90489 /* 1500 */ 39, 20, 104, 25, 138, 43, 104, 22, 5, 1,
90490 /* 1510 */ 117, 35, 107, 27, 126, 76, 76, 22, 118, 1,
90491 /* 1520 */ 16, 120, 53, 53, 118, 20, 59, 107, 22, 126,
90492 /* 1530 */ 23, 16, 23, 22, 127, 15, 140, 65, 3, 253,
90493 /* 1540 */ 4,
90494 };
90495 #define YY_SHIFT_USE_DFLT (-110)
90496 #define YY_SHIFT_MAX 417
90497 static const short yy_shift_ofst[] = {
90498 /* 0 */ 111, 1091, 1198, 1091, 1223, 1223, -2, 88, 88, -19,
90499 /* 10 */ 1223, 1223, 1223, 1223, 1223, 210, 465, 129, 1104, 1223,
90500 /* 20 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223,
90501 /* 30 */ 1223, 1223, 1246, 1223, 1223, 1223, 1223, 1223, 1223, 1223,
90502 /* 40 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223,
90503 /* 50 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223,
90504 /* 60 */ 1223, -49, 361, 465, 465, 154, 138, 138, -109, 55,
90505 /* 70 */ 203, 277, 351, 425, 499, 573, 647, 721, 795, 869,
90506 /* 80 */ 795, 795, 795, 795, 795, 795, 795, 795, 795, 795,
90507 /* 90 */ 795, 795, 795, 795, 795, 795, 795, 795, 943, 1017,
90508 /* 100 */ 1017, -69, -69, -69, -69, -1, -1, 57, 155, -44,
90509 /* 110 */ 465, 465, 465, 465, 465, 654, 205, 465, 465, 465,
90510 /* 120 */ 465, 465, 465, 465, 465, 465, 465, 465, 465, 465,
90511 /* 130 */ 465, 465, 465, 248, 154, -80, -110, -110, -110, 1303,
90512 /* 140 */ 131, 95, 291, 352, 458, 510, 582, 582, 465, 465,
90513 /* 150 */ 465, 465, 465, 465, 465, 465, 465, 465, 465, 465,
90514 /* 160 */ 465, 465, 465, 465, 465, 465, 465, 465, 465, 465,
90515 /* 170 */ 465, 465, 465, 465, 465, 465, 465, 465, 465, 465,
90516 /* 180 */ 613, 683, 601, 379, 379, 379, 657, 586, -109, -109,
90517 /* 190 */ -109, -110, -110, -110, 172, 172, 275, 160, 516, 667,
90518 /* 200 */ 724, 442, 744, 883, 60, 60, 612, 367, 236, 803,
90519 /* 210 */ 708, 708, 143, 718, 708, 708, 708, 708, 542, 426,
90520 /* 220 */ 438, 154, 773, 773, 713, 428, 428, 904, 428, 876,
90521 /* 230 */ 428, 154, 428, 154, 643, 1024, 946, 1024, 904, 904,
90522 /* 240 */ 946, 1115, 1115, 1115, 1115, 1129, 1129, 1127, -109, 1040,
90523 /* 250 */ 1052, 1059, 1062, 1072, 1066, 1113, 1113, 1140, 1137, 1140,
90524 /* 260 */ 1137, 1140, 1137, 1154, 1154, 1231, 1154, 1211, 1154, 1302,
90525 /* 270 */ 1256, 1256, 1231, 1154, 1154, 1154, 1302, 1378, 1113, 1378,
90526 /* 280 */ 1113, 1378, 1113, 1113, 1353, 1276, 1378, 1113, 1344, 1344,
90527 /* 290 */ 1404, 1040, 1113, 1412, 1412, 1412, 1412, 1040, 1344, 1404,
90528 /* 300 */ 1113, 1397, 1397, 1113, 1113, 1408, -110, -110, -110, -110,
90529 /* 310 */ -110, -110, 939, 46, 547, 905, 983, 971, 972, 970,
90530 /* 320 */ 1037, 941, 982, 1029, 1047, 1097, 1110, 1128, 1262, 1263,
90531 /* 330 */ 1093, 1297, 1450, 1437, 1431, 1435, 1341, 1343, 1345, 1346,
90532 /* 340 */ 1347, 1349, 1443, 1444, 1445, 1447, 1455, 1448, 1449, 1446,
90533 /* 350 */ 1451, 1452, 1453, 1438, 1454, 1441, 1453, 1358, 1458, 1456,
90534 /* 360 */ 1457, 1364, 1459, 1460, 1461, 1433, 1464, 1463, 1436, 1465,
90535 /* 370 */ 1466, 1468, 1471, 1442, 1473, 1394, 1389, 1479, 1481, 1475,
90536 /* 380 */ 1398, 1462, 1467, 1469, 1478, 1470, 1366, 1402, 1485, 1503,
90537 /* 390 */ 1508, 1393, 1476, 1486, 1405, 1439, 1440, 1388, 1495, 1400,
90538 /* 400 */ 1518, 1504, 1401, 1505, 1406, 1420, 1403, 1506, 1407, 1507,
90539 /* 410 */ 1509, 1515, 1472, 1520, 1396, 1511, 1535, 1536,
90540 };
90541 #define YY_REDUCE_USE_DFLT (-197)
90542 #define YY_REDUCE_MAX 311
90543 static const short yy_reduce_ofst[] = {
90544 /* 0 */ -141, 90, 16, 147, -55, 21, 148, 149, 158, 240,
90545 /* 10 */ 223, 237, 242, 303, 307, 164, 370, 171, 369, 376,
90546 /* 20 */ 380, 443, 450, 504, 517, 524, 535, 537, 578, 591,
90547 /* 30 */ 594, 599, 611, 652, 665, 668, 686, 726, 739, 742,
90548 /* 40 */ 746, 760, 800, 816, 834, 874, 888, 890, 908, 911,
90549 /* 50 */ 962, 975, 989, 993, 1030, 1089, 1096, 1102, 1119, 1125,
90550 /* 60 */ 1131, -196, 954, 740, 396, 169, -68, 463, 405, 459,
90551 /* 70 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459,
90552 /* 80 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459,
90553 /* 90 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459,
90554 /* 100 */ 459, 459, 459, 459, 459, 459, 459, -21, 459, 459,
90555 /* 110 */ 538, 375, 592, 666, 814, 6, 222, 521, 682, 817,
90556 /* 120 */ 356, 244, 466, 684, 691, 891, 994, 1023, 1063, 1142,
90557 /* 130 */ 1169, 759, 1173, 459, -89, 459, 459, 459, 459, 285,
90558 /* 140 */ 76, 430, 598, 610, 765, 818, 423, 485, 892, 909,
90559 /* 150 */ 910, 969, 1006, 818, 1011, 1016, 1067, 1076, 1132, 1177,
90560 /* 160 */ 1178, 1181, 1186, 1195, 1199, 1200, 1209, 1217, 1218, 1221,
90561 /* 170 */ 1222, 1234, 1235, 1238, 1241, 1242, 1243, 1244, 1254, 1255,
90562 /* 180 */ 532, 532, 549, 178, 324, 688, 446, 769, 776, 809,
90563 /* 190 */ 813, 655, 581, 738, -74, -58, -50, -17, -23, -23,
90564 /* 200 */ -23, 63, -23, 29, 68, 121, 183, 146, 225, 29,
90565 /* 210 */ -23, -23, 196, 177, -23, -23, -23, -23, 255, 328,
90566 /* 220 */ 335, 381, 404, 439, 449, 600, 648, 546, 685, 638,
90567 /* 230 */ 717, 663, 722, 811, 734, 756, 801, 827, 868, 872,
90568 /* 240 */ 899, 967, 980, 996, 997, 981, 987, 1003, 961, 976,
90569 /* 250 */ 979, 992, 998, 1004, 991, 1057, 1070, 1009, 1036, 1038,
90570 /* 260 */ 1069, 1041, 1080, 1098, 1122, 1111, 1135, 1123, 1139, 1168,
90571 /* 270 */ 1133, 1143, 1174, 1185, 1194, 1205, 1216, 1257, 1245, 1258,
90572 /* 280 */ 1253, 1259, 1260, 1261, 1183, 1184, 1266, 1267, 1227, 1236,
90573 /* 290 */ 1208, 1229, 1272, 1239, 1247, 1248, 1249, 1237, 1264, 1219,
90574 /* 300 */ 1278, 1201, 1202, 1285, 1286, 1203, 1283, 1268, 1270, 1206,
90575 /* 310 */ 1204, 1207,
90576 };
90577 static const YYACTIONTYPE yy_default[] = {
90578 /* 0 */ 634, 869, 958, 958, 869, 958, 958, 898, 898, 757,
90579 /* 10 */ 867, 958, 958, 958, 958, 958, 958, 932, 958, 958,
90580 /* 20 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
90581 /* 30 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
90582 /* 40 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
90583 /* 50 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
90584 /* 60 */ 958, 841, 958, 958, 958, 673, 898, 898, 761, 792,
90585 /* 70 */ 958, 958, 958, 958, 958, 958, 958, 958, 793, 958,
90586 /* 80 */ 871, 866, 862, 864, 863, 870, 794, 783, 790, 797,
90587 /* 90 */ 772, 911, 799, 800, 806, 807, 933, 931, 829, 828,
90588 /* 100 */ 847, 831, 845, 853, 846, 830, 840, 665, 832, 833,
90589 /* 110 */ 958, 958, 958, 958, 958, 726, 660, 958, 958, 958,
90590 /* 120 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
90591 /* 130 */ 958, 958, 958, 834, 958, 835, 848, 849, 850, 958,
90592 /* 140 */ 958, 958, 958, 958, 958, 958, 958, 958, 640, 958,
90593 /* 150 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
90594 /* 160 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
90595 /* 170 */ 958, 958, 958, 958, 958, 882, 958, 936, 938, 958,
90596 /* 180 */ 958, 958, 634, 757, 757, 757, 958, 958, 958, 958,
90597 /* 190 */ 958, 751, 761, 950, 958, 958, 717, 958, 958, 958,
90598 /* 200 */ 958, 958, 958, 958, 958, 958, 642, 749, 675, 759,
90599 /* 210 */ 662, 738, 904, 958, 923, 921, 740, 802, 958, 749,
90600 /* 220 */ 758, 958, 958, 958, 865, 786, 786, 774, 786, 696,
90601 /* 230 */ 786, 958, 786, 958, 699, 916, 796, 916, 774, 774,
90602 /* 240 */ 796, 639, 639, 639, 639, 650, 650, 716, 958, 796,
90603 /* 250 */ 787, 789, 779, 791, 958, 765, 765, 773, 778, 773,
90604 /* 260 */ 778, 773, 778, 728, 728, 713, 728, 699, 728, 875,
90605 /* 270 */ 879, 879, 713, 728, 728, 728, 875, 657, 765, 657,
90606 /* 280 */ 765, 657, 765, 765, 908, 910, 657, 765, 730, 730,
90607 /* 290 */ 808, 796, 765, 737, 737, 737, 737, 796, 730, 808,
90608 /* 300 */ 765, 935, 935, 765, 765, 943, 683, 701, 701, 950,
90609 /* 310 */ 955, 955, 958, 958, 958, 958, 958, 958, 958, 958,
90610 /* 320 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
90611 /* 330 */ 884, 958, 958, 648, 958, 667, 815, 820, 816, 958,
90612 /* 340 */ 817, 743, 958, 958, 958, 958, 958, 958, 958, 958,
90613 /* 350 */ 958, 958, 868, 958, 780, 958, 788, 958, 958, 958,
90614 /* 360 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
90615 /* 370 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
90616 /* 380 */ 958, 958, 958, 906, 907, 958, 958, 958, 958, 958,
90617 /* 390 */ 958, 914, 958, 958, 958, 958, 958, 958, 958, 958,
90618 /* 400 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
90619 /* 410 */ 958, 958, 942, 958, 958, 945, 635, 958, 630, 632,
90620 /* 420 */ 633, 637, 638, 641, 667, 668, 670, 671, 672, 643,
90621 /* 430 */ 644, 645, 646, 647, 649, 653, 651, 652, 654, 661,
90622 /* 440 */ 663, 682, 684, 686, 747, 748, 812, 741, 742, 746,
90623 /* 450 */ 669, 823, 814, 818, 819, 821, 822, 836, 837, 839,
90624 /* 460 */ 844, 852, 855, 838, 843, 851, 854, 744, 745, 858,
90625 /* 470 */ 676, 677, 680, 681, 894, 896, 895, 897, 679, 678,
90626 /* 480 */ 824, 827, 860, 861, 924, 925, 926, 927, 928, 856,
90627 /* 490 */ 766, 859, 842, 781, 784, 785, 782, 750, 760, 768,
90628 /* 500 */ 769, 770, 771, 755, 756, 762, 777, 810, 811, 775,
90629 /* 510 */ 776, 763, 764, 752, 753, 754, 857, 813, 825, 826,
90630 /* 520 */ 687, 688, 820, 689, 690, 691, 729, 732, 733, 734,
90631 /* 530 */ 692, 711, 714, 715, 693, 700, 694, 695, 702, 703,
90632 /* 540 */ 704, 706, 707, 708, 709, 710, 705, 876, 877, 880,
90633 /* 550 */ 878, 697, 698, 712, 685, 674, 666, 718, 721, 722,
90634 /* 560 */ 723, 724, 725, 727, 719, 720, 664, 655, 658, 767,
90635 /* 570 */ 900, 909, 905, 901, 902, 903, 659, 872, 873, 731,
90636 /* 580 */ 804, 805, 899, 912, 915, 917, 918, 919, 809, 920,
90637 /* 590 */ 922, 913, 947, 656, 735, 736, 739, 881, 929, 795,
@@ -88898,10 +90680,11 @@
90680 0, /* AS => nothing */
90681 0, /* COMMA => nothing */
90682 0, /* ID => nothing */
90683 0, /* INDEXED => nothing */
90684 26, /* ABORT => ID */
90685 26, /* ACTION => ID */
90686 26, /* AFTER => ID */
90687 26, /* ANALYZE => ID */
90688 26, /* ASC => ID */
90689 26, /* ATTACH => ID */
90690 26, /* BEFORE => ID */
@@ -88919,10 +90702,11 @@
90702 26, /* IGNORE => ID */
90703 26, /* INITIALLY => ID */
90704 26, /* INSTEAD => ID */
90705 26, /* LIKE_KW => ID */
90706 26, /* MATCH => ID */
90707 26, /* NO => ID */
90708 26, /* KEY => ID */
90709 26, /* OF => ID */
90710 26, /* OFFSET => ID */
90711 26, /* PRAGMA => ID */
90712 26, /* RAISE => ID */
@@ -89018,36 +90802,36 @@
90802 "IMMEDIATE", "EXCLUSIVE", "COMMIT", "END",
90803 "ROLLBACK", "SAVEPOINT", "RELEASE", "TO",
90804 "TABLE", "CREATE", "IF", "NOT",
90805 "EXISTS", "TEMP", "LP", "RP",
90806 "AS", "COMMA", "ID", "INDEXED",
90807 "ABORT", "ACTION", "AFTER", "ANALYZE",
90808 "ASC", "ATTACH", "BEFORE", "BY",
90809 "CASCADE", "CAST", "COLUMNKW", "CONFLICT",
90810 "DATABASE", "DESC", "DETACH", "EACH",
90811 "FAIL", "FOR", "IGNORE", "INITIALLY",
90812 "INSTEAD", "LIKE_KW", "MATCH", "NO",
90813 "KEY", "OF", "OFFSET", "PRAGMA",
90814 "RAISE", "REPLACE", "RESTRICT", "ROW",
90815 "TRIGGER", "VACUUM", "VIEW", "VIRTUAL",
90816 "REINDEX", "RENAME", "CTIME_KW", "ANY",
90817 "OR", "AND", "IS", "BETWEEN",
90818 "IN", "ISNULL", "NOTNULL", "NE",
90819 "EQ", "GT", "LE", "LT",
90820 "GE", "ESCAPE", "BITAND", "BITOR",
90821 "LSHIFT", "RSHIFT", "PLUS", "MINUS",
90822 "STAR", "SLASH", "REM", "CONCAT",
90823 "COLLATE", "BITNOT", "STRING", "JOIN_KW",
90824 "CONSTRAINT", "DEFAULT", "NULL", "PRIMARY",
90825 "UNIQUE", "CHECK", "REFERENCES", "AUTOINCR",
90826 "ON", "DELETE", "UPDATE", "SET",
90827 "DEFERRABLE", "FOREIGN", "DROP", "UNION",
90828 "ALL", "EXCEPT", "INTERSECT", "SELECT",
90829 "DISTINCT", "DOT", "FROM", "JOIN",
90830 "USING", "ORDER", "GROUP", "HAVING",
90831 "LIMIT", "WHERE", "INTO", "VALUES",
90832 "INSERT", "INTEGER", "FLOAT", "BLOB",
90833 "REGISTER", "VARIABLE", "CASE", "WHEN",
90834 "THEN", "ELSE", "INDEX", "ALTER",
90835 "ADD", "error", "input", "cmdlist",
90836 "ecmd", "explain", "cmdx", "cmd",
90837 "transtype", "trans_opt", "nm", "savepoint_opt",
@@ -89159,15 +90943,15 @@
90943 /* 72 */ "refargs ::=",
90944 /* 73 */ "refargs ::= refargs refarg",
90945 /* 74 */ "refarg ::= MATCH nm",
90946 /* 75 */ "refarg ::= ON DELETE refact",
90947 /* 76 */ "refarg ::= ON UPDATE refact",
90948 /* 77 */ "refact ::= SET NULL",
90949 /* 78 */ "refact ::= SET DEFAULT",
90950 /* 79 */ "refact ::= CASCADE",
90951 /* 80 */ "refact ::= RESTRICT",
90952 /* 81 */ "refact ::= NO ACTION",
90953 /* 82 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
90954 /* 83 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
90955 /* 84 */ "init_deferred_pred_opt ::=",
90956 /* 85 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
90957 /* 86 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
@@ -89297,13 +91081,13 @@
91081 /* 210 */ "likeop ::= NOT MATCH",
91082 /* 211 */ "escape ::= ESCAPE expr",
91083 /* 212 */ "escape ::=",
91084 /* 213 */ "expr ::= expr likeop expr escape",
91085 /* 214 */ "expr ::= expr ISNULL|NOTNULL",
91086 /* 215 */ "expr ::= expr NOT NULL",
91087 /* 216 */ "expr ::= expr IS expr",
91088 /* 217 */ "expr ::= expr IS NOT expr",
91089 /* 218 */ "expr ::= NOT expr",
91090 /* 219 */ "expr ::= BITNOT expr",
91091 /* 220 */ "expr ::= MINUS expr",
91092 /* 221 */ "expr ::= PLUS expr",
91093 /* 222 */ "between_op ::= BETWEEN",
@@ -89869,15 +91653,15 @@
91653 { 180, 0 },
91654 { 180, 2 },
91655 { 182, 2 },
91656 { 182, 3 },
91657 { 182, 3 },
 
91658 { 183, 2 },
91659 { 183, 2 },
91660 { 183, 1 },
91661 { 183, 1 },
91662 { 183, 2 },
91663 { 181, 3 },
91664 { 181, 2 },
91665 { 184, 0 },
91666 { 184, 2 },
91667 { 184, 2 },
@@ -90236,10 +92020,11 @@
92020 }
92021 break;
92022 case 28: /* ifnotexists ::= */
92023 case 31: /* temp ::= */ yytestcase(yyruleno==31);
92024 case 70: /* autoinc ::= */ yytestcase(yyruleno==70);
92025 case 82: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==82);
92026 case 84: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==84);
92027 case 86: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==86);
92028 case 97: /* defer_subclause_opt ::= */ yytestcase(yyruleno==97);
92029 case 108: /* ifexists ::= */ yytestcase(yyruleno==108);
92030 case 119: /* distinct ::= ALL */ yytestcase(yyruleno==119);
@@ -90366,11 +92151,11 @@
92151 break;
92152 case 69: /* ccons ::= COLLATE ids */
92153 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
92154 break;
92155 case 72: /* refargs ::= */
92156 { yygotominor.yy328 = OE_None * 0x000101; }
92157 break;
92158 case 73: /* refargs ::= refargs refarg */
92159 { yygotominor.yy328 = (yymsp[-1].minor.yy328 & ~yymsp[0].minor.yy429.mask) | yymsp[0].minor.yy429.value; }
92160 break;
92161 case 74: /* refarg ::= MATCH nm */
@@ -90380,27 +92165,26 @@
92165 { yygotominor.yy429.value = yymsp[0].minor.yy328; yygotominor.yy429.mask = 0x0000ff; }
92166 break;
92167 case 76: /* refarg ::= ON UPDATE refact */
92168 { yygotominor.yy429.value = yymsp[0].minor.yy328<<8; yygotominor.yy429.mask = 0x00ff00; }
92169 break;
92170 case 77: /* refact ::= SET NULL */
 
 
 
92171 { yygotominor.yy328 = OE_SetNull; }
92172 break;
92173 case 78: /* refact ::= SET DEFAULT */
92174 { yygotominor.yy328 = OE_SetDflt; }
92175 break;
92176 case 79: /* refact ::= CASCADE */
92177 { yygotominor.yy328 = OE_Cascade; }
92178 break;
92179 case 80: /* refact ::= RESTRICT */
92180 { yygotominor.yy328 = OE_Restrict; }
92181 break;
92182 case 81: /* refact ::= NO ACTION */
92183 { yygotominor.yy328 = OE_None; }
92184 break;
92185 case 83: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
92186 case 98: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==98);
92187 case 100: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==100);
92188 case 103: /* resolvetype ::= raisetype */ yytestcase(yyruleno==103);
92189 {yygotominor.yy328 = yymsp[0].minor.yy328;}
92190 break;
@@ -90830,18 +92614,28 @@
92614 }
92615 break;
92616 case 214: /* expr ::= expr ISNULL|NOTNULL */
92617 {spanUnaryPostfix(&yygotominor.yy346,pParse,yymsp[0].major,&yymsp[-1].minor.yy346,&yymsp[0].minor.yy0);}
92618 break;
92619 case 215: /* expr ::= expr NOT NULL */
 
 
 
92620 {spanUnaryPostfix(&yygotominor.yy346,pParse,TK_NOTNULL,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy0);}
92621 break;
92622 case 216: /* expr ::= expr IS expr */
92623 {
92624 spanBinaryExpr(&yygotominor.yy346,pParse,TK_IS,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy346);
92625 if( pParse->db->mallocFailed==0 && yymsp[0].minor.yy346.pExpr->op==TK_NULL ){
92626 yygotominor.yy346.pExpr->op = TK_ISNULL;
92627 }
92628 }
92629 break;
92630 case 217: /* expr ::= expr IS NOT expr */
92631 {
92632 spanBinaryExpr(&yygotominor.yy346,pParse,TK_ISNOT,&yymsp[-3].minor.yy346,&yymsp[0].minor.yy346);
92633 if( pParse->db->mallocFailed==0 && yymsp[0].minor.yy346.pExpr->op==TK_NULL ){
92634 yygotominor.yy346.pExpr->op = TK_NOTNULL;
92635 }
92636 }
92637 break;
92638 case 218: /* expr ::= NOT expr */
92639 case 219: /* expr ::= BITNOT expr */ yytestcase(yyruleno==219);
92640 {spanUnaryPrefix(&yygotominor.yy346,pParse,yymsp[-1].major,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
92641 break;
@@ -91583,13 +93377,13 @@
93377 ** might be implemented more directly using a hand-written hash table.
93378 ** But by using this automatically generated code, the size of the code
93379 ** is substantially reduced. This is important for embedded applications
93380 ** on platforms with limited memory.
93381 */
93382 /* Hash score: 175 */
93383 static int keywordCode(const char *z, int n){
93384 /* zText[] encodes 811 bytes of keywords in 541 bytes */
93385 /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
93386 /* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */
93387 /* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */
93388 /* UNIQUERYATTACHAVINGROUPDATEBEGINNERELEASEBETWEENOTNULLIKE */
93389 /* CASCADELETECASECOLLATECREATECURRENT_DATEDETACHIMMEDIATEJOIN */
@@ -91629,82 +93423,83 @@
93423 'T','R','I','C','T','O','U','T','E','R','I','G','H','T','R','O','L','L',
93424 'B','A','C','K','R','O','W','U','N','I','O','N','U','S','I','N','G','V',
93425 'A','C','U','U','M','V','I','E','W','I','N','I','T','I','A','L','L','Y',
93426 };
93427 static const unsigned char aHash[127] = {
93428 72, 101, 114, 70, 0, 44, 0, 0, 78, 0, 73, 0, 0,
93429 42, 12, 74, 15, 0, 113, 81, 50, 108, 0, 19, 0, 0,
93430 118, 0, 116, 111, 0, 22, 89, 0, 9, 0, 0, 66, 67,
93431 0, 65, 6, 0, 48, 86, 98, 0, 115, 97, 0, 0, 45,
93432 0, 99, 24, 0, 17, 0, 119, 49, 23, 0, 5, 106, 25,
93433 92, 0, 0, 121, 102, 56, 120, 53, 28, 51, 0, 87, 0,
93434 96, 26, 0, 95, 0, 0, 0, 91, 88, 93, 84, 105, 14,
93435 39, 104, 0, 77, 0, 18, 85, 107, 32, 0, 117, 76, 109,
93436 59, 46, 80, 0, 0, 90, 40, 0, 112, 0, 36, 0, 0,
93437 29, 0, 82, 58, 60, 0, 20, 57, 0, 52,
93438 };
93439 static const unsigned char aNext[121] = {
93440 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
93441 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
93442 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
93443 0, 0, 0, 0, 0, 33, 21, 0, 0, 0, 43, 3, 47,
93444 0, 0, 0, 0, 30, 54, 0, 0, 38, 0, 0, 0, 1,
93445 62, 0, 0, 63, 0, 41, 0, 0, 0, 0, 0, 0, 0,
93446 61, 0, 0, 0, 0, 31, 55, 16, 34, 10, 0, 0, 0,
93447 0, 0, 0, 0, 11, 68, 75, 0, 8, 0, 100, 94, 0,
93448 103, 0, 83, 0, 71, 0, 0, 110, 27, 37, 69, 79, 0,
93449 35, 64, 0, 0,
93450 };
93451 static const unsigned char aLen[121] = {
93452 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
93453 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6,
93454 11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10,
93455 4, 6, 2, 3, 4, 9, 2, 6, 5, 6, 6, 5, 6,
93456 5, 5, 7, 7, 7, 2, 3, 4, 4, 7, 3, 6, 4,
93457 7, 6, 12, 6, 9, 4, 6, 5, 4, 7, 6, 5, 6,
93458 7, 5, 4, 5, 6, 5, 7, 3, 7, 13, 2, 2, 4,
93459 6, 6, 8, 5, 17, 12, 7, 8, 8, 2, 4, 4, 4,
93460 4, 4, 2, 2, 6, 5, 8, 5, 5, 8, 3, 5, 5,
93461 6, 4, 9, 3,
93462 };
93463 static const unsigned short int aOffset[121] = {
93464 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
93465 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
93466 86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152,
93467 159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 189, 194, 197,
93468 203, 206, 210, 217, 223, 223, 223, 226, 229, 233, 234, 238, 244,
93469 248, 255, 261, 273, 279, 288, 290, 296, 301, 303, 310, 315, 320,
93470 326, 332, 337, 341, 344, 350, 354, 361, 363, 370, 372, 374, 383,
93471 387, 393, 399, 407, 412, 412, 428, 435, 442, 443, 450, 454, 458,
93472 462, 466, 469, 471, 473, 479, 483, 491, 495, 500, 508, 511, 516,
93473 521, 527, 531, 536,
93474 };
93475 static const unsigned char aCode[121] = {
93476 TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
93477 TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
93478 TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
93479 TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
93480 TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
93481 TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW,
93482 TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT,
93483 TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO,
93484 TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP,
93485 TK_OR, TK_UNIQUE, TK_QUERY, TK_ATTACH, TK_HAVING,
93486 TK_GROUP, TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RELEASE,
93487 TK_BETWEEN, TK_NOTNULL, TK_NO, TK_NOT, TK_NULL,
93488 TK_LIKE_KW, TK_CASCADE, TK_ASC, TK_DELETE, TK_CASE,
93489 TK_COLLATE, TK_CREATE, TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE,
93490 TK_JOIN, TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE,
93491 TK_PRAGMA, TK_ABORT, TK_VALUES, TK_VIRTUAL, TK_LIMIT,
93492 TK_WHEN, TK_WHERE, TK_RENAME, TK_AFTER, TK_REPLACE,
93493 TK_AND, TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN,
93494 TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW,
93495 TK_CTIME_KW, TK_CTIME_KW, TK_PRIMARY, TK_DEFERRED, TK_DISTINCT,
93496 TK_IS, TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW,
93497 TK_LIKE_KW, TK_BY, TK_IF, TK_ISNULL, TK_ORDER,
93498 TK_RESTRICT, TK_JOIN_KW, TK_JOIN_KW, TK_ROLLBACK, TK_ROW,
93499 TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_INITIALLY,
93500 TK_ALL,
93501 };
93502 int h, i;
93503 if( n<2 ) return TK_ID;
93504 h = ((charMap(z[0])*4) ^
93505 (charMap(z[n-1])*3) ^
@@ -91736,102 +93531,104 @@
93531 testcase( i==22 ); /* END */
93532 testcase( i==23 ); /* DEFERRABLE */
93533 testcase( i==24 ); /* ELSE */
93534 testcase( i==25 ); /* EXCEPT */
93535 testcase( i==26 ); /* TRANSACTION */
93536 testcase( i==27 ); /* ACTION */
93537 testcase( i==28 ); /* ON */
93538 testcase( i==29 ); /* NATURAL */
93539 testcase( i==30 ); /* ALTER */
93540 testcase( i==31 ); /* RAISE */
93541 testcase( i==32 ); /* EXCLUSIVE */
93542 testcase( i==33 ); /* EXISTS */
93543 testcase( i==34 ); /* SAVEPOINT */
93544 testcase( i==35 ); /* INTERSECT */
93545 testcase( i==36 ); /* TRIGGER */
93546 testcase( i==37 ); /* REFERENCES */
93547 testcase( i==38 ); /* CONSTRAINT */
93548 testcase( i==39 ); /* INTO */
93549 testcase( i==40 ); /* OFFSET */
93550 testcase( i==41 ); /* OF */
93551 testcase( i==42 ); /* SET */
93552 testcase( i==43 ); /* TEMP */
93553 testcase( i==44 ); /* TEMPORARY */
93554 testcase( i==45 ); /* OR */
93555 testcase( i==46 ); /* UNIQUE */
93556 testcase( i==47 ); /* QUERY */
93557 testcase( i==48 ); /* ATTACH */
93558 testcase( i==49 ); /* HAVING */
93559 testcase( i==50 ); /* GROUP */
93560 testcase( i==51 ); /* UPDATE */
93561 testcase( i==52 ); /* BEGIN */
93562 testcase( i==53 ); /* INNER */
93563 testcase( i==54 ); /* RELEASE */
93564 testcase( i==55 ); /* BETWEEN */
93565 testcase( i==56 ); /* NOTNULL */
93566 testcase( i==57 ); /* NO */
93567 testcase( i==58 ); /* NOT */
93568 testcase( i==59 ); /* NULL */
93569 testcase( i==60 ); /* LIKE */
93570 testcase( i==61 ); /* CASCADE */
93571 testcase( i==62 ); /* ASC */
93572 testcase( i==63 ); /* DELETE */
93573 testcase( i==64 ); /* CASE */
93574 testcase( i==65 ); /* COLLATE */
93575 testcase( i==66 ); /* CREATE */
93576 testcase( i==67 ); /* CURRENT_DATE */
93577 testcase( i==68 ); /* DETACH */
93578 testcase( i==69 ); /* IMMEDIATE */
93579 testcase( i==70 ); /* JOIN */
93580 testcase( i==71 ); /* INSERT */
93581 testcase( i==72 ); /* MATCH */
93582 testcase( i==73 ); /* PLAN */
93583 testcase( i==74 ); /* ANALYZE */
93584 testcase( i==75 ); /* PRAGMA */
93585 testcase( i==76 ); /* ABORT */
93586 testcase( i==77 ); /* VALUES */
93587 testcase( i==78 ); /* VIRTUAL */
93588 testcase( i==79 ); /* LIMIT */
93589 testcase( i==80 ); /* WHEN */
93590 testcase( i==81 ); /* WHERE */
93591 testcase( i==82 ); /* RENAME */
93592 testcase( i==83 ); /* AFTER */
93593 testcase( i==84 ); /* REPLACE */
93594 testcase( i==85 ); /* AND */
93595 testcase( i==86 ); /* DEFAULT */
93596 testcase( i==87 ); /* AUTOINCREMENT */
93597 testcase( i==88 ); /* TO */
93598 testcase( i==89 ); /* IN */
93599 testcase( i==90 ); /* CAST */
93600 testcase( i==91 ); /* COLUMN */
93601 testcase( i==92 ); /* COMMIT */
93602 testcase( i==93 ); /* CONFLICT */
93603 testcase( i==94 ); /* CROSS */
93604 testcase( i==95 ); /* CURRENT_TIMESTAMP */
93605 testcase( i==96 ); /* CURRENT_TIME */
93606 testcase( i==97 ); /* PRIMARY */
93607 testcase( i==98 ); /* DEFERRED */
93608 testcase( i==99 ); /* DISTINCT */
93609 testcase( i==100 ); /* IS */
93610 testcase( i==101 ); /* DROP */
93611 testcase( i==102 ); /* FAIL */
93612 testcase( i==103 ); /* FROM */
93613 testcase( i==104 ); /* FULL */
93614 testcase( i==105 ); /* GLOB */
93615 testcase( i==106 ); /* BY */
93616 testcase( i==107 ); /* IF */
93617 testcase( i==108 ); /* ISNULL */
93618 testcase( i==109 ); /* ORDER */
93619 testcase( i==110 ); /* RESTRICT */
93620 testcase( i==111 ); /* OUTER */
93621 testcase( i==112 ); /* RIGHT */
93622 testcase( i==113 ); /* ROLLBACK */
93623 testcase( i==114 ); /* ROW */
93624 testcase( i==115 ); /* UNION */
93625 testcase( i==116 ); /* USING */
93626 testcase( i==117 ); /* VACUUM */
93627 testcase( i==118 ); /* VIEW */
93628 testcase( i==119 ); /* INITIALLY */
93629 testcase( i==120 ); /* ALL */
93630 return aCode[i];
93631 }
93632 }
93633 return TK_ID;
93634 }
@@ -93408,10 +95205,13 @@
95205
95206 if( db->flags&SQLITE_InternChanges ){
95207 sqlite3ExpirePreparedStatements(db);
95208 sqlite3ResetInternalSchema(db, 0);
95209 }
95210
95211 /* Any deferred constraint violations have now been resolved. */
95212 db->nDeferredCons = 0;
95213
95214 /* If one has been configured, invoke the rollback-hook callback */
95215 if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){
95216 db->xRollbackCallback(db->pRollbackArg);
95217 }
@@ -106670,22 +108470,22 @@
108470 ** here is the LinearPickSeeds algorithm from Gutman[1984]. The
108471 ** indices of the two seed cells in the array are stored in local
108472 ** variables iLeftSeek and iRightSeed.
108473 */
108474 for(i=0; i<pRtree->nDim; i++){
108475 float x1 = DCOORD(aCell[0].aCoord[i*2]);
108476 float x2 = DCOORD(aCell[0].aCoord[i*2+1]);
108477 float x3 = x1;
108478 float x4 = x2;
108479 int jj;
108480
108481 int iCellLeft = 0;
108482 int iCellRight = 0;
108483
108484 for(jj=1; jj<nCell; jj++){
108485 float left = DCOORD(aCell[jj].aCoord[i*2]);
108486 float right = DCOORD(aCell[jj].aCoord[i*2+1]);
108487
108488 if( left<x1 ) x1 = left;
108489 if( right>x4 ) x4 = right;
108490 if( left>x3 ){
108491 x3 = left;
@@ -107039,10 +108839,13 @@
108839 int iRightSeed = 1;
108840 int *aiUsed;
108841 int i;
108842
108843 aiUsed = sqlite3_malloc(sizeof(int)*nCell);
108844 if( !aiUsed ){
108845 return SQLITE_NOMEM;
108846 }
108847 memset(aiUsed, 0, sizeof(int)*nCell);
108848
108849 PickSeeds(pRtree, aCell, nCell, &iLeftSeed, &iRightSeed);
108850
108851 memcpy(pBboxLeft, &aCell[iLeftSeed], sizeof(RtreeCell));
108852
+11 -7
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -117,13 +117,13 @@
117117
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
118118
** [sqlite_version()] and [sqlite_source_id()].
119119
**
120120
** Requirements: [H10011] [H10014]
121121
*/
122
-#define SQLITE_VERSION "3.6.18"
123
-#define SQLITE_VERSION_NUMBER 3006018
124
-#define SQLITE_SOURCE_ID "2009-09-11 14:05:07 b084828a771ec40be85f07c590ca99de4f6c24ee"
122
+#define SQLITE_VERSION "3.6.19"
123
+#define SQLITE_VERSION_NUMBER 3006019
124
+#define SQLITE_SOURCE_ID "2009-10-13 15:42:49 f894ebf86d6bafcd1461f104f5f677b3b6a3aa1a"
125125
126126
/*
127127
** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
128128
** KEYWORDS: sqlite3_version
129129
**
@@ -1314,12 +1314,13 @@
13141314
** This function returns the number of database rows that were changed
13151315
** or inserted or deleted by the most recently completed SQL statement
13161316
** on the [database connection] specified by the first parameter.
13171317
** Only changes that are directly specified by the [INSERT], [UPDATE],
13181318
** or [DELETE] statement are counted. Auxiliary changes caused by
1319
-** triggers are not counted. Use the [sqlite3_total_changes()] function
1320
-** to find the total number of changes including changes caused by triggers.
1319
+** triggers or [foreign key actions] are not counted. Use the
1320
+** [sqlite3_total_changes()] function to find the total number of changes
1321
+** including changes caused by triggers and foreign key actions.
13211322
**
13221323
** Changes to a view that are simulated by an [INSTEAD OF trigger]
13231324
** are not counted. Only real table changes are counted.
13241325
**
13251326
** A "row change" is a change to a single row of a single table
@@ -1367,12 +1368,12 @@
13671368
/*
13681369
** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600>
13691370
**
13701371
** This function returns the number of row changes caused by [INSERT],
13711372
** [UPDATE] or [DELETE] statements since the [database connection] was opened.
1372
-** The count includes all changes from all
1373
-** [CREATE TRIGGER | trigger] contexts. However,
1373
+** The count includes all changes from all [CREATE TRIGGER | trigger]
1374
+** contexts and changes made by [foreign key actions]. However,
13741375
** the count does not include changes used to implement [REPLACE] constraints,
13751376
** do rollbacks or ABORT processing, or [DROP TABLE] processing. The
13761377
** count does not include rows of views that fire an [INSTEAD OF trigger],
13771378
** though if the INSTEAD OF trigger makes changes of its own, those changes
13781379
** are counted.
@@ -4509,10 +4510,13 @@
45094510
** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
45104511
** </pre> {END}
45114512
**
45124513
** If the flags parameter is non-zero, then the BLOB is opened for read
45134514
** and write access. If it is zero, the BLOB is opened for read access.
4515
+** It is not possible to open a column that is part of an index or primary
4516
+** key for writing. ^If [foreign key constraints] are enabled, it is
4517
+** not possible to open a column that is part of a [child key] for writing.
45144518
**
45154519
** Note that the database name is not the filename that contains
45164520
** the database but rather the symbolic name of the database that
45174521
** is assigned when the database is connected using [ATTACH].
45184522
** For the main database file, the database name is "main".
45194523
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -117,13 +117,13 @@
117 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
118 ** [sqlite_version()] and [sqlite_source_id()].
119 **
120 ** Requirements: [H10011] [H10014]
121 */
122 #define SQLITE_VERSION "3.6.18"
123 #define SQLITE_VERSION_NUMBER 3006018
124 #define SQLITE_SOURCE_ID "2009-09-11 14:05:07 b084828a771ec40be85f07c590ca99de4f6c24ee"
125
126 /*
127 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
128 ** KEYWORDS: sqlite3_version
129 **
@@ -1314,12 +1314,13 @@
1314 ** This function returns the number of database rows that were changed
1315 ** or inserted or deleted by the most recently completed SQL statement
1316 ** on the [database connection] specified by the first parameter.
1317 ** Only changes that are directly specified by the [INSERT], [UPDATE],
1318 ** or [DELETE] statement are counted. Auxiliary changes caused by
1319 ** triggers are not counted. Use the [sqlite3_total_changes()] function
1320 ** to find the total number of changes including changes caused by triggers.
 
1321 **
1322 ** Changes to a view that are simulated by an [INSTEAD OF trigger]
1323 ** are not counted. Only real table changes are counted.
1324 **
1325 ** A "row change" is a change to a single row of a single table
@@ -1367,12 +1368,12 @@
1367 /*
1368 ** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600>
1369 **
1370 ** This function returns the number of row changes caused by [INSERT],
1371 ** [UPDATE] or [DELETE] statements since the [database connection] was opened.
1372 ** The count includes all changes from all
1373 ** [CREATE TRIGGER | trigger] contexts. However,
1374 ** the count does not include changes used to implement [REPLACE] constraints,
1375 ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The
1376 ** count does not include rows of views that fire an [INSTEAD OF trigger],
1377 ** though if the INSTEAD OF trigger makes changes of its own, those changes
1378 ** are counted.
@@ -4509,10 +4510,13 @@
4509 ** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
4510 ** </pre> {END}
4511 **
4512 ** If the flags parameter is non-zero, then the BLOB is opened for read
4513 ** and write access. If it is zero, the BLOB is opened for read access.
 
 
 
4514 **
4515 ** Note that the database name is not the filename that contains
4516 ** the database but rather the symbolic name of the database that
4517 ** is assigned when the database is connected using [ATTACH].
4518 ** For the main database file, the database name is "main".
4519
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -117,13 +117,13 @@
117 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
118 ** [sqlite_version()] and [sqlite_source_id()].
119 **
120 ** Requirements: [H10011] [H10014]
121 */
122 #define SQLITE_VERSION "3.6.19"
123 #define SQLITE_VERSION_NUMBER 3006019
124 #define SQLITE_SOURCE_ID "2009-10-13 15:42:49 f894ebf86d6bafcd1461f104f5f677b3b6a3aa1a"
125
126 /*
127 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
128 ** KEYWORDS: sqlite3_version
129 **
@@ -1314,12 +1314,13 @@
1314 ** This function returns the number of database rows that were changed
1315 ** or inserted or deleted by the most recently completed SQL statement
1316 ** on the [database connection] specified by the first parameter.
1317 ** Only changes that are directly specified by the [INSERT], [UPDATE],
1318 ** or [DELETE] statement are counted. Auxiliary changes caused by
1319 ** triggers or [foreign key actions] are not counted. Use the
1320 ** [sqlite3_total_changes()] function to find the total number of changes
1321 ** including changes caused by triggers and foreign key actions.
1322 **
1323 ** Changes to a view that are simulated by an [INSTEAD OF trigger]
1324 ** are not counted. Only real table changes are counted.
1325 **
1326 ** A "row change" is a change to a single row of a single table
@@ -1367,12 +1368,12 @@
1368 /*
1369 ** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600>
1370 **
1371 ** This function returns the number of row changes caused by [INSERT],
1372 ** [UPDATE] or [DELETE] statements since the [database connection] was opened.
1373 ** The count includes all changes from all [CREATE TRIGGER | trigger]
1374 ** contexts and changes made by [foreign key actions]. However,
1375 ** the count does not include changes used to implement [REPLACE] constraints,
1376 ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The
1377 ** count does not include rows of views that fire an [INSTEAD OF trigger],
1378 ** though if the INSTEAD OF trigger makes changes of its own, those changes
1379 ** are counted.
@@ -4509,10 +4510,13 @@
4510 ** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
4511 ** </pre> {END}
4512 **
4513 ** If the flags parameter is non-zero, then the BLOB is opened for read
4514 ** and write access. If it is zero, the BLOB is opened for read access.
4515 ** It is not possible to open a column that is part of an index or primary
4516 ** key for writing. ^If [foreign key constraints] are enabled, it is
4517 ** not possible to open a column that is part of a [child key] for writing.
4518 **
4519 ** Note that the database name is not the filename that contains
4520 ** the database but rather the symbolic name of the database that
4521 ** is assigned when the database is connected using [ATTACH].
4522 ** For the main database file, the database name is "main".
4523

Keyboard Shortcuts

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