2
2
--
3
3
-- complex.sql-
4
4
-- This file shows how to create a new user-defined type and how to
5
- -- use them .
5
+ -- use this new type .
6
6
--
7
7
--
8
8
-- Copyright (c) 1994, Regents of the University of California
9
9
--
10
- -- $Id: complex.source,v 1.1.1.1 1996/07/09 06 :22:34 scrappy Exp $
10
+ -- $Id: complex.source,v 1.2 1996/12/28 02 :22:07 momjian Exp $
11
11
--
12
12
---------------------------------------------------------------------------
13
13
@@ -105,7 +105,7 @@ SELECT a + '(1.0,1.0)'::complex AS aa,
105
105
106
106
-----------------------------
107
107
-- Creating aggregate functions
108
- -- you can also define aggregate functions. The syntax is some what
108
+ -- you can also define aggregate functions. The syntax is somewhat
109
109
-- cryptic but the idea is to express the aggregate in terms of state
110
110
-- transition functions.
111
111
-----------------------------
@@ -122,8 +122,8 @@ SELECT complex_sum(a) FROM test_complex;
122
122
123
123
-------------------------------------------------------------------------------
124
124
-- ATTENTION! ATTENTION! ATTENTION! --
125
- -- YOU MAY SKIP THE SECTION BELOW ON INTERFACING WITH INDICIES . YOU DON'T --
126
- -- NEED THE FOLLOWING IF YOU DON'T USE INDICIES WITH NEW DATA TYPES. --
125
+ -- YOU MAY SKIP THE SECTION BELOW ON INTERFACING WITH INDICES . YOU DON'T --
126
+ -- NEED THE FOLLOWING IF YOU DON'T USE INDICES WITH NEW DATA TYPES. --
127
127
-------------------------------------------------------------------------------
128
128
129
129
SELECT 'READ ABOVE!' AS STOP;
@@ -239,7 +239,8 @@ INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
239
239
and proname = 'complex_abs_cmp';
240
240
241
241
-- now, we can define a btree index on complex types. First, let's populate
242
- -- the table (THIS DOESN'T ACTUALLY WORK. YOU NEED MANY MORE TUPLES.)
242
+ -- the table. Note that postgres needs many more tuples to start using the
243
+ -- btree index during selects.
243
244
INSERT INTO test_complex VALUES ('(56.0,-22.5)', '(-43.2,-0.07)')
244
245
INSERT INTO test_complex VALUES ('(-91.9,33.6)', '(8.6,3.0)');
245
246
@@ -248,4 +249,4 @@ CREATE INDEX test_cplx_ind ON test_complex
248
249
249
250
SELECT * from test_complex where a = '(56.0,-22.5)';
250
251
SELECT * from test_complex where a < '(56.0,-22.5)';
251
- SELECT * from test_complex where a > '(56.0,-22.5)';
252
+ SELECT * from test_complex where a > '(56.0,-22.5)';
0 commit comments