42611 — 列定义无效(invalid_column_definition)
列定义无效,如继承的父表默认值冲突。
英文手册覆盖始于 PostgreSQL 8.1. 来源历史与运行验证各自保留独立版本边界。
当前阅读 PG 18·选择有来源记录的版本
- aliases
- 未知
- class name
- Syntax Error or Access Rule Violation
- condition name
- invalid_column_definition
- lang
- en
- sqlstate
- 42611
版本定义 PG 18
42611 — 列定义无效
速览 {#at-a-glance}
SQLSTATE 42611 是 Class 42 中的 invalid_column_definition。42611 表示列定义无效。选定案例中的两个继承父表为 id 定义了不同默认值;子表 DDL 失败并报告 column "%s" inherits conflicting default values,提示显式指定默认值。
含义 {#meaning}
42611 表示列定义无效。在 MergeAttributes 中,PostgreSQL 按父表顺序合并同名列。如果继承来的默认表达式不相等,且子表没有覆盖它,最终检查会发出 ERROR:column "%s" inherits conflicting default values,并提示显式指定默认值。选定案例的两个父表为 id 定义了不同默认值。
诊断 {#diagnosis}
检查 INHERITS 列表中的每个父表,比较同名列的类型、排序规则、可空性和默认表达式。相同默认值可以合并;子表本地默认值可以覆盖继承冲突。选定 DDL 的 ERROR 后自动提交会话仍为 IDLE;这是继承默认值分支,不是一般的重复列错误,也不是类型/排序规则冲突。
处理 {#response}
按服务器提示在子表定义中显式声明预期默认值,然后插入 DEFAULT VALUES 并核对结果。如果父表本应一致,应直接修复父表迁移;如果差异是有意的,就把子表覆盖值明确写在 DDL 中。选定修复返回 1,但这是案例值,不代表所有场景都应选择同一策略。
报文 {#messages}
选定源码分支以明确的 ERROR 发出主报文 column "%s" inherits conflicting default values 和 HINT To resolve the conflict, specify a default explicitly. %s 是冲突列名。只有客户端异常而没有服务器 SQLSTATE、主报文和 HINT 时,不能据此识别这个选定的继承默认值子路径;其他固定 producer 可以使用同一 SQLSTATE 和不同诊断。
代表案例 {#case}
本页使用与运行器注册表相同的语句。执行时,syntax_schema、syntax_role 等生成名称会替换为一次性实例中的实际值。
CREATE TABLE syntax_schema.parent_one (id integer DEFAULT 1);
CREATE TABLE syntax_schema.parent_two (id integer DEFAULT 2);
CREATE TABLE syntax_schema.child_bad () INHERITS (syntax_schema.parent_one, syntax_schema.parent_two);
CREATE TABLE syntax_schema.child_good (id integer DEFAULT 1) INHERITS (syntax_schema.parent_one, syntax_schema.parent_two);
INSERT INTO syntax_schema.child_good DEFAULT VALUES RETURNING id;
选定的 18.6 运行记录结构化诊断并通过修复断言;10.21 运行通过同一案例的具体检查。可下载的案例和证据投影分别是 42611 案例 JSON 和 作者证据。运行器清单为 verify/cases/42611/cases.json,页面 SQL 会与共享注册表核对。
版本 {#versions}
选定的自然运行范围是 PostgreSQL 18.6 与 10.21,不能据此推断所有中间版本的行为。
相关 {#related}
来源 {#sources}
src.errcodes.18.6— fixederrcodes.txtdefinition at commit724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-2566e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba(source).src.inherited-conflicting-default.18.6—src/backend/commands/tablecmds.catREL_18_6commit724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9(source).src.inherited-conflicting-default.10.23—src/backend/commands/tablecmds.catREL_10_23commit02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-2566de441c88496c6cf57a836898388085ec08bf69afd70d07acdafd6089b9b5f8c(source).src.calls.REL_18_6/src.calls.REL_10_23— fixed call scans, SHA-2569ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf/00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
比较版本
SQLSTATE 证据与已记录的运行版本
cases · conflicting_inherited_default
{
"assertions": [
"SQLSTATE is 42611 with the conflicting-default diagnostic",
"The session remains IDLE",
"An explicit child default resolves the inheritance conflict and DEFAULT inserts 1"
],
"case_id": "conflicting_inherited_default",
"cleanup": "Drop the case schema with an owner connection.",
"has_snippet": true,
"position": 0,
"preconditions": [
"A runner-owned disposable target is provisioned."
],
"repair": "Specify the intended default explicitly on the child definition, then verify the inherited table.",
"trigger": "Create two parent tables with different defaults and inherit both without an explicit child default.",
"versions": [
"10",
"18"
]
}claims · identity.class-and-condition
{
"claim_id": "identity.class-and-condition",
"limits": "Directory identity does not identify every backend path.",
"method": "Read fixed errcodes.txt and the locked catalogue metadata.",
"position": 0,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "42611 is the invalid_column_definition condition in Class 42."
}claims · mechanism.backend-path
{
"claim_id": "mechanism.backend-path",
"limits": "Other calls can use the same SQLSTATE with different context or dynamic fields.",
"method": "Trace the resolved REL_18_6 and REL_10_23 source call records at the locked commits.",
"position": 1,
"runtime": [],
"sources": [
"src.inherited-conflicting-default.18.6",
"src.inherited-conflicting-default.10.23"
],
"statement": "The fixed source calls for 42611 include the mechanism and message boundary selected for this page."
}claims · runtime.representative-case
{
"claim_id": "runtime.representative-case",
"limits": "This covers the selected case and targets only; it does not generalize to all drivers or intermediate releases.",
"method": "Run the shared registry case and inspect structured diagnostics, state/recovery assertions, and cleanup.",
"position": 2,
"runtime": [
"runtime.42611-syntax-latest1.latest",
"runtime.42611-syntax-pg10.pg10"
],
"sources": [
"manifest.42611",
"snippet-registry.42611"
],
"statement": "The selected conflicting_inherited_default case 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.",
"method": "Read generated facts and selected summaries.",
"position": 3,
"runtime": [],
"sources": [
"src.errcodes.18.6",
"src.calls.REL_18_6",
"src.calls.REL_10_23"
],
"statement": "The locked catalogue records 42611; runtime scope is limited to the selected targets."
}messages · message.inherited-default
{
"limits": "",
"message_id": "message.inherited-default",
"path": "",
"position": 0,
"raw": {
"hint_template": "To resolve the conflict, specify a default explicitly.",
"id": "message.inherited-default",
"primary_template": "column \"%s\" inherits conflicting default values",
"severity_source": "explicit ERROR",
"sources": [
"src.inherited-conflicting-default.18.6",
"src.inherited-conflicting-default.10.23"
],
"sqlstate": "42611"
},
"severity": "explicit ERROR",
"sources": [
"src.inherited-conflicting-default.18.6",
"src.inherited-conflicting-default.10.23"
],
"templates": [
{
"kind": "primary",
"literal": "column \" \" inherits conflicting default values",
"position": 0,
"role": "",
"template": "column \"%s\" inherits conflicting default values"
},
{
"kind": "hint",
"literal": "To resolve the conflict, specify a default explicitly.",
"position": 1,
"role": "",
"template": "To resolve the conflict, specify a default explicitly."
}
]
}runtimes · runtime.42611-syntax-latest1.latest · 18.6 (Homebrew) · passed
{
"cases": [],
"limits": "",
"position": 0,
"raw": {
"assertions": [
{
"expected": "42611",
"name": "42611 SQLSTATE",
"observed": "42611",
"passed": true
},
{
"expected": "ERROR",
"name": "42611 ERROR severity",
"observed": "ERROR",
"passed": true
},
{
"expected": "conflicting default values",
"name": "diagnostic identifies conflicting inherited defaults",
"observed": "column \"id\" inherits conflicting default values",
"passed": true
},
{
"expected": "IDLE",
"name": "inheritance definition failure leaves session usable",
"observed": "IDLE",
"passed": true
},
{
"expected": {
"status": "IDLE",
"value": 1
},
"name": "explicit default resolves inherited conflict",
"observed": {
"status": "IDLE",
"value": 1
},
"passed": true
}
],
"case_manifest": {
"id": "manifest.42611",
"kind": "local_artifact",
"path": "verify/cases/42611/cases.json",
"sha256": "f5e5e9e9ed3523b965a78dbce9f27b3e15a718780ee5b260286785279e54efb5",
"source_role": "case_manifest"
},
"cleanup": {
"errors": [],
"passed": true
},
"environment": {
"TimeZone": "Asia/Shanghai",
"backend_pid": 1674,
"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": "en_US.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.42611-syntax-latest1.latest",
"observed": {
"connection_autocommit": true,
"diagnostic": {
"column_name": null,
"constraint_name": null,
"context": null,
"datatype_name": null,
"exception_type": "InvalidColumnDefinition",
"internal_position": null,
"internal_query": null,
"message_detail": null,
"message_hint": "To resolve the conflict, specify a default explicitly.",
"message_primary": "column \"id\" inherits conflicting default values",
"schema_name": null,
"severity": "ERROR",
"severity_nonlocalized": "ERROR",
"source_file": "tablecmds.c",
"source_function": "MergeAttributes",
"source_line": "3148",
"sqlstate": "42611",
"statement_position": null,
"table_name": null,
"text": "column \"id\" inherits conflicting default values\nHINT: To resolve the conflict, specify a default explicitly."
},
"failed_status": "IDLE",
"repair_status": "IDLE",
"repair_value": 1
},
"raw": "verify/results/42611-syntax-latest1/latest/raw.jsonl",
"raw_sha256": "914e3a6eaf7e7c885705addc898f313ae220899970223c505d331ce7bdeecdca",
"run_id": "42611-syntax-latest1",
"server_version": "18.6 (Homebrew)",
"server_version_num": 180006,
"snippet_registry": {
"id": "snippet-registry.42611",
"kind": "local_artifact",
"path": "verify/cases/42611/snippets.json",
"sha256": "23614c2fa79a899cf2946d823ba17ec62a03e9c7ed4833db5a0422d889581569",
"source_role": "snippet_registry"
},
"status": "passed",
"summary": "verify/results/42611-syntax-latest1/latest/summary.json",
"summary_sha256": "b09e6edfd79545d85e38ecb14bddd49527cfcb1e304e881fd46f713277b40749",
"target": "latest"
},
"run_id": "42611-syntax-latest1",
"runtime_id": "runtime.42611-syntax-latest1.latest",
"server_version": "18.6 (Homebrew)",
"status": "passed",
"target": "latest"
}runtimes · runtime.42611-syntax-pg10.pg10 · 10.21 (Debian 10.21-1.pgdg90+1) · passed
{
"cases": [],
"limits": "",
"position": 1,
"raw": {
"assertions": [
{
"expected": "42611",
"name": "42611 SQLSTATE",
"observed": "42611",
"passed": true
},
{
"expected": "ERROR",
"name": "42611 ERROR severity",
"observed": "ERROR",
"passed": true
},
{
"expected": "conflicting default values",
"name": "diagnostic identifies conflicting inherited defaults",
"observed": "column \"id\" inherits conflicting default values",
"passed": true
},
{
"expected": "IDLE",
"name": "inheritance definition failure leaves session usable",
"observed": "IDLE",
"passed": true
},
{
"expected": {
"status": "IDLE",
"value": 1
},
"name": "explicit default resolves inherited conflict",
"observed": {
"status": "IDLE",
"value": 1
},
"passed": true
}
],
"case_manifest": {
"id": "manifest.42611",
"kind": "local_artifact",
"path": "verify/cases/42611/cases.json",
"sha256": "f5e5e9e9ed3523b965a78dbce9f27b3e15a718780ee5b260286785279e54efb5",
"source_role": "case_manifest"
},
"cleanup": {
"errors": [],
"passed": true
},
"environment": {
"TimeZone": "Etc/UTC",
"backend_pid": 79,
"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": "en_US.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.42611-syntax-pg10.pg10",
"observed": {
"connection_autocommit": true,
"diagnostic": {
"column_name": null,
"constraint_name": null,
"context": null,
"datatype_name": null,
"exception_type": "InvalidColumnDefinition",
"internal_position": null,
"internal_query": null,
"message_detail": null,
"message_hint": "To resolve the conflict, specify a default explicitly.",
"message_primary": "column \"id\" inherits conflicting default values",
"schema_name": null,
"severity": "ERROR",
"severity_nonlocalized": "ERROR",
"source_file": "tablecmds.c",
"source_function": "MergeAttributes",
"source_line": "2292",
"sqlstate": "42611",
"statement_position": null,
"table_name": null,
"text": "column \"id\" inherits conflicting default values\nHINT: To resolve the conflict, specify a default explicitly."
},
"failed_status": "IDLE",
"repair_status": "IDLE",
"repair_value": 1
},
"raw": "verify/results/42611-syntax-pg10/pg10/raw.jsonl",
"raw_sha256": "e89bdd693471c7175bb269a983da72edd45c03dc571db7e9b758408359b00346",
"run_id": "42611-syntax-pg10",
"server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
"server_version_num": 100021,
"snippet_registry": {
"id": "snippet-registry.42611",
"kind": "local_artifact",
"path": "verify/cases/42611/snippets.json",
"sha256": "23614c2fa79a899cf2946d823ba17ec62a03e9c7ed4833db5a0422d889581569",
"source_role": "snippet_registry"
},
"status": "passed",
"summary": "verify/results/42611-syntax-pg10/pg10/summary.json",
"summary_sha256": "61ae83ec573f52f434a492cc21bacb3ba544dcaa3d505236d69f2d1cce364a03",
"target": "pg10"
},
"run_id": "42611-syntax-pg10",
"runtime_id": "runtime.42611-syntax-pg10.pg10",
"server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
"status": "passed",
"target": "pg10"
}sources · src.errcodes.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/errcodes.txt",
"position": 0,
"sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
"source_id": "src.errcodes.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.inherited-conflicting-default.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/commands/tablecmds.c",
"position": 3,
"sha256": "422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9",
"source_id": "src.inherited-conflicting-default.18.6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/tablecmds.c#L3144-L3148"
}sources · src.inherited-conflicting-default.10.23
{
"commit": "02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/commands/tablecmds.c",
"position": 4,
"sha256": "6de441c88496c6cf57a836898388085ec08bf69afd70d07acdafd6089b9b5f8c",
"source_id": "src.inherited-conflicting-default.10.23",
"tag": "REL_10_23",
"url": "https://github.com/postgres/postgres/blob/02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4/src/backend/commands/tablecmds.c#L2288-L2292"
}sources · manifest.42611
{
"commit": "",
"docs_url": "",
"kind": "local_artifact",
"location": "",
"path": "verify/cases/42611/cases.json",
"position": 5,
"sha256": "f5e5e9e9ed3523b965a78dbce9f27b3e15a718780ee5b260286785279e54efb5",
"source_id": "manifest.42611",
"tag": "",
"url": ""
}sources · snippet-registry.42611
{
"commit": "",
"docs_url": "",
"kind": "local_artifact",
"location": "",
"path": "verify/cases/42611/snippets.json",
"position": 6,
"sha256": "23614c2fa79a899cf2946d823ba17ec62a03e9c7ed4833db5a0422d889581569",
"source_id": "snippet-registry.42611",
"tag": "",
"url": ""
}来源引用
定义来源
center · PostgreSQL 18 · english-manuals:e2ba52d050bf9a609fabf7c3bda9a05e2ece4792055d22bc9fe264b8b520e465
正文语言: zh-Hans · english-manuals:e2ba52d050bf9a609fabf7c3bda9a05e2ece4792055d22bc9fe264b8b520e465