/ Check-in [65d2100d]
Login

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

Overview
Comment::-) (CVS 63)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:65d2100d33350e6bce30d4d75f3cead9fcab3efb
User & Date: drh 2000-06-06 22:13:55
Context
2000-06-06
22:19
:-) (CVS 64) check-in: 3a2f4dca user: drh tags: trunk
22:13
:-) (CVS 63) check-in: 65d2100d user: drh tags: trunk
21:56
:-) (CVS 62) check-in: f4d9089c user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/select.c.

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
...
178
179
180
181
182
183
184

185
186
187
188
189
190
191
...
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
**   drh@hwaci.com
**   http://www.hwaci.com/drh/
**
*************************************************************************
** This file contains C code routines that are called by the parser
** to handle SELECT statements.
**
** $Id: select.c,v 1.13 2000/06/06 21:56:08 drh Exp $
*/
#include "sqliteInt.h"

/*
** Allocate a new Select structure and return a pointer to that
** structure.
*/
................................................................................
  }else 

  /* Construct a record from the query result, but instead of
  ** saving that record, use it as a key to delete elements from
  ** the temporary table iParm.
  */
  if( eDest==SRT_Except ){
    assert( pEList->nExpr==1 );
    sqliteVdbeAddOp(v, OP_String, 0, 0, "", 0);
    sqliteVdbeAddOp(v, OP_Put, iParm, 0, 0, 0);
  }else 

  /* If we are creating a set for an "expr IN (SELECT ...)" construct,
  ** then there should be a single item on the stack.  Write this
  ** item into the set table with bogus data.
  */
  if( eDest==SRT_Set ){
................................................................................


  /* If this is a scalar select that is part of an expression, then
  ** store the results in the appropriate memory cell and break out
  ** of the scan loop.
  */
  if( eDest==SRT_Mem ){

    sqliteVdbeAddOp(v, OP_MemStore, iParm, 0, 0, 0);
    sqliteVdbeAddOp(v, OP_Goto, 0, iBreak, 0, 0);
  }else

  /* If none of the above, send the data to the callback function.
  */
  {
................................................................................
        sqliteVdbeAddOp(v, OP_Goto, 0, iCont, 0, 0);
        sqliteVdbeAddOp(v, OP_Close, unionTab, 0, 0, iBreak);
      }
      break;
    }
    case TK_INTERSECT: {
      int tab1, tab2;
      Select *pPrior;
      int iCont, iBreak;

      tab1 = pParse->nTab++;
      tab2 = pParse->nTab++;
      sqliteVdbeAddOp(v, OP_Open, tab1, 1, 0, 0);
      sqliteVdbeAddOp(v, OP_KeyAsData, tab1, 1, 0, 0);
      rc = sqliteSelect(pParse, pPrior, SRT_Union, tab1);







|







 







<
|
|







 







>







 







<







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
...
157
158
159
160
161
162
163

164
165
166
167
168
169
170
171
172
...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
...
302
303
304
305
306
307
308

309
310
311
312
313
314
315
**   drh@hwaci.com
**   http://www.hwaci.com/drh/
**
*************************************************************************
** This file contains C code routines that are called by the parser
** to handle SELECT statements.
**
** $Id: select.c,v 1.14 2000/06/06 22:13:55 drh Exp $
*/
#include "sqliteInt.h"

/*
** Allocate a new Select structure and return a pointer to that
** structure.
*/
................................................................................
  }else 

  /* Construct a record from the query result, but instead of
  ** saving that record, use it as a key to delete elements from
  ** the temporary table iParm.
  */
  if( eDest==SRT_Except ){

    sqliteVdbeAddOp(v, OP_MakeRecord, nField, 0, 0, 0);
    sqliteVdbeAddOp(v, OP_Delete, iParm, 0, 0, 0);
  }else 

  /* If we are creating a set for an "expr IN (SELECT ...)" construct,
  ** then there should be a single item on the stack.  Write this
  ** item into the set table with bogus data.
  */
  if( eDest==SRT_Set ){
................................................................................


  /* If this is a scalar select that is part of an expression, then
  ** store the results in the appropriate memory cell and break out
  ** of the scan loop.
  */
  if( eDest==SRT_Mem ){
    assert( pEList->nExpr==1 );
    sqliteVdbeAddOp(v, OP_MemStore, iParm, 0, 0, 0);
    sqliteVdbeAddOp(v, OP_Goto, 0, iBreak, 0, 0);
  }else

  /* If none of the above, send the data to the callback function.
  */
  {
................................................................................
        sqliteVdbeAddOp(v, OP_Goto, 0, iCont, 0, 0);
        sqliteVdbeAddOp(v, OP_Close, unionTab, 0, 0, iBreak);
      }
      break;
    }
    case TK_INTERSECT: {
      int tab1, tab2;

      int iCont, iBreak;

      tab1 = pParse->nTab++;
      tab2 = pParse->nTab++;
      sqliteVdbeAddOp(v, OP_Open, tab1, 1, 0, 0);
      sqliteVdbeAddOp(v, OP_KeyAsData, tab1, 1, 0, 0);
      rc = sqliteSelect(pParse, pPrior, SRT_Union, tab1);

Changes to src/vdbe.c.

37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
....
1962
1963
1964
1965
1966
1967
1968





1969
1970

1971
1972
1973
1974
1975
1976
1977
** inplicit conversion from one type to the other occurs as necessary.
** 
** Most of the code in this file is taken up by the sqliteVdbeExec()
** function which does the work of interpreting a VDBE program.
** But other routines are also provided to help in building up
** a program instruction by instruction.
**
** $Id: vdbe.c,v 1.23 2000/06/06 21:56:08 drh Exp $
*/
#include "sqliteInt.h"
#include <unistd.h>

/*
** SQL is translated into a sequence of instructions to be
** executed by a virtual machine.  Each instruction is an instance
................................................................................
        int i = pOp->p1;
        int tos = ++p->tos;
        DbbeTable *pTab;

        if( NeedStack(p, p->tos) ) goto no_mem;
        if( i>=0 && i<p->nTable && (pTab = p->aTab[i].pTable)!=0 ){
          char *z = sqliteDbbeReadKey(pTab, 0);





          memcpy(&p->aStack[tos].i, z, sizeof(int));
          p->aStack[tos].flags = STK_Int;

        }
        break;
      }

      /* Opcode: Rewind P1 * *
      **
      ** The next use of the Key or Field or Next instruction for P1 







|







 







>
>
>
>
>
|
|
>







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
....
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
** inplicit conversion from one type to the other occurs as necessary.
** 
** Most of the code in this file is taken up by the sqliteVdbeExec()
** function which does the work of interpreting a VDBE program.
** But other routines are also provided to help in building up
** a program instruction by instruction.
**
** $Id: vdbe.c,v 1.24 2000/06/06 22:13:55 drh Exp $
*/
#include "sqliteInt.h"
#include <unistd.h>

/*
** SQL is translated into a sequence of instructions to be
** executed by a virtual machine.  Each instruction is an instance
................................................................................
        int i = pOp->p1;
        int tos = ++p->tos;
        DbbeTable *pTab;

        if( NeedStack(p, p->tos) ) goto no_mem;
        if( i>=0 && i<p->nTable && (pTab = p->aTab[i].pTable)!=0 ){
          char *z = sqliteDbbeReadKey(pTab, 0);
          if( p->aTab[i].keyAsData ){
            p->zStack[tos] = z;
            p->aStack[tos].flags = STK_Str;
            p->aStack[tos].n = sqliteDbbeKeyLength(pTab);
          }else{
            memcpy(&p->aStack[tos].i, z, sizeof(int));
            p->aStack[tos].flags = STK_Int;
          }
        }
        break;
      }

      /* Opcode: Rewind P1 * *
      **
      ** The next use of the Key or Field or Next instruction for P1