mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-22 14:43:33 +08:00
fixes
This commit is contained in:
@@ -22,7 +22,7 @@ import (
|
||||
func splitSQLStatements(query string) []string {
|
||||
var statements []string
|
||||
var current strings.Builder
|
||||
|
||||
|
||||
query = strings.TrimSpace(query)
|
||||
if query == "" {
|
||||
return []string{}
|
||||
@@ -30,57 +30,50 @@ func splitSQLStatements(query string) []string {
|
||||
|
||||
runes := []rune(query)
|
||||
i := 0
|
||||
|
||||
|
||||
for i < len(runes) {
|
||||
char := runes[i]
|
||||
|
||||
|
||||
// Handle single-line comments (-- comment)
|
||||
if char == '-' && i+1 < len(runes) && runes[i+1] == '-' {
|
||||
// Include the entire comment in the current statement
|
||||
// Skip the entire comment without including it in any statement
|
||||
for i < len(runes) && runes[i] != '\n' && runes[i] != '\r' {
|
||||
current.WriteRune(runes[i])
|
||||
i++
|
||||
}
|
||||
// Include the newline if present
|
||||
// Skip the newline if present
|
||||
if i < len(runes) {
|
||||
current.WriteRune(runes[i])
|
||||
i++
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Handle multi-line comments (/* comment */)
|
||||
|
||||
// Handle multi-line comments (/* comment */)
|
||||
if char == '/' && i+1 < len(runes) && runes[i+1] == '*' {
|
||||
current.WriteRune(char) // Include the /*
|
||||
// Skip the /* opening
|
||||
i++
|
||||
i++
|
||||
if i < len(runes) {
|
||||
current.WriteRune(runes[i])
|
||||
i++
|
||||
}
|
||||
|
||||
// Skip to end of comment or end of input
|
||||
// Skip to end of comment or end of input without including content
|
||||
for i < len(runes) {
|
||||
current.WriteRune(runes[i])
|
||||
if runes[i] == '*' && i+1 < len(runes) && runes[i+1] == '/' {
|
||||
i++
|
||||
current.WriteRune(runes[i]) // Include the */
|
||||
i++
|
||||
i++ // Skip the *
|
||||
i++ // Skip the /
|
||||
break
|
||||
}
|
||||
i++
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
// Handle single-quoted strings
|
||||
if char == '\'' {
|
||||
current.WriteRune(char)
|
||||
i++
|
||||
|
||||
|
||||
for i < len(runes) {
|
||||
char = runes[i]
|
||||
current.WriteRune(char)
|
||||
|
||||
|
||||
if char == '\'' {
|
||||
// Check if it's an escaped quote
|
||||
if i+1 < len(runes) && runes[i+1] == '\'' {
|
||||
@@ -97,16 +90,16 @@ func splitSQLStatements(query string) []string {
|
||||
i++
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
// Handle double-quoted identifiers
|
||||
if char == '"' {
|
||||
current.WriteRune(char)
|
||||
i++
|
||||
|
||||
|
||||
for i < len(runes) {
|
||||
char = runes[i]
|
||||
current.WriteRune(char)
|
||||
|
||||
|
||||
if char == '"' {
|
||||
// Check if it's an escaped quote
|
||||
if i+1 < len(runes) && runes[i+1] == '"' {
|
||||
@@ -123,7 +116,7 @@ func splitSQLStatements(query string) []string {
|
||||
i++
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
// Handle semicolon (statement separator)
|
||||
if char == ';' {
|
||||
stmt := strings.TrimSpace(current.String())
|
||||
@@ -134,7 +127,7 @@ func splitSQLStatements(query string) []string {
|
||||
} else {
|
||||
current.WriteRune(char)
|
||||
}
|
||||
|
||||
|
||||
i++
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user