starRocksBackendAlive reports whether SHOW BACKENDS lists a backend with Alive=true.
(ctx context.Context, db *sql.DB)
| 362 | |
| 363 | // starRocksBackendAlive reports whether SHOW BACKENDS lists a backend with Alive=true. |
| 364 | func starRocksBackendAlive(ctx context.Context, db *sql.DB) bool { |
| 365 | rows, err := db.QueryContext(ctx, "SHOW BACKENDS") |
| 366 | if err != nil { |
| 367 | return false |
| 368 | } |
| 369 | defer rows.Close() |
| 370 | cols, err := rows.Columns() |
| 371 | if err != nil { |
| 372 | return false |
| 373 | } |
| 374 | aliveIdx := -1 |
| 375 | for i, c := range cols { |
| 376 | if strings.EqualFold(c, "Alive") { |
| 377 | aliveIdx = i |
| 378 | break |
| 379 | } |
| 380 | } |
| 381 | if aliveIdx < 0 { |
| 382 | return false |
| 383 | } |
| 384 | alive := false |
| 385 | for rows.Next() { |
| 386 | vals := make([]sql.RawBytes, len(cols)) |
| 387 | ptrs := make([]any, len(cols)) |
| 388 | for i := range vals { |
| 389 | ptrs[i] = &vals[i] |
| 390 | } |
| 391 | if err := rows.Scan(ptrs...); err != nil { |
| 392 | return false |
| 393 | } |
| 394 | if strings.EqualFold(string(vals[aliveIdx]), "true") { |
| 395 | alive = true |
| 396 | break |
| 397 | } |
| 398 | } |
| 399 | if err := rows.Err(); err != nil { |
| 400 | return false |
| 401 | } |
| 402 | return alive |
| 403 | } |
| 404 | |
| 405 | // GetMSSQLContainer creates a Microsoft SQL Server container for testing |
| 406 | func GetMSSQLContainer(ctx context.Context) (retC *Container, retErr error) { |
no test coverage detected