1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Chapter37.PL/Tcl - Tcl Procedural Language</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="server-programming.html" title="PartV.Server Programming">
<link rel="prev" href="plpgsql-porting.html" title="36.11.Porting from Oracle PL/SQL">
<link rel="next" href="pltcl-functions.html" title="37.2.PL/Tcl Functions and Arguments">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="chapter" lang="en" id="pltcl">
<div class="titlepage"><div><div><h2 class="title">
<a name="pltcl"></a>Chapter37.PL/Tcl - Tcl Procedural Language</h2></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="sect1"><a href="pltcl.html#pltcl-overview">37.1. Overview</a></span></dt>
<dt><span class="sect1"><a href="pltcl-functions.html">37.2. PL/Tcl Functions and Arguments</a></span></dt>
<dt><span class="sect1"><a href="pltcl-data.html">37.3. Data Values in PL/Tcl</a></span></dt>
<dt><span class="sect1"><a href="pltcl-global.html">37.4. Global Data in PL/Tcl</a></span></dt>
<dt><span class="sect1"><a href="pltcl-dbaccess.html">37.5. Database Access from PL/Tcl</a></span></dt>
<dt><span class="sect1"><a href="pltcl-trigger.html">37.6. Trigger Procedures in PL/Tcl</a></span></dt>
<dt><span class="sect1"><a href="pltcl-unknown.html">37.7. Modules and the <code class="function">unknown</code> command</a></span></dt>
<dt><span class="sect1"><a href="pltcl-procnames.html">37.8. Tcl Procedure Names</a></span></dt>
</dl>
</div>
<a name="id729248"></a><a name="id729258"></a><p> PL/Tcl is a loadable procedural language for the
<span class="productname">PostgreSQL</span> database system
that enables the <a href="http://www.tcl.tk/" target="_top"> Tcl language</a> to be used to write functions and
trigger procedures.
</p>
<div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="pltcl-overview"></a>37.1.Overview</h2></div></div></div>
<p> PL/Tcl offers most of the capabilities a function
writer has in the C language, except for some restrictions.
</p>
<p> The good restriction is that everything is executed in a safe
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 <code class="function">elog()</code>. There is no way to access internals of the
database server or to gain OS-level access under the permissions of the
<span class="productname">PostgreSQL</span> server process, as a C function can do.
Thus, any unprivileged database user may be
permitted to use this language.
</p>
<p> The other, implementation restriction is that Tcl functions cannot
be used to create input/output functions for new data types.
</p>
<p> Sometimes 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 <span class="application">PL/Tcl</span> called <code class="literal">PL/TclU</code>
(for untrusted Tcl). This is the exact same language except that a full
Tcl interpreter is used. <span class="emphasis"><em>If <span class="application">PL/TclU</span> is used, it must be
installed as an untrusted procedural language</em></span> so that only
database superusers can create functions in it. The writer of a <span class="application">PL/TclU</span>
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.
</p>
<p> The shared object for the <span class="application">PL/Tcl</span> and <span class="application">PL/TclU</span> call handlers is
automatically built and installed in the
<span class="productname">PostgreSQL</span>
library directory if Tcl support is specified
in the configuration step of the installation procedure. To install
<span class="application">PL/Tcl</span> and/or <span class="application">PL/TclU</span> in a particular database, use the
<code class="command">createlang</code> program, for example
<code class="literal">createlang pltcl <em class="replaceable"><code>dbname</code></em></code> or
<code class="literal">createlang pltclu <em class="replaceable"><code>dbname</code></em></code>.
</p>
</div>
</div></body>
</html>
|