Sample
github.com/jackc/pgx/v5 v5.10.0: pgconn.NewCommandTag
Verified sample for golang github.com/jackc/pgx/v5 v5.10.0: pgconn.NewCommandTag. The contract ran on go 1.26 · linux alpine/x64 · docker and passed.
sha256:57c689b4185f01915428e3256224fa339e8976d0fdc45fbf667c3f3b9a4ba909
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-28 |
Case
HOW- Goal
- verify github.com/jackc/pgx/v5/pgconn.NewCommandTag in pkg:golang/github.com/jackc/pgx/v5@v5.10.0
- Packages
- Symbols
-
- github.com/jackc/pgx/v5/pgconn.NewCommandTag
- Environment
- go 1.26.6
- Created
- 2026-08-28T01:17:41Z
Contract
- pgconn.NewCommandTag parses PostgreSQL command tag strings and provides command type predicates and rows affected counts
- CommandTag methods Insert, Update, Delete, and Select identify standard SQL operations
- CommandTag.RowsAffected extracts the number of affected rows from command tags
- sample helpers provide parsing, formatting, and mutation classification for command tags
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- sample.go
- spec.json
- test/contract.go
Source
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify github.com/jackc/pgx/v5/pgconn.NewCommandTag in pkg:golang/github.com/jackc/pgx/v5@v5.10.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/jackc/pgx/v5@v5.10.0
Demonstrate these symbols/APIs:
- github.com/jackc/pgx/v5/pgconn.NewCommandTag
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:da9fc1aab62e544d39c5d4af603daba8562dc632642891b8a12be1df97fbea5d","contract":["pgconn.NewCommandTag parses PostgreSQL command tag strings and provides command type predicates and rows affected counts","CommandTag methods Insert, Update, Delete, and Select identify standard SQL operations","CommandTag.RowsAffected extracts the number of affected rows from command tags","sample helpers provide parsing, formatting, and mutation classification for command tags"],"goal":"verify github.com/jackc/pgx/v5/pgconn.NewCommandTag in pkg:golang/github.com/jackc/pgx/v5@v5.10.0","kind":"HOW","packages":["pkg:golang/github.com/jackc/pgx/v5@v5.10.0"],"schemaVersion":1,"symbols":["github.com/jackc/pgx/v5/pgconn.NewCommandTag"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/jackc/pgx/v5@v5.10.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/jackc/pgx/v5@v5.10.0","symbols":["github.com/jackc/pgx/v5/pgconn.NewCommandTag"],"verifierAdapter":"golang@1"}
module sample
go 1.26.5
require github.com/jackc/pgx/v5 v5.10.0
require (
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
golang.org/x/text v0.29.0 // indirect
)
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.10.0 h1:VhSvgU2jSli8o3AqIEOTJr7rZwAEUVo4E4XhR94Zfr0=
github.com/jackc/pgx/v5 v5.10.0/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
package sample
import (
"fmt"
"strings"
"github.com/jackc/pgx/v5/pgconn"
)
// ParseCommandTag constructs a pgconn.CommandTag from a raw PostgreSQL command tag string.
func ParseCommandTag(rawTag string) pgconn.CommandTag {
return pgconn.NewCommandTag(rawTag)
}
// CommandSummary returns the command category string and the number of rows affected.
func CommandSummary(tag pgconn.CommandTag) (string, int64) {
rows := tag.RowsAffected()
switch {
case tag.Insert():
return "INSERT", rows
case tag.Update():
return "UPDATE", rows
case tag.Delete():
return "DELETE", rows
case tag.Select():
return "SELECT", rows
default:
parts := strings.Fields(tag.String())
if len(parts) > 0 {
return parts[0], rows
}
return "UNKNOWN", rows
}
}
// IsMutation returns true if the command tag represents an INSERT, UPDATE, or DELETE operation.
func IsMutation(tag pgconn.CommandTag) bool {
return tag.Insert() || tag.Update() || tag.Delete()
}
// FormatCommandTag formats standard command tag strings and wraps them into pgconn.CommandTag.
func FormatCommandTag(cmdType string, rowsAffected int64) pgconn.CommandTag {
upper := strings.ToUpper(strings.TrimSpace(cmdType))
switch upper {
case "INSERT":
return pgconn.NewCommandTag(fmt.Sprintf("INSERT 0 %d", rowsAffected))
case "UPDATE":
return pgconn.NewCommandTag(fmt.Sprintf("UPDATE %d", rowsAffected))
case "DELETE":
return pgconn.NewCommandTag(fmt.Sprintf("DELETE %d", rowsAffected))
case "SELECT":
return pgconn.NewCommandTag(fmt.Sprintf("SELECT %d", rowsAffected))
default:
if rowsAffected > 0 {
return pgconn.NewCommandTag(fmt.Sprintf("%s %d", upper, rowsAffected))
}
return pgconn.NewCommandTag(upper)
}
}
// BatchSummary aggregates total rows affected and counts of operations across command tags.
func BatchSummary(tags []pgconn.CommandTag) (totalRows int64, inserts int, updates int, deletes int, selects int) {
for _, tag := range tags {
totalRows += tag.RowsAffected()
switch {
case tag.Insert():
inserts++
case tag.Update():
updates++
case tag.Delete():
deletes++
case tag.Select():
selects++
}
}
return totalRows, inserts, updates, deletes, selects
}
{
"schemaVersion": 1,
"goal": "verify github.com/jackc/pgx/v5/pgconn.NewCommandTag in pkg:golang/github.com/jackc/pgx/v5@v5.10.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/jackc/pgx/v5@v5.10.0"
],
"symbols": [
"github.com/jackc/pgx/v5/pgconn.NewCommandTag"
]
}
package main
import (
"fmt"
"os"
"github.com/jackc/pgx/v5/pgconn"
"sample"
)
func main() {
// 1. Direct verification of pgconn.NewCommandTag for INSERT
tagInsert := pgconn.NewCommandTag("INSERT 0 3")
if !tagInsert.Insert() {
fmt.Fprintf(os.Stderr, "expected tagInsert.Insert() to be true\n")
os.Exit(1)
}
if tagInsert.Update() || tagInsert.Delete() || tagInsert.Select() {
fmt.Fprintf(os.Stderr, "expected tagInsert non-insert methods to be false\n")
os.Exit(1)
}
if tagInsert.RowsAffected() != 3 {
fmt.Fprintf(os.Stderr, "expected tagInsert.RowsAffected() == 3, got %d\n", tagInsert.RowsAffected())
os.Exit(1)
}
if tagInsert.String() != "INSERT 0 3" {
fmt.Fprintf(os.Stderr, "expected tagInsert.String() == 'INSERT 0 3', got %q\n", tagInsert.String())
os.Exit(1)
}
// 2. Direct verification of pgconn.NewCommandTag for UPDATE
tagUpdate := pgconn.NewCommandTag("UPDATE 7")
if !tagUpdate.Update() {
fmt.Fprintf(os.Stderr, "expected tagUpdate.Update() to be true\n")
os.Exit(1)
}
if tagUpdate.RowsAffected() != 7 {
fmt.Fprintf(os.Stderr, "expected tagUpdate.RowsAffected() == 7, got %d\n", tagUpdate.RowsAffected())
os.Exit(1)
}
// 3. Direct verification of pgconn.NewCommandTag for DELETE
tagDelete := pgconn.NewCommandTag("DELETE 15")
if !tagDelete.Delete() {
fmt.Fprintf(os.Stderr, "expected tagDelete.Delete() to be true\n")
os.Exit(1)
}
if tagDelete.RowsAffected() != 15 {
fmt.Fprintf(os.Stderr, "expected tagDelete.RowsAffected() == 15, got %d\n", tagDelete.RowsAffected())
os.Exit(1)
}
// 4. Direct verification of pgconn.NewCommandTag for SELECT
tagSelect := pgconn.NewCommandTag("SELECT 100")
if !tagSelect.Select() {
fmt.Fprintf(os.Stderr, "expected tagSelect.Select() to be true\n")
os.Exit(1)
}
if tagSelect.RowsAffected() != 100 {
fmt.Fprintf(os.Stderr, "expected tagSelect.RowsAffected() == 100, got %d\n", tagSelect.RowsAffected())
os.Exit(1)
}
// 5. Direct verification of pgconn.NewCommandTag for DDL / other tags
tagDDL := pgconn.NewCommandTag("CREATE TABLE")
if tagDDL.Insert() || tagDDL.Update() || tagDDL.Delete() || tagDDL.Select() {
fmt.Fprintf(os.Stderr, "expected DDL tag methods to be false\n")
os.Exit(1)
}
if tagDDL.RowsAffected() != 0 {
fmt.Fprintf(os.Stderr, "expected DDL tag RowsAffected() == 0, got %d\n", tagDDL.RowsAffected())
os.Exit(1)
}
if tagDDL.String() != "CREATE TABLE" {
fmt.Fprintf(os.Stderr, "expected DDL tag.String() == 'CREATE TABLE', got %q\n", tagDDL.String())
os.Exit(1)
}
// 6. Verify sample helper functions: ParseCommandTag, CommandSummary, IsMutation
parsed := sample.ParseCommandTag("UPDATE 4")
if !parsed.Update() || parsed.RowsAffected() != 4 {
fmt.Fprintf(os.Stderr, "ParseCommandTag failed\n")
os.Exit(1)
}
summaryName, summaryRows := sample.CommandSummary(tagInsert)
if summaryName != "INSERT" || summaryRows != 3 {
fmt.Fprintf(os.Stderr, "CommandSummary failed for INSERT: got (%s, %d)\n", summaryName, summaryRows)
os.Exit(1)
}
ddlName, ddlRows := sample.CommandSummary(tagDDL)
if ddlName != "CREATE" || ddlRows != 0 {
fmt.Fprintf(os.Stderr, "CommandSummary failed for DDL: got (%s, %d)\n", ddlName, ddlRows)
os.Exit(1)
}
if !sample.IsMutation(tagInsert) || !sample.IsMutation(tagUpdate) || !sample.IsMutation(tagDelete) {
fmt.Fprintf(os.Stderr, "IsMutation should be true for mutations\n")
os.Exit(1)
}
if sample.IsMutation(tagSelect) || sample.IsMutation(tagDDL) {
fmt.Fprintf(os.Stderr, "IsMutation should be false for SELECT and DDL\n")
os.Exit(1)
}
// 7. Verify FormatCommandTag helper
fmtInsert := sample.FormatCommandTag("INSERT", 1)
if !fmtInsert.Insert() || fmtInsert.RowsAffected() != 1 || fmtInsert.String() != "INSERT 0 1" {
fmt.Fprintf(os.Stderr, "FormatCommandTag INSERT failed: %q (rows=%d)\n", fmtInsert.String(), fmtInsert.RowsAffected())
os.Exit(1)
}
fmtUpdate := sample.FormatCommandTag("UPDATE", 8)
if !fmtUpdate.Update() || fmtUpdate.RowsAffected() != 8 || fmtUpdate.String() != "UPDATE 8" {
fmt.Fprintf(os.Stderr, "FormatCommandTag UPDATE failed: %q\n", fmtUpdate.String())
os.Exit(1)
}
// 8. Verify BatchSummary helper
tags := []pgconn.CommandTag{tagInsert, tagUpdate, tagDelete, tagSelect, tagDDL}
totalRows, ins, upd, del, sel := sample.BatchSummary(tags)
if totalRows != 125 || ins != 1 || upd != 1 || del != 1 || sel != 1 {
fmt.Fprintf(os.Stderr, "BatchSummary mismatch: rows=%d, ins=%d, upd=%d, del=%d, sel=%d\n", totalRows, ins, upd, del, sel)
os.Exit(1)
}
fmt.Println("All pgconn.NewCommandTag contract assertions passed successfully.")
}
Origin Seeder
anonymous