/ Check-in [9385ad5c]
Login

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

Overview
Comment:Move the sqlite3_exec() function to legacy.c. (CVS 1455)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9385ad5ca82c82d9ef699102ca0b53661d02a052
User & Date: danielk1977 2004-05-25 23:35:18
Context
2004-05-26
00:01
Add file legacy.c with old APIs. (CVS 1456) check-in: ae18fcb7 user: danielk1977 tags: trunk
2004-05-25
23:35
Move the sqlite3_exec() function to legacy.c. (CVS 1455) check-in: 9385ad5c user: danielk1977 tags: trunk
12:05
Change a couple of symbol names for the new user function API. (CVS 1454) check-in: 8f6b20c2 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to main.mk.

    55     55   # Object files for the SQLite library.
    56     56   #
    57     57   LIBOBJ = attach.o auth.o btree.o build.o copy.o date.o delete.o \
    58     58            expr.o func.o hash.o insert.o \
    59     59            main.o opcodes.o os_mac.o os_unix.o os_win.o \
    60     60            pager.o parse.o pragma.o printf.o random.o \
    61     61            select.o table.o tokenize.o trigger.o update.o util.o \
    62         -         vacuum.o vdbe.o vdbeaux.o where.o tclsqlite.o utf.o
           62  +         vacuum.o vdbe.o vdbeaux.o where.o tclsqlite.o utf.o legacy.o
    63     63   
    64     64   # All of the source code files.
    65     65   #
    66     66   SRC = \
    67     67     $(TOP)/src/attach.c \
    68     68     $(TOP)/src/auth.c \
    69     69     $(TOP)/src/btree.c \
................................................................................
   236    236   
   237    237   hash.o:	$(TOP)/src/hash.c $(HDR)
   238    238   	$(TCCX) -c $(TOP)/src/hash.c
   239    239   
   240    240   insert.o:	$(TOP)/src/insert.c $(HDR)
   241    241   	$(TCCX) -c $(TOP)/src/insert.c
   242    242   
          243  +legacy.o:	$(TOP)/src/legacy.c $(HDR)
          244  +	$(TCCX) -c $(TOP)/src/legacy.c
   243    245   
   244    246   main.o:	$(TOP)/src/main.c $(HDR)
   245    247   	$(TCCX) -c $(TOP)/src/main.c
   246    248   
   247    249   pager.o:	$(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
   248    250   	$(TCCX) -c $(TOP)/src/pager.c
   249    251   

Changes to src/copy.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to implement the COPY command.
    13     13   **
    14         -** $Id: copy.c,v 1.11 2004/05/10 10:34:35 danielk1977 Exp $
           14  +** $Id: copy.c,v 1.12 2004/05/25 23:35:18 danielk1977 Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   
    18     18   /*
    19     19   ** The COPY command is for compatibility with PostgreSQL and specificially
    20     20   ** for the ability to read the output of pg_dump.  The format is as
    21     21   ** follows:
................................................................................
    96     96       sqlite3VdbeResolveLabel(v, end);
    97     97       sqlite3VdbeAddOp(v, OP_Noop, 0, 0);
    98     98       sqlite3EndWriteOperation(pParse);
    99     99       if( db->flags & SQLITE_CountRows ){
   100    100         sqlite3VdbeAddOp(v, OP_ColumnName, 0, 1);
   101    101         sqlite3VdbeChangeP3(v, -1, "rows inserted", P3_STATIC);
   102    102         sqlite3VdbeAddOp(v, OP_Callback, 1, 0);
          103  +      sqlite3VdbeSetNumCols(v, 1);
   103    104       }
   104    105     }
   105    106     
   106    107   copy_cleanup:
   107    108     sqlite3SrcListDelete(pTableName);
   108    109     sqliteFree(zFile);
   109    110     return;
   110    111   }
   111    112   
   112    113   
   113    114   

Changes to src/delete.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle DELETE FROM statements.
    14     14   **
    15         -** $Id: delete.c,v 1.68 2004/05/19 14:56:56 drh Exp $
           15  +** $Id: delete.c,v 1.69 2004/05/25 23:35:18 danielk1977 Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** Look up every table that is named in pSrc.  If any table is not found,
    21     21   ** add an error message to pParse->zErrMsg and return NULL.  If all tables
    22     22   ** are found, return a pointer to the last table.
................................................................................
   302    302     /*
   303    303     ** Return the number of rows that were deleted.
   304    304     */
   305    305     if( db->flags & SQLITE_CountRows ){
   306    306       sqlite3VdbeAddOp(v, OP_ColumnName, 0, 1);
   307    307       sqlite3VdbeChangeP3(v, -1, "rows deleted", P3_STATIC);
   308    308       sqlite3VdbeAddOp(v, OP_Callback, 1, 0);
          309  +    sqlite3VdbeSetNumCols(v, 1);
   309    310     }
   310    311   
   311    312   delete_from_cleanup:
   312    313     sqlite3AuthContextPop(&sContext);
   313    314     sqlite3SrcListDelete(pTabList);
   314    315     sqlite3ExprDelete(pWhere);
   315    316     return;

Changes to src/insert.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle INSERT statements in SQLite.
    14     14   **
    15         -** $Id: insert.c,v 1.105 2004/05/20 22:16:29 drh Exp $
           15  +** $Id: insert.c,v 1.106 2004/05/25 23:35:18 danielk1977 Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** Set P3 of the most recently inserted opcode to a column affinity
    21     21   ** string for index pIdx. A column affinity string has one character
    22     22   ** for each column in the table, according to the affinity of the column:
................................................................................
   616    616     /*
   617    617     ** Return the number of rows inserted.
   618    618     */
   619    619     if( db->flags & SQLITE_CountRows ){
   620    620       sqlite3VdbeOp3(v, OP_ColumnName, 0, 1, "rows inserted", P3_STATIC);
   621    621       sqlite3VdbeAddOp(v, OP_MemLoad, iCntMem, 0);
   622    622       sqlite3VdbeAddOp(v, OP_Callback, 1, 0);
          623  +    sqlite3VdbeSetNumCols(v, 1);
   623    624     }
   624    625   
   625    626   insert_cleanup:
   626    627     sqlite3SrcListDelete(pTabList);
   627    628     if( pList ) sqlite3ExprListDelete(pList);
   628    629     if( pSelect ) sqlite3SelectDelete(pSelect);
   629    630     sqlite3IdListDelete(pColumn);

Changes to src/main.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Main file for the SQLite library.  The routines in this file
    13     13   ** implement the programmer interface to the library.  Routines in
    14     14   ** other files are for internal use by SQLite and should not be
    15     15   ** accessed by users of the library.
    16     16   **
    17         -** $Id: main.c,v 1.188 2004/05/25 12:05:57 danielk1977 Exp $
           17  +** $Id: main.c,v 1.189 2004/05/25 23:35:18 danielk1977 Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include "os.h"
    21     21   #include <ctype.h>
    22     22   
    23     23   /*
    24     24   ** A pointer to this structure is used to communicate information
................................................................................
   477    477         sqlite3BtreeRollback(db->aDb[i].pBt);
   478    478         db->aDb[i].inTrans = 0;
   479    479       }
   480    480     }
   481    481     sqlite3ResetInternalSchema(db, 0);
   482    482     /* sqlite3RollbackInternalChanges(db); */
   483    483   }
   484         -
   485         -/*
   486         -** Execute SQL code.  Return one of the SQLITE_ success/failure
   487         -** codes.  Also write an error message into memory obtained from
   488         -** malloc() and make *pzErrMsg point to that message.
   489         -**
   490         -** If the SQL is a query, then for each row in the query result
   491         -** the xCallback() function is called.  pArg becomes the first
   492         -** argument to xCallback().  If xCallback=NULL then no callback
   493         -** is invoked, even for queries.
   494         -*/
   495         -int sqlite3_exec(
   496         -  sqlite *db,                 /* The database on which the SQL executes */
   497         -  const char *zSql,           /* The SQL to be executed */
   498         -  sqlite_callback xCallback,  /* Invoke this callback routine */
   499         -  void *pArg,                 /* First argument to xCallback() */
   500         -  char **pzErrMsg             /* Write error messages here */
   501         -){
   502         -  int rc = SQLITE_OK;
   503         -  const char *zLeftover;
   504         -  sqlite_vm *pVm;
   505         -  int nRetry = 0;
   506         -  int nChange = 0;
   507         -  int nCallback;
   508         -
   509         -  if( zSql==0 ) return SQLITE_OK;
   510         -  while( rc==SQLITE_OK && zSql[0] ){
   511         -    pVm = 0;
   512         -    rc = sqlite3_compile(db, zSql, &zLeftover, &pVm, pzErrMsg);
   513         -    if( rc!=SQLITE_OK ){
   514         -      assert( pVm==0 || sqlite3_malloc_failed );
   515         -      return rc;
   516         -    }
   517         -    if( pVm==0 ){
   518         -      /* This happens if the zSql input contained only whitespace */
   519         -      break;
   520         -    }
   521         -    db->nChange += nChange;
   522         -    nCallback = 0;
   523         -    while(1){
   524         -      int nArg;
   525         -      char **azArg, **azCol;
   526         -      rc = sqlite3_step(pVm, &nArg, (const char***)&azArg,(const char***)&azCol);
   527         -      if( rc==SQLITE_ROW ){
   528         -        if( xCallback!=0 && xCallback(pArg, nArg, azArg, azCol) ){
   529         -          sqlite3_finalize(pVm, 0);
   530         -          return SQLITE_ABORT;
   531         -        }
   532         -        nCallback++;
   533         -      }else{
   534         -        if( rc==SQLITE_DONE && nCallback==0
   535         -          && (db->flags & SQLITE_NullCallback)!=0 && xCallback!=0 ){
   536         -          xCallback(pArg, nArg, azArg, azCol);
   537         -        }
   538         -        rc = sqlite3_finalize(pVm, pzErrMsg);
   539         -        if( rc==SQLITE_SCHEMA && nRetry<2 ){
   540         -          nRetry++;
   541         -          rc = SQLITE_OK;
   542         -          break;
   543         -        }
   544         -        if( db->pVdbe==0 ){
   545         -          nChange = db->nChange;
   546         -        }
   547         -        nRetry = 0;
   548         -        zSql = zLeftover;
   549         -        while( isspace(zSql[0]) ) zSql++;
   550         -        break;
   551         -      }
   552         -    }
   553         -  }
   554         -  return rc;
   555         -}
   556         -
   557    484   
   558    485   /*
   559    486   ** Compile a single statement of SQL into a virtual machine.  Return one
   560    487   ** of the SQLITE_ success/failure codes.  Also write an error message into
   561    488   ** memory obtained from malloc() and make *pzErrMsg point to that message.
   562    489   */
   563    490   int sqlite3_compile(
................................................................................
  1070    997     if( sqlite3SafetyOn(db) ){
  1071    998       rc = SQLITE_MISUSE;
  1072    999       goto prepare_out;
  1073   1000     }
  1074   1001   
  1075   1002     if( !db->init.busy ){
  1076   1003       if( (db->flags & SQLITE_Initialized)==0 ){
  1077         -      int rc, cnt = 1;
         1004  +      int cnt = 1;
  1078   1005         while( (rc = sqlite3Init(db, &zErrMsg))==SQLITE_BUSY
  1079   1006            && db->xBusyCallback
  1080   1007            && db->xBusyCallback(db->pBusyArg, "", cnt++)!=0 ){}
  1081   1008         if( rc!=SQLITE_OK ){
  1082   1009           goto prepare_out;
  1083   1010         }
  1084   1011         if( zErrMsg ){
................................................................................
  1128   1055     if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK;
  1129   1056     if( sParse.rc==SQLITE_SCHEMA ){
  1130   1057       sqlite3ResetInternalSchema(db, 0);
  1131   1058     }
  1132   1059     assert( ppStmt );
  1133   1060     *ppStmt = (sqlite3_stmt*)sParse.pVdbe;
  1134   1061     if( pzTail ) *pzTail = sParse.zTail;
  1135         -
  1136         -  if( sqlite3SafetyOff(db) ){
  1137         -    rc = SQLITE_MISUSE;
  1138         -    goto prepare_out;
  1139         -  }
  1140         -
  1141   1062     rc = sParse.rc;
         1063  +
         1064  +  if( rc==SQLITE_OK && sParse.pVdbe && sParse.explain ){
         1065  +    sqlite3VdbeSetNumCols(sParse.pVdbe, 5);
         1066  +  } 
  1142   1067   
  1143   1068   prepare_out:
         1069  +  if( sqlite3SafetyOff(db) ){
         1070  +    rc = SQLITE_MISUSE;
         1071  +  }
  1144   1072     if( zErrMsg ){
  1145   1073       sqlite3Error(db, rc, "%s", zErrMsg);
  1146   1074     }else{
  1147   1075       sqlite3Error(db, rc, 0);
  1148   1076     }
  1149   1077     return rc;
  1150   1078   }

Changes to src/pragma.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to implement the PRAGMA command.
    13     13   **
    14         -** $Id: pragma.c,v 1.28 2004/05/22 21:30:41 drh Exp $
           14  +** $Id: pragma.c,v 1.29 2004/05/25 23:35:18 danielk1977 Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   #include <ctype.h>
    18     18   
    19     19   /*
    20     20   ** Interpret the given string as a boolean value.
    21     21   */
................................................................................
   125    125     };
   126    126     int i;
   127    127     for(i=0; i<sizeof(aPragma)/sizeof(aPragma[0]); i++){
   128    128       if( sqlite3StrICmp(zLeft, aPragma[i].zName)==0 ){
   129    129         sqlite *db = pParse->db;
   130    130         Vdbe *v;
   131    131         if( strcmp(zLeft,zRight)==0 && (v = sqlite3GetVdbe(pParse))!=0 ){
          132  +        sqlite3VdbeSetNumCols(v, 1);
   132    133           sqlite3VdbeOp3(v, OP_ColumnName, 0, 1, aPragma[i].zName, P3_STATIC);
   133    134           sqlite3VdbeOp3(v, OP_ColumnName, 1, 0, "boolean", P3_STATIC);
   134    135           sqlite3VdbeCode(v, OP_Integer, (db->flags & aPragma[i].mask)!=0, 0,
   135    136                             OP_Callback, 1, 0,
   136    137                             0);
   137    138         }else if( getBoolean(zRight) ){
   138    139           db->flags |= aPragma[i].mask;
................................................................................
   203    204         { OP_Ne,          0, 6,        0},
   204    205         { OP_Integer,     0, 0,        0},  /* 5 */
   205    206         { OP_ColumnName,  0, 1,        "cache_size"},
   206    207         { OP_Callback,    1, 0,        0},
   207    208       };
   208    209       int addr;
   209    210       if( pRight->z==pLeft->z ){
          211  +      sqlite3VdbeSetNumCols(v, 1);
   210    212         addr = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize);
   211    213         sqlite3VdbeChangeP1(v, addr+5, MAX_PAGES);
   212    214       }else{
   213    215         int size = atoi(zRight);
   214    216         if( size<0 ) size = -size;
   215    217         sqlite3BeginWriteOperation(pParse, 0, 0);
   216    218         sqlite3VdbeAddOp(v, OP_Integer, size, 0);
................................................................................
   244    246         { OP_ColumnName,  0, 1,        "cache_size"},
   245    247         { OP_Callback,    1, 0,        0},
   246    248       };
   247    249       if( pRight->z==pLeft->z ){
   248    250         int size = db->cache_size;;
   249    251         if( size<0 ) size = -size;
   250    252         sqlite3VdbeAddOp(v, OP_Integer, size, 0);
          253  +      sqlite3VdbeSetNumCols(v, 1);
   251    254         sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize);
   252    255       }else{
   253    256         int size = atoi(zRight);
   254    257         if( size<0 ) size = -size;
   255    258         if( db->cache_size<0 ) size = -size;
   256    259         db->cache_size = size;
   257    260         sqlite3BtreeSetCacheSize(db->aDb[0].pBt, db->cache_size);
................................................................................
   289    292         { OP_AddImm,      1, 0,        0},
   290    293         { OP_Callback,    1, 0,        0},
   291    294         { OP_Halt,        0, 0,        0},
   292    295         { OP_AddImm,     -1, 0,        0},  /* 10 */
   293    296         { OP_Callback,    1, 0,        0}
   294    297       };
   295    298       if( pRight->z==pLeft->z ){
          299  +      sqlite3VdbeSetNumCols(v, 1);
   296    300         int addr = sqlite3VdbeAddOpList(v, ArraySize(getSync), getSync);
   297    301         sqlite3VdbeChangeP2(v, addr+3, addr+10);
   298    302       }else{
   299    303         int addr;
   300    304         int size = db->cache_size;
   301    305         if( size<0 ) size = -size;
   302    306         sqlite3BeginWriteOperation(pParse, 0, 0);
................................................................................
   332    336     */
   333    337     if( sqlite3StrICmp(zLeft,"synchronous")==0 ){
   334    338       static VdbeOpList getSync[] = {
   335    339         { OP_ColumnName,  0, 1,        "synchronous"},
   336    340         { OP_Callback,    1, 0,        0},
   337    341       };
   338    342       if( pRight->z==pLeft->z ){
          343  +      sqlite3VdbeSetNumCols(v, 1);
   339    344         sqlite3VdbeAddOp(v, OP_Integer, db->safety_level-1, 0);
   340    345         sqlite3VdbeAddOpList(v, ArraySize(getSync), getSync);
   341    346       }else{
   342    347         int size = db->cache_size;
   343    348         if( size<0 ) size = -size;
   344    349         db->safety_level = getSafetyLevel(zRight)+1;
   345    350         if( db->safety_level==1 ) size = -size;
................................................................................
   372    377           { OP_ColumnName,  1, 0,       "name"},
   373    378           { OP_ColumnName,  2, 0,       "type"},
   374    379           { OP_ColumnName,  3, 0,       "notnull"},
   375    380           { OP_ColumnName,  4, 0,       "dflt_value"},
   376    381           { OP_ColumnName,  5, 1,       "pk"},
   377    382         };
   378    383         int i;
          384  +      sqlite3VdbeSetNumCols(v, 6);
   379    385         sqlite3VdbeAddOpList(v, ArraySize(tableInfoPreface), tableInfoPreface);
   380    386         sqlite3ViewGetColumnNames(pParse, pTab);
   381    387         for(i=0; i<pTab->nCol; i++){
   382    388           sqlite3VdbeAddOp(v, OP_Integer, i, 0);
   383    389           sqlite3VdbeOp3(v, OP_String, 0, 0, pTab->aCol[i].zName, 0);
   384    390           sqlite3VdbeOp3(v, OP_String, 0, 0,
   385    391              pTab->aCol[i].zType ? pTab->aCol[i].zType : "numeric", 0);
................................................................................
   400    406         static VdbeOpList tableInfoPreface[] = {
   401    407           { OP_ColumnName,  0, 0,       "seqno"},
   402    408           { OP_ColumnName,  1, 0,       "cid"},
   403    409           { OP_ColumnName,  2, 1,       "name"},
   404    410         };
   405    411         int i;
   406    412         pTab = pIdx->pTable;
          413  +      sqlite3VdbeSetNumCols(v, 3);
   407    414         sqlite3VdbeAddOpList(v, ArraySize(tableInfoPreface), tableInfoPreface);
   408    415         for(i=0; i<pIdx->nColumn; i++){
   409    416           int cnum = pIdx->aiColumn[i];
   410    417           sqlite3VdbeAddOp(v, OP_Integer, i, 0);
   411    418           sqlite3VdbeAddOp(v, OP_Integer, cnum, 0);
   412    419           assert( pTab->nCol>cnum );
   413    420           sqlite3VdbeOp3(v, OP_String, 0, 0, pTab->aCol[cnum].zName, 0);
................................................................................
   428    435         int i = 0; 
   429    436         static VdbeOpList indexListPreface[] = {
   430    437           { OP_ColumnName,  0, 0,       "seq"},
   431    438           { OP_ColumnName,  1, 0,       "name"},
   432    439           { OP_ColumnName,  2, 1,       "unique"},
   433    440         };
   434    441   
          442  +      sqlite3VdbeSetNumCols(v, 3);
   435    443         sqlite3VdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface);
   436    444         while(pIdx){
   437    445           sqlite3VdbeAddOp(v, OP_Integer, i, 0);
   438    446           sqlite3VdbeOp3(v, OP_String, 0, 0, pIdx->zName, 0);
   439    447           sqlite3VdbeAddOp(v, OP_Integer, pIdx->onError!=OE_None, 0);
   440    448           sqlite3VdbeAddOp(v, OP_Callback, 3, 0);
   441    449           ++i;
................................................................................
   458    466           { OP_ColumnName,  0, 0,       "id"},
   459    467           { OP_ColumnName,  1, 0,       "seq"},
   460    468           { OP_ColumnName,  2, 0,       "table"},
   461    469           { OP_ColumnName,  3, 0,       "from"},
   462    470           { OP_ColumnName,  4, 1,       "to"},
   463    471         };
   464    472   
          473  +      sqlite3VdbeSetNumCols(v, 6);
   465    474         sqlite3VdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface);
   466    475         while(pFK){
   467    476           int j;
   468    477           for(j=0; j<pFK->nCol; j++){
   469    478             sqlite3VdbeAddOp(v, OP_Integer, i, 0);
   470    479             sqlite3VdbeAddOp(v, OP_Integer, j, 0);
   471    480             sqlite3VdbeOp3(v, OP_String, 0, 0, pFK->zTo, 0);
................................................................................
   484    493       int i;
   485    494       static VdbeOpList indexListPreface[] = {
   486    495         { OP_ColumnName,  0, 0,       "seq"},
   487    496         { OP_ColumnName,  1, 0,       "name"},
   488    497         { OP_ColumnName,  2, 1,       "file"},
   489    498       };
   490    499   
          500  +    sqlite3VdbeSetNumCols(v, 3);
   491    501       sqlite3VdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface);
   492    502       for(i=0; i<db->nDb; i++){
   493    503         if( db->aDb[i].pBt==0 ) continue;
   494    504         assert( db->aDb[i].zName!=0 );
   495    505         sqlite3VdbeAddOp(v, OP_Integer, i, 0);
   496    506         sqlite3VdbeOp3(v, OP_String, 0, 0, db->aDb[i].zName, 0);
   497    507         sqlite3VdbeOp3(v, OP_String, 0, 0,
................................................................................
   515    525     if( sqlite3StrICmp(zLeft, "temp_store")==0 ){
   516    526       static VdbeOpList getTmpDbLoc[] = {
   517    527         { OP_ColumnName,  0, 1,        "temp_store"},
   518    528         { OP_Callback,    1, 0,        0},
   519    529       };
   520    530       if( pRight->z==pLeft->z ){
   521    531         sqlite3VdbeAddOp(v, OP_Integer, db->temp_store, 0);
          532  +      sqlite3VdbeSetNumCols(v, 1);
   522    533         sqlite3VdbeAddOpList(v, ArraySize(getTmpDbLoc), getTmpDbLoc);
   523    534       }else{
   524    535         changeTempStorage(pParse, zRight);
   525    536       }
   526    537     }else
   527    538   
   528    539     /*
................................................................................
   538    549     */
   539    550     if( sqlite3StrICmp(zLeft, "default_temp_store")==0 ){
   540    551       static VdbeOpList getTmpDbLoc[] = {
   541    552         { OP_ColumnName,  0, 1,        "temp_store"},
   542    553         { OP_ReadCookie,  0, 5,        0},
   543    554         { OP_Callback,    1, 0,        0}};
   544    555       if( pRight->z==pLeft->z ){
          556  +      sqlite3VdbeSetNumCols(v, 1);
   545    557         sqlite3VdbeAddOpList(v, ArraySize(getTmpDbLoc), getTmpDbLoc);
   546    558       }else{
   547    559         sqlite3BeginWriteOperation(pParse, 0, 0);
   548    560         sqlite3VdbeAddOp(v, OP_Integer, getTempStore(zRight), 0);
   549    561         sqlite3VdbeAddOp(v, OP_SetCookie, 0, 5);
   550    562         sqlite3EndWriteOperation(pParse);
   551    563       }
................................................................................
   583    595         { OP_Integer,     0, 0,        0},
   584    596         { OP_Ne,          0, 0,        0},    /* 2 */
   585    597         { OP_String,      0, 0,        "ok"},
   586    598         { OP_Callback,    1, 0,        0},
   587    599       };
   588    600   
   589    601       /* Initialize the VDBE program */
          602  +    sqlite3VdbeSetNumCols(v, 1);
   590    603       sqlite3VdbeAddOpList(v, ArraySize(initCode), initCode);
   591    604   
   592    605       /* Do an integrity check on each database file */
   593    606       for(i=0; i<db->nDb; i++){
   594    607         HashElem *x;
   595    608         int cnt = 0;
   596    609   

Changes to src/select.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle SELECT statements in SQLite.
    14     14   **
    15         -** $Id: select.c,v 1.174 2004/05/21 03:01:59 drh Exp $
           15  +** $Id: select.c,v 1.175 2004/05/25 23:35:19 danielk1977 Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   
    20     20   /*
    21     21   ** Allocate a new Select structure and return a pointer to that
    22     22   ** structure.
................................................................................
   683    683     int fullNames, shortNames;
   684    684   
   685    685     assert( v!=0 );
   686    686     if( pParse->colNamesSet || v==0 || sqlite3_malloc_failed ) return;
   687    687     pParse->colNamesSet = 1;
   688    688     fullNames = (db->flags & SQLITE_FullColNames)!=0;
   689    689     shortNames = (db->flags & SQLITE_ShortColNames)!=0;
          690  +  sqlite3VdbeSetNumCols(v, pEList->nExpr);
   690    691     for(i=0; i<pEList->nExpr; i++){
   691    692       Expr *p;
   692    693       int p2 = i==pEList->nExpr-1;
   693    694       p = pEList->a[i].pExpr;
   694    695       if( p==0 ) continue;
   695    696       if( pEList->a[i].zName ){
   696    697         char *zName = pEList->a[i].zName;

Changes to src/sqlite.h.in.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This header file defines the interface that the SQLite library
    13     13   ** presents to client programs.
    14     14   **
    15         -** @(#) $Id: sqlite.h.in,v 1.76 2004/05/25 12:05:57 danielk1977 Exp $
           15  +** @(#) $Id: sqlite.h.in,v 1.77 2004/05/25 23:35:19 danielk1977 Exp $
    16     16   */
    17     17   #ifndef _SQLITE_H_
    18     18   #define _SQLITE_H_
    19     19   #include <stdarg.h>     /* Needed for the definition of va_list */
    20     20   
    21     21   /*
    22     22   ** Make sure we can call this stuff from C++.
................................................................................
  1055   1055   ** The first parameter is a compiled SQL statement. If this statement
  1056   1056   ** is a SELECT statement, the Nth column of the returned result set 
  1057   1057   ** of the SELECT is a table column then the declared type of the table
  1058   1058   ** column is returned. If the Nth column of the result set is not at table
  1059   1059   ** column, then a NULL pointer is returned. The returned string is always
  1060   1060   ** UTF-8 encoded. For example, in the database schema:
  1061   1061   **
  1062         -** CREATE TABLE t1(c1 VARINT);
         1062  +** CREATE TABLE t1(c1 VARIANT);
  1063   1063   **
  1064   1064   ** And the following statement compiled:
  1065   1065   **
  1066   1066   ** SELECT c1 + 1, 0 FROM t1;
  1067   1067   **
  1068   1068   ** Then this routine would return the string "VARIANT" for the second
  1069   1069   ** result column (i==1), and a NULL pointer for the first result column

Changes to src/test1.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing the printf() interface to SQLite.  This code
    13     13   ** is not included in the SQLite library.  It is used for automated
    14     14   ** testing of the SQLite library.
    15     15   **
    16         -** $Id: test1.c,v 1.51 2004/05/25 12:05:57 danielk1977 Exp $
           16  +** $Id: test1.c,v 1.52 2004/05/25 23:35:19 danielk1977 Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "tcl.h"
    20     20   #include "os.h"
    21     21   #include <stdlib.h>
    22     22   #include <string.h>
    23     23   
................................................................................
   760    760   
   761    761   /*
   762    762   ** Usage:  sqlite3_step  VM  ?NVAR?  ?VALUEVAR?  ?COLNAMEVAR?
   763    763   **
   764    764   ** Step a virtual machine.  Return a the result code as a string.
   765    765   ** Column results are written into three variables.
   766    766   */
          767  +#if 0
   767    768   static int test_step(
   768    769     void *NotUsed,
   769    770     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
   770    771     int argc,              /* Number of arguments */
   771    772     char **argv            /* Text of each argument */
   772    773   ){
   773    774     sqlite_vm *vm;
................................................................................
   813    814       case SQLITE_ERROR:  zRc = "SQLITE_ERROR";   break;
   814    815       case SQLITE_MISUSE: zRc = "SQLITE_MISUSE";  break;
   815    816       default:            zRc = "unknown";        break;
   816    817     }
   817    818     Tcl_AppendResult(interp, zRc, 0);
   818    819     return TCL_OK;
   819    820   }
          821  +#endif
   820    822   
   821    823   /*
   822    824   ** Usage:  sqlite3_finalize  STMT 
   823    825   **
   824    826   ** Finalize a statement handle.
   825    827   */
   826    828   static int test_finalize(
................................................................................
  1558   1560        Tcl_CmdProc *xProc;
  1559   1561     } aCmd[] = {
  1560   1562        { "sqlite3_mprintf_int",           (Tcl_CmdProc*)sqlite3_mprintf_int    },
  1561   1563        { "sqlite3_mprintf_str",           (Tcl_CmdProc*)sqlite3_mprintf_str    },
  1562   1564        { "sqlite3_mprintf_double",        (Tcl_CmdProc*)sqlite3_mprintf_double },
  1563   1565        { "sqlite3_mprintf_scaled",        (Tcl_CmdProc*)sqlite3_mprintf_scaled },
  1564   1566        { "sqlite3_mprintf_z_test",        (Tcl_CmdProc*)test_mprintf_z        },
  1565         -//     { "sqlite3_open",                  (Tcl_CmdProc*)sqlite_test_open      },
  1566   1567        { "sqlite3_last_insert_rowid",     (Tcl_CmdProc*)test_last_rowid       },
  1567   1568        { "sqlite3_exec_printf",           (Tcl_CmdProc*)test_exec_printf      },
  1568   1569        { "sqlite3_get_table_printf",      (Tcl_CmdProc*)test_get_table_printf },
  1569   1570        { "sqlite3_close",                 (Tcl_CmdProc*)sqlite_test_close     },
  1570   1571        { "sqlite3_create_function",       (Tcl_CmdProc*)test_create_function  },
  1571   1572        { "sqlite3_create_aggregate",      (Tcl_CmdProc*)test_create_aggregate },
  1572   1573        { "sqlite_register_test_function", (Tcl_CmdProc*)test_register_func    },
  1573   1574        { "sqlite_abort",                  (Tcl_CmdProc*)sqlite_abort          },
  1574   1575        { "sqlite_datatypes",              (Tcl_CmdProc*)sqlite_datatypes      },
  1575   1576   #ifdef MEMORY_DEBUG
  1576   1577        { "sqlite_malloc_fail",            (Tcl_CmdProc*)sqlite_malloc_fail    },
  1577   1578        { "sqlite_malloc_stat",            (Tcl_CmdProc*)sqlite_malloc_stat    },
  1578   1579   #endif
  1579         -     { "sqlite_step",                    (Tcl_CmdProc*)test_step             },
  1580         -// { "sqlite_finalize",                (Tcl_CmdProc*)test_finalize         },
         1580  +/*{ "sqlite_step",                    (Tcl_CmdProc*)test_step * },*/
  1581   1581        { "sqlite_bind",                    (Tcl_CmdProc*)test_bind             },
  1582         -// { "sqlite_reset",                   (Tcl_CmdProc*)test_reset            },
  1583   1582        { "breakpoint",                     (Tcl_CmdProc*)test_breakpoint       },
  1584   1583     };
  1585   1584     static struct {
  1586   1585        char *zName;
  1587   1586        Tcl_ObjCmdProc *xProc;
  1588   1587     } aObjCmd[] = {
  1589   1588        { "sqlite3_bind_int32",            (Tcl_ObjCmdProc*)test_bind_int32    },

Changes to src/update.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle UPDATE statements.
    14     14   **
    15         -** $Id: update.c,v 1.78 2004/05/20 22:16:30 drh Exp $
           15  +** $Id: update.c,v 1.79 2004/05/25 23:35:19 danielk1977 Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** Process an UPDATE statement.
    21     21   **
    22     22   **   UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL;
................................................................................
   444    444   
   445    445     /*
   446    446     ** Return the number of rows that were changed.
   447    447     */
   448    448     if( db->flags & SQLITE_CountRows && !pParse->trigStack ){
   449    449       sqlite3VdbeOp3(v, OP_ColumnName, 0, 1, "rows updated", P3_STATIC);
   450    450       sqlite3VdbeAddOp(v, OP_Callback, 1, 0);
          451  +    sqlite3VdbeSetNumCols(v, 1);
   451    452     }
   452    453   
   453    454   update_cleanup:
   454    455     sqlite3AuthContextPop(&sContext);
   455    456     sqliteFree(apIdx);
   456    457     sqliteFree(aXRef);
   457    458     sqlite3SrcListDelete(pTabList);
   458    459     sqlite3ExprListDelete(pChanges);
   459    460     sqlite3ExprDelete(pWhere);
   460    461     return;
   461    462   }

Changes to src/vdbe.c.

    39     39   **
    40     40   ** Various scripts scan this source file in order to generate HTML
    41     41   ** documentation, headers files, or other derived files.  The formatting
    42     42   ** of the code in this file is, therefore, important.  See other comments
    43     43   ** in this file for details.  If in doubt, do not deviate from existing
    44     44   ** commenting and indentation practices when changing or adding code.
    45     45   **
    46         -** $Id: vdbe.c,v 1.328 2004/05/25 11:47:26 danielk1977 Exp $
           46  +** $Id: vdbe.c,v 1.329 2004/05/25 23:35:19 danielk1977 Exp $
    47     47   */
    48     48   #include "sqliteInt.h"
    49     49   #include "os.h"
    50     50   #include <ctype.h>
    51     51   #include "vdbeInt.h"
    52     52   
    53     53   /*
................................................................................
   523    523   **
   524    524   ** SQLITE_MISUSE means that the this routine was called inappropriately.
   525    525   ** Perhaps it was called on a virtual machine that had already been
   526    526   ** finalized or on one that had previously returned SQLITE_ERROR or
   527    527   ** SQLITE_DONE.  Or it could be the case the the same database connection
   528    528   ** is being used simulataneously by two or more threads.
   529    529   */
          530  +#if 0
   530    531   int sqlite3_step(
   531    532     sqlite_vm *pVm,              /* The virtual machine to execute */
   532    533     int *pN,                     /* OUT: Number of columns in result */
   533    534     const char ***pazValue,      /* OUT: Column data */
   534    535     const char ***pazColName     /* OUT: Column names and datatypes */
   535    536   ){
   536    537     sqlite3_stmt *pStmt = (sqlite3_stmt*)pVm;
................................................................................
   564    565           (*pazValue)[i] = sqlite3_column_data(pStmt, i);
   565    566         }
   566    567       }
   567    568     }
   568    569   
   569    570     return rc;
   570    571   }
          572  +#endif 
   571    573   
   572    574   /*
   573    575   ** Execute the statement pStmt, either until a row of data is ready, the
   574    576   ** statement is completely executed or an error occurs.
   575    577   */
   576    578   int sqlite3_step_new(sqlite3_stmt *pStmt){
   577    579     Vdbe *p = (Vdbe*)pStmt;
................................................................................
  2086   2088   ** number of columns specified in OP_Callback must one more than the P1
  2087   2089   ** value of the OP_ColumnName that has P2==1.
  2088   2090   */
  2089   2091   case OP_ColumnName: {
  2090   2092     assert( pOp->p1>=0 && pOp->p1<p->nOp );
  2091   2093     p->azColName[pOp->p1] = pOp->p3;
  2092   2094     p->nCallback = 0;
  2093         -  if( pOp->p2 ) p->nResColumn = pOp->p1+1;
         2095  +  assert( !pOp->p2 || p->nResColumn==(pOp->p1+1) );
         2096  +  /* if( pOp->p2 ) p->nResColumn = pOp->p1+1; */
  2094   2097     break;
  2095   2098   }
  2096   2099   
  2097   2100   /* Opcode: Callback P1 * *
  2098   2101   **
  2099   2102   ** Pop P1 values off the stack and form them into an array.  Then
  2100   2103   ** invoke the callback function using the newly formed array as the
................................................................................
  2343   2346   ** Pop all arguments from the stack and push back the result.
  2344   2347   **
  2345   2348   ** See also: AggFunc
  2346   2349   */
  2347   2350   case OP_Function: {
  2348   2351     int i;
  2349   2352     Mem *pArg;
  2350         -  sqlite_func ctx;
         2353  +  sqlite3_context ctx;
  2351   2354     sqlite3_value **apVal;
  2352   2355     int n = pOp->p1;
  2353   2356   
  2354   2357     n = pOp->p1;
  2355   2358     apVal = p->apArg;
  2356   2359     assert( apVal || n==0 );
  2357   2360   
................................................................................
  5689   5692   ** Ideally, this index would be another parameter, but there are
  5690   5693   ** no free parameters left.  The integer is popped from the stack.
  5691   5694   */
  5692   5695   case OP_AggFunc: {
  5693   5696     int n = pOp->p2;
  5694   5697     int i;
  5695   5698     Mem *pMem, *pRec;
  5696         -  sqlite_func ctx;
         5699  +  sqlite3_context ctx;
  5697   5700     sqlite3_value **apVal;
  5698   5701   
  5699   5702     assert( n>=0 );
  5700   5703     assert( pTos->flags==MEM_Int );
  5701   5704     pRec = &pTos[-n];
  5702   5705     assert( pRec>=p->aStack );
  5703   5706   
................................................................................
  5836   5839     }else{
  5837   5840       p->agg.pSearch = sqliteHashNext(p->agg.pSearch);
  5838   5841     }
  5839   5842     if( p->agg.pSearch==0 ){
  5840   5843       pc = pOp->p2 - 1;
  5841   5844     } else {
  5842   5845       int i;
  5843         -    sqlite_func ctx;
         5846  +    sqlite3_context ctx;
  5844   5847       Mem *aMem;
  5845   5848       p->agg.pCurrent = sqliteHashData(p->agg.pSearch);
  5846   5849       aMem = p->agg.pCurrent->aMem;
  5847   5850       for(i=0; i<p->agg.nMem; i++){
  5848   5851         int freeCtx;
  5849   5852         if( p->agg.apFunc[i]==0 ) continue;
  5850   5853         if( p->agg.apFunc[i]->xFinalize==0 ) continue;

Changes to src/vdbe.h.

    11     11   *************************************************************************
    12     12   ** Header file for the Virtual DataBase Engine (VDBE)
    13     13   **
    14     14   ** This header defines the interface to the virtual database engine
    15     15   ** or VDBE.  The VDBE implements an abstract machine that runs a
    16     16   ** simple program to access and modify the underlying database.
    17     17   **
    18         -** $Id: vdbe.h,v 1.81 2004/05/21 10:08:55 danielk1977 Exp $
           18  +** $Id: vdbe.h,v 1.82 2004/05/25 23:35:20 danielk1977 Exp $
    19     19   */
    20     20   #ifndef _SQLITE_VDBE_H_
    21     21   #define _SQLITE_VDBE_H_
    22     22   #include <stdio.h>
    23     23   
    24     24   /*
    25     25   ** A single VDBE is an opaque structure named "Vdbe".  Only routines
................................................................................
   116    116   int sqlite3VdbeFinalize(Vdbe*,char**);
   117    117   void sqlite3VdbeResolveLabel(Vdbe*, int);
   118    118   int sqlite3VdbeCurrentAddr(Vdbe*);
   119    119   void sqlite3VdbeTrace(Vdbe*,FILE*);
   120    120   void sqlite3VdbeCompressSpace(Vdbe*,int);
   121    121   int sqlite3VdbeReset(Vdbe*,char **);
   122    122   int sqliteVdbeSetVariables(Vdbe*,int,const char**);
          123  +void sqlite3VdbeSetNumCols(Vdbe*,int);
   123    124   
   124    125   #ifndef NDEBUG
   125    126     void sqlite3VdbeComment(Vdbe*, const char*, ...);
   126    127   # define VdbeComment(X)  sqlite3VdbeComment X
   127    128   #else
   128    129   # define VdbeComment(X)
   129    130   #endif
   130    131   
   131    132   #endif

Changes to src/vdbeaux.c.

   861    861       p->keylistStack = 0;
   862    862     }
   863    863     sqliteFree(p->contextStack);
   864    864     p->contextStack = 0;
   865    865     sqliteFree(p->zErrMsg);
   866    866     p->zErrMsg = 0;
   867    867   }
          868  +
          869  +/*
          870  +** Set the number of result columns that will be returned by this SQL
          871  +** statement. This is now set at compile time, rather than during
          872  +** execution of the vdbe program so that sqlite3_column_count() can
          873  +** be called on an SQL statement before sqlite3_step().
          874  +*/
          875  +void sqlite3VdbeSetNumCols(Vdbe *p, int nResColumn){
          876  +  p->nResColumn = nResColumn;
          877  +}
   868    878   
   869    879   /*
   870    880   ** Clean up a VDBE after execution but do not delete the VDBE just yet.
   871    881   ** Write any error messages into *pzErrMsg.  Return the result code.
   872    882   **
   873    883   ** After this routine is run, the VDBE should be ready to be executed
   874    884   ** again.