|
| 1 | +from util import run |
| 2 | + |
| 3 | + |
| 4 | +sql = """ |
| 5 | +CREATE FUNCTION python_max(a integer, b integer) RETURNS integer AS $$ |
| 6 | + return max(a, b) |
| 7 | +$$ LANGUAGE plpython3u SET search_path TO 'pg_catalog', 'pg_temp' |
| 8 | +; |
| 9 | +
|
| 10 | +CREATE FUNCTION tcl_max(integer, integer) RETURNS integer AS $$ |
| 11 | + if {$1 > $2} {return $1} |
| 12 | + return $2 |
| 13 | +$$ LANGUAGE pltcl STRICT SET search_path TO 'pg_catalog', 'pg_temp' |
| 14 | +; |
| 15 | +""" |
| 16 | + |
| 17 | + |
| 18 | +def test_unknown_lang_plpython3u(): |
| 19 | + output = run(sql) |
| 20 | + assert "Unknown function language: plpython3u" in output |
| 21 | + |
| 22 | + |
| 23 | +def test_unknown_lang_pltcl(): |
| 24 | + output = run(sql) |
| 25 | + assert "Unknown function language: pltcl" in output |
| 26 | + |
| 27 | + |
| 28 | +def test_ignore_lang_plpython3u(): |
| 29 | + output = run(sql, list("--ignore-lang=plpython3u")) |
| 30 | + assert "Unknown function language: plpython3u" not in output |
| 31 | + |
| 32 | + |
| 33 | +def test_ignore_lang_pltcl(): |
| 34 | + output = run(sql, list("--ignore-lang=pltcl")) |
| 35 | + assert "Unknown function language: pltcl" not in output |
| 36 | + |
| 37 | + |
| 38 | +def test_ignore_lang_plpython3u_pltcl(): |
| 39 | + output = run(sql, ["--ignore-lang=plpython3u", "--ignore-lang=pltcl"]) |
| 40 | + assert ( |
| 41 | + "Unknown function language: pltcl" not in output |
| 42 | + and "Unknown function language: plpython3u" not in output |
| 43 | + ) |
| 44 | + |
| 45 | + |
| 46 | +def test_ignore_lang_upper(): |
| 47 | + output = run(sql, ["--ignore-lang=PLPYTHON3U", "--ignore-lang=PLTCL"]) |
| 48 | + assert ( |
| 49 | + "Unknown function language: pltcl" not in output |
| 50 | + and "Unknown function language: plpython3u" not in output |
| 51 | + ) |
0 commit comments