Overview
| SHA1 Hash: | 652233d646236d3fbca629813b20d075f00f3ed6 |
|---|---|
| Date: | 2013-01-17 03:18:38 |
| User: | mistachkin |
| Comment: | Enhance RTree virtual table creation error messages that involve the getNodeSize() function. |
Tags And Properties
- branch=rtreeErrMsg propagates to descendants
- closed added by [ae22eb46a7] on 2013-01-17 17:05:46
- sym-fsVfsWin cancelled
- sym-rtreeErrMsg propagates to descendants
Changes
Changes to ext/rtree/rtree.c
3045 ** This ensures that each node is stored on a single database page. If the 3045 ** This ensures that each node is stored on a single database page. If the 3046 ** database page-size is so large that more than RTREE_MAXCELLS entries 3046 ** database page-size is so large that more than RTREE_MAXCELLS entries 3047 ** would fit in a single node, use a smaller node-size. 3047 ** would fit in a single node, use a smaller node-size. 3048 */ 3048 */ 3049 static int getNodeSize( 3049 static int getNodeSize( 3050 sqlite3 *db, /* Database handle */ 3050 sqlite3 *db, /* Database handle */ 3051 Rtree *pRtree, /* Rtree handle */ 3051 Rtree *pRtree, /* Rtree handle */ 3052 int isCreate /* True for xCreate, false for xConnect */ | 3052 int isCreate, /* True for xCreate, false for xConnect */ > 3053 char **pzErr /* OUT: Error message, if any */ 3053 ){ 3054 ){ 3054 int rc; 3055 int rc; 3055 char *zSql; 3056 char *zSql; 3056 if( isCreate ){ 3057 if( isCreate ){ 3057 int iPageSize = 0; 3058 int iPageSize = 0; 3058 zSql = sqlite3_mprintf("PRAGMA %Q.page_size", pRtree->zDb); 3059 zSql = sqlite3_mprintf("PRAGMA %Q.page_size", pRtree->zDb); 3059 rc = getIntFromStmt(db, zSql, &iPageSize); 3060 rc = getIntFromStmt(db, zSql, &iPageSize); 3060 if( rc==SQLITE_OK ){ 3061 if( rc==SQLITE_OK ){ 3061 pRtree->iNodeSize = iPageSize-64; 3062 pRtree->iNodeSize = iPageSize-64; 3062 if( (4+pRtree->nBytesPerCell*RTREE_MAXCELLS)<pRtree->iNodeSize ){ 3063 if( (4+pRtree->nBytesPerCell*RTREE_MAXCELLS)<pRtree->iNodeSize ){ 3063 pRtree->iNodeSize = 4+pRtree->nBytesPerCell*RTREE_MAXCELLS; 3064 pRtree->iNodeSize = 4+pRtree->nBytesPerCell*RTREE_MAXCELLS; 3064 } 3065 } > 3066 }else{ > 3067 *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db)); 3065 } 3068 } 3066 }else{ 3069 }else{ 3067 zSql = sqlite3_mprintf( 3070 zSql = sqlite3_mprintf( 3068 "SELECT length(data) FROM '%q'.'%q_node' WHERE nodeno = 1", 3071 "SELECT length(data) FROM '%q'.'%q_node' WHERE nodeno = 1", 3069 pRtree->zDb, pRtree->zName 3072 pRtree->zDb, pRtree->zName 3070 ); 3073 ); 3071 rc = getIntFromStmt(db, zSql, &pRtree->iNodeSize); 3074 rc = getIntFromStmt(db, zSql, &pRtree->iNodeSize); > 3075 if( rc!=SQLITE_OK ){ > 3076 *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db)); > 3077 } 3072 } 3078 } 3073 3079 3074 sqlite3_free(zSql); 3080 sqlite3_free(zSql); 3075 return rc; 3081 return rc; 3076 } 3082 } 3077 3083 3078 /* 3084 /* ................................................................................................................................................................................ 3128 pRtree->nDim = (argc-4)/2; 3134 pRtree->nDim = (argc-4)/2; 3129 pRtree->nBytesPerCell = 8 + pRtree->nDim*4*2; 3135 pRtree->nBytesPerCell = 8 + pRtree->nDim*4*2; 3130 pRtree->eCoordType = eCoordType; 3136 pRtree->eCoordType = eCoordType; 3131 memcpy(pRtree->zDb, argv[1], nDb); 3137 memcpy(pRtree->zDb, argv[1], nDb); 3132 memcpy(pRtree->zName, argv[2], nName); 3138 memcpy(pRtree->zName, argv[2], nName); 3133 3139 3134 /* Figure out the node size to use. */ 3140 /* Figure out the node size to use. */ 3135 rc = getNodeSize(db, pRtree, isCreate); | 3141 rc = getNodeSize(db, pRtree, isCreate, pzErr); 3136 3142 3137 /* Create/Connect to the underlying relational database schema. If 3143 /* Create/Connect to the underlying relational database schema. If 3138 ** that is successful, call sqlite3_declare_vtab() to configure 3144 ** that is successful, call sqlite3_declare_vtab() to configure 3139 ** the r-tree table schema. 3145 ** the r-tree table schema. 3140 */ 3146 */ 3141 if( rc==SQLITE_OK ){ 3147 if( rc==SQLITE_OK ){ 3142 if( (rc = rtreeSqlInit(pRtree, db, argv[1], argv[2], isCreate)) ){ 3148 if( (rc = rtreeSqlInit(pRtree, db, argv[1], argv[2], isCreate)) ){