pltclu
PL/TclU untrusted procedural language
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pltcl | 1.0 | LANG | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 3240 | pltcl | No | Yes | No | Yes | No | No | - |
| 3250 | pltclu | No | No | No | Yes | No | No | - |
| Related | plpgsql plperlu plpython3u plv8 plluau pljava pg_tle |
|---|
Version
| PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|
| 1.0 | 1.0 | 1.0 | 1.0 | 1.0 |
Install
Note: This is a built-in contrib extension of PostgreSQL
CREATE EXTENSION pltclu;
Usage
PL/Tcl Untrusted provides full Tcl capabilities including filesystem access and external program execution. Only superusers can create functions in this language.
CREATE EXTENSION pltclu;
-- Read a file from the server filesystem
CREATE FUNCTION read_file(filename text) RETURNS text
LANGUAGE pltclu AS $$
set fd [open $1 r]
set content [read $fd]
close $fd
return $content
$$;
-- Execute an external command
CREATE FUNCTION run_command(cmd text) RETURNS text
LANGUAGE pltclu AS $$
return [exec {*}$1]
$$;
-- Access environment variables
CREATE FUNCTION get_env(varname text) RETURNS text
LANGUAGE pltclu AS $$
if {[info exists ::env($1)]} {
return $::env($1)
}
return ""
$$;
SELECT get_env('HOME');
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.