Fix incorrect function return code in cube_cmp and cube_dim;
update regression expected files to what I think is correct.
This commit is contained in:
parent
9f99edfd7e
commit
5f0473534f
@ -1,5 +1,5 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
$PostgreSQL: pgsql/contrib/cube/cube.c,v 1.27 2006/07/25 23:23:44 momjian Exp $
|
$PostgreSQL: pgsql/contrib/cube/cube.c,v 1.28 2006/07/27 21:55:09 tgl Exp $
|
||||||
|
|
||||||
This file contains routines that can be bound to a Postgres backend and
|
This file contains routines that can be bound to a Postgres backend and
|
||||||
called by the backend in the process of processing queries. The calling
|
called by the backend in the process of processing queries. The calling
|
||||||
@ -14,12 +14,19 @@
|
|||||||
#include "access/gist.h"
|
#include "access/gist.h"
|
||||||
#include "access/skey.h"
|
#include "access/skey.h"
|
||||||
#include "lib/stringinfo.h"
|
#include "lib/stringinfo.h"
|
||||||
|
#include "utils/array.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
|
|
||||||
#include "cubedata.h"
|
#include "cubedata.h"
|
||||||
|
|
||||||
PG_MODULE_MAGIC;
|
PG_MODULE_MAGIC;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Taken from the intarray contrib header
|
||||||
|
*/
|
||||||
|
#define ARRPTR(x) ( (double *) ARR_DATA_PTR(x) )
|
||||||
|
#define ARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
|
||||||
|
|
||||||
extern int cube_yyparse();
|
extern int cube_yyparse();
|
||||||
extern void cube_yyerror(const char *message);
|
extern void cube_yyerror(const char *message);
|
||||||
extern void cube_scanner_init(const char *str);
|
extern void cube_scanner_init(const char *str);
|
||||||
@ -179,15 +186,6 @@ cube(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "utils/array.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Taken from the intarray contrib header
|
|
||||||
*/
|
|
||||||
#define ARRPTR(x) ( (double *) ARR_DATA_PTR(x) )
|
|
||||||
#define ARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Allows the construction of a cube from 2 float[]'s
|
** Allows the construction of a cube from 2 float[]'s
|
||||||
*/
|
*/
|
||||||
@ -1000,7 +998,7 @@ cube_cmp(PG_FUNCTION_ARGS)
|
|||||||
a = (NDBOX *) PG_GETARG_POINTER(0);
|
a = (NDBOX *) PG_GETARG_POINTER(0);
|
||||||
b = (NDBOX *) PG_GETARG_POINTER(1);
|
b = (NDBOX *) PG_GETARG_POINTER(1);
|
||||||
|
|
||||||
PG_RETURN_INT16(cube_cmp_v0(a, b));
|
PG_RETURN_INT32(cube_cmp_v0(a, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1285,7 +1283,7 @@ cube_dim(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
c = (NDBOX *) PG_GETARG_POINTER(0);
|
c = (NDBOX *) PG_GETARG_POINTER(0);
|
||||||
|
|
||||||
PG_RETURN_INT16 (c->dim);
|
PG_RETURN_INT32(c->dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a specific normalized LL coordinate */
|
/* Return a specific normalized LL coordinate */
|
||||||
|
@ -1054,10 +1054,10 @@ CREATE INDEX test_cube_ix ON test_cube USING gist (c);
|
|||||||
SELECT * FROM test_cube WHERE c && '(3000,1000),(0,0)' ORDER BY c;
|
SELECT * FROM test_cube WHERE c && '(3000,1000),(0,0)' ORDER BY c;
|
||||||
c
|
c
|
||||||
--------------------------
|
--------------------------
|
||||||
(1594, 1043),(1517, 971)
|
|
||||||
(337, 455),(240, 359)
|
(337, 455),(240, 359)
|
||||||
(1444, 403),(1346, 344)
|
|
||||||
(759, 187),(662, 163)
|
(759, 187),(662, 163)
|
||||||
|
(1444, 403),(1346, 344)
|
||||||
|
(1594, 1043),(1517, 971)
|
||||||
(2424, 160),(2424, 81)
|
(2424, 160),(2424, 81)
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
@ -1065,10 +1065,10 @@ SELECT * FROM test_cube WHERE c && '(3000,1000),(0,0)' ORDER BY c;
|
|||||||
SELECT * FROM test_cube WHERE c && '(3000,1000),(0,0)' GROUP BY c ORDER BY c;
|
SELECT * FROM test_cube WHERE c && '(3000,1000),(0,0)' GROUP BY c ORDER BY c;
|
||||||
c
|
c
|
||||||
--------------------------
|
--------------------------
|
||||||
(1594, 1043),(1517, 971)
|
|
||||||
(337, 455),(240, 359)
|
(337, 455),(240, 359)
|
||||||
(1444, 403),(1346, 344)
|
|
||||||
(759, 187),(662, 163)
|
(759, 187),(662, 163)
|
||||||
|
(1444, 403),(1346, 344)
|
||||||
|
(1594, 1043),(1517, 971)
|
||||||
(2424, 160),(2424, 81)
|
(2424, 160),(2424, 81)
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
|
@ -1054,10 +1054,10 @@ CREATE INDEX test_cube_ix ON test_cube USING gist (c);
|
|||||||
SELECT * FROM test_cube WHERE c && '(3000,1000),(0,0)' ORDER BY c;
|
SELECT * FROM test_cube WHERE c && '(3000,1000),(0,0)' ORDER BY c;
|
||||||
c
|
c
|
||||||
--------------------------
|
--------------------------
|
||||||
(1594, 1043),(1517, 971)
|
|
||||||
(337, 455),(240, 359)
|
(337, 455),(240, 359)
|
||||||
(1444, 403),(1346, 344)
|
|
||||||
(759, 187),(662, 163)
|
(759, 187),(662, 163)
|
||||||
|
(1444, 403),(1346, 344)
|
||||||
|
(1594, 1043),(1517, 971)
|
||||||
(2424, 160),(2424, 81)
|
(2424, 160),(2424, 81)
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
@ -1065,10 +1065,10 @@ SELECT * FROM test_cube WHERE c && '(3000,1000),(0,0)' ORDER BY c;
|
|||||||
SELECT * FROM test_cube WHERE c && '(3000,1000),(0,0)' GROUP BY c ORDER BY c;
|
SELECT * FROM test_cube WHERE c && '(3000,1000),(0,0)' GROUP BY c ORDER BY c;
|
||||||
c
|
c
|
||||||
--------------------------
|
--------------------------
|
||||||
(1594, 1043),(1517, 971)
|
|
||||||
(337, 455),(240, 359)
|
(337, 455),(240, 359)
|
||||||
(1444, 403),(1346, 344)
|
|
||||||
(759, 187),(662, 163)
|
(759, 187),(662, 163)
|
||||||
|
(1444, 403),(1346, 344)
|
||||||
|
(1594, 1043),(1517, 971)
|
||||||
(2424, 160),(2424, 81)
|
(2424, 160),(2424, 81)
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
|
@ -5,10 +5,9 @@
|
|||||||
-- first, define the datatype. Turn off echoing so that expected file
|
-- first, define the datatype. Turn off echoing so that expected file
|
||||||
-- does not depend on contents of cube.sql.
|
-- does not depend on contents of cube.sql.
|
||||||
--
|
--
|
||||||
|
SET client_min_messages = warning;
|
||||||
\set ECHO none
|
\set ECHO none
|
||||||
psql:cube.sql:10: NOTICE: type "cube" is not yet defined
|
RESET client_min_messages;
|
||||||
DETAIL: Creating a shell type definition.
|
|
||||||
psql:cube.sql:15: NOTICE: argument type cube is only a shell
|
|
||||||
--
|
--
|
||||||
-- testing the input and output functions
|
-- testing the input and output functions
|
||||||
--
|
--
|
||||||
@ -395,6 +394,37 @@ SELECT '(0)'::text::cube;
|
|||||||
(0)
|
(0)
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Test the float[] -> cube cast
|
||||||
|
--
|
||||||
|
SELECT cube('{0,1,2}'::float[], '{3,4,5}'::float[]);
|
||||||
|
cube
|
||||||
|
---------------------
|
||||||
|
(0, 1, 2),(3, 4, 5)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT cube('{0,1,2}'::float[], '{3}'::float[]);
|
||||||
|
ERROR: UR and LL arrays must be of same length
|
||||||
|
SELECT cube(NULL::float[], '{3}'::float[]);
|
||||||
|
cube
|
||||||
|
------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT cube('{0,1,2}'::float[]);
|
||||||
|
cube
|
||||||
|
-----------
|
||||||
|
(0, 1, 2)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT cube_subset(cube('(1,3,5),(6,7,8)'), ARRAY[3,2,1,1]);
|
||||||
|
cube_subset
|
||||||
|
---------------------------
|
||||||
|
(5, 3, 1, 1),(8, 7, 6, 6)
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT cube_subset(cube('(1,3,5),(6,7,8)'), ARRAY[4,0]);
|
||||||
|
ERROR: Index out of bounds
|
||||||
--
|
--
|
||||||
-- Testing limit of CUBE_MAX_DIM dimensions check in cube_in.
|
-- Testing limit of CUBE_MAX_DIM dimensions check in cube_in.
|
||||||
--
|
--
|
||||||
@ -1021,18 +1051,18 @@ SELECT cube_enlarge('(2,-2),(-3,7)'::cube, -3, 2);
|
|||||||
CREATE TABLE test_cube (c cube);
|
CREATE TABLE test_cube (c cube);
|
||||||
\copy test_cube from 'data/test_cube.data'
|
\copy test_cube from 'data/test_cube.data'
|
||||||
CREATE INDEX test_cube_ix ON test_cube USING gist (c);
|
CREATE INDEX test_cube_ix ON test_cube USING gist (c);
|
||||||
SELECT * FROM test_cube WHERE c && '(3000,1000),(0,0)';
|
SELECT * FROM test_cube WHERE c && '(3000,1000),(0,0)' ORDER BY c;
|
||||||
c
|
c
|
||||||
--------------------------
|
--------------------------
|
||||||
(2424, 160),(2424, 81)
|
(337, 455),(240, 359)
|
||||||
(759, 187),(662, 163)
|
(759, 187),(662, 163)
|
||||||
(1444, 403),(1346, 344)
|
(1444, 403),(1346, 344)
|
||||||
(337, 455),(240, 359)
|
|
||||||
(1594, 1043),(1517, 971)
|
(1594, 1043),(1517, 971)
|
||||||
|
(2424, 160),(2424, 81)
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
-- Test sorting
|
-- Test sorting
|
||||||
SELECT * FROM test_cube WHERE c && '(3000,1000),(0,0)' GROUP BY c;
|
SELECT * FROM test_cube WHERE c && '(3000,1000),(0,0)' GROUP BY c ORDER BY c;
|
||||||
c
|
c
|
||||||
--------------------------
|
--------------------------
|
||||||
(337, 455),(240, 359)
|
(337, 455),(240, 359)
|
||||||
|
Loading…
Reference in New Issue
Block a user