SQLite

Check-in [bad8b55833]
Login

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

Overview
Comment:In a SELECT, the rowid of a view or subquery which is really a join is set to NULL if the join is flattened. Ticket #364. (CVS 1034)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: bad8b55833f5120003a19883154dac5146cc36a3
User & Date: drh 2003-06-24 10:39:46.000
Context
2003-06-28
16:20
Fix a bug in the soundex() code. Ticket #367. Add tests for ticket #261 even thought the problem could not be reproduced. (CVS 1035) (check-in: e2ca936fee user: drh tags: trunk)
2003-06-24
10:39
In a SELECT, the rowid of a view or subquery which is really a join is set to NULL if the join is flattened. Ticket #364. (CVS 1034) (check-in: bad8b55833 user: drh tags: trunk)
2003-06-23
15:15
Remove a surplus "return" statement accidentaly left in check-in (1032). (CVS 1033) (check-in: c697410af4 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbe.c.
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
**
** Various scripts scan this source file in order to generate HTML
** documentation, headers files, or other derived files.  The formatting
** of the code in this file is, therefore, important.  See other comments
** in this file for details.  If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.229 2003/06/22 01:41:49 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/*
** The makefile scans this source file and creates the following







|







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
**
** Various scripts scan this source file in order to generate HTML
** documentation, headers files, or other derived files.  The formatting
** of the code in this file is, therefore, important.  See other comments
** in this file for details.  If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.230 2003/06/24 10:39:46 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/*
** The makefile scans this source file and creates the following
4209
4210
4211
4212
4213
4214
4215


4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
  int tos = ++p->tos;
  Cursor *pC;
  int v;

  assert( i>=0 && i<p->nCursor );
  if( (pC = &p->aCsr[i])->recnoIsValid ){
    v = pC->lastRecno;


  }else if( pC->nullRow ){
    aStack[tos].flags = STK_Null;
    break;
  }else if( pC->pseudoTable ){
    v = keyToInt(pC->iKey);
  }else{
    assert( pC->pCursor!=0 );
    sqliteBtreeKey(pC->pCursor, 0, sizeof(u32), (char*)&v);
    v = keyToInt(v);
  }
  aStack[tos].i = v;
  aStack[tos].flags = STK_Int;







>
>
|


<
<







4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220


4221
4222
4223
4224
4225
4226
4227
  int tos = ++p->tos;
  Cursor *pC;
  int v;

  assert( i>=0 && i<p->nCursor );
  if( (pC = &p->aCsr[i])->recnoIsValid ){
    v = pC->lastRecno;
  }else if( pC->pseudoTable ){
    v = keyToInt(pC->iKey);
  }else if( pC->nullRow || pC->pCursor==0 ){
    aStack[tos].flags = STK_Null;
    break;


  }else{
    assert( pC->pCursor!=0 );
    sqliteBtreeKey(pC->pCursor, 0, sizeof(u32), (char*)&v);
    v = keyToInt(v);
  }
  aStack[tos].i = v;
  aStack[tos].flags = STK_Int;
Changes to test/misc2.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32


















#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc2.test,v 1.1 2003/06/22 01:41:50 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Test for ticket #360
#
do_test misc2-1.1 {
  catchsql {
    CREATE TABLE FOO(bar integer);
    CREATE TRIGGER foo_insert BEFORE INSERT ON foo BEGIN
      SELECT CASE WHEN (NOT new.bar BETWEEN 0 AND 20)
             THEN raise(rollback, 'aiieee') END;
    END;
    INSERT INTO foo(bar) VALUES (1);
  }
} {1 aiieee}

























|
















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc2.test,v 1.2 2003/06/24 10:39:46 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Test for ticket #360
#
do_test misc2-1.1 {
  catchsql {
    CREATE TABLE FOO(bar integer);
    CREATE TRIGGER foo_insert BEFORE INSERT ON foo BEGIN
      SELECT CASE WHEN (NOT new.bar BETWEEN 0 AND 20)
             THEN raise(rollback, 'aiieee') END;
    END;
    INSERT INTO foo(bar) VALUES (1);
  }
} {1 aiieee}

# Make sure ROWID works on a view and a subquery.  Ticket #364
#
do_test misc2-2.1 {
  execsql {
    CREATE TABLE t1(a,b,c);
    INSERT INTO t1 VALUES(1,2,3);
    CREATE TABLE t2(x,y,z);
    INSERT INTO t2 VALUES(7,8,9);
    SELECT rowid, * FROM (SELECT * FROM t1, t2);
  }
} {{} 1 2 3 7 8 9}
do_test misc2-2.2 {
  execsql {
    CREATE VIEW v1 AS SELECT * FROM t1, t2;
    SELECT rowid, * FROM v1;
  }
} {{} 1 2 3 7 8 9}