↑↓ 选择↵ 打开⌫ 切换范围完整搜索

PG.CENTER 连接 PostgreSQL 文档、百科与生态知识。由 Pigsty 维护。

Wiki / SQLSTATE

42P15 — 无效模式定义

CREATE SCHEMA 的模式声明不一致被拒绝。

英文手册覆盖始于 PostgreSQL 8.1. 来源历史与运行验证各自保留独立版本边界。

当前阅读 PG 18·选择有来源记录的版本

aliases
未知
class name
Syntax Error or Access Rule Violation
condition name
invalid_schema_definition
lang
en
sqlstate
42P15

版本定义 PG 18

42P15 — 无效模式定义

速览 {#at-a-glance}

42P15(invalid_schema_definition)CREATE SCHEMA 的模式声明不一致时会被拒绝。

含义 {#meaning}

模式定义校验发生在转换 CREATE SCHEMA 所包含的对象时。setSchemaName helper 会拒绝某个所含对象显式指定的模式名,只要它不同于当前 CREATE SCHEMA 正在创建的模式。这是所含对象的声明不一致,不是两个顶层模式,也不是找不到模式。

诊断 {#diagnosis}

从消息和完整 CREATE SCHEMA 语句中读取两个模式标识符,找出哪个所含的 CREATE TABLE、序列、视图或其他对象提供了冲突的限定名。分别检查生成的 DDL 与 search_path;改变 search_path 不能让语句中明确给出的两个名称一致。

处理 {#response}

让 CREATE SCHEMA 只使用一个预期名称,让其中对象的显式限定名也使用该名称,或省略由该命令提供上下文的限定名。修正迁移生成器或引用方式。CREATE SCHEMA 失败本身不能证明已经提交了部分模式;只有需要清理或外层事务已有状态时才检查目录。如果 ERROR 发生在显式事务中,重试前先 ROLLBACK 或回滚到错误前的保存点。

消息 {#messages}

固定源码中的代表性消息包括:message: CREATE specifies a schema (%s) different from the one being created (%s)。占位符由实际对象、列或参数填充。

版本 {#versions}

锁定目录显示该条件最早见于 PostgreSQL 7.4;行为说明固定在 PostgreSQL 18.6 源码,目录存在范围不等于每条消息或功能都从该版本开始。

相关 {#related}

来源 {#sources}

源码消息、行号和证据边界见 作者证据。

  • src/backend/parser/parse_utilcmd.c:4229-4233 (fixed source)

比较版本

SQLSTATE 证据与已记录的运行版本

claims · identity.class-and-condition
{
  "claim_id": "identity.class-and-condition",
  "limits": "Identity does not enumerate all source branches or client failures.",
  "method": "Read fixed REL_18_6 errcodes.txt and locked facts.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.42P15.18.6"
  ],
  "statement": "42P15 is the invalid_schema_definition condition in Class 42."
}
claims · mechanism.selected-source-path
{
  "claim_id": "mechanism.selected-source-path",
  "limits": "Representative confirmed core paths only; not exhaustive historical or extension coverage.",
  "method": "Read selected resolved REL_18_6 report groups and message roles.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.call.42P15.2db5c33b3c90c42ac6dd7a34"
  ],
  "statement": "The setSchemaName helper runs while transforming CREATE SCHEMA contents and rejects a contained object whose explicit schema differs from the schema being created. This is a contained-object declaration mismatch, not two top-level schemas or a missing-schema lookup."
}
claims · versions.catalogue-boundary
{
  "claim_id": "versions.catalogue-boundary",
  "limits": "First observed release is a lower bound, not precise behavioral introduction.",
  "method": "Read locked catalogue facts and definition snapshot.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.errcodes.42P15.18.6"
  ],
  "statement": "Locked catalogue snapshots show this condition by PostgreSQL 7.4; source behavior here is fixed at PostgreSQL 18.6."
}
messages · message.variant-1
{
  "limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
  "message_id": "message.variant-1",
  "path": "",
  "position": 0,
  "raw": {
    "detail_templates": [],
    "hint_templates": [],
    "id": "message.variant-1",
    "limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
    "primary_template": "CREATE specifies a schema (%s) different from the one being created (%s)",
    "roles": [
      {
        "role": "errmsg",
        "template": "CREATE specifies a schema (%s) different from the one being created (%s)"
      }
    ],
    "severity_source": "ERROR",
    "sources": [
      "src.call.42P15.2db5c33b3c90c42ac6dd7a34"
    ],
    "sqlstate": "42P15"
  },
  "severity": "ERROR",
  "sources": [
    "src.call.42P15.2db5c33b3c90c42ac6dd7a34"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "CREATE specifies a schema ( ) different from the one being created ( )",
      "position": 0,
      "role": "",
      "template": "CREATE specifies a schema (%s) different from the one being created (%s)"
    }
  ]
}
sources · src.errcodes.42P15.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "line 396",
  "path": "src/backend/utils/errcodes.txt",
  "position": 0,
  "sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
  "source_id": "src.errcodes.42P15.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L396"
}
sources · src.call.42P15.2db5c33b3c90c42ac6dd7a34
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "lines 4229-4233",
  "path": "src/backend/parser/parse_utilcmd.c",
  "position": 1,
  "sha256": "6758a539fdd493127dfd98e58b995ffcfc3068194bdacdf168ba495caa6cacbf",
  "source_id": "src.call.42P15.2db5c33b3c90c42ac6dd7a34",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/parser/parse_utilcmd.c#L4229-L4233"
}
sources · src.calls.REL_18_6.42P15
{
  "commit": "",
  "docs_url": "",
  "kind": "local_artifact",
  "location": "",
  "path": "raw/calls/REL_18_6.jsonl",
  "position": 2,
  "sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
  "source_id": "src.calls.REL_18_6.42P15",
  "tag": "",
  "url": ""
}

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · english-manuals:5911f4601d02ffcd0e8e853c6ea32a56bdcf73e6ffa5ab04199bdfa9bd1e2ebf

正文语言: zh-Hans · english-manuals:5911f4601d02ffcd0e8e853c6ea32a56bdcf73e6ffa5ab04199bdfa9bd1e2ebf