supabase / postgres

Unmodified Postgres with some useful plugins
https://supabase.com
PostgreSQL License
1.38k stars 139 forks source link

Sam/pgroonga deps #1105

Closed samrose closed 1 month ago

samrose commented 2 months ago

What kind of change does this PR introduce?

a comment on a PR https://github.com/supabase/postgres/pull/462#issuecomment-2270662752 reported that in our 15.6 release, TokenMecab was no longer working on the pgroonga extension.

This PR restores that Tokenizer capability to the proonga extension, and adds the following test below, which will run on every PR going forward.

-- File: 0005-test_pgroonga_revised.sql

begin;
    -- Plan for 3 tests: extension, table, and index
    select plan(3);

    -- Create the PGroonga extension
    create extension if not exists pgroonga;

    -- -- Test 1: Check if PGroonga extension exists
    select has_extension('pgroonga', 'The pgroonga extension should exist.');

    -- Create the table
    create table notes(
        id integer primary key,
        content text
    );

    -- Test 2: Check if the table was created
    SELECT has_table('public', 'notes', 'The notes table should exist.');    
    -- Create the PGroonga index
    CREATE INDEX pgroonga_content_index
            ON notes
         USING pgroonga (content)
          WITH (tokenizer='TokenMecab');

    -- -- Test 3: Check if the index was created
    SELECT has_index('public', 'notes', 'pgroonga_content_index', 'The pgroonga_content_index should exist.');

    -- -- Cleanup (this won't affect the test results as they've already been checked)
    DROP INDEX IF EXISTS pgroonga_content_index;
    DROP TABLE IF EXISTS notes;

    -- Finish the test plan
    select * from finish();
rollback;
olirice commented 1 month ago

@samrose lgtm, feel free to merge once the conflicts are resolved