Skip to content

Invalid function_search_path_mutable lint warning for aggregates #139

@WolfspiritM

Description

@WolfspiritM

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When creating an aggregate it shows a lint warning regarding
https://supabase.com/docs/guides/database/database-advisors?queryGroups=lint&lint=0011_function_search_path_mutable
even so aggregates don't have a search path.

To Reproduce

Create this aggregate in supabase:

-- Create a function to compare MIN uuid
CREATE OR REPLACE FUNCTION private.uuid_min(uuid, uuid)
RETURNS uuid
set search_path = '' AS $$
BEGIN
    RETURN LEAST($1, $2);
END;
$$ LANGUAGE plpgsql IMMUTABLE STRICT;

-- Create optimized binary MIN aggregate
CREATE OR REPLACE AGGREGATE private.min(uuid) (
    SFUNC = private.uuid_min,
    STYPE = uuid,
    COMBINEFUNC = private.uuid_min,
    PARALLEL = SAFE,
    SORTOP = operator (<) -- Essential for index optimization
);

Open supabase dashboard and you'll get this warning:

Issue
Function private.min has a role mutable search_path

Description
Detects functions where the search_path parameter is not set.

Expected behavior

No warning as the function has search_path set to ''.

I think the linter should ignore functions with prolang referencing internal. In my case it's oid 12, but not sure if that can be hardcoded or should be joined from the pg_language table.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions