diff options
| author | Andrew Dunstan | 2017-09-21 23:02:23 +0000 |
|---|---|---|
| committer | Andrew Dunstan | 2017-09-21 23:02:23 +0000 |
| commit | d57c7a7c506276597af619bdb8c62fa5b592745a (patch) | |
| tree | 6cab776216fa74f256164cbbc7859fbe1fb97b02 /src/bin/psql | |
| parent | 71480501057fee9fa3649b072173ff10e2b842d0 (diff) | |
Provide a test for variable existence in psql
"\if :{?variable_name}" will be translated to "\if TRUE" if the variable
exists and "\if FALSE" otherwise. Thus it will be possible to execute code
conditionally on the existence of the variable, regardless of its value.
Fabien Coelho, with some review by Robins Tharakan and some light text
editing by me.
Discussion: https://postgr.es/m/alpine.DEB.2.20.1708260835520.3627@lancre
Diffstat (limited to 'src/bin/psql')
| -rw-r--r-- | src/bin/psql/psqlscanslash.l | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/bin/psql/psqlscanslash.l b/src/bin/psql/psqlscanslash.l index db7a1b9eead..9a53cb3e02b 100644 --- a/src/bin/psql/psqlscanslash.l +++ b/src/bin/psql/psqlscanslash.l @@ -281,6 +281,10 @@ other . unquoted_option_chars = 0; } +:\{\?{variable_char}+\} { + psqlscan_test_variable(cur_state, yytext, yyleng); + } + :'{variable_char}* { /* Throw back everything but the colon */ yyless(1); @@ -295,6 +299,20 @@ other . ECHO; } +:\{\?{variable_char}* { + /* Throw back everything but the colon */ + yyless(1); + unquoted_option_chars++; + ECHO; + } + +:\{ { + /* Throw back everything but the colon */ + yyless(1); + unquoted_option_chars++; + ECHO; + } + {other} { unquoted_option_chars++; ECHO; |
