Thread: Rules listing error

Rules listing error

From
Tomasz Rybak
Date:
Is rules system in pgAdmin complete?
Here's script I used to create tables
(it's few tables of more complicated system).

CREATE DATABASE c OWNER postgres ENCODING 'UNICODE';
\connect 'c'

CREATE TABLE ta (
    id1 SERIAL NOT NULL,
    id2 INTEGER NOT NULL,
    id3 INTEGER NOT NULL,
    d TIMESTAMP WITH TIME ZONE NOT NULL,
    a CHARACTER VARYING(128) NOT NULL,
    b CHARACTER VARYING(3) NOT NULL,
    c TEXT NOT NULL,

    CONSTRAINT ta_pkey PRIMARY KEY (id1)
);

CREATE TABLE tb (
    id1 INTEGER NOT NULL,
    id2 INTEGER NOT NULL,
    id3 INTEGER NOT NULL,
    d TIMESTAMP WITH TIME ZONE NOT NULL,
    a CHARACTER VARYING(128) NOT NULL,
    b CHARACTER VARYING(3) NOT NULL,
    c TEXT NOT NULL,

    CONSTRAINT tb_pkey PRIMARY KEY (id1)
);

CREATE TABLE tc (
    id1 INTEGER NOT NULL,
    id2 INTEGER NOT NULL,
    id3 INTEGER NOT NULL,
    d TIMESTAMP WITH TIME ZONE NOT NULL,
    a TIMESTAMP WITH TIME ZONE NOT NULL,
    b TEXT NOT NULL,
    c INTEGER NOT NULL,

    CONSTRAINT tc_pkey PRIMARY KEY (id1)
);

CREATE TABLE td (
    id1 INTEGER UNIQUE,
    id2 INTEGER NOT NULL,
    id3 INTEGER NOT NULL,
    d TIMESTAMP WITH TIME ZONE NOT NULL,
    a INTEGER NOT NULL,
    b INTEGER NOT NULL CHECK (b > 0),

    CONSTRAINT td_pkey PRIMARY KEY (id2, id3)
);

CREATE RULE update_ta AS ON UPDATE TO ta
DO (UPDATE td SET
id1 = NEW.id1, d = NEW.d
WHERE
id2 = NEW.id2 AND id3 = NEW.id3
AND id1 = NEW.id1);

CREATE RULE delete_ta AS ON DELETE TO ta
DO (UPDATE td SET a = 1
WHERE
id2 = OLD.id2 AND id3 = OLD.id3
AND id1 = OLD.id1);


CREATE RULE insert_tb AS ON INSERT TO tb
DO (UPDATE td SET
a = 3
WHERE
id2 = NEW.id2 AND id2 = NEW.id2
AND id1 = NEW.id1);

CREATE RULE update_tb AS ON UPDATE TO tb
DO (UPDATE td SET
id1 = NEW.id1, d = NEW.d
WHERE
id2 = NEW.id2 AND id3 = NEW.id3
AND id1 = NEW.id1);

CREATE RULE delete_tb AS ON DELETE TO tb
DO (UPDATE td SET
id1 = (SELECT id1 FROM tc
WHERE
id2 = OLD.id2 AND id3 = OLD.id3
ORDER BY id1 DESC LIMIT 1),
b = b - 1
WHERE
id2 = OLD.id2 AND id3 = OLD.id3
AND id1 = OLD.id1);


I run this script to create database on PG 8.0.3
(from Debian Sid 8.0.3-14) and on PG 8.1
(from Debian Experimental 8.0+8.1beta-1).

When I check created database using pgAdmin rev 4427,
it doesn't show any of existing rules (just created ones).
It shows triggers; but no rules.

What's going on?

--
Tomasz Rybak <bogomips@post.pl>


Re: Rules listing error

From
Andreas Pflug
Date:
Tomasz Rybak wrote:
> Is rules system in pgAdmin complete?
> Here's script I used to create tables
> (it's few tables of more complicated system).

Fixed in SVN, thx for reporting.

Regards,
Andreas