timestamptz scan → bind roundtrip loses equality (binary and text parameters alike)
- Dominant language
- Go
- Stars
- 2.1k
- Forks
- 73
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 129
Description
**Version:** reproduced on `dolthub/doltgresql:1.1.0` and `1.0.0` (clean Docker container, empty database; latest run 2026-08-15)
**Client:** Go, `jackc/pgx/v5` v5.10.0 (default extended protocol)
**Class:** silently wrong — 0 rows instead of 1, no error
## Repro
```go
package main
import (
"context"
"fmt"
"time"
"github.com/jackc/pgx/v5"
)
func main() {
ctx := context.Background()
c, _ := pgx.Connect(ctx, "postgres://postgres:password@localhost:15432/postgres?sslmode=disable")
c.Exec(ctx, "CREATE TABLE g_tstz (id int PRIMARY KEY, ts timestamptz)")
c.Exec(ctx, "INSERT INTO g_tstz VALUES (1, now())")
var ts time.Time
c.QueryRow(ctx, "SELECT ts FROM g_tstz WHERE id = 1").Scan(&ts)
var n, n2 int
c.QueryRow(ctx, "SELECT count(*) FROM g_tstz WHERE ts = $1", ts).Scan(&n)
c.QueryRow(ctx, "SELECT count(*) FROM g_tstz WHERE ts = $1::timestamptz",
ts.Format(time.RFC3339Nano)).Scan(&n2)
fmt.Println("binary bind:", n, "text param with cast:", n2) // want 1 and 1
}
```
## Actual (DoltgreSQL 1.1.0)
```
binary bind: 0 text param with cast: 0
```
## Expected (PostgreSQL 15, same program)
```
binary bind: 1 text param with cast: 1
```
## Impact
A value read from the database does not equal itself when bound back — optimistic
concurrency checks of the form `WHERE updated_at = $1` never match and updates are
silently skipped. The row is also lost when the same value is sent as RFC3339 text
with an explicit `::timestamptz` cast, so the divergence sits in timestamptz
parameter handling/equality generally, not exclusively in the binary-format decode
path.
Related (both closed, other direction of the wire): #2318 (server→client TIMESTAMPTZ
format) and #2360 (JSONB binary format) — this one is about the client→server
parameter path.
---
*Part of a clean-room deviation battery (fresh official Docker container + empty
database per probe, `postgres:15` control running identical probes). Filing the
findings together so they can be triaged/batched as a set — index in a comment on
#2600. Happy to re-test any of them against a nightly/branch build.*
Contributor guide
Assessment
This issue has not been assessed yet.