/ Check-in [fd8b8c41]
Login

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

Overview
Comment:Convert the schema creation logic in the rtree extension to use the new sqlite3_str interface.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: fd8b8c4196d3f0f6cb129f43ebf473ada86eefdf16181fa70ceee21e1232b5e1
User & Date: drh 2018-05-14 15:26:05
Context
2018-05-14
22:46
Make more aggressive use of automatic indexes when processing materalized views and subqueries. check-in: 172f5bd2 user: drh tags: trunk
17:12
Experimental syntax enhancement for an "INDEXED" keyword following a FROM-clause subquery that indicates that an automatic index on that subquery is suggested. check-in: 32b3d110 user: drh tags: exp-indexed-clause
15:26
Convert the schema creation logic in the rtree extension to use the new sqlite3_str interface. check-in: fd8b8c41 user: drh tags: trunk
12:23
Fix typo in the shell.c source file. check-in: 389dc0a9 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/rtree/rtree.c.

  3490   3490     ** that is successful, call sqlite3_declare_vtab() to configure
  3491   3491     ** the r-tree table schema.
  3492   3492     */
  3493   3493     if( rc==SQLITE_OK ){
  3494   3494       if( (rc = rtreeSqlInit(pRtree, db, argv[1], argv[2], isCreate)) ){
  3495   3495         *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db));
  3496   3496       }else{
  3497         -      char *zSql = sqlite3_mprintf("CREATE TABLE x(%s", argv[3]);
  3498         -      char *zTmp;
         3497  +      sqlite3_str *pSql = sqlite3_str_new(db);
         3498  +      char *zSql;
  3499   3499         int ii;
  3500         -      for(ii=4; zSql && ii<argc; ii++){
  3501         -        zTmp = zSql;
  3502         -        zSql = sqlite3_mprintf("%s, %s", zTmp, argv[ii]);
  3503         -        sqlite3_free(zTmp);
  3504         -      }
  3505         -      if( zSql ){
  3506         -        zTmp = zSql;
  3507         -        zSql = sqlite3_mprintf("%s);", zTmp);
  3508         -        sqlite3_free(zTmp);
         3500  +      if( pSql==0 ){
         3501  +        zSql = 0;
         3502  +      }else{
         3503  +        sqlite3_str_appendf(pSql, "CREATE TABLE x(%s", argv[3]);
         3504  +        for(ii=4; ii<argc; ii++){
         3505  +          sqlite3_str_appendf(pSql, ", %s", argv[ii]);
         3506  +        }
         3507  +        sqlite3_str_appendf(pSql, ");");
         3508  +        zSql = sqlite3_str_finish(pSql);
  3509   3509         }
  3510   3510         if( !zSql ){
  3511   3511           rc = SQLITE_NOMEM;
  3512   3512         }else if( SQLITE_OK!=(rc = sqlite3_declare_vtab(db, zSql)) ){
  3513   3513           *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db));
  3514   3514         }
  3515   3515         sqlite3_free(zSql);