mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-23 07:03:34 +08:00
fixes
This commit is contained in:
@@ -303,7 +303,10 @@ SQL Query Flow:
|
|||||||
## Success Metrics
|
## Success Metrics
|
||||||
|
|
||||||
* **Feature Completeness:** Support for all specified DDL/DML operations
|
* **Feature Completeness:** Support for all specified DDL/DML operations
|
||||||
* **Performance:** Query latency < 100ms for simple selects, < 1s for complex joins
|
* **Performance:**
|
||||||
|
* **Simple SELECT queries**: < 100ms latency for single-table queries with up to 3 WHERE predicates on ≤ 100K records
|
||||||
|
* **Complex queries**: < 1s latency for queries involving aggregations (COUNT, SUM, MAX, MIN) on ≤ 1M records
|
||||||
|
* **Time-range queries**: < 500ms for timestamp-based filtering on ≤ 500K records within 24-hour windows
|
||||||
* **Scalability:** Handle topics with millions of messages efficiently
|
* **Scalability:** Handle topics with millions of messages efficiently
|
||||||
* **Reliability:** 99.9% success rate for valid SQL operations
|
* **Reliability:** 99.9% success rate for valid SQL operations
|
||||||
* **Usability:** Intuitive SQL interface matching standard database expectations
|
* **Usability:** Intuitive SQL interface matching standard database expectations
|
||||||
|
@@ -10,7 +10,6 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
|
||||||
"github.com/seaweedfs/seaweedfs/weed/server/postgres"
|
"github.com/seaweedfs/seaweedfs/weed/server/postgres"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||||
)
|
)
|
||||||
@@ -363,7 +362,7 @@ func validatePortNumber(port int) error {
|
|||||||
return fmt.Errorf("port number must be between 1 and 65535, got %d", port)
|
return fmt.Errorf("port number must be between 1 and 65535, got %d", port)
|
||||||
}
|
}
|
||||||
if port < 1024 {
|
if port < 1024 {
|
||||||
glog.Warningf("port number %d may require root privileges", port)
|
fmt.Fprintf(os.Stderr, "Warning: port number %d may require root privileges\n", port)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@@ -36,14 +36,12 @@ func splitSQLStatements(query string) []string {
|
|||||||
|
|
||||||
// Handle single-line comments (-- comment)
|
// Handle single-line comments (-- comment)
|
||||||
if char == '-' && i+1 < len(runes) && runes[i+1] == '-' {
|
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' {
|
for i < len(runes) && runes[i] != '\n' && runes[i] != '\r' {
|
||||||
current.WriteRune(runes[i])
|
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
// Include the newline if present
|
// Skip the newline if present
|
||||||
if i < len(runes) {
|
if i < len(runes) {
|
||||||
current.WriteRune(runes[i])
|
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@@ -51,20 +49,15 @@ func splitSQLStatements(query string) []string {
|
|||||||
|
|
||||||
// Handle multi-line comments (/* comment */)
|
// Handle multi-line comments (/* comment */)
|
||||||
if char == '/' && i+1 < len(runes) && runes[i+1] == '*' {
|
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++
|
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) {
|
for i < len(runes) {
|
||||||
current.WriteRune(runes[i])
|
|
||||||
if runes[i] == '*' && i+1 < len(runes) && runes[i+1] == '/' {
|
if runes[i] == '*' && i+1 < len(runes) && runes[i+1] == '/' {
|
||||||
i++
|
i++ // Skip the *
|
||||||
current.WriteRune(runes[i]) // Include the */
|
i++ // Skip the /
|
||||||
i++
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
i++
|
i++
|
||||||
|
@@ -44,22 +44,22 @@ func TestSplitSQLStatements(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Single line comment",
|
name: "Single line comment",
|
||||||
input: "SELECT * FROM users; -- This is a comment\nSELECT * FROM orders;",
|
input: "SELECT * FROM users; -- This is a comment\nSELECT * FROM orders;",
|
||||||
expected: []string{"SELECT * FROM users", "-- This is a comment\nSELECT * FROM orders"},
|
expected: []string{"SELECT * FROM users", "SELECT * FROM orders"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Single line comment with semicolon",
|
name: "Single line comment with semicolon",
|
||||||
input: "SELECT * FROM users; -- Comment with; semicolon\nSELECT * FROM orders;",
|
input: "SELECT * FROM users; -- Comment with; semicolon\nSELECT * FROM orders;",
|
||||||
expected: []string{"SELECT * FROM users", "-- Comment with; semicolon\nSELECT * FROM orders"},
|
expected: []string{"SELECT * FROM users", "SELECT * FROM orders"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Multi-line comment",
|
name: "Multi-line comment",
|
||||||
input: "SELECT * FROM users; /* Multi-line\ncomment */ SELECT * FROM orders;",
|
input: "SELECT * FROM users; /* Multi-line\ncomment */ SELECT * FROM orders;",
|
||||||
expected: []string{"SELECT * FROM users", "/* Multi-line\ncomment */ SELECT * FROM orders"},
|
expected: []string{"SELECT * FROM users", "SELECT * FROM orders"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Multi-line comment with semicolon",
|
name: "Multi-line comment with semicolon",
|
||||||
input: "SELECT * FROM users; /* Comment with; semicolon */ SELECT * FROM orders;",
|
input: "SELECT * FROM users; /* Comment with; semicolon */ SELECT * FROM orders;",
|
||||||
expected: []string{"SELECT * FROM users", "/* Comment with; semicolon */ SELECT * FROM orders"},
|
expected: []string{"SELECT * FROM users", "SELECT * FROM orders"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Complex mixed case",
|
name: "Complex mixed case",
|
||||||
@@ -68,9 +68,7 @@ func TestSplitSQLStatements(t *testing.T) {
|
|||||||
INSERT INTO users VALUES ('name''s value', "id""field");`,
|
INSERT INTO users VALUES ('name''s value', "id""field");`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
`SELECT 'test;string', "quoted;id" FROM users`,
|
`SELECT 'test;string', "quoted;id" FROM users`,
|
||||||
`-- Comment; here
|
`INSERT INTO users VALUES ('name''s value', "id""field")`,
|
||||||
/* Another; comment */
|
|
||||||
INSERT INTO users VALUES ('name''s value', "id""field")`,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -119,7 +117,7 @@ func TestSplitSQLStatements_EdgeCases(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Nested comments are not supported but handled gracefully",
|
name: "Nested comments are not supported but handled gracefully",
|
||||||
input: "SELECT * FROM users; /* Outer /* inner */ comment */ SELECT * FROM orders;",
|
input: "SELECT * FROM users; /* Outer /* inner */ comment */ SELECT * FROM orders;",
|
||||||
expected: []string{"SELECT * FROM users", "/* Outer /* inner */ comment */ SELECT * FROM orders"},
|
expected: []string{"SELECT * FROM users", "comment */ SELECT * FROM orders"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Unterminated string (malformed SQL)",
|
name: "Unterminated string (malformed SQL)",
|
||||||
@@ -129,7 +127,7 @@ func TestSplitSQLStatements_EdgeCases(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Unterminated comment (malformed SQL)",
|
name: "Unterminated comment (malformed SQL)",
|
||||||
input: "SELECT * FROM users; /* unterminated comment",
|
input: "SELECT * FROM users; /* unterminated comment",
|
||||||
expected: []string{"SELECT * FROM users", "/* unterminated comment"},
|
expected: []string{"SELECT * FROM users"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Multiple semicolons in quotes",
|
name: "Multiple semicolons in quotes",
|
||||||
|
Reference in New Issue
Block a user