pltclu

pltclu

pltcl : PL/TclU untrusted procedural language

Overview

ID Extension Package Version Category License Language
3250
pltclu
pltcl
1.0
LANG
PostgreSQL
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
----d--
No
No
No
Yes
no
no
Relationships
Schemas pg_catalog
See Also
plpgsql
plperlu
plpython3u
plv8
plluau
pljava
pg_tle
Siblings
pltcl

Packages

PG18 PG17 PG16 PG15 PG14
1.0
1.0
1.0
1.0
1.0

This is a built-in contrib extension ship with the PostgreSQL kernel

Install

Create this extension with:

CREATE EXTENSION pltclu;

Usage

pltclu: PL/Tcl untrusted procedural language

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');
Last updated on