Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jovakaloom committed Nov 16, 2022
1 parent f01a111 commit 02eec62
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cnuodb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ int nuodb_statement_set_query_micros(struct nuodb *db, struct nuodb_statement *s
try {
if (st) {
PreparedStatement *stmt = reinterpret_cast<PreparedStatement *>(st);
// Set the timeout in micro seconds; zero means there is no limit.
stmt->setQueryTimeoutMicros(timeout_micro_seconds);
st = 0;
}
return 0;
} catch (SQLException &e) {
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/tilinna/go-nuodb

go 1.13
9 changes: 9 additions & 0 deletions nuodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ type Stmt struct {
ddlStatement bool
}

var _ interface {
driver.Stmt
driver.StmtQueryContext
// driver.StmtExecContext
} = (*Stmt)(nil)

type Result struct {
rowsAffected C.int64_t
lastInsertId C.int64_t
Expand Down Expand Up @@ -360,6 +366,9 @@ func (stmt *Stmt) addTimeoutFromContext(ctx context.Context) error {
return nil
}

// getMicrosecondsUntilDeadline returns the number of micro seconds until the context's deadline is reached.
// Returns an error if the context is already done.
// N.B. A value of zero means no limit.
func getMicrosecondsUntilDeadline(ctx context.Context) (uSec C.int64_t, err error) {
if deadline, ok := ctx.Deadline(); ok {
uSec = C.int64_t(time.Until(deadline).Microseconds())
Expand Down

0 comments on commit 02eec62

Please sign in to comment.