SQLite

Check-in [a835658e50]
Login

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

Overview
Comment:2.0.7 (CVS 292)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a835658e507fc7d0c684959c0f0afb9018b6a8d4
User & Date: drh 2001-10-20 12:30:11.000
Context
2001-10-22
02:58
More changes for 2.0.7. (CVS 293) (check-in: f8328a5f11 user: drh tags: trunk)
2001-10-20
12:30
2.0.7 (CVS 292) (check-in: a835658e50 user: drh tags: trunk)
2001-10-19
16:45
Version 2.0.6 (CVS 464) (check-in: c8535a0de9 user: drh tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to VERSION.
1


1
-
+
2.0.6
2.0.7
Changes to src/select.c.
8
9
10
11
12
13
14
15

16
17
18
19
20
21
22
8
9
10
11
12
13
14

15
16
17
18
19
20
21
22







-
+







**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.42 2001/10/19 16:44:57 drh Exp $
** $Id: select.c,v 1.43 2001/10/20 12:30:11 drh Exp $
*/
#include "sqliteInt.h"

/*
** Allocate a new Select structure and return a pointer to that
** structure.
*/
256
257
258
259
260
261
262
263

264
265
266
267
268
269
270
256
257
258
259
260
261
262

263
264
265
266
267
268
269
270







-
+







    }else if( p->op==TK_COLUMN && pTabList ){
      if( pTabList->nId>1 || showFullNames ){
        char *zName = 0;
        Table *pTab = pTabList->a[p->iTable - pParse->nTab].pTab;
        char *zTab;
 
        zTab = pTabList->a[p->iTable - pParse->nTab].zAlias;
        if( zTab==0 ) zTab = pTab->zName;
        if( showFullNames || zTab==0 ) zTab = pTab->zName;
        sqliteSetString(&zName, zTab, ".", pTab->aCol[p->iColumn].zName, 0);
        sqliteVdbeAddOp(v, OP_ColumnName, i, 0);
        sqliteVdbeChangeP3(v, -1, zName, strlen(zName));
        sqliteFree(zName);
      }else{
        Table *pTab = pTabList->a[0].pTab;
        char *zName = pTab->aCol[p->iColumn].zName;
Changes to src/table.c.
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

69
70
71
72
73
74
75
44
45
46
47
48
49
50

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75







-

















+







  int i;
  char *z;

  /* Make sure there is enough space in p->azResult to hold everything
  ** we need to remember from this invocation of the callback.
  */
  if( p->nRow==0 && argv!=0 ){
    p->nColumn = nCol;
    need = nCol*2;
  }else{
    need = nCol;
  }
  if( p->nData + need >= p->nAlloc ){
    p->nAlloc = p->nAlloc*2 + need + 1;
    p->azResult = realloc( p->azResult, sizeof(char*)*p->nAlloc );
    if( p->azResult==0 ){
      p->rc = SQLITE_NOMEM;
      return 1;
    }
  }

  /* If this is the first row, then generate an extra row containing
  ** the names of all columns.
  */
  if( p->nRow==0 ){
    p->nColumn = nCol;
    for(i=0; i<nCol; i++){
      if( colv[i]==0 ){
        z = 0;
      }else{
        z = malloc( strlen(colv[i])+1 );
        if( z==0 ){
          p->rc = SQLITE_NOMEM;
Changes to src/vdbe.c.
26
27
28
29
30
31
32
33

34
35
36
37
38
39
40
26
27
28
29
30
31
32

33
34
35
36
37
38
39
40







-
+







** 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.87 2001/10/19 16:44:57 drh Exp $
** $Id: vdbe.c,v 1.88 2001/10/20 12:30:11 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** SQL is translated into a sequence of instructions to be
** executed by a virtual machine.  Each instruction is an instance
1453
1454
1455
1456
1457
1458
1459
1460

1461
1462
1463
1464
1465
1466
1467
1453
1454
1455
1456
1457
1458
1459

1460
1461
1462
1463
1464
1465
1466
1467







-
+







  if( nDigit<0 ) nDigit = 0;
  if( nDigit>30 ) nDigit = 30;
  v = aStack[tos].r;
  sprintf(zBuf, "%.*f", nDigit, v);
  POPSTACK;
  Release(p, nos);
  zStack[nos] = sqliteStrDup(zBuf);
  aStack[nos].n = strlen(zStack[tos]) + 1;
  aStack[nos].n = strlen(zStack[nos]) + 1;
  aStack[nos].flags = STK_Str | STK_Dyn;
  break;
}

/* Opcode: Max * * *
**
** Pop the top two elements from the stack then push back the
Changes to test/func.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14

15
16
17
18
19
20
21
1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
21













-
+







# 2001 September 15
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing built-in functions.
#
# $Id: func.test,v 1.5 2001/10/13 02:59:09 drh Exp $
# $Id: func.test,v 1.6 2001/10/20 12:30:12 drh Exp $

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

# Create a table to work with.
#
do_test func-0.0 {
154
155
156
157
158
159
160



161
162
163
164
154
155
156
157
158
159
160
161
162
163
164
165
166
167







+
+
+




do_test func-4.8 {
  catchsql {SELECT round(c) FROM t1 ORDER BY a}
} {0 {3 -12346 -5}}
do_test func-4.9 {
  catchsql {SELECT round(c,a) FROM t1 ORDER BY a}
} {0 {3.0 -12345.68 -5.000}}
do_test func-4.10 {
  catchsql {SELECT 'x' || round(c,a) || 'y' FROM t1 ORDER BY a}
} {0 {x3.0y x-12345.68y x-5.000y}}
do_test func-4.11 {
  catchsql {SELECT round() FROM t1 ORDER BY a}
} {1 {too few arguments to function round()}}

finish_test
Changes to test/tableapi.test.
8
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
8
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







-
+




















+







#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing the sqlite_exec_printf() and
# sqlite_get_table_printf() APIs.
#
# $Id: tableapi.test,v 1.3 2001/09/16 00:13:28 drh Exp $
# $Id: tableapi.test,v 1.4 2001/10/20 12:30:12 drh Exp $

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

do_test tableapi-1.0 {
  set ::dbx [sqlite_open testdb]
  catch {sqlite_exec_printf $::dbx {DROP TABLE xyz} {}}
  sqlite_exec_printf $::dbx {CREATE TABLE %s(a int, b text)} xyz
} {0 {}}
do_test tableapi-1.1 {
  sqlite_exec_printf $::dbx {
    INSERT INTO xyz VALUES(1,'%q')
  } {Hi Y'all}
} {0 {}}
do_test tableapi-1.2 {
  sqlite_exec_printf $::dbx {SELECT * FROM xyz} {}
} {0 {a b 1 {Hi Y'all}}}

do_test tableapi-2.1 {
  sqlite_get_table_printf $::dbx {
    BEGIN TRANSACTION;
    SELECT * FROM xyz WHERE b='%q'
  } {Hi Y'all}
} {0 1 2 a b 1 {Hi Y'all}}
do_test tableapi-2.2 {
  sqlite_get_table_printf $::dbx {
    SELECT * FROM xyz
  } {}
75
76
77
78
79
80
81





82


























































83
84
85
86
87
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151







+
+
+
+
+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+





  sqlite_get_table_printf $::dbx {
    INSERT INTO xyz VALUES(52,NULL)
  } {}
  sqlite_get_table_printf $::dbx {
    SELECT * FROM xyz WHERE a IN (42,50,52) ORDER BY a DESC
  } {}
} {0 3 2 a b 52 NULL 50 (50) 42 (42)}
do_test tableapi-2.7 {
  sqlite_get_table_printf $::dbx {
    SELECT * FROM xyz WHERE a>1000
  } {}
} {0 0 0}

# Repeat all tests with the empty_result_callbacks pragma turned on
#
do_test tableapi-3.1 {
  sqlite_get_table_printf $::dbx {
    ROLLBACK;
    PRAGMA empty_result_callbacks = ON;
    SELECT * FROM xyz WHERE b='%q'
  } {Hi Y'all}
} {0 1 2 a b 1 {Hi Y'all}}
do_test tableapi-3.2 {
  sqlite_get_table_printf $::dbx {
    SELECT * FROM xyz
  } {}
} {0 1 2 a b 1 {Hi Y'all}}
do_test tableapi-3.3 {
  for {set i 2} {$i<=50} {incr i} {
    sqlite_get_table_printf $::dbx \
       "INSERT INTO xyz VALUES($i,'(%s)')" $i
  }
  sqlite_get_table_printf $::dbx {
    SELECT * FROM xyz ORDER BY a
  } {}
} {0 50 2 a b 1 {Hi Y'all} 2 (2) 3 (3) 4 (4) 5 (5) 6 (6) 7 (7) 8 (8) 9 (9) 10 (10) 11 (11) 12 (12) 13 (13) 14 (14) 15 (15) 16 (16) 17 (17) 18 (18) 19 (19) 20 (20) 21 (21) 22 (22) 23 (23) 24 (24) 25 (25) 26 (26) 27 (27) 28 (28) 29 (29) 30 (30) 31 (31) 32 (32) 33 (33) 34 (34) 35 (35) 36 (36) 37 (37) 38 (38) 39 (39) 40 (40) 41 (41) 42 (42) 43 (43) 44 (44) 45 (45) 46 (46) 47 (47) 48 (48) 49 (49) 50 (50)}
do_test tableapi-3.3.1 {
  sqlite_get_table_printf $::dbx {
    SELECT * FROM xyz  WHERE a>49 ORDER BY a
  } {}
} {0 1 2 a b 50 (50)}
do_test tableapi-3.3.2 {
  sqlite_get_table_printf $::dbx {
    SELECT * FROM xyz WHERE a>47 ORDER BY a
  } {}
} {0 3 2 a b 48 (48) 49 (49) 50 (50)}
do_test tableapi-3.4 {
  set ::big_str [sqlite_mprintf_str {%500'* Hello %500'*} 0 0 {}]
  sqlite_get_table_printf $::dbx {
    INSERT INTO xyz VALUES(51,'%q')
  } $::big_str
} {0 0 0}
do_test tableapi-3.5 {
  sqlite_get_table_printf $::dbx {
    SELECT * FROM xyz WHERE a>49 ORDER BY a;
  } {}
} "0 2 2 a b 50 (50) 51 \173$::big_str\175"
do_test tableapi-3.6 {
  sqlite_get_table_printf $::dbx {
    INSERT INTO xyz VALUES(52,NULL)
  } {}
  sqlite_get_table_printf $::dbx {
    SELECT * FROM xyz WHERE a IN (42,50,52) ORDER BY a DESC
  } {}
} {0 3 2 a b 52 NULL 50 (50) 42 (42)}
do_test tableapi-3.7 {
  sqlite_get_table_printf $::dbx {
    SELECT * FROM xyz WHERE a>1000
  } {}
} {0 0 2 a b}

do_test tableapi-99.0 {
  sqlite_close $::dbx
} {}

finish_test
Changes to www/changes.tcl.
12
13
14
15
16
17
18




19
20
21
22
23
24
25
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29







+
+
+
+







}


proc chng {date desc} {
  puts "<DT><B>$date</B></DT>"
  puts "<DD><P><UL>$desc</UL></P></DD>"
}

chng {2001 Oct 20 (2.0.7)} {
<li>Patches from Christian Werner</li>
}

chng {2001 Oct 19 (2.0.6)} {
<li>Added the EMPTY_RESULT_CALLBACKS pragma</li>
<li>Support for UTF-8 and ISO8859 characters in column and table names.</li>
<li>Bug fix: Compute correct table names with the FULL_COLUMN_NAMES pragma
    is turned on.</li>
}