Bug 3187 - Documentation suggests changing escape character is possible - how to disable it entirely?
Summary: Documentation suggests changing escape character is possible - how to disable...
Status: NEW
Alias: None
Product: SQL
Classification: Unclassified
Component: all (show other bugs)
Version: -- development
Hardware: Other Linux
: Normal enhancement
Assignee: SQL devs
URL:
Keywords: NONEEDTOTEST
Depends on:
Blocks:
 
Reported: 2012-11-19 13:26 CET by Stefan de Konink
Modified: 2016-04-11 11:46 CEST (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan de Konink 2012-11-19 13:26:55 CET
User-Agent:       Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.14 Safari/537.17
Build Identifier: 

"The input syntax should comply to the following grammar: [ [ [quote] [[escape]char] * [quote]] feldspar] * record separator. Quote characters in quoted fields may be escaped with a backslash. Field and record separators can be embedded in quoted fields."


I wanted to disable the escape character entirely, because it does more harm than it does good.

copy 3188251 records into kvk_import from '/home/skinkie/kvk_normal_sort.tsv' using delimiters '', '\t', '\n' NULL AS '';

But this doesn't seem to be picked up.

Reproducible: Always
Comment 1 Fabian Groffen 2012-11-20 13:30:38 CET
so, you effectively want this to work:

'\'

right?
Comment 2 Stefan de Konink 2012-11-20 13:45:59 CET
(In reply to comment #1)
> so, you effectively want this to work:
> 
> '\'
> 
> right?

Effectively I want '' to work. Ignore all escape chars in the file.
Comment 3 Fabian Groffen 2012-11-20 13:53:16 CET
I don't know right now if strings are or are not required to be quoted.  If so, you exclude your quote character to occur (could be fine).  When a string isn't quoted you can't use the , or whatever is the column separating char.

It seems to me if you want to add random garbage to the database using copy into, you'll have to ensure it "behaves", e.g. being properly escaped in a double-quoted encapsulation.
Comment 4 Stefan de Konink 2012-11-20 13:58:59 CET
(In reply to comment #3)
> I don't know right now if strings are or are not required to be quoted. 

Strings doesn't have to be quoted. The example below '\t', '\n' perfectly import tab separated files.

> It seems to me if you want to add random garbage to the database using copy
> into, you'll have to ensure it "behaves", e.g. being properly escaped in a
> double-quoted encapsulation.

No I don't want to put random garbage in, I want to put in text files that might use \ as ordinary character. MonetDB now forces the user to explicitly replace those occurences in that file with \\. If the escape functuality could be disabled, it would just tokenize and copy.
Comment 5 Fabian Groffen 2012-11-20 14:02:54 CET
I'm not sure if it's easily possible to bypass the escaping routines.
Comment 6 Stefan de Konink 2012-11-20 14:37:46 CET
(In reply to comment #5)
> I'm not sure if it's easily possible to bypass the escaping routines.

From a quickscan in the code from copyfrom and rel_import (sql) to insert_line (monetdb5), it might be possible to add a dynamic escape character.

/* recognize fields starting with a quote */
if (*line && *line == fmt[i].quote && (line == s || *(line - 1) != '\\')) {


Is my reading of the documentation wrong? If we look at for example to PostgreSQL they have a keyword for ESCAPE. Similar to the keyword QUOTE. In any case it would be a valuable enhancement.
Comment 7 Ying Zhang cwiconfidential 2012-11-27 16:21:39 CET
No test needed for feature request