> > In the varlistentry, I suggest we add "This variable is unset when the > > connection is lost." after "but can be changed or unset. > > Personally I'd much rather have BACKEND_PID set to 0 rather than being unset > when not connected. For one thing it allows safely using \if :BACKEND_PID.
Oops it turns out that was wishful thinking from me. \if does not interpret a non-zero integer as true, except for the value "1". I'd still prefer BACKEND_PID being 0 when not connected, though.
I think psql never tries to execute a query if the engine is not connected, so for usage in queries undefined state is not important - it will be always defined.
for using in \if is unset may be a better state, because you can try to use {? varname} syntax.
0 is theoretically valid process id number, so I am not sure if 0 is ok. I don't know if some numbers can be used like invalid process id?