sqllogictest

Check-in [fdbe3f356a]
Login

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

Overview
Comment:Make sure the number of columns returned by the query matches the number of columns that the test script expects. Generate an error if they disagree. Fix a bug in select2.tcl that was causing the wrong number of columns to be generated.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: fdbe3f356aa429fa782211c88523de6267d344c0
User & Date: drh 2008-12-02 14:25:25.000
Context
2008-12-02
15:16
Modified ODBC interface to check zType length on xQuery to be consistent with SQLite interface. check-in: d3d496700a user: shaneh tags: trunk
14:25
Make sure the number of columns returned by the query matches the number of columns that the test script expects. Generate an error if they disagree. Fix a bug in select2.tcl that was causing the wrong number of columns to be generated. check-in: fdbe3f356a user: drh tags: trunk
14:05
Add the ability to label query results. Demonstrate the behavior with select3.tcl which permutes the terms of the WHERE clause. check-in: cdee9945da user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to proto/select2.tcl.
90
91
92
93
94
95
96
97
98
99
100
  set sql "SELECT [join $r ",\n       "]\n  FROM t1"
  set m [expr {int(rand()*4)}]
  if {$m>0} {
    set op [expr {rand()>0.5 ? "\n    OR " : "\n   AND "}]
    set w [lrange [scramble $wexpr] 1 $m]
    append sql "\n WHERE [join $w $op]"
  }
  puts "query [string range $type 0 $n] rowsort"
  puts "$sql"
  puts ""
}







|



90
91
92
93
94
95
96
97
98
99
100
  set sql "SELECT [join $r ",\n       "]\n  FROM t1"
  set m [expr {int(rand()*4)}]
  if {$m>0} {
    set op [expr {rand()>0.5 ? "\n    OR " : "\n   AND "}]
    set w [lrange [scramble $wexpr] 1 $m]
    append sql "\n WHERE [join $w $op]"
  }
  puts "query [string range $type 1 $n] rowsort"
  puts "$sql"
  puts ""
}
Changes to src/Makefile.
17
18
19
20
21
22
23




24
25
26
27
28
29
30
31
# You should not need to change anything below this line
###############################################################################
#
OBJ = \
  md5.o \
  sqlite3.o





sqllogictest$(E):	sqllogictest.c sqllogictest.h $(OBJ)
	$(CC) -o sqllogictest$(E) sqllogictest.c $(OBJ)

md5.o:	md5.c
	$(CC) -c md5.c

sqlite3.o:	sqlite3.c sqlite3.h
	$(CC) -c sqlite3.c -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION







>
>
>
>
|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# You should not need to change anything below this line
###############################################################################
#
OBJ = \
  md5.o \
  sqlite3.o

INC = \
  slt_sqlite.c \
  slt_odbc3.c

sqllogictest$(E):	sqllogictest.c sqllogictest.h $(OBJ) $(INC)
	$(CC) -o sqllogictest$(E) sqllogictest.c $(OBJ)

md5.o:	md5.c
	$(CC) -c md5.c

sqlite3.o:	sqlite3.c sqlite3.h
	$(CC) -c sqlite3.c -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION
Changes to src/slt_sqlite.c.
151
152
153
154
155
156
157





158
159
160
161
162
163
164

  memset(&res, 0, sizeof(res));
  db = (sqlite3*)pConn;
  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
  if( rc!=SQLITE_OK ){
    sqlite3_finalize(pStmt);
    return 1;





  }
  while( sqlite3_step(pStmt)==SQLITE_ROW ){
    int i;
    for(i=0; zType[i]; i++){
      if( sqlite3_column_type(pStmt, i)==SQLITE_NULL ){
        appendValue(&res, "NULL");
      }else{







>
>
>
>
>







151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169

  memset(&res, 0, sizeof(res));
  db = (sqlite3*)pConn;
  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
  if( rc!=SQLITE_OK ){
    sqlite3_finalize(pStmt);
    return 1;
  }
  if( strlen(zType)!=sqlite3_column_count(pStmt) ){
    fprintf(stderr, "Wrong number of result columns: Expected %d but got %d\n",
            strlen(zType), sqlite3_column_count(pStmt));
    return 1;
  }
  while( sqlite3_step(pStmt)==SQLITE_ROW ){
    int i;
    for(i=0; zType[i]; i++){
      if( sqlite3_column_type(pStmt, i)==SQLITE_NULL ){
        appendValue(&res, "NULL");
      }else{