From 73c8e8506cd1933ccf5c5d61088ca171a5f414c0 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Wed, 26 Oct 2016 14:17:07 +0300 Subject: [PATCH] Avoid using platform-dependent floats in test case. The number of decimals printed for floats varied in this test case, as noted by several buildfarm members. There's nothing special about floats and arrays in the code being tested, so replace the floats with numerics to make the output platform-independent. --- src/pl/plpython/expected/plpython_types.out | 19 ++++--------------- src/pl/plpython/expected/plpython_types_3.out | 19 ++++--------------- src/pl/plpython/sql/plpython_types.sql | 11 ++--------- 3 files changed, 10 insertions(+), 39 deletions(-) diff --git a/src/pl/plpython/expected/plpython_types.out b/src/pl/plpython/expected/plpython_types.out index 5243aab548..c53f240c0b 100644 --- a/src/pl/plpython/expected/plpython_types.out +++ b/src/pl/plpython/expected/plpython_types.out @@ -568,24 +568,13 @@ INFO: ([[[1L, 2L, None], [None, 5L, 6L]], [[None, 8L, 9L], [10L, 11L, 12L]]], < {{{1,2,NULL},{NULL,5,6}},{{NULL,8,9},{10,11,12}}} (1 row) -CREATE FUNCTION test_type_conversion_array_float4(x float4[]) RETURNS float4[] AS $$ +CREATE FUNCTION test_type_conversion_array_numeric(x numeric[]) RETURNS numeric[] AS $$ plpy.info(x, type(x)) return x $$ LANGUAGE plpythonu; -SELECT * FROM test_type_conversion_array_float4(ARRAY[[[1.2,2.3,NULL],[NULL,5.7,6.8]],[[NULL,8.9,9.345],[10.123,11.456,12.6768]]]::float4[]); -INFO: ([[[1.2000000476837158, 2.299999952316284, None], [None, 5.699999809265137, 6.800000190734863]], [[None, 8.899999618530273, 9.345000267028809], [10.123000144958496, 11.456000328063965, 12.676799774169922]]], ) - test_type_conversion_array_float4 ------------------------------------------------------------------------------- - {{{1.2,2.3,NULL},{NULL,5.7,6.8}},{{NULL,8.9,9.345},{10.123,11.456,12.6768}}} -(1 row) - -CREATE FUNCTION test_type_conversion_array_float8(x float8[]) RETURNS float8[] AS $$ -plpy.info(x, type(x)) -return x -$$ LANGUAGE plpythonu; -SELECT * FROM test_type_conversion_array_float8(ARRAY[[[1.2,2.3,NULL],[NULL,5.7,6.8]],[[NULL,8.9,9.345],[10.123,11.456,12.6768]]]::float8[]); -INFO: ([[[1.2, 2.3, None], [None, 5.7, 6.8]], [[None, 8.9, 9.345], [10.123, 11.456, 12.6768]]], ) - test_type_conversion_array_float8 +SELECT * FROM test_type_conversion_array_numeric(ARRAY[[[1.2,2.3,NULL],[NULL,5.7,6.8]],[[NULL,8.9,9.345],[10.123,11.456,12.6768]]]::numeric[]); +INFO: ([[[Decimal('1.2'), Decimal('2.3'), None], [None, Decimal('5.7'), Decimal('6.8')]], [[None, Decimal('8.9'), Decimal('9.345')], [Decimal('10.123'), Decimal('11.456'), Decimal('12.6768')]]], ) + test_type_conversion_array_numeric ------------------------------------------------------------------------------ {{{1.2,2.3,NULL},{NULL,5.7,6.8}},{{NULL,8.9,9.345},{10.123,11.456,12.6768}}} (1 row) diff --git a/src/pl/plpython/expected/plpython_types_3.out b/src/pl/plpython/expected/plpython_types_3.out index 1592219522..6a2955b0ac 100644 --- a/src/pl/plpython/expected/plpython_types_3.out +++ b/src/pl/plpython/expected/plpython_types_3.out @@ -568,24 +568,13 @@ INFO: ([[[1, 2, None], [None, 5, 6]], [[None, 8, 9], [10, 11, 12]]], ) - test_type_conversion_array_float4 ------------------------------------------------------------------------------- - {{{1.2,2.3,NULL},{NULL,5.7,6.8}},{{NULL,8.9,9.345},{10.123,11.456,12.6768}}} -(1 row) - -CREATE FUNCTION test_type_conversion_array_float8(x float8[]) RETURNS float8[] AS $$ -plpy.info(x, type(x)) -return x -$$ LANGUAGE plpython3u; -SELECT * FROM test_type_conversion_array_float8(ARRAY[[[1.2,2.3,NULL],[NULL,5.7,6.8]],[[NULL,8.9,9.345],[10.123,11.456,12.6768]]]::float8[]); -INFO: ([[[1.2, 2.3, None], [None, 5.7, 6.8]], [[None, 8.9, 9.345], [10.123, 11.456, 12.6768]]], ) - test_type_conversion_array_float8 +SELECT * FROM test_type_conversion_array_numeric(ARRAY[[[1.2,2.3,NULL],[NULL,5.7,6.8]],[[NULL,8.9,9.345],[10.123,11.456,12.6768]]]::numeric[]); +INFO: ([[[Decimal('1.2'), Decimal('2.3'), None], [None, Decimal('5.7'), Decimal('6.8')]], [[None, Decimal('8.9'), Decimal('9.345')], [Decimal('10.123'), Decimal('11.456'), Decimal('12.6768')]]], ) + test_type_conversion_array_numeric ------------------------------------------------------------------------------ {{{1.2,2.3,NULL},{NULL,5.7,6.8}},{{NULL,8.9,9.345},{10.123,11.456,12.6768}}} (1 row) diff --git a/src/pl/plpython/sql/plpython_types.sql b/src/pl/plpython/sql/plpython_types.sql index 802dd4104a..41a70dea51 100644 --- a/src/pl/plpython/sql/plpython_types.sql +++ b/src/pl/plpython/sql/plpython_types.sql @@ -247,19 +247,12 @@ $$ LANGUAGE plpythonu; SELECT * FROM test_type_conversion_array_int8(ARRAY[[[1,2,NULL],[NULL,5,6]],[[NULL,8,9],[10,11,12]]]::int8[]); -CREATE FUNCTION test_type_conversion_array_float4(x float4[]) RETURNS float4[] AS $$ +CREATE FUNCTION test_type_conversion_array_numeric(x numeric[]) RETURNS numeric[] AS $$ plpy.info(x, type(x)) return x $$ LANGUAGE plpythonu; -SELECT * FROM test_type_conversion_array_float4(ARRAY[[[1.2,2.3,NULL],[NULL,5.7,6.8]],[[NULL,8.9,9.345],[10.123,11.456,12.6768]]]::float4[]); - -CREATE FUNCTION test_type_conversion_array_float8(x float8[]) RETURNS float8[] AS $$ -plpy.info(x, type(x)) -return x -$$ LANGUAGE plpythonu; - -SELECT * FROM test_type_conversion_array_float8(ARRAY[[[1.2,2.3,NULL],[NULL,5.7,6.8]],[[NULL,8.9,9.345],[10.123,11.456,12.6768]]]::float8[]); +SELECT * FROM test_type_conversion_array_numeric(ARRAY[[[1.2,2.3,NULL],[NULL,5.7,6.8]],[[NULL,8.9,9.345],[10.123,11.456,12.6768]]]::numeric[]); CREATE FUNCTION test_type_conversion_array_date(x date[]) RETURNS date[] AS $$ plpy.info(x, type(x)) -- 2.39.5