diff options
Diffstat (limited to 'src/bin/psql/psqlscanslash.l')
-rw-r--r-- | src/bin/psql/psqlscanslash.l | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/bin/psql/psqlscanslash.l b/src/bin/psql/psqlscanslash.l index 514977e59dc..e1ae8627dbf 100644 --- a/src/bin/psql/psqlscanslash.l +++ b/src/bin/psql/psqlscanslash.l @@ -18,6 +18,8 @@ */ #include "postgres_fe.h" +#include <ctype.h> + #include "common.h" #include "psqlscanslash.h" @@ -608,7 +610,7 @@ psql_scan_slash_option(PsqlScanState state, /* empty arg */ break; case xslasharg: - /* Strip any unquoted trailing semi-colons if requested */ + /* Strip any unquoted trailing semicolons if requested */ if (semicolon) { while (unquoted_option_chars-- > 0 && @@ -640,7 +642,22 @@ psql_scan_slash_option(PsqlScanState state, termPQExpBuffer(&mybuf); return NULL; case xslashwholeline: - /* always okay */ + /* + * In whole-line mode, we interpret semicolon = true as stripping + * trailing whitespace as well as semicolons; this gives the + * nearest equivalent to what semicolon = true does in normal + * mode. Note there's no concept of quoting in this mode. + */ + if (semicolon) + { + while (mybuf.len > 0 && + (mybuf.data[mybuf.len - 1] == ';' || + (isascii((unsigned char) mybuf.data[mybuf.len - 1]) && + isspace((unsigned char) mybuf.data[mybuf.len - 1])))) + { + mybuf.data[--mybuf.len] = '\0'; + } + } break; default: /* can't get here */ |