# RTE-03: valid rows and conflicting prices

This public synthetic PostgreSQL example separates scoped references, row
identity, endpoint order, and cross-row matching. It is not a migration or a
copy of the private engine. The teaching example is independently usable;
it contains no unpublished article text or private research.

With `psql` connected to a disposable PostgreSQL database, run:

```sh
psql -X --set ON_ERROR_STOP=1 --file integrity.sql
```

Connection options can be supplied through normal `psql` flags or PostgreSQL
environment variables. Use a database where creating temporary tables and
functions is permitted. The example creates no extensions or permanent objects,
uses no application data, bounds statement and lock waits, and rolls back at the
end. Closing the connection also removes session-temporary objects on failure.
Tested with PostgreSQL 18.6.

Expected results:

- wrong-owner references fail with SQLSTATE `23503`;
- duplicate row codes and sequences fail with `23505`;
- a missing owner fails with `23502`;
- identical codes in different books remain valid;
- the baseline accepts a reversed range;
- adding an endpoint-order check rejects that range with `23514`;
- two individually valid rows still match a weight of 4.5 kg;
- closed intervals share a boundary while half-open intervals do not;
- the final message says `All integrity demonstrations passed`.

The check added midway is a demonstration of an alternative, not an assertion
that the historical engine used that constraint. The example does not implement
its publication policy, currencies, unit conversion, row-family signatures,
precedence, or concurrency protocol. It makes no performance claim.
