Skip to content

Commit

Permalink
importccl: fix case sensitive INSERT INTO column names in PGDUMP
Browse files Browse the repository at this point in the history
Tested by uncommenting out the skip and re-commenting it afterwards.

Release note (sql change, bug fix): When using `IMPORT PGDUMP` with
`INSERT INTO` clauses, specifying a column name that is case sensitive
(e.g. `"cApItAls"`)  would previously error specifying the column name
was not found. This has been rectified.
  • Loading branch information
otan committed Aug 6, 2020
1 parent ef0e879 commit 3b180b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions pkg/ccl/importccl/import_stmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,17 @@ COPY t (a, b, c) FROM stdin;
`SHOW TABLES`: {{"public", "weather", "table"}},
},
},
{
name: "case sensitive table names",
typ: "PGDUMP",
data: `
CREATE TABLE t ("sPoNgE" int8);
INSERT INTO t ("sPoNgE") VALUES (1337);
`,
query: map[string][][]string{
`SELECT * from t`: {{"1337"}},
},
},
{
name: "sequence",
typ: "PGDUMP",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/importccl/read_import_pgdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ func (m *pgDumpReader) readFile(
targetColMapInd = make([]int, len(i.Columns))
conv.IsTargetCol = make(map[int]struct{}, len(i.Columns))
for j := range i.Columns {
colName := i.Columns[j].String()
colName := string(i.Columns[j])
ind, ok := m.colMap[conv][colName]
if !ok {
return errors.Newf("targeted column %q not found", colName)
Expand Down

0 comments on commit 3b180b2

Please sign in to comment.