QueryConn queries a SQL statement in a given connection. The result.Rows.Values can be nil in DynamoDB, which means the column is not set in the row.
(ctx context.Context, _ *sql.Conn, statement string, queryContext db.QueryContext)
| 165 | // QueryConn queries a SQL statement in a given connection. |
| 166 | // The result.Rows.Values can be nil in DynamoDB, which means the column is not set in the row. |
| 167 | func (d *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, queryContext db.QueryContext) ([]*v1pb.QueryResult, error) { |
| 168 | if queryContext.Explain { |
| 169 | return nil, errors.New("DynamoDB does not support EXPLAIN") |
| 170 | } |
| 171 | |
| 172 | singleSQLs, err := base.SplitMultiSQL(storepb.Engine_DYNAMODB, statement) |
| 173 | if err != nil { |
| 174 | return nil, errors.Wrapf(err, "failed to split multi statement") |
| 175 | } |
| 176 | singleSQLs = base.FilterEmptyStatements(singleSQLs) |
| 177 | if len(singleSQLs) == 0 { |
| 178 | return nil, nil |
| 179 | } |
| 180 | |
| 181 | var results []*v1pb.QueryResult |
| 182 | for _, singleSQL := range singleSQLs { |
| 183 | startTime := time.Now() |
| 184 | result, err := d.querySinglePartiQL(ctx, singleSQL.Text, queryContext) |
| 185 | stop := false |
| 186 | if err != nil { |
| 187 | result = &v1pb.QueryResult{ |
| 188 | Error: err.Error(), |
| 189 | } |
| 190 | stop = true |
| 191 | } |
| 192 | result.Latency = durationpb.New(time.Since(startTime)) |
| 193 | result.Statement = statement |
| 194 | result.RowsCount = int64(len(result.Rows)) |
| 195 | results = append(results, result) |
| 196 | if stop { |
| 197 | break |
| 198 | } |
| 199 | } |
| 200 | return results, nil |
| 201 | } |
| 202 | |
| 203 | type dynamodbQueryResultMeta struct { |
| 204 | columnType string |
nothing calls this directly
no test coverage detected