/ Check-in [48526a2f]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix RTREE so that it does not run queries against the sqlite_stat1 if that table does not exist.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tree-stat1-fix
Files: files | file ages | folders
SHA1: 48526a2fe5373e3d19e8b813cc8a342d6b7c9c3d
User & Date: drh 2016-05-23 18:12:04
Context
2016-05-23
18:27
Fix the rtreeG.test test case. Closed-Leaf check-in: 9589e937 user: drh tags: tree-stat1-fix
18:12
Fix RTREE so that it does not run queries against the sqlite_stat1 if that table does not exist. check-in: 48526a2f user: drh tags: tree-stat1-fix
18:06
Remove an extra "finish_test" from the end of rtreeC.test. check-in: bfbb6dd8 user: drh tags: tree-stat1-fix
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/rtree/rtree.c.

3008
3009
3010
3011
3012
3013
3014





3015
3016
3017
3018
3019
3020
3021
static int rtreeQueryStat1(sqlite3 *db, Rtree *pRtree){
  const char *zFmt = "SELECT stat FROM %Q.sqlite_stat1 WHERE tbl = '%q_rowid'";
  char *zSql;
  sqlite3_stmt *p;
  int rc;
  i64 nRow = 0;






  zSql = sqlite3_mprintf(zFmt, pRtree->zDb, pRtree->zName);
  if( zSql==0 ){
    rc = SQLITE_NOMEM;
  }else{
    rc = sqlite3_prepare_v2(db, zSql, -1, &p, 0);
    if( rc==SQLITE_OK ){
      if( sqlite3_step(p)==SQLITE_ROW ) nRow = sqlite3_column_int64(p, 0);







>
>
>
>
>







3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
static int rtreeQueryStat1(sqlite3 *db, Rtree *pRtree){
  const char *zFmt = "SELECT stat FROM %Q.sqlite_stat1 WHERE tbl = '%q_rowid'";
  char *zSql;
  sqlite3_stmt *p;
  int rc;
  i64 nRow = 0;

  if( sqlite3_table_column_metadata(db,pRtree->zDb,"sqlite_stat1",
          0,0,0,0,0,0)==SQLITE_ERROR ){
    pRtree->nRowEst = RTREE_DEFAULT_ROWEST;
    return SQLITE_OK;
  }
  zSql = sqlite3_mprintf(zFmt, pRtree->zDb, pRtree->zName);
  if( zSql==0 ){
    rc = SQLITE_NOMEM;
  }else{
    rc = sqlite3_prepare_v2(db, zSql, -1, &p, 0);
    if( rc==SQLITE_OK ){
      if( sqlite3_step(p)==SQLITE_ROW ) nRow = sqlite3_column_int64(p, 0);

Added ext/rtree/rtreeG.test.





































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 2016-05-32
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file contains tests for the r-tree module.
#
# Verify that no invalid SQL is run during initialization

if {![info exists testdir]} {
  set testdir [file join [file dirname [info script]] .. .. test]
} 
source $testdir/tester.tcl
ifcapable !rtree { finish_test ; return }

db close
sqlite3_shutdown
test_sqlite3_log [list lappend ::log]
set ::log [list]
sqlite3 db test.db


set ::log {}
do_test rtreeG-1.1 {
  db eval {CREATE VIRTUAL TABLE t1 USING rtree(a,b,c);}
  set ::log
} {}

finish_test