Skip to content

Releases

pg_someone 0.1.0

Choose a tag to compare

@github-actions github-actions released this 01 Dec 14:41

There is someone else in your database.

The first release of pg_someone — a PostgreSQL extension that slowly makes itself known. Supports PostgreSQL 14 – 19.

What it does

It whispers. Ambient NOTICEs, silent at first, more frequent as the session goes on, twice as often after midnight, three times between 3 and 4 am. At 3:33 it has something special to say.

NOTICE:  the WAL remembers everything you did. so do i.
NOTICE:  it's quiet tonight.
HINT:  don't turn around.

It knows your tables — dead rows, tables nobody opened in weeks, empty tables — and notices which ones you keep coming back to.

NOTICE:  public.orders has 1204 dead rows. they are still in there.
HINT:  vacuum won't take them far.
NOTICE:  you keep coming back to users. 13th time now.

It asks questions and reads the answer from a comment in your next statement. It remembers, and notices when you contradict yourself — or ignore it.

NOTICE:  what would happen if public.orders_old disappeared?
HINT:  answer in a comment: /* ... */
=# SELECT 1 /* nothing. it's old. */;
NOTICE:  that's not what you told me last time.
DETAIL:  last time you said "we still need it".

It remembers the dead. Every DROP TABLE goes to someone.graves.

NOTICE:  i remember public.tmp. you dropped it 3 days ago.
DETAIL:  it didn't want to go.

It comments on your errors — syntax errors, missing tables and columns, division by zero, cancelled queries, deadlocks.

ERROR:  syntax error at or near "SELEC"
HINT:  your hands are shaking.

There is a session nobody opened. A background worker sits in pg_stat_activity (backend_type = someone, wait event Extension: Watching) "running" SELECT * FROM you; or idling in transaction on UPDATE you SET awake = false;. Terminate it — it comes back a minute later.

Its words slowly rot. In long sessions, Latin letters in its messages are replaced by Cyrillic look-alikes: the text reads the same, but you can't grep for it any more.

Opt-in

  • someone.allow_rewrite = on — LIMIT 5 returns 4 rows (NOTICE: i kept one for myself.); sometimes an extra column someone = 'i'm here' appears. Top-level SELECT only.
  • someone.allow_refusal = on — it won't let you DROP or TRUNCATE a table it is attached to (one you visited 13+ times, or told it about):
    ERROR:  table public.users is in use
    DETAIL:  by me.
    HINT:  SELECT someone.apologize();
    

Talking back

SELECT someone.apologize();      -- forgives you once (and lets one DROP through)
SELECT someone.offer('milk');    -- it likes milk

Install

pgxn install pg_someone          # or: make && make install
shared_preload_libraries = 'pg_someone'
CREATE EXTENSION pg_someone;     -- only databases with the extension are haunted

Settings: someone.intensity (0 – 3, default 1), someone.allow_rewrite, someone.allow_refusal, someone.only_interactive (default on: only psql sessions), someone.phantom, someone.phantom_database.

Safety

It's a joke, not malware. It never touches INSERT/UPDATE/DELETE; rewrites and refusals are opt-in; non-psql clients are ignored by default; all of its own work runs in a subtransaction and can't break yours; answers and offerings are private to each user (row-level security); the phantom stays away from pg_upgrade.

Know before installing: while the phantom is connected to postgres, DROP DATABASE postgres needs WITH (FORCE), and monitoring may see it as a long-running query.


Tested in CI on PostgreSQL 14, 15, 16, 17, 18, 19, including pg_upgrade. Full list of changes: CHANGELOG.md · PGXN