pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix behavior of ~> (cube, int) operator
7+ messages / 3 participants
[nested] [flat]

* pgsql: Fix behavior of ~> (cube, int) operator
@ 2018-01-11 11:41  Teodor Sigaev <teodor@sigaev.ru>
  0 siblings, 1 reply; 7+ messages in thread

From: Teodor Sigaev @ 2018-01-11 11:41 UTC (permalink / raw)
  To: pgsql-committers

Fix behavior of ~> (cube, int) operator

~> (cube, int) operator was especially designed for knn-gist search.
However, it appears that knn-gist search can't work correctly with current
behavior of this operator when dataset contains cubes of variable
dimensionality. In this case, the same value of second operator argument
can point to different dimension depending on dimensionality of particular cube.
Such behavior is incompatible with gist indexing of cubes, and knn-gist doesn't
work correctly for it.

This patch changes behavior of ~> (cube, int) operator by introducing dimension
numbering where value of second argument unambiguously identifies number of
dimension. With new behavior, this operator can be correctly supported by
knn-gist. Relevant changes to cube operator class are also included.

Backpatch to v9.6 where operator was introduced.

Since behavior of ~> (cube, int) operator is changed, depending entities
must be refreshed after upgrade. Such as, expression indexes using this
operator must be reindexed, materialized views must be rebuilt, stored
procedures and client code must be revised to correctly use new behavior.
That should be mentioned in release notes.

Noticed by: Tomas Vondra
Author: Alexander Korotkov
Reviewed by: Tomas Vondra, Andrey Borodin
Discussion: https://www.postgresql.org/message-id/flat/a9657f6a-b497-36ff-e56-482a2c7e3292@2ndquadrant.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/563a053bdd4b91c5e5560f4bf91220e562326f7d

Modified Files
--------------
contrib/cube/cube.c              | 120 ++++++++++++---
contrib/cube/expected/cube.out   | 317 ++++++++++++++++++++++++---------------
contrib/cube/expected/cube_2.out | 317 ++++++++++++++++++++++++---------------
contrib/cube/sql/cube.sql        |  35 +++--
doc/src/sgml/cube.sgml           |   9 +-
5 files changed, 512 insertions(+), 286 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix behavior of ~> (cube, int) operator
@ 2018-01-11 11:42  Teodor Sigaev <teodor@sigaev.ru>
  0 siblings, 0 replies; 7+ messages in thread

From: Teodor Sigaev @ 2018-01-11 11:42 UTC (permalink / raw)
  To: pgsql-committers

Fix behavior of ~> (cube, int) operator

~> (cube, int) operator was especially designed for knn-gist search.
However, it appears that knn-gist search can't work correctly with current
behavior of this operator when dataset contains cubes of variable
dimensionality. In this case, the same value of second operator argument
can point to different dimension depending on dimensionality of particular cube.
Such behavior is incompatible with gist indexing of cubes, and knn-gist doesn't
work correctly for it.

This patch changes behavior of ~> (cube, int) operator by introducing dimension
numbering where value of second argument unambiguously identifies number of
dimension. With new behavior, this operator can be correctly supported by
knn-gist. Relevant changes to cube operator class are also included.

Backpatch to v9.6 where operator was introduced.

Since behavior of ~> (cube, int) operator is changed, depending entities
must be refreshed after upgrade. Such as, expression indexes using this
operator must be reindexed, materialized views must be rebuilt, stored
procedures and client code must be revised to correctly use new behavior.
That should be mentioned in release notes.

Noticed by: Tomas Vondra
Author: Alexander Korotkov
Reviewed by: Tomas Vondra, Andrey Borodin
Discussion: https://www.postgresql.org/message-id/flat/a9657f6a-b497-36ff-e56-482a2c7e3292@2ndquadrant.com

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b8279a783dafb7c715b3835d4c9244d3451c4c1a

Modified Files
--------------
contrib/cube/cube.c              | 120 ++++++++++++---
contrib/cube/expected/cube.out   | 317 ++++++++++++++++++++++++---------------
contrib/cube/expected/cube_2.out | 317 ++++++++++++++++++++++++---------------
contrib/cube/sql/cube.sql        |  35 +++--
doc/src/sgml/cube.sgml           |   9 +-
5 files changed, 512 insertions(+), 286 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix behavior of ~> (cube, int) operator
@ 2018-01-11 11:43  Teodor Sigaev <teodor@sigaev.ru>
  0 siblings, 0 replies; 7+ messages in thread

From: Teodor Sigaev @ 2018-01-11 11:43 UTC (permalink / raw)
  To: pgsql-committers

Fix behavior of ~> (cube, int) operator

~> (cube, int) operator was especially designed for knn-gist search.
However, it appears that knn-gist search can't work correctly with current
behavior of this operator when dataset contains cubes of variable
dimensionality. In this case, the same value of second operator argument
can point to different dimension depending on dimensionality of particular cube.
Such behavior is incompatible with gist indexing of cubes, and knn-gist doesn't
work correctly for it.

This patch changes behavior of ~> (cube, int) operator by introducing dimension
numbering where value of second argument unambiguously identifies number of
dimension. With new behavior, this operator can be correctly supported by
knn-gist. Relevant changes to cube operator class are also included.

Backpatch to v9.6 where operator was introduced.

Since behavior of ~> (cube, int) operator is changed, depending entities
must be refreshed after upgrade. Such as, expression indexes using this
operator must be reindexed, materialized views must be rebuilt, stored
procedures and client code must be revised to correctly use new behavior.
That should be mentioned in release notes.

Noticed by: Tomas Vondra
Author: Alexander Korotkov
Reviewed by: Tomas Vondra, Andrey Borodin
Discussion: https://www.postgresql.org/message-id/flat/a9657f6a-b497-36ff-e56-482a2c7e3292@2ndquadrant.com

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/bda5281fdc5e41b6f54ff8f47df2ca37df00a19e

Modified Files
--------------
contrib/cube/cube.c              | 118 ++++++++++++---
contrib/cube/expected/cube.out   | 317 ++++++++++++++++++++++++---------------
contrib/cube/expected/cube_1.out | 317 ++++++++++++++++++++++++---------------
contrib/cube/expected/cube_2.out | 317 ++++++++++++++++++++++++---------------
contrib/cube/expected/cube_3.out | 317 ++++++++++++++++++++++++---------------
contrib/cube/sql/cube.sql        |  35 +++--
doc/src/sgml/cube.sgml           |   9 +-
7 files changed, 902 insertions(+), 528 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: pgsql: Fix behavior of ~> (cube, int) operator
@ 2018-01-21 20:20  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Teodor Sigaev <teodor@sigaev.ru>
  0 siblings, 1 reply; 7+ messages in thread

From: Tom Lane @ 2018-01-21 20:20 UTC (permalink / raw)
  To: Teodor Sigaev <teodor@sigaev.ru>; +Cc: pgsql-committers

Teodor Sigaev <teodor@sigaev.ru> writes:
> Fix behavior of ~> (cube, int) operator

This patch has caused Coverity to complain, correctly AFAICS, about
dead code in cube_coord_llur in the back branches:

1628     	/* Inverse value if needed */
1629     	if (inverse)
>>>     CID 1463943:  Control flow issues  (DEADCODE)
>>>     Execution cannot reach this statement: "result = -result;".
1630     		result = -result;
1631     
1632     	PG_RETURN_FLOAT8(result);

Seems to be due to sloppy division of changes between f50c80dbb (which
was not back-patched) and 563a053bd.  Please fix.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: pgsql: Fix behavior of ~> (cube, int) operator
@ 2018-04-10 11:33  Alexander Korotkov <a.korotkov@postgrespro.ru>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 7+ messages in thread

From: Alexander Korotkov @ 2018-04-10 11:33 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Teodor Sigaev <teodor@sigaev.ru>; pgsql-committers

On Sun, Jan 21, 2018 at 11:20 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Teodor Sigaev <teodor@sigaev.ru> writes:
> > Fix behavior of ~> (cube, int) operator
>
> This patch has caused Coverity to complain, correctly AFAICS, about
> dead code in cube_coord_llur in the back branches:
>
> 1628            /* Inverse value if needed */
> 1629            if (inverse)
> >>>     CID 1463943:  Control flow issues  (DEADCODE)
> >>>     Execution cannot reach this statement: "result = -result;".
> 1630                    result = -result;
> 1631
> 1632            PG_RETURN_FLOAT8(result);
>
> Seems to be due to sloppy division of changes between f50c80dbb (which
> was not back-patched) and 563a053bd.  Please fix.
>

Thank you for catching this.  You diagnosis is right.
I propose to commit the attached patch to 10 and 9.6.

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Attachments:

cube_backpatch_fix.patch (application/octet-stream, 858B) download commit be49af2216a127a82089366fdb5b335fb2f4e0c2 Author: Alexander Korotkov <a.korotkov@postgrespro.ru> Date: Tue Apr 10 14:27:55 2018 +0300 Remove wrongly backpatched piece of code in cube.c Due to sloppy division of changes between f50c80dbb (which was not back-patched) and 563a053bd, this piece of code was wrongly backpatched to REL_10_STABLE and REL9_6_STABLE. This code never causes real error because its condition is never satisfied, but it's a dead code, which needs to be removed. diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c index e695a5e16c..b72053a1d5 100644 --- a/contrib/cube/cube.c +++ b/contrib/cube/cube.c @@ -1592,11 +1592,6 @@ cube_coord_llur(PG_FUNCTION_ARGS) */ result = 0.0; } - - /* Inverse value if needed */ - if (inverse) - result = -result; - PG_RETURN_FLOAT8(result); }
^ permalink raw reply [nested|flat] 7+ messages in thread

* Re: pgsql: Fix behavior of ~> (cube, int) operator
@ 2018-04-10 11:51  Teodor Sigaev <teodor@sigaev.ru>
  parent: Alexander Korotkov <a.korotkov@postgrespro.ru>
  1 sibling, 0 replies; 7+ messages in thread

From: Teodor Sigaev @ 2018-04-10 11:51 UTC (permalink / raw)
  To: Alexander Korotkov <a.korotkov@postgrespro.ru>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers

inverse variable becomes unused, will remove


Alexander Korotkov wrote:
>     Seems to be due to sloppy division of changes between f50c80dbb (which
>     was not back-patched) and 563a053bd.  Please fix.
> 
> 
> Thank you for catching this.  You diagnosis is right.
> I propose to commit the attached patch to 10 and 9.6.

-- 
Teodor Sigaev                                   E-mail: teodor@sigaev.ru
                                                    WWW: http://www.sigaev.ru/




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: pgsql: Fix behavior of ~> (cube, int) operator
@ 2018-04-10 12:00  Teodor Sigaev <teodor@sigaev.ru>
  parent: Alexander Korotkov <a.korotkov@postgrespro.ru>
  1 sibling, 0 replies; 7+ messages in thread

From: Teodor Sigaev @ 2018-04-10 12:00 UTC (permalink / raw)
  To: Alexander Korotkov <a.korotkov@postgrespro.ru>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers

Pushed, thank you

Alexander Korotkov wrote:
> On Sun, Jan 21, 2018 at 11:20 PM, Tom Lane <tgl@sss.pgh.pa.us 
> <mailto:tgl@sss.pgh.pa.us>> wrote:
> 
>     Teodor Sigaev <teodor@sigaev.ru <mailto:teodor@sigaev.ru>> writes:
>     > Fix behavior of ~> (cube, int) operator
> 
>     This patch has caused Coverity to complain, correctly AFAICS, about
>     dead code in cube_coord_llur in the back branches:
> 
>     1628            /* Inverse value if needed */
>     1629            if (inverse)
>      >>>     CID 1463943:  Control flow issues  (DEADCODE)
>      >>>     Execution cannot reach this statement: "result = -result;".
>     1630                    result = -result;
>     1631
>     1632            PG_RETURN_FLOAT8(result);
> 
>     Seems to be due to sloppy division of changes between f50c80dbb (which
>     was not back-patched) and 563a053bd.  Please fix.
> 
> 
> Thank you for catching this.  You diagnosis is right.
> I propose to commit the attached patch to 10 and 9.6.
> 
> ------
> Alexander Korotkov
> Postgres Professional:http://www.postgrespro.com <http://www.postgrespro.com/;
> The Russian Postgres Company

-- 
Teodor Sigaev                                   E-mail: teodor@sigaev.ru
                                                    WWW: http://www.sigaev.ru/




^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2018-04-10 12:00 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-01-11 11:41 pgsql: Fix behavior of ~> (cube, int) operator Teodor Sigaev <teodor@sigaev.ru>
2018-01-21 20:20 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-04-10 11:33   ` Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-10 11:51     ` Teodor Sigaev <teodor@sigaev.ru>
2018-04-10 12:00     ` Teodor Sigaev <teodor@sigaev.ru>
2018-01-11 11:42 pgsql: Fix behavior of ~> (cube, int) operator Teodor Sigaev <teodor@sigaev.ru>
2018-01-11 11:43 pgsql: Fix behavior of ~> (cube, int) operator Teodor Sigaev <teodor@sigaev.ru>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox