|
@@ -1,4 +1,4 @@
|
|
-// Copyright 2021 EMQ Technologies Co., Ltd.
|
|
|
|
|
|
+// Copyright 2021-2022 EMQ Technologies Co., Ltd.
|
|
//
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// you may not use this file except in compliance with the License.
|
|
@@ -115,7 +115,7 @@ func (p *StreamProcessor) execSave(stmt *ast.StreamStmt, statement string, repla
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
|
|
-func (p *StreamProcessor) ExecReplaceStream(statement string, st ast.StreamType) (string, error) {
|
|
|
|
|
|
+func (p *StreamProcessor) ExecReplaceStream(name string, statement string, st ast.StreamType) (string, error) {
|
|
parser := xsql.NewParser(strings.NewReader(statement))
|
|
parser := xsql.NewParser(strings.NewReader(statement))
|
|
stmt, err := xsql.Language.Parse(parser)
|
|
stmt, err := xsql.Language.Parse(parser)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -127,6 +127,9 @@ func (p *StreamProcessor) ExecReplaceStream(statement string, st ast.StreamType)
|
|
if s.StreamType != st {
|
|
if s.StreamType != st {
|
|
return "", errorx.NewWithCode(errorx.NOT_FOUND, fmt.Sprintf("%s %s is not found", ast.StreamTypeMap[st], s.Name))
|
|
return "", errorx.NewWithCode(errorx.NOT_FOUND, fmt.Sprintf("%s %s is not found", ast.StreamTypeMap[st], s.Name))
|
|
}
|
|
}
|
|
|
|
+ if string(s.Name) != name {
|
|
|
|
+ return "", fmt.Errorf("Replace %s fails: the sql statement must update the %s source.", name, name)
|
|
|
|
+ }
|
|
err = p.execSave(s, statement, true)
|
|
err = p.execSave(s, statement, true)
|
|
if err != nil {
|
|
if err != nil {
|
|
return "", fmt.Errorf("Replace %s fails: %v.", stt, err)
|
|
return "", fmt.Errorf("Replace %s fails: %v.", stt, err)
|