mirror of
https://github.com/postgres/postgres.git
synced 2026-03-09 09:40:40 -04:00
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.
74 lines
1.4 KiB
Text
74 lines
1.4 KiB
Text
--
|
|
-- create.source
|
|
--
|
|
--
|
|
|
|
CREATE FUNCTION widget_in(opaque)
|
|
RETURNS widget
|
|
AS '_OBJWD_/regress_DLSUFFIX_'
|
|
LANGUAGE 'c';
|
|
|
|
CREATE FUNCTION widget_out(opaque)
|
|
RETURNS opaque
|
|
AS '_OBJWD_/regress_DLSUFFIX_'
|
|
LANGUAGE 'c';
|
|
|
|
--
|
|
-- FUNCTION DEFINITIONS
|
|
--
|
|
CREATE FUNCTION hobbies(person)
|
|
RETURNS setof hobbies_r
|
|
AS 'select * from hobbies_r where person = $1.name'
|
|
LANGUAGE 'sql';
|
|
|
|
|
|
CREATE FUNCTION hobby_construct(text, text)
|
|
RETURNS hobbies_r
|
|
AS 'select $1 as name, $2 as hobby'
|
|
LANGUAGE 'sql';
|
|
|
|
|
|
CREATE FUNCTION equipment(hobbies_r)
|
|
RETURNS setof equipment_r
|
|
AS 'select * from equipment_r where hobby = $1.name'
|
|
LANGUAGE 'sql';
|
|
|
|
|
|
CREATE FUNCTION user_relns()
|
|
RETURNS setof name
|
|
AS 'select relname
|
|
from pg_class
|
|
where relname !~ ''pg_.*'' and
|
|
relkind <> ''i'' '
|
|
LANGUAGE 'sql';
|
|
|
|
CREATE FUNCTION pt_in_widget(point, widget)
|
|
RETURNS int4
|
|
AS '_OBJWD_/regress_DLSUFFIX_'
|
|
LANGUAGE 'c';
|
|
|
|
CREATE FUNCTION overpaid(emp)
|
|
RETURNS bool
|
|
AS '_OBJWD_/regress_DLSUFFIX_'
|
|
LANGUAGE 'c';
|
|
|
|
CREATE FUNCTION boxarea(box)
|
|
RETURNS int4
|
|
AS '_OBJWD_/regress_DLSUFFIX_'
|
|
LANGUAGE 'c';
|
|
|
|
CREATE FUNCTION interpt_pp(path, path)
|
|
RETURNS point
|
|
AS '_OBJWD_/regress_DLSUFFIX_'
|
|
LANGUAGE 'c';
|
|
|
|
CREATE FUNCTION reverse_c16(char16)
|
|
RETURNS char16
|
|
AS '_OBJWD_/regress_DLSUFFIX_'
|
|
LANGUAGE 'c';
|
|
|
|
--
|
|
-- FUNCTION DYNAMIC LOADING
|
|
--
|
|
LOAD '_OBJWD_/regress_DLSUFFIX_';
|
|
|