Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

fix(util): ignore comment only sql input (#9933)

7y-954687072892a
diff --git a/weed/util/sqlutil/splitter.go b/weed/util/sqlutil/splitter.go
index 098a7ecb35..a9d6befa99 100644
--- a/weed/util/sqlutil/splitter.go
+++ b/weed/util/sqlutil/splitter.go
@@ -133,10 +133,8 @@ func SplitStatements(query string) []string {
}
}
- // If no statements found, return the original query as a single statement
if len(statements) == 0 {
- return []string{strings.TrimSpace(strings.TrimSuffix(strings.TrimSpace(query), ";"))}
+ return []string{}
}
-
return statements
}
diff --git a/weed/util/sqlutil/splitter_test.go b/weed/util/sqlutil/splitter_test.go
index 91fac6196d..13f3baf2b8 100644
--- a/weed/util/sqlutil/splitter_test.go
+++ b/weed/util/sqlutil/splitter_test.go
@@ -96,6 +96,16 @@ func TestSplitStatements(t *testing.T) {
input: " \n\t ",
expected: []string{},
},
+ {
+ name: "Only single line comment",
+ input: "-- just a comment",
+ expected: []string{},
+ },
+ {
+ name: "Only multi-line comment",
+ input: "/* just a comment; with separator */",
+ expected: []string{},
+ },
}
for _, tt := range tests {