mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
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. :)
This commit is contained in:
parent
f3f7712675
commit
207acd86d7
@ -4,7 +4,7 @@
|
|||||||
# Makefile for tutorial
|
# Makefile for tutorial
|
||||||
#
|
#
|
||||||
# IDENTIFICATION
|
# IDENTIFICATION
|
||||||
# $Header: /cvsroot/pgsql/src/tutorial/Makefile,v 1.7 1998/02/28 23:37:07 scrappy Exp $
|
# $Header: /cvsroot/pgsql/src/tutorial/Makefile,v 1.8 1998/03/01 04:52:55 scrappy Exp $
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -29,16 +29,7 @@ DLOBJS= complex$(DLSUFFIX) funcs$(DLSUFFIX)
|
|||||||
|
|
||||||
QUERIES= advanced.sql basics.sql complex.sql funcs.sql syscat.sql
|
QUERIES= advanced.sql basics.sql complex.sql funcs.sql syscat.sql
|
||||||
|
|
||||||
INFILES= $(DLOBJS)
|
all: $(DLOBJS) $(QUERIES)
|
||||||
|
|
||||||
#
|
|
||||||
# plus exports files
|
|
||||||
#
|
|
||||||
ifdef EXPSUFF
|
|
||||||
INFILES+= $(DLOBJS:.o=$(EXPSUFF))
|
|
||||||
endif
|
|
||||||
|
|
||||||
all: $(QUERIES)
|
|
||||||
|
|
||||||
%.sql: %.source
|
%.sql: %.source
|
||||||
if [ -z "$$USER" ]; then USER=$$LOGNAME; fi; \
|
if [ -z "$$USER" ]; then USER=$$LOGNAME; fi; \
|
||||||
@ -51,12 +42,7 @@ all: $(QUERIES)
|
|||||||
-e "s:_DLSUFFIX_:$(DLSUFFIX):g" \
|
-e "s:_DLSUFFIX_:$(DLSUFFIX):g" \
|
||||||
-e "s/_USER_/$$USER/g" < $< > $@
|
-e "s/_USER_/$$USER/g" < $< > $@
|
||||||
|
|
||||||
funcs.sql: $(INFILES)
|
funcs.sql: $(DLOBJS)
|
||||||
|
|
||||||
$(INFILES):
|
|
||||||
$(MAKE) -C C-code $@
|
|
||||||
cp C-code/$@ .
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -C C-code clean
|
rm -f $(DLOBJS) $(QUERIES)
|
||||||
rm -f $(QUERIES) $(INFILES)
|
|
||||||
|
@ -4,13 +4,11 @@ to compile all the scripts and C files for the user-defined functions
|
|||||||
and types. (make needs to be GNU make and may be named something
|
and types. (make needs to be GNU make and may be named something
|
||||||
different on your system)
|
different on your system)
|
||||||
|
|
||||||
Then, change to the object directory
|
Then, run psql with the -s flag:
|
||||||
% cd obj
|
|
||||||
|
|
||||||
and run psql with the -s flag:
|
|
||||||
% psql -s
|
% psql -s
|
||||||
|
|
||||||
Welcome to the POSTGRES95 interactive sql monitor:
|
Welcome to the POSTGRESQL interactive sql monitor:
|
||||||
|
Please read the file COPYRIGHT for copyright terms of POSTGRESQL
|
||||||
|
|
||||||
type \? for help on slash commands
|
type \? for help on slash commands
|
||||||
type \q to quit
|
type \q to quit
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
/* do not include libpq-fe.h for backend-loaded functions*/
|
/* do not include libpq-fe.h for backend-loaded functions*/
|
||||||
/* #include "libpq-fe.h" */
|
/* #include "libpq-fe.h" */
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
#include "utils/elog.h"
|
|
||||||
#include "utils/palloc.h"
|
|
||||||
#include "utils/mcxt.h"
|
#include "utils/mcxt.h"
|
||||||
|
|
||||||
typedef struct Complex
|
typedef struct Complex
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
--
|
--
|
||||||
-- Copyright (c) 1994, Regents of the University of California
|
-- Copyright (c) 1994, Regents of the University of California
|
||||||
--
|
--
|
||||||
-- $Id: complex.source,v 1.3 1998/02/28 23:37:09 scrappy Exp $
|
-- $Id: complex.source,v 1.4 1998/03/01 04:52:59 scrappy Exp $
|
||||||
--
|
--
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -19,7 +19,7 @@
|
|||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
-- Assume the user defined functions are in _OBJWD_/complex.so
|
-- Assume the user defined functions are in _OBJWD_/complex.so
|
||||||
-- Look at $PWD/C-code/complex.c for the source.
|
-- Look at $PWD/complex.c for the source.
|
||||||
|
|
||||||
-- the input function 'complex_in' takes a null-terminated string (the
|
-- the input function 'complex_in' takes a null-terminated string (the
|
||||||
-- textual representation of the type) and turns it into the internal
|
-- textual representation of the type) and turns it into the internal
|
||||||
@ -77,7 +77,7 @@ SELECT * FROM test_complex;
|
|||||||
-- arguments.)
|
-- arguments.)
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
-- first, define a function complex_add (also in C-code/complex.c)
|
-- first, define a function complex_add (also in complex.c)
|
||||||
CREATE FUNCTION complex_add(complex, complex)
|
CREATE FUNCTION complex_add(complex, complex)
|
||||||
RETURNS complex
|
RETURNS complex
|
||||||
AS '_OBJWD_/complex.so'
|
AS '_OBJWD_/complex.so'
|
||||||
@ -224,8 +224,6 @@ INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy,
|
|||||||
WHERE amname = 'btree' and opcname = 'complex_abs_ops'
|
WHERE amname = 'btree' and opcname = 'complex_abs_ops'
|
||||||
and c.oprname = '>';
|
and c.oprname = '>';
|
||||||
|
|
||||||
DROP table complex_ops_tmp;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
CREATE FUNCTION complex_abs_cmp(complex, complex) RETURNS int4
|
CREATE FUNCTION complex_abs_cmp(complex, complex) RETURNS int4
|
||||||
AS '_OBJWD_/complex.so' LANGUAGE 'c';
|
AS '_OBJWD_/complex.so' LANGUAGE 'c';
|
||||||
@ -251,6 +249,50 @@ 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)';
|
||||||
SELECT * from test_complex where a > '(56.0,-22.5)';
|
SELECT * from test_complex where a > '(56.0,-22.5)';
|
||||||
|
|
||||||
|
DELETE FROM pg_amop where (amopid, amopclaid, amopopr, amopstrategy)
|
||||||
|
= (
|
||||||
|
SELECT am.oid, opcl.oid, c.opoid, 1
|
||||||
|
FROM pg_am am, pg_opclass opcl, complex_ops_tmp c
|
||||||
|
WHERE amname = 'btree' and opcname = 'complex_abs_ops'
|
||||||
|
and c.oprname = '<');
|
||||||
|
|
||||||
|
DELETE FROM pg_amop where (amopid, amopclaid, amopopr, amopstrategy)
|
||||||
|
= (
|
||||||
|
SELECT am.oid, opcl.oid, c.opoid, 2
|
||||||
|
FROM pg_am am, pg_opclass opcl, complex_ops_tmp c
|
||||||
|
WHERE amname = 'btree' and opcname = 'complex_abs_ops'
|
||||||
|
and c.oprname = '<=');
|
||||||
|
|
||||||
|
DELETE FROM pg_amop where (amopid, amopclaid, amopopr, amopstrategy)
|
||||||
|
= (
|
||||||
|
SELECT am.oid, opcl.oid, c.opoid, 3
|
||||||
|
FROM pg_am am, pg_opclass opcl, complex_ops_tmp c
|
||||||
|
WHERE amname = 'btree' and opcname = 'complex_abs_ops'
|
||||||
|
and c.oprname = '=');
|
||||||
|
|
||||||
|
DELETE FROM pg_amop where (amopid, amopclaid, amopopr, amopstrategy)
|
||||||
|
= (
|
||||||
|
SELECT am.oid, opcl.oid, c.opoid, 4
|
||||||
|
FROM pg_am am, pg_opclass opcl, complex_ops_tmp c
|
||||||
|
WHERE amname = 'btree' and opcname = 'complex_abs_ops'
|
||||||
|
and c.oprname = '>=');
|
||||||
|
|
||||||
|
DELETE FROM pg_amop where (amopid, amopclaid, amopopr, amopstrategy)
|
||||||
|
= (
|
||||||
|
SELECT am.oid, opcl.oid, c.opoid, 5
|
||||||
|
FROM pg_am am, pg_opclass opcl, complex_ops_tmp c
|
||||||
|
WHERE amname = 'btree' and opcname = 'complex_abs_ops'
|
||||||
|
and c.oprname = '>');
|
||||||
|
|
||||||
|
DELETE FROM pg_amproc where (amid, amopclaid, amproc, amprocnum)
|
||||||
|
= (
|
||||||
|
SELECT am.oid, opcl.oid, pro.oid, 1
|
||||||
|
FROM pg_am am, pg_opclass opcl, pg_proc pro
|
||||||
|
WHERE amname = 'btree' and opcname = 'complex_abs_ops'
|
||||||
|
and proname = 'complex_abs_cmp');
|
||||||
|
|
||||||
|
DELETE FROM pg_opclass WHERE opcname = 'complex_abs_ops';
|
||||||
|
|
||||||
DROP FUNCTION complex_in(opaque);
|
DROP FUNCTION complex_in(opaque);
|
||||||
DROP FUNCTION complex_out(opaque);
|
DROP FUNCTION complex_out(opaque);
|
||||||
DROP FUNCTION complex_add(complex, complex);
|
DROP FUNCTION complex_add(complex, complex);
|
||||||
@ -268,4 +310,4 @@ DROP OPERATOR >= (complex, complex);
|
|||||||
DROP OPERATOR > (complex, complex);
|
DROP OPERATOR > (complex, complex);
|
||||||
DROP AGGREGATE complex_sum complex;
|
DROP AGGREGATE complex_sum complex;
|
||||||
DROP TYPE complex;
|
DROP TYPE complex;
|
||||||
DROP TABLE test_complex;
|
DROP TABLE test_complex, complex_ops_tmp;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user