mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Fix for ticket #71: Correctly handle CR and CRLF line terminators in the
input files for the COPY command. (CVS 694) FossilOrigin-Name: be1315755ef801b5ec07f469134e0d33a3ece990
This commit is contained in:
20
manifest
20
manifest
@@ -1,5 +1,5 @@
|
|||||||
C UPDATE\striggers\son\sTEMP\stables\swere\sbroken.\s(CVS\s693)
|
C Fix\sfor\sticket\s#71:\sCorrectly\shandle\sCR\sand\sCRLF\sline\sterminators\sin\sthe\ninput\sfiles\sfor\sthe\sCOPY\scommand.\s(CVS\s694)
|
||||||
D 2002-07-21T23:09:55
|
D 2002-07-30T17:20:40
|
||||||
F Makefile.in 6291a33b87d2a395aafd7646ee1ed562c6f2c28c
|
F Makefile.in 6291a33b87d2a395aafd7646ee1ed562c6f2c28c
|
||||||
F Makefile.template 4e11752e0b5c7a043ca50af4296ec562857ba495
|
F Makefile.template 4e11752e0b5c7a043ca50af4296ec562857ba495
|
||||||
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
|
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
|
||||||
@@ -40,8 +40,8 @@ F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe
|
|||||||
F src/select.c a43eabfc2e3e4d67660027f016889935f706deab
|
F src/select.c a43eabfc2e3e4d67660027f016889935f706deab
|
||||||
F src/shell.c 37a8405aec5740726c4ee18826c1ff5fd2c29b96
|
F src/shell.c 37a8405aec5740726c4ee18826c1ff5fd2c29b96
|
||||||
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
|
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
|
||||||
F src/sqlite.h.in 75c5bbb066d0faf34424b7d1babf8b44d5b31af2
|
F src/sqlite.h.in d3999a9c6374675779058d6cfe5431131618e92b
|
||||||
F src/sqliteInt.h a7a088cd9e69e9dbefe0fdfe411bb6387b50f384
|
F src/sqliteInt.h d0a54982e1eb01f9b05aa9329e8d569acb0996ea
|
||||||
F src/table.c eed2098c9b577aa17f8abe89313a9c4413f57d63
|
F src/table.c eed2098c9b577aa17f8abe89313a9c4413f57d63
|
||||||
F src/tclsqlite.c c502819c209011659e1bbb428cbac5670cce7f79
|
F src/tclsqlite.c c502819c209011659e1bbb428cbac5670cce7f79
|
||||||
F src/test1.c 456cb080db85056be723e770435d9509afc3a83a
|
F src/test1.c 456cb080db85056be723e770435d9509afc3a83a
|
||||||
@@ -52,7 +52,7 @@ F src/tokenize.c b5500e193a82b5b9888fbf947efd90d3b4858178
|
|||||||
F src/trigger.c d88ab4d68d68955c217b38fb6717e090fbbf54a4
|
F src/trigger.c d88ab4d68d68955c217b38fb6717e090fbbf54a4
|
||||||
F src/update.c f07e6ed2c517c92871e54d3f5886d1cf56121b11
|
F src/update.c f07e6ed2c517c92871e54d3f5886d1cf56121b11
|
||||||
F src/util.c 7a99e754c44dd220e881122e30581c08b6d6adef
|
F src/util.c 7a99e754c44dd220e881122e30581c08b6d6adef
|
||||||
F src/vdbe.c 7433a7811fbbb7cfec4f12c142913b4d8a02231e
|
F src/vdbe.c b35ea5d6af6c4649d6cda171d326352ff616875d
|
||||||
F src/vdbe.h a9292f2b5fcecef924fa255fb74609e9cbc776c2
|
F src/vdbe.h a9292f2b5fcecef924fa255fb74609e9cbc776c2
|
||||||
F src/where.c 6a43aa6c80eab12221eeca754cba852a9ecd1e13
|
F src/where.c 6a43aa6c80eab12221eeca754cba852a9ecd1e13
|
||||||
F test/all.test f296d27fff6aca72348af15092154f879d1fc7d4
|
F test/all.test f296d27fff6aca72348af15092154f879d1fc7d4
|
||||||
@@ -61,7 +61,7 @@ F test/btree.test bf326f546a666617367a7033fa2c07451bd4f8e1
|
|||||||
F test/btree2.test e3b81ec33dc2f89b3e6087436dfe605b870c9080
|
F test/btree2.test e3b81ec33dc2f89b3e6087436dfe605b870c9080
|
||||||
F test/btree3.test 9caa9e22491dd8cd8aa36d7ac3b48b089817c895
|
F test/btree3.test 9caa9e22491dd8cd8aa36d7ac3b48b089817c895
|
||||||
F test/conflict.test 4518cc3c1c40c4ba74220d9ee814257ae7d09c47
|
F test/conflict.test 4518cc3c1c40c4ba74220d9ee814257ae7d09c47
|
||||||
F test/copy.test 92e21ebea11319c3f70448d3763fdaa0e2f1c21f
|
F test/copy.test 55d60a4d5ed342a0fa08b7cd07d46d43ea0d0d7f
|
||||||
F test/delete.test 5821a95a66061ae09723a88938f23d10d8a881ad
|
F test/delete.test 5821a95a66061ae09723a88938f23d10d8a881ad
|
||||||
F test/expr.test 5fadd0bc87c223b424ce6752b576c1df346abf1f
|
F test/expr.test 5fadd0bc87c223b424ce6752b576c1df346abf1f
|
||||||
F test/func.test cae5f27e09736cfdcc978c3719ac1345405b848c
|
F test/func.test cae5f27e09736cfdcc978c3719ac1345405b848c
|
||||||
@@ -142,7 +142,7 @@ F www/speed.tcl da8afcc1d3ccc5696cfb388a68982bc3d9f7f00f
|
|||||||
F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
|
F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
|
||||||
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
|
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
|
||||||
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
|
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
|
||||||
P 610b7bc70a12b271994255bd01a76b3525421535
|
P c080ed01ea51628b86050762f097e702e3aeafdf
|
||||||
R 8d04659c9e44b4da98d3cabd50c7863c
|
R 2c19fd10fe86bd88ef844a3055d315b5
|
||||||
U danielk1977
|
U drh
|
||||||
Z 554b81b4d4eac0c4e8ece2aa3bada3ab
|
Z e835230fdc0a66edc7f339264e4e0fbb
|
||||||
|
@@ -1 +1 @@
|
|||||||
c080ed01ea51628b86050762f097e702e3aeafdf
|
be1315755ef801b5ec07f469134e0d33a3ece990
|
@@ -12,7 +12,7 @@
|
|||||||
** This header file defines the interface that the SQLite library
|
** This header file defines the interface that the SQLite library
|
||||||
** presents to client programs.
|
** presents to client programs.
|
||||||
**
|
**
|
||||||
** @(#) $Id: sqlite.h.in,v 1.33 2002/06/25 19:31:18 drh Exp $
|
** @(#) $Id: sqlite.h.in,v 1.34 2002/07/30 17:20:40 drh Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _SQLITE_H_
|
#ifndef _SQLITE_H_
|
||||||
#define _SQLITE_H_
|
#define _SQLITE_H_
|
||||||
@@ -384,6 +384,7 @@ int sqlite_get_table_vprintf(
|
|||||||
char **errmsg, /* Error msg written here */
|
char **errmsg, /* Error msg written here */
|
||||||
va_list ap /* Arguments to the format string */
|
va_list ap /* Arguments to the format string */
|
||||||
);
|
);
|
||||||
|
char *sqlite_mprintf(const char*,...);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Windows systems should call this routine to free memory that
|
** Windows systems should call this routine to free memory that
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** Internal interface definitions for SQLite.
|
** Internal interface definitions for SQLite.
|
||||||
**
|
**
|
||||||
** @(#) $Id: sqliteInt.h,v 1.140 2002/07/19 17:46:39 drh Exp $
|
** @(#) $Id: sqliteInt.h,v 1.141 2002/07/30 17:20:40 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqlite.h"
|
#include "sqlite.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
@@ -912,7 +912,6 @@ int sqliteRandomInteger(void);
|
|||||||
void sqliteBeginTransaction(Parse*, int);
|
void sqliteBeginTransaction(Parse*, int);
|
||||||
void sqliteCommitTransaction(Parse*);
|
void sqliteCommitTransaction(Parse*);
|
||||||
void sqliteRollbackTransaction(Parse*);
|
void sqliteRollbackTransaction(Parse*);
|
||||||
char *sqlite_mprintf(const char *, ...);
|
|
||||||
int sqliteExprIsConstant(Expr*);
|
int sqliteExprIsConstant(Expr*);
|
||||||
int sqliteExprIsInteger(Expr*, int*);
|
int sqliteExprIsInteger(Expr*, int*);
|
||||||
int sqliteIsRowid(const char*);
|
int sqliteIsRowid(const char*);
|
||||||
|
30
src/vdbe.c
30
src/vdbe.c
@@ -30,7 +30,7 @@
|
|||||||
** But other routines are also provided to help in building up
|
** But other routines are also provided to help in building up
|
||||||
** a program instruction by instruction.
|
** a program instruction by instruction.
|
||||||
**
|
**
|
||||||
** $Id: vdbe.c,v 1.165 2002/07/18 00:34:12 drh Exp $
|
** $Id: vdbe.c,v 1.166 2002/07/30 17:20:40 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -1240,6 +1240,32 @@ static int byteSwap(int x){
|
|||||||
# define VERIFY(X) X
|
# define VERIFY(X) X
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The following routine works like a replacement for the standard
|
||||||
|
** library routine fgets(). The difference is in how end-of-line (EOL)
|
||||||
|
** is handled. Standard fgets() uses LF for EOL under unix, CRLF
|
||||||
|
** under windows, and CR under mac. This routine accepts any of these
|
||||||
|
** character sequences as an EOL mark. The EOL mark is replaced by
|
||||||
|
** a single LF character in zBuf.
|
||||||
|
*/
|
||||||
|
static char *vdbe_fgets(char *zBuf, int nBuf, FILE *in){
|
||||||
|
int i, c;
|
||||||
|
for(i=0; i<nBuf-1 && (c=getc(in))!=EOF; i++){
|
||||||
|
zBuf[i] = c;
|
||||||
|
if( c=='\r' || c=='\n' ){
|
||||||
|
if( c=='\r' ){
|
||||||
|
zBuf[i] = '\n';
|
||||||
|
c = getc(in);
|
||||||
|
if( c!=EOF && c!='\n' ) ungetc(c, in);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zBuf[i] = 0;
|
||||||
|
return i>0 ? zBuf : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Execute the program in the VDBE.
|
** Execute the program in the VDBE.
|
||||||
**
|
**
|
||||||
@@ -4470,7 +4496,7 @@ case OP_FileRead: {
|
|||||||
}
|
}
|
||||||
p->zLine = zLine;
|
p->zLine = zLine;
|
||||||
}
|
}
|
||||||
if( fgets(&p->zLine[n], p->nLineAlloc-n, p->pFile)==0 ){
|
if( vdbe_fgets(&p->zLine[n], p->nLineAlloc-n, p->pFile)==0 ){
|
||||||
eol = 1;
|
eol = 1;
|
||||||
p->zLine[n] = 0;
|
p->zLine[n] = 0;
|
||||||
}else{
|
}else{
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
# This file implements regression tests for SQLite library. The
|
# This file implements regression tests for SQLite library. The
|
||||||
# focus of this file is testing the COPY statement.
|
# focus of this file is testing the COPY statement.
|
||||||
#
|
#
|
||||||
# $Id: copy.test,v 1.11 2002/06/25 13:16:04 drh Exp $
|
# $Id: copy.test,v 1.12 2002/07/30 17:20:41 drh Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@@ -39,6 +39,14 @@ set f [open data5.txt w]
|
|||||||
puts $f "11|22|33"
|
puts $f "11|22|33"
|
||||||
puts $f "22|33|11"
|
puts $f "22|33|11"
|
||||||
close $f
|
close $f
|
||||||
|
set f [open dataX.txt w]
|
||||||
|
puts -nonewline $f "11|22|33\r"
|
||||||
|
puts -nonewline $f "22|33|44\r\n"
|
||||||
|
puts -nonewline $f "33|44|55\n"
|
||||||
|
puts -nonewline $f "44|55|66\r"
|
||||||
|
puts -nonewline $f "55|66|77\r\n"
|
||||||
|
puts -nonewline $f "66|77|88\n"
|
||||||
|
close $f
|
||||||
|
|
||||||
# Try to COPY into a non-existant table.
|
# Try to COPY into a non-existant table.
|
||||||
#
|
#
|
||||||
@@ -226,10 +234,20 @@ do_test copy-5.7 {
|
|||||||
}
|
}
|
||||||
} {0}
|
} {0}
|
||||||
|
|
||||||
integrity_check copy-6.0
|
do_test copy-6.1 {
|
||||||
|
execsql {
|
||||||
|
PRAGMA count_changes=off;
|
||||||
|
CREATE TABLE t2(a,b,c);
|
||||||
|
COPY t2 FROM 'dataX.txt' USING DELIMITERS '|';
|
||||||
|
SELECT * FROM t2;
|
||||||
|
}
|
||||||
|
} {11 22 33 22 33 44 33 44 55 44 55 66 55 66 77 66 77 88}
|
||||||
|
|
||||||
|
integrity_check copy-7.1
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
#
|
#
|
||||||
file delete -force data1.txt data2.txt data3.txt data4.txt data5.txt data6.txt
|
file delete -force data1.txt data2.txt data3.txt data4.txt data5.txt \
|
||||||
|
data6.txt dataX.txt
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
Reference in New Issue
Block a user