1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

The changes I have made are described in CHANGES. This was based on

diffs to 7.3-devel and may not be applicable to 7.2. I have included a
change covered by a previous bugfix patch I submitted (the problem with
-.1 not being accepted by cube_in). It does not include a fix for the
potential buffer overrun issue I reported for cube_yyerror in
cubeparse.y.


Bruno Wolff III
This commit is contained in:
Bruce Momjian
2002-08-29 23:03:58 +00:00
parent 6d27cfdd89
commit 32784cddf1
8 changed files with 696 additions and 256 deletions

View File

@ -43,7 +43,10 @@ SELECT '.1'::cube AS cube;
(1 row)
SELECT '-.1'::cube AS cube;
ERROR: parse error, expecting `FLOAT' or `O_PAREN' or `O_BRACKET' at or before position 2, character ('.', \056), input: '-.1'
cube
--------
(-0.1)
(1 row)
SELECT '1.0'::cube AS cube;
cube
@ -57,52 +60,52 @@ SELECT '-1.0'::cube AS cube;
(-1)
(1 row)
SELECT '1e7'::cube AS cube;
SELECT '1e27'::cube AS cube;
cube
---------
(1e+07)
(1e+27)
(1 row)
SELECT '-1e7'::cube AS cube;
SELECT '-1e27'::cube AS cube;
cube
----------
(-1e+07)
(-1e+27)
(1 row)
SELECT '1.0e7'::cube AS cube;
SELECT '1.0e27'::cube AS cube;
cube
---------
(1e+07)
(1e+27)
(1 row)
SELECT '-1.0e7'::cube AS cube;
SELECT '-1.0e27'::cube AS cube;
cube
----------
(-1e+07)
(-1e+27)
(1 row)
SELECT '1e+7'::cube AS cube;
SELECT '1e+27'::cube AS cube;
cube
---------
(1e+07)
(1e+27)
(1 row)
SELECT '-1e+7'::cube AS cube;
SELECT '-1e+27'::cube AS cube;
cube
----------
(-1e+07)
(-1e+27)
(1 row)
SELECT '1.0e+7'::cube AS cube;
SELECT '1.0e+27'::cube AS cube;
cube
---------
(1e+07)
(1e+27)
(1 row)
SELECT '-1.0e+7'::cube AS cube;
SELECT '-1.0e+27'::cube AS cube;
cube
----------
(-1e+07)
(-1e+27)
(1 row)
SELECT '1e-7'::cube AS cube;
@ -141,6 +144,42 @@ SELECT '-1e-700'::cube AS cube;
(0)
(1 row)
SELECT '1234567890123456'::cube AS cube;
cube
--------------------
(1234567890123456)
(1 row)
SELECT '+1234567890123456'::cube AS cube;
cube
--------------------
(1234567890123456)
(1 row)
SELECT '-1234567890123456'::cube AS cube;
cube
---------------------
(-1234567890123456)
(1 row)
SELECT '.1234567890123456'::cube AS cube;
cube
----------------------
(0.1234567890123456)
(1 row)
SELECT '+.1234567890123456'::cube AS cube;
cube
----------------------
(0.1234567890123456)
(1 row)
SELECT '-.1234567890123456'::cube AS cube;
cube
-----------------------
(-0.1234567890123456)
(1 row)
-- simple lists (points)
SELECT '1,2'::cube AS cube;
cube
@ -924,6 +963,224 @@ SELECT '(-1,-1),(1,1)'::cube @ '(-2),(1)'::cube AS bool;
f
(1 row)
-- Test of distance function
--
SELECT cube_distance('(0)'::cube,'(2,2,2,2)'::cube);
cube_distance
---------------
4
(1 row)
SELECT cube_distance('(0)'::cube,'(.3,.4)'::cube);
cube_distance
---------------
0.5
(1 row)
-- Test of cube function (text to cube)
--
SELECT cube('('||1||','||1.2||')');
cube
----------
(1, 1.2)
(1 row)
SELECT cube(NULL);
cube
------
(1 row)
-- Test of cube_dim function (dimensions stored in cube)
--
SELECT cube_dim('(0)'::cube);
cube_dim
----------
1
(1 row)
SELECT cube_dim('(0,0)'::cube);
cube_dim
----------
2
(1 row)
SELECT cube_dim('(0,0,0)'::cube);
cube_dim
----------
3
(1 row)
-- Test of cube_ll_coord function (retrieves LL coodinate values)
--
SELECT cube_ll_coord('(-1,1),(2,-2)'::cube, 1);
cube_ll_coord
---------------
-1
(1 row)
SELECT cube_ll_coord('(-1,1),(2,-2)'::cube, 2);
cube_ll_coord
---------------
-2
(1 row)
SELECT cube_ll_coord('(-1,1),(2,-2)'::cube, 3);
cube_ll_coord
---------------
0
(1 row)
-- Test of cube_ur_coord function (retrieves UR coodinate values)
--
SELECT cube_ur_coord('(-1,1),(2,-2)'::cube, 1);
cube_ur_coord
---------------
2
(1 row)
SELECT cube_ur_coord('(-1,1),(2,-2)'::cube, 2);
cube_ur_coord
---------------
1
(1 row)
SELECT cube_ur_coord('(-1,1),(2,-2)'::cube, 3);
cube_ur_coord
---------------
0
(1 row)
-- Test of cube_is_point
--
SELECT cube_is_point('(0)'::cube);
cube_is_point
---------------
t
(1 row)
SELECT cube_is_point('(0,1,2)'::cube);
cube_is_point
---------------
t
(1 row)
SELECT cube_is_point('(0,1,2),(0,1,2)'::cube);
cube_is_point
---------------
t
(1 row)
SELECT cube_is_point('(0,1,2),(-1,1,2)'::cube);
cube_is_point
---------------
f
(1 row)
SELECT cube_is_point('(0,1,2),(0,-1,2)'::cube);
cube_is_point
---------------
f
(1 row)
SELECT cube_is_point('(0,1,2),(0,1,-2)'::cube);
cube_is_point
---------------
f
(1 row)
-- Test of cube_enlarge (enlarging and shrinking cubes)
--
SELECT cube_enlarge('(0)'::cube, 0, 0);
cube_enlarge
--------------
(0)
(1 row)
SELECT cube_enlarge('(0)'::cube, 0, 1);
cube_enlarge
--------------
(0)
(1 row)
SELECT cube_enlarge('(0)'::cube, 0, 2);
cube_enlarge
--------------
(0)
(1 row)
SELECT cube_enlarge('(0)'::cube, 1, 0);
cube_enlarge
--------------
(-1),(1)
(1 row)
SELECT cube_enlarge('(0)'::cube, 1, 1);
cube_enlarge
--------------
(-1),(1)
(1 row)
SELECT cube_enlarge('(0)'::cube, 1, 2);
cube_enlarge
-----------------
(-1, -1),(1, 1)
(1 row)
SELECT cube_enlarge('(0)'::cube, -1, 0);
cube_enlarge
--------------
(0)
(1 row)
SELECT cube_enlarge('(0)'::cube, -1, 1);
cube_enlarge
--------------
(0)
(1 row)
SELECT cube_enlarge('(0)'::cube, -1, 2);
cube_enlarge
--------------
(0)
(1 row)
SELECT cube_enlarge('(0,0,0)'::cube, 1, 0);
cube_enlarge
------------------------
(-1, -1, -1),(1, 1, 1)
(1 row)
SELECT cube_enlarge('(0,0,0)'::cube, 1, 2);
cube_enlarge
------------------------
(-1, -1, -1),(1, 1, 1)
(1 row)
SELECT cube_enlarge('(2,-2),(-3,7)'::cube, 1, 2);
cube_enlarge
-----------------
(-4, -3),(3, 8)
(1 row)
SELECT cube_enlarge('(2,-2),(-3,7)'::cube, 3, 2);
cube_enlarge
------------------
(-6, -5),(5, 10)
(1 row)
SELECT cube_enlarge('(2,-2),(-3,7)'::cube, -1, 2);
cube_enlarge
-----------------
(-2, -1),(1, 6)
(1 row)
SELECT cube_enlarge('(2,-2),(-3,7)'::cube, -3, 2);
cube_enlarge
---------------------
(-0.5, 1),(-0.5, 4)
(1 row)
-- Load some example data and build the index
--
CREATE TABLE test_cube (c cube);