选择 打开 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

文档 / SQL 状态码 / Class 2F SQL例程异常

2F003 prohibited_sql_statement_attempted

ERROR 源码确认 参考 未实测

类别
Class 2F SQL例程异常
严重等级
ERROR
条件名
prohibited_sql_statement_attempted
宏名称
ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED
启用版本
7.4
状态
活跃

版本覆盖

速览

SQLSTATE 2F003 是 SQL Routine Exception 类别中“尝试执行被禁止 SQL 语句”的成员。固定 PostgreSQL 18.6 源码在 dblink 和 postgres_fdw 的不同连接路径中确认了该 ERROR;dblink 还覆盖了结果返回形状不符合 API 要求的路径。

含义

确认的消息包括 statement returning results not allowed,以及 password or GSSAPI delegated credentials required,后者带有 detail,有些路径还带 hint。postgres_fdw 的 detail 会说明 user mapping,有时 hint 会提到 password_required=false;dblink 使用自己的凭据措辞。由于同一 SQLSTATE 覆盖不同 API,必须保留实际产生者。

消息

确认的消息包括 statement returning results not allowed,以及 password or GSSAPI delegated credentials required,后者带有 detail,有些路径还带 hint。postgres_fdw 的 detail 会说明 user mapping,有时 hint 会提到 password_required=false;dblink 使用自己的凭据措辞。由于同一 SQLSTATE 覆盖不同 API,必须保留实际产生者。

报文模板

源码里的格式串,不是某一次运行的输出。%s 之类是占位符,实际报文会填入对象名与取值。适用范围一栏是核验时留下的原始英文记录,未经翻译。

主消息 statement returning results not allowed

来源:contrib/dblink/dblink.c @ REL_18_6

适用范围:This is dblink no-result API enforcement.

主消息 password or GSSAPI delegated credentials required
DETAIL Non-superusers may only connect using credentials they provide, eg: password in connection string or delegated GSSAPI credentials
HINT Ensure provided credentials match target server's authentication method.

来源:contrib/dblink/dblink.c @ REL_18_6

适用范围:Credential wording and whether HINT is present vary by dblink connection path.

主消息 password or GSSAPI delegated credentials required
DETAIL Non-superusers must provide a password in the connection string or send delegated GSSAPI credentials.

来源:contrib/dblink/dblink.c @ REL_18_6

适用范围:This dblink credential branch has DETAIL but no HINT.

主消息 password or GSSAPI delegated credentials required
DETAIL Non-superuser cannot connect if the server does not request a password or use GSSAPI with delegated credentials.
HINT Target server's authentication method must be changed or password_required=false set in the user mapping attributes.

来源:contrib/postgres_fdw/connection.c @ REL_18_6

适用范围:User mapping, authentication method, and password_required setting are deployment-dependent.

主消息 password or GSSAPI delegated credentials required
DETAIL Non-superusers must delegate GSSAPI credentials, provide a password, or enable SCRAM pass-through in user mapping.

来源:contrib/postgres_fdw/connection.c @ REL_18_6

适用范围:This branch has DETAIL and no HINT.

诊断

对于 dblink,确认本地调用是把会返回行的命令用于无结果 API,还是连接凭据检查。对于 postgres_fdw,若消息点名这些对象,就检查 foreign server 连接、user mapping、认证方法以及服务器的 password_required 策略。保留固定 detail/hint,不要把 dblink 和 postgres_fdw 合并成一个笼统 wrapper。

处理

修正命令与 API 的搭配,或修正消息点名的连接凭据和 user mapping,然后验证远端操作。远端连接尝试可能尚未完成;重试前要保留远端/本地边界。不要仅因 dblink 或 postgres_fdw 报告 2F003 就改变事务策略。

版本

锁定目录将该条件的已知下界记为 PostgreSQL 7.4;事实块列出已发布快照,源码路径状态仅限于下方固定的 PostgreSQL 18.6 资料。

来源

证据

断言

每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。

  • 2F003 is prohibited_sql_statement_attempted in SQLSTATE Class 2F.

    核实方式Read the fixed errcodes definition row, severity, and macro.

    来源src/backend/utils/errcodes.txt

  • The fixed PostgreSQL 18.6 source contains the report contexts and message variants described on the page.

    核实方式Read the complete source context around the resolved report groups.

    不覆盖Source confirmation is not a runtime observation in this batch.

    来源contrib/dblink/dblink.c · contrib/postgres_fdw/connection.c

  • Locked release definitions establish catalogue presence from 7.4; they do not establish a precise introducing release or runtime use.

    核实方式Compare canonical release facts with the available history boundary.

    不覆盖Definition presence is not an emitting-path observation.

    来源src/backend/utils/errcodes.txt

同类 SQL 状态码

状态码 条件名 宏名称 严重等级 版本
Class 2F SQL例程异常 SQL Routine Exception 5 个
2F000 sql_routine_exception ERRCODE_SQL_ROUTINE_EXCEPTION ERROR 7.4
SQL 例程异常的类别码,需按具体子码诊断。 活跃
2F002 modifying_sql_data_not_permitted ERRCODE_S_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED ERROR 7.4
例程的数据访问契约不允许修改 SQL 数据。 活跃
2F003 prohibited_sql_statement_attempted ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED ERROR 7.4
例程中尝试执行被禁止的 SQL 语句,见于 dblink。 活跃
2F004 reading_sql_data_not_permitted ERRCODE_S_R_E_READING_SQL_DATA_NOT_PERMITTED ERROR 7.4
例程的数据访问契约不允许读取 SQL 数据。 活跃
2F005 function_executed_no_return_statement ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT ERROR 7.4
函数执行结束时没有执行 RETURN 语句。 活跃