Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit bb163f6

Browse files
authored
Merge pull request ClickHouse#276 from naylinn69/master
Watch context cancel in stmt.execContext
2 parents 7b0f96e + 07447f4 commit bb163f6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

clickhouse.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,18 @@ func (ch *clickhouse) watchCancel(ctx context.Context) func() {
318318
}
319319
return func() {}
320320
}
321+
322+
func (ch *clickhouse) ExecContext(ctx context.Context, query string,
323+
args []driver.NamedValue) (driver.Result, error) {
324+
finish := ch.watchCancel(ctx)
325+
defer finish()
326+
stmt, err := ch.PrepareContext(ctx, query)
327+
if err != nil {
328+
return nil, err
329+
}
330+
dargs := make([]driver.Value, len(args))
331+
for i, nv := range args {
332+
dargs[i] = nv.Value
333+
}
334+
return stmt.Exec(dargs)
335+
}

0 commit comments

Comments
 (0)