Skip to content

Commit

Permalink
fix: CI failed plpython and plpython3 (#1)
Browse files Browse the repository at this point in the history
* fix: plpython2 test failed

* fix: plpython3 test

* fix: some typos

* fix: some bug by comments

* fix: no need the plpython_return_2 file
  • Loading branch information
yihong0618 authored Mar 30, 2022
1 parent c1d6665 commit 8b94b9e
Show file tree
Hide file tree
Showing 5 changed files with 3,121 additions and 43 deletions.
51 changes: 26 additions & 25 deletions src/pl/plpython/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,30 +94,29 @@ else
REGRESS_OPTS += --load-extension=plpython3u
endif

REGRESS = plpython_record plpython_returns
# REGRESS = \
# plpython_schema \
# plpython_populate \
# plpython_test \
# plpython_do \
# plpython_global \
# plpython_import \
# plpython_spi \
# plpython_newline \
# plpython_void \
# plpython_params \
# plpython_setof \
# plpython_record \
# plpython_trigger \
# plpython_types \
# plpython_error \
# plpython_unicode \
# plpython_quote \
# plpython_composite \
# plpython_subtransaction \
# plpython_returns \
# plpython_gpdb \
# plpython_drop
REGRESS = \
plpython_schema \
plpython_populate \
plpython_test \
plpython_do \
plpython_global \
plpython_import \
plpython_spi \
plpython_newline \
plpython_void \
plpython_params \
plpython_setof \
plpython_record \
plpython_trigger \
plpython_types \
plpython_error \
plpython_unicode \
plpython_quote \
plpython_composite \
plpython_subtransaction \
plpython_returns \
plpython_gpdb \
plpython_drop

REGRESS_PLPYTHON3_MANGLE := $(REGRESS)

Expand Down Expand Up @@ -160,6 +159,9 @@ REGRESS := $(foreach test,$(REGRESS),$(if $(filter $(test),$(REGRESS_PLPYTHON3_M
.PHONY: pgregress-python3-mangle
pgregress-python3-mangle:
$(MKDIR_P) sql/python3 expected/python3 results/python3
# for python and python3 types and returns test are not the same.
cp expected/plpython_types_3.out expected/python3/plpython_types.out
cp expected/plpython_returns_3.out expected/python3/plpython_returns.out
for file in $(patsubst %,$(srcdir)/sql/%.sql,$(REGRESS_PLPYTHON3_MANGLE)) $(patsubst %,$(srcdir)/expected/%*.out,$(REGRESS_PLPYTHON3_MANGLE)); do \
sed -e 's/except \([[:alpha:]][[:alpha:].]*\), *\([[:alpha:]][[:alpha:]]*\):/except \1 as \2:/g' \
-e "s/<type 'exceptions\.\([[:alpha:]]*\)'>/<class '\1'>/g" \
Expand All @@ -176,7 +178,6 @@ pgregress-python3-mangle:
-e "s/EXTENSION plpython2u/EXTENSION plpython3u/Ig" \
$$file >`echo $$file | sed 's,^.*/\([^/][^/]*/\)\([^/][^/]*\)$$,\1python3/\2,'` || exit; \
done
cp expected/plpython_types_3.out expected/python3/plpython_types.out

check installcheck: pgregress-python3-mangle

Expand Down
36 changes: 18 additions & 18 deletions src/pl/plpython/expected/plpython_returns.out
Original file line number Diff line number Diff line change
Expand Up @@ -359,15 +359,15 @@ SELECT test_return_bool('{None: None}') FROM gp_single_row;

-- From Python Object with bad str() function
SELECT test_return_bool(
E'1; exec("class Foo:\\n def __str__(self): return None"); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return None", globals()); y = Foo()'
);
test_return_bool
------------------
t
(1 row)

SELECT * FROM test_return_bool(
E'1; exec("class Foo:\\n def __str__(self): return None"); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return None", globals()); y = Foo()'
);
test_return_bool
------------------
Expand Down Expand Up @@ -541,23 +541,23 @@ FROM gp_single_row;

-- From Python Object with str() function
SELECT test_return_text(
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\""); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\"", globals()); y = Foo()'
);
test_return_text
------------------
test
(1 row)

SELECT * FROM test_return_text(
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\""); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\"", globals()); y = Foo()'
);
test_return_text
------------------
test
(1 row)

SELECT test_return_text(
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\""); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\"", globals()); y = Foo()'
) FROM gp_single_row;
test_return_text
------------------
Expand All @@ -575,11 +575,11 @@ SELECT * FROM test_return_text(E'"test\\0"');
ERROR: could not convert Python object into cstring: Python string representation appears to contain null bytes
-- [ERROR] From Python Object with bad str() function
SELECT test_return_text(
E'1; exec("class Foo:\\n def __str__(self): return None"); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return None", globals()); y = Foo()'
);
ERROR: could not create string representation of Python object (plpy_elog.c:106)
SELECT * FROM test_return_text(
E'1; exec("class Foo:\\n def __str__(self): return None"); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return None", globals()); y = Foo()'
);
ERROR: could not create string representation of Python object (plpy_elog.c:106)
--
Expand Down Expand Up @@ -750,23 +750,23 @@ FROM gp_single_row;

-- From Python Object with str() function
SELECT test_return_bytea(
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\""); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\"", globals()); y = Foo()'
);
test_return_bytea
-------------------
\x74657374
(1 row)

SELECT * FROM test_return_bytea(
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\""); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\"", globals()); y = Foo()'
);
test_return_bytea
-------------------
\x74657374
(1 row)

SELECT test_return_bytea(
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\""); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\"", globals()); y = Foo()'
) FROM gp_single_row;
test_return_bytea
-------------------
Expand Down Expand Up @@ -796,15 +796,15 @@ FROM gp_single_row;
-- Error conditions
-- [ERROR] From Python Object with bad str() function
SELECT test_return_bytea(
E'1; exec("class Foo:\\n def __str__(self): return None"); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return None", globals()); y = Foo()'
);
ERROR: could not create bytes representation of Python object (plpy_elog.c:106)
SELECT * FROM test_return_bytea(
E'1; exec("class Foo:\\n def __str__(self): return None"); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return None", globals()); y = Foo()'
);
ERROR: could not create bytes representation of Python object (plpy_elog.c:106)
SELECT test_return_bytea(
E'1; exec("class Foo:\\n def __str__(self): return None"); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return None", globals()); y = Foo()'
) FROM gp_single_row;
ERROR: could not create bytes representation of Python object (plpy_elog.c:106) (seg0 slice1 127.0.0.1:25432 pid=24014) (plpy_elog.c:106)
--
Expand Down Expand Up @@ -2482,23 +2482,23 @@ FROM gp_single_row;

-- From Python Object with str() function
SELECT test_return_out_text(
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\""); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\"", globals()); y = Foo()'
);
test_return_out_text
----------------------
test
(1 row)

SELECT * FROM test_return_out_text(
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\""); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\"", globals()); y = Foo()'
);
test_return_out_text
----------------------
test
(1 row)

SELECT test_return_out_text(
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\""); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return \\"test\\"", globals()); y = Foo()'
) FROM gp_single_row;
test_return_out_text
----------------------
Expand All @@ -2516,11 +2516,11 @@ SELECT * FROM test_return_out_text(E'"test\\0"');
ERROR: could not convert Python object into cstring: Python string representation appears to contain null bytes
-- [ERROR] From Python Object with bad str() function
SELECT test_return_out_text(
E'1; exec("class Foo:\\n def __str__(self): return None"); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return None", globals()); y = Foo()'
);
ERROR: could not create string representation of Python object (plpy_elog.c:106)
SELECT * FROM test_return_out_text(
E'1; exec("class Foo:\\n def __str__(self): return None"); y = Foo()'
E'1; exec("class Foo:\\n def __str__(self): return None", globals()); y = Foo()'
);
ERROR: could not create string representation of Python object (plpy_elog.c:106)
--
Expand Down
Loading

0 comments on commit 8b94b9e

Please sign in to comment.