-
Notifications
You must be signed in to change notification settings - Fork 3
/
notes
43 lines (34 loc) · 818 Bytes
/
notes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
POSTGRES interpretation
% cat t.csv
abcd
ab"c"d
ab""c""d
ab\cd
ab\\cd
"abcd"
"ab\cd"
"ab\"cd"
"ab""cd"
"ab" "cd"
=== Command:
COPY t from file.csv CSV ESCAPE E'\\';
=== Result:
abcd => abcd (4)
ab"c"d => abcd (4)
ab""c""d => abcd (4)
ab\cd => ab\cd (5)
ab\\cd => ab\\cd (6)
"abcd" => abcd (4)
"ab\cd" => ab\cd (5)
"ab\"cd" => ab"cd (5)
"ab\\cd" => ab\cd (5)
"ab""cd" => abcd (4)
"ab" "cd" => ab cd (5)
=== Observations:
ab"c"d => abcd (4) ==> quotes are interpreted inside an unquoted field
ab\\cd => ab\\cd (6) ==> escape is ignored inside an unquoted field
"ab\cd" => ab\cd (5)
"ab\"cd" => ab"cd (5)
"ab\\cd" => ab\cd (5) ==> escape only works on esc and quote
"ab""cd" => abcd (4)
"ab" "cd" => ab cd (5) ==> if escape is not QUOTE, then " is interpreted as either closing quote and opening quote