Skip to content

Commit cfd7148

Browse files
EDsCODEclaude
andcommitted
Fix COPY FROM STDIN regex to handle transpiled SQL
The transpiler removes the space between table name and column list: - Before: COPY "table" ("col") FROM STDIN - After: COPY table(col) FROM STDIN Updated regex to use \s* (optional space) instead of \s+ (required space) so it matches both formats. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 51d27be commit cfd7148

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

server/conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ func (c *clientConn) buildCommandTag(cmdType string, result sql.Result) string {
608608
// Regular expressions for parsing COPY commands
609609
var (
610610
copyToStdoutRegex = regexp.MustCompile(`(?i)COPY\s+(.+?)\s+TO\s+STDOUT`)
611-
copyFromStdinRegex = regexp.MustCompile(`(?i)COPY\s+(\S+)\s+(?:\(([^)]+)\)\s+)?FROM\s+STDIN`)
611+
copyFromStdinRegex = regexp.MustCompile(`(?i)COPY\s+(\S+)\s*(?:\(([^)]+)\)\s*)?FROM\s+STDIN`)
612612
copyWithCSVRegex = regexp.MustCompile(`(?i)\bCSV\b`)
613613
copyWithHeaderRegex = regexp.MustCompile(`(?i)\bHEADER\b`)
614614
copyDelimiterRegex = regexp.MustCompile(`(?i)\bDELIMITER\s+['"](.)['"]\b`)

0 commit comments

Comments
 (0)