Revision 13640
Added by Aaron Marcuse-Kubitza over 10 years ago
util.sql | ||
---|---|---|
2885 | 2885 |
CREATE FUNCTION pg_get_viewdef(view_ regclass) RETURNS text |
2886 | 2886 |
LANGUAGE sql STABLE |
2887 | 2887 |
AS $_$ |
2888 |
/* unexpand expanded * expressions. any list of 5+ cols from the same table is |
|
2889 |
treated as a * expression. */ |
|
2890 |
SELECT regexp_replace(pg_catalog.pg_get_viewdef($1), |
|
2891 |
'\y((?:"[^"]+"|\w+)\.)(?:"[^"]+"|\w+)'|| --1st col, which lacks separator before |
|
2892 |
'(,[[:blank:]]* |
|
2893 |
[[:blank:]]*)\1(?:"[^"]+"|\w+)'|| -- 2nd col, which has separator before |
|
2894 |
'(?:\2\1(?:"[^"]+"|\w+)){4,}', -- later cols, w/ same table name and separator |
|
2895 |
'\1*'/*prefix w/ table*/, 'g') |
|
2888 |
SELECT util.view_def_to_orig(pg_catalog.pg_get_viewdef($1)) |
|
2896 | 2889 |
$_$; |
2897 | 2890 |
|
2898 | 2891 |
|
Also available in: Unified diff
schemas/util.sql: pg_get_viewdef(): use util.view_def_to_orig()