CodeSampleX

サンプル

github.com/jackc/pgx/v5 v5.10.0: Execute SQL statements within pgx transactions using pgx.Tx.Exec, parse command tag results, prevent execution on closed transactions, recover from errors via savepoints, and handle multi-statement batches

検証済みサンプル — golang github.com/jackc/pgx/v5 v5.10.0: Execute SQL statements within pgx transactions using pgx.Tx.Exec, parse command tag results, prevent…

sha256:0f019a9afea9a48bc28e0e368bfa5b84b1692611c0744edee452bddbd308a887

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
2
ビルドした署名鍵
2
宣言された環境 go linux x64 go go gomod

検証実行環境

環境 コントラクト ステージ 実行日
go 1.26 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1
2026-08-17
go 1.26 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1
2026-08-18

ケース

HOW
ゴール
Execute SQL statements within pgx transactions using pgx.Tx.Exec, parse command tag results, prevent execution on closed transactions, recover from errors via savepoints, and handle multi-statement batches
パッケージ
シンボル
  • pgx.Tx.Exec
環境
go
作成日
2026-08-17T23:32:54Z

コントラクト

  1. pgx.Tx.Exec returns a structured pgconn.CommandTag with RowsAffected and command predicates rather than sql.Result, and immediately rejects execution on committed or rolled back transactions with ErrTxClosed
  2. assert rolling back a failed subtransaction savepoint restores the outer transaction from aborted state allowing subsequent tx.Exec commands to succeed
  3. assert binding nil arguments or invalid pgtype values in tx.Exec encodes parameters as PostgreSQL NULL values
  4. assert executing multi-statement SQL strings with tx.Exec in simple protocol mode returns the CommandTag of the final executed statement
  5. assert configuring TxOptions with Serializable and ReadOnly issues the corresponding begin SQL transaction preamble
  6. assert passing a pre-canceled context to tx.Exec immediately returns context.Canceled without executing on the connection

ファイル

  • NOTES.md
  • csx.json
  • go.mod
  • go.sum
  • sample_test.go

ソースアーティファクトをダウンロード (tar.gz)

オリジンシーダー

csx-seed