Skip to content

Add a safeguard that nothing in test/* sets/mutates search_path #66

Description

@jnasbyupgrade

Problem

The entire point of testing with TEST_SCHEMA empty (PR #54) is to prove cat_tools
works correctly when it is NOT on search_path at all — i.e. every reference to a
cat_tools object inside the extension's own SQL is fully schema-qualified, with no
reliance on search_path resolution. But nothing currently stops a test file itself from
quietly setting/mutating search_path (e.g. a stray SET search_path = ... added to
some test/sql/*.sql file for developer convenience while writing a test) — which would
silently defeat that guarantee: the empty-TEST_SCHEMA leg would keep passing even if
cat_tools itself secretly depended on search_path, because the test file quietly put the
right schema on search_path itself rather than cat_tools resolving it correctly on its
own.

What to add

A safeguard — hopefully as simple as a grep — that fails if anything under test/ sets
or otherwise mutates search_path (SET search_path, SET LOCAL search_path,
ALTER ROLE ... SET search_path, ALTER DATABASE ... SET search_path, etc.). Needs to
distinguish legitimate, deliberate search_path manipulation — test/install/load.sql's
own TEST_SCHEMA-targeting SET search_path from PR #54 is supposed to be there —
from anything else that shouldn't be. Where this should live (a make lint-style check,
a dedicated CI step, a pgTAP test) is open; whatever's easiest to grep reliably.

Why this matters now specifically

This wasn't a real risk before PR #54 existed — there was no leg proving "no search_path
at all" was ever actually being exercised. Now that the empty-TEST_SCHEMA leg is meant
to be that proof, a silent violator anywhere under test/ would make that leg pass for
the wrong reason.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions