跳转到主要内容

pg_disorder

Perturb unordered SELECT row order to expose order-dependent tests

pg_disorder : Perturb unordered SELECT row order to expose order-dependent tests

Overview

ID Extension Package Version Category License Language
2880 pg_disorder pg_disorder 0.1.0 FEAT PostgreSQL C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--sL--- No Yes Yes No no no
Headless loadable module with no control file and no CREATE EXTENSION step; intended only for test databases; load per session with session_preload_libraries and never enable globally in production.

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT PIGSTY 0.1.0 18 17 16 15 14 pg_disorder -
RPM PIGSTY 0.1.0 18 17 16 15 14 pg_disorder_$v -
DEB PIGSTY 0.1.0 18 17 16 15 14 postgresql-$v-pg-disorder -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0
el8.aarch64 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0
el9.x86_64 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0
el9.aarch64 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0
el10.x86_64 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0
el10.aarch64 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0
d12.x86_64 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0
d12.aarch64 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0
d13.x86_64 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0
d13.aarch64 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0
u22.x86_64 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0
u22.aarch64 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0
u24.x86_64 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0
u24.aarch64 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0
u26.x86_64 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0
u26.aarch64 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0 PIGSTY 0.1.0
Package Version OS ORG SIZE File URL
pg_disorder_18 0.1.0 el8.x86_64 pigsty 18.7 KiB pg_disorder_18-0.1.0-1PIGSTY.el8.x86_64.rpm
pg_disorder_18 0.1.0 el8.aarch64 pigsty 18.8 KiB pg_disorder_18-0.1.0-1PIGSTY.el8.aarch64.rpm
pg_disorder_18 0.1.0 el9.x86_64 pigsty 18.7 KiB pg_disorder_18-0.1.0-1PIGSTY.el9.x86_64.rpm
pg_disorder_18 0.1.0 el9.aarch64 pigsty 18.7 KiB pg_disorder_18-0.1.0-1PIGSTY.el9.aarch64.rpm
pg_disorder_18 0.1.0 el10.x86_64 pigsty 18.7 KiB pg_disorder_18-0.1.0-1PIGSTY.el10.x86_64.rpm
pg_disorder_18 0.1.0 el10.aarch64 pigsty 18.9 KiB pg_disorder_18-0.1.0-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-disorder 0.1.0 d12.x86_64 pigsty 21.3 KiB postgresql-18-pg-disorder_0.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-disorder 0.1.0 d12.aarch64 pigsty 21.0 KiB postgresql-18-pg-disorder_0.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-disorder 0.1.0 d13.x86_64 pigsty 21.3 KiB postgresql-18-pg-disorder_0.1.0-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-disorder 0.1.0 d13.aarch64 pigsty 21.1 KiB postgresql-18-pg-disorder_0.1.0-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-disorder 0.1.0 u22.x86_64 pigsty 22.2 KiB postgresql-18-pg-disorder_0.1.0-1PIGSTY~jammy_amd64.deb
postgresql-18-pg-disorder 0.1.0 u22.aarch64 pigsty 22.0 KiB postgresql-18-pg-disorder_0.1.0-1PIGSTY~jammy_arm64.deb
postgresql-18-pg-disorder 0.1.0 u24.x86_64 pigsty 22.2 KiB postgresql-18-pg-disorder_0.1.0-1PIGSTY~noble_amd64.deb
postgresql-18-pg-disorder 0.1.0 u24.aarch64 pigsty 21.9 KiB postgresql-18-pg-disorder_0.1.0-1PIGSTY~noble_arm64.deb
postgresql-18-pg-disorder 0.1.0 u26.x86_64 pigsty 22.1 KiB postgresql-18-pg-disorder_0.1.0-1PIGSTY~resolute_amd64.deb
postgresql-18-pg-disorder 0.1.0 u26.aarch64 pigsty 21.8 KiB postgresql-18-pg-disorder_0.1.0-1PIGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_disorder_17 0.1.0 el8.x86_64 pigsty 18.7 KiB pg_disorder_17-0.1.0-1PIGSTY.el8.x86_64.rpm
pg_disorder_17 0.1.0 el8.aarch64 pigsty 18.8 KiB pg_disorder_17-0.1.0-1PIGSTY.el8.aarch64.rpm
pg_disorder_17 0.1.0 el9.x86_64 pigsty 18.7 KiB pg_disorder_17-0.1.0-1PIGSTY.el9.x86_64.rpm
pg_disorder_17 0.1.0 el9.aarch64 pigsty 18.7 KiB pg_disorder_17-0.1.0-1PIGSTY.el9.aarch64.rpm
pg_disorder_17 0.1.0 el10.x86_64 pigsty 18.7 KiB pg_disorder_17-0.1.0-1PIGSTY.el10.x86_64.rpm
pg_disorder_17 0.1.0 el10.aarch64 pigsty 18.9 KiB pg_disorder_17-0.1.0-1PIGSTY.el10.aarch64.rpm
postgresql-17-pg-disorder 0.1.0 d12.x86_64 pigsty 21.2 KiB postgresql-17-pg-disorder_0.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-17-pg-disorder 0.1.0 d12.aarch64 pigsty 21.0 KiB postgresql-17-pg-disorder_0.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-17-pg-disorder 0.1.0 d13.x86_64 pigsty 21.2 KiB postgresql-17-pg-disorder_0.1.0-1PIGSTY~trixie_amd64.deb
postgresql-17-pg-disorder 0.1.0 d13.aarch64 pigsty 21.1 KiB postgresql-17-pg-disorder_0.1.0-1PIGSTY~trixie_arm64.deb
postgresql-17-pg-disorder 0.1.0 u22.x86_64 pigsty 25.0 KiB postgresql-17-pg-disorder_0.1.0-1PIGSTY~jammy_amd64.deb
postgresql-17-pg-disorder 0.1.0 u22.aarch64 pigsty 24.7 KiB postgresql-17-pg-disorder_0.1.0-1PIGSTY~jammy_arm64.deb
postgresql-17-pg-disorder 0.1.0 u24.x86_64 pigsty 22.0 KiB postgresql-17-pg-disorder_0.1.0-1PIGSTY~noble_amd64.deb
postgresql-17-pg-disorder 0.1.0 u24.aarch64 pigsty 21.9 KiB postgresql-17-pg-disorder_0.1.0-1PIGSTY~noble_arm64.deb
postgresql-17-pg-disorder 0.1.0 u26.x86_64 pigsty 22.2 KiB postgresql-17-pg-disorder_0.1.0-1PIGSTY~resolute_amd64.deb
postgresql-17-pg-disorder 0.1.0 u26.aarch64 pigsty 21.8 KiB postgresql-17-pg-disorder_0.1.0-1PIGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_disorder_16 0.1.0 el8.x86_64 pigsty 18.8 KiB pg_disorder_16-0.1.0-1PIGSTY.el8.x86_64.rpm
pg_disorder_16 0.1.0 el8.aarch64 pigsty 18.8 KiB pg_disorder_16-0.1.0-1PIGSTY.el8.aarch64.rpm
pg_disorder_16 0.1.0 el9.x86_64 pigsty 18.8 KiB pg_disorder_16-0.1.0-1PIGSTY.el9.x86_64.rpm
pg_disorder_16 0.1.0 el9.aarch64 pigsty 18.9 KiB pg_disorder_16-0.1.0-1PIGSTY.el9.aarch64.rpm
pg_disorder_16 0.1.0 el10.x86_64 pigsty 18.8 KiB pg_disorder_16-0.1.0-1PIGSTY.el10.x86_64.rpm
pg_disorder_16 0.1.0 el10.aarch64 pigsty 19.0 KiB pg_disorder_16-0.1.0-1PIGSTY.el10.aarch64.rpm
postgresql-16-pg-disorder 0.1.0 d12.x86_64 pigsty 21.3 KiB postgresql-16-pg-disorder_0.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-16-pg-disorder 0.1.0 d12.aarch64 pigsty 21.2 KiB postgresql-16-pg-disorder_0.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-16-pg-disorder 0.1.0 d13.x86_64 pigsty 21.3 KiB postgresql-16-pg-disorder_0.1.0-1PIGSTY~trixie_amd64.deb
postgresql-16-pg-disorder 0.1.0 d13.aarch64 pigsty 21.2 KiB postgresql-16-pg-disorder_0.1.0-1PIGSTY~trixie_arm64.deb
postgresql-16-pg-disorder 0.1.0 u22.x86_64 pigsty 25.1 KiB postgresql-16-pg-disorder_0.1.0-1PIGSTY~jammy_amd64.deb
postgresql-16-pg-disorder 0.1.0 u22.aarch64 pigsty 24.8 KiB postgresql-16-pg-disorder_0.1.0-1PIGSTY~jammy_arm64.deb
postgresql-16-pg-disorder 0.1.0 u24.x86_64 pigsty 22.2 KiB postgresql-16-pg-disorder_0.1.0-1PIGSTY~noble_amd64.deb
postgresql-16-pg-disorder 0.1.0 u24.aarch64 pigsty 22.1 KiB postgresql-16-pg-disorder_0.1.0-1PIGSTY~noble_arm64.deb
postgresql-16-pg-disorder 0.1.0 u26.x86_64 pigsty 22.3 KiB postgresql-16-pg-disorder_0.1.0-1PIGSTY~resolute_amd64.deb
postgresql-16-pg-disorder 0.1.0 u26.aarch64 pigsty 21.9 KiB postgresql-16-pg-disorder_0.1.0-1PIGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_disorder_15 0.1.0 el8.x86_64 pigsty 18.7 KiB pg_disorder_15-0.1.0-1PIGSTY.el8.x86_64.rpm
pg_disorder_15 0.1.0 el8.aarch64 pigsty 18.8 KiB pg_disorder_15-0.1.0-1PIGSTY.el8.aarch64.rpm
pg_disorder_15 0.1.0 el9.x86_64 pigsty 18.8 KiB pg_disorder_15-0.1.0-1PIGSTY.el9.x86_64.rpm
pg_disorder_15 0.1.0 el9.aarch64 pigsty 18.8 KiB pg_disorder_15-0.1.0-1PIGSTY.el9.aarch64.rpm
pg_disorder_15 0.1.0 el10.x86_64 pigsty 18.8 KiB pg_disorder_15-0.1.0-1PIGSTY.el10.x86_64.rpm
pg_disorder_15 0.1.0 el10.aarch64 pigsty 19.0 KiB pg_disorder_15-0.1.0-1PIGSTY.el10.aarch64.rpm
postgresql-15-pg-disorder 0.1.0 d12.x86_64 pigsty 21.3 KiB postgresql-15-pg-disorder_0.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-15-pg-disorder 0.1.0 d12.aarch64 pigsty 21.2 KiB postgresql-15-pg-disorder_0.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-15-pg-disorder 0.1.0 d13.x86_64 pigsty 21.3 KiB postgresql-15-pg-disorder_0.1.0-1PIGSTY~trixie_amd64.deb
postgresql-15-pg-disorder 0.1.0 d13.aarch64 pigsty 21.2 KiB postgresql-15-pg-disorder_0.1.0-1PIGSTY~trixie_arm64.deb
postgresql-15-pg-disorder 0.1.0 u22.x86_64 pigsty 25.1 KiB postgresql-15-pg-disorder_0.1.0-1PIGSTY~jammy_amd64.deb
postgresql-15-pg-disorder 0.1.0 u22.aarch64 pigsty 24.8 KiB postgresql-15-pg-disorder_0.1.0-1PIGSTY~jammy_arm64.deb
postgresql-15-pg-disorder 0.1.0 u24.x86_64 pigsty 22.2 KiB postgresql-15-pg-disorder_0.1.0-1PIGSTY~noble_amd64.deb
postgresql-15-pg-disorder 0.1.0 u24.aarch64 pigsty 22.1 KiB postgresql-15-pg-disorder_0.1.0-1PIGSTY~noble_arm64.deb
postgresql-15-pg-disorder 0.1.0 u26.x86_64 pigsty 22.3 KiB postgresql-15-pg-disorder_0.1.0-1PIGSTY~resolute_amd64.deb
postgresql-15-pg-disorder 0.1.0 u26.aarch64 pigsty 22.0 KiB postgresql-15-pg-disorder_0.1.0-1PIGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_disorder_14 0.1.0 el8.x86_64 pigsty 18.7 KiB pg_disorder_14-0.1.0-1PIGSTY.el8.x86_64.rpm
pg_disorder_14 0.1.0 el8.aarch64 pigsty 18.8 KiB pg_disorder_14-0.1.0-1PIGSTY.el8.aarch64.rpm
pg_disorder_14 0.1.0 el9.x86_64 pigsty 18.8 KiB pg_disorder_14-0.1.0-1PIGSTY.el9.x86_64.rpm
pg_disorder_14 0.1.0 el9.aarch64 pigsty 18.8 KiB pg_disorder_14-0.1.0-1PIGSTY.el9.aarch64.rpm
pg_disorder_14 0.1.0 el10.x86_64 pigsty 18.8 KiB pg_disorder_14-0.1.0-1PIGSTY.el10.x86_64.rpm
pg_disorder_14 0.1.0 el10.aarch64 pigsty 19.0 KiB pg_disorder_14-0.1.0-1PIGSTY.el10.aarch64.rpm
postgresql-14-pg-disorder 0.1.0 d12.x86_64 pigsty 21.3 KiB postgresql-14-pg-disorder_0.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-14-pg-disorder 0.1.0 d12.aarch64 pigsty 21.1 KiB postgresql-14-pg-disorder_0.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-14-pg-disorder 0.1.0 d13.x86_64 pigsty 21.3 KiB postgresql-14-pg-disorder_0.1.0-1PIGSTY~trixie_amd64.deb
postgresql-14-pg-disorder 0.1.0 d13.aarch64 pigsty 21.2 KiB postgresql-14-pg-disorder_0.1.0-1PIGSTY~trixie_arm64.deb
postgresql-14-pg-disorder 0.1.0 u22.x86_64 pigsty 25.1 KiB postgresql-14-pg-disorder_0.1.0-1PIGSTY~jammy_amd64.deb
postgresql-14-pg-disorder 0.1.0 u22.aarch64 pigsty 24.7 KiB postgresql-14-pg-disorder_0.1.0-1PIGSTY~jammy_arm64.deb
postgresql-14-pg-disorder 0.1.0 u24.x86_64 pigsty 22.2 KiB postgresql-14-pg-disorder_0.1.0-1PIGSTY~noble_amd64.deb
postgresql-14-pg-disorder 0.1.0 u24.aarch64 pigsty 22.1 KiB postgresql-14-pg-disorder_0.1.0-1PIGSTY~noble_arm64.deb
postgresql-14-pg-disorder 0.1.0 u26.x86_64 pigsty 22.3 KiB postgresql-14-pg-disorder_0.1.0-1PIGSTY~resolute_amd64.deb
postgresql-14-pg-disorder 0.1.0 u26.aarch64 pigsty 21.9 KiB postgresql-14-pg-disorder_0.1.0-1PIGSTY~resolute_arm64.deb

Source

pig build pkg pg_disorder;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_disorder;		# install via package name, for the active PG version

pig install pg_disorder -v 18;   # install for PG 18
pig install pg_disorder -v 17;   # install for PG 17
pig install pg_disorder -v 16;   # install for PG 16
pig install pg_disorder -v 15;   # install for PG 15
pig install pg_disorder -v 14;   # install for PG 14

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pg_disorder';

This extension does not need CREATE EXTENSION DDL command

Usage

Sources:

pg_disorder is a test-only PostgreSQL loadable module that deliberately changes the output order of eligible SELECT queries. It helps find applications and tests that accidentally depend on unspecified row order. It is a headless module: there is no control file, SQL install script, or CREATE EXTENSION pg_disorder step.

Enable It for a Test Database

Load the module at session start so its planner hook is available:

ALTER DATABASE regression_db
  SET session_preload_libraries = 'pg_disorder';

ALTER DATABASE regression_db
  SET pg_disorder.mode = 'reverse';

Reconnect after changing session_preload_libraries. Do not add this module to a production-wide shared_preload_libraries setting.

Modes

SET pg_disorder.mode = 'off';
SET pg_disorder.mode = 'reverse';
SET pg_disorder.mode = 'shuffle';
SET pg_disorder.seed = 42;
SET pg_disorder.force_serial = on;
  • off leaves plans unchanged.
  • reverse deterministically reverses eligible output.
  • shuffle produces a deterministic permutation for a fixed session seed, submitted query text, and plan. With the default seed of zero, each session first chooses and logs a random seed.
  • force_serial suppresses parallel plans to make disorder tests reproducible.

Always fix a failing query by adding a semantically correct ORDER BY; do not encode the accidental order observed under off.

Eligibility and Caveats

The hook targets top-level SELECT statements without ORDER BY. It deliberately skips query shapes where reordering is unsafe or changes SQL semantics, including aggregates, grouping, DISTINCT, set operations, window functions, recursive queries, row locks, and queries without a FROM relation.

  • pg_disorder is fault-injection tooling, not a production query feature.
  • Passing a disorder run does not prove every unordered query is safe; excluded query shapes and planner paths are not rewritten.
  • The package installs a server module only. Verify enablement with the GUCs or module load state, not pg_extension.