Re: [Patch] New psql prompt substitution %r (m = master, r = replica)

Поиск
Список
Период
Сортировка
От Aleksander Alekseev
Тема Re: [Patch] New psql prompt substitution %r (m = master, r = replica)
Дата
Msg-id 20160818152917.1ad3108e@e733
обсуждение исходный текст
Ответ на Re: [Patch] New psql prompt substitution %r (m = master, r = replica)  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Ответы Re: [Patch] New psql prompt substitution %r (m = master, r = replica)  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-hackers
Hello, Alvaro.

> ... this is terrible.  Not only because it's a lot of code dependent
> on an external tool which will be rather heavyhanded for something
> that should probably be very lightweight, but also because the code
> itself is (no offense) an unreadable mess.
> 
> I think your general idea for the feature is a good one, even if the
> patch you submitted isn't a good implementation.  Not sure a real one
> is worth the effort, though.  I don't think Peter's comment that more
> roles than master/replica are possible is a showstopper: that's
> already going to be an issue for things like ALTER TRIGGER ENABLE
> REPLICA and the like, I suppose.

Thank you for sharing your thoughts on this!

Peter has a good point that in general case it's more complicated than
just master or replica. I also agree with David that what actually
would be nice to have is a some syntax that allows user to execute
arbitrary commands before displaying a prompt. This way user could
display any information he or she wants, in any format. As we can see
it's quite doable now but probably too complicated and ugly.

Still I don't think that many users have a problem discussed in this
thread, i.e. updating a prompt on the fly. Probably introducing a new
syntax (I personally don't even have a good idea how exactly it should
look like), not mentioning implementing and supporting it, doesn't
worth an effort. Maybe there is a simpler way.

Let's say we introduce a new variable EXPORT_CONNECTION_STRING. When
this variable is true, psql sets PSQL_CONNECTION_STRING environment
variable for every child process it creates. Naturally psql itself
checks this environment variable and if it's specified uses
corresponding connection string.

In this case user could extend prompt string quite easily like this:

```
\set EXPORT_CONNECTION_STRING true
\set PROMPT1 '%`psql ~/.psql_prompt_script`> =#'
```

Basically it does the same I did using Python and Bash aliases but in
much simpler and clean way.

What do you think about such approach?

-- 
Best regards,
Aleksander Alekseev



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: Password identifiers, protocol aging and SCRAM protocol
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: Password identifiers, protocol aging and SCRAM protocol