Re: Controlling complexity in queries
| От | Harald Fuchs |
|---|---|
| Тема | Re: Controlling complexity in queries |
| Дата | |
| Msg-id | 86ty52xjk2.fsf@protecting.net обсуждение исходный текст |
| Ответ на | Controlling complexity in queries (Robert James <srobertjames@gmail.com>) |
| Ответы |
Re: Controlling complexity in queries
|
| Список | pgsql-general |
Jay Levitt <jay.levitt@gmail.com> writes:
> * You want contextual queries.
>
> (I guess this is a special case of "you need non relational features".)
>
> In my case, I want all queries against content to be filtered by their
> relevance to the current user. That can't go into a view, because
> views don't have parameters; I need a computed column that may be
> different every time I run the query, and depends on a piece of
> information (the current user ID) that Postgres can't know.
How about the following:
CREATE TABLE test1 (
id serial NOT NULL,
username text NOT NULL,
value text NOT NULL,
PRIMARY KEY (id)
);
COPY test1 (username, value) FROM stdin DELIMITER '|';
user1|user1_1
user1|user1_2
user2|user2_1
user2|user2_2
user2|user2_3
\.
CREATE VIEW test1v AS
SELECT id, username, value
FROM test1
WHERE username = current_user;
Here the result of "SELECT * FROM test1v" depends on who issued the query.
В списке pgsql-general по дате отправления: