| From: | Andrzej Mazurkiewicz <andrzej(dot)mazurkiewicz(at)polkomtel(dot)com(dot)pl> | 
|---|---|
| To: | "'pgsql-hackers(at)hub(dot)org'" <pgsql-hackers(at)hub(dot)org> | 
| Subject: | inheritance of functions | 
| Date: | 1999-11-02 09:11:43 | 
| Message-ID: | 13288F4408ADD11186FF0060B06A43130164F976@MSGWAW1 | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
Hello.
I have not got any help from SQL and GENERAL groups so I send my problem to
you.
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(at)hub(dot)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|pror
> etset|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-----
> From:	Aaron J. Seigo [SMTP:aaron(at)gtv(dot)ca]
> Sent:	27 paYdziernika 1999 17:39
> To:	Andrzej Mazurkiewicz; 'pgsql-general(at)hub(dot)org'
> Subject:	Re: [GENERAL] FW: inheritance of functions
> 
> hi...
> 
> > >  Postgres automatically allows the created table to inherit functions
> on
> > > tables above it in the inheritance hierarchy. 
> > > create table A (
> > > .
> > > .
> > > );
> > > 
> > > create function F ...
> > > 
> > > create table B (
> > > ..
> > > ) inherits (A);
> > > 
> > > Now I assume that I can somehow use function F on table B 
> 
> you would be able to use function F on table B even if it didn't inherit
> A. 
> 
> however, if you construct rules, triggers, etc... on table A, these should
> be
> inherited by table B.
> 
> the manual is, as far as my experience has led me to believe, referring to
> functions "bound" (for lack of a better word) to the parent table....
> 
> -- 
> Aaron J. Seigo
> Sys Admin
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 1999-11-02 09:20:33 | Re: [GENERAL] users in Postgresql | 
| Previous Message | Gene Sokolov | 1999-11-02 09:04:14 | Re: [HACKERS] file descriptors leak? |