Thread

  1. inheritance of functions in postgres

    Andrzej Mazurkiewicz <andrzej.mazurkiewicz@polkomtel.com.pl> — 2000-01-04T15:27:29Z

    ============================================================================
                            POSTGRESQL BUG REPORT TEMPLATE
    ============================================================================
    
    
    Your name               : Andrzej Mazurkiewicz
    Your email address      : andrzej.mazurkiewicz@polkomtel.com.pl
    
    
    System Configuration
    ---------------------
      Architecture (example: Intel Pentium)         : Intel pentium 686
    
      Operating System (example: Linux 2.0.26 ELF)  : Linux 2.2.6 (Slackware4.0)
    
      PostgreSQL version (example: PostgreSQL-6.5.2):   PostgreSQL-6.5.1
    
      Compiler used (example:  gcc 2.8.0)           : gcc 2.8.1
    
    
    Please enter a FULL description of your problem:
    ------------------------------------------------
    
    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.
    
    
    
    Please describe a way to repeat the problem.   Please try to provide a
    concise reproducible example, if at all possible: 
    ----------------------------------------------------------------------
    
    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=> 
    
    
    
    
    If you know how this problem might be fixed, list the solution below:
    ---------------------------------------------------------------------