@@ -16,6 +16,7 @@ import (
16
16
"os"
17
17
"path/filepath"
18
18
"regexp"
19
+ "slices"
19
20
"sort"
20
21
"strconv"
21
22
"strings"
@@ -54,8 +55,11 @@ and stats in an unzipped statement bundle directory.
54
55
Args : cobra .ExactArgs (1 ),
55
56
}
56
57
57
- var placeholderPairs []string
58
- var explainPrefix string
58
+ var (
59
+ placeholderPairs []string
60
+ explainPrefix string
61
+ commentPattern = regexp .MustCompile (`^\s*--` )
62
+ )
59
63
60
64
func init () {
61
65
statementBundleRecreateCmd .RunE = clierrorplus .MaybeDecorateError (runBundleRecreate )
@@ -169,8 +173,10 @@ func runBundleRecreate(cmd *cobra.Command, args []string) (resErr error) {
169
173
return runDemoInternal (cmd , nil /* gen */ , func (ctx context.Context , conn clisqlclient.Conn ) error {
170
174
// SET CLUSTER SETTING statements cannot be executed in multi-statement
171
175
// implicit transaction, so we need to separate them out into their own
172
- // implicit transactions.
173
- initStmts := strings .Split (string (bundle .env ), "SET CLUSTER SETTING" )
176
+ // implicit transactions. Comments are stripped from the env file first.
177
+ lines := strings .Split (string (bundle .env ), "\n " )
178
+ lines = slices .DeleteFunc (lines , commentPattern .MatchString )
179
+ initStmts := strings .Split (strings .Join (lines , "\n " ), "SET CLUSTER SETTING" )
174
180
for i := 1 ; i < len (initStmts ); i ++ {
175
181
initStmts [i ] = "SET CLUSTER SETTING " + initStmts [i ]
176
182
}
0 commit comments