Hello.
I have not got any help from HACKERS, SQL and GENERAL groups so I send my
problem to you. Could you send the clear indication whether lack of
inheritance of functions is a bug. If it is not, I would appreciate ANY
example showing inheritance of functions in postgres.
Thanks,
Regards,
Andrzej Mazurkiewicz
In Postgres Users Guide, CREATE TABLE section, the following is stated:
Postgres automatically allows the created table to inherit functions on
tables above it in the inheritance hierarchy.
Aside: Inheritance of functions is done according to the
conventions of the Common Lisp Object System (CLOS).
I have tried different constructs but I have not been able to create such a
function. Can anybody send me an example of a function that will be
inherited by inherited table? I. e.
create table A (
.
.
);
create function F ...
create table B (
..
) inherits (A);
Now I assume that I can somehow use function F on table B
The specific example is given below !!
Thank you,
Regards,
Andrzej Mazurkiewicz
-----Original Message-----
From: Andrzej Mazurkiewicz
Sent: 27 paYdziernika 1999 18:09
To: 'pgsql-general@hub.org'
Subject: RE: [GENERAL] FW: inheritance of functions
Hello.
Here is an example of my problem:
ccbslin2:~/lipa$ psql -c "drop database archimp0;" template1
DESTROYDB
ccbslin2:~/lipa$ psql -c "create database archimp0;" template1
CREATEDB
ccbslin2:~/lipa$ psql -f funinh1.sql archimp0
BEGIN WORK;
BEGIN
CREATE TABLE A (
liczba float
);
CREATE
COMMIT WORK;
END
BEGIN WORK;
BEGIN
CREATE FUNCTION suma (A) RETURNS float
AS 'SELECT $1.liczba AS suma;' LANGUAGE 'sql';
CREATE
COMMIT WORK;
END
BEGIN WORK;
BEGIN
CREATE TABLE B (
liczwym float
) INHERITS (A)
;
CREATE
COMMIT WORK;
END
BEGIN WORK;
BEGIN
INSERT INTO A (liczba) VALUES (1.56);
INSERT 71414 1
COMMIT WORK;
END
BEGIN WORK;
BEGIN
INSERT INTO B (liczba, liczwym) VALUES (2.5, 3.2);
INSERT 71415 1
COMMIT WORK;
END
select liczba, suma(A) from A;
liczba|suma
------+----
1.56|1.56
(1 row)
select liczba, suma(A) from A*;
liczba|suma
------+----
1.56|1.56
2.5| 2.5
(2 rows)
[Andrzej Mazurkiewicz] --
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
select liczba, suma(B) from B; [Andrzej Mazurkiewicz] !!!!!!!
ERROR: Functions on sets are not yet supported [Andrzej Mazurkiewicz]
!!!!!!!
[Andrzej Mazurkiewicz] --
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EOF
----------------------------------------------------------------------------
--------------------------------------
After invoking psql:
archimp0=> select * from pg_proc where proname = 'suma';
proname|proowner|prolang|proisinh|proistrusted|proiscachable|pronargs|proret
set|prorettype|
proargtypes|probyte_pct|properbyte_cpu|propercall_cpu|proouti
n_ratio|prosrc |probin
-------+--------+-------+--------+------------+-------------+--------+------
---+----------+-------------------+-----------+--------------+--------------
+--------------+-------------------------+------
suma | 302| 14|f |t |f | 1|f
| 701|71393 0 0 0 0 0 0 0| 100| 0| 0|
100|SELECT $1.liczba AS suma;|-
(1 row)
archimp0=>
I am looking for working example !!!!!
Regards,
Andrzej Mazurkiewicz
-----Original Message-----