~ubuntu-branches/ubuntu/oneiric/plr/oneiric

« back to all changes in this revision

Viewing changes to doc/plr-pgsql-support-funcs.html

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-07-23 10:21:03 UTC
  • mfrom: (3.1.2 edgy)
  • Revision ID: james.westby@ubuntu.com-20060723102103-bs3qic50imfbhxmt
Tags: 1:0.6.2-4
Build on mips and mipsel again, now that the PostgreSQL SIGBUS problem
turned out to be a kernel bug (which is fixed in 2.6.16).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<HTML
2
 
><HEAD
3
 
><TITLE
4
 
>PostgreSQL Support Functions</TITLE
5
 
><META
6
 
NAME="GENERATOR"
7
 
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
8
 
"><LINK
9
 
REV="MADE"
10
 
HREF="mailto:pgsql-docs@postgresql.org"><LINK
11
 
REL="HOME"
12
 
TITLE="PL/R User's Guide - R Procedural Language"
13
 
HREF="index.html"><LINK
14
 
REL="PREVIOUS"
15
 
TITLE="Database Access and Support Functions"
16
 
HREF="plr-spi-rsupport-funcs.html"><LINK
17
 
REL="NEXT"
18
 
TITLE="Aggregate Functions"
19
 
HREF="plr-aggregate-funcs.html"><LINK
20
 
REL="STYLESHEET"
21
 
TYPE="text/css"
22
 
HREF="stylesheet.css"><META
23
 
NAME="creation"
24
 
CONTENT="2003-08-25T17:44:28"></HEAD
25
 
><BODY
26
 
CLASS="CHAPTER"
27
 
BGCOLOR="#FFFFFF"
28
 
TEXT="#000000"
29
 
LINK="#0000FF"
30
 
VLINK="#840084"
31
 
ALINK="#0000FF"
32
 
><DIV
33
 
CLASS="NAVHEADER"
34
 
><TABLE
35
 
SUMMARY="Header navigation table"
36
 
WIDTH="100%"
37
 
BORDER="0"
38
 
CELLPADDING="0"
39
 
CELLSPACING="0"
40
 
><TR
41
 
><TH
42
 
COLSPAN="3"
43
 
ALIGN="center"
44
 
>PL/R User's Guide - R Procedural Language</TH
45
 
></TR
46
 
><TR
47
 
><TD
48
 
WIDTH="10%"
49
 
ALIGN="left"
50
 
VALIGN="bottom"
51
 
><A
52
 
HREF="plr-spi-rsupport-funcs.html"
53
 
ACCESSKEY="P"
54
 
>Prev</A
55
 
></TD
56
 
><TD
57
 
WIDTH="80%"
58
 
ALIGN="center"
59
 
VALIGN="bottom"
60
 
></TD
61
 
><TD
62
 
WIDTH="10%"
63
 
ALIGN="right"
64
 
VALIGN="bottom"
65
 
><A
66
 
HREF="plr-aggregate-funcs.html"
67
 
ACCESSKEY="N"
68
 
>Next</A
69
 
></TD
70
 
></TR
71
 
></TABLE
72
 
><HR
73
 
ALIGN="LEFT"
74
 
WIDTH="100%"></DIV
75
 
><DIV
76
 
CLASS="CHAPTER"
77
 
><H1
78
 
><A
79
 
NAME="PLR-PGSQL-SUPPORT-FUNCS"
80
 
></A
81
 
>Chapter 7. PostgreSQL Support Functions</H1
82
 
><P
83
 
>     The following commands are available to use in PostgreSQL queries
84
 
     to aid in the use of PL/R functions:
85
 
    </P
86
 
><P
87
 
></P
88
 
><DIV
89
 
CLASS="VARIABLELIST"
90
 
><DL
91
 
><DT
92
 
><TT
93
 
CLASS="FUNCTION"
94
 
>install_rcmd</TT
95
 
>
96
 
           (<TT
97
 
CLASS="TYPE"
98
 
>text</TT
99
 
> <TT
100
 
CLASS="REPLACEABLE"
101
 
><I
102
 
>R_code</I
103
 
></TT
104
 
>)</DT
105
 
><DD
106
 
><P
107
 
>        Install R code, given as a string, into the interpreter. See
108
 
        <A
109
 
HREF="plr-global-data.html"
110
 
>Chapter 5</A
111
 
> for an example.
112
 
       </P
113
 
></DD
114
 
><DT
115
 
><TT
116
 
CLASS="FUNCTION"
117
 
>reload_plr_modules</TT
118
 
>
119
 
           ()</DT
120
 
><DD
121
 
><P
122
 
>        Force re-loading of R code from the <TT
123
 
CLASS="LITERAL"
124
 
>plr_modules</TT
125
 
>
126
 
        table. It is useful after modifying the contents of
127
 
        <TT
128
 
CLASS="LITERAL"
129
 
>plr_modules</TT
130
 
>, so that the change will have an
131
 
        immediate effect.
132
 
       </P
133
 
></DD
134
 
><DT
135
 
><TT
136
 
CLASS="FUNCTION"
137
 
>plr_singleton_array</TT
138
 
>
139
 
           (<TT
140
 
CLASS="TYPE"
141
 
>float8</TT
142
 
> <TT
143
 
CLASS="REPLACEABLE"
144
 
><I
145
 
>first_element</I
146
 
></TT
147
 
>)</DT
148
 
><DD
149
 
><P
150
 
>        Creates a new PostgreSQL array, using element 
151
 
        <TT
152
 
CLASS="REPLACEABLE"
153
 
><I
154
 
>first_element</I
155
 
></TT
156
 
>. This function is predefined
157
 
        to accept one float8 value and return a float8 array. The C function
158
 
        that implements this PostgreSQL function is capable of accepting and
159
 
        returning other data types, although the return type must be an array
160
 
        of the input parameter type. It can also accept multiple input
161
 
        parameters. For example, to define a <TT
162
 
CLASS="FUNCTION"
163
 
>plr_array</TT
164
 
>
165
 
        function to create a text array from two input text values:
166
 
     </P><PRE
167
 
CLASS="PROGRAMLISTING"
168
 
>CREATE OR REPLACE FUNCTION plr_array (text, text)
169
 
RETURNS text[]
170
 
AS '$libdir/plr','plr_array'
171
 
LANGUAGE 'C' WITH (isstrict);
172
 
 
173
 
select plr_array('hello','world');
174
 
   plr_array
175
 
---------------
176
 
 {hello,world}
177
 
(1 row)
178
 
     </PRE
179
 
><P>
180
 
       </P
181
 
></DD
182
 
><DT
183
 
><TT
184
 
CLASS="FUNCTION"
185
 
>plr_array_push</TT
186
 
>
187
 
           (<TT
188
 
CLASS="TYPE"
189
 
>float8[]</TT
190
 
> <TT
191
 
CLASS="REPLACEABLE"
192
 
><I
193
 
>array</I
194
 
></TT
195
 
>,
196
 
            <TT
197
 
CLASS="TYPE"
198
 
>float8</TT
199
 
> <TT
200
 
CLASS="REPLACEABLE"
201
 
><I
202
 
>next_element</I
203
 
></TT
204
 
>)</DT
205
 
><DD
206
 
><P
207
 
>        Pushes a new element onto the end of an existing PostgreSQL array.
208
 
        This function is predefined to accept one float8 array and a float8
209
 
        value, and return a float8 array. The C function that implements this
210
 
        PostgreSQL function is capable of accepting and returning other data
211
 
        types. For example, to define a <TT
212
 
CLASS="FUNCTION"
213
 
>plr_array_push</TT
214
 
>
215
 
        function to add a text value to an existing text array:
216
 
     </P><PRE
217
 
CLASS="PROGRAMLISTING"
218
 
>CREATE OR REPLACE FUNCTION plr_array_push (_text, text)
219
 
RETURNS text[]
220
 
AS '$libdir/plr','plr_array_push'
221
 
LANGUAGE 'C' WITH (isstrict);
222
 
 
223
 
select plr_array_push(plr_array('hello','world'), 'how are you');
224
 
       plr_array_push
225
 
-----------------------------
226
 
 {hello,world,"how are you"}
227
 
(1 row)
228
 
     </PRE
229
 
><P>
230
 
       </P
231
 
></DD
232
 
><DT
233
 
><TT
234
 
CLASS="FUNCTION"
235
 
>plr_array_accum</TT
236
 
>
237
 
           (<TT
238
 
CLASS="TYPE"
239
 
>float8[]</TT
240
 
> <TT
241
 
CLASS="REPLACEABLE"
242
 
><I
243
 
>state_value</I
244
 
></TT
245
 
>,
246
 
            <TT
247
 
CLASS="TYPE"
248
 
>float8</TT
249
 
> <TT
250
 
CLASS="REPLACEABLE"
251
 
><I
252
 
>next_element</I
253
 
></TT
254
 
>)</DT
255
 
><DD
256
 
><P
257
 
>        Creates a new array using <TT
258
 
CLASS="REPLACEABLE"
259
 
><I
260
 
>next_element</I
261
 
></TT
262
 
> if
263
 
        <TT
264
 
CLASS="REPLACEABLE"
265
 
><I
266
 
>state_value</I
267
 
></TT
268
 
> is NULL. Otherwise, pushes
269
 
        <TT
270
 
CLASS="REPLACEABLE"
271
 
><I
272
 
>next_element</I
273
 
></TT
274
 
> onto the end of
275
 
        <TT
276
 
CLASS="REPLACEABLE"
277
 
><I
278
 
>state_value</I
279
 
></TT
280
 
>. This function is predefined
281
 
        to accept one float8 array and a float8 value, and return a float8
282
 
        array. The C function that implements this PostgreSQL function is
283
 
        capable of accepting and returning other data types. For example,
284
 
        to define a <TT
285
 
CLASS="FUNCTION"
286
 
>plr_array_accum</TT
287
 
> function to add an
288
 
        int4 value to an existing int4 array:
289
 
        </P><PRE
290
 
CLASS="PROGRAMLISTING"
291
 
>CREATE OR REPLACE FUNCTION plr_array_accum (_int4, int4)
292
 
RETURNS int4[]
293
 
AS '$libdir/plr','plr_array_accum'
294
 
LANGUAGE 'C';
295
 
 
296
 
select plr_array_accum(NULL, 42);
297
 
 plr_array_accum
298
 
-------------
299
 
 {42}
300
 
(1 row)
301
 
select plr_array_accum('{23,35}', 42);
302
 
 plr_array_accum
303
 
-----------------
304
 
 {23,35,42}
305
 
(1 row)
306
 
        </PRE
307
 
><P>
308
 
        This function may be useful for creating custom aggregates. See
309
 
        <A
310
 
HREF="plr-aggregate-funcs.html"
311
 
>Chapter 8</A
312
 
> for an example.
313
 
       </P
314
 
></DD
315
 
><DT
316
 
><TT
317
 
CLASS="FUNCTION"
318
 
>load_r_typenames</TT
319
 
>()</DT
320
 
><DD
321
 
><P
322
 
>        Installs datatype Oid variables into the R interpreter
323
 
        as globals. See also <TT
324
 
CLASS="FUNCTION"
325
 
>r_typenames</TT
326
 
> below.
327
 
       </P
328
 
></DD
329
 
><DT
330
 
><TT
331
 
CLASS="FUNCTION"
332
 
>r_typenames</TT
333
 
>()</DT
334
 
><DD
335
 
><P
336
 
>        Displays the datatype Oid variables installed into the R interpreter
337
 
        as globals. See <A
338
 
HREF="plr-spi-rsupport-funcs.html"
339
 
>Chapter 6</A
340
 
> for an example.
341
 
       </P
342
 
></DD
343
 
><DT
344
 
><TT
345
 
CLASS="FUNCTION"
346
 
>plr_environ</TT
347
 
>()</DT
348
 
><DD
349
 
><P
350
 
>        Displays the environment under which the Postmaster is currently
351
 
        running. This may be useful to debug issues related to R specific
352
 
        environment variables. This function is installed with EXECUTE
353
 
        permission revoked from PUBLIC.
354
 
       </P
355
 
></DD
356
 
></DL
357
 
></DIV
358
 
></DIV
359
 
><DIV
360
 
CLASS="NAVFOOTER"
361
 
><HR
362
 
ALIGN="LEFT"
363
 
WIDTH="100%"><TABLE
364
 
SUMMARY="Footer navigation table"
365
 
WIDTH="100%"
366
 
BORDER="0"
367
 
CELLPADDING="0"
368
 
CELLSPACING="0"
369
 
><TR
370
 
><TD
371
 
WIDTH="33%"
372
 
ALIGN="left"
373
 
VALIGN="top"
374
 
><A
375
 
HREF="plr-spi-rsupport-funcs.html"
376
 
ACCESSKEY="P"
377
 
>Prev</A
378
 
></TD
379
 
><TD
380
 
WIDTH="34%"
381
 
ALIGN="center"
382
 
VALIGN="top"
383
 
><A
384
 
HREF="index.html"
385
 
ACCESSKEY="H"
386
 
>Home</A
387
 
></TD
388
 
><TD
389
 
WIDTH="33%"
390
 
ALIGN="right"
391
 
VALIGN="top"
392
 
><A
393
 
HREF="plr-aggregate-funcs.html"
394
 
ACCESSKEY="N"
395
 
>Next</A
396
 
></TD
397
 
></TR
398
 
><TR
399
 
><TD
400
 
WIDTH="33%"
401
 
ALIGN="left"
402
 
VALIGN="top"
403
 
>Database Access and Support Functions</TD
404
 
><TD
405
 
WIDTH="34%"
406
 
ALIGN="center"
407
 
VALIGN="top"
408
 
>&nbsp;</TD
409
 
><TD
410
 
WIDTH="33%"
411
 
ALIGN="right"
412
 
VALIGN="top"
413
 
>Aggregate Functions</TD
414
 
></TR
415
 
></TABLE
416
 
></DIV
417
 
></BODY
418
 
></HTML
419
 
>
 
 
b'\\ No newline at end of file'