Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5f04735

Browse files
committed
Fix incorrect function return code in cube_cmp and cube_dim;
update regression expected files to what I think is correct.
1 parent9f99edf commit5f04735

File tree

4 files changed

+55
-27
lines changed

4 files changed

+55
-27
lines changed

‎contrib/cube/cube.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/******************************************************************************
2-
$PostgreSQL: pgsql/contrib/cube/cube.c,v 1.27 2006/07/25 23:23:44 momjian Exp $
2+
$PostgreSQL: pgsql/contrib/cube/cube.c,v 1.28 2006/07/27 21:55:09 tgl Exp $
33
44
This file contains routines that can be bound to a Postgres backend and
55
called by the backend in the process of processing queries. The calling
@@ -14,12 +14,19 @@
1414
#include"access/gist.h"
1515
#include"access/skey.h"
1616
#include"lib/stringinfo.h"
17+
#include"utils/array.h"
1718
#include"utils/builtins.h"
1819

1920
#include"cubedata.h"
2021

2122
PG_MODULE_MAGIC;
2223

24+
/*
25+
* Taken from the intarray contrib header
26+
*/
27+
#defineARRPTR(x) ( (double *) ARR_DATA_PTR(x) )
28+
#defineARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
29+
2330
externintcube_yyparse();
2431
externvoidcube_yyerror(constchar*message);
2532
externvoidcube_scanner_init(constchar*str);
@@ -179,15 +186,6 @@ cube(PG_FUNCTION_ARGS)
179186
}
180187

181188

182-
#include"utils/array.h"
183-
184-
/*
185-
** Taken from the intarray contrib header
186-
*/
187-
#defineARRPTR(x) ( (double *) ARR_DATA_PTR(x) )
188-
#defineARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
189-
190-
191189
/*
192190
** Allows the construction of a cube from 2 float[]'s
193191
*/
@@ -1000,7 +998,7 @@ cube_cmp(PG_FUNCTION_ARGS)
1000998
a= (NDBOX*)PG_GETARG_POINTER(0);
1001999
b= (NDBOX*)PG_GETARG_POINTER(1);
10021000

1003-
PG_RETURN_INT16(cube_cmp_v0(a,b));
1001+
PG_RETURN_INT32(cube_cmp_v0(a,b));
10041002
}
10051003

10061004

@@ -1285,7 +1283,7 @@ cube_dim(PG_FUNCTION_ARGS)
12851283

12861284
c= (NDBOX*)PG_GETARG_POINTER(0);
12871285

1288-
PG_RETURN_INT16(c->dim);
1286+
PG_RETURN_INT32(c->dim);
12891287
}
12901288

12911289
/* Return a specific normalized LL coordinate */

‎contrib/cube/expected/cube.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,21 +1054,21 @@ CREATE INDEX test_cube_ix ON test_cube USING gist (c);
10541054
SELECT * FROM test_cubeWHERE c && '(3000,1000),(0,0)' ORDER BY c;
10551055
c
10561056
--------------------------
1057-
(1594, 1043),(1517, 971)
10581057
(337, 455),(240, 359)
1059-
(1444, 403),(1346, 344)
10601058
(759, 187),(662, 163)
1059+
(1444, 403),(1346, 344)
1060+
(1594, 1043),(1517, 971)
10611061
(2424, 160),(2424, 81)
10621062
(5 rows)
10631063

10641064
-- Test sorting
10651065
SELECT * FROM test_cubeWHERE c && '(3000,1000),(0,0)' GROUP BY c ORDER BY c;
10661066
c
10671067
--------------------------
1068-
(1594, 1043),(1517, 971)
10691068
(337, 455),(240, 359)
1070-
(1444, 403),(1346, 344)
10711069
(759, 187),(662, 163)
1070+
(1444, 403),(1346, 344)
1071+
(1594, 1043),(1517, 971)
10721072
(2424, 160),(2424, 81)
10731073
(5 rows)
10741074

‎contrib/cube/expected/cube_1.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,21 +1054,21 @@ CREATE INDEX test_cube_ix ON test_cube USING gist (c);
10541054
SELECT * FROM test_cubeWHERE c && '(3000,1000),(0,0)' ORDER BY c;
10551055
c
10561056
--------------------------
1057-
(1594, 1043),(1517, 971)
10581057
(337, 455),(240, 359)
1059-
(1444, 403),(1346, 344)
10601058
(759, 187),(662, 163)
1059+
(1444, 403),(1346, 344)
1060+
(1594, 1043),(1517, 971)
10611061
(2424, 160),(2424, 81)
10621062
(5 rows)
10631063

10641064
-- Test sorting
10651065
SELECT * FROM test_cubeWHERE c && '(3000,1000),(0,0)' GROUP BY c ORDER BY c;
10661066
c
10671067
--------------------------
1068-
(1594, 1043),(1517, 971)
10691068
(337, 455),(240, 359)
1070-
(1444, 403),(1346, 344)
10711069
(759, 187),(662, 163)
1070+
(1444, 403),(1346, 344)
1071+
(1594, 1043),(1517, 971)
10721072
(2424, 160),(2424, 81)
10731073
(5 rows)
10741074

‎contrib/cube/expected/cube_2.out

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
-- first, define the datatype. Turn off echoing so that expected file
66
-- does not depend on contents of cube.sql.
77
--
8+
SET client_min_messages = warning;
89
\set ECHO none
9-
psql:cube.sql:10: NOTICE: type "cube" is not yet defined
10-
DETAIL: Creating a shell type definition.
11-
psql:cube.sql:15: NOTICE: argument type cube is only a shell
10+
RESET client_min_messages;
1211
--
1312
-- testing the input and output functions
1413
--
@@ -395,6 +394,37 @@ SELECT '(0)'::text::cube;
395394
(0)
396395
(1 row)
397396

397+
--
398+
-- Test the float[] -> cube cast
399+
--
400+
SELECT cube('{0,1,2}'::float[], '{3,4,5}'::float[]);
401+
cube
402+
---------------------
403+
(0, 1, 2),(3, 4, 5)
404+
(1 row)
405+
406+
SELECT cube('{0,1,2}'::float[], '{3}'::float[]);
407+
ERROR: UR and LL arrays must be of same length
408+
SELECT cube(NULL::float[], '{3}'::float[]);
409+
cube
410+
------
411+
412+
(1 row)
413+
414+
SELECT cube('{0,1,2}'::float[]);
415+
cube
416+
-----------
417+
(0, 1, 2)
418+
(1 row)
419+
420+
SELECT cube_subset(cube('(1,3,5),(6,7,8)'), ARRAY[3,2,1,1]);
421+
cube_subset
422+
---------------------------
423+
(5, 3, 1, 1),(8, 7, 6, 6)
424+
(1 row)
425+
426+
SELECT cube_subset(cube('(1,3,5),(6,7,8)'), ARRAY[4,0]);
427+
ERROR: Index out of bounds
398428
--
399429
-- Testing limit of CUBE_MAX_DIM dimensions check in cube_in.
400430
--
@@ -1021,18 +1051,18 @@ SELECT cube_enlarge('(2,-2),(-3,7)'::cube, -3, 2);
10211051
CREATE TABLE test_cube (c cube);
10221052
\copy test_cube from 'data/test_cube.data'
10231053
CREATE INDEX test_cube_ix ON test_cube USING gist (c);
1024-
SELECT * FROM test_cubeWHERE c && '(3000,1000),(0,0)';
1054+
SELECT * FROM test_cubeWHERE c && '(3000,1000),(0,0)' ORDER BY c;
10251055
c
10261056
--------------------------
1027-
(2424, 160),(2424, 81)
1057+
(337, 455),(240, 359)
10281058
(759, 187),(662, 163)
10291059
(1444, 403),(1346, 344)
1030-
(337, 455),(240, 359)
10311060
(1594, 1043),(1517, 971)
1061+
(2424, 160),(2424, 81)
10321062
(5 rows)
10331063

10341064
-- Test sorting
1035-
SELECT * FROM test_cubeWHERE c && '(3000,1000),(0,0)' GROUP BY c;
1065+
SELECT * FROM test_cubeWHERE c && '(3000,1000),(0,0)' GROUP BY c ORDER BY c;
10361066
c
10371067
--------------------------
10381068
(337, 455),(240, 359)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp