From 02eec624a3e7bc23b931a8652550d40acc21181b Mon Sep 17 00:00:00 2001 From: Joel Jr Vanier Date: Wed, 16 Nov 2022 11:53:27 -0500 Subject: [PATCH] review comments --- cnuodb.cpp | 2 +- go.mod | 3 +++ nuodb.go | 9 +++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 go.mod diff --git a/cnuodb.cpp b/cnuodb.cpp index 5fce737..cafc127 100644 --- a/cnuodb.cpp +++ b/cnuodb.cpp @@ -302,8 +302,8 @@ int nuodb_statement_set_query_micros(struct nuodb *db, struct nuodb_statement *s try { if (st) { PreparedStatement *stmt = reinterpret_cast(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) { diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..792d2eb --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/tilinna/go-nuodb + +go 1.13 diff --git a/nuodb.go b/nuodb.go index d5fcbbb..e6bc1d0 100644 --- a/nuodb.go +++ b/nuodb.go @@ -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 @@ -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())