Skip to content

Commit

Permalink
Merge pull request #93261 from cockroachdb/blathers/backport-release-…
Browse files Browse the repository at this point in the history
…22.2-93100

Resolves #93051
  • Loading branch information
rafiss authored Dec 9, 2022
2 parents 41e3453 + 5d12198 commit 45cceae
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/cli/clisqlshell/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,7 @@ func (c *cliState) doStartLine(nextState cliStateEnum) cliStateEnum {
c.atEOF = false
c.partialLines = c.partialLines[:0]
c.partialStmtsLen = 0
c.concatLines = ""

c.useContinuePrompt = false

Expand Down Expand Up @@ -1305,7 +1306,8 @@ func (c *cliState) doHandleCliCmd(loopState, nextState cliStateEnum) cliStateEnu

case `\.`:
if c.inCopy() {
c.concatLines += "\n" + `\.`
c.partialLines = append(c.partialLines, `\.`)
c.partialStmtsLen++
return cliRunStatement
}
return c.invalidSyntax(errState)
Expand Down Expand Up @@ -1737,7 +1739,7 @@ func (c *cliState) doPrepareStatementLine(
(c.inCopy() && (strings.HasSuffix(c.concatLines, "\n"+`\.`) || c.atEOF)) ||
// We're always at the end of a statement if EOF is reached in the
// single statement mode.
c.singleStatement && c.atEOF
(c.singleStatement && c.atEOF)
if c.atEOF {
// Definitely no more input expected.
if !endOfStmt {
Expand Down
16 changes: 16 additions & 0 deletions pkg/cli/interactive_tests/test_copy.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ eexpect "could not parse"

end_test

start_test "check EMPTY copy"

send "COPY t FROM STDIN;\r"
eexpect ">>"
send_eof
eexpect "COPY 0"
eexpect root@

send "COPY t FROM STDIN;\r"
eexpect ">>"
send "\\.\r"
eexpect "COPY 0"
eexpect root@

end_test

start_test "multi statement with COPY"
send "SELECT 1; COPY t FROM STDIN CSV;\r"
eexpect "COPY together with other statements in a query string is not supported"
Expand Down

0 comments on commit 45cceae

Please sign in to comment.