Aw: Re: Set COLLATE on a session level

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To:
Cc: "Pgsql-General(at)Lists(dot)Postgresql(dot)Org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Aw: Re: Set COLLATE on a session level
Date: 2020-12-05 14:18:29
Message-ID: trinity-6d5962ef-1ffc-469d-91d2-c530c02e113d-1607177909245@3c-app-gmx-bap68
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Verite 2020-12-05 14:31:05 Re: Set COLLATE on a session level
Previous Message Peter Eisentraut 2020-12-05 12:12:15 Re: Set COLLATE on a session level