Aw: Re: Set COLLATE on a session level - Mailing list pgsql-general

From Karsten Hilbert
Subject Aw: Re: Set COLLATE on a session level
Date
Msg-id trinity-6d5962ef-1ffc-469d-91d2-c530c02e113d-1607177909245@3c-app-gmx-bap68
Whole thread Raw
In response to Re: Set COLLATE on a session level  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
List pgsql-general
> > Or a "smart" view. Set a session variable before running the
> > query and have the (one) view return the locale'd data based
> > on the session variable ...
> >
> >         set session "mika.current_locale" = 'locale@2_use';
> >
> > and use
> >
> >         select current_setting('mika.current_locale')
> >
> > as needed inside the view definition
>
> But the argument that follows COLLATE is an identifier, not a parameter,

ah, true enough

> so it must be hardcoded in the view, just like column names or table names.
> I don't see how you could use the setting to control the COLLATE clause
> through a view.

The view might produce its rows by calling a function which
in turn reads the setting and dynamically constructs and exexcutes
the query needed to produce the locale-dependant rows, no ?  =8-)

Convoluted ?  I guess so ...

Karsten



pgsql-general by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Set COLLATE on a session level
Next
From: "Daniel Verite"
Date:
Subject: Re: Set COLLATE on a session level