Re: [HACKERS] GSoC 2017: Foreign Key Arrays

From: "Joel Jacobson" <joel(at)compiler(dot)org>
To: "Mark Rofail" <markm(dot)rofail(at)gmail(dot)com>, "Alvaro Herrera" <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: "Alexander Korotkov" <aekorotkov(at)gmail(dot)com>, "Andreas Karlsson" <andreas(at)proxel(dot)se>, "David Steele" <david(at)pgmasters(dot)net>, "Erik Rijkers" <er(at)xs4all(dot)nl>, Hans-Jürgen Schönig <hs(at)cybertec(dot)at>, "Michael Paquier" <michael(at)paquier(dot)xyz>, "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Stephen Frost" <sfrost(at)snowman(dot)net>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Zhihong Yu" <zyu(at)yugabyte(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] GSoC 2017: Foreign Key Arrays
Date: 2021-02-13 11:35:34
Message-ID: 1fad85ba-547c-4292-8782-cb2733132149@www.fastmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Feb 12, 2021, at 20:56, Mark Rofail wrote:
>Attachments:
>anyarray_anyelement_operators-v2.patch

I've created a quite sophisticated test in PL/pgSQL,
that takes advantage of all the test data produced
by the official PostgreSQL regression test suite.

It goes through all tables and columns, and extracts values
for all the different types it can find.

It then uses these values to probe for differences between

some_value::some_type = ANY(ARRAY[some_other_value]::some_other_type[])
and
some_value::some_type <<@ ARRAY[some_other_value]::some_other_type[]

psql:type-test.sql:165: NOTICE:
========================
144 of 21632 tests failed.
========================

Out of these 144 differences found, this one was really interesting:

psql:type-test.sql:165: WARNING:
SQL queries produced different results:
SELECT '285970053'::pg_catalog."numeric" = ANY(ARRAY['285970053']::pg_catalog.float4[])
false
SELECT '285970053'::pg_catalog."numeric" <<@ ARRAY['285970053']::pg_catalog.float4[]
true

I don't see why one of them returns false and the other true?

If testing for equality:

SELECT '285970053'::pg_catalog.float4 = '285970053'::numeric;

You get "false".

So it looks like ANY() does the right thing here, and <<@ has a problem.

To run, first run the PostgreSQL regression tests, to produce data in the "regression" database.

Then run:

$ psql -f type-test.sql regression

/Joel

Attachment Content-Type Size
type-test.sql application/octet-stream 4.1 KB
type-test.out application/octet-stream 46.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Erik Rijkers 2021-02-13 12:28:29 Re: logical replication seems broken
Previous Message Greg Stark 2021-02-13 11:35:07 Re: pg13.2: invalid memory alloc request size NNNN