SQLite

Check-in [c1006fb1c8]
Login

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

Overview
Comment:Fix a typo in the date/time function tests. Add additional cases to the zeroblob tests to make sure sqlite3_bind_zeroblob() does not use excess memory. (CVS 5216)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c1006fb1c817bc0b7fada873edb772abbf972012
User & Date: drh 2008-06-12 18:05:40.000
Context
2008-06-12
18:17
Enhance zeroblob tests to use the sqlite3_memory_highwater in order to double-check that no large allocations are occurring. (CVS 5217) (check-in: e93079be83 user: drh tags: trunk)
18:05
Fix a typo in the date/time function tests. Add additional cases to the zeroblob tests to make sure sqlite3_bind_zeroblob() does not use excess memory. (CVS 5216) (check-in: c1006fb1c8 user: drh tags: trunk)
16:35
Convert the date/time functions to work with milliseconds since the julian epoch internally (instead of days since the epoch) in order to avoid problems with floating-point roundoff error. The interface is unchanged. (CVS 5215) (check-in: ed35f8a983 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/date.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2003 October 31
#
# 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 date and time functions.
#
# $Id: date.test,v 1.29 2008/06/12 16:35:39 drh Exp $

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

# Skip this whole file if date and time functions are omitted
# at compile-time
#













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2003 October 31
#
# 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 date and time functions.
#
# $Id: date.test,v 1.30 2008/06/12 18:05:40 drh Exp $

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

# Skip this whole file if date and time functions are omitted
# at compile-time
#
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486

# Changing the least significant byte of the floating point value between
# 00 and FF should always generate a time of either 23:59:59 or 00:00:00,
# never 24:00:00
#
for {set i 0} {$i<=255} {incr i} {
  db close
  hexio_write test.db 2047 [format %2x $i]
  sqlite3 db test.db
  do_test date-14.2.$i {
    set date [db one {SELECT datetime(x) FROM t1}]
    expr {$date eq "2008-06-12 00:00:00" || $date eq "2008-06-11 23:59:59"}
  } {1}
}
finish_test







|







472
473
474
475
476
477
478
479
480
481
482
483
484
485
486

# Changing the least significant byte of the floating point value between
# 00 and FF should always generate a time of either 23:59:59 or 00:00:00,
# never 24:00:00
#
for {set i 0} {$i<=255} {incr i} {
  db close
  hexio_write test.db 2047 [format %02x $i]
  sqlite3 db test.db
  do_test date-14.2.$i {
    set date [db one {SELECT datetime(x) FROM t1}]
    expr {$date eq "2008-06-12 00:00:00" || $date eq "2008-06-11 23:59:59"}
  } {1}
}
finish_test
Changes to test/zeroblob.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing of the zero-filled blob functionality
# including the sqlite3_bind_zeroblob(), sqlite3_result_zeroblob(),
# and the built-in zeroblob() SQL function.
#
# $Id: zeroblob.test,v 1.10 2007/09/12 17:01:45 danielk1977 Exp $

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

ifcapable !incrblob {
  finish_test
  return







|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing of the zero-filled blob functionality
# including the sqlite3_bind_zeroblob(), sqlite3_result_zeroblob(),
# and the built-in zeroblob() SQL function.
#
# $Id: zeroblob.test,v 1.11 2008/06/12 18:05:40 drh Exp $

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

ifcapable !incrblob {
  finish_test
  return
184
185
186
187
188
189
190



191
192

193
194
195
196
197
198
199
200
201






202
203
204
205
206
207
208
209
210
211
212
213
} {{}}
do_test zeroblob-6.7 {
  execsql {select typeof(zeroblob(-1))}
} {blob}

# Test bind_zeroblob()
#



do_test zeroblob-7.1 {
  set ::STMT [sqlite3_prepare $::DB "SELECT length(?)" -1 DUMMY]

  sqlite3_bind_zeroblob $::STMT 1 450
  sqlite3_step $::STMT
} {SQLITE_ROW}
do_test zeroblob-7.2 {
  sqlite3_column_int $::STMT 0
} {450}
do_test zeroblob-7.3 {
  sqlite3_finalize $::STMT
} {SQLITE_OK}







# Test that MakeRecord can handle a value with some real content
# and a zero-blob tail.
#
do_test zeroblob-8.1 {
  llength [execsql {
    SELECT 'hello' AS a, zeroblob(10) as b from t1 ORDER BY a, b;
  }]
} {8}


finish_test







>
>
>


>
|




|



>
>
>
>
>
>












184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
} {{}}
do_test zeroblob-6.7 {
  execsql {select typeof(zeroblob(-1))}
} {blob}

# Test bind_zeroblob()
#
sqlite3_memory_highwater 1
unset -nocomplain memused
set memused [sqlite3_memory_used]
do_test zeroblob-7.1 {
  set ::STMT [sqlite3_prepare $::DB "SELECT length(?)" -1 DUMMY]
  set ::sqlite3_max_blobsize 0
  sqlite3_bind_zeroblob $::STMT 1 450000
  sqlite3_step $::STMT
} {SQLITE_ROW}
do_test zeroblob-7.2 {
  sqlite3_column_int $::STMT 0
} {450000}
do_test zeroblob-7.3 {
  sqlite3_finalize $::STMT
} {SQLITE_OK}
do_test zeroblob-7.4 {
  set ::sqlite3_max_blobsize
} {0}
do_test zeroblob-7.5 {
  expr {[sqlite3_memory_highwater]<$::memused+10000}
} {1}

# Test that MakeRecord can handle a value with some real content
# and a zero-blob tail.
#
do_test zeroblob-8.1 {
  llength [execsql {
    SELECT 'hello' AS a, zeroblob(10) as b from t1 ORDER BY a, b;
  }]
} {8}


finish_test