mirror of
https://github.com/postgres/postgres.git
synced 2026-06-06 23:59:45 -04:00
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
This commit is contained in:
@@ -7,19 +7,19 @@ CREATE FUNCTION nested_call_one(a text) RETURNS text
|
||||
'q = "SELECT nested_call_two(''%s'')" % a
|
||||
r = plpy.execute(q)
|
||||
return r[0]'
|
||||
LANGUAGE plpythonu ;
|
||||
LANGUAGE plpython3u ;
|
||||
|
||||
CREATE FUNCTION nested_call_two(a text) RETURNS text
|
||||
AS
|
||||
'q = "SELECT nested_call_three(''%s'')" % a
|
||||
r = plpy.execute(q)
|
||||
return r[0]'
|
||||
LANGUAGE plpythonu ;
|
||||
LANGUAGE plpython3u ;
|
||||
|
||||
CREATE FUNCTION nested_call_three(a text) RETURNS text
|
||||
AS
|
||||
'return a'
|
||||
LANGUAGE plpythonu ;
|
||||
LANGUAGE plpython3u ;
|
||||
|
||||
-- some spi stuff
|
||||
|
||||
@@ -35,7 +35,7 @@ except Exception as ex:
|
||||
plpy.error(str(ex))
|
||||
return None
|
||||
'
|
||||
LANGUAGE plpythonu;
|
||||
LANGUAGE plpython3u;
|
||||
|
||||
CREATE FUNCTION spi_prepared_plan_test_two(a text) RETURNS text
|
||||
AS
|
||||
@@ -49,7 +49,7 @@ except Exception as ex:
|
||||
plpy.error(str(ex))
|
||||
return None
|
||||
'
|
||||
LANGUAGE plpythonu;
|
||||
LANGUAGE plpython3u;
|
||||
|
||||
CREATE FUNCTION spi_prepared_plan_test_nested(a text) RETURNS text
|
||||
AS
|
||||
@@ -64,7 +64,7 @@ except Exception as ex:
|
||||
plpy.error(str(ex))
|
||||
return None
|
||||
'
|
||||
LANGUAGE plpythonu;
|
||||
LANGUAGE plpython3u;
|
||||
|
||||
CREATE FUNCTION join_sequences(s sequences) RETURNS text
|
||||
AS
|
||||
@@ -77,7 +77,7 @@ for r in rv:
|
||||
seq = seq + r["sequence"]
|
||||
return seq
|
||||
'
|
||||
LANGUAGE plpythonu;
|
||||
LANGUAGE plpython3u;
|
||||
|
||||
CREATE FUNCTION spi_recursive_sum(a int) RETURNS int
|
||||
AS
|
||||
@@ -86,7 +86,7 @@ if a > 1:
|
||||
r = plpy.execute("SELECT spi_recursive_sum(%d) as a" % (a-1))[0]["a"]
|
||||
return a + r
|
||||
'
|
||||
LANGUAGE plpythonu;
|
||||
LANGUAGE plpython3u;
|
||||
|
||||
--
|
||||
-- spi and nested calls
|
||||
@@ -120,7 +120,7 @@ if result.status() > 0:
|
||||
return result.nrows()
|
||||
else:
|
||||
return None
|
||||
$$ LANGUAGE plpythonu;
|
||||
$$ LANGUAGE plpython3u;
|
||||
|
||||
SELECT result_metadata_test($$SELECT 1 AS foo, '11'::text AS bar UNION SELECT 2, '22'$$);
|
||||
SELECT result_metadata_test($$CREATE TEMPORARY TABLE foo1 (a int, b text)$$);
|
||||
@@ -129,7 +129,7 @@ CREATE FUNCTION result_nrows_test(cmd text) RETURNS int
|
||||
AS $$
|
||||
result = plpy.execute(cmd)
|
||||
return result.nrows()
|
||||
$$ LANGUAGE plpythonu;
|
||||
$$ LANGUAGE plpython3u;
|
||||
|
||||
SELECT result_nrows_test($$SELECT 1$$);
|
||||
SELECT result_nrows_test($$CREATE TEMPORARY TABLE foo2 (a int, b text)$$);
|
||||
@@ -140,7 +140,7 @@ CREATE FUNCTION result_len_test(cmd text) RETURNS int
|
||||
AS $$
|
||||
result = plpy.execute(cmd)
|
||||
return len(result)
|
||||
$$ LANGUAGE plpythonu;
|
||||
$$ LANGUAGE plpython3u;
|
||||
|
||||
SELECT result_len_test($$SELECT 1$$);
|
||||
SELECT result_len_test($$CREATE TEMPORARY TABLE foo3 (a int, b text)$$);
|
||||
@@ -162,7 +162,7 @@ result[-1] = {'c': 1000}
|
||||
result[:2] = [{'c': 10}, {'c': 100}]
|
||||
plpy.info([item['c'] for item in result[:]])
|
||||
|
||||
# raises TypeError, but the message differs on Python 2.6, so silence it
|
||||
# raises TypeError, catch so further tests could be added
|
||||
try:
|
||||
plpy.info(result['foo'])
|
||||
except TypeError:
|
||||
@@ -170,7 +170,7 @@ except TypeError:
|
||||
else:
|
||||
assert False, "TypeError not raised"
|
||||
|
||||
$$ LANGUAGE plpythonu;
|
||||
$$ LANGUAGE plpython3u;
|
||||
|
||||
SELECT result_subscript_test();
|
||||
|
||||
@@ -180,7 +180,7 @@ result = plpy.execute("select 1 where false")
|
||||
|
||||
plpy.info(result[:])
|
||||
|
||||
$$ LANGUAGE plpythonu;
|
||||
$$ LANGUAGE plpython3u;
|
||||
|
||||
SELECT result_empty_test();
|
||||
|
||||
@@ -189,7 +189,7 @@ AS $$
|
||||
plan = plpy.prepare(cmd)
|
||||
result = plpy.execute(plan)
|
||||
return str(result)
|
||||
$$ LANGUAGE plpythonu;
|
||||
$$ LANGUAGE plpython3u;
|
||||
|
||||
SELECT result_str_test($$SELECT 1 AS foo UNION SELECT 2$$);
|
||||
SELECT result_str_test($$CREATE TEMPORARY TABLE foo1 (a int, b text)$$);
|
||||
@@ -203,13 +203,13 @@ for row in res:
|
||||
if row['lname'] == 'doe':
|
||||
does += 1
|
||||
return does
|
||||
$$ LANGUAGE plpythonu;
|
||||
$$ LANGUAGE plpython3u;
|
||||
|
||||
CREATE FUNCTION double_cursor_close() RETURNS int AS $$
|
||||
res = plpy.cursor("select fname, lname from users")
|
||||
res.close()
|
||||
res.close()
|
||||
$$ LANGUAGE plpythonu;
|
||||
$$ LANGUAGE plpython3u;
|
||||
|
||||
CREATE FUNCTION cursor_fetch() RETURNS int AS $$
|
||||
res = plpy.cursor("select fname, lname from users")
|
||||
@@ -228,7 +228,7 @@ except StopIteration:
|
||||
pass
|
||||
else:
|
||||
assert False, "StopIteration not raised"
|
||||
$$ LANGUAGE plpythonu;
|
||||
$$ LANGUAGE plpython3u;
|
||||
|
||||
CREATE FUNCTION cursor_mix_next_and_fetch() RETURNS int AS $$
|
||||
res = plpy.cursor("select fname, lname from users order by fname")
|
||||
@@ -242,7 +242,7 @@ except AttributeError:
|
||||
assert item['fname'] == 'rick'
|
||||
|
||||
assert len(res.fetch(2)) == 1
|
||||
$$ LANGUAGE plpythonu;
|
||||
$$ LANGUAGE plpython3u;
|
||||
|
||||
CREATE FUNCTION fetch_after_close() RETURNS int AS $$
|
||||
res = plpy.cursor("select fname, lname from users")
|
||||
@@ -253,7 +253,7 @@ except ValueError:
|
||||
pass
|
||||
else:
|
||||
assert False, "ValueError not raised"
|
||||
$$ LANGUAGE plpythonu;
|
||||
$$ LANGUAGE plpython3u;
|
||||
|
||||
CREATE FUNCTION next_after_close() RETURNS int AS $$
|
||||
res = plpy.cursor("select fname, lname from users")
|
||||
@@ -267,7 +267,7 @@ except ValueError:
|
||||
pass
|
||||
else:
|
||||
assert False, "ValueError not raised"
|
||||
$$ LANGUAGE plpythonu;
|
||||
$$ LANGUAGE plpython3u;
|
||||
|
||||
CREATE FUNCTION cursor_fetch_next_empty() RETURNS int AS $$
|
||||
res = plpy.cursor("select fname, lname from users where false")
|
||||
@@ -281,7 +281,7 @@ except StopIteration:
|
||||
pass
|
||||
else:
|
||||
assert False, "StopIteration not raised"
|
||||
$$ LANGUAGE plpythonu;
|
||||
$$ LANGUAGE plpython3u;
|
||||
|
||||
CREATE FUNCTION cursor_plan() RETURNS SETOF text AS $$
|
||||
plan = plpy.prepare(
|
||||
@@ -291,13 +291,13 @@ for row in plpy.cursor(plan, ["w"]):
|
||||
yield row['fname']
|
||||
for row in plan.cursor(["j"]):
|
||||
yield row['fname']
|
||||
$$ LANGUAGE plpythonu;
|
||||
$$ LANGUAGE plpython3u;
|
||||
|
||||
CREATE FUNCTION cursor_plan_wrong_args() RETURNS SETOF text AS $$
|
||||
plan = plpy.prepare("select fname, lname from users where fname like $1 || '%'",
|
||||
["text"])
|
||||
c = plpy.cursor(plan, ["a", "b"])
|
||||
$$ LANGUAGE plpythonu;
|
||||
$$ LANGUAGE plpython3u;
|
||||
|
||||
CREATE TYPE test_composite_type AS (
|
||||
a1 int,
|
||||
@@ -308,7 +308,7 @@ CREATE OR REPLACE FUNCTION plan_composite_args() RETURNS test_composite_type AS
|
||||
plan = plpy.prepare("select $1 as c1", ["test_composite_type"])
|
||||
res = plpy.execute(plan, [{"a1": 3, "a2": "label"}])
|
||||
return res[0]["c1"]
|
||||
$$ LANGUAGE plpythonu;
|
||||
$$ LANGUAGE plpython3u;
|
||||
|
||||
SELECT simple_cursor_test();
|
||||
SELECT double_cursor_close();
|
||||
|
||||
Reference in New Issue
Block a user