]> granicus.if.org Git - postgresql/commitdiff
From: Darren King <darrenk@insightdist.com>
authorMarc G. Fournier <scrappy@hub.org>
Sat, 28 Feb 1998 23:37:10 +0000 (23:37 +0000)
committerMarc G. Fournier <scrappy@hub.org>
Sat, 28 Feb 1998 23:37:10 +0000 (23:37 +0000)
Seem to remember someone posting to one of the lists a while back
that the tutorial code wouldn't compile and/or run.  Found four
problems with it that will let it run.

1. Tutorial makefile had a recursive use of DLOBJS.

2. Some tutorial needed semi-colons added to many statements.

3. Complex tutorial didn't clean up after itself.

4. Advanced had a time-travel example.  Commented it out and
   put a line pointing the user to contrib/spi/README.

src/tutorial/Makefile
src/tutorial/advanced.source
src/tutorial/complex.source
src/tutorial/syscat.source

index c575d040b492679ec3d84d643d72d656a7aa41df..5302c9cc39dc6865e4c1a11b43383e04e9c67794 100644 (file)
@@ -4,7 +4,7 @@
 #    Makefile for tutorial
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/tutorial/Makefile,v 1.6 1998/01/04 19:12:55 scrappy Exp $
+#    $Header: /cvsroot/pgsql/src/tutorial/Makefile,v 1.7 1998/02/28 23:37:07 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -28,11 +28,14 @@ endif
 DLOBJS= complex$(DLSUFFIX) funcs$(DLSUFFIX)
 
 QUERIES= advanced.sql basics.sql complex.sql funcs.sql syscat.sql
+
+INFILES= $(DLOBJS)
+
 #
 # plus exports files
 #
 ifdef EXPSUFF
-DLOBJS+= $(DLOBJS:.o=$(EXPSUFF))
+INFILES+= $(DLOBJS:.o=$(EXPSUFF))
 endif
 
 all: $(QUERIES)
@@ -48,13 +51,12 @@ all: $(QUERIES)
            -e "s:_DLSUFFIX_:$(DLSUFFIX):g" \
            -e "s/_USER_/$$USER/g" < $< > $@
 
-funcs.sql:: $(DLOBJS)
+funcs.sql: $(INFILES)
 
-$(DLOBJS): 
+$(INFILES): 
        $(MAKE) -C C-code $@
        cp C-code/$@ .
 
 clean:
        $(MAKE) -C C-code clean
-       rm -f $(QUERIES)
-       rm -f $(DLOBJS)
+       rm -f $(QUERIES) $(INFILES)
index 6e4c7f1e9bda168678f5ca7d5af8e23a6e45281f..0139a943ab56e6e6fce83cec77b3fab436ab4fc5 100644 (file)
@@ -7,7 +7,7 @@
 --
 -- Copyright (c) 1994, Regents of the University of California
 --
--- $Id: advanced.source,v 1.1.1.1 1996/07/09 06:22:34 scrappy Exp $
+-- $Id: advanced.source,v 1.2 1998/02/28 23:37:08 scrappy Exp $
 --
 ---------------------------------------------------------------------------
 
@@ -25,21 +25,21 @@ CREATE TABLE cities (
        name            text,
        population      float8,
        altitude        int             -- (in ft)
-)
+);
 
 CREATE TABLE capitals (
        state           char2
 ) INHERITS (cities);
 
 -- now, let's populate the tables
-INSERT INTO cities VALUES ('San Francisco', 7.24E+5, 63)
-INSERT INTO cities VALUES ('Las Vegas', 2.583E+5, 2174)
-INSERT INTO cities VALUES ('Mariposa', 1200, 1953)
+INSERT INTO cities VALUES ('San Francisco', 7.24E+5, 63);
+INSERT INTO cities VALUES ('Las Vegas', 2.583E+5, 2174);
+INSERT INTO cities VALUES ('Mariposa', 1200, 1953);
 
-INSERT INTO capitals VALUES ('Sacramento', 3.694E+5, 30, 'CA')
-INSERT INTO capitals VALUES ('Madison', 1.913E+5, 845, 'WI')
+INSERT INTO capitals VALUES ('Sacramento', 3.694E+5, 30, 'CA');
+INSERT INTO capitals VALUES ('Madison', 1.913E+5, 845, 'WI');
 
-SELECT * FROM cities
+SELECT * FROM cities;
 SELECT * FROM capitals;
 
 -- like before, a regular query references rows of the base table only
@@ -59,25 +59,27 @@ WHERE c.altitude > 500;
 -----------------------------
 -- Time Travel:
 --     this feature allows you to run historical queries. 
+--     removed for v6.3, but possible using triggers.
+--     see contrib/spi/README for more information.
 -----------------------------
 
 -- first, let's make some changes to the cities table (suppose Mariposa's
 -- population grows 10% this year)
 
-UPDATE cities
-SET population = population * 1.1
-WHERE name = 'Mariposa';
+-- UPDATE cities
+-- SET population = population * 1.1
+-- WHERE name = 'Mariposa';
 
 -- the default time is the current time ('now'):
 
-SELECT * FROM cities WHERE name = 'Mariposa';
+-- SELECT * FROM cities WHERE name = 'Mariposa';
 
 -- we can also retrieve the population of Mariposa ever has. ('epoch' is the
 -- earliest time representable by the system)
 
-SELECT name, population
-FROM cities['epoch', 'now']    -- can be abbreviated to cities[,]
-WHERE name = 'Mariposa';
+-- SELECT name, population
+-- FROM cities['epoch', 'now'] -- can be abbreviated to cities[,]
+-- WHERE name = 'Mariposa';
 
 
 ----------------------
@@ -96,7 +98,7 @@ CREATE TABLE sal_emp (
 INSERT INTO sal_emp VALUES (
        'Bill',
        '{10000,10000,10000,10000}',
-       '{{"meeting", "lunch"}, {}}')
+       '{{"meeting", "lunch"}, {}}');
 
 INSERT INTO sal_emp VALUES (
        'Carol',
@@ -120,6 +122,6 @@ SELECT sal_emp.schedule[1:2][1:1] FROM sal_emp WHERE
 
 
 -- clean up (you must remove the children first)
-DROP TABLE sal_emp
-DROP TABLE capitals
+DROP TABLE sal_emp;
+DROP TABLE capitals;
 DROP TABLE cities;
index 82fe4187d978c31a70691d239a66c15ce1becb0a..05ca6728ae5336cfde363f515bd60f203de6b2f6 100644 (file)
@@ -7,7 +7,7 @@
 --
 -- Copyright (c) 1994, Regents of the University of California
 --
--- $Id: complex.source,v 1.2 1996/12/28 02:22:07 momjian Exp $
+-- $Id: complex.source,v 1.3 1998/02/28 23:37:09 scrappy Exp $
 --
 ---------------------------------------------------------------------------
 
@@ -64,8 +64,8 @@ CREATE TABLE test_complex (
 -- data for user-defined type are just strings in the proper textual
 -- representation. 
 
-INSERT INTO test_complex VALUES ('(1.0, 2.5)', '(4.2, 3.55 )')
-INSERT INTO test_complex VALUES ('(33.0, 51.4)', '(100.42, 93.55)')
+INSERT INTO test_complex VALUES ('(1.0, 2.5)', '(4.2, 3.55 )');
+INSERT INTO test_complex VALUES ('(33.0, 51.4)', '(100.42, 93.55)');
 
 SELECT * FROM test_complex;
 
@@ -138,13 +138,13 @@ SELECT 'READ ABOVE!' AS STOP;
 
 -- first, define the required operators
 CREATE FUNCTION complex_abs_lt(complex, complex) RETURNS bool
-   AS '_OBJWD_/complex.so' LANGUAGE 'c'
+   AS '_OBJWD_/complex.so' LANGUAGE 'c';
 CREATE FUNCTION complex_abs_le(complex, complex) RETURNS bool
-   AS '_OBJWD_/complex.so' LANGUAGE 'c'
+   AS '_OBJWD_/complex.so' LANGUAGE 'c';
 CREATE FUNCTION complex_abs_eq(complex, complex) RETURNS bool
-   AS '_OBJWD_/complex.so' LANGUAGE 'c'
+   AS '_OBJWD_/complex.so' LANGUAGE 'c';
 CREATE FUNCTION complex_abs_ge(complex, complex) RETURNS bool
-   AS '_OBJWD_/complex.so' LANGUAGE 'c'
+   AS '_OBJWD_/complex.so' LANGUAGE 'c';
 CREATE FUNCTION complex_abs_gt(complex, complex) RETURNS bool
    AS '_OBJWD_/complex.so' LANGUAGE 'c';
 
@@ -153,25 +153,25 @@ CREATE FUNCTION complex_abs_gt(complex, complex) RETURNS bool
 CREATE OPERATOR < (
    leftarg = complex, rightarg = complex, procedure = complex_abs_lt,
    restrict = intltsel, join = intltjoinsel
-)
+);
 CREATE OPERATOR <= (
    leftarg = complex, rightarg = complex, procedure = complex_abs_le,
    restrict = intltsel, join = intltjoinsel
-)
+);
 CREATE OPERATOR = (
    leftarg = complex, rightarg = complex, procedure = complex_abs_eq,
    restrict = eqsel, join = eqjoinsel
-)
+);
 CREATE OPERATOR >= (
    leftarg = complex, rightarg = complex, procedure = complex_abs_ge,
    restrict = intgtsel, join = intgtjoinsel
-)
+);
 CREATE OPERATOR > (
    leftarg = complex, rightarg = complex, procedure = complex_abs_gt,
    restrict = intgtsel, join = intgtjoinsel
 );
 
-INSERT INTO pg_opclass VALUES ('complex_abs_ops')
+INSERT INTO pg_opclass VALUES ('complex_abs_ops');
 
 SELECT oid, opcname FROM pg_opclass WHERE opcname = 'complex_abs_ops';
 
@@ -241,7 +241,7 @@ INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
 -- now, we can define a btree index on complex types. First, let's populate
 -- the table. Note that postgres needs many more tuples to start using the
 -- btree index during selects.
-INSERT INTO test_complex VALUES ('(56.0,-22.5)', '(-43.2,-0.07)')
+INSERT INTO test_complex VALUES ('(56.0,-22.5)', '(-43.2,-0.07)');
 INSERT INTO test_complex VALUES ('(-91.9,33.6)', '(8.6,3.0)');
 
 CREATE INDEX test_cplx_ind ON test_complex
@@ -250,3 +250,22 @@ CREATE INDEX test_cplx_ind ON test_complex
 SELECT * from test_complex where a = '(56.0,-22.5)';
 SELECT * from test_complex where a < '(56.0,-22.5)';
 SELECT * from test_complex where a > '(56.0,-22.5)';
+
+DROP FUNCTION complex_in(opaque);
+DROP FUNCTION complex_out(opaque);
+DROP FUNCTION complex_add(complex, complex);
+DROP FUNCTION complex_abs_lt(complex, complex);
+DROP FUNCTION complex_abs_le(complex, complex);
+DROP FUNCTION complex_abs_eq(complex, complex);
+DROP FUNCTION complex_abs_ge(complex, complex);
+DROP FUNCTION complex_abs_gt(complex, complex);
+DROP FUNCTION complex_abs_cmp(complex, complex);
+DROP OPERATOR + (complex, complex);
+DROP OPERATOR < (complex, complex);
+DROP OPERATOR <= (complex, complex);
+DROP OPERATOR = (complex, complex);
+DROP OPERATOR >= (complex, complex);
+DROP OPERATOR > (complex, complex);
+DROP AGGREGATE complex_sum complex;
+DROP TYPE complex;
+DROP TABLE test_complex;
index 90ed0e4ec5a89e600b9582870e12d9a50833df87..5234499be63ca5bd2f98b9993b3042aec140bfef 100644 (file)
@@ -6,7 +6,7 @@
 --
 -- Copyright (c) 1994, Regents of the University of California
 --
--- $Id: syscat.source,v 1.1.1.1 1996/07/09 06:22:34 scrappy Exp $
+-- $Id: syscat.source,v 1.2 1998/02/28 23:37:10 scrappy Exp $
 --
 ---------------------------------------------------------------------------
 
@@ -80,11 +80,11 @@ SELECT u.usename, t.typname
 -- lists all left unary operators
 --
 SELECT o.oprname AS left_unary, 
-       right.typname AS operand,
+       right_type.typname AS operand,
        result.typname AS return_type
-  FROM pg_operator o, pg_type right, pg_type result
+  FROM pg_operator o, pg_type right_type, pg_type result
   WHERE o.oprkind = 'l'           -- left unary
-    and o.oprright = right.oid
+    and o.oprright = right_type.oid
     and o.oprresult = result.oid
   ORDER BY operand;
 
@@ -93,11 +93,11 @@ SELECT o.oprname AS left_unary,
 -- lists all right unary operators
 --
 SELECT o.oprname AS right_unary,
-       left.typname AS operand,
+       left_type.typname AS operand,
        result.typname AS return_type
-  FROM pg_operator o, pg_type left, pg_type result
+  FROM pg_operator o, pg_type left_type, pg_type result
   WHERE o.oprkind = 'r'          -- right unary
-    and o.oprleft = left.oid
+    and o.oprleft = left_type.oid
     and o.oprresult = result.oid
   ORDER BY operand;
 
@@ -105,13 +105,13 @@ SELECT o.oprname AS right_unary,
 -- lists all binary operators
 --
 SELECT o.oprname AS binary_op,
-       left.typname AS left_opr,
-       right.typname AS right_opr,
+       left_type.typname AS left_opr,
+       right_type.typname AS right_opr,
        result.typname AS return_type
-  FROM pg_operator o, pg_type left, pg_type right, pg_type result
+  FROM pg_operator o, pg_type left_type, pg_type right_type, pg_type result
   WHERE o.oprkind = 'b'         -- binary
-    and o.oprleft = left.oid
-    and o.oprright = right.oid
+    and o.oprleft = left_type.oid
+    and o.oprright = right_type.oid
     and o.oprresult = result.oid
   ORDER BY left_opr, right_opr;