/ Check-in [70a50bdd]
Login

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

Overview
Comment:Add additional backslash escapes to the COPY command for compatibility with PostgreSQL. Ticket #460. (CVS 1104)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 70a50bdda318f353c8be1ba200f9aedc34642c93
User & Date: drh 2003-09-27 00:56:32
Context
2003-09-27
01:08
Add a test case for ticket #464 but leave it commented out for now. We will fix this problem when VACUUM is rewritten. (CVS 1105) check-in: 7ba8dc9b user: drh tags: trunk
00:56
Add additional backslash escapes to the COPY command for compatibility with PostgreSQL. Ticket #460. (CVS 1104) check-in: 70a50bdd user: drh tags: trunk
00:41
Do all WHERE clauses tests, even if an index is used for lookup so that we know the test cannot be FALSE. The test might end up being NULL in which case it would need to be treated as false. Ticket #461. (CVS 1103) check-in: 5aea8148 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/vdbe.c.

    39     39   **
    40     40   ** Various scripts scan this source file in order to generate HTML
    41     41   ** documentation, headers files, or other derived files.  The formatting
    42     42   ** of the code in this file is, therefore, important.  See other comments
    43     43   ** in this file for details.  If in doubt, do not deviate from existing
    44     44   ** commenting and indentation practices when changing or adding code.
    45     45   **
    46         -** $Id: vdbe.c,v 1.240 2003/09/06 22:18:08 drh Exp $
           46  +** $Id: vdbe.c,v 1.241 2003/09/27 00:56:32 drh Exp $
    47     47   */
    48     48   #include "sqliteInt.h"
    49     49   #include "os.h"
    50     50   #include <ctype.h>
    51     51   #include "vdbeInt.h"
    52     52   
    53     53   /*
................................................................................
  4121   4121         if( i<=nField ) p->azField[i-1] = 0;
  4122   4122         z += 2 + nDelim;
  4123   4123         if( i<nField ) p->azField[i] = z;
  4124   4124         continue;
  4125   4125       }
  4126   4126       while( z[from] ){
  4127   4127         if( z[from]=='\\' && z[from+1]!=0 ){
  4128         -        z[to++] = z[from+1];
         4128  +        int tx = z[from+1];
         4129  +        switch( tx ){
         4130  +          case 'b':  tx = '\b'; break;
         4131  +          case 'f':  tx = '\f'; break;
         4132  +          case 'n':  tx = '\n'; break;
         4133  +          case 'r':  tx = '\r'; break;
         4134  +          case 't':  tx = '\t'; break;
         4135  +          case 'v':  tx = '\v'; break;
         4136  +          default:   break;
         4137  +        }
         4138  +        z[to++] = tx;
  4129   4139           from += 2;
  4130   4140           continue;
  4131   4141         }
  4132   4142         if( z[from]==c && strncmp(&z[from],zDelim,nDelim)==0 ) break;
  4133   4143         z[to++] = z[from++];
  4134   4144       }
  4135   4145       if( z[from] ){

Changes to test/copy.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the COPY statement.
    13     13   #
    14         -# $Id: copy.test,v 1.15 2003/08/05 13:13:39 drh Exp $
           14  +# $Id: copy.test,v 1.16 2003/09/27 00:56:33 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Create a file of data from which to copy.
    20     20   #
    21     21   set f [open data1.txt w]
................................................................................
   154    154     execsql {
   155    155       DELETE FROM t1;
   156    156       COPY t1 FROM 'data6.txt';
   157    157       SELECT * FROM t1 ORDER BY a;
   158    158     }
   159    159   } {1 {hello
   160    160   world} 2 {hello world}}
          161  +do_test copy-3.3 {
          162  +  set fd [open data6.txt w]
          163  +  puts $fd "1:hello\\b\\f\\n\\r\\t\\vworld"
          164  +  puts $fd "2:hello world"
          165  +  close $fd
          166  +  execsql {
          167  +    DELETE FROM t1;
          168  +    COPY t1 FROM 'data6.txt' USING DELIMITERS ':';
          169  +    SELECT * FROM t1 ORDER BY a;
          170  +  }
          171  +} [list 1 "hello\b\f\n\r\t\vworld" 2 "hello world"]
   161    172   
   162    173   # Test the embedded NULL logic.
   163    174   #
   164    175   do_test copy-4.1 {
   165    176     set fd [open data6.txt w]
   166    177     puts $fd "1\t\\N"
   167    178     puts $fd "\\N\thello world"