diff options
| author | Tom Lane | 2016-12-25 21:04:31 +0000 |
|---|---|---|
| committer | Tom Lane | 2016-12-25 21:04:45 +0000 |
| commit | a3aef88e6a9c5822eb4a5ad0744b15dc6e8a5d86 (patch) | |
| tree | ab5e5834ff940b27ab897c463fa4f4515b9ac689 /src/test | |
| parent | 86d216c77549e200b95bed487b6fb87d99a1e789 (diff) | |
Fix incorrect error reporting for duplicate data in \crosstabview.
\crosstabview's complaint about multiple entries for the same crosstab
cell quoted the wrong row and/or column values. It would accidentally
appear to work if the data had been in strcmp() order to start with,
which probably explains how we missed noticing this during development.
This could be fixed in more than one way, but the way I chose was to
hang onto both result pointers from bsearch() and use those to get at
the value names.
In passing, avoid casting away const in the bsearch comparison functions.
No bug there, just poor style.
Per bug #14476 from Tomonari Katsumata. Back-patch to 9.6 where
\crosstabview was introduced.
Report: https://postgr.es/m/20161225021519.10139.45460@wrigleys.postgresql.org
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/psql_crosstab.out | 13 | ||||
| -rw-r--r-- | src/test/regress/sql/psql_crosstab.sql | 11 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/test/regress/expected/psql_crosstab.out b/src/test/regress/expected/psql_crosstab.out index b583323a9e4..eae6fbd0512 100644 --- a/src/test/regress/expected/psql_crosstab.out +++ b/src/test/regress/expected/psql_crosstab.out @@ -201,3 +201,16 @@ SELECT a,a,1 FROM generate_series(1,3000) AS a SELECT 1 \crosstabview \crosstabview: query must return at least three columns DROP TABLE ctv_data; +-- check error reporting (bug #14476) +CREATE TABLE ctv_data (x int, y int, v text); +INSERT INTO ctv_data SELECT 1, x, '*' || x FROM generate_series(1,10) x; +SELECT * FROM ctv_data \crosstabview + x | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 +---+----+----+----+----+----+----+----+----+----+----- + 1 | *1 | *2 | *3 | *4 | *5 | *6 | *7 | *8 | *9 | *10 +(1 row) + +INSERT INTO ctv_data VALUES (1, 10, '*'); -- duplicate data to cause error +SELECT * FROM ctv_data \crosstabview +\crosstabview: query result contains multiple data values for row "1", column "10" +DROP TABLE ctv_data; diff --git a/src/test/regress/sql/psql_crosstab.sql b/src/test/regress/sql/psql_crosstab.sql index 1237e82f2d6..5a4511389de 100644 --- a/src/test/regress/sql/psql_crosstab.sql +++ b/src/test/regress/sql/psql_crosstab.sql @@ -111,3 +111,14 @@ SELECT a,a,1 FROM generate_series(1,3000) AS a SELECT 1 \crosstabview DROP TABLE ctv_data; + +-- check error reporting (bug #14476) +CREATE TABLE ctv_data (x int, y int, v text); + +INSERT INTO ctv_data SELECT 1, x, '*' || x FROM generate_series(1,10) x; +SELECT * FROM ctv_data \crosstabview + +INSERT INTO ctv_data VALUES (1, 10, '*'); -- duplicate data to cause error +SELECT * FROM ctv_data \crosstabview + +DROP TABLE ctv_data; |
