This repository has been archived by the owner on Nov 30, 2021. It is now read-only.
forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
importccl: fix rejected file overwriting the original file
There was severe error introduced by cockroachdb#41430 that causes the original IMPORT file to be overwritten by the rejected file. Release note (bug fix): fix bug when using ‘experimental_save_rejected’ that would cause the rejected row file to overwrite the original input file.
- Loading branch information
Spas Bojanov
committed
Nov 12, 2019
1 parent
0e9dd73
commit b0acf0d
Showing
2 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2019 The Cockroach Authors. | ||
// | ||
// Licensed as a CockroachDB Enterprise file under the Cockroach Community | ||
// License (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt | ||
|
||
package importccl | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
) | ||
|
||
func TestRejectedFilename(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
tests := []struct { | ||
name string | ||
fname string | ||
rejected string | ||
}{ | ||
{ | ||
name: "http", | ||
fname: "http://127.0.0.1", | ||
rejected: "http://127.0.0.1/.rejected", | ||
}, | ||
{ | ||
name: "nodelocal", | ||
fname: "nodelocal:///file.csv", | ||
rejected: "nodelocal:///file.csv.rejected", | ||
}, | ||
} | ||
for _, tc := range tests { | ||
rej, err := rejectedFilename(tc.fname) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if tc.rejected != rej { | ||
t.Errorf("expected:\n%v\ngot:\n%v\n", tc.rejected, rej) | ||
} | ||
} | ||
} |