SQLite

Check-in [06f90bb274]
Login

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

Overview
Comment:Eponymous virtual tables exist in the "main" schema only. Enforce this rule.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 06f90bb274c4bb0c30585024c8d365d43c4162f2
User & Date: drh 2015-09-08 20:26:09.245
Context
2015-09-08
21:12
Enhance the DBSTAT virtual table with a new hidden table "schema" that if set will cause the table to report on the specified schema rather than on "main". Also: Fix a faulty assert in sqlite3_context_db_handle(). (check-in: 6beb512c7a user: drh tags: trunk)
20:26
Eponymous virtual tables exist in the "main" schema only. Enforce this rule. (check-in: 06f90bb274 user: drh tags: trunk)
17:31
Fix the help message that sqlite3_analyzer.exe generates for invalid arguments. (check-in: 33a14e7be1 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/build.c.
353
354
355
356
357
358
359

360
361
362
363
364
365

366
367
368
369
370
371
372
    return 0;
  }

  p = sqlite3FindTable(pParse->db, zName, zDbase);
  if( p==0 ){
    const char *zMsg = isView ? "no such view" : "no such table";
#ifndef SQLITE_OMIT_VIRTUALTABLE

    /* If zName is the not the name of a table in the schema created using
    ** CREATE, then check to see if it is the name of an virtual table that
    ** can be an eponymous virtual table. */
    Module *pMod = (Module*)sqlite3HashFind(&pParse->db->aModule, zName);
    if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
      return pMod->pEpoTab;

    }
#endif
    if( zDbase ){
      sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
    }else{
      sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
    }







>
|
|
|
|
|
|
>







353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
    return 0;
  }

  p = sqlite3FindTable(pParse->db, zName, zDbase);
  if( p==0 ){
    const char *zMsg = isView ? "no such view" : "no such table";
#ifndef SQLITE_OMIT_VIRTUALTABLE
    if( sqlite3FindDbName(pParse->db, zDbase)<1 ){
      /* If zName is the not the name of a table in the schema created using
      ** CREATE, then check to see if it is the name of an virtual table that
      ** can be an eponymous virtual table. */
      Module *pMod = (Module*)sqlite3HashFind(&pParse->db->aModule, zName);
      if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
        return pMod->pEpoTab;
      }
    }
#endif
    if( zDbase ){
      sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
    }else{
      sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
    }
Changes to test/tabfunc01.test.
65
66
67
68
69
70
71













72
73
  SELECT * FROM generate_series() LIMIT 5;
} {0 1 2 3 4}

do_execsql_test tabfunc01-3.1 {
  SELECT DISTINCT value FROM generate_series(1,x), t1 ORDER BY 1;
} {1 2 3}















finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>


65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
  SELECT * FROM generate_series() LIMIT 5;
} {0 1 2 3 4}

do_execsql_test tabfunc01-3.1 {
  SELECT DISTINCT value FROM generate_series(1,x), t1 ORDER BY 1;
} {1 2 3}

# Eponymous virtual table exists in the "main" schema only
#
do_execsql_test tabfunc01-4.1 {
  SELECT * FROM main.generate_series(1,4)
} {1 2 3 4}
do_catchsql_test tabfunc01-4.2 {
  SELECT * FROM temp.generate_series(1,4)
} {1 {no such table: temp.generate_series}}
do_catchsql_test tabfunc01-4.3 {
  ATTACH ':memory:' AS aux1;
  CREATE TABLE aux1.t1(a,b,c);
  SELECT * FROM aux1.generate_series(1,4)
} {1 {no such table: aux1.generate_series}}

finish_test