SQLite

Check-in [04abadb545]
Login

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

Overview
Comment:Simplify some of the code modified by the previous commit.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 04abadb545d1b34bdd74d62becb3bfd83aceee373fd6b4b708d5ad53f41d9464
User & Date: dan 2020-03-21 20:58:05.148
Context
2020-03-21
22:03
Enhance the treeview system to show the SrcList_item.colUsed field for FROM clause elements. (check-in: 8a5c539b77 user: drh tags: trunk)
20:58
Simplify some of the code modified by the previous commit. (check-in: 04abadb545 user: dan tags: trunk)
15:41
Ensure that "main" can always be used to refer to the main database, even if it has been renamed using SQLITE_DBCONFIG_MAINDBNAME. (check-in: 682b426f56 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/attach.c.
469
470
471
472
473
474
475
476
477
478
479

480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
** checks out, these routines return 0.
*/
int sqlite3FixSrcList(
  DbFixer *pFix,       /* Context of the fixation */
  SrcList *pList       /* The Source list to check and modify */
){
  int i;
  const char *zDb;
  struct SrcList_item *pItem;
  sqlite3 *db = pFix->pParse->db;
  const char *zAlt = 0;


  if( NEVER(pList==0) ) return 0;

  /* If zDb refers to the main database and the main database has been
  ** renamed using DBCONFIG_MAINDBNAME, then items in pList may be
  ** qualified using "main" or the new name as the database name. Set
  ** zAlt to point to the alternative (alternative to zDb) name in this 
  ** case. */
  zDb = pFix->zDb;
  if( sqlite3StrICmp(db->aDb[0].zDbSName, zDb)==0 ){ 
    zAlt = "main";
  }else if( sqlite3StrICmp("main", zDb)==0 ){
    zAlt = db->aDb[0].zDbSName;
  }

  for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){
    if( pFix->bTemp==0 ){
      if( pItem->zDatabase 
       && sqlite3StrICmp(pItem->zDatabase, zDb) 
       && sqlite3_stricmp(pItem->zDatabase, zAlt)
      ){
        sqlite3ErrorMsg(pFix->pParse,
            "%s %T cannot reference objects in database %s",
            pFix->zType, pFix->pName, pItem->zDatabase);
        return 1;
      }
      sqlite3DbFree(pFix->pParse->db, pItem->zDatabase);
      pItem->zDatabase = 0;
      pItem->pSchema = pFix->pSchema;
      pItem->fg.fromDDL = 1;
    }
#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
    if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1;
    if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1;







<


<
>



<
<
<
<
<
<
<
<
<
<
<
<


|
<
<
<





|







469
470
471
472
473
474
475

476
477

478
479
480
481












482
483
484



485
486
487
488
489
490
491
492
493
494
495
496
497
** checks out, these routines return 0.
*/
int sqlite3FixSrcList(
  DbFixer *pFix,       /* Context of the fixation */
  SrcList *pList       /* The Source list to check and modify */
){
  int i;

  struct SrcList_item *pItem;
  sqlite3 *db = pFix->pParse->db;

  int iDb = sqlite3FindDbName(db, pFix->zDb);

  if( NEVER(pList==0) ) return 0;













  for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){
    if( pFix->bTemp==0 ){
      if( pItem->zDatabase && iDb!=sqlite3FindDbName(db, pItem->zDatabase) ){



        sqlite3ErrorMsg(pFix->pParse,
            "%s %T cannot reference objects in database %s",
            pFix->zType, pFix->pName, pItem->zDatabase);
        return 1;
      }
      sqlite3DbFree(db, pItem->zDatabase);
      pItem->zDatabase = 0;
      pItem->pSchema = pFix->pSchema;
      pItem->fg.fromDDL = 1;
    }
#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
    if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1;
    if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1;