[postgis-users] create tables smarter
Chris Hermansen
chris.hermansen at timberline.ca
Wed Jun 4 16:19:11 PDT 2008
Kevin, I'm always game to try something that's potentially worthwhile :-)
clh=# create table tracks (tablename name);
CREATE TABLE
clh=# create rule table_rule as on insert to pg_class do also
insert into tracks values (new.relname);
CREATE RULE
clh=# create table foo (a int, b text);
CREATE TABLE
clh=# create table bar (c float, d date);
CREATE TABLE
clh=# select * from tracks;
tablename
-----------
(0 rows)
clh=# select * from pg_class where relname = 'foo';
relname | relnamespace | reltype | relowner | relam | relfilenode |
reltablespace | relpages | reltuples | reltoastrelid | reltoastidxid
| relhasindex | relisshared | relkind | relnatts | relchecks |
reltriggers | relukeys | relfkeys | relrefs | relhasoids |
relhaspkey | relhasrules | relhassubclass | relfrozenxid | relacl |
reloptions
---------+--------------+---------+----------+-------+-------------+---------------+----------+-----------+---------------+---------------+-------------+-------------+---------+----------+-----------+-------------+----------+----------+---------+------------+------------+-------------+----------------+--------------+--------+------------
foo | 2200 | 24623 | 16384 | 0 | 24621
| 0 | 0 | 0 | 24624 |
0 | f | f | r | 2 | 0
| 0 | 0 | 0 | 0 | f |
f | f | f | 655 | |
(1 row)
clh=#
Oh well.
Kevin Neufeld wrote:
>
> Chris Hermansen wrote:
> ...
>> OK, so far, so good. Let's try the same thing with pg_tables:
>>
>> clh=# drop rule table_rule on data;
>> DROP RULE
>> clh=# drop table tracks;
>> DROP TABLE
>> clh=# drop table data;
>> DROP TABLE
>> clh=# create table tracks (tablename name);
>> CREATE TABLE
>> clh=# create rule table_rule as on insert to pg_tables do also
>> insert into tracks values (new.tablename);
>> CREATE RULE
>> clh=# create table fink (a int, b text);
>> CREATE TABLE
>> clh=# create table zink (c float, d date);
>> CREATE TABLE
>> clh=# select * from tracks;
>> tablename
>> -----------
>> (0 rows)
>>
>> clh=#
>>
>>
>> Well, so much for that idea. We can create rules on system tables, they
>> just don't work.
>>
>> Bummer.
>>
>
> Just thought I'd point out Chris that pg_tables is a view, not a
> system table. For kicks, try your rule on pg_class.
>
> -- Kevin
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
--
Regards,
Chris Hermansen mailto:chris.hermansen at timberline.ca
tel+1.604.714.2878 · fax+1.604.733.0631 · mob+1.778.232.0644
Timberline Natural Resource Group · http://www.timberline.ca
401 · 958 West 8th Avenue · Vancouver BC · Canada · V5Z 1E5
More information about the postgis-users
mailing list