Smaller and hopefully faster routine for converting blob literals into binary. (CVS 4967)

FossilOrigin-Name: 92d49499ee3371db64267c7e2ba72a5e12ea76f3
This commit is contained in:
drh 2008-04-04 15:12:21 +00:00
parent 1c22f2ddfb
commit 335d29d208
4 changed files with 44 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C Fix\sthe\soutput\slabels\son\sthe\stests\sin\smalloc9.\s(CVS\s4966)
D 2008-04-04T12:21:26
C Smaller\sand\shopefully\sfaster\sroutine\sfor\sconverting\sblob\sliterals\sinto\sbinary.\s(CVS\s4967)
D 2008-04-04T15:12:22
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in b861627d91df5ee422c54237aa38296954dc0151
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -172,7 +172,7 @@ F src/tokenize.c d642f36a07e3c38703f52b609f13cd534897a57e
F src/trigger.c 9bd3b6fa0beff4a02d262c96466f752ec15a7fc3
F src/update.c 6d5f7728ec254c4a36a06a744f45b232b2eef857
F src/utf.c 8c94fa10efc78c2568d08d436acc59df4df7191b
F src/util.c dba9e04121eb17ec4643d6ca231ff859452cf0e2
F src/util.c 9a435395c8e03fa0b1658f59ff44e552844ac6c6
F src/vacuum.c 3524411bfb58aac0d87eadd3e5b7cd532772af30
F src/vdbe.c 66ca98cce0f5776006eb5fcaa95a6d90b341646e
F src/vdbe.h f72201a0657d5f3d6cc008d1f8d9cc65768518c9
@ -214,7 +214,7 @@ F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747
F test/bind.test 261fd1603613e7f877a516d29f281c9d8c2ecf52
F test/bindxfer.test 995d2cf8df61204d748cde6960443121c4ccd2e1
F test/bitvec.test 62a512c3f7041d1df12558eb25990e5a19820571
F test/blob.test f2dbdbf1159674283645c2636436839313ee7131
F test/blob.test 2a38d867bdf08f9ce081776acec1ac8d4bca66be
F test/busy.test 76b4887f8b9160ba903c1ac22e8ff406ad6ae2f0
F test/cache.test 3ff445c445742a7b6b9ba6e1d62a25263f9424b9
F test/capi2.test cc64df7560a96f848f919ea2926c60acf639684b
@ -625,7 +625,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 046a98a8c88be7389c1571a819ccf1907a3f7217
R c2eb8a3e99b84237743b30cf9d3410ed
P 9987a7b193095dc90a83666bdac5e23105909cba
R ef205f0a77d72d2ab92875e08b608793
U drh
Z 8168e0c974d32f7ba3946f548ac61cf1
Z c22c0013da67b67c72be28004cc0d047

View File

@ -1 +1 @@
9987a7b193095dc90a83666bdac5e23105909cba
92d49499ee3371db64267c7e2ba72a5e12ea76f3

View File

@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.217 2008/03/19 13:03:34 drh Exp $
** $Id: util.c,v 1.218 2008/04/04 15:12:22 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@ -597,8 +597,18 @@ void sqlite3Put4byte(unsigned char *p, u32 v){
#if !defined(SQLITE_OMIT_BLOB_LITERAL) || defined(SQLITE_HAS_CODEC)
/*
** Translate a single byte of Hex into an integer.
** This routinen only works if h really is a valid hexadecimal
** character: 0..9a..fA..F
*/
static int hexToInt(int h){
#if !defined(SQLITE_EBCDIC)
int x = h - '0';
if( x>9 ){
x = (h - 'A' + 10) & 0xf;
}
assert( x>=0 && x<=15 );
return x;
#else
if( h>='0' && h<='9' ){
return h - '0';
}else if( h>='a' && h<='f' ){
@ -607,6 +617,7 @@ static int hexToInt(int h){
assert( h>='A' && h<='F' );
return h - 'A' + 10;
}
#endif
}
#endif /* !SQLITE_OMIT_BLOB_LITERAL || SQLITE_HAS_CODEC */

View File

@ -10,7 +10,7 @@
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# $Id: blob.test,v 1.6 2008/01/22 23:37:10 drh Exp $
# $Id: blob.test,v 1.7 2008/04/04 15:12:22 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -45,6 +45,10 @@ do_test blob-1.3 {
set blob [execsql {SELECT x'abcdEF12';}]
bin_to_hex [lindex $blob 0]
} {ABCDEF12}
do_test blob-1.3.2 {
set blob [execsql {SELECT x'0123456789abcdefABCDEF';}]
bin_to_hex [lindex $blob 0]
} {0123456789ABCDEFABCDEF}
# Try some syntax errors in blob literals.
do_test blob-1.4 {
@ -59,6 +63,25 @@ do_test blob-1.6 {
do_test blob-1.7 {
catchsql {SELECT X'01001'}
} {1 {unrecognized token: "X'01001'"}}
do_test blob-1.8 {
catchsql {SELECT x'012/45'}
} {1 {unrecognized token: "x'012/45'"}}
do_test blob-1.9 {
catchsql {SELECT x'012:45'}
} {1 {unrecognized token: "x'012:45'"}}
do_test blob-1.10 {
catchsql {SELECT x'012@45'}
} {1 {unrecognized token: "x'012@45'"}}
do_test blob-1.11 {
catchsql {SELECT x'012G45'}
} {1 {unrecognized token: "x'012G45'"}}
do_test blob-1.12 {
catchsql {SELECT x'012`45'}
} {1 {unrecognized token: "x'012`45'"}}
do_test blob-1.13 {
catchsql {SELECT x'012g45'}
} {1 {unrecognized token: "x'012g45'"}}
# Insert a blob into a table and retrieve it.
do_test blob-2.0 {