diff options
| author | Marc G. Fournier <scrappy@hub.org> | 1997-04-22 17:35:09 +0000 |
|---|---|---|
| committer | Marc G. Fournier <scrappy@hub.org> | 1997-04-22 17:35:09 +0000 |
| commit | 9e2a87b62db87fc4175b00dabfd26293a2d072fa (patch) | |
| tree | 431dc2f390475e033dc2cfda38fddb6a79e4abb2 /src/test/regress | |
| parent | 051b4210e3cb3f3a9ec7cd5ab4503b48f279ab48 (diff) | |
| download | postgresql-9e2a87b62db87fc4175b00dabfd26293a2d072fa.tar.gz | |
Major patch from Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
OK, here are a passel of patches for the geometric data types.
These add a "circle" data type, new operators and functions
for the existing data types, and change the default formats
for some of the existing types to make them consistant with
each other. Current formatting conventions (e.g. compatible
with v6.0 to allow dump/reload) are supported, but the new
conventions should be an improvement and we can eventually
drop the old conventions entirely.
For example, there are two kinds of paths (connected line segments),
open and closed, and the old format was
'(1,2,1,2,3,4)' for a closed path with two points (1,2) and (3,4)
'(0,2,1,2,3,4)' for an open path with two points (1,2) and (3,4)
Pretty arcane, huh? The new format for paths is
'((1,2),(3,4))' for a closed path with two points (1,2) and (3,4)
'[(1,2),(3,4)]' for an open path with two points (1,2) and (3,4)
For polygons, the old convention is
'(0,4,2,0,4,3)' for a triangle with points at (0,0),(4,4), and (2,3)
and the new convention is
'((0,0),(4,4),(2,3))' for a triangle with points at (0,0),(4,4), and (2,3)
Other data types which are also represented as lists of points
(e.g. boxes, line segments, and polygons) have similar representations
(they surround each point with parens).
For v6.1, any format which can be interpreted as the old style format
is decoded as such; we can remove that backwards compatibility but ugly
convention for v7.0. This will allow dump/reloads from v6.0.
These include some updates to the regression test files to change the test
for creating a data type from "circle" to "widget" to keep the test from
trashing the new builtin circle type.
Diffstat (limited to 'src/test/regress')
| -rw-r--r-- | src/test/regress/expected/create_operator.out | 4 | ||||
| -rw-r--r-- | src/test/regress/expected/create_type.out | 6 | ||||
| -rw-r--r-- | src/test/regress/expected/misc.out | 10 | ||||
| -rw-r--r-- | src/test/regress/input/create_function.source | 8 | ||||
| -rw-r--r-- | src/test/regress/regress.c | 62 | ||||
| -rw-r--r-- | src/test/regress/sql/create_operator.sql | 4 | ||||
| -rw-r--r-- | src/test/regress/sql/create_type.sql | 6 |
7 files changed, 51 insertions, 49 deletions
diff --git a/src/test/regress/expected/create_operator.out b/src/test/regress/expected/create_operator.out index c45e48a839..cc9217826d 100644 --- a/src/test/regress/expected/create_operator.out +++ b/src/test/regress/expected/create_operator.out @@ -6,8 +6,8 @@ QUERY: CREATE OPERATOR ## ( ); QUERY: CREATE OPERATOR <% ( leftarg = point, - rightarg = circle, - procedure = pt_in_circle, + rightarg = widget, + procedure = pt_in_widget, commutator = >=% ); QUERY: CREATE OPERATOR @#@ ( diff --git a/src/test/regress/expected/create_type.out b/src/test/regress/expected/create_type.out index 7919b01e37..104a9eb5b8 100644 --- a/src/test/regress/expected/create_type.out +++ b/src/test/regress/expected/create_type.out @@ -1,7 +1,7 @@ -QUERY: CREATE TYPE circle ( +QUERY: CREATE TYPE widget ( internallength = 24, - input = circle_in, - output = circle_out, + input = widget_in, + output = widget_out, alignment = double ); QUERY: CREATE TYPE city_budget ( diff --git a/src/test/regress/expected/misc.out b/src/test/regress/expected/misc.out index 4466bd9187..5bc297a346 100644 --- a/src/test/regress/expected/misc.out +++ b/src/test/regress/expected/misc.out @@ -3357,20 +3357,20 @@ QUERY: DROP FUNCTION hobbies(person); QUERY: DROP FUNCTION hobby_construct(text,text); QUERY: DROP FUNCTION equipment(hobbies_r); QUERY: DROP FUNCTION user_relns(); -QUERY: DROP FUNCTION circle_in(opaque); -QUERY: DROP FUNCTION circle_out(opaque); -QUERY: DROP FUNCTION pt_in_circle(point,circle); +QUERY: DROP FUNCTION widget_in(opaque); +QUERY: DROP FUNCTION widget_out(opaque); +QUERY: DROP FUNCTION pt_in_widget(point,widget); QUERY: DROP FUNCTION overpaid(emp); QUERY: DROP FUNCTION boxarea(box); QUERY: DROP FUNCTION interpt_pp(path,path); QUERY: DROP FUNCTION reverse_c16(char16); QUERY: DROP OPERATOR ## (path, path); -QUERY: DROP OPERATOR <% (point, circle); +QUERY: DROP OPERATOR <% (point, widget); QUERY: DROP OPERATOR @#@ (none, int4); QUERY: DROP OPERATOR #@# (int4, none); QUERY: DROP OPERATOR #%# (int4, none); QUERY: DROP TYPE city_budget; -QUERY: DROP TYPE circle; +QUERY: DROP TYPE widget; QUERY: DROP AGGREGATE newavg; QUERY: DROP AGGREGATE newsum; QUERY: DROP AGGREGATE newcnt; diff --git a/src/test/regress/input/create_function.source b/src/test/regress/input/create_function.source index fc944c4e1d..602f0ca4e3 100644 --- a/src/test/regress/input/create_function.source +++ b/src/test/regress/input/create_function.source @@ -3,12 +3,12 @@ -- -- -CREATE FUNCTION circle_in(opaque) - RETURNS circle +CREATE FUNCTION widget_in(opaque) + RETURNS widget AS '_OBJWD_/regress_DLSUFFIX_' LANGUAGE 'c'; -CREATE FUNCTION circle_out(opaque) +CREATE FUNCTION widget_out(opaque) RETURNS opaque AS '_OBJWD_/regress_DLSUFFIX_' LANGUAGE 'c'; @@ -42,7 +42,7 @@ CREATE FUNCTION user_relns() relkind <> ''i'' ' LANGUAGE 'sql'; -CREATE FUNCTION pt_in_circle(point, circle) +CREATE FUNCTION pt_in_widget(point, widget) RETURNS int4 AS '_OBJWD_/regress_DLSUFFIX_' LANGUAGE 'c'; diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c index 28f04d8955..8eb70daf3f 100644 --- a/src/test/regress/regress.c +++ b/src/test/regress/regress.c @@ -1,5 +1,5 @@ /* - * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.5 1997/03/14 23:34:16 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.6 1997/04/22 17:33:00 scrappy Exp $ */ #include <float.h> /* faked on sunos */ @@ -103,22 +103,19 @@ poly2path(poly) { int i; char *output = (char *)PALLOC(2*(P_MAXDIG + 1)*poly->npts + 64); - char *outptr = output; - double *xp, *yp; + char buf[2*(P_MAXDIG)+20]; - sprintf(outptr, "(1, %*d", P_MAXDIG, poly->npts); - xp = (double *) poly->pts; - yp = (double *) (poly->pts + (poly->npts * sizeof(double *))); + sprintf(output, "(1, %*d", P_MAXDIG, poly->npts); - for (i=1; i<poly->npts; i++,xp++,yp++) + for (i=0; i<poly->npts; i++) { - sprintf(outptr, ",%*g,%*g", P_MAXDIG, *xp, P_MAXDIG, *yp); - outptr += 2*(P_MAXDIG + 1); + sprintf(buf, ",%*g,%*g", P_MAXDIG, poly->p[i].x, P_MAXDIG, poly->p[i].y); + strcat(output, buf); } - *outptr++ = RDELIM; - *outptr = '\0'; - return(path_in(outptr)); + sprintf(buf, "%c", RDELIM); + strcat(output, buf); + return(path_in(output)); } /* return the point where two paths intersect. Assumes that they do. */ @@ -176,24 +173,29 @@ char overpaid(tuple) return(salary > 699); } +/* New type "widget" + * This used to be "circle", but I added circle to builtins, + * so needed to make sure the names do not collide. - tgl 97/04/21 + */ + typedef struct { Point center; double radius; -} CIRCLE; +} WIDGET; -extern CIRCLE *circle_in (char *str); -extern char *circle_out (CIRCLE *circle); -extern int pt_in_circle (Point *point, CIRCLE *circle); +extern WIDGET *widget_in (char *str); +extern char *widget_out (WIDGET *widget); +extern int pt_in_widget (Point *point, WIDGET *widget); #define NARGS 3 -CIRCLE * -circle_in(str) +WIDGET * +widget_in(str) char *str; { char *p, *coord[NARGS], buf2[1000]; int i; - CIRCLE *result; + WIDGET *result; if (str == NULL) return(NULL); @@ -202,39 +204,39 @@ char *str; coord[i++] = p + 1; if (i < NARGS - 1) return(NULL); - result = (CIRCLE *) palloc(sizeof(CIRCLE)); + result = (WIDGET *) palloc(sizeof(WIDGET)); result->center.x = atof(coord[0]); result->center.y = atof(coord[1]); result->radius = atof(coord[2]); - sprintf(buf2, "circle_in: read (%f, %f, %f)\n", result->center.x, + sprintf(buf2, "widget_in: read (%f, %f, %f)\n", result->center.x, result->center.y,result->radius); return(result); } char * -circle_out(circle) - CIRCLE *circle; +widget_out(widget) + WIDGET *widget; { char *result; - if (circle == NULL) + if (widget == NULL) return(NULL); result = (char *) palloc(60); (void) sprintf(result, "(%g,%g,%g)", - circle->center.x, circle->center.y, circle->radius); + widget->center.x, widget->center.y, widget->radius); return(result); } int -pt_in_circle(point, circle) +pt_in_widget(point, widget) Point *point; - CIRCLE *circle; + WIDGET *widget; { extern double point_dt(); - return( point_dt(point, &circle->center) < circle->radius ); + return( point_dt(point, &widget->center) < widget->radius ); } #define ABS(X) ((X) > 0 ? (X) : -(X)) @@ -247,8 +249,8 @@ BOX *box; { int width, height; - width = ABS(box->xh - box->xl); - height = ABS(box->yh - box->yl); + width = ABS(box->high.x - box->low.x); + height = ABS(box->high.y - box->low.y); return (width * height); } diff --git a/src/test/regress/sql/create_operator.sql b/src/test/regress/sql/create_operator.sql index 60e4420782..74fdd8eb4f 100644 --- a/src/test/regress/sql/create_operator.sql +++ b/src/test/regress/sql/create_operator.sql @@ -10,8 +10,8 @@ CREATE OPERATOR ## ( CREATE OPERATOR <% ( leftarg = point, - rightarg = circle, - procedure = pt_in_circle, + rightarg = widget, + procedure = pt_in_widget, commutator = >=% ); diff --git a/src/test/regress/sql/create_type.sql b/src/test/regress/sql/create_type.sql index 87d1737c64..1a75ba5295 100644 --- a/src/test/regress/sql/create_type.sql +++ b/src/test/regress/sql/create_type.sql @@ -3,10 +3,10 @@ -- -- -CREATE TYPE circle ( +CREATE TYPE widget ( internallength = 24, - input = circle_in, - output = circle_out, + input = widget_in, + output = widget_out, alignment = double ); |
