Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 207acd8

Browse files
committed
From: Darren King <darrenk@insightdist.com>
1. Make 'all' works without complaint. Don't have to add the .exp files to the files list. They are made automagically when making the respective shared lib file. Only port that actually uses EXPSUFF (from makefiles/Makefile.*) is Aix, so if this breaks anybody else, let me know, asap. 2. Make 'clean' actually cleans up correctly. Previously, it would leave the .o files in C-code directory. 3. Changed references to reflect new location of .c files. 4. Added DELETE statements to complex.source so that it tidies up when done. Previously, it would leave things in pg_amop, pg_amproc and pg_opclass. Only possible to do this with the new SUBSELECT code in 6.3. Nice work, fellas... Not deleting the index entries would cause a non-fatal error if complex.sql was run again on the same database. Much tidier now. 5. Corrected the README. obj directory hasn't existed since Bryan redid the make way back when. Also changed the snipet from psql to match the current version. POSTGRES95?!? I don't think so. :)
1 parent f3f7712 commit 207acd8

File tree

4 files changed

+55
-31
lines changed

4 files changed

+55
-31
lines changed

src/tutorial/Makefile

+4-18
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for tutorial
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/tutorial/Makefile,v 1.7 1998/02/28 23:37:07 scrappy Exp $
7+
# $Header: /cvsroot/pgsql/src/tutorial/Makefile,v 1.8 1998/03/01 04:52:55 scrappy Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -29,16 +29,7 @@ DLOBJS= complex$(DLSUFFIX) funcs$(DLSUFFIX)
2929

3030
QUERIES= advanced.sql basics.sql complex.sql funcs.sql syscat.sql
3131

32-
INFILES= $(DLOBJS)
33-
34-
#
35-
# plus exports files
36-
#
37-
ifdef EXPSUFF
38-
INFILES+= $(DLOBJS:.o=$(EXPSUFF))
39-
endif
40-
41-
all: $(QUERIES)
32+
all: $(DLOBJS) $(QUERIES)
4233

4334
%.sql: %.source
4435
if [ -z "$$USER" ]; then USER=$$LOGNAME; fi; \
@@ -51,12 +42,7 @@ all: $(QUERIES)
5142
-e "s:_DLSUFFIX_:$(DLSUFFIX):g" \
5243
-e "s/_USER_/$$USER/g" < $< > $@
5344

54-
funcs.sql: $(INFILES)
55-
56-
$(INFILES):
57-
$(MAKE) -C C-code $@
58-
cp C-code/$@ .
45+
funcs.sql: $(DLOBJS)
5946

6047
clean:
61-
$(MAKE) -C C-code clean
62-
rm -f $(QUERIES) $(INFILES)
48+
rm -f $(DLOBJS) $(QUERIES)

src/tutorial/README

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ to compile all the scripts and C files for the user-defined functions
44
and types. (make needs to be GNU make and may be named something
55
different on your system)
66

7-
Then, change to the object directory
8-
% cd obj
9-
10-
and run psql with the -s flag:
7+
Then, run psql with the -s flag:
118
% psql -s
129

13-
Welcome to the POSTGRES95 interactive sql monitor:
10+
Welcome to the POSTGRESQL interactive sql monitor:
11+
Please read the file COPYRIGHT for copyright terms of POSTGRESQL
1412

1513
type \? for help on slash commands
1614
type \q to quit

src/tutorial/complex.c

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
/* do not include libpq-fe.h for backend-loaded functions*/
99
/* #include "libpq-fe.h" */
1010
#include "postgres.h"
11-
#include "utils/elog.h"
12-
#include "utils/palloc.h"
1311
#include "utils/mcxt.h"
1412

1513
typedef struct Complex

src/tutorial/complex.source

+48-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
--
88
-- Copyright (c) 1994, Regents of the University of California
99
--
10-
-- $Id: complex.source,v 1.3 1998/02/28 23:37:09 scrappy Exp $
10+
-- $Id: complex.source,v 1.4 1998/03/01 04:52:59 scrappy Exp $
1111
--
1212
---------------------------------------------------------------------------
1313

@@ -19,7 +19,7 @@
1919
-----------------------------
2020

2121
-- Assume the user defined functions are in _OBJWD_/complex.so
22-
-- Look at $PWD/C-code/complex.c for the source.
22+
-- Look at $PWD/complex.c for the source.
2323

2424
-- the input function 'complex_in' takes a null-terminated string (the
2525
-- textual representation of the type) and turns it into the internal
@@ -77,7 +77,7 @@ SELECT * FROM test_complex;
7777
-- arguments.)
7878
-----------------------------
7979

80-
-- first, define a function complex_add (also in C-code/complex.c)
80+
-- first, define a function complex_add (also in complex.c)
8181
CREATE FUNCTION complex_add(complex, complex)
8282
RETURNS complex
8383
AS '_OBJWD_/complex.so'
@@ -224,8 +224,6 @@ INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy,
224224
WHERE amname = 'btree' and opcname = 'complex_abs_ops'
225225
and c.oprname = '>';
226226

227-
DROP table complex_ops_tmp;
228-
229227
--
230228
CREATE FUNCTION complex_abs_cmp(complex, complex) RETURNS int4
231229
AS '_OBJWD_/complex.so' LANGUAGE 'c';
@@ -251,6 +249,50 @@ SELECT * from test_complex where a = '(56.0,-22.5)';
251249
SELECT * from test_complex where a < '(56.0,-22.5)';
252250
SELECT * from test_complex where a > '(56.0,-22.5)';
253251

252+
DELETE FROM pg_amop where (amopid, amopclaid, amopopr, amopstrategy)
253+
= (
254+
SELECT am.oid, opcl.oid, c.opoid, 1
255+
FROM pg_am am, pg_opclass opcl, complex_ops_tmp c
256+
WHERE amname = 'btree' and opcname = 'complex_abs_ops'
257+
and c.oprname = '<');
258+
259+
DELETE FROM pg_amop where (amopid, amopclaid, amopopr, amopstrategy)
260+
= (
261+
SELECT am.oid, opcl.oid, c.opoid, 2
262+
FROM pg_am am, pg_opclass opcl, complex_ops_tmp c
263+
WHERE amname = 'btree' and opcname = 'complex_abs_ops'
264+
and c.oprname = '<=');
265+
266+
DELETE FROM pg_amop where (amopid, amopclaid, amopopr, amopstrategy)
267+
= (
268+
SELECT am.oid, opcl.oid, c.opoid, 3
269+
FROM pg_am am, pg_opclass opcl, complex_ops_tmp c
270+
WHERE amname = 'btree' and opcname = 'complex_abs_ops'
271+
and c.oprname = '=');
272+
273+
DELETE FROM pg_amop where (amopid, amopclaid, amopopr, amopstrategy)
274+
= (
275+
SELECT am.oid, opcl.oid, c.opoid, 4
276+
FROM pg_am am, pg_opclass opcl, complex_ops_tmp c
277+
WHERE amname = 'btree' and opcname = 'complex_abs_ops'
278+
and c.oprname = '>=');
279+
280+
DELETE FROM pg_amop where (amopid, amopclaid, amopopr, amopstrategy)
281+
= (
282+
SELECT am.oid, opcl.oid, c.opoid, 5
283+
FROM pg_am am, pg_opclass opcl, complex_ops_tmp c
284+
WHERE amname = 'btree' and opcname = 'complex_abs_ops'
285+
and c.oprname = '>');
286+
287+
DELETE FROM pg_amproc where (amid, amopclaid, amproc, amprocnum)
288+
= (
289+
SELECT am.oid, opcl.oid, pro.oid, 1
290+
FROM pg_am am, pg_opclass opcl, pg_proc pro
291+
WHERE amname = 'btree' and opcname = 'complex_abs_ops'
292+
and proname = 'complex_abs_cmp');
293+
294+
DELETE FROM pg_opclass WHERE opcname = 'complex_abs_ops';
295+
254296
DROP FUNCTION complex_in(opaque);
255297
DROP FUNCTION complex_out(opaque);
256298
DROP FUNCTION complex_add(complex, complex);
@@ -268,4 +310,4 @@ DROP OPERATOR >= (complex, complex);
268310
DROP OPERATOR > (complex, complex);
269311
DROP AGGREGATE complex_sum complex;
270312
DROP TYPE complex;
271-
DROP TABLE test_complex;
313+
DROP TABLE test_complex, complex_ops_tmp;

0 commit comments

Comments
 (0)