Revision 13515
Added by Aaron Marcuse-Kubitza over 10 years ago
trunk/schemas/util.sql | ||
---|---|---|
2396 | 2396 |
|
2397 | 2397 |
|
2398 | 2398 |
-- |
2399 |
-- Name: mk_drop_from_create(text); Type: FUNCTION; Schema: util; Owner: - |
|
2400 |
-- |
|
2401 |
|
|
2402 |
CREATE FUNCTION mk_drop_from_create(create_cmd text) RETURNS text |
|
2403 |
LANGUAGE sql IMMUTABLE |
|
2404 |
AS $_$ |
|
2405 |
SELECT (util.regexp_match($1, |
|
2406 |
'(?m)^CREATE(?: OR REPLACE)? ((?:)??[[:upper:]]+ .*?)(?: AS ?)?$'))[1] |
|
2407 |
/* (?:)?? makes the surrounding () group non-greedy, so that (?: AS ?)? |
|
2408 |
works properly (due to nonstandard Postgres regexp behavior: |
|
2409 |
http://www.postgresql.org/docs/9.3/static/functions-matching.html#POSIX-MATCHING-RULES) */ |
|
2410 |
$_$; |
|
2411 |
|
|
2412 |
|
|
2413 |
-- |
|
2399 | 2414 |
-- Name: mk_keys_func(regtype); Type: FUNCTION; Schema: util; Owner: - |
2400 | 2415 |
-- |
2401 | 2416 |
|
Also available in: Unified diff
schemas/util.sql: added mk_drop_from_create()