mirror of
https://github.com/postgres/postgres.git
synced 2025-11-19 13:42:17 +03:00
Handle \v as a whitespace character in parsers
This commit comes as a continuation of the discussion that has led tod522b05, as \v was handled inconsistently when parsing array values or anything going through the parsers, and changing a parser behavior in stable branches is a scary thing to do. The parsing of array values now uses the more central scanner_isspace() and array_isspace() is removed. As pointing out by Peter Eisentraut, fix a confusing reference to horizontal space in the parsers with the term "horiz_space". \f was included in this set since3cfdd8ffrom 2000, but it is not horizontal. "horiz_space" is renamed to "non_newline_space", to refer to all whitespace characters except newlines. The changes impact the parsers for the backend, psql, seg, cube, ecpg and replication commands. Note that JSON should not escape \v, as per RFC 7159, so these are not touched. Reviewed-by: Peter Eisentraut, Tom Lane Discussion: https://postgr.es/m/ZJKcjNwWHHvw9ksQ@paquier.xyz
This commit is contained in:
@@ -149,16 +149,16 @@ extern void psql_yyset_column(int column_no, yyscan_t yyscanner);
|
||||
* versions of Postgres failed to recognize -- as a comment if the input
|
||||
* did not end with a newline.
|
||||
*
|
||||
* XXX perhaps \f (formfeed) should be treated as a newline as well?
|
||||
* non_newline_space tracks all space characters except newlines.
|
||||
*
|
||||
* XXX if you change the set of whitespace characters, fix scanner_isspace()
|
||||
* to agree.
|
||||
*/
|
||||
|
||||
space [ \t\n\r\f]
|
||||
horiz_space [ \t\f]
|
||||
newline [\n\r]
|
||||
non_newline [^\n\r]
|
||||
space [ \t\n\r\f\v]
|
||||
non_newline_space [ \t\f\v]
|
||||
newline [\n\r]
|
||||
non_newline [^\n\r]
|
||||
|
||||
comment ("--"{non_newline}*)
|
||||
|
||||
@@ -172,8 +172,8 @@ whitespace ({space}+|{comment})
|
||||
*/
|
||||
|
||||
special_whitespace ({space}+|{comment}{newline})
|
||||
horiz_whitespace ({horiz_space}|{comment})
|
||||
whitespace_with_newline ({horiz_whitespace}*{newline}{special_whitespace}*)
|
||||
non_newline_whitespace ({non_newline_space}|{comment})
|
||||
whitespace_with_newline ({non_newline_whitespace}*{newline}{special_whitespace}*)
|
||||
|
||||
quote '
|
||||
/* If we see {quote} then {quotecontinue}, the quoted string continues */
|
||||
|
||||
@@ -761,7 +761,7 @@ appendPGArray(PQExpBuffer buffer, const char *value)
|
||||
|
||||
if (ch == '"' || ch == '\\' ||
|
||||
ch == '{' || ch == '}' || ch == ',' ||
|
||||
/* these match array_isspace(): */
|
||||
/* these match scanner_isspace(): */
|
||||
ch == ' ' || ch == '\t' || ch == '\n' ||
|
||||
ch == '\r' || ch == '\v' || ch == '\f')
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user