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

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

Wiki / SQLSTATE

42830 — 无效外键(invalid_foreign_key)

外键在被引用列上找不到合格的唯一键。

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

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

aliases
未知
class name
Syntax Error or Access Rule Violation
condition name
invalid_foreign_key
lang
en
sqlstate
42830

版本定义 PG 18

42830 — 无效外键(invalid_foreign_key)

速览 {#at-a-glance}

42830 是 invalid_foreign_key(无效外键):外键定义在被引用列上找不到合格唯一键。本案例的父表整数列没有唯一约束。

含义 {#meaning}

创建时先检查父键,尚未插入子行。固定主报文为 there is no unique constraint matching given keys for referenced table "%s"。普通 FK 的被引用列集合可以匹配物理顺序不同但合格的唯一索引;源码匹配器会拒绝被引用列重复,并要求列数正确、唯一、有效且没有部分谓词或索引表达式。若匹配到可延迟的唯一/主键索引,则进入仅源码确认的 55000 分支。这是定义时错误,不同于 23503;自动提交 ALTER 失败后为 IDLE。

诊断 {#diagnosis}

将被引用列集合与 pg_constraint、pg_index 对照。检查重复引用、列数、唯一/主键属性、有效性、部分谓词和表达式;普通路径不要求物理索引顺序与 FK 列表相同。还要检查 indimmediate:匹配但可延迟的键会报 55000,不是本案例的 42830。类型相同本身不能使键符合要求。

处理 {#response}

在被引用列集合上添加或使用有意且不可延迟的唯一键,再创建 FK。核对父表键的业务含义及 NULL/MATCH 语义;过宽唯一约束可能改变可接受数据。不要为了匹配 FK 书写顺序而重排本来合格的索引,也不要把部分或表达式索引当作合格键。案例添加 UNIQUE (id) 后创建 FK。显式事务中被拒绝的 ALTER TABLE 会使事务进入 INERROR,应先回滚或回到合适的 savepoint 再重试;本案例的自动提交路径回到 IDLE。

实测诊断 {#messages}

选定 tablecmds.c 组是 ERROR,主报文为 there is no unique constraint matching given keys for referenced table "%s",没有 DETAIL/HINT。同一匹配器还有仅源码确认的 55000(object_not_in_prerequisite_state)变体:当唯一键本来匹配但可延迟时为 cannot use a deferrable unique constraint for referenced table "%s"。

代表案例 {#case}

注册表创建父子表,先尝试 FK,再添加父唯一键、创建有效 FK 并统计。

CREATE TABLE syntax_schema.fk_parent (id integer);
CREATE TABLE syntax_schema.fk_child (parent_id integer);
ALTER TABLE syntax_schema.fk_child ADD CONSTRAINT fk_bad FOREIGN KEY (parent_id) REFERENCES syntax_schema.fk_parent (id);
ALTER TABLE syntax_schema.fk_parent ADD CONSTRAINT fk_parent_id_key UNIQUE (id);
ALTER TABLE syntax_schema.fk_child ADD CONSTRAINT fk_good FOREIGN KEY (parent_id) REFERENCES syntax_schema.fk_parent (id);
SELECT count(*) FROM pg_constraint c JOIN pg_namespace n ON n.oid = c.connamespace WHERE n.nspname = 'syntax_schema_name' AND c.conname = 'fk_good' AND c.contype = 'f';

选定的 18.6 与 10.21 运行均通过 SQLSTATE、严重级别、状态/恢复、修复、清理和一次性实例停止断言。详见 案例 JSON 与 作者证据;私有清单和注册表哈希也记录在其中。

版本 {#versions}

锁定目录从 7.4 存在边界起包含该条件并列出相关快照。选定自然案例已在 PostgreSQL 18.6 与 10.21 通过;这是有界观察,不能推断所有中间版本或所有源码分支。

相关 {#related}

来源 {#sources}

  • src.errcodes.REL_18_6 — fixed definition at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.invalid-fk.18.6 — src/backend/commands/tablecmds.c lines 13639–13642 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9 (source).
  • src.invalid-fk.10.23 — src/backend/commands/tablecmds.c lines 8133–8136 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 6de441c88496c6cf57a836898388085ec08bf69afd70d07acdafd6089b9b5f8c (source).
  • src.invalid-fk-guards.18.6 — transformFkeyCheckAttrs 完整源码为 src/backend/commands/tablecmds.c lines 13505–13642,commit 724edf9bde9d356724ad384a2e196edc3c9f80f7;blob SHA-256 422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9 (source).
  • src.invalid-fk-guards.10.23 — transformFkeyCheckAttrs 完整源码为 src/backend/commands/tablecmds.c lines 8002–8136,commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4;blob SHA-256 6de441c88496c6cf57a836898388085ec08bf69afd70d07acdafd6089b9b5f8c (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
  • manifest.42830 / snippet-registry.42830 — hashes are recorded in evidence/42830.json and each runtime record.

比较版本

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

cases · fk_missing_unique_key
{
  "assertions": [
    "SQLSTATE is 42830 with the missing referenced unique-key message",
    "The failed autocommit session remains IDLE",
    "Adding a parent UNIQUE constraint then the FK creates one valid constraint"
  ],
  "case_id": "fk_missing_unique_key",
  "cleanup": "Drop the runner schema and both tables.",
  "has_snippet": true,
  "position": 0,
  "preconditions": [
    "A runner-owned disposable target is provisioned."
  ],
  "repair": "Add a deliberate primary/unique key over the referenced columns before defining the FK; matching types alone are insufficient.",
  "trigger": "Create a foreign key referencing a parent column with no unique constraint.",
  "versions": [
    "10",
    "18"
  ]
}
claims · identity.class-and-condition
{
  "claim_id": "identity.class-and-condition",
  "limits": "Identity does not identify every backend call that can reuse this SQLSTATE.",
  "method": "Read fixed errcodes.txt and locked catalogue metadata.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.REL_18_6"
  ],
  "statement": "42830 is the invalid_foreign_key condition in Class 42."
}
claims · mechanism.selected-source-path
{
  "claim_id": "mechanism.selected-source-path",
  "limits": "This is one mechanism boundary, not an exhaustive inventory of the code.",
  "method": "Trace the REL_18_6 and REL_10_23 source-call records at the locked commits.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.invalid-fk.18.6",
    "src.invalid-fk.10.23",
    "src.invalid-fk-guards.18.6",
    "src.invalid-fk-guards.10.23"
  ],
  "statement": "The selected fk_missing_unique_key follows a resolved PostgreSQL source-call group; the complete matcher accepts a duplicate-free referenced column set in any physical order only when the candidate index has the required count, uniqueness, validity, and no predicate or expressions."
}
claims · mechanism.fk-index-guards
{
  "claim_id": "mechanism.fk-index-guards",
  "limits": "The selected runtime covers only the missing-key 42830 case and does not observe the duplicate-list or deferrable branches.",
  "method": "Read the complete transformFkeyCheckAttrs function in both locked tablecmds.c snapshots.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.invalid-fk-guards.18.6",
    "src.invalid-fk-guards.10.23"
  ],
  "statement": "The same matcher rejects a duplicate referenced-column list with 42830 and rejects an otherwise matching deferrable unique or primary index with OBJECT_NOT_IN_PREREQUISITE_STATE (55000); the latter is source-only in this review."
}
claims · runtime.representative-case
{
  "claim_id": "runtime.representative-case",
  "limits": "Scope is limited to these statements, psycopg, and two versions.",
  "method": "Run the shared SQL registry and inspect SQLSTATE, severity, state, repair, cleanup, and target stop.",
  "position": 3,
  "runtime": [
    "runtime.syntax2-42830-latest.latest",
    "runtime.syntax2-42830-pg10.pg10"
  ],
  "sources": [
    "manifest.42830",
    "snippet-registry.42830"
  ],
  "statement": "The selected fk_missing_unique_key passed on isolated PostgreSQL 18.6 and 10.21 targets."
}
claims · versions.catalogue-boundary
{
  "claim_id": "versions.catalogue-boundary",
  "limits": "Definition presence is not an exact behavioral introduction; two runtime versions do not prove every intermediate behavior.",
  "method": "Read generated facts, fixed calls, and selected summaries.",
  "position": 4,
  "runtime": [],
  "sources": [
    "src.errcodes.REL_18_6",
    "src.calls.REL_18_6",
    "src.calls.REL_10_23"
  ],
  "statement": "The locked catalogue records 42830 from the 7.4 presence bound through the listed snapshots; runtime scope is 18.6 and 10.21."
}
messages · message.fk_missing_unique_key
{
  "limits": "",
  "message_id": "message.fk_missing_unique_key",
  "path": "",
  "position": 0,
  "raw": {
    "id": "message.fk_missing_unique_key",
    "primary_template": "there is no unique constraint matching given keys for referenced table \"%s\"",
    "severity_source": "explicit ERROR",
    "sources": [
      "src.invalid-fk.18.6",
      "src.invalid-fk.10.23"
    ],
    "sqlstate": "42830"
  },
  "severity": "explicit ERROR",
  "sources": [
    "src.invalid-fk.18.6",
    "src.invalid-fk.10.23"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "there is no unique constraint matching given keys for referenced table \" \"",
      "position": 0,
      "role": "",
      "template": "there is no unique constraint matching given keys for referenced table \"%s\""
    }
  ]
}
messages · message.deferrable-unique
{
  "limits": "",
  "message_id": "message.deferrable-unique",
  "path": "",
  "position": 1,
  "raw": {
    "condition_name": "object_not_in_prerequisite_state",
    "id": "message.deferrable-unique",
    "primary_template": "cannot use a deferrable unique constraint for referenced table \"%s\"",
    "scope": "source-only deferrable-key branch",
    "severity_source": "explicit ERROR",
    "sources": [
      "src.invalid-fk-guards.18.6",
      "src.invalid-fk-guards.10.23"
    ],
    "sqlstate": "55000"
  },
  "severity": "explicit ERROR",
  "sources": [
    "src.invalid-fk-guards.18.6",
    "src.invalid-fk-guards.10.23"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "cannot use a deferrable unique constraint for referenced table \" \"",
      "position": 0,
      "role": "",
      "template": "cannot use a deferrable unique constraint for referenced table \"%s\""
    }
  ]
}
runtimes · runtime.syntax2-42830-latest.latest · 18.6 (Homebrew) · passed
{
  "cases": [
    "fk_missing_unique_key"
  ],
  "limits": "",
  "position": 0,
  "raw": {
    "assertions": [
      {
        "expected": "42830",
        "name": "42830 SQLSTATE",
        "observed": "42830",
        "passed": true
      },
      {
        "expected": "ERROR",
        "name": "42830 ERROR severity",
        "observed": "ERROR",
        "passed": true
      },
      {
        "expected": "there is no unique constraint matching given keys for referenced table \"fk_parent\"",
        "name": "42830 primary diagnostic",
        "observed": "there is no unique constraint matching given keys for referenced table \"fk_parent\"",
        "passed": true
      },
      {
        "expected": "IDLE",
        "name": "invalid foreign key leaves autocommit session usable",
        "observed": "IDLE",
        "passed": true
      },
      {
        "expected": {
          "foreign_keys": 1,
          "status": "IDLE"
        },
        "name": "referenced unique key repairs foreign-key definition",
        "observed": {
          "error": true,
          "foreign_keys": 1,
          "status": "IDLE"
        },
        "passed": true
      }
    ],
    "case_manifest": {
      "id": "manifest.42830",
      "kind": "local_artifact",
      "path": "verify/cases/42830/cases.json",
      "sha256": "d9ac3703aac83c78dd0565bb928ef2a4e6f28e5e6138d588191f39a3cbd72297",
      "source_role": "case_manifest"
    },
    "cases": [
      "fk_missing_unique_key"
    ],
    "cleanup": {
      "errors": [],
      "passed": true
    },
    "environment": {
      "TimeZone": "Asia/Shanghai",
      "backend_pid": 30133,
      "binary": {
        "bindir": "/opt/homebrew/Cellar/postgresql@18/18.6/bin",
        "pg_config": "/opt/homebrew/bin/pg_config",
        "pg_config_version": "PostgreSQL 18.6 (Homebrew)",
        "postgres": "/opt/homebrew/Cellar/postgresql@18/18.6/bin/postgres"
      },
      "connection_scope": "runner-owned localhost port",
      "current_user": "runner",
      "docker": {},
      "lc_messages": "C",
      "libpq_version": "18.6",
      "locale": "C.UTF-8",
      "log_destination": "csvlog,jsonlog",
      "log_error_verbosity": "verbose",
      "log_min_error_statement": "error",
      "log_min_messages": "error",
      "logging_collector": "on",
      "machine": "arm64",
      "max_connections": "100",
      "platform": "macOS-26.6.2-arm64-arm-64bit-Mach-O",
      "psycopg_version": "3.3.5",
      "python_version": "3.14.6 (main, Jun 10 2026, 10:03:53) [Clang 21.0.0 (clang-2100.0.123.102)]",
      "server_encoding": "UTF8",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": "180006",
      "target_kind": "latest",
      "wal_level": "logical"
    },
    "id": "runtime.syntax2-42830-latest.latest",
    "observed": {
      "connection_autocommit": true,
      "diagnostic": {
        "column_name": null,
        "constraint_name": null,
        "context": null,
        "datatype_name": null,
        "exception_type": "InvalidForeignKey",
        "internal_position": null,
        "internal_query": null,
        "message_detail": null,
        "message_hint": null,
        "message_primary": "there is no unique constraint matching given keys for referenced table \"fk_parent\"",
        "schema_name": null,
        "severity": "ERROR",
        "severity_nonlocalized": "ERROR",
        "source_file": "tablecmds.c",
        "source_function": "transformFkeyCheckAttrs",
        "source_line": "13642",
        "sqlstate": "42830",
        "statement_position": null,
        "table_name": null,
        "text": "there is no unique constraint matching given keys for referenced table \"fk_parent\""
      },
      "failed_status": "IDLE",
      "foreign_key_count": 1,
      "repair_status": "IDLE"
    },
    "raw": "verify/results/syntax2-42830-latest/latest/raw.jsonl",
    "raw_sha256": "77881dcf880972f5fe0595fbea0388acea661d315e5cc7db322ca8b8302450b5",
    "run_id": "syntax2-42830-latest",
    "server_version": "18.6 (Homebrew)",
    "server_version_num": 180006,
    "snippet_registry": {
      "id": "snippet-registry.42830",
      "kind": "local_artifact",
      "path": "verify/cases/42830/snippets.json",
      "sha256": "9133c8bee8f6cb7f908c33a6bf53d4eceea58565293e839a90143ba27e25ca25",
      "source_role": "snippet_registry"
    },
    "status": "passed",
    "summary": "verify/results/syntax2-42830-latest/latest/summary.json",
    "summary_sha256": "00ff7903bc8bbe0a909c3176cf42dc1c9c50524dcbb55ef89188772c49353e29",
    "target": "latest",
    "target_stop": {
      "argv": [
        "/opt/homebrew/Cellar/postgresql@18/18.6/bin/pg_ctl",
        "-D",
        "/Users/vonng/pgcenter/err-code/.cache/runtime/syntax2-42830-latest/latest/data",
        "-m",
        "fast",
        "-w",
        "stop"
      ],
      "elapsed_seconds": 0.116,
      "returncode": 0,
      "stderr": "",
      "stdout": "waiting for server to shut down.... done\nserver stopped\n"
    }
  },
  "run_id": "syntax2-42830-latest",
  "runtime_id": "runtime.syntax2-42830-latest.latest",
  "server_version": "18.6 (Homebrew)",
  "status": "passed",
  "target": "latest"
}
runtimes · runtime.syntax2-42830-pg10.pg10 · 10.21 (Debian 10.21-1.pgdg90+1) · passed
{
  "cases": [
    "fk_missing_unique_key"
  ],
  "limits": "",
  "position": 1,
  "raw": {
    "assertions": [
      {
        "expected": "42830",
        "name": "42830 SQLSTATE",
        "observed": "42830",
        "passed": true
      },
      {
        "expected": "ERROR",
        "name": "42830 ERROR severity",
        "observed": "ERROR",
        "passed": true
      },
      {
        "expected": "there is no unique constraint matching given keys for referenced table \"fk_parent\"",
        "name": "42830 primary diagnostic",
        "observed": "there is no unique constraint matching given keys for referenced table \"fk_parent\"",
        "passed": true
      },
      {
        "expected": "IDLE",
        "name": "invalid foreign key leaves autocommit session usable",
        "observed": "IDLE",
        "passed": true
      },
      {
        "expected": {
          "foreign_keys": 1,
          "status": "IDLE"
        },
        "name": "referenced unique key repairs foreign-key definition",
        "observed": {
          "error": true,
          "foreign_keys": 1,
          "status": "IDLE"
        },
        "passed": true
      }
    ],
    "case_manifest": {
      "id": "manifest.42830",
      "kind": "local_artifact",
      "path": "verify/cases/42830/cases.json",
      "sha256": "d9ac3703aac83c78dd0565bb928ef2a4e6f28e5e6138d588191f39a3cbd72297",
      "source_role": "case_manifest"
    },
    "cases": [
      "fk_missing_unique_key"
    ],
    "cleanup": {
      "errors": [],
      "passed": true
    },
    "environment": {
      "TimeZone": "Etc/UTC",
      "backend_pid": 80,
      "binary": {},
      "connection_scope": "runner-owned localhost port",
      "current_user": "postgres",
      "docker": {
        "architecture": "arm64",
        "command": "/usr/local/bin/docker",
        "digest": "sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc",
        "id": "sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc",
        "image": "postgres:10",
        "image_created": "2022-06-23T09:11:18.374607054Z",
        "image_ref": "postgres@sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc",
        "log_destination": "csvlog",
        "os": "linux",
        "repo_digests": [
          "postgres@sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc"
        ]
      },
      "lc_messages": "en_US.utf8",
      "libpq_version": "18.6",
      "locale": "C.UTF-8",
      "log_destination": "csvlog",
      "log_error_verbosity": "verbose",
      "log_min_error_statement": "error",
      "log_min_messages": "error",
      "logging_collector": "on",
      "machine": "arm64",
      "max_connections": "100",
      "platform": "macOS-26.6.2-arm64-arm-64bit-Mach-O",
      "psycopg_version": "3.3.5",
      "python_version": "3.14.6 (main, Jun 10 2026, 10:03:53) [Clang 21.0.0 (clang-2100.0.123.102)]",
      "server_encoding": "UTF8",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": "100021",
      "target_kind": "pg10",
      "wal_level": "logical"
    },
    "id": "runtime.syntax2-42830-pg10.pg10",
    "observed": {
      "connection_autocommit": true,
      "diagnostic": {
        "column_name": null,
        "constraint_name": null,
        "context": null,
        "datatype_name": null,
        "exception_type": "InvalidForeignKey",
        "internal_position": null,
        "internal_query": null,
        "message_detail": null,
        "message_hint": null,
        "message_primary": "there is no unique constraint matching given keys for referenced table \"fk_parent\"",
        "schema_name": null,
        "severity": "ERROR",
        "severity_nonlocalized": "ERROR",
        "source_file": "tablecmds.c",
        "source_function": "transformFkeyCheckAttrs",
        "source_line": "8136",
        "sqlstate": "42830",
        "statement_position": null,
        "table_name": null,
        "text": "there is no unique constraint matching given keys for referenced table \"fk_parent\""
      },
      "failed_status": "IDLE",
      "foreign_key_count": 1,
      "repair_status": "IDLE"
    },
    "raw": "verify/results/syntax2-42830-pg10/pg10/raw.jsonl",
    "raw_sha256": "78ac72e825bd2c12c8861c36573fb0bf919f815c6a71c45b7974207c90228a39",
    "run_id": "syntax2-42830-pg10",
    "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
    "server_version_num": 100021,
    "snippet_registry": {
      "id": "snippet-registry.42830",
      "kind": "local_artifact",
      "path": "verify/cases/42830/snippets.json",
      "sha256": "9133c8bee8f6cb7f908c33a6bf53d4eceea58565293e839a90143ba27e25ca25",
      "source_role": "snippet_registry"
    },
    "status": "passed",
    "summary": "verify/results/syntax2-42830-pg10/pg10/summary.json",
    "summary_sha256": "ad665b5cc446930d400a60975debedf388d1f0e9dfb4888b0e1e1b38138f46f1",
    "target": "pg10",
    "target_stop": {
      "cleanup": {
        "argv": [
          "/usr/local/bin/docker",
          "rm",
          "-f",
          "-v",
          "sqlstate42830_syntax242830pg10_pg10"
        ],
        "elapsed_seconds": 0.277,
        "returncode": 0,
        "stderr": "",
        "stdout": "sqlstate42830_syntax242830pg10_pg10\n"
      },
      "inspect": {
        "argv": [
          "/usr/local/bin/docker",
          "inspect",
          "sqlstate42830_syntax242830pg10_pg10"
        ],
        "elapsed_seconds": 0.022,
        "returncode": 0,
        "stderr": "",
        "stdout": "[\n    {\n        \"Id\": \"6594cbedd55e6c28e1dd19f9528db9dbc8131d7301c871f3107aba4427a23570\",\n        \"Created\": \"2026-09-09T16:40:16.019812084Z\",\n        \"Path\": \"docker-entrypoint.sh\",\n        \"Args\": [\n            \"postgres\",\n            \"-c\",\n            \"listen_addresses=*\",\n            \"-c\",\n            \"log_destination=csvlog\",\n            \"-c\",\n            \"logging_collector=on\",\n            \"-c\",\n            \"log_directory=log\",\n            \"-c\",\n            \"log_filename=postgresql-%Y%m%d%H%M%S.log\",\n            \"-c\",\n            \"log_min_messages=error\",\n            \"-c\",\n            \"log_min_error_statement=error\",\n            \"-c\",\n            \"log_error_verbosity=verbose\",\n            \"-c\",\n            \"wal_level=logical\",\n            \"-c\",\n            \"max_wal_senders=10\",\n            \"-c\",\n            \"max_replication_slots=10\"\n        ],\n        \"State\": {\n            \"Status\": \"running\",\n            \"Running\": true,\n            \"Paused\": false,\n            \"Restarting\": false,\n            \"OOMKilled\": false,\n            \"Dead\": false,\n            \"Pid\": 63219,\n            \"ExitCode\": 0,\n            \"Error\": \"\",\n            \"StartedAt\": \"2026-09-09T16:40:16.094014417Z\",\n            \"FinishedAt\": \"0001-01-01T00:00:00Z\"\n        },\n        \"Image\": \"sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc\",\n        \"ResolvConfPath\": \"/var/lib/docker/containers/6594cbedd55e6c28e1dd19f9528db9dbc8131d7301c871f3107aba4427a23570/resolv.conf\",\n        \"HostnamePath\": \"/var/lib/docker/containers/6594cbedd55e6c28e1dd19f9528db9dbc8131d7301c871f3107aba4427a23570/hostname\",\n        \"HostsPath\": \"/var/lib/docker/containers/6594cbedd55e6c28e1dd19f9528db9dbc8131d7301c871f3107aba4427a23570/hosts\",\n        \"LogPath\": \"/var/lib/docker/containers/6594cbedd55e6c28e1dd19f9528db9dbc8131d7301c871f3107aba4427a23570/6594cbedd55e6c28e1dd19f9528db9dbc8131d7301c871f3107aba4427a23570-json.log\",\n        \"Name\": \"/sqlstate42830_syntax242830pg10_pg10\",\n        \"RestartCount\": 0,\n        \"Driver\": \"overlayfs\",\n        \"Platform\": \"linux\",\n        \"MountLabel\": \"\",\n        \"ProcessLabel\": \"\",\n        \"AppArmorProfile\": \"\",\n        \"ExecIDs\": null,\n        \"HostConfig\": {\n            \"Binds\": null,\n            \"ContainerIDFile\": \"\",\n            \"LogConfig\": {\n                \"Type\": \"json-file\",\n                \"Config\": {}\n            },\n            \"NetworkMode\": \"bridge\",\n            \"PortBindings\": {\n                \"5432/tcp\": [\n                    {\n                        \"HostIp\": \"127.0.0.1\",\n                        \"HostPort\": \"\"\n                    }\n                ]\n            },\n            \"RestartPolicy\": {\n                \"Name\": \"no\",\n                \"MaximumRetryCount\": 0\n            },\n            \"AutoRemove\": false,\n            \"VolumeDriver\": \"\",\n            \"VolumesFrom\": null,\n            \"ConsoleSize\": [\n                0,\n                0\n            ],\n            \"CapAdd\": null,\n            \"CapDrop\": null,\n            \"CgroupnsMode\": \"private\",\n            \"Dns\": null,\n            \"DnsOptions\": [],\n            \"DnsSearch\": [],\n            \"ExtraHosts\": null,\n            \"GroupAdd\": null,\n            \"IpcMode\": \"private\",\n            \"Cgroup\": \"\",\n            \"Links\": null,\n            \"OomScoreAdj\": 0,\n            \"PidMode\": \"\",\n            \"Privileged\": false,\n            \"PublishAllPorts\": false,\n            \"ReadonlyRootfs\": false,\n            \"SecurityOpt\": null,\n            \"UTSMode\": \"\",\n            \"UsernsMode\": \"\",\n            \"ShmSize\": 67108864,\n            \"Runtime\": \"runc\",\n            \"Isolation\": \"\",\n            \"CpuShares\": 0,\n            \"Memory\": 0,\n            \"NanoCpus\": 0,\n            \"CgroupParent\": \"\",\n            \"BlkioWeight\": 0,\n            \"BlkioWeightDevice\": [],\n            \"BlkioDeviceReadBps\": [],\n            \"BlkioDeviceWriteBps\": [],\n            \"BlkioDeviceReadIOps\": [],\n            \"BlkioDeviceWriteIOps\": [],\n            \"CpuPeriod\": 0,\n            \"CpuQuota\": 0,\n            \"CpuRealtimePeriod\": 0,\n            \"CpuRealtimeRuntime\": 0,\n            \"CpusetCpus\": \"\",\n            \"CpusetMems\": \"\",\n            \"Devices\": [],\n            \"DeviceCgroupRules\": null,\n            \"DeviceRequests\": null,\n            \"MemoryReservation\": 0,\n            \"MemorySwap\": 0,\n            \"MemorySwappiness\": null,\n            \"OomKillDisable\": null,\n            \"PidsLimit\": null,\n            \"Ulimits\": [],\n            \"CpuCount\": 0,\n            \"CpuPercent\": 0,\n            \"IOMaximumIOps\": 0,\n            \"IOMaximumBandwidth\": 0,\n            \"MaskedPaths\": [\n                \"/proc/acpi\",\n                \"/proc/asound\",\n                \"/proc/interrupts\",\n                \"/proc/kcore\",\n                \"/proc/keys\",\n                \"/proc/latency_stats\",\n                \"/proc/sched_debug\",\n                \"/proc/scsi\",\n                \"/proc/timer_list\",\n                \"/proc/timer_stats\",\n                \"/sys/devices/virtual/powercap\",\n                \"/sys/firmware\"\n            ],\n            \"ReadonlyPaths\": [\n                \"/proc/bus\",\n                \"/proc/fs\",\n                \"/proc/irq\",\n                \"/proc/sys\",\n                \"/proc/sysrq-trigger\"\n            ]\n        },\n        \"Storage\": {\n            \"RootFS\": {\n                \"Snapshot\": {\n                    \"Name\": \"overlayfs\"\n                }\n            }\n        },\n        \"Mounts\": [\n            {\n                \"Type\": \"volume\",\n                \"Name\": \"a0017ea5e9f8d89a5487121b928e6d2881ec921dddd499c224111f76eb058e1f\",\n                \"Source\": \"/var/lib/docker/volumes/a0017ea5e9f8d89a5487121b928e6d2881ec921dddd499c224111f76eb058e1f/_data\",\n                \"Destination\": \"/var/lib/postgresql/data\",\n                \"Driver\": \"local\",\n                \"Mode\": \"\",\n                \"RW\": true,\n                \"Propagation\": \"\"\n            }\n        ],\n        \"Config\": {\n            \"Hostname\": \"6594cbedd55e\",\n            \"Domainname\": \"\",\n            \"User\": \"\",\n            \"AttachStdin\": false,\n            \"AttachStdout\": false,\n            \"AttachStderr\": false,\n            \"ExposedPorts\": {\n                \"5432/tcp\": {}\n            },\n            \"Tty\": false,\n            \"OpenStdin\": false,\n            \"StdinOnce\": false,\n            \"Env\": [\n                \"POSTGRES_HOST_AUTH_METHOD=trust\",\n                \"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/postgresql/10/bin\",\n                \"GOSU_VERSION=1.14\",\n                \"LANG=en_US.utf8\",\n                \"PG_MAJOR=10\",\n                \"PG_VERSION=10.21-1.pgdg90+1\",\n                \"PGDATA=/var/lib/postgresql/data\"\n            ],\n            \"Cmd\": [\n                \"postgres\",\n                \"-c\",\n                \"listen_addresses=*\",\n                \"-c\",\n                \"log_destination=csvlog\",\n                \"-c\",\n                \"logging_collector=on\",\n                \"-c\",\n                \"log_directory=log\",\n                \"-c\",\n                \"log_filename=postgresql-%Y%m%d%H%M%S.log\",\n                \"-c\",\n                \"log_min_messages=error\",\n                \"-c\",\n                \"log_min_error_statement=error\",\n                \"-c\",\n                \"log_error_verbosity=verbose\",\n                \"-c\",\n                \"wal_level=logical\",\n                \"-c\",\n                \"max_wal_senders=10\",\n                \"-c\",\n                \"max_replication_slots=10\"\n            ],\n            \"Image\": \"postgres@sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc\",\n            \"Volumes\": {\n                \"/var/lib/postgresql/data\": {}\n            },\n            \"WorkingDir\": \"\",\n            \"Entrypoint\": [\n                \"docker-entrypoint.sh\"\n            ],\n            \"Labels\": {},\n            \"StopSignal\": \"SIGINT\",\n            \"StopTimeout\": 1\n        },\n        \"NetworkSettings\": {\n            \"SandboxID\": \"ab4408da0330eff85a5f4436aebdf2fcf5772e444c9dde5732cc95d216caf292\",\n            \"SandboxKey\": \"/var/run/docker/netns/ab4408da0330\",\n            \"Ports\": {\n                \"5432/tcp\": [\n                    {\n                        \"HostIp\": \"127.0.0.1\",\n                        \"HostPort\": \"54169\"\n                    }\n                ]\n            },\n            \"Networks\": {\n                \"bridge\": {\n                    \"IPAMConfig\": null,\n                    \"Links\": null,\n                    \"Aliases\": null,\n                    \"DriverOpts\": null,\n                    \"GwPriority\": 0,\n                    \"NetworkID\": \"aed51554f8cd8bac69ecd4f073e41e147fda7b458e9d95be2af472651f2e825c\",\n                    \"EndpointID\": \"8b2660bcd8c005543d2e0f748c3861ab2a33766d4d3f24309f1cc276d1fe7cb0\",\n                    \"Gateway\": \"172.17.0.1\",\n                    \"IPAddress\": \"172.17.0.53\",\n                    \"MacAddress\": \"5e:6d:a3:aa:b8:f7\",\n                    \"IPPrefixLen\": 16,\n                    \"IPv6Gateway\": \"\",\n                    \"GlobalIPv6Address\": \"\",\n                    \"GlobalIPv6PrefixLen\": 0,\n                    \"DNSNames\": null\n                }\n            }\n        },\n        \"ImageManifestDescriptor\": {\n            \"mediaType\": \"application/vnd.docker.distribution.manifest.v2+json\",\n            \"digest\": \"sha256:52aada7978f1eef3b6b52a51afb7a3defd69254d00c946cb90d2ceb32b8ffce7\",\n            \"size\": 3246,\n            \"platform\": {\n                \"architecture\": \"arm64\",\n                \"os\": \"linux\",\n                \"variant\": \"v8\"\n            }\n        }\n    }\n]\n"
      }
    }
  },
  "run_id": "syntax2-42830-pg10",
  "runtime_id": "runtime.syntax2-42830-pg10.pg10",
  "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
  "status": "passed",
  "target": "pg10"
}
sources · src.errcodes.REL_18_6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/errcodes.txt",
  "position": 0,
  "sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
  "source_id": "src.errcodes.REL_18_6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt"
}
sources · src.calls.REL_18_6
{
  "commit": "",
  "docs_url": "",
  "kind": "local_artifact",
  "location": "",
  "path": "raw/calls/REL_18_6.jsonl",
  "position": 1,
  "sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
  "source_id": "src.calls.REL_18_6",
  "tag": "",
  "url": ""
}
sources · src.calls.REL_10_23
{
  "commit": "",
  "docs_url": "",
  "kind": "local_artifact",
  "location": "",
  "path": "raw/calls/REL_10_23.jsonl",
  "position": 2,
  "sha256": "00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c",
  "source_id": "src.calls.REL_10_23",
  "tag": "",
  "url": ""
}
sources · src.invalid-fk.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/commands/tablecmds.c",
  "position": 3,
  "sha256": "422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9",
  "source_id": "src.invalid-fk.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/tablecmds.c#L13639-L13642"
}
sources · src.invalid-fk.10.23
{
  "commit": "02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/commands/tablecmds.c",
  "position": 4,
  "sha256": "6de441c88496c6cf57a836898388085ec08bf69afd70d07acdafd6089b9b5f8c",
  "source_id": "src.invalid-fk.10.23",
  "tag": "REL_10_23",
  "url": "https://github.com/postgres/postgres/blob/02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4/src/backend/commands/tablecmds.c#L8133-L8136"
}
sources · src.invalid-fk-guards.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/commands/tablecmds.c",
  "position": 5,
  "sha256": "422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9",
  "source_id": "src.invalid-fk-guards.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/tablecmds.c#L13505-L13642"
}
sources · src.invalid-fk-guards.10.23
{
  "commit": "02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/commands/tablecmds.c",
  "position": 6,
  "sha256": "6de441c88496c6cf57a836898388085ec08bf69afd70d07acdafd6089b9b5f8c",
  "source_id": "src.invalid-fk-guards.10.23",
  "tag": "REL_10_23",
  "url": "https://github.com/postgres/postgres/blob/02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4/src/backend/commands/tablecmds.c#L8002-L8136"
}
sources · manifest.42830
{
  "commit": "",
  "docs_url": "",
  "kind": "local_artifact",
  "location": "",
  "path": "verify/cases/42830/cases.json",
  "position": 7,
  "sha256": "d9ac3703aac83c78dd0565bb928ef2a4e6f28e5e6138d588191f39a3cbd72297",
  "source_id": "manifest.42830",
  "tag": "",
  "url": ""
}
sources · snippet-registry.42830
{
  "commit": "",
  "docs_url": "",
  "kind": "local_artifact",
  "location": "",
  "path": "verify/cases/42830/snippets.json",
  "position": 8,
  "sha256": "9133c8bee8f6cb7f908c33a6bf53d4eceea58565293e839a90143ba27e25ca25",
  "source_id": "snippet-registry.42830",
  "tag": "",
  "url": ""
}

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · english-manuals:33479784cd2e0532d9b11499feeb9aa5f8b1703572045163ee8580a650f01eca

正文语言: zh-Hans · english-manuals:33479784cd2e0532d9b11499feeb9aa5f8b1703572045163ee8580a650f01eca