/ Check-in [06f90bb2]
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:Eponymous virtual tables exist in the "main" schema only. Enforce this rule.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 06f90bb274c4bb0c30585024c8d365d43c4162f2
User & Date: drh 2015-09-08 20:26:09
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: 6beb512c user: drh tags: trunk
20:26
Eponymous virtual tables exist in the "main" schema only. Enforce this rule. check-in: 06f90bb2 user: drh tags: trunk
17:31
Fix the help message that sqlite3_analyzer.exe generates for invalid arguments. check-in: 33a14e7b user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

   353    353       return 0;
   354    354     }
   355    355   
   356    356     p = sqlite3FindTable(pParse->db, zName, zDbase);
   357    357     if( p==0 ){
   358    358       const char *zMsg = isView ? "no such view" : "no such table";
   359    359   #ifndef SQLITE_OMIT_VIRTUALTABLE
   360         -    /* If zName is the not the name of a table in the schema created using
   361         -    ** CREATE, then check to see if it is the name of an virtual table that
   362         -    ** can be an eponymous virtual table. */
   363         -    Module *pMod = (Module*)sqlite3HashFind(&pParse->db->aModule, zName);
   364         -    if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
   365         -      return pMod->pEpoTab;
          360  +    if( sqlite3FindDbName(pParse->db, zDbase)<1 ){
          361  +      /* If zName is the not the name of a table in the schema created using
          362  +      ** CREATE, then check to see if it is the name of an virtual table that
          363  +      ** can be an eponymous virtual table. */
          364  +      Module *pMod = (Module*)sqlite3HashFind(&pParse->db->aModule, zName);
          365  +      if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
          366  +        return pMod->pEpoTab;
          367  +      }
   366    368       }
   367    369   #endif
   368    370       if( zDbase ){
   369    371         sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
   370    372       }else{
   371    373         sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
   372    374       }

Changes to test/tabfunc01.test.

    65     65     SELECT * FROM generate_series() LIMIT 5;
    66     66   } {0 1 2 3 4}
    67     67   
    68     68   do_execsql_test tabfunc01-3.1 {
    69     69     SELECT DISTINCT value FROM generate_series(1,x), t1 ORDER BY 1;
    70     70   } {1 2 3}
    71     71   
           72  +# Eponymous virtual table exists in the "main" schema only
           73  +#
           74  +do_execsql_test tabfunc01-4.1 {
           75  +  SELECT * FROM main.generate_series(1,4)
           76  +} {1 2 3 4}
           77  +do_catchsql_test tabfunc01-4.2 {
           78  +  SELECT * FROM temp.generate_series(1,4)
           79  +} {1 {no such table: temp.generate_series}}
           80  +do_catchsql_test tabfunc01-4.3 {
           81  +  ATTACH ':memory:' AS aux1;
           82  +  CREATE TABLE aux1.t1(a,b,c);
           83  +  SELECT * FROM aux1.generate_series(1,4)
           84  +} {1 {no such table: aux1.generate_series}}
    72     85   
    73     86   finish_test