]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Get trace with parameter insertion working for UTF16 databases.
authordrh <drh@noemail.net>
Wed, 25 Nov 2009 19:35:23 +0000 (19:35 +0000)
committerdrh <drh@noemail.net>
Wed, 25 Nov 2009 19:35:23 +0000 (19:35 +0000)
FossilOrigin-Name: 01d5451af0bd2743eb74b98f2e77dd2c75f403b6

manifest
manifest.uuid
src/vdbetrace.c
test/trace.test

index 3840423987d71172452087060b8fc958c7146ff9..80b57bdbc611b45c9daa470af1f2450f8a360833 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,8 +1,8 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-C Initial\scheck-in\sof\scode\sthat\sinserts\stokenizations\sof\sthe\svalues\nfor\sbound\sparameters\sinto\sthe\soutput\sof\ssqlite3_trace().
-D 2009-11-25T18:03:43
+C Get\strace\swith\sparameter\sinsertion\sworking\sfor\sUTF16\sdatabases.
+D 2009-11-25T19:35:23
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -219,7 +219,7 @@ F src/vdbeapi.c 17680ab7a75ec938c5ba039a6c87489d01faf2cb
 F src/vdbeaux.c 0981dcb5b933b74ae7bc9bfa7770df5e4da849b3
 F src/vdbeblob.c 84f924700a7a889152aeebef77ca5f4e3875ffb4
 F src/vdbemem.c 1e16e3a16e55f4c3452834f0e041726021aa66e0
-F src/vdbetrace.c 0c0c85de878afa593d129e96035844fb9cb66538
+F src/vdbetrace.c 07c1f37c6dd753bf254928c8b4880aabf01653ff
 F src/vtab.c 456fc226614569f0e46f216e33265bea268bd917
 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
 F src/where.c 11b5b00c49d53e767a7eb855bc60790edeca6185
@@ -691,7 +691,7 @@ F test/tkt3992.test f3e7d548ac26f763b47bc0f750da3d03c81071da
 F test/tkt3997.test a335fa41ca3985660a139df7b734a26ef53284bd
 F test/tkt4018.test 7c2c9ba4df489c676a0a7a0e809a1fb9b2185bd1
 F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7
-F test/trace.test 1e194d4aa28072866d65b4522d61439156673cbe
+F test/trace.test 2739f8dcc6739a9235523819c4cd30e78c44985c
 F test/trans.test d887cb07630dc39879a322d958ad8b006137485c
 F test/trans2.test d5337e61de45e66b1fcbf9db833fa8c82e624b22
 F test/trans3.test d728abaa318ca364dc370e06576aa7e5fbed7e97
@@ -777,14 +777,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 3ba773132d3baeb87acaee538b8fb0b0f4293673
-R 083042b00e5c6f135e16a26d8597a9b9
+P 545cfb3b63f482036ae152e6ebcce86d373585a8
+R bf765939fc59b1f09dfded7d2e7b810c
 U drh
-Z dc2a97232842ecfec2bf765bdef955e5
+Z 502c1270f78689fd631f9bda4d5d8cef
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.6 (GNU/Linux)
 
-iD8DBQFLDXGFoxKgR168RlERAjnNAJ4s92jZVLjoWiP2AFZjoGmznb2KLgCcDqhv
-qcS6kVAJAbCr5+upcVo5F4g=
-=mEiC
+iD8DBQFLDYb+oxKgR168RlERAkN1AJ4xk5LnqIkUiJ6464MOkgJWhl0VzACgiaz0
+IMigDnq3LvaxBTiGDg2jzno=
+=r6LT
 -----END PGP SIGNATURE-----
index 99c192899d874f718b86d9961cf5a00fda39ad5e..4a19e62eb5e14543d24a376851ea1285e60c9527 100644 (file)
@@ -1 +1 @@
-545cfb3b63f482036ae152e6ebcce86d373585a8
\ No newline at end of file
+01d5451af0bd2743eb74b98f2e77dd2c75f403b6
\ No newline at end of file
index f43fe5532df2259ceb950a89226cc6911d5efa06..9b23375f663e04ab97b3ae9807c6ce9809888748 100644 (file)
@@ -93,6 +93,9 @@ char *sqlite3VdbeExpandSql(
       }
     }else{
       assert( zRawSql[0]==':' || zRawSql[0]=='$' || zRawSql[0]=='@' );
+      testcase( zRawSql[0]==':' );
+      testcase( zRawSql[0]=='$' );
+      testcase( zRawSql[0]=='@' );
       n = sqlite3GetToken((u8*)zRawSql, &dummy);
       idx = 0;
       for(i=0, pOp=p->aOp; ALWAYS(i<p->nOp); i++, pOp++){
@@ -116,7 +119,20 @@ char *sqlite3VdbeExpandSql(
     }else if( pVar->flags & MEM_Real ){
       sqlite3XPrintf(&out, "%!.15g", pVar->r);
     }else if( pVar->flags & MEM_Str ){
-      sqlite3XPrintf(&out, "'%.*q'", pVar->n, pVar->z);
+#ifndef SQLITE_OMIT_UTF16
+      if( ENC(db)!=SQLITE_UTF8 ){
+        Mem utf8;
+        memset(&utf8, 0, sizeof(utf8));
+        utf8.db = db;
+        sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, ENC(db), SQLITE_STATIC);
+        sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8);
+        sqlite3XPrintf(&out, "'%.*q'", utf8.n, utf8.z);
+        sqlite3VdbeMemRelease(&utf8);
+      }else
+#endif
+      {
+        sqlite3XPrintf(&out, "'%.*q'", pVar->n, pVar->z);
+      }
     }else{
       assert( pVar->flags & MEM_Blob );
       sqlite3StrAccumAppend(&out, "x'", 2);
index b0b0fea2b015f54b4f8675893a3fe3e28c5f2d29..f40993dedcfa3e1efd713b4db214602499a3403d 100644 (file)
@@ -183,5 +183,55 @@ do_test trace-6.1 {
 do_test trace-6.2 {
   set TRACE_OUT
 } {{SELECT 6, 6.0, 'test-six y''all', x'3031323334', NULL}}
+do_test trace-6.3 {
+  set TRACE_OUT {}
+  execsql {SELECT $::t6int, ?1, $::t6int}
+} {6 6 6}
+do_test trace-6.4 {
+  set TRACE_OUT
+} {{SELECT 6, 6, 6}}
+do_test trace-6.5 {
+  execsql {CREATE TABLE t6([$::t6int],"?1"); INSERT INTO t6 VALUES(1,2)}
+  set TRACE_OUT {}
+  execsql {SELECT '$::t6int', [$::t6int], $::t6int, ?1, "?1", $::t6int FROM t6}
+} {{$::t6int} 1 6 6 2 6}
+do_test trace-6.6 {
+  set TRACE_OUT
+} {{SELECT '$::t6int', [$::t6int], 6, 6, "?1", 6 FROM t6}}
+
+# Do these same tests with a UTF16 database.
+#
+do_test trace-6.100 {
+  db close
+  sqlite3 db :memory:
+  db eval {
+     PRAGMA encoding=UTF16be;
+     CREATE TABLE t6([$::t6str],"?1");
+     INSERT INTO t6 VALUES(1,2);
+  }
+  db trace trace_proc
+  set TRACE_OUT {}
+  execsql {SELECT '$::t6str', [$::t6str], $::t6str, ?1, "?1", $::t6str FROM t6}
+} {{$::t6str} 1 {test-six y'all} {test-six y'all} 2 {test-six y'all}}
+do_test trace-6.101 {
+  set TRACE_OUT
+} {{SELECT '$::t6str', [$::t6str], 'test-six y''all', 'test-six y''all', "?1", 'test-six y''all' FROM t6}}
+
+do_test trace-6.200 {
+  db close
+  sqlite3 db :memory:
+  db eval {
+     PRAGMA encoding=UTF16le;
+     CREATE TABLE t6([$::t6str],"?1");
+     INSERT INTO t6 VALUES(1,2);
+  }
+  db trace trace_proc
+  set TRACE_OUT {}
+  execsql {SELECT '$::t6str', [$::t6str], $::t6str, ?1, "?1", $::t6str FROM t6}
+} {{$::t6str} 1 {test-six y'all} {test-six y'all} 2 {test-six y'all}}
+do_test trace-6.101 {
+  set TRACE_OUT
+} {{SELECT '$::t6str', [$::t6str], 'test-six y''all', 'test-six y''all', "?1", 'test-six y''all' FROM t6}}
+
 
 finish_test