Modify change to use a second 'open' column rather than range scans

If PostgreSQL's cluster was installed with lc_collate = 'en_US.UTF-8'
then "WHERE status >= 'a' AND status <= 'z'" returns both upper and
lowercase status values, effectively selecting the entire database.
This is because under the en_US sorting rules, 'a' and 'A' compare
as the same value, even though they have different byte values.

As a result, we shouldn't rely upon the sort orders of the database
cluster's character columns to provide efficient range scans based
on status fields.  Instead we should decompose the field into two;
using one field for the open/closed flag and another for the current
status value.

Signed-off-by: Shawn O. Pearce <sop@google.com>
5 files changed