1 /*-------------------------------------------------------------------------
4 * Functions for the system pseudo-types.
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
14 * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
15 * Portions Copyright (c) 1994, Regents of the University of California
19 * $Header: /cvsroot/pgsql/src/backend/utils/adt/pseudotypes.c,v 1.3 2002/08/26 17:53:58 tgl Exp $
21 *-------------------------------------------------------------------------
25 #include "utils/array.h"
26 #include "utils/builtins.h"
30 * record_in - input routine for pseudo-type RECORD.
33 record_in(PG_FUNCTION_ARGS)
35 elog(ERROR, "Cannot accept a constant of type %s", "RECORD");
37 PG_RETURN_VOID(); /* keep compiler quiet */
41 * record_out - output routine for pseudo-type RECORD.
44 record_out(PG_FUNCTION_ARGS)
46 elog(ERROR, "Cannot display a value of type %s", "RECORD");
48 PG_RETURN_VOID(); /* keep compiler quiet */
53 * cstring_in - input routine for pseudo-type CSTRING.
55 * We might as well allow this to support constructs like "foo_in('blah')".
58 cstring_in(PG_FUNCTION_ARGS)
60 char *str = PG_GETARG_CSTRING(0);
62 PG_RETURN_CSTRING(pstrdup(str));
66 * cstring_out - output routine for pseudo-type CSTRING.
68 * We allow this mainly so that "SELECT some_output_function(...)" does
69 * what the user will expect.
72 cstring_out(PG_FUNCTION_ARGS)
74 char *str = PG_GETARG_CSTRING(0);
76 PG_RETURN_CSTRING(pstrdup(str));
81 * any_in - input routine for pseudo-type ANY.
84 any_in(PG_FUNCTION_ARGS)
86 elog(ERROR, "Cannot accept a constant of type %s", "ANY");
88 PG_RETURN_VOID(); /* keep compiler quiet */
92 * any_out - output routine for pseudo-type ANY.
95 any_out(PG_FUNCTION_ARGS)
97 elog(ERROR, "Cannot display a value of type %s", "ANY");
99 PG_RETURN_VOID(); /* keep compiler quiet */
104 * anyarray_in - input routine for pseudo-type ANYARRAY.
107 anyarray_in(PG_FUNCTION_ARGS)
109 elog(ERROR, "Cannot accept a constant of type %s", "ANYARRAY");
111 PG_RETURN_VOID(); /* keep compiler quiet */
115 * anyarray_out - output routine for pseudo-type ANYARRAY.
117 * We may as well allow this, since array_out will in fact work.
120 anyarray_out(PG_FUNCTION_ARGS)
122 return array_out(fcinfo);
127 * void_in - input routine for pseudo-type VOID.
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.
134 void_in(PG_FUNCTION_ARGS)
136 PG_RETURN_VOID(); /* you were expecting something different? */
140 * void_out - output routine for pseudo-type VOID.
142 * We allow this so that "SELECT function_returning_void(...)" works.
145 void_out(PG_FUNCTION_ARGS)
147 PG_RETURN_CSTRING(pstrdup(""));
152 * trigger_in - input routine for pseudo-type TRIGGER.
155 trigger_in(PG_FUNCTION_ARGS)
157 elog(ERROR, "Cannot accept a constant of type %s", "TRIGGER");
159 PG_RETURN_VOID(); /* keep compiler quiet */
163 * trigger_out - output routine for pseudo-type TRIGGER.
166 trigger_out(PG_FUNCTION_ARGS)
168 elog(ERROR, "Cannot display a value of type %s", "TRIGGER");
170 PG_RETURN_VOID(); /* keep compiler quiet */
175 * language_handler_in - input routine for pseudo-type LANGUAGE_HANDLER.
178 language_handler_in(PG_FUNCTION_ARGS)
180 elog(ERROR, "Cannot accept a constant of type %s", "LANGUAGE_HANDLER");
182 PG_RETURN_VOID(); /* keep compiler quiet */
186 * language_handler_out - output routine for pseudo-type LANGUAGE_HANDLER.
189 language_handler_out(PG_FUNCTION_ARGS)
191 elog(ERROR, "Cannot display a value of type %s", "LANGUAGE_HANDLER");
193 PG_RETURN_VOID(); /* keep compiler quiet */
198 * internal_in - input routine for pseudo-type INTERNAL.
201 internal_in(PG_FUNCTION_ARGS)
203 elog(ERROR, "Cannot accept a constant of type %s", "INTERNAL");
205 PG_RETURN_VOID(); /* keep compiler quiet */
209 * internal_out - output routine for pseudo-type INTERNAL.
212 internal_out(PG_FUNCTION_ARGS)
214 elog(ERROR, "Cannot display a value of type %s", "INTERNAL");
216 PG_RETURN_VOID(); /* keep compiler quiet */
221 * opaque_in - input routine for pseudo-type OPAQUE.
224 opaque_in(PG_FUNCTION_ARGS)
226 elog(ERROR, "Cannot accept a constant of type %s", "OPAQUE");
228 PG_RETURN_VOID(); /* keep compiler quiet */
232 * opaque_out - output routine for pseudo-type OPAQUE.
235 opaque_out(PG_FUNCTION_ARGS)
237 elog(ERROR, "Cannot display a value of type %s", "OPAQUE");
239 PG_RETURN_VOID(); /* keep compiler quiet */