Debian Codegraph @

doc/html/libpgtcl.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3 <html>
4 <head>
5 <meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.6.0">
6 <title>pgtcl - Tcl Binding Library</title>
7 <meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.79">
8 <link rev="MADE" href="mailto:[email protected]">
9 <link rel="HOME" title="PostgreSQL Tcl Interface Documentation" href="index.html">
10 <link rel="PREVIOUS" title="PostgreSQL Tcl Interface Documentation" href="index.html">
11 <link rel="NEXT" title="Loading pgtcl into an Application" href="libpgtcl-loading.html">
12 <link rel="STYLESHEET" type="text/css" href="stylesheet.css">
13 </head>
14 <body class="CHAPTER">
15 <div class="NAVHEADER">
16 <table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
17 <tr>
18 <th colspan="5" align="center" valign="bottom">PostgreSQL Tcl Interface Documentation</th>
19 </tr>
20 <tr>
21 <td width="10%" align="left" valign="top"><a href="index.html" accesskey="P">Prev</a></td>
22 <td width="10%" align="left" valign="top"><a href="index.html#AEN3">Fast Backward</a></td>
23 <td width="60%" align="center" valign="bottom"></td>
24 <td width="10%" align="right" valign="top">&nbsp;</td>
25 <td width="10%" align="right" valign="top"><a href="libpgtcl-loading.html" accesskey="N">Next</a></td>
26 </tr>
27 </table>
28 <hr align="left" width="100%"></div>
29 <div class="CHAPTER">
30 <h1><a name="LIBPGTCL" id="LIBPGTCL"></a>Chapter 1. <span class="APPLICATION">pgtcl</span> - Tcl Binding Library</h1>
31 <div class="TOC">
32 <dl>
33 <dt><b>Table of Contents</b></dt>
34 <dt>1.1. <a href="libpgtcl.html#PGTCL-OVERVIEW">Overview</a></dt>
35 <dt>1.2. <a href="libpgtcl-loading.html">Loading <span class="APPLICATION">pgtcl</span> into an Application</a></dt>
36 <dt>1.3. <a href="libpgtcl-ref.html"><span class="APPLICATION">pgtcl</span> Command Reference</a></dt>
37 <dd>
38 <dl>
39 <dt><a href="pgtcl-pgconnect.html">pg_connect</a>&nbsp;--&nbsp;open a connection to the server</dt>
40 <dt><a href="pgtcl-pgconninfo.html">pg_dbinfo</a>&nbsp;--&nbsp;returns data about the connection</dt>
41 <dt><a href="pgtcl-pgdisconnect.html">pg_disconnect</a>&nbsp;--&nbsp;close a connection to the server</dt>
42 <dt><a href="pgtcl-pgconndefaults.html">pg_conndefaults</a>&nbsp;--&nbsp;get connection options and their defaults</dt>
43 <dt><a href="pgtcl-pgexec.html">pg_exec</a>&nbsp;--&nbsp;send a command to the server</dt>
44 <dt><a href="pgtcl-pgexecprepared.html">pg_exec_prepared</a>&nbsp;--&nbsp;send a request to execute a prepared SQL statement to the server</dt>
45 <dt><a href="pgtcl-pgresult.html">pg_result</a>&nbsp;--&nbsp;get information about a command result</dt>
46 <dt><a href="pgtcl-pgselect.html">pg_select</a>&nbsp;--&nbsp;loop over the result of a query</dt>
47 <dt><a href="pgtcl-pgexecute.html">pg_execute</a>&nbsp;--&nbsp;send a query and optionally loop over the results</dt>
48 <dt><a href="pgtcl-pglisten.html">pg_listen</a>&nbsp;--&nbsp;set or change a callback for asynchronous notification messages</dt>
49 <dt><a href="pgtcl-pgon-connection-loss.html">pg_on_connection_loss</a>&nbsp;--&nbsp;set or change a callback for unexpected connection loss</dt>
50 <dt><a href="pgtcl-pgsendquery.html">pg_sendquery</a>&nbsp;--&nbsp;send a query string to the backend connection without waiting for a result</dt>
51 <dt><a href="pgtcl-pgsendqueryprepared.html">pg_sendquery_prepared</a>&nbsp;--&nbsp;send a request to execute a prepared statement to the backend connection, without waiting for a result</dt>
52 <dt><a href="pgtcl-pggetresult.html">pg_getresult</a>&nbsp;--&nbsp;process asychronous results</dt>
53 <dt><a href="pgtcl-pgisbusy.html">pg_isbusy</a>&nbsp;--&nbsp;see if a query is busy</dt>
54 <dt><a href="pgtcl-pgblocking.html">pg_blocking</a>&nbsp;--&nbsp;see or set whether or not a connection is set to blocking or nonblocking</dt>
55 <dt><a href="pgtcl-pgcancelrequest.html">pg_cancelrequest</a>&nbsp;--&nbsp;request that <span class="PRODUCTNAME">PostgreSQL</span> abandon processing of the current command</dt>
56 <dt><a href="pgtcl-nullvaluestring.html">pg_null_value_string</a>&nbsp;--&nbsp;define a value to be returned for NULL fields distinct from the default value of an empty string.</dt>
57 <dt><a href="pgtcl-quote.html">pg_quote</a>&nbsp;--&nbsp;escapes a string for inclusion into SQL statements</dt>
58 <dt><a href="pgtcl-pgescape-string.html">pg_escape_string</a>&nbsp;--&nbsp;escapes a string for inclusion into SQL statements. This is the same as pg_quote. It was added for consistency.</dt>
59 <dt><a href="pgtcl-pgescape-bytea.html">pg_escape_bytea</a>&nbsp;--&nbsp;escapes a binary string for inclusion into SQL statements.</dt>
60 <dt><a href="pgtcl-pgunescape-bytea.html">pg_unescape_bytea</a>&nbsp;--&nbsp;unescapes a binary string.</dt>
61 <dt><a href="pgtcl-pglocreat.html">pg_lo_creat</a>&nbsp;--&nbsp;create a large object</dt>
62 <dt><a href="pgtcl-pgloopen.html">pg_lo_open</a>&nbsp;--&nbsp;open a large object</dt>
63 <dt><a href="pgtcl-pgloclose.html">pg_lo_close</a>&nbsp;--&nbsp;close a large object</dt>
64 <dt><a href="pgtcl-pgloread.html">pg_lo_read</a>&nbsp;--&nbsp;read from a large object</dt>
65 <dt><a href="pgtcl-pglowrite.html">pg_lo_write</a>&nbsp;--&nbsp;write to a large object</dt>
66 <dt><a href="pgtcl-pglolseek.html">pg_lo_lseek</a>&nbsp;--&nbsp;seek to a position of a large object</dt>
67 <dt><a href="pgtcl-pglotell.html">pg_lo_tell</a>&nbsp;--&nbsp;return the current seek position of a large object</dt>
68 <dt><a href="pgtcl-pgtruncate.html">pg_lo_truncate</a>&nbsp;--&nbsp;Truncate a large object to a given length</dt>
69 <dt><a href="pgtcl-pglounlink.html">pg_lo_unlink</a>&nbsp;--&nbsp;delete a large object</dt>
70 <dt><a href="pgtcl-pgloimport.html">pg_lo_import</a>&nbsp;--&nbsp;import a large object from a file</dt>
71 <dt><a href="pgtcl-pgloexport.html">pg_lo_export</a>&nbsp;--&nbsp;export a large object to a file</dt>
72 <dt><a href="pgtcl-pgsqlite.html">pg_sqlite</a>&nbsp;--&nbsp;implements a bridge between PostgreSQL and Sqlite3 using the Pgtcl and sqlite3 packages.</dt>
73 <dt><a href="pgtcl-pgcopycomplete.html">pg_copy_complete</a>&nbsp;--&nbsp;Completes a <tt class="COMMAND">COPY FROM stdin</tt> operation</dt>
74 <dt><a href="pgtcl-pggetconnectionid.html">PgGetConnectionId</a>&nbsp;--&nbsp;Provides access to the underlying <tt class="LITERAL">libpq</tt> SQL connection handle.</dt>
75 </dl>
76 </dd>
77 <dt>1.4. <a href="pgtcl-tclnamespace.html">Tcl Namespace Support</a></dt>
78 <dt>1.5. <a href="pgtcl-commandhandles.html">Connection/result handles as commands</a></dt>
79 <dt>1.6. <a href="pgtcl-examplesect.html">Example Program</a></dt>
80 </dl>
81 </div>
82 <a name="AEN9" id="AEN9"></a><a name="AEN11" id="AEN11"></a><a name="AEN13" id="AEN13"></a>
83 <p><span class="APPLICATION">pgtcl</span> is a Tcl package for client programs to interface with <span class="PRODUCTNAME">PostgreSQL</span> servers. It makes most of the functionality of <span class="APPLICATION">libpq</span> available to Tcl scripts.</p>
84 <div class="SECT1">
85 <h1 class="SECT1"><a name="PGTCL-OVERVIEW" id="PGTCL-OVERVIEW">1.1. Overview</a></h1>
86 <p><a href="libpgtcl.html#PGTCL-COMMANDS-TABLE">Table 1-1</a>&gt; gives an overview over the commands available in <span class="APPLICATION">pgtcl</span>. These commands are described further on subsequent pages.</p>
87 <div class="TABLE"><a name="PGTCL-COMMANDS-TABLE" id="PGTCL-COMMANDS-TABLE"></a>
88 <p><b>Table 1-1. <span class="APPLICATION">pgtcl</span> Commands</b></p>
89 <table border="1" class="CALSTABLE">
90 <col>
91 <col>
92 <col>
93 <thead>
94 <tr>
95 <th>Command</th>
96 <th>Namespace Command</th>
97 <th>Description</th>
98 </tr>
99 </thead>
100 <tbody>
101 <tr>
102 <td><code class="FUNCTION">pg_connect</code></td>
103 <td><code class="FUNCTION">pg::connect</code></td>
104 <td>open a connection to the server</td>
105 </tr>
106 <tr>
107 <td><code class="FUNCTION">pg_dbinfo</code></td>
108 <td><code class="FUNCTION">pg::dbinfo</code></td>
109 <td>returns data about the connection</td>
110 </tr>
111 <tr>
112 <td><code class="FUNCTION">pg_disconnect</code></td>
113 <td><code class="FUNCTION">pg::disconnect</code></td>
114 <td>close a connection to the server</td>
115 </tr>
116 <tr>
117 <td><code class="FUNCTION">pg_conndefaults</code></td>
118 <td><code class="FUNCTION">pg::conndefaults</code></td>
119 <td>get connection options and their defaults</td>
120 </tr>
121 <tr>
122 <td><code class="FUNCTION">pg_exec</code></td>
123 <td><code class="FUNCTION">pg::sqlexec</code></td>
124 <td>send a command to the server</td>
125 </tr>
126 <tr>
127 <td><code class="FUNCTION">pg_exec_prepared</code></td>
128 <td><code class="FUNCTION">pg::exec_prepared</code></td>
129 <td>send a request to execute a prepared statement, with parameters</td>
130 </tr>
131 <tr>
132 <td><code class="FUNCTION">pg_result</code></td>
133 <td><code class="FUNCTION">pg::result</code></td>
134 <td>get information about a command result</td>
135 </tr>
136 <tr>
137 <td><code class="FUNCTION">pg_select</code></td>
138 <td><code class="FUNCTION">pg::select</code></td>
139 <td>loop over the result of a query</td>
140 </tr>
141 <tr>
142 <td><code class="FUNCTION">pg_execute</code></td>
143 <td><code class="FUNCTION">pg::execute</code></td>
144 <td>send a query and optionally loop over the results</td>
145 </tr>
146 <tr>
147 <td><code class="FUNCTION">pg_null_value_string</code></td>
148 <td><code class="FUNCTION">pg::null_value_string</code></td>
149 <td>set string to be returned for null values in query results</td>
150 </tr>
151 <tr>
152 <td><code class="FUNCTION">pg_quote</code></td>
153 <td><code class="FUNCTION">pg::quote</code></td>
154 <td>escape a string for inclusion into SQL statements</td>
155 </tr>
156 <tr>
157 <td><code class="FUNCTION">pg_escape_string</code></td>
158 <td><code class="FUNCTION">pg::escape_string</code></td>
159 <td>escape a binary string for inclusion into SQL statements</td>
160 </tr>
161 <tr>
162 <td><code class="FUNCTION">pg_escape_bytea</code></td>
163 <td><code class="FUNCTION">pg::escape_bytea</code></td>
164 <td>escape a binary string for inclusion into SQL statements</td>
165 </tr>
166 <tr>
167 <td><code class="FUNCTION">pg_unescape_bytea</code></td>
168 <td><code class="FUNCTION">pg::unescape_bytea</code></td>
169 <td>unescape a binary string from the backend</td>
170 </tr>
171 <tr>
172 <td><code class="FUNCTION">pg_listen</code></td>
173 <td><code class="FUNCTION">pg::listen</code></td>
174 <td>set or change a callback for asynchronous notification messages</td>
175 </tr>
176 <tr>
177 <td><code class="FUNCTION">pg_on_connection_loss</code></td>
178 <td><code class="FUNCTION">pg::on_connection_loss</code></td>
179 <td>set or change a callback for unexpected connection loss</td>
180 </tr>
181 <tr>
182 <td><code class="FUNCTION">pg_sendquery</code></td>
183 <td><code class="FUNCTION">pg::sendquery</code></td>
184 <td>issue pg_exec-style command asynchronously</td>
185 </tr>
186 <tr>
187 <td><code class="FUNCTION">pg_sendquery_prepared</code></td>
188 <td><code class="FUNCTION">pg::sendquery_prepared</code></td>
189 <td>send an asynchronous request to execute a prepared statement, with parameters</td>
190 </tr>
191 <tr>
192 <td><code class="FUNCTION">pg_getresult</code></td>
193 <td><code class="FUNCTION">pg::getresult</code></td>
194 <td>check on results from asynchronously issued commands</td>
195 </tr>
196 <tr>
197 <td><code class="FUNCTION">pg_isbusy</code></td>
198 <td><code class="FUNCTION">pg::isbusy</code></td>
199 <td>check to see if the connection is busy processing a query</td>
200 </tr>
201 <tr>
202 <td><code class="FUNCTION">pg_blocking</code></td>
203 <td><code class="FUNCTION">pg::blocking</code></td>
204 <td>set a database connection to be either blocking or nonblocking</td>
205 </tr>
206 <tr>
207 <td><code class="FUNCTION">pg_cancelrequest</code></td>
208 <td><code class="FUNCTION">pg::cancelrequest</code></td>
209 <td>request <span class="PRODUCTNAME">PostgreSQL</span> abandon processing of the current command</td>
210 </tr>
211 <tr>
212 <td><code class="FUNCTION">pg_lo_creat</code></td>
213 <td><code class="FUNCTION">pg::lo_creat</code></td>
214 <td>create a large object</td>
215 </tr>
216 <tr>
217 <td><code class="FUNCTION">pg_lo_open</code></td>
218 <td><code class="FUNCTION">pg::lo_open</code></td>
219 <td>open a large object</td>
220 </tr>
221 <tr>
222 <td><code class="FUNCTION">pg_lo_close</code></td>
223 <td><code class="FUNCTION">pg::lo_close</code></td>
224 <td>close a large object</td>
225 </tr>
226 <tr>
227 <td><code class="FUNCTION">pg_lo_read</code></td>
228 <td><code class="FUNCTION">pg::lo_read</code></td>
229 <td>read from a large object</td>
230 </tr>
231 <tr>
232 <td><code class="FUNCTION">pg_lo_write</code></td>
233 <td><code class="FUNCTION">pg::lo_write</code></td>
234 <td>write to a large object</td>
235 </tr>
236 <tr>
237 <td><code class="FUNCTION">pg_lo_lseek</code></td>
238 <td><code class="FUNCTION">pg::lo_lseek</code></td>
239 <td>seek to a position in a large object</td>
240 </tr>
241 <tr>
242 <td><code class="FUNCTION">pg_lo_tell</code></td>
243 <td><code class="FUNCTION">pg::lo_tell</code></td>
244 <td>return the current seek position of a large object</td>
245 </tr>
246 <tr>
247 <td><code class="FUNCTION">pg_lo_truncate</code></td>
248 <td><code class="FUNCTION">pg::lo_truncate</code></td>
249 <td>Truncate (or pad) a large object to a specified length</td>
250 </tr>
251 <tr>
252 <td><code class="FUNCTION">pg_lo_unlink</code></td>
253 <td><code class="FUNCTION">pg::lo_unlink</code></td>
254 <td>delete a large object</td>
255 </tr>
256 <tr>
257 <td><code class="FUNCTION">pg_lo_import</code></td>
258 <td><code class="FUNCTION">pg::lo_import</code></td>
259 <td>import a large object from a file</td>
260 </tr>
261 <tr>
262 <td><code class="FUNCTION">pg_lo_export</code></td>
263 <td><code class="FUNCTION">pg::lo_export</code></td>
264 <td>export a large object to a file</td>
265 </tr>
266 <tr>
267 <td><code class="FUNCTION">pg_sqlite</code></td>
268 <td><code class="FUNCTION">pg::sqlite</code></td>
269 <td>bridge between pgtcl and the Tcl sqlite package (when compiled with sqlite bridge)</td>
270 </tr>
271 <tr>
272 <td><code class="FUNCTION">pg_copy_complete</code></td>
273 <td><code class="FUNCTION">pg::copy_complete</code></td>
274 <td>Complete <tt class="COMMAND">COPY FROM stdin</tt> operation after finished writing</td>
275 </tr>
276 </tbody>
277 </table>
278 </div>
279 <p>The <code class="FUNCTION">pg_lo_*</code> commands are interfaces to the large object features of <span class="PRODUCTNAME">PostgreSQL</span>.<a name="AEN249" id="AEN249"></a> The functions are designed to mimic the analogous file system functions in the standard Unix file system interface. The <code class="FUNCTION">pg_lo_*</code> commands should be used within a <tt class="COMMAND">BEGIN</tt>/<tt class="COMMAND">COMMIT</tt> transaction block because the descriptor returned by <code class="FUNCTION">pg_lo_open</code> is only valid for the current transaction. <code class="FUNCTION">pg_lo_import</code> and <code class="FUNCTION">pg_lo_export</code> <span class="emphasis"><i class="EMPHASIS">must</i></span> be used in a <tt class="COMMAND">BEGIN</tt>/<tt class="COMMAND">COMMIT</tt> transaction block.</p>
280 <p>The <code class="FUNCTION">pg_sqlite</code> command is only included if <span class="PRODUCTNAME">Sqlite 3</span> is installed. It can be disabled at compile time with <tt class="LITERAL">"./configure --without-sqlite3"</tt>.</p>
281 <div class="TABLE"><a name="PGTCL-C-API-TABLE" id="PGTCL-C-API-TABLE"></a>
282 <p><b>Table 1-2. <span class="APPLICATION">pgtcl</span> C API</b></p>
283 <table border="1" class="CALSTABLE">
284 <col>
285 <col>
286 <thead>
287 <tr>
288 <th>Function</th>
289 <th>Description</th>
290 </tr>
291 </thead>
292 <tbody>
293 <tr>
294 <td><code class="FUNCTION">PGconn *PgGetConnectionId(interp, id, connid)</code></td>
295 <td>Given a Tcl handle to an open Pgtcl connection, return the underlying libpq connection</td>
296 </tr>
297 </tbody>
298 </table>
299 </div>
300 </div>
301 </div>
302 <div class="NAVFOOTER">
303 <hr align="left" width="100%">
304 <table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
305 <tr>
306 <td width="33%" align="left" valign="top"><a href="index.html" accesskey="P">Prev</a></td>
307 <td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">Home</a></td>
308 <td width="33%" align="right" valign="top"><a href="libpgtcl-loading.html" accesskey="N">Next</a></td>
309 </tr>
310 <tr>
311 <td width="33%" align="left" valign="top">PostgreSQL Tcl Interface Documentation</td>
312 <td width="34%" align="center" valign="top">&nbsp;</td>
313 <td width="33%" align="right" valign="top">Loading <span class="APPLICATION">pgtcl</span> into an Application</td>
314 </tr>
315 </table>
316 </div>
317 </body>
318 </html>