MCPcopy Create free account
hub / github.com/bytebase/bytebase / QueryConn

Method QueryConn

backend/plugin/db/dynamodb/dynamodb.go:167–201  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
167func (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
203type dynamodbQueryResultMeta struct {
204 columnType string

Callers

nothing calls this directly

Implementers 15

MockDriverbackend/plugin/advisor/utils_for_tests
Driverbackend/plugin/db/bigquery/bigquery.go
Driverbackend/plugin/db/mongodb/mongodb.go
Driverbackend/plugin/db/trino/trino.go
Driverbackend/plugin/db/redshift/redshift.go
Driverbackend/plugin/db/oracle/oracle.go
Driverbackend/plugin/db/dynamodb/dynamodb.go
Driverbackend/plugin/db/cosmosdb/cosmosdb.go
Driverbackend/plugin/db/spanner/spanner.go
Driverbackend/plugin/db/mssql/mssql.go
Driverbackend/plugin/db/mysql/mysql.go
Driverbackend/plugin/db/pg/pg.go

Calls 4

querySinglePartiQLMethod · 0.95
SplitMultiSQLFunction · 0.92
FilterEmptyStatementsFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected