postgres

package
v1.7.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package postgres 是 reliable Store 的 PostgreSQL 薄方言包(D17)。 仅提供 migration SQL、PGClassifier、NewStore(db) 注入。GORM 逻辑在 store/gormshared。

Index

Constants

View Source
const CreateTableSQL = `` /* 6503-byte string literal not displayed */

CreateTableSQL 建 four tables(PostgreSQL 方言)。与 mysql 语义等价,类型用 PG 原生 + partial index。

View Source
const DropTableSQL = `` /* 181-byte string literal not displayed */

Variables

This section is empty.

Functions

func Migration

func Migration() func(*gorm.DB) error

func NewQuarantineStore

func NewQuarantineStore(db *gorm.DB) store.QuarantineStore

func NewStore

func NewStore(db *gorm.DB) store.Store

NewStore 注入 PGClassifier 到共享 gormStore。db 必须是 pooled(§3.3,D16)。

Types

type PGClassifier

type PGClassifier struct{}

PGClassifier 实现 reliable.ErrorClassifier(§5 第 2 级,PostgreSQL SQLSTATE)。

func (PGClassifier) ClassifyDriver

func (PGClassifier) ClassifyDriver(err error) (reliable.ErrorClass, bool)

func (PGClassifier) ErrorCode

func (PGClassifier) ErrorCode(err error) (string, bool)

ErrorCode 提取 PostgreSQL SQLSTATE 码(如 "23505"、"40P01"),用于填充 error_code 列。 B1(本轮评审):原稿此处注释行首多一个 `n`、函数体多一层缩进,且文件缺 `store` import(下方 NewStore 返回 store.Store)——与 mysql/classify.go 同款错误,两处一并修。

func (PGClassifier) IsDuplicateKey

func (PGClassifier) IsDuplicateKey(err error) bool

IsDuplicateKey 报告 err 是否是 PG unique_violation(23505)。D3:typed errors.As。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL