]> granicus.if.org Git - postgresql/blob - src/backend/utils/adt/pseudotypes.c
Modify array operations to include array's element type OID in the
[postgresql] / src / backend / utils / adt / pseudotypes.c
1 /*-------------------------------------------------------------------------
2  *
3  * pseudotypes.c
4  *        Functions for the system pseudo-types.
5  *
6  * A pseudo-type isn't really a type and never has any operations, but
7  * we do need to supply input and output functions to satisfy the links
8  * in the pseudo-type's entry in pg_type.  In most cases the functions
9  * just throw an error if invoked.  (XXX the error messages here cover
10  * the most common case, but might be confusing in some contexts.  Can
11  * we do better?)
12  *
13  *
14  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
15  * Portions Copyright (c) 1994, Regents of the University of California
16  *
17  *
18  * IDENTIFICATION
19  *        $Header: /cvsroot/pgsql/src/backend/utils/adt/pseudotypes.c,v 1.3 2002/08/26 17:53:58 tgl Exp $
20  *
21  *-------------------------------------------------------------------------
22  */
23 #include "postgres.h"
24
25 #include "utils/array.h"
26 #include "utils/builtins.h"
27
28
29 /*
30  * record_in            - input routine for pseudo-type RECORD.
31  */
32 Datum
33 record_in(PG_FUNCTION_ARGS)
34 {
35         elog(ERROR, "Cannot accept a constant of type %s", "RECORD");
36
37         PG_RETURN_VOID();                       /* keep compiler quiet */
38 }
39
40 /*
41  * record_out           - output routine for pseudo-type RECORD.
42  */
43 Datum
44 record_out(PG_FUNCTION_ARGS)
45 {
46         elog(ERROR, "Cannot display a value of type %s", "RECORD");
47
48         PG_RETURN_VOID();                       /* keep compiler quiet */
49 }
50
51
52 /*
53  * cstring_in           - input routine for pseudo-type CSTRING.
54  *
55  * We might as well allow this to support constructs like "foo_in('blah')".
56  */
57 Datum
58 cstring_in(PG_FUNCTION_ARGS)
59 {
60         char       *str = PG_GETARG_CSTRING(0);
61
62         PG_RETURN_CSTRING(pstrdup(str));
63 }
64
65 /*
66  * cstring_out          - output routine for pseudo-type CSTRING.
67  *
68  * We allow this mainly so that "SELECT some_output_function(...)" does
69  * what the user will expect.
70  */
71 Datum
72 cstring_out(PG_FUNCTION_ARGS)
73 {
74         char       *str = PG_GETARG_CSTRING(0);
75
76         PG_RETURN_CSTRING(pstrdup(str));
77 }
78
79
80 /*
81  * any_in               - input routine for pseudo-type ANY.
82  */
83 Datum
84 any_in(PG_FUNCTION_ARGS)
85 {
86         elog(ERROR, "Cannot accept a constant of type %s", "ANY");
87
88         PG_RETURN_VOID();                       /* keep compiler quiet */
89 }
90
91 /*
92  * any_out              - output routine for pseudo-type ANY.
93  */
94 Datum
95 any_out(PG_FUNCTION_ARGS)
96 {
97         elog(ERROR, "Cannot display a value of type %s", "ANY");
98
99         PG_RETURN_VOID();                       /* keep compiler quiet */
100 }
101
102
103 /*
104  * anyarray_in          - input routine for pseudo-type ANYARRAY.
105  */
106 Datum
107 anyarray_in(PG_FUNCTION_ARGS)
108 {
109         elog(ERROR, "Cannot accept a constant of type %s", "ANYARRAY");
110
111         PG_RETURN_VOID();                       /* keep compiler quiet */
112 }
113
114 /*
115  * anyarray_out         - output routine for pseudo-type ANYARRAY.
116  *
117  * We may as well allow this, since array_out will in fact work.
118  */
119 Datum
120 anyarray_out(PG_FUNCTION_ARGS)
121 {
122         return array_out(fcinfo);
123 }
124
125
126 /*
127  * void_in              - input routine for pseudo-type VOID.
128  *
129  * We allow this so that PL functions can return VOID without any special
130  * hack in the PL handler.  Whatever value the PL thinks it's returning
131  * will just be ignored.
132  */
133 Datum
134 void_in(PG_FUNCTION_ARGS)
135 {
136         PG_RETURN_VOID();                       /* you were expecting something different? */
137 }
138
139 /*
140  * void_out             - output routine for pseudo-type VOID.
141  *
142  * We allow this so that "SELECT function_returning_void(...)" works.
143  */
144 Datum
145 void_out(PG_FUNCTION_ARGS)
146 {
147         PG_RETURN_CSTRING(pstrdup(""));
148 }
149
150
151 /*
152  * trigger_in           - input routine for pseudo-type TRIGGER.
153  */
154 Datum
155 trigger_in(PG_FUNCTION_ARGS)
156 {
157         elog(ERROR, "Cannot accept a constant of type %s", "TRIGGER");
158
159         PG_RETURN_VOID();                       /* keep compiler quiet */
160 }
161
162 /*
163  * trigger_out          - output routine for pseudo-type TRIGGER.
164  */
165 Datum
166 trigger_out(PG_FUNCTION_ARGS)
167 {
168         elog(ERROR, "Cannot display a value of type %s", "TRIGGER");
169
170         PG_RETURN_VOID();                       /* keep compiler quiet */
171 }
172
173
174 /*
175  * language_handler_in          - input routine for pseudo-type LANGUAGE_HANDLER.
176  */
177 Datum
178 language_handler_in(PG_FUNCTION_ARGS)
179 {
180         elog(ERROR, "Cannot accept a constant of type %s", "LANGUAGE_HANDLER");
181
182         PG_RETURN_VOID();                       /* keep compiler quiet */
183 }
184
185 /*
186  * language_handler_out         - output routine for pseudo-type LANGUAGE_HANDLER.
187  */
188 Datum
189 language_handler_out(PG_FUNCTION_ARGS)
190 {
191         elog(ERROR, "Cannot display a value of type %s", "LANGUAGE_HANDLER");
192
193         PG_RETURN_VOID();                       /* keep compiler quiet */
194 }
195
196
197 /*
198  * internal_in          - input routine for pseudo-type INTERNAL.
199  */
200 Datum
201 internal_in(PG_FUNCTION_ARGS)
202 {
203         elog(ERROR, "Cannot accept a constant of type %s", "INTERNAL");
204
205         PG_RETURN_VOID();                       /* keep compiler quiet */
206 }
207
208 /*
209  * internal_out         - output routine for pseudo-type INTERNAL.
210  */
211 Datum
212 internal_out(PG_FUNCTION_ARGS)
213 {
214         elog(ERROR, "Cannot display a value of type %s", "INTERNAL");
215
216         PG_RETURN_VOID();                       /* keep compiler quiet */
217 }
218
219
220 /*
221  * opaque_in            - input routine for pseudo-type OPAQUE.
222  */
223 Datum
224 opaque_in(PG_FUNCTION_ARGS)
225 {
226         elog(ERROR, "Cannot accept a constant of type %s", "OPAQUE");
227
228         PG_RETURN_VOID();                       /* keep compiler quiet */
229 }
230
231 /*
232  * opaque_out           - output routine for pseudo-type OPAQUE.
233  */
234 Datum
235 opaque_out(PG_FUNCTION_ARGS)
236 {
237         elog(ERROR, "Cannot display a value of type %s", "OPAQUE");
238
239         PG_RETURN_VOID();                       /* keep compiler quiet */
240 }