Revision 13639
Added by Aaron Marcuse-Kubitza over 10 years ago
util.sql | ||
---|---|---|
4449 | 4449 |
|
4450 | 4450 |
|
4451 | 4451 |
-- |
4452 |
-- Name: view_def_to_orig(text); Type: FUNCTION; Schema: util; Owner: - |
|
4453 |
-- |
|
4454 |
|
|
4455 |
CREATE FUNCTION view_def_to_orig(view_def text) RETURNS text |
|
4456 |
LANGUAGE sql IMMUTABLE |
|
4457 |
AS $_$ |
|
4458 |
/* unexpand expanded * expressions. any list of 5+ cols from the same table is |
|
4459 |
treated as a * expression. */ |
|
4460 |
SELECT regexp_replace($1, |
|
4461 |
'\y((?:"[^"]+"|\w+)\.)(?:"[^"]+"|\w+)'|| --1st col, which lacks separator before |
|
4462 |
'(,[[:blank:]]* |
|
4463 |
[[:blank:]]*)\1(?:"[^"]+"|\w+)'|| -- 2nd col, which has separator before |
|
4464 |
'(?:\2\1(?:"[^"]+"|\w+)){4,}', -- later cols, w/ same table name and separator |
|
4465 |
'\1*'/*prefix w/ table*/, 'g') |
|
4466 |
$_$; |
|
4467 |
|
|
4468 |
|
|
4469 |
-- |
|
4452 | 4470 |
-- Name: all_same(anyelement); Type: AGGREGATE; Schema: util; Owner: - |
4453 | 4471 |
-- |
4454 | 4472 |
|
Also available in: Unified diff
schemas/util.sql: added view_def_to_orig()