Revision 12577
Added by Aaron Marcuse-Kubitza almost 11 years ago
trunk/schemas/util.sql | ||
---|---|---|
2099 | 2099 |
LANGUAGE sql IMMUTABLE |
2100 | 2100 |
AS $_$ |
2101 | 2101 |
SELECT util.create_if_not_exists($$ |
2102 |
CREATE TYPE $$||util.prefixed_name($3||'_', $1)||$$ AS |
|
2103 |
($$||util.mk_typed_cols_list($2)||$$); |
|
2104 |
|
|
2102 | 2105 |
CREATE OR REPLACE FUNCTION $$||util.qual_name(util.schema($1), $3)||$$(value $$ |
2103 |
||util.qual_name($1)||util.mk_out_params($2)||$$) |
|
2104 |
RETURNS $$||util._if(util.array_length($2) = 1, $2[1].type::text, $$record$$) |
|
2105 |
||$$ AS |
|
2106 |
||util.qual_name($1)||$$) |
|
2107 |
RETURNS $$||util.prefixed_name($3||'_', $1)||$$ AS |
|
2106 | 2108 |
$BODY1$ |
2107 |
SELECT $$|| util._if(util.array_length($2) = 1, ''::text, $$ROW$$) ||$$($$||
|
|
2109 |
SELECT ROW($$||
|
|
2108 | 2110 |
(SELECT COALESCE(string_agg($$$1.$$||(unnest).col_name, ', '), '') |
2109 |
FROM unnest($2)) ||$$) |
|
2111 |
FROM unnest($2)) ||$$)::$$||util.prefixed_name($3||'_', $1)||$$
|
|
2110 | 2112 |
$BODY1$ |
2111 | 2113 |
LANGUAGE sql IMMUTABLE |
2112 | 2114 |
COST 100; |
Also available in: Unified diff
bugfix: schemas/util.sql: mk_keys_func(regtype, util.col_cast[]): use named return type to avoid complicated edge cases with 1-column records, which prevent (values_(...)).* from working correctly