Order dependency in function test

Started by Magnus Haganderover 5 years ago5 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t43978
psql -h localhost -U postgres

Built from patchset v4 (message #4), July 27, 2026 at 05:14 PM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t43978_4 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t43978_4 && git checkout t43978_4

Patchset v4 (message #4) is on t43978_4

Jump to latest
#1Magnus Hagander
magnus@hagander.net

Looking at https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=prion&dt=2021-04-08%2009%3A43%3A13
which broke with the patch to add pg_wait_backend_termination().

AFAICT the change is that the order of rows coming back from "SELECT
routine_name, sequence_name FROM
information_schema.routine_sequence_usage" has changed. This test was
added in f40c6969d0e ("Routine usage information schema tables"),

It does not change consistently, as it works fine on my machine and
has also passed on other buildfarm animals (including other archs and
compilers).

My guess is that maybe the query plan is different, ending up with a
different order, since there is no explicit ORDER BY in the query.

Is there a particular thing we want to check on it that requires it to
run without ORDER BY, or should we add one to solve the problem? Or,
of course, am I completely misunderstanding it? :)

--
Magnus Hagander
Me: https://www.hagander.net/
Work: https://www.redpill-linpro.com/

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Magnus Hagander (#1)
Re: Order dependency in function test

On 08.04.21 12:04, Magnus Hagander wrote:

Looking at https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=prion&dt=2021-04-08%2009%3A43%3A13
which broke with the patch to add pg_wait_backend_termination().

AFAICT the change is that the order of rows coming back from "SELECT
routine_name, sequence_name FROM
information_schema.routine_sequence_usage" has changed. This test was
added in f40c6969d0e ("Routine usage information schema tables"),

It does not change consistently, as it works fine on my machine and
has also passed on other buildfarm animals (including other archs and
compilers).

My guess is that maybe the query plan is different, ending up with a
different order, since there is no explicit ORDER BY in the query.

Is there a particular thing we want to check on it that requires it to
run without ORDER BY, or should we add one to solve the problem? Or,
of course, am I completely misunderstanding it? :)

I added some ORDER BY clauses to fix this.

#3Magnus Hagander
magnus@hagander.net
In reply to: Peter Eisentraut (#2)
Re: Order dependency in function test

On Thu, Apr 8, 2021 at 12:22 PM Peter Eisentraut
<peter.eisentraut@enterprisedb.com> wrote:

On 08.04.21 12:04, Magnus Hagander wrote:

Looking at https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=prion&amp;dt=2021-04-08%2009%3A43%3A13
which broke with the patch to add pg_wait_backend_termination().

AFAICT the change is that the order of rows coming back from "SELECT
routine_name, sequence_name FROM
information_schema.routine_sequence_usage" has changed. This test was
added in f40c6969d0e ("Routine usage information schema tables"),

It does not change consistently, as it works fine on my machine and
has also passed on other buildfarm animals (including other archs and
compilers).

My guess is that maybe the query plan is different, ending up with a
different order, since there is no explicit ORDER BY in the query.

Is there a particular thing we want to check on it that requires it to
run without ORDER BY, or should we add one to solve the problem? Or,
of course, am I completely misunderstanding it? :)

I added some ORDER BY clauses to fix this.

Thanks!

--
Magnus Hagander
Me: https://www.hagander.net/
Work: https://www.redpill-linpro.com/

#4Bharath Rupireddy
bharath.rupireddyforpostgres@gmail.com
In reply to: Magnus Hagander (#1)
Re: Order dependency in function test

On Thu, Apr 8, 2021 at 3:34 PM Magnus Hagander <magnus@hagander.net> wrote:

Looking at https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=prion&amp;dt=2021-04-08%2009%3A43%3A13
which broke with the patch to add pg_wait_backend_termination().

AFAICT the change is that the order of rows coming back from "SELECT
routine_name, sequence_name FROM
information_schema.routine_sequence_usage" has changed. This test was
added in f40c6969d0e ("Routine usage information schema tables"),

It does not change consistently, as it works fine on my machine and
has also passed on other buildfarm animals (including other archs and
compilers).

My guess is that maybe the query plan is different, ending up with a
different order, since there is no explicit ORDER BY in the query.

Is there a particular thing we want to check on it that requires it to
run without ORDER BY, or should we add one to solve the problem? Or,
of course, am I completely misunderstanding it? :)

The buildfarm failure is due to lack of ORDER BY clause. Upon
searching in that file, I found below statements are returning more
than one row but doesn't have ORDER BY clause which can make output
quite unstable.

SELECT routine_name, sequence_name FROM
information_schema.routine_sequence_usage;
SELECT routine_name, table_name, column_name FROM
information_schema.routine_column_usage;
SELECT routine_name, table_name FROM information_schema.routine_table_usage;
SELECT * FROM functest_sri1();
SELECT * FROM functest_sri2();
TABLE sometable;

I added a ORDER BY 1 clause for each of the above statements and
replaced TABLE sometable; with SELECT * FROM sometable ORDER BY 1;

Here's the patch.

With Regards,
Bharath Rupireddy.
EnterpriseDB: http://www.enterprisedb.com

Attachments:

t43978_4
v1-0001-Stabilize-tests-in-create_function_3.sql-with-ORD.patchapplication/octet-stream; name=v1-0001-Stabilize-tests-in-create_function_3.sql-with-ORD.patchDownload+10-11
#5Bharath Rupireddy
bharath.rupireddyforpostgres@gmail.com
In reply to: Bharath Rupireddy (#4)
Re: Order dependency in function test

On Thu, Apr 8, 2021 at 3:53 PM Bharath Rupireddy
<bharath.rupireddyforpostgres@gmail.com> wrote:

On Thu, Apr 8, 2021 at 3:34 PM Magnus Hagander <magnus@hagander.net> wrote:

Looking at https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=prion&amp;dt=2021-04-08%2009%3A43%3A13
which broke with the patch to add pg_wait_backend_termination().

AFAICT the change is that the order of rows coming back from "SELECT
routine_name, sequence_name FROM
information_schema.routine_sequence_usage" has changed. This test was
added in f40c6969d0e ("Routine usage information schema tables"),

It does not change consistently, as it works fine on my machine and
has also passed on other buildfarm animals (including other archs and
compilers).

My guess is that maybe the query plan is different, ending up with a
different order, since there is no explicit ORDER BY in the query.

Is there a particular thing we want to check on it that requires it to
run without ORDER BY, or should we add one to solve the problem? Or,
of course, am I completely misunderstanding it? :)

The buildfarm failure is due to lack of ORDER BY clause. Upon
searching in that file, I found below statements are returning more
than one row but doesn't have ORDER BY clause which can make output
quite unstable.

SELECT routine_name, sequence_name FROM
information_schema.routine_sequence_usage;
SELECT routine_name, table_name, column_name FROM
information_schema.routine_column_usage;
SELECT routine_name, table_name FROM information_schema.routine_table_usage;
SELECT * FROM functest_sri1();
SELECT * FROM functest_sri2();
TABLE sometable;

I added a ORDER BY 1 clause for each of the above statements and
replaced TABLE sometable; with SELECT * FROM sometable ORDER BY 1;

Here's the patch.

I realized that the ORDER BY is added. Isn't it good if we add ORDER
BY for SELECT * FROM functest_sri2();, SELECT * FROM functest_sri1();
and replace TABLE sometable; with SELECT * FROM sometable ORDER BY 1;
? Otherwise they might become unstable at some other time?

With Regards,
Bharath Rupireddy.
EnterpriseDB: http://www.enterprisedb.com