Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Correctly set the length of the string in bytes when transforming an OP_String8 to OP_String in a utf-16 vdbe program. (CVS 2949) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
69f996e0fac1dc50b8c43d5fa132f797 |
User & Date: | danielk1977 2006-01-15 14:11:49.000 |
Context
2006-01-15
| ||
17:27 | Clean up comments in os_unix.c. (CVS 2950) (check-in: 2170e803ad user: drh tags: trunk) | |
14:11 | Correctly set the length of the string in bytes when transforming an OP_String8 to OP_String in a utf-16 vdbe program. (CVS 2949) (check-in: 69f996e0fa user: danielk1977 tags: trunk) | |
13:13 | Fix a buffer-overrun that could occur after a malloc() failure. (CVS 2948) (check-in: 662522218f user: danielk1977 tags: trunk) | |
Changes
Changes to src/vdbe.c.
︙ | ︙ | |||
39 40 41 42 43 44 45 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** ** $Id: vdbe.c,v 1.530 2006/01/15 14:11:49 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> #include "vdbeInt.h" /* |
︙ | ︙ | |||
661 662 663 664 665 666 667 | pTos->flags |= MEM_Real; sqlite3VdbeChangeEncoding(pTos, encoding); break; } /* Opcode: String8 * * P3 ** | | < | | | 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | pTos->flags |= MEM_Real; sqlite3VdbeChangeEncoding(pTos, encoding); break; } /* Opcode: String8 * * P3 ** ** P3 points to a nul terminated UTF-8 string. This opcode is transformed ** into an OP_String before it is executed for the first time. */ case OP_String8: { /* same as TK_STRING */ assert( pOp->p3!=0 ); pOp->opcode = OP_String; pOp->p1 = strlen(pOp->p3); #ifndef SQLITE_OMIT_UTF16 if( encoding!=SQLITE_UTF8 ){ pTos++; sqlite3VdbeMemSetStr(pTos, pOp->p3, -1, SQLITE_UTF8, SQLITE_STATIC); if( SQLITE_OK!=sqlite3VdbeChangeEncoding(pTos, encoding) ) goto no_mem; if( SQLITE_OK!=sqlite3VdbeMemDynamicify(pTos) ) goto no_mem; pTos->flags &= ~(MEM_Dyn); pTos->flags |= MEM_Static; if( pOp->p3type==P3_DYNAMIC ){ sqliteFree(pOp->p3); } pOp->p3type = P3_DYNAMIC; pOp->p3 = pTos->z; pOp->p1 = pTos->n; break; } #endif /* Otherwise fall through to the next case, OP_String */ } /* Opcode: String P1 * P3 ** ** The string value P3 of length P1 (bytes) is pushed onto the stack. */ case OP_String: { pTos++; assert( pOp->p3!=0 ); pTos->flags = MEM_Str|MEM_Static|MEM_Term; pTos->z = pOp->p3; pTos->n = pOp->p1; |
︙ | ︙ |
Changes to test/alter.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2004 November 10 # # 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 script is testing the ALTER TABLE statement. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2004 November 10 # # 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 script is testing the ALTER TABLE statement. # # $Id: alter.test,v 1.15 2006/01/15 14:11:49 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # If SQLITE_OMIT_ALTERTABLE is defined, omit this file. ifcapable !altertable { |
︙ | ︙ | |||
547 548 549 550 551 552 553 554 555 | ALTER TABLE tbl1 RENAME TO tbl2; SELECT * FROM tbl2; } db2 } {x y z} do_test alter-5.3 { db2 close } {} set ::tbl_name "abc\uABCDdef" | > > > > > > | | > > > | | | | | | 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | ALTER TABLE tbl1 RENAME TO tbl2; SELECT * FROM tbl2; } db2 } {x y z} do_test alter-5.3 { db2 close } {} foreach tblname [execsql { SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite%' }] { execsql "DROP TABLE \"$tblname\"" } set ::tbl_name "abc\uABCDdef" do_test alter-6.1 { string length $::tbl_name } {7} do_test alter-6.2 { execsql " CREATE TABLE ${tbl_name}(a, b, c); " set ::oid [execsql {SELECT max(oid) FROM sqlite_master}] execsql { SELECT sql FROM sqlite_master WHERE oid = $::oid; } } "{CREATE TABLE ${::tbl_name}(a, b, c)}" execsql " SELECT * FROM ${::tbl_name} " set ::tbl_name2 "abcXdef" do_test alter-6.3 { execsql " ALTER TABLE $::tbl_name RENAME TO $::tbl_name2 " execsql { SELECT sql FROM sqlite_master WHERE oid = $::oid; } } "{CREATE TABLE '${::tbl_name2}'(a, b, c)}" do_test alter-6.4 { execsql " ALTER TABLE $::tbl_name2 RENAME TO $::tbl_name " execsql { SELECT sql FROM sqlite_master WHERE oid = $::oid; } } "{CREATE TABLE '${::tbl_name}'(a, b, c)}" set ::col_name ghi\1234\jkl do_test alter-6.5 { execsql " ALTER TABLE $::tbl_name ADD COLUMN $::col_name VARCHAR " execsql { SELECT sql FROM sqlite_master WHERE oid = $::oid; } } "{CREATE TABLE '${::tbl_name}'(a, b, c, $::col_name VARCHAR)}" set ::col_name2 B\3421\A do_test alter-6.6 { db close sqlite3 db test.db execsql " ALTER TABLE $::tbl_name ADD COLUMN $::col_name2 " execsql { SELECT sql FROM sqlite_master WHERE oid = $::oid; } } "{CREATE TABLE '${::tbl_name}'(a, b, c, $::col_name VARCHAR, $::col_name2)}" do_test alter-6.7 { execsql " INSERT INTO ${::tbl_name} VALUES(1, 2, 3, 4, 5); SELECT $::col_name, $::col_name2 FROM $::tbl_name; " } {4 5} finish_test |