Project

General

Profile

« Previous | Next » 

Revision 13603

bugfix: schemas/util.sql: mk_drop_from_create(): only match CREATE if no custom DROP came before it

View differences:

util.sql
2432 2432
    LANGUAGE sql IMMUTABLE
2433 2433
    AS $_$
2434 2434
SELECT $$DROP $$||(util.regexp_match($1,
2435
'(?m)^CREATE(?: OR REPLACE)? ((?:)??[[:upper:]]+ .*?)(?: AS(?: (?:SELECT\y.*)?)?)?$'))[1]||$$;$$
2435
-- match first CREATE, *if* no DROP came before it
2436
'(?m)\A(?:^(?!DROP\y).*\n)*^CREATE(?: OR REPLACE)? ((?:)??[[:upper:]]+ .*?)(?: AS(?: (?:SELECT\y.*)?)?)?$'
2436 2437
	/* (?:)?? makes the surrounding () group non-greedy, so that (?: AS ?)?
2437 2438
	works properly (due to nonstandard Postgres regexp behavior:
2438 2439
	http://www.postgresql.org/docs/9.3/static/functions-matching.html#POSIX-MATCHING-RULES) */
2440
))[1]||$$;$$
2439 2441
$_$;
2440 2442

  
2441 2443

  

Also available in: Unified diff