Summary
Add a psql prompt escape %o that shows whether the current session is in
Oracle compatibility mode. It expands to [ORA] when
ivorysql.compatible_mode = 'oracle', and to empty otherwise.
Motivation
When using psql interactively there is no easy way to tell whether the session
is in Oracle compatibility mode, which makes it easy to misjudge SQL behavior.
Proposed behavior
- New prompt escape
%o in both prompt.c and ora_prompt.c.
- Reads the value via
PQparameterStatus("ivorysql.compatible_mode"), so it
reflects in-session SET changes in real time.
- Requires marking
ivorysql.compatible_mode as GUC_REPORT in the backend so
the server pushes value changes to the client.
- Off by default (default prompt unchanged); opt-in via:
\set PROMPT1 '%o%/%R%x%# '
Example
ivorysql=# -- pg mode
[ORA]ivorysql=# -- oracle mode (prefix tracks SET in real time)
Notes / risks
- Prompts are interactive-only → scripts/CI/pg_regress unaffected.
- Default behavior unchanged; existing prompt-parsing tools unaffected unless
the user opts in (and even then only the prefix changes, not the =# suffix).
- Behind a connection pooler (e.g. PgBouncer), %o may not track SET unless
the parameter is included (e.g. track_extra_parameters).
- Requires server recompile + restart for GUC_REPORT to take effect; against
an older server %o safely degrades to empty.
psql-oracle-mode-prompt.en.md
Summary
Add a psql prompt escape
%othat shows whether the current session is inOracle compatibility mode. It expands to
[ORA]whenivorysql.compatible_mode = 'oracle', and to empty otherwise.Motivation
When using psql interactively there is no easy way to tell whether the session
is in Oracle compatibility mode, which makes it easy to misjudge SQL behavior.
Proposed behavior
%oin bothprompt.candora_prompt.c.PQparameterStatus("ivorysql.compatible_mode"), so itreflects in-session
SETchanges in real time.ivorysql.compatible_modeasGUC_REPORTin the backend sothe server pushes value changes to the client.
Example
ivorysql=# -- pg mode
[ORA]ivorysql=# -- oracle mode (prefix tracks SET in real time)
Notes / risks
the user opts in (and even then only the prefix changes, not the =# suffix).
the parameter is included (e.g. track_extra_parameters).
an older server %o safely degrades to empty.
psql-oracle-mode-prompt.en.md