diff options
Diffstat (limited to 'benchmark/internal/oblast_pgx/results.go')
| -rw-r--r-- | benchmark/internal/oblast_pgx/results.go | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/benchmark/internal/oblast_pgx/results.go b/benchmark/internal/oblast_pgx/results.go new file mode 100644 index 0000000..3ccb5ce --- /dev/null +++ b/benchmark/internal/oblast_pgx/results.go @@ -0,0 +1,66 @@ +// SPDX-FileCopyrightText: 2026 Stefan Majewsky <majewsky@gmx.net> +// SPDX-License-Identifier: Apache-2.0 + +package oblast_pgx + +import ( + "database/sql" + "errors" + + "github.com/jackc/pgx/v5" + "github.com/jackc/pgx/v5/pgconn" + "go.xyrillian.de/oblast/handle" +) + +type wrappedRows struct { + inner pgx.Rows +} + +var _ handle.Rows = wrappedRows{} + +// Columns implements the [handle.Rows] interface. +func (r wrappedRows) Columns() ([]string, error) { + descriptions := r.inner.FieldDescriptions() + result := make([]string, len(descriptions)) + for idx, desc := range descriptions { + result[idx] = desc.Name + } + return result, nil +} + +// Close implements the [handle.Rows] interface. +func (r wrappedRows) Close() error { + r.inner.Close() + return nil +} + +// Err implements the [handle.Rows] interface. +func (r wrappedRows) Err() error { + return r.inner.Err() +} + +// Next implements the [handle.Rows] interface. +func (r wrappedRows) Next() bool { + return r.inner.Next() +} + +// Scan implements the [handle.Rows] interface. +func (r wrappedRows) Scan(args ...any) error { + return r.inner.Scan(args...) +} + +type wrappedResult struct { + inner pgconn.CommandTag +} + +var _ sql.Result = wrappedResult{} + +// LastInsertId implements the [sql.Result] interface. +func (r wrappedResult) LastInsertId() (int64, error) { + return 0, errors.New("PostgreSQL does not support LastInsertId()") +} + +// LastInsertId implements the [sql.Result] interface. +func (r wrappedResult) RowsAffected() (int64, error) { + return r.inner.RowsAffected(), nil +} |
