/ Check-in [a915e8e0]
Login

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

Overview
Comment:Update comments in build.c to conform to the latest implementation. (CVS 6369)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a915e8e0a429ab6a10536c45264a790c2d076461
User & Date: drh 2009-03-21 16:19:26
Context
2009-03-22
20:36
Allow the keyword INDEXED to be used as the name of a table or index or column - for backwards compatibility. (CVS 6370) check-in: 53149c9f user: drh tags: trunk
2009-03-21
16:19
Update comments in build.c to conform to the latest implementation. (CVS 6369) check-in: a915e8e0 user: drh tags: trunk
14:56
Rig the unix backend to use fdatasync() by default, without having to set the HAVE_FDATASYNC macro. Systems that do not support fdatasync() can be compiled using -Dfdatasync=fsync. (CVS 6368) check-in: a3315627 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/build.c.

    18     18   **     CREATE INDEX
    19     19   **     DROP INDEX
    20     20   **     creating ID lists
    21     21   **     BEGIN TRANSACTION
    22     22   **     COMMIT
    23     23   **     ROLLBACK
    24     24   **
    25         -** $Id: build.c,v 1.524 2009/03/18 18:43:36 danielk1977 Exp $
           25  +** $Id: build.c,v 1.525 2009/03/21 16:19:26 drh Exp $
    26     26   */
    27     27   #include "sqliteInt.h"
    28     28   
    29     29   /*
    30     30   ** This routine is called when a new SQL statement is beginning to
    31     31   ** be parsed.  Initialize the pParse structure as needed.
    32     32   */
................................................................................
   887    887       sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, 4, reg3);
   888    888       sqlite3VdbeJumpHere(v, j1);
   889    889   
   890    890       /* This just creates a place-holder record in the sqlite_master table.
   891    891       ** The record created does not contain anything yet.  It will be replaced
   892    892       ** by the real entry in code generated at sqlite3EndTable().
   893    893       **
   894         -    ** The rowid for the new entry is left on the top of the stack.
   895         -    ** The rowid value is needed by the code that sqlite3EndTable will
   896         -    ** generate.
          894  +    ** The rowid for the new entry is left in register pParse->regRowid.
          895  +    ** The root page number of the new table is left in reg pParse->regRoot.
          896  +    ** The rowid and root page number values are needed by the code that
          897  +    ** sqlite3EndTable will generate.
   897    898       */
   898    899   #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)
   899    900       if( isView || isVirtual ){
   900    901         sqlite3VdbeAddOp2(v, OP_Integer, 0, reg2);
   901    902       }else
   902    903   #endif
   903    904       {
................................................................................
  1558   1559     ** should have been put there by the sqliteOpenCb routine.)
  1559   1560     */
  1560   1561     if( db->init.busy ){
  1561   1562       p->tnum = db->init.newTnum;
  1562   1563     }
  1563   1564   
  1564   1565     /* If not initializing, then create a record for the new table
  1565         -  ** in the SQLITE_MASTER table of the database.  The record number
  1566         -  ** for the new table entry should already be on the stack.
         1566  +  ** in the SQLITE_MASTER table of the database.
  1567   1567     **
  1568   1568     ** If this is a TEMPORARY table, write the entry into the auxiliary
  1569   1569     ** file instead of into the main database file.
  1570   1570     */
  1571   1571     if( !db->init.busy ){
  1572   1572       int n;
  1573   1573       Vdbe *v;
................................................................................
  1576   1576       char *zStmt;    /* Text of the CREATE TABLE or CREATE VIEW statement */
  1577   1577   
  1578   1578       v = sqlite3GetVdbe(pParse);
  1579   1579       if( v==0 ) return;
  1580   1580   
  1581   1581       sqlite3VdbeAddOp1(v, OP_Close, 0);
  1582   1582   
  1583         -    /* Create the rootpage for the new table and push it onto the stack.
  1584         -    ** A view has no rootpage, so just push a zero onto the stack for
  1585         -    ** views.  Initialize zType at the same time.
         1583  +    /* 
         1584  +    ** Initialize zType for the new view or table.
  1586   1585       */
  1587   1586       if( p->pSelect==0 ){
  1588   1587         /* A regular table */
  1589   1588         zType = "table";
  1590   1589         zType2 = "TABLE";
  1591   1590   #ifndef SQLITE_OMIT_VIEW
  1592   1591       }else{
................................................................................
  1594   1593         zType = "view";
  1595   1594         zType2 = "VIEW";
  1596   1595   #endif
  1597   1596       }
  1598   1597   
  1599   1598       /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT
  1600   1599       ** statement to populate the new table. The root-page number for the
  1601         -    ** new table is on the top of the vdbe stack.
         1600  +    ** new table is in register pParse->regRoot.
  1602   1601       **
  1603   1602       ** Once the SELECT has been coded by sqlite3Select(), it is in a
  1604   1603       ** suitable state to query for the column names and types to be used
  1605   1604       ** by the new table.
  1606   1605       **
  1607   1606       ** A shared-cache write-lock is not required to write to the new table,
  1608   1607       ** as a schema-lock must have already been obtained to create it. Since
................................................................................
  1640   1639         zStmt = sqlite3MPrintf(db, 
  1641   1640             "CREATE %s %.*s", zType2, n, pParse->sNameToken.z
  1642   1641         );
  1643   1642       }
  1644   1643   
  1645   1644       /* A slot for the record has already been allocated in the 
  1646   1645       ** SQLITE_MASTER table.  We just need to update that slot with all
  1647         -    ** the information we've collected.  The rowid for the preallocated
  1648         -    ** slot is the 2nd item on the stack.  The top of the stack is the
  1649         -    ** root page for the new table (or a 0 if this is a view).
         1646  +    ** the information we've collected.
  1650   1647       */
  1651   1648       sqlite3NestedParse(pParse,
  1652   1649         "UPDATE %Q.%s "
  1653   1650            "SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q "
  1654   1651          "WHERE rowid=#%d",
  1655   1652         db->aDb[iDb].zName, SCHEMA_TABLE(iDb),
  1656   1653         zType,
................................................................................
  1961   1958     sqlite3VdbeAddOp3(v, OP_Destroy, iTable, r1, iDb);
  1962   1959   #ifndef SQLITE_OMIT_AUTOVACUUM
  1963   1960     /* OP_Destroy stores an in integer r1. If this integer
  1964   1961     ** is non-zero, then it is the root page number of a table moved to
  1965   1962     ** location iTable. The following code modifies the sqlite_master table to
  1966   1963     ** reflect this.
  1967   1964     **
  1968         -  ** The "#%d" in the SQL is a special constant that means whatever value
  1969         -  ** is on the top of the stack.  See sqlite3RegisterExpr().
         1965  +  ** The "#NNN" in the SQL is a special constant that means whatever value
         1966  +  ** is in register NNN.  See sqlite3RegisterExpr().
  1970   1967     */
  1971   1968     sqlite3NestedParse(pParse, 
  1972   1969        "UPDATE %Q.%s SET rootpage=%d WHERE #%d AND rootpage=#%d",
  1973   1970        pParse->db->aDb[iDb].zName, SCHEMA_TABLE(iDb), iTable, r1, r1);
  1974   1971   #endif
  1975   1972     sqlite3ReleaseTempReg(pParse, r1);
  1976   1973   }