mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-24 23:10:41 +02:00
address comments
This commit is contained in:
1 parent
ac83adc6ce
commit
e901abffd3
4 files changed
+79
-53
No files matched your search
+8
-1
@@ -11,6 +11,7 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||
"github.com/seaweedfs/seaweedfs/weed/server/postgres"
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
)
|
||||
@@ -183,6 +184,12 @@ func runDB(cmd *Command, args []string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Validate port number
|
||||
if err := validatePortNumber(*dbOptions.port); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
return false
|
||||
}
|
||||
|
||||
// Setup TLS if requested
|
||||
var tlsConfig *tls.Config
|
||||
if *dbOptions.tlsCert != "" && *dbOptions.tlsKey != "" {
|
||||
@@ -357,7 +364,7 @@ func validatePortNumber(port int) error {
|
||||
return fmt.Errorf("port number must be between 1 and 65535, got %d", port)
|
||||
}
|
||||
if port < 1024 {
|
||||
return fmt.Errorf("port number %d may require root privileges", port)
|
||||
glog.Warningf("port number %d may require root privileges", port)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+7
-2
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/peterh/liner"
|
||||
"github.com/seaweedfs/seaweedfs/weed/query/engine"
|
||||
"github.com/seaweedfs/seaweedfs/weed/util/grace"
|
||||
"github.com/xwb1989/sqlparser"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -155,8 +156,12 @@ func executeFileQueries(ctx *SQLContext, filename string) bool {
|
||||
fmt.Printf("Executing queries from %s against %s...\n", filename, *sqlMaster)
|
||||
}
|
||||
|
||||
// Split file content into individual queries (simple approach)
|
||||
queries := strings.Split(string(content), ";")
|
||||
// Split file content into individual queries (robust approach)
|
||||
queries, err := sqlparser.SplitStatementToPieces(string(content))
|
||||
if err != nil {
|
||||
fmt.Printf("Error splitting SQL statements from file %s: %v\n", filename, err)
|
||||
return false
|
||||
}
|
||||
|
||||
for i, query := range queries {
|
||||
query = strings.TrimSpace(query)
|
||||
|
||||
Reference in new issue
Block a user