-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
67 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package spanner | ||
|
||
import ( | ||
"github.com/apstndb/gsqlutils" | ||
) | ||
|
||
// Directly use of memefish is permitted only in this file. | ||
func toStatements(filename string, data []byte) ([]string, error) { | ||
rawStmts, err := gsqlutils.SeparateInputPreserveCommentsWithStatus(filename, string(data)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var result []string | ||
for _, rawStmt := range rawStmts { | ||
stripped, err := gsqlutils.SimpleStripComments("", rawStmt.Statement) | ||
if err != nil { | ||
return nil, err | ||
} | ||
result = append(result, stripped) | ||
} | ||
return result, nil | ||
} | ||
|
||
func isDML(statement string) bool { | ||
token, err := gsqlutils.FirstNonHintToken("", statement) | ||
if err != nil { | ||
return false | ||
} | ||
return token.IsKeywordLike("INSERT") | ||
} | ||
|
||
func isPartitionedDML(statement string) bool { | ||
token, err := gsqlutils.FirstNonHintToken("", statement) | ||
if err != nil { | ||
return false | ||
} | ||
return token.IsKeywordLike("UPDATE") || token.IsKeywordLike("DELETE") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters