{"Entry":{"collection":"language","key":"pltcl","name":"pltcl","aliases":[],"metadata":{"aliases":[],"category":"PL/Tcl","content_hash":"41d652076c86662d737dae6716830b706fe534aa59c1dbe1476ddabfde05ea81","derived_content_hash":"ed341b2725ff6416ff8b92aabb96f5cebb559692cb679dc21e13bff60e2a1a98","imported_at":"2026-09-30T00:40:44.369471+08:00","name":"pltcl","name_zh":"","slug":"pltcl","summary":"PL/Tcl procedural language"}},"Definition":{"Collection":"language","Key":"pltcl","SourceDatabase":"center","Version":"18","SourceTable":"procedural_language","SourceKey":"pltcl","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","Facts":{"aliases":[],"attributes":{"comment":"PL/Tcl procedural language","default_version":"1.0","family":"PL/Tcl","handler":"pltcl_call_handler","inline_handler":"","kind":"Bundled procedural-language variant","library":"$libdir/pltcl","module_pathname":"$libdir/pltcl","trusted":"t","validator":""},"comparison_data":{"default_version":"1.0","family":"PL/Tcl","handler":"pltcl_call_handler","inline_handler":"","kind":"Bundled procedural-language variant","library":"$libdir/pltcl","trusted":"t","validator":""},"comparison_hash":"e46eb0b37d7a8df979587d5efa5dc9dcdd895a8ee52bb73a51e62f5b705e3b47","description":["PL/Tcl procedural language"],"description_zh":"过程语言 pltcl。","description_zh_html":"\u003cp\u003e过程语言 pltcl。\u003c/p\u003e\u003cdl\u003e\u003cdt\u003e运算符族\u003c/dt\u003e\u003cdd\u003e\u003ccode\u003ePL/Tcl\u003c/code\u003e\u003c/dd\u003e\u003cdt\u003e处理函数\u003c/dt\u003e\u003cdd\u003e\u003ccode\u003epltcl_call_handler\u003c/code\u003e\u003c/dd\u003e\u003cdt\u003e库\u003c/dt\u003e\u003cdd\u003e\u003ccode\u003e$libdir/pltcl\u003c/code\u003e\u003c/dd\u003e\u003cdt\u003e受信任\u003c/dt\u003e\u003cdd\u003e\u003ccode\u003e是\u003c/code\u003e\u003c/dd\u003e\u003cdt\u003e默认版本\u003c/dt\u003e\u003cdd\u003e\u003ccode\u003e1.0\u003c/code\u003e\u003c/dd\u003e\u003cdt\u003e模块路径\u003c/dt\u003e\u003cdd\u003e\u003ccode\u003e$libdir/pltcl\u003c/code\u003e\u003c/dd\u003e\u003c/dl\u003e\u003ch3\u003e同版本中文手册节选\u003c/h3\u003e\u003cp\u003e\n    PL/Tcl 提供了函数编写者在 C 语言中所具备的大部分能力，但会施加少量限制，并额外提供 Tcl 可用的强大字符串处理库。\n   \u003c/p\u003e\u003cp\u003e\n    其中一个颇具吸引力的\u003cspan class=\"emphasis\"\u003e\u003cem\u003e良性\u003c/em\u003e\u003c/span\u003e限制是，所有内容都在 Tcl 解释器的安全上下文中执行。除了安全 Tcl 受限的命令集之外，只提供了少数通过 SPI 访问数据库以及通过 \u003ccode class=\"function\"\u003eelog()\u003c/code\u003e 发出消息的命令。与 C 函数不同，PL/Tcl 不提供访问数据库服务器内部机制的方法，也不能在 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 服务器进程的权限下获得操作系统级访问。因此，可以信任非特权数据库用户使用这种语言；它不会授予他们无限制的权限。\n   \u003c/p\u003e\u003cp\u003e\n    另一项值得注意的实现限制是，Tcl 函数不能用来为新数据类型创建输入/输出函数。\n   \u003c/p\u003e\u003cp\u003e\n    有时需要编写不受安全 Tcl 限制的 Tcl 函数。例如，可能希望某个 Tcl 函数能够发送电子邮件。为处理这类情况，\u003cspan class=\"application\"\u003ePL/Tcl\u003c/span\u003e 提供了一个名为 \u003ccode class=\"literal\"\u003ePL/TclU\u003c/code\u003e 的变体（其中 U 表示不受信任的 Tcl）。除了使用完整的 Tcl 解释器之外，它与前者是完全相同的语言。\u003cspan class=\"emphasis\"\u003e\u003cem\u003e如果使用 \u003cspan class=\"application\"\u003ePL/TclU\u003c/span\u003e，就必须将其安装为一种不受信任的过程语言\u003c/em\u003e\u003c/span\u003e，这样就只有数据库超级用户才能在其中创建函数。\u003cspan class=\"application\"\u003ePL/TclU\u003c/span\u003e 函数的编写者必须确保该函数不会被用来做任何不希望发生的事情，因为它能够执行任何以数据库管理员身份登录的用户所能做的事情。\n   \u003c/p\u003e\u003cp\u003e\u003ca href=\"/zh/docs/18/pltcl-overview.html\"\u003e查看完整中文手册与上下文\u003c/a\u003e。\u003c/p\u003e","facts":[{"label":"Kind","value":"Bundled procedural-language variant"},{"label":"Family","value":"PL/Tcl"},{"label":"Trusted","value":"t"},{"label":"Handler","value":"pltcl_call_handler"},{"label":"Library","value":"$libdir/pltcl"},{"label":"Default version","value":"1.0"},{"label":"Module pathname","value":"$libdir/pltcl"},{"label":"Comment","value":"PL/Tcl procedural language"}],"facts_zh":[{"label":"种类","value":"随源码提供的过程语言变体"},{"label":"操作符家族","value":"PL/Tcl"},{"label":"可信","value":"t"},{"label":"处理函数","value":"pltcl_call_handler"},{"label":"库","value":"$libdir/pltcl"},{"label":"默认版本","value":"1.0"},{"label":"模块路径","value":"$libdir/pltcl"},{"label":"注释","value":"PL/Tcl 过程语言"}],"manual_html":"\u003cdiv class=\"sect1\" id=\"PLTCL-OVERVIEW\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch2 class=\"title\"\u003e42.1. Overview \u003c/h2\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003ePL/Tcl offers most of the capabilities a function writer has in the C language, with a few restrictions, and with the addition of the powerful string processing libraries that are available for Tcl.\u003c/p\u003e\n\u003cp\u003eOne compelling \u003cspan class=\"emphasis\"\u003e\u003cem\u003egood\u003c/em\u003e\u003c/span\u003e restriction is that everything is executed from within the safety of the context of a Tcl interpreter. In addition to the limited command set of safe Tcl, only a few commands are available to access the database via SPI and to raise messages via \u003ccode class=\"function\"\u003eelog()\u003c/code\u003e. PL/Tcl provides no way to access internals of the database server or to gain OS-level access under the permissions of the \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e server process, as a C function can do. Thus, unprivileged database users can be trusted to use this language; it does not give them unlimited authority.\u003c/p\u003e\n\u003cp\u003eThe other notable implementation restriction is that Tcl functions cannot be used to create input/output functions for new data types.\u003c/p\u003e\n\u003cp\u003eSometimes it is desirable to write Tcl functions that are not restricted to safe Tcl. For example, one might want a Tcl function that sends email. To handle these cases, there is a variant of \u003cspan class=\"application\"\u003ePL/Tcl\u003c/span\u003e called \u003ccode class=\"literal\"\u003ePL/TclU\u003c/code\u003e (for untrusted Tcl). This is exactly the same language except that a full Tcl interpreter is used. \u003cspan class=\"emphasis\"\u003e\u003cem\u003eIf \u003cspan class=\"application\"\u003ePL/TclU\u003c/span\u003e is used, it must be installed as an untrusted procedural language\u003c/em\u003e\u003c/span\u003e so that only database superusers can create functions in it. The writer of a \u003cspan class=\"application\"\u003ePL/TclU\u003c/span\u003e function must take care that the function cannot be used to do anything unwanted, since it will be able to do anything that could be done by a user logged in as the database administrator.\u003c/p\u003e\n\u003cp\u003eThe shared object code for the \u003cspan class=\"application\"\u003ePL/Tcl\u003c/span\u003e and \u003cspan class=\"application\"\u003ePL/TclU\u003c/span\u003e call handlers is automatically built and installed in the \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e library directory if Tcl support is specified in the configuration step of the installation procedure. To install \u003cspan class=\"application\"\u003ePL/Tcl\u003c/span\u003e and/or \u003cspan class=\"application\"\u003ePL/TclU\u003c/span\u003e in a particular database, use the \u003ccode class=\"command\"\u003eCREATE EXTENSION\u003c/code\u003e command, for example \u003ccode class=\"literal\"\u003eCREATE EXTENSION pltcl\u003c/code\u003e or \u003ccode class=\"literal\"\u003eCREATE EXTENSION pltclu\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e","manual_path":"/docs/18/pltcl-overview.html","related":[{"label":"pltcl-config","url":"/docs/18/pltcl-config.html"},{"label":"pltcl-data","url":"/docs/18/pltcl-data.html"},{"label":"pltcl-dbaccess","url":"/docs/18/pltcl-dbaccess.html"},{"label":"pltcl-error-handling","url":"/docs/18/pltcl-error-handling.html"},{"label":"pltcl-event-trigger","url":"/docs/18/pltcl-event-trigger.html"},{"label":"pltcl-functions","url":"/docs/18/pltcl-functions.html"},{"label":"pltcl-global","url":"/docs/18/pltcl-global.html"},{"label":"pltcl-overview","url":"/docs/18/pltcl-overview.html"},{"label":"pltcl-procnames","url":"/docs/18/pltcl-procnames.html"},{"label":"pltcl-subtransactions","url":"/docs/18/pltcl-subtransactions.html"},{"label":"pltcl-transactions","url":"/docs/18/pltcl-transactions.html"},{"label":"pltcl-trigger","url":"/docs/18/pltcl-trigger.html"}],"release":{"catalog_fingerprint":"65c93d6048ef30e61023a84f9680fa6a92b1c383b7eb226741170077eb078502","channel":"stable","label":"18.6","major":"18","ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[{"code":"/* src/pl/tcl/pltcl--1.0.sql */\n\nCREATE FUNCTION pltcl_call_handler() RETURNS language_handler\n  LANGUAGE c AS 'MODULE_PATHNAME';\n\nCREATE TRUSTED LANGUAGE pltcl\n  HANDLER pltcl_call_handler;\n\n-- The language object, but not the functions, can be owned by a non-superuser.\nALTER LANGUAGE pltcl OWNER TO @extowner@;\n\nCOMMENT ON LANGUAGE pltcl IS 'PL/Tcl procedural language';","paragraphs":["This extension is shipped with the source. Its presence does not establish that the language or external runtime is installed."],"title":"Installation definition from the matching source archive"}],"sections_zh":[{"code":"/* src/pl/tcl/pltcl--1.0.sql */\n\nCREATE FUNCTION pltcl_call_handler() RETURNS language_handler\n  LANGUAGE c AS 'MODULE_PATHNAME';\n\nCREATE TRUSTED LANGUAGE pltcl\n  HANDLER pltcl_call_handler;\n\n-- The language object, but not the functions, can be owned by a non-superuser.\nALTER LANGUAGE pltcl OWNER TO @extowner@;\n\nCOMMENT ON LANGUAGE pltcl IS 'PL/Tcl procedural language';","paragraphs":["此扩展随源码提供；收录它并不表示已安装该语言或外部运行时。"],"title":"同构建源码中的安装定义"}],"signature":"","source_files":{"src/pl/tcl/pltcl--1.0.sql":"ac88016ee30120ef28b03d64f9b511ef55bcc2e8deb1a79e6bf18302a529c174","src/pl/tcl/pltcl.control":"1a82de220094e85a979335f97e14d3baab8eed8c8d98015c2adc7ba4dd98c30c"},"sources":[{"label":"Matching PostgreSQL source archive","sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"label":"PostgreSQL 18 English manual","path":"pltcl-overview.html","sha256":"ed93c7e7682e446657a8c944dbabdabb0236e2d09c48db1c7e804270ce480044","url":"/docs/18/pltcl-overview.html"}],"tables":[],"tables_zh":[],"zh_from":{"authored_translation":"source-derived-structured-summary","body_sha256":"b050f16bbcef5150f93395d11cad06062d17c90cb1ccb833303e498ea1027634","kind":"same-version-chinese-manual-with-source-derived-structured-summary","manual":{"anchor":"","build_id":107,"extraction":"concept-introduction","fragment_sha256":"b7c9227131bf64d653cdea2685ce3647932708c511072a5a133b39a9af0ba4c4","locale":"zh-Hans","page_key":"pltcl-overview.html","source_hash":"55e36d230231cb356bd65998471f93060e3753dc785b3a34802d1b8c83f8978a","source_revision":"unknown:rendered-translation-baseline","translated_from_revision":null,"translation_revision":"git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:08e987a66af27b98444a8057c256314eafa13611a3fb9e888214fc436824244b","url":"/zh/docs/18/pltcl-overview.html","version":"18"},"runtime_rerun":false,"source_facts_revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}},"ManualEvidence":{"manual_path":"/docs/18/pltcl-overview.html","release":{"catalog_fingerprint":"65c93d6048ef30e61023a84f9680fa6a92b1c383b7eb226741170077eb078502","channel":"stable","label":"18.6","major":"18","ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"label":"Matching PostgreSQL source archive","sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"label":"PostgreSQL 18 English manual","path":"pltcl-overview.html","sha256":"ed93c7e7682e446657a8c944dbabdabb0236e2d09c48db1c7e804270ce480044","url":"/docs/18/pltcl-overview.html"}]},"MeasuredEvidence":{}},"Text":{"Collection":"language","Key":"pltcl","SourceDatabase":"center","Version":"18","Locale":"en","Title":"pltcl","Summary":"PL/Tcl procedural language","BodyHTML":"\u003cdiv id=\"PLTCL-OVERVIEW\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch2\u003e42.1. Overview \u003c/h2\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003ePL/Tcl offers most of the capabilities a function writer has in the C language, with a few restrictions, and with the addition of the powerful string processing libraries that are available for Tcl.\u003c/p\u003e\n\u003cp\u003eOne compelling \u003cspan\u003e\u003cem\u003egood\u003c/em\u003e\u003c/span\u003e restriction is that everything is executed from within the safety of the context of a Tcl interpreter. In addition to the limited command set of safe Tcl, only a few commands are available to access the database via SPI and to raise messages via \u003ccode\u003eelog()\u003c/code\u003e. PL/Tcl provides no way to access internals of the database server or to gain OS-level access under the permissions of the \u003cspan\u003ePostgreSQL\u003c/span\u003e server process, as a C function can do. Thus, unprivileged database users can be trusted to use this language; it does not give them unlimited authority.\u003c/p\u003e\n\u003cp\u003eThe other notable implementation restriction is that Tcl functions cannot be used to create input/output functions for new data types.\u003c/p\u003e\n\u003cp\u003eSometimes it is desirable to write Tcl functions that are not restricted to safe Tcl. For example, one might want a Tcl function that sends email. To handle these cases, there is a variant of \u003cspan\u003ePL/Tcl\u003c/span\u003e called \u003ccode\u003ePL/TclU\u003c/code\u003e (for untrusted Tcl). This is exactly the same language except that a full Tcl interpreter is used. \u003cspan\u003e\u003cem\u003eIf \u003cspan\u003ePL/TclU\u003c/span\u003e is used, it must be installed as an untrusted procedural language\u003c/em\u003e\u003c/span\u003e so that only database superusers can create functions in it. The writer of a \u003cspan\u003ePL/TclU\u003c/span\u003e function must take care that the function cannot be used to do anything unwanted, since it will be able to do anything that could be done by a user logged in as the database administrator.\u003c/p\u003e\n\u003cp\u003eThe shared object code for the \u003cspan\u003ePL/Tcl\u003c/span\u003e and \u003cspan\u003ePL/TclU\u003c/span\u003e call handlers is automatically built and installed in the \u003cspan\u003ePostgreSQL\u003c/span\u003e library directory if Tcl support is specified in the configuration step of the installation procedure. To install \u003cspan\u003ePL/Tcl\u003c/span\u003e and/or \u003cspan\u003ePL/TclU\u003c/span\u003e in a particular database, use the \u003ccode\u003eCREATE EXTENSION\u003c/code\u003e command, for example \u003ccode\u003eCREATE EXTENSION pltcl\u003c/code\u003e or \u003ccode\u003eCREATE EXTENSION pltclu\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","ContentHash":"49e9ec66f5eef841691ba44a4157d531891366e6260da235f143e29525a39b80","Payload":{"description":["PL/Tcl procedural language"],"manual_html":"\u003cdiv class=\"sect1\" id=\"PLTCL-OVERVIEW\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch2 class=\"title\"\u003e42.1. Overview \u003c/h2\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003ePL/Tcl offers most of the capabilities a function writer has in the C language, with a few restrictions, and with the addition of the powerful string processing libraries that are available for Tcl.\u003c/p\u003e\n\u003cp\u003eOne compelling \u003cspan class=\"emphasis\"\u003e\u003cem\u003egood\u003c/em\u003e\u003c/span\u003e restriction is that everything is executed from within the safety of the context of a Tcl interpreter. In addition to the limited command set of safe Tcl, only a few commands are available to access the database via SPI and to raise messages via \u003ccode class=\"function\"\u003eelog()\u003c/code\u003e. PL/Tcl provides no way to access internals of the database server or to gain OS-level access under the permissions of the \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e server process, as a C function can do. Thus, unprivileged database users can be trusted to use this language; it does not give them unlimited authority.\u003c/p\u003e\n\u003cp\u003eThe other notable implementation restriction is that Tcl functions cannot be used to create input/output functions for new data types.\u003c/p\u003e\n\u003cp\u003eSometimes it is desirable to write Tcl functions that are not restricted to safe Tcl. For example, one might want a Tcl function that sends email. To handle these cases, there is a variant of \u003cspan class=\"application\"\u003ePL/Tcl\u003c/span\u003e called \u003ccode class=\"literal\"\u003ePL/TclU\u003c/code\u003e (for untrusted Tcl). This is exactly the same language except that a full Tcl interpreter is used. \u003cspan class=\"emphasis\"\u003e\u003cem\u003eIf \u003cspan class=\"application\"\u003ePL/TclU\u003c/span\u003e is used, it must be installed as an untrusted procedural language\u003c/em\u003e\u003c/span\u003e so that only database superusers can create functions in it. The writer of a \u003cspan class=\"application\"\u003ePL/TclU\u003c/span\u003e function must take care that the function cannot be used to do anything unwanted, since it will be able to do anything that could be done by a user logged in as the database administrator.\u003c/p\u003e\n\u003cp\u003eThe shared object code for the \u003cspan class=\"application\"\u003ePL/Tcl\u003c/span\u003e and \u003cspan class=\"application\"\u003ePL/TclU\u003c/span\u003e call handlers is automatically built and installed in the \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e library directory if Tcl support is specified in the configuration step of the installation procedure. To install \u003cspan class=\"application\"\u003ePL/Tcl\u003c/span\u003e and/or \u003cspan class=\"application\"\u003ePL/TclU\u003c/span\u003e in a particular database, use the \u003ccode class=\"command\"\u003eCREATE EXTENSION\u003c/code\u003e command, for example \u003ccode class=\"literal\"\u003eCREATE EXTENSION pltcl\u003c/code\u003e or \u003ccode class=\"literal\"\u003eCREATE EXTENSION pltclu\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e","related":[{"label":"pltcl-config","url":"/docs/18/pltcl-config.html"},{"label":"pltcl-data","url":"/docs/18/pltcl-data.html"},{"label":"pltcl-dbaccess","url":"/docs/18/pltcl-dbaccess.html"},{"label":"pltcl-error-handling","url":"/docs/18/pltcl-error-handling.html"},{"label":"pltcl-event-trigger","url":"/docs/18/pltcl-event-trigger.html"},{"label":"pltcl-functions","url":"/docs/18/pltcl-functions.html"},{"label":"pltcl-global","url":"/docs/18/pltcl-global.html"},{"label":"pltcl-overview","url":"/docs/18/pltcl-overview.html"},{"label":"pltcl-procnames","url":"/docs/18/pltcl-procnames.html"},{"label":"pltcl-subtransactions","url":"/docs/18/pltcl-subtransactions.html"},{"label":"pltcl-transactions","url":"/docs/18/pltcl-transactions.html"},{"label":"pltcl-trigger","url":"/docs/18/pltcl-trigger.html"}],"sections":[{"code":"/* src/pl/tcl/pltcl--1.0.sql */\n\nCREATE FUNCTION pltcl_call_handler() RETURNS language_handler\n  LANGUAGE c AS 'MODULE_PATHNAME';\n\nCREATE TRUSTED LANGUAGE pltcl\n  HANDLER pltcl_call_handler;\n\n-- The language object, but not the functions, can be owned by a non-superuser.\nALTER LANGUAGE pltcl OWNER TO @extowner@;\n\nCOMMENT ON LANGUAGE pltcl IS 'PL/Tcl procedural language';","paragraphs":["This extension is shipped with the source. Its presence does not establish that the language or external runtime is installed."],"title":"Installation definition from the matching source archive"}],"tables":[]}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
