Skip to content

Commit 41d573d

Browse files
committed
Add enable_source/disable_source
1 parent 3c938b5 commit 41d573d

File tree

6 files changed

+28
-7
lines changed

6 files changed

+28
-7
lines changed

include/hello.inc

-2
This file was deleted.

r/source.result

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
first line
1+
before source
22
Hello from the included file
33
SELECT 1
44
1
55
1
6-
last line
6+
after source
7+
Goodbye from the included file
8+
SELECT 3
9+
3
10+
3

src/main.go

+9
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ var (
4747
retryConnCount int
4848
collationDisable bool
4949
checkErr bool
50+
disableSource bool
5051
)
5152

5253
func init() {
@@ -516,7 +517,15 @@ func (t *tester) runQueries(queries []query) (int, error) {
516517
q.location(), q.Query))
517518
}
518519
t.replaceRegex = regex
520+
case Q_ENABLE_SOURCE:
521+
disableSource = false
522+
case Q_DISABLE_SOURCE:
523+
disableSource = true
519524
case Q_SOURCE:
525+
if disableSource {
526+
log.WithFields(log.Fields{"line": q.location()}).Warn("source command disabled")
527+
break
528+
}
520529
fileName := strings.TrimSpace(q.Query)
521530
cwd, err := os.Getwd()
522531
if err != nil {

src/query.go

+2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ const (
124124
Q_COMMENT /* Comments, ignored. */
125125
Q_COMMENT_WITH_COMMAND
126126
Q_EMPTY_LINE
127+
Q_DISABLE_SOURCE
128+
Q_ENABLE_SOURCE
127129
)
128130

129131
// ParseQueries parses an array of string into an array of query object.

src/type.go

+2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ var commandMap = map[string]int{
114114
"single_query": Q_SINGLE_QUERY,
115115
"begin_concurrent": Q_BEGIN_CONCURRENT,
116116
"end_concurrent": Q_END_CONCURRENT,
117+
"disable_source": Q_DISABLE_SOURCE,
118+
"enable_source": Q_ENABLE_SOURCE,
117119
}
118120

119121
func findType(cmdName string) int {

t/source.test

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
--echo first line
2-
--source include/hello.inc
3-
--echo last line
1+
--echo before source
2+
--source include/hello1.inc
3+
--echo after source
4+
5+
--disable_source
6+
--source include/hello2.inc
7+
--enable_source
8+
9+
--source include/hello3.inc

0 commit comments

Comments
 (0)