File: lo-funcs.html

package info (click to toggle)
pgadmin3 1.4.3-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 29,796 kB
  • ctags: 10,758
  • sloc: cpp: 55,356; sh: 6,164; ansic: 1,520; makefile: 576; sql: 482; xml: 100; perl: 18
file content (59 lines) | stat: -rw-r--r-- 2,826 bytes parent folder | download
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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>29.4.Server-Side Functions</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="largeobjects.html" title="Chapter29.Large Objects">
<link rel="prev" href="lo-interfaces.html" title="29.3.Client Interfaces">
<link rel="next" href="lo-examplesect.html" title="29.5.Example Program">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="lo-funcs"></a>29.4.Server-Side Functions</h2></div></div></div>
<p>   There are server-side functions callable from SQL that correspond to
   each of the client-side functions described above; indeed, for the
   most part the client-side functions are simply interfaces to the
   equivalent server-side functions.  The ones that are actually useful
   to call via SQL commands are
   <code class="function">lo_creat</code><a name="id688857"></a>,
   <code class="function">lo_create</code><a name="id688870"></a>,
   <code class="function">lo_unlink</code><a name="id688883"></a>,
   <code class="function">lo_import</code><a name="id688896"></a>, and
   <code class="function">lo_export</code><a name="id688910"></a>.
   Here are examples of their use:

</p>
<pre class="programlisting">CREATE TABLE image (
    name            text,
    raster          oid
);

SELECT lo_creat(-1);       -- returns OID of new, empty large object

SELECT lo_create(43213);   -- attempts to create large object with OID 43213

SELECT lo_unlink(173454);  -- deletes large object with OID 173454

INSERT INTO image (name, raster)
    VALUES ('beautiful image', lo_import('/etc/motd'));

SELECT lo_export(image.raster, '/tmp/motd') FROM image
    WHERE name = 'beautiful image';</pre>
<p>
  </p>
<p>    The server-side <code class="function">lo_import</code> and
    <code class="function">lo_export</code> functions behave considerably differently
    from their client-side analogs.  These two functions read and write files
    in the server's file system, using the permissions of the database's
    owning user.  Therefore, their use is restricted to superusers.  In
    contrast, the client-side import and export functions read and write files
    in the client's file system, using the permissions of the client program.
    The client-side functions can be used by any
    <span class="productname">PostgreSQL</span> user.
  </p>
</div></body>
</html>