跳转至

ev-drogon-inline-vars-pgstate-001

字段 值
项目 drogonframework/drogon
固定 commit 3aae769cc405
路径 orm_lib/src/postgresql_impl/PgConnection.h
行段 L40-L50
特性 内联变量
许可证 MIT
代码来源 项目源码
级别 manual
审核 zyuhao7 @ 2026-10-26
测试代码 否
发现方式 manual

用法

在头文件中定义一组 inline constexpr string_view 常量

为什么典型

PostgreSQL 错误码常量需要被多个翻译单元共享,inline constexpr 让定义直接留在头文件且只产生一个实体。

摘录

inline constexpr std::string_view pgNotNullViolationState{"23502"};
inline constexpr std::string_view pgForeignKeyViolationState{"23503"};
inline constexpr std::string_view pgUniqueViolationState{"23505"};
inline constexpr std::string_view pgCheckViolationState{"23514"};
inline constexpr std::string_view pgDataExceptionClass{"22"};
inline constexpr std::string_view pgIntegrityConstraintViolationClass{"23"};
inline constexpr std::string_view pgInsufficientPrivilegeState{"42501"};
inline constexpr std::string_view pgOutOfMemoryState{"53200"};
inline constexpr std::string_view pgDiskFullState{"53100"};
inline constexpr std::string_view pgDefaultErrorMessage{
    "PostgreSQL query failed"};

备注

生产路径;头文件中的命名空间级常量,供 ORM 错误分类共享。

查看固定 commit 源码 · 返回证据索引