| 24 | } |
| 25 | |
| 26 | func (g *PostgreSQLColumnGetter) GetColumnNames(ctx context.Context, query string) ([]string, error) { |
| 27 | conn, err := g.pool.Acquire(ctx) |
| 28 | if err != nil { |
| 29 | return nil, err |
| 30 | } |
| 31 | defer conn.Release() |
| 32 | |
| 33 | desc, err := conn.Conn().Prepare(ctx, "", query) |
| 34 | if err != nil { |
| 35 | return nil, err |
| 36 | } |
| 37 | |
| 38 | columns := make([]string, len(desc.Fields)) |
| 39 | for i, field := range desc.Fields { |
| 40 | columns[i] = field.Name |
| 41 | } |
| 42 | |
| 43 | return columns, nil |
| 44 | } |
| 45 | |
| 46 | // MySQLColumnGetter implements ColumnGetter for MySQL. Column names are read |
| 47 | // from the result set metadata returned by executing the query; the test |