-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathresult.go
55 lines (45 loc) · 1.33 KB
/
result.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package redshiftdatasqldriver
import (
"database/sql/driver"
"fmt"
"github.com/aws/aws-sdk-go-v2/service/redshiftdata"
"github.com/aws/aws-sdk-go-v2/service/redshiftdata/types"
)
type redshiftDataResult struct {
affectedRows int64
}
func newResult(output *redshiftdata.DescribeStatementOutput) *redshiftDataResult {
debugLogger.Printf("[%s] create result", coalesce(output.Id))
return &redshiftDataResult{
affectedRows: output.ResultRows,
}
}
func newResultWithSubStatementData(st types.SubStatementData) *redshiftDataResult {
debugLogger.Printf("[%s] create result", coalesce(st.Id))
return &redshiftDataResult{
affectedRows: st.ResultRows,
}
}
func (r *redshiftDataResult) LastInsertId() (int64, error) {
return 0, fmt.Errorf("LastInsertId %w", ErrNotSupported)
}
func (r *redshiftDataResult) RowsAffected() (int64, error) {
return r.affectedRows, nil
}
type redshiftDataDelayedResult struct {
driver.Result
}
func (r *redshiftDataDelayedResult) LastInsertId() (int64, error) {
debugLogger.Printf("delayed result LastInsertId called")
if r.Result != nil {
return r.Result.LastInsertId()
}
return 0, ErrBeforeCommit
}
func (r *redshiftDataDelayedResult) RowsAffected() (int64, error) {
debugLogger.Printf("delayed result RowsAffected called")
if r.Result != nil {
return r.Result.RowsAffected()
}
return 0, ErrBeforeCommit
}