I want to use stored generated column to create a separate tsvector column to hold the output of to_tsvector. The config name for the ts_vector is stored in the separate column language_field
. Similarly to sql for creating ts_vector index I thought that using column name for the ts_vector config can be possible. But I got an error [42P17] ERROR: generation expression is not immutable
Here is the code which I use:
ALTER TABLE table_name
ADD COLUMN textsearchable_index_col tsvector
GENERATED ALWAYS AS (
to_tsvector("table_name"."language_field"::regconfig, COALESCE("table_name"."name", ''))
) STORED;
Is it possible to use column name as a vector config in the stored generated column?
If I explicitly set config name during column generation (to_tsvector('english', coalesce("table_name"."name", '')
) and then the text in the "table_name"."name"
will change to some other language different from english
does it mean that I need to recreate generated column with another config name? If so, maybe you can suggest possible workarounds / solutions.