Skip to content

db advisors fails for local projects with custom ports and multi-statement lint SQL #4965

@jsj

Description

@jsj

supabase db advisors fails when executing the embedded local lint SQL.

Tagging @Rodriguespn since the original advisors implementation came from commit 43ce0a6a.

Repro

Run the command against a local database with an explicit Postgres URL:

go run . db advisors --db-url 'postgresql://postgres:postgres@127.0.0.1:55322/postgres?sslmode=disable' --debug

Actual Behavior

The command connects successfully, starts a transaction, and then fails when executing the embedded lint SQL:

ERROR: cannot insert multiple commands into a prepared statement (SQLSTATE 42601)

The debug trace points at internal/db/advisors/advisors.go in the tx.Query(ctx, lintsSQL) path.

Root Cause

lintsSQL begins with a separate session statement:

set local search_path = '';

That setup statement and the actual lint query are bundled together and sent through the prepared-statement path, which Postgres rejects.

Expected Behavior

supabase db advisors should execute the session setup and the lint query successfully against a local database.

Suggested Fix

Split the session setup from the lint query, for example:

  1. tx.Exec(ctx, "set local search_path = ''")
  2. tx.Query(ctx, <remaining lint query>)

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