Skip to content

Commit 984e5be

Browse files
committed
Sort out paired double quotes in \connect, \password and \crosstabview.
In arguments, these meta-commands wrongly treated each pair as closing the double quoted string. Make the behavior match the documentation. This is a compatibility break, but I more expect to find software with untested reliance on the documented behavior than software reliant on today's behavior. Back-patch to 9.1 (all supported versions). Reviewed by Tom Lane and Peter Eisentraut. Security: CVE-2016-5424
1 parent a1f8b6b commit 984e5be

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

src/bin/psql/psqlscanslash.l

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,8 @@ dequote_downcase_identifier(char *str, bool downcase, int encoding)
671671
/* Keep the first quote, remove the second */
672672
cp++;
673673
}
674-
inquotes = !inquotes;
674+
else
675+
inquotes = !inquotes;
675676
/* Collapse out quote at *cp */
676677
memmove(cp, cp + 1, strlen(cp));
677678
/* do not advance cp */

src/test/regress/expected/psql_crosstab.out

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ SELECT v, to_char(d, 'Mon') AS "month name", EXTRACT(month FROM d) AS num,
4646
(3 rows)
4747

4848
-- ordered months in vertical header, ordered years in horizontal header
49-
SELECT EXTRACT(year FROM d) AS year, to_char(d,'Mon') AS "month name",
49+
SELECT EXTRACT(year FROM d) AS year, to_char(d,'Mon') AS """month"" name",
5050
EXTRACT(month FROM d) AS month,
5151
format('sum=%s avg=%s', sum(i), avg(i)::numeric(2,1))
5252
FROM ctv_data
5353
GROUP BY EXTRACT(year FROM d), to_char(d,'Mon'), EXTRACT(month FROM d)
5454
ORDER BY month
55-
\crosstabview "month name" year format year
56-
month name | 2014 | 2015
57-
------------+-----------------+----------------
58-
Jan | | sum=3 avg=3.0
59-
Apr | | sum=10 avg=5.0
60-
Jul | sum=5 avg=5.0 | sum=4 avg=4.0
61-
Dec | sum=-3 avg=-3.0 |
55+
\crosstabview """month"" name" year format year
56+
"month" name | 2014 | 2015
57+
--------------+-----------------+----------------
58+
Jan | | sum=3 avg=3.0
59+
Apr | | sum=10 avg=5.0
60+
Jul | sum=5 avg=5.0 | sum=4 avg=4.0
61+
Dec | sum=-3 avg=-3.0 |
6262
(4 rows)
6363

6464
-- combine contents vertically into the same cell (V/H duplicates)

src/test/regress/sql/psql_crosstab.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ SELECT v, to_char(d, 'Mon') AS "month name", EXTRACT(month FROM d) AS num,
2929
\crosstabview v "month name" 4 num
3030

3131
-- ordered months in vertical header, ordered years in horizontal header
32-
SELECT EXTRACT(year FROM d) AS year, to_char(d,'Mon') AS "month name",
32+
SELECT EXTRACT(year FROM d) AS year, to_char(d,'Mon') AS """month"" name",
3333
EXTRACT(month FROM d) AS month,
3434
format('sum=%s avg=%s', sum(i), avg(i)::numeric(2,1))
3535
FROM ctv_data
3636
GROUP BY EXTRACT(year FROM d), to_char(d,'Mon'), EXTRACT(month FROM d)
3737
ORDER BY month
38-
\crosstabview "month name" year format year
38+
\crosstabview """month"" name" year format year
3939

4040
-- combine contents vertically into the same cell (V/H duplicates)
4141
SELECT v, h, string_agg(c, E'\n') FROM ctv_data GROUP BY v, h ORDER BY 1,2,3

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy