SQLite

Check-in [70a50bdda3]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 70a50bdda318f353c8be1ba200f9aedc34642c93
User & Date: drh 2003-09-27 00:56:32.000
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: 7ba8dc9b1e user: drh tags: trunk)
00:56
Add additional backslash escapes to the COPY command for compatibility with PostgreSQL. Ticket #460. (CVS 1104) (check-in: 70a50bdda3 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: 5aea81488b user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbe.c.
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.240 2003/09/06 22:18:08 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>
#include "vdbeInt.h"

/*







|







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.241 2003/09/27 00:56:32 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>
#include "vdbeInt.h"

/*
4121
4122
4123
4124
4125
4126
4127










4128
4129
4130
4131
4132
4133
4134
4135
      if( i<=nField ) p->azField[i-1] = 0;
      z += 2 + nDelim;
      if( i<nField ) p->azField[i] = z;
      continue;
    }
    while( z[from] ){
      if( z[from]=='\\' && z[from+1]!=0 ){










        z[to++] = z[from+1];
        from += 2;
        continue;
      }
      if( z[from]==c && strncmp(&z[from],zDelim,nDelim)==0 ) break;
      z[to++] = z[from++];
    }
    if( z[from] ){







>
>
>
>
>
>
>
>
>
>
|







4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
      if( i<=nField ) p->azField[i-1] = 0;
      z += 2 + nDelim;
      if( i<nField ) p->azField[i] = z;
      continue;
    }
    while( z[from] ){
      if( z[from]=='\\' && z[from+1]!=0 ){
        int tx = z[from+1];
        switch( tx ){
          case 'b':  tx = '\b'; break;
          case 'f':  tx = '\f'; break;
          case 'n':  tx = '\n'; break;
          case 'r':  tx = '\r'; break;
          case 't':  tx = '\t'; break;
          case 'v':  tx = '\v'; break;
          default:   break;
        }
        z[to++] = tx;
        from += 2;
        continue;
      }
      if( z[from]==c && strncmp(&z[from],zDelim,nDelim)==0 ) break;
      z[to++] = z[from++];
    }
    if( z[from] ){
Changes to test/copy.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2001 September 15
#
# 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 the COPY statement.
#
# $Id: copy.test,v 1.15 2003/08/05 13:13:39 drh Exp $

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

# Create a file of data from which to copy.
#
set f [open data1.txt w]













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2001 September 15
#
# 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 the COPY statement.
#
# $Id: copy.test,v 1.16 2003/09/27 00:56:33 drh Exp $

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

# Create a file of data from which to copy.
#
set f [open data1.txt w]
154
155
156
157
158
159
160











161
162
163
164
165
166
167
  execsql {
    DELETE FROM t1;
    COPY t1 FROM 'data6.txt';
    SELECT * FROM t1 ORDER BY a;
  }
} {1 {hello
world} 2 {hello world}}












# Test the embedded NULL logic.
#
do_test copy-4.1 {
  set fd [open data6.txt w]
  puts $fd "1\t\\N"
  puts $fd "\\N\thello world"







>
>
>
>
>
>
>
>
>
>
>







154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
  execsql {
    DELETE FROM t1;
    COPY t1 FROM 'data6.txt';
    SELECT * FROM t1 ORDER BY a;
  }
} {1 {hello
world} 2 {hello world}}
do_test copy-3.3 {
  set fd [open data6.txt w]
  puts $fd "1:hello\\b\\f\\n\\r\\t\\vworld"
  puts $fd "2:hello world"
  close $fd
  execsql {
    DELETE FROM t1;
    COPY t1 FROM 'data6.txt' USING DELIMITERS ':';
    SELECT * FROM t1 ORDER BY a;
  }
} [list 1 "hello\b\f\n\r\t\vworld" 2 "hello world"]

# Test the embedded NULL logic.
#
do_test copy-4.1 {
  set fd [open data6.txt w]
  puts $fd "1\t\\N"
  puts $fd "\\N\thello world"