postgresql/src/pl/plpython/expected/plpython_quote.out
Andres Freund db23464715 plpython: Remove regression test infrastructure for Python 2.
Since 19252e8ec9 we reject Python 2 during build configuration. Now that the
dust on the buildfarm has settled, remove regression testing infrastructure
dealing with differing output between Python 2 / 3.

Reviewed-By: Peter Eisentraut <peter@eisentraut.org>
Reviewed-By: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/20211031184548.g4sxfe47n2kyi55r@alap3.anarazel.de
2022-03-07 18:20:51 -08:00

56 lines
992 B
Text

-- test quoting functions
CREATE FUNCTION quote(t text, how text) RETURNS text AS $$
if how == "literal":
return plpy.quote_literal(t)
elif how == "nullable":
return plpy.quote_nullable(t)
elif how == "ident":
return plpy.quote_ident(t)
else:
raise plpy.Error("unrecognized quote type %s" % how)
$$ LANGUAGE plpython3u;
SELECT quote(t, 'literal') FROM (VALUES
('abc'),
('a''bc'),
('''abc'''),
(''),
(''''),
('xyzv')) AS v(t);
quote
-----------
'abc'
'a''bc'
'''abc'''
''
''''
'xyzv'
(6 rows)
SELECT quote(t, 'nullable') FROM (VALUES
('abc'),
('a''bc'),
('''abc'''),
(''),
(''''),
(NULL)) AS v(t);
quote
-----------
'abc'
'a''bc'
'''abc'''
''
''''
NULL
(6 rows)
SELECT quote(t, 'ident') FROM (VALUES
('abc'),
('a b c'),
('a " ''abc''')) AS v(t);
quote
--------------
abc
"a b c"
"a "" 'abc'"
(3 rows)