Skip to content

Commit 06486e4

Browse files
committed
changed load data to copy
1 parent 0ef55ba commit 06486e4

2 files changed

Lines changed: 21 additions & 16 deletions

File tree

integration-tests/go-sql-server-driver/tests/sql-server-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ tests:
126126
columns: ["load_file"]
127127
rows: [["NULL"]]
128128
- exec: "create table loaded (contents text)"
129-
- exec: "load data infile \"config.yaml\" into table loaded"
130-
error_match: "LOAD DATA is unable to open file: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement"
131-
- exec: "load data infile \"/config.yaml\" into table loaded"
132-
error_match: "LOAD DATA is unable to open file: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement"
129+
- exec: "COPY loaded FROM 'config.yaml'"
130+
error_match: "must be superuser or have privileges of the pg_read_server_files role|secure_file_priv"
131+
- exec: "COPY loaded FROM '/config.yaml'"
132+
error_match: "must be superuser or have privileges of the pg_read_server_files role|secure_file_priv"

integration-tests/go-sql-server-driver/tests/sql-server-orig.yaml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -226,29 +226,33 @@ tests:
226226
columns: ["datname"]
227227
rows:
228228
- ["repo1"]
229-
- name: LOAD DATA LOCAL INFILE works
230-
skip: "MySQL-specific LOAD DATA LOCAL INFILE behavior has no Postgres equivalent"
229+
- name: COPY loads CSV data from a file
231230
repos:
232231
- name: repo1
232+
with_files:
233+
- name: "1pk5col-ints.csv"
234+
source_path: "testdata/1pk5col-ints.csv"
233235
server:
234236
args: []
235237
dynamic_port: server1
236238
connections:
237239
- on: repo1
238240
queries:
239241
- exec: "CREATE TABLE test(pk int primary key, c1 int, c2 int, c3 int, c4 int, c5 int)"
240-
- exec: "SET local_infile = 1"
241-
- exec: "LOAD DATA LOCAL INFILE 'testdata/1pk5col-ints.csv' INTO TABLE test CHARACTER SET UTF8MB4 FIELDS TERMINATED BY ',' ESCAPED BY '' LINES TERMINATED BY '\n' IGNORE 1 LINES"
242+
- exec: "COPY test FROM '1pk5col-ints.csv' WITH (FORMAT csv, HEADER)"
242243
- query: "SELECT * FROM test"
243244
result:
244245
columns: ["pk","c1","c2","c3","c4","c5"]
245246
rows:
246247
- ["0","1","2","3","4","5"]
247248
- ["1","1","2","3","4","5"]
248-
- name: LOAD DATA LOCAL INFILE automatically ignores row with existing primary key
249-
skip: "MySQL-specific LOAD DATA LOCAL INFILE behavior has no Postgres equivalent"
249+
- name: COPY into a table with a conflicting primary key (no IGNORE equivalent)
250+
skip: "Postgres COPY errors on a primary-key conflict and has no equivalent of MySQL's LOAD DATA ... IGNORE; the Postgres idiom is INSERT ... ON CONFLICT DO NOTHING"
250251
repos:
251252
- name: repo1
253+
with_files:
254+
- name: "1pk5col-ints.csv"
255+
source_path: "testdata/1pk5col-ints.csv"
252256
server:
253257
args: []
254258
dynamic_port: server1
@@ -257,18 +261,20 @@ tests:
257261
queries:
258262
- exec: "CREATE TABLE test(pk int primary key, c1 int, c2 int, c3 int, c4 int, c5 int)"
259263
- exec: "INSERT INTO test VALUES (0, 0, 0, 0, 0, 0)"
260-
- exec: "SET local_infile = 1"
261-
- exec: "LOAD DATA LOCAL INFILE 'testdata/1pk5col-ints.csv' INTO TABLE test CHARACTER SET UTF8MB4 FIELDS TERMINATED BY ',' ESCAPED BY '' LINES TERMINATED BY '\n' IGNORE 1 LINES"
264+
- exec: "COPY test FROM '1pk5col-ints.csv' WITH (FORMAT csv, HEADER)"
262265
- query: "SELECT * FROM test"
263266
result:
264267
columns: ["pk","c1","c2","c3","c4","c5"]
265268
rows:
266269
- ["0","0","0","0","0","0"]
267270
- ["1","1","2","3","4","5"]
268-
- name: LOAD DATA LOCAL INFILE can replace row with existing primary key
269-
skip: "MySQL-specific LOAD DATA LOCAL INFILE behavior has no Postgres equivalent"
271+
- name: COPY into a table with a conflicting primary key (no REPLACE equivalent)
272+
skip: "Postgres COPY errors on a primary-key conflict and has no equivalent of MySQL's LOAD DATA ... REPLACE; the Postgres idiom is INSERT ... ON CONFLICT DO UPDATE"
270273
repos:
271274
- name: repo1
275+
with_files:
276+
- name: "1pk5col-ints.csv"
277+
source_path: "testdata/1pk5col-ints.csv"
272278
server:
273279
args: []
274280
dynamic_port: server1
@@ -277,8 +283,7 @@ tests:
277283
queries:
278284
- exec: "CREATE TABLE test(pk int primary key, c1 int, c2 int, c3 int, c4 int, c5 int)"
279285
- exec: "INSERT INTO test VALUES (0, 0, 0, 0, 0, 0)"
280-
- exec: "SET local_infile = 1"
281-
- exec: "LOAD DATA LOCAL INFILE 'testdata/1pk5col-ints.csv' REPLACE INTO TABLE test CHARACTER SET UTF8MB4 FIELDS TERMINATED BY ',' ESCAPED BY '' LINES TERMINATED BY '\n' IGNORE 1 LINES"
286+
- exec: "COPY test FROM '1pk5col-ints.csv' WITH (FORMAT csv, HEADER)"
282287
- query: "SELECT * FROM test"
283288
result:
284289
columns: ["pk","c1","c2","c3","c4","c5"]

0 commit comments

Comments
 (0)