Skip to content

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

IDExtensionPackageVersionCategoryLicenseLanguage
2880pg_disorderpg_disorder0.1.0FEATPostgreSQLC
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--sL---NoYesYesNonono
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

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY0.1.019 18 17 16 15pg_disorder-
RPMPIGSTY0.1.019 18 17 16 15pg_disorder_$v-
DEBPIGSTY0.1.019 18 17 16 15postgresql-$v-pg-disorder-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
el8.aarch64N/APIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
el9.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
el9.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
el10.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
el10.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
d12.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
d12.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
d13.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
d13.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u22.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u22.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u24.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u24.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u26.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u26.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
PackageVersionOSORGSIZEFile URL
pg_disorder_190.1.0el9.x86_64pigsty30.1 KiBpg_disorder_19-0.1.0-1PGSTY.el9.x86_64.rpm
pg_disorder_190.1.0el9.aarch64pigsty29.9 KiBpg_disorder_19-0.1.0-1PGSTY.el9.aarch64.rpm
pg_disorder_190.1.0el10.x86_64pigsty30.3 KiBpg_disorder_19-0.1.0-1PGSTY.el10.x86_64.rpm
pg_disorder_190.1.0el10.aarch64pigsty30.2 KiBpg_disorder_19-0.1.0-1PGSTY.el10.aarch64.rpm
postgresql-19-pg-disorder0.1.0d12.x86_64pigsty21.5 KiBpostgresql-19-pg-disorder_0.1.0-1PGSTY~bookworm_amd64.deb
postgresql-19-pg-disorder0.1.0d12.aarch64pigsty21.2 KiBpostgresql-19-pg-disorder_0.1.0-1PGSTY~bookworm_arm64.deb
postgresql-19-pg-disorder0.1.0d13.x86_64pigsty21.5 KiBpostgresql-19-pg-disorder_0.1.0-1PGSTY~trixie_amd64.deb
postgresql-19-pg-disorder0.1.0d13.aarch64pigsty21.3 KiBpostgresql-19-pg-disorder_0.1.0-1PGSTY~trixie_arm64.deb
postgresql-19-pg-disorder0.1.0u22.x86_64pigsty22.3 KiBpostgresql-19-pg-disorder_0.1.0-1PGSTY~jammy_amd64.deb
postgresql-19-pg-disorder0.1.0u22.aarch64pigsty22.2 KiBpostgresql-19-pg-disorder_0.1.0-1PGSTY~jammy_arm64.deb
postgresql-19-pg-disorder0.1.0u24.x86_64pigsty22.3 KiBpostgresql-19-pg-disorder_0.1.0-1PGSTY~noble_amd64.deb
postgresql-19-pg-disorder0.1.0u24.aarch64pigsty22.2 KiBpostgresql-19-pg-disorder_0.1.0-1PGSTY~noble_arm64.deb
postgresql-19-pg-disorder0.1.0u26.x86_64pigsty22.3 KiBpostgresql-19-pg-disorder_0.1.0-1PGSTY~resolute_amd64.deb
postgresql-19-pg-disorder0.1.0u26.aarch64pigsty22.0 KiBpostgresql-19-pg-disorder_0.1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_disorder_180.1.0el8.x86_64pigsty29.6 KiBpg_disorder_18-0.1.0-1PGSTY.el8.x86_64.rpm
pg_disorder_180.1.0el8.aarch64pigsty29.3 KiBpg_disorder_18-0.1.0-1PGSTY.el8.aarch64.rpm
pg_disorder_180.1.0el9.x86_64pigsty30.1 KiBpg_disorder_18-0.1.0-1PGSTY.el9.x86_64.rpm
pg_disorder_180.1.0el9.aarch64pigsty29.8 KiBpg_disorder_18-0.1.0-1PGSTY.el9.aarch64.rpm
pg_disorder_180.1.0el10.x86_64pigsty30.3 KiBpg_disorder_18-0.1.0-1PGSTY.el10.x86_64.rpm
pg_disorder_180.1.0el10.aarch64pigsty30.1 KiBpg_disorder_18-0.1.0-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-disorder0.1.0d12.x86_64pigsty21.4 KiBpostgresql-18-pg-disorder_0.1.0-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-disorder0.1.0d12.aarch64pigsty21.2 KiBpostgresql-18-pg-disorder_0.1.0-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-disorder0.1.0d13.x86_64pigsty21.5 KiBpostgresql-18-pg-disorder_0.1.0-1PGSTY~trixie_amd64.deb
postgresql-18-pg-disorder0.1.0d13.aarch64pigsty21.2 KiBpostgresql-18-pg-disorder_0.1.0-1PGSTY~trixie_arm64.deb
postgresql-18-pg-disorder0.1.0u22.x86_64pigsty22.3 KiBpostgresql-18-pg-disorder_0.1.0-1PGSTY~jammy_amd64.deb
postgresql-18-pg-disorder0.1.0u22.aarch64pigsty22.2 KiBpostgresql-18-pg-disorder_0.1.0-1PGSTY~jammy_arm64.deb
postgresql-18-pg-disorder0.1.0u24.x86_64pigsty22.3 KiBpostgresql-18-pg-disorder_0.1.0-1PGSTY~noble_amd64.deb
postgresql-18-pg-disorder0.1.0u24.aarch64pigsty22.1 KiBpostgresql-18-pg-disorder_0.1.0-1PGSTY~noble_arm64.deb
postgresql-18-pg-disorder0.1.0u26.x86_64pigsty22.3 KiBpostgresql-18-pg-disorder_0.1.0-1PGSTY~resolute_amd64.deb
postgresql-18-pg-disorder0.1.0u26.aarch64pigsty22.0 KiBpostgresql-18-pg-disorder_0.1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_disorder_170.1.0el8.x86_64pigsty29.6 KiBpg_disorder_17-0.1.0-1PGSTY.el8.x86_64.rpm
pg_disorder_170.1.0el8.aarch64pigsty29.4 KiBpg_disorder_17-0.1.0-1PGSTY.el8.aarch64.rpm
pg_disorder_170.1.0el9.x86_64pigsty30.3 KiBpg_disorder_17-0.1.0-1PGSTY.el9.x86_64.rpm
pg_disorder_170.1.0el9.aarch64pigsty29.8 KiBpg_disorder_17-0.1.0-1PGSTY.el9.aarch64.rpm
pg_disorder_170.1.0el10.x86_64pigsty30.3 KiBpg_disorder_17-0.1.0-1PGSTY.el10.x86_64.rpm
pg_disorder_170.1.0el10.aarch64pigsty30.2 KiBpg_disorder_17-0.1.0-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-disorder0.1.0d12.x86_64pigsty21.3 KiBpostgresql-17-pg-disorder_0.1.0-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-disorder0.1.0d12.aarch64pigsty21.2 KiBpostgresql-17-pg-disorder_0.1.0-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-disorder0.1.0d13.x86_64pigsty21.3 KiBpostgresql-17-pg-disorder_0.1.0-1PGSTY~trixie_amd64.deb
postgresql-17-pg-disorder0.1.0d13.aarch64pigsty21.2 KiBpostgresql-17-pg-disorder_0.1.0-1PGSTY~trixie_arm64.deb
postgresql-17-pg-disorder0.1.0u22.x86_64pigsty25.2 KiBpostgresql-17-pg-disorder_0.1.0-1PGSTY~jammy_amd64.deb
postgresql-17-pg-disorder0.1.0u22.aarch64pigsty24.8 KiBpostgresql-17-pg-disorder_0.1.0-1PGSTY~jammy_arm64.deb
postgresql-17-pg-disorder0.1.0u24.x86_64pigsty22.2 KiBpostgresql-17-pg-disorder_0.1.0-1PGSTY~noble_amd64.deb
postgresql-17-pg-disorder0.1.0u24.aarch64pigsty22.1 KiBpostgresql-17-pg-disorder_0.1.0-1PGSTY~noble_arm64.deb
postgresql-17-pg-disorder0.1.0u26.x86_64pigsty22.3 KiBpostgresql-17-pg-disorder_0.1.0-1PGSTY~resolute_amd64.deb
postgresql-17-pg-disorder0.1.0u26.aarch64pigsty22.0 KiBpostgresql-17-pg-disorder_0.1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_disorder_160.1.0el8.x86_64pigsty29.7 KiBpg_disorder_16-0.1.0-1PGSTY.el8.x86_64.rpm
pg_disorder_160.1.0el8.aarch64pigsty29.5 KiBpg_disorder_16-0.1.0-1PGSTY.el8.aarch64.rpm
pg_disorder_160.1.0el9.x86_64pigsty30.4 KiBpg_disorder_16-0.1.0-1PGSTY.el9.x86_64.rpm
pg_disorder_160.1.0el9.aarch64pigsty30.0 KiBpg_disorder_16-0.1.0-1PGSTY.el9.aarch64.rpm
pg_disorder_160.1.0el10.x86_64pigsty30.4 KiBpg_disorder_16-0.1.0-1PGSTY.el10.x86_64.rpm
pg_disorder_160.1.0el10.aarch64pigsty30.3 KiBpg_disorder_16-0.1.0-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-disorder0.1.0d12.x86_64pigsty21.4 KiBpostgresql-16-pg-disorder_0.1.0-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-disorder0.1.0d12.aarch64pigsty21.3 KiBpostgresql-16-pg-disorder_0.1.0-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-disorder0.1.0d13.x86_64pigsty21.4 KiBpostgresql-16-pg-disorder_0.1.0-1PGSTY~trixie_amd64.deb
postgresql-16-pg-disorder0.1.0d13.aarch64pigsty21.4 KiBpostgresql-16-pg-disorder_0.1.0-1PGSTY~trixie_arm64.deb
postgresql-16-pg-disorder0.1.0u22.x86_64pigsty25.2 KiBpostgresql-16-pg-disorder_0.1.0-1PGSTY~jammy_amd64.deb
postgresql-16-pg-disorder0.1.0u22.aarch64pigsty24.9 KiBpostgresql-16-pg-disorder_0.1.0-1PGSTY~jammy_arm64.deb
postgresql-16-pg-disorder0.1.0u24.x86_64pigsty22.3 KiBpostgresql-16-pg-disorder_0.1.0-1PGSTY~noble_amd64.deb
postgresql-16-pg-disorder0.1.0u24.aarch64pigsty22.2 KiBpostgresql-16-pg-disorder_0.1.0-1PGSTY~noble_arm64.deb
postgresql-16-pg-disorder0.1.0u26.x86_64pigsty22.5 KiBpostgresql-16-pg-disorder_0.1.0-1PGSTY~resolute_amd64.deb
postgresql-16-pg-disorder0.1.0u26.aarch64pigsty22.1 KiBpostgresql-16-pg-disorder_0.1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_disorder_150.1.0el8.x86_64pigsty29.7 KiBpg_disorder_15-0.1.0-1PGSTY.el8.x86_64.rpm
pg_disorder_150.1.0el8.aarch64pigsty29.5 KiBpg_disorder_15-0.1.0-1PGSTY.el8.aarch64.rpm
pg_disorder_150.1.0el9.x86_64pigsty30.4 KiBpg_disorder_15-0.1.0-1PGSTY.el9.x86_64.rpm
pg_disorder_150.1.0el9.aarch64pigsty30.0 KiBpg_disorder_15-0.1.0-1PGSTY.el9.aarch64.rpm
pg_disorder_150.1.0el10.x86_64pigsty30.4 KiBpg_disorder_15-0.1.0-1PGSTY.el10.x86_64.rpm
pg_disorder_150.1.0el10.aarch64pigsty30.3 KiBpg_disorder_15-0.1.0-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-disorder0.1.0d12.x86_64pigsty21.4 KiBpostgresql-15-pg-disorder_0.1.0-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-disorder0.1.0d12.aarch64pigsty21.3 KiBpostgresql-15-pg-disorder_0.1.0-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-disorder0.1.0d13.x86_64pigsty21.4 KiBpostgresql-15-pg-disorder_0.1.0-1PGSTY~trixie_amd64.deb
postgresql-15-pg-disorder0.1.0d13.aarch64pigsty21.4 KiBpostgresql-15-pg-disorder_0.1.0-1PGSTY~trixie_arm64.deb
postgresql-15-pg-disorder0.1.0u22.x86_64pigsty25.2 KiBpostgresql-15-pg-disorder_0.1.0-1PGSTY~jammy_amd64.deb
postgresql-15-pg-disorder0.1.0u22.aarch64pigsty24.9 KiBpostgresql-15-pg-disorder_0.1.0-1PGSTY~jammy_arm64.deb
postgresql-15-pg-disorder0.1.0u24.x86_64pigsty22.3 KiBpostgresql-15-pg-disorder_0.1.0-1PGSTY~noble_amd64.deb
postgresql-15-pg-disorder0.1.0u24.aarch64pigsty22.3 KiBpostgresql-15-pg-disorder_0.1.0-1PGSTY~noble_arm64.deb
postgresql-15-pg-disorder0.1.0u26.x86_64pigsty22.5 KiBpostgresql-15-pg-disorder_0.1.0-1PGSTY~resolute_amd64.deb
postgresql-15-pg-disorder0.1.0u26.aarch64pigsty22.1 KiBpostgresql-15-pg-disorder_0.1.0-1PGSTY~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 by package name

pig install pg_disorder -v 19;   # install for PG 19
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

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.

Table reader