Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch rtree-batch-insert Excluding Merge-Ins
This is equivalent to a diff from 122431d3a7 to f94f3da5de
2023-04-27
| ||
19:27 | Dynamically resize the node hash table used by the rtree module. (Leaf check-in: f94f3da5de user: dan tags: rtree-batch-insert) | |
2023-04-26
| ||
20:41 | Fix some problems with the rtree module and existing tests on this branch. (check-in: 50e8a30be1 user: dan tags: rtree-batch-insert) | |
2023-04-25
| ||
02:44 | Check for OOM sqlite_value_x() returns in base64, base85 extensions, a partial response to forum post 74dd86263e. (check-in: e6f9c0b1f9 user: larrybr tags: trunk) | |
2023-04-24
| ||
23:14 | Allow trailing commas in objects and arrays of JSON. (check-in: 4031b231c2 user: drh tags: json5) | |
21:08 |
Hold the RTREE node cache open and defer writes until the very end of the
INSERT statement, | |
19:23 | Update the compile-time detection of architecture byte-order in the RTREE extension so that it is aligned with the latest enhancements in the core. (check-in: 122431d3a7 user: drh tags: trunk) | |
19:14 | Mistake → branched off of the wrong branch. (Closed-Leaf check-in: 491bd51da5 user: drh tags: mistake) | |
04:25 | Add a note about the journaling mode in the OPFS VFS. No code changes. (check-in: e79c95fc13 user: stephan tags: trunk) | |
Changes to ext/rtree/geopoly.c.
︙ | |||
1768 1769 1770 1771 1772 1773 1774 | 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 | - - - + + + - - + + | geopolyFilter, /* xFilter - configure scan constraints */ rtreeNext, /* xNext - advance a cursor */ rtreeEof, /* xEof */ geopolyColumn, /* xColumn - read data */ rtreeRowid, /* xRowid - read data */ geopolyUpdate, /* xUpdate - write data */ rtreeBeginTransaction, /* xBegin - begin transaction */ |
︙ |
Changes to ext/rtree/rtree.c.
︙ | |||
112 113 114 115 116 117 118 119 120 121 122 123 124 125 | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | + - + - - - - + + + + + + + + + + + | typedef struct RtreeNode RtreeNode; typedef struct RtreeCell RtreeCell; typedef struct RtreeConstraint RtreeConstraint; typedef struct RtreeMatchArg RtreeMatchArg; typedef struct RtreeGeomCallback RtreeGeomCallback; typedef union RtreeCoord RtreeCoord; typedef struct RtreeSearchPoint RtreeSearchPoint; typedef struct RtreeGlobal RtreeGlobal; /* The rtree may have between 1 and RTREE_MAX_DIMENSIONS dimensions. */ #define RTREE_MAX_DIMENSIONS 5 /* Maximum number of auxiliary columns */ #define RTREE_MAX_AUX_COLUMN 100 |
︙ | |||
191 192 193 194 195 196 197 | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | + + - + + + + | sqlite3_stmt *pReadParent; sqlite3_stmt *pWriteParent; sqlite3_stmt *pDeleteParent; /* Statement for writing to the "aux:" fields, if there are any */ sqlite3_stmt *pWriteAux; int nHashSize; /* Number of hash buckets */ int nHashEntry; /* Number of entries in hash table */ |
︙ | |||
217 218 219 220 221 222 223 | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | + + + - + | # define RTREE_ZERO 0.0 #endif /* ** Set the Rtree.bCorrupt flag */ #ifdef SQLITE_DEBUG static void rtreeIsCorrupt(Rtree *pRtree){ pRtree->bCorrupt = 1; } |
︙ | |||
351 352 353 354 355 356 357 358 359 360 361 362 | 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | + + + + + - + | ** are used in the cursor for contraints such as x=NULL (RTREE_FALSE) or ** x<'xyz' (RTREE_TRUE) */ #define RTREE_TRUE 0x3f /* ? */ #define RTREE_FALSE 0x40 /* @ */ /* ** An rtree structure node. ** ** bDel: ** This node is not in the hash table. It should be freed when its ** ref-count reaches 0. */ struct RtreeNode { RtreeNode *pParent; /* Parent node */ i64 iNode; /* The node number */ int nRef; /* Number of references to this node */ u8 bDel; |
︙ | |||
617 618 619 620 621 622 623 | 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 | - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + + | p->isDirty = 1; } /* ** Given a node number iNode, return the corresponding key to use ** in the Rtree.aHash table. */ |
︙ | |||
703 704 705 706 707 708 709 | 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 | + + + + + - - - - + + + + + + + | int rc = SQLITE_OK; RtreeNode *pNode = 0; /* Check if the requested node is already in the hash table. If so, ** increase its reference count and return it. */ if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){ assert( pNode->pParent==0 || pNode->nRef>0 ); if( pNode->nRef==0 ){ pNode->pParent = pParent; nodeReference(pParent); }else{ |
︙ | |||
743 744 745 746 747 748 749 | 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 | - + | RTREE_IS_CORRUPT(pRtree); } }else if( pRtree->iNodeSize==sqlite3_blob_bytes(pRtree->pNodeBlob) ){ pNode = (RtreeNode *)sqlite3_malloc64(sizeof(RtreeNode)+pRtree->iNodeSize); if( !pNode ){ rc = SQLITE_NOMEM; }else{ |
︙ | |||
782 783 784 785 786 787 788 789 790 791 792 793 794 795 | 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 | + | rc = SQLITE_CORRUPT_VTAB; RTREE_IS_CORRUPT(pRtree); } } if( rc==SQLITE_OK ){ if( pNode!=0 ){ pNode->pParent = pParent; nodeReference(pParent); nodeHashInsert(pRtree, pNode); }else{ rc = SQLITE_CORRUPT_VTAB; RTREE_IS_CORRUPT(pRtree); } *ppNode = pNode; |
︙ | |||
875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 | 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } sqlite3_bind_blob(p, 2, pNode->zData, pRtree->iNodeSize, SQLITE_STATIC); sqlite3_step(p); pNode->isDirty = 0; rc = sqlite3_reset(p); sqlite3_bind_null(p, 2); if( pNode->iNode==0 && rc==SQLITE_OK ){ pNode->bDel = 0; pNode->iNode = sqlite3_last_insert_rowid(pRtree->db); nodeHashInsert(pRtree, pNode); } } return rc; } /* ** Write all dirty nodes out to disk. */ static int rtreeFlushCache(Rtree *pRtree){ int i; int rc = SQLITE_OK; i64 iLIR = sqlite3_last_insert_rowid(pRtree->db); for(i=0; i<pRtree->nHashSize && rc==SQLITE_OK; i++){ RtreeNode *pNode; for(pNode=pRtree->aHash[i]; pNode; pNode=pNode->pNext){ if( pNode->isDirty ){ rc = nodeWrite(pRtree, pNode); if( rc ) break; } } } sqlite3_set_last_insert_rowid(pRtree->db, iLIR); return rc; } /* ** Scan the hash table. Verify that every hash table entry has nRef==0 ** and remove them. Any dirty pages are written if writeDirty is true. */ static int rtreeResetHashTable(Rtree *pRtree, int writeDirty){ int i; int rc = SQLITE_OK; for(i=0; i<pRtree->nHashSize; i++){ RtreeNode *pNode = pRtree->aHash[i]; RtreeNode *pNext; if( pNode==0 ) continue; while( 1 /*exit-by-break*/ ){ pNext = pNode->pNext; if( pNode->isDirty && writeDirty ){ rc = nodeWrite(pRtree, pNode); if( rc ) writeDirty = 0; } if( pNode->nRef==0 ){ sqlite3_free(pNode); }else{ pNode->isDirty = 0; pNode->bDel = 1; } if( pNext==0 ) break; pNode = pNext; } pRtree->aHash[i] = 0; } pRtree->nHashEntry = 0; return rc; } /* ** Release a reference to a node. If the node is dirty and the reference ** count drops to zero, the node data is written to the database. */ static int nodeRelease(Rtree *pRtree, RtreeNode *pNode){ int rc = SQLITE_OK; if( pNode ){ assert( pNode->nRef>0 ); assert( pRtree->nNodeRef>0 ); pNode->nRef--; if( pNode->nRef==0 ){ pRtree->nNodeRef--; if( pNode->iNode==1 ){ pRtree->iDepth = -1; } if( pNode->pParent ){ rc = nodeRelease(pRtree, pNode->pParent); pNode->pParent = 0; } if( pNode->bDel ){ sqlite3_free(pNode); } #if 0 if( rc==SQLITE_OK ){ rc = nodeWrite(pRtree, pNode); } nodeHashDelete(pRtree, pNode); sqlite3_free(pNode); #endif } } return rc; } /* ** Return the 64-bit integer value associated with cell iCell of |
︙ | |||
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 | 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 | + + + + + + + + + + | */ static void rtreeRelease(Rtree *pRtree){ pRtree->nBusy--; if( pRtree->nBusy==0 ){ pRtree->inWrTrans = 0; assert( pRtree->nCursor==0 ); nodeBlobReset(pRtree); rtreeResetHashTable(pRtree, 0); assert( pRtree->nNodeRef==0 || pRtree->bCorrupt ); sqlite3_finalize(pRtree->pWriteNode); sqlite3_finalize(pRtree->pDeleteNode); sqlite3_finalize(pRtree->pReadRowid); sqlite3_finalize(pRtree->pWriteRowid); sqlite3_finalize(pRtree->pDeleteRowid); sqlite3_finalize(pRtree->pReadParent); sqlite3_finalize(pRtree->pWriteParent); sqlite3_finalize(pRtree->pDeleteParent); sqlite3_finalize(pRtree->pWriteAux); sqlite3_free(pRtree->zReadAuxSql); sqlite3_free(pRtree->aHash); /* Remove this object from the global list. */ if( pRtree->pGlobal ){ Rtree **pp; for(pp=&pRtree->pGlobal->pGlobalRtree;*pp!=pRtree;pp=&(*pp)->pGlobalNext); *pp = pRtree->pGlobalNext; } sqlite3_free(pRtree); } } /* ** Rtree virtual table module xDisconnect method. */ |
︙ | |||
1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 | 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 | + + + + + | RtreeCursor *pCsr = (RtreeCursor *)cur; assert( pRtree->nCursor>0 ); resetCursor(pCsr); sqlite3_finalize(pCsr->pReadAux); sqlite3_free(pCsr); pRtree->nCursor--; nodeBlobReset(pRtree); if( pRtree->inWrTrans==0 && pRtree->nCursor==0 ){ /* If this was the last open cursor, and there is no write-transaction, ** discard the contents of the node-cache. */ rtreeResetHashTable(pRtree, 0); } return SQLITE_OK; } /* ** Rtree virtual table module xEof method. ** ** Return non-zero if the cursor does not currently point to a valid |
︙ | |||
2563 2564 2565 2566 2567 2568 2569 | 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 | - + | xSetMapping = ((iHeight==0)?rowidWrite:parentWrite); if( iHeight>0 ){ RtreeNode *pChild = nodeHashLookup(pRtree, iRowid); RtreeNode *p; for(p=pNode; p; p=p->pParent){ if( p==pChild ) return SQLITE_CORRUPT_VTAB; } |
︙ | |||
2978 2979 2980 2981 2982 2983 2984 | 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 | - + | RtreeNode *pNode, RtreeCell *pCell, int iHeight ){ int rc = SQLITE_OK; if( iHeight>0 ){ RtreeNode *pChild = nodeHashLookup(pRtree, pCell->iRowid); |
︙ | |||
3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 | 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 | + + + + + | sqlite3_value **aData, sqlite_int64 *pRowid ){ Rtree *pRtree = (Rtree *)pVtab; int rc = SQLITE_OK; RtreeCell cell; /* New cell to insert if nData>1 */ int bHaveRowid = 0; /* Set to 1 after new rowid is determined */ i64 iLIR = sqlite3_last_insert_rowid(pRtree->db); #ifdef SQLITE_DEBUG int nNodeRefSave = pRtree->nNodeRef; #endif if( pRtree->nNodeRef ){ /* Unable to write to the btree while another cursor is reading from it, ** since the write might do a rebalance which would disrupt the read ** cursor. */ return SQLITE_LOCKED_VTAB; } |
︙ | |||
3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 | 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 | + + - + + + + + + + + + + + + + + + + + + + + + + + + + + | } sqlite3_step(pUp); rc = sqlite3_reset(pUp); } } constraint: sqlite3_set_last_insert_rowid(pRtree->db, iLIR); assert( pRtree->nNodeRef==nNodeRefSave ); rtreeRelease(pRtree); return rc; } /* ** Called when a transaction starts. */ static int rtreeBeginTransaction(sqlite3_vtab *pVtab){ Rtree *pRtree = (Rtree *)pVtab; assert( pRtree->inWrTrans==0 ); pRtree->inWrTrans++; return SQLITE_OK; } /* ** Called when a transaction completes (either by COMMIT or ROLLBACK). ** The sqlite3_blob object should be released at this point. */ |
︙ | |||
3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 | 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 | + + - + | ** INSERT INTO rtree... ** DROP TABLE <tablename>; -- Would fail with SQLITE_LOCKED ** COMMIT; */ static int rtreeSavepoint(sqlite3_vtab *pVtab, int iSavepoint){ Rtree *pRtree = (Rtree *)pVtab; u8 iwt = pRtree->inWrTrans; int rc = SQLITE_OK; UNUSED_PARAMETER(iSavepoint); rc = rtreeFlushCache(pRtree); pRtree->inWrTrans = 0; nodeBlobReset(pRtree); pRtree->inWrTrans = iwt; |
︙ | |||
3490 3491 3492 3493 3494 3495 3496 | 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 | - - - + + + - - + + | rtreeFilter, /* xFilter - configure scan constraints */ rtreeNext, /* xNext - advance a cursor */ rtreeEof, /* xEof */ rtreeColumn, /* xColumn - read data */ rtreeRowid, /* xRowid - read data */ rtreeUpdate, /* xUpdate - write data */ rtreeBeginTransaction, /* xBegin - begin transaction */ |
︙ | |||
3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 | 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 | + - + + + + + + + + | sqlite3 *db, /* Database connection */ void *pAux, /* One of the RTREE_COORD_* constants */ int argc, const char *const*argv, /* Parameters to CREATE TABLE statement */ sqlite3_vtab **ppVtab, /* OUT: New virtual table */ char **pzErr, /* OUT: Error message, if any */ int isCreate /* True for xCreate, false for xConnect */ ){ RtreeGlobal *pGlobal = (RtreeGlobal*)pAux; int rc = SQLITE_OK; Rtree *pRtree; int nDb; /* Length of string argv[1] */ int nName; /* Length of string argv[2] */ |
︙ | |||
3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 | 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 | + + + + + + + + + | pRtree->base.pModule = &rtreeModule; pRtree->zDb = (char *)&pRtree[1]; pRtree->zName = &pRtree->zDb[nDb+1]; pRtree->eCoordType = (u8)eCoordType; memcpy(pRtree->zDb, argv[1], nDb); memcpy(pRtree->zName, argv[2], nName); pRtree->aHash = (RtreeNode**)sqlite3_malloc64( sizeof(RtreeNode*) * INITIAL_HASHSIZE ); if( pRtree->aHash==0 ){ rc = SQLITE_NOMEM; goto rtreeInit_fail; } memset(pRtree->aHash, 0, sizeof(RtreeNode*)*INITIAL_HASHSIZE); pRtree->nHashSize = INITIAL_HASHSIZE; /* Create/Connect to the underlying relational database schema. If ** that is successful, call sqlite3_declare_vtab() to configure ** the r-tree table schema. */ pSql = sqlite3_str_new(db); sqlite3_str_appendf(pSql, "CREATE TABLE x(%.*s INT", |
︙ | |||
3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 | 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 | + + + + + | rc = getNodeSize(db, pRtree, isCreate, pzErr); if( rc ) goto rtreeInit_fail; rc = rtreeSqlInit(pRtree, db, argv[1], argv[2], isCreate); if( rc ){ *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db)); goto rtreeInit_fail; } /* Link this rtree into the global list */ pRtree->pGlobal = pGlobal; pRtree->pGlobalNext = pGlobal->pGlobalRtree; pGlobal->pGlobalRtree = pRtree; *ppVtab = (sqlite3_vtab *)pRtree; return SQLITE_OK; rtreeInit_fail: if( rc==SQLITE_OK ) rc = SQLITE_ERROR; assert( *ppVtab==0 ); |
︙ | |||
3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 | 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 | + | ** implementation of integrity-check function rtreecheck(). */ typedef struct RtreeCheck RtreeCheck; struct RtreeCheck { sqlite3 *db; /* Database handle */ const char *zDb; /* Database containing rtree table */ const char *zTab; /* Name of rtree table */ Rtree *pRtree; /* Rtree object (may be NULL) */ int bInt; /* True for rtree_i32 table */ int nDim; /* Number of dimensions for this rtree tbl */ sqlite3_stmt *pGetNode; /* Statement used to retrieve nodes */ sqlite3_stmt *aCheckMapping[2]; /* Statements to query %_parent/%_rowid */ int nLeaf; /* Number of leaf cells in table */ int nNonLeaf; /* Number of non-leaf cells in table */ int rc; /* Return code */ |
︙ | |||
4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 | 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 | + + + + + + + + + + + + + + + | ** ** Or, if an error does occur, NULL is returned and an error code left ** in the RtreeCheck object. The final value of *pnNode is undefined in ** this case. */ static u8 *rtreeCheckGetNode(RtreeCheck *pCheck, i64 iNode, int *pnNode){ u8 *pRet = 0; /* Return value */ if( pCheck->pRtree ){ RtreeNode *pNode = nodeHashLookup(pCheck->pRtree, iNode); if( pNode ){ int nNode = pCheck->pRtree->iNodeSize; pRet = (u8*)sqlite3_malloc64(nNode); if( pRet==0 ){ pCheck->rc = SQLITE_NOMEM; }else{ memcpy(pRet, pNode->zData, nNode); *pnNode = nNode; } return pRet; } } if( pCheck->rc==SQLITE_OK && pCheck->pGetNode==0 ){ pCheck->pGetNode = rtreeCheckPrepare(pCheck, "SELECT data FROM %Q.'%q_node' WHERE nodeno=?", pCheck->zDb, pCheck->zTab ); } |
︙ | |||
4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 | 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 | + + + + + + + + | /* ** This function does the bulk of the work for the rtree integrity-check. ** It is called by rtreecheck(), which is the SQL function implementation. */ static int rtreeCheckTable( sqlite3 *db, /* Database handle to access db through */ RtreeGlobal *pGlobal, const char *zDb, /* Name of db ("main", "temp" etc.) */ const char *zTab, /* Name of rtree table to check */ char **pzReport /* OUT: sqlite3_malloc'd report text */ ){ RtreeCheck check; /* Common context for various routines */ sqlite3_stmt *pStmt = 0; /* Used to find column count of rtree table */ int bEnd = 0; /* True if transaction should be closed */ int nAux = 0; /* Number of extra columns. */ Rtree *pRtree = 0; /* Initialize the context object */ memset(&check, 0, sizeof(check)); check.db = db; check.zDb = zDb; check.zTab = zTab; for(pRtree=pGlobal->pGlobalRtree; pRtree; pRtree=pRtree->pGlobalNext){ if( sqlite3_stricmp(zDb, pRtree->zDb) ) continue; if( sqlite3_stricmp(zTab, pRtree->zName) ) continue; break; } check.pRtree = pRtree; /* If there is not already an open transaction, open one now. This is ** to ensure that the queries run as part of this integrity-check operate ** on a consistent snapshot. */ if( sqlite3_get_autocommit(db) ){ check.rc = sqlite3_exec(db, "BEGIN", 0, 0, 0); bEnd = 1; |
︙ | |||
4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 | 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 | + + - + + + + + + + + + + + + + + - - + + - - + + - - + + - + + - - - + - - - + + + - - + + + + + + + + + + + | sqlite3_value **apArg ){ if( nArg!=1 && nArg!=2 ){ sqlite3_result_error(ctx, "wrong number of arguments to function rtreecheck()", -1 ); }else{ sqlite3 *db = sqlite3_context_db_handle(ctx); RtreeGlobal *pGlobal = (RtreeGlobal*)sqlite3_user_data(ctx); int rc; char *zReport = 0; const char *zDb = (const char*)sqlite3_value_text(apArg[0]); const char *zTab; if( nArg==1 ){ zTab = zDb; zDb = "main"; }else{ zTab = (const char*)sqlite3_value_text(apArg[1]); } |
︙ |
Changes to ext/rtree/rtree1.test.
︙ | |||
751 752 753 754 755 756 757 758 759 | 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 | + + + + + + + | db null - do_execsql_test 20.3 { SELECT * FROM t1 JOIN t0 ON true RIGHT JOIN rt0 ON x0>a WHERE +x0 = 0; } {- - 0 0.0 0.0} do_execsql_test 20.4 { SELECT * FROM t1 JOIN t0 ON true RIGHT JOIN rt0 ON x0>a WHERE x0 = 0; } {- - 0 0.0 0.0} reset_db do_execsql_test 21.0 { CREATE VIRTUAL TABLE rt0 USING rtree(id, x0, x1); INSERT INTO rt0 VALUES(5, 10, 10); SELECT last_insert_rowid(); } {5} finish_test |