possible DOMAIN implementation

From: Horák Daniel <horak(at)sit(dot)plzen-city(dot)cz>
To: <pgsql-hackers(at)postgreSQL(dot)org>
Subject: possible DOMAIN implementation
Date: 2001-05-17 15:22:05
Message-ID: 9C8918CC8CDAAC4AA79D4594A480648901E68C2B@EXCHANGE.mmp.plzen-city.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

I have spend some thinking about implementation of DOMAIN capability.
Here are my ideas.

What is a domain? It is an alias for a type with size, constraints and
default values. It is like one column of a table. And this is the main
idea of my "implementation". It should be possible to implement it using
existing system tables.

New rules for grammar can be easily created from already existing pieces
(column definition of a table).

How to store information about a domain in system tables?
When a new domain is created it will:
- put a record into pg_type with typnam = domain name, new code for
typtype = 'd' and typrelid = oid of a new record in pg_class (next line)
- put a record into pg_class to create a fictional table with a new
relkind ('d'?), relnatts = 1, relname can be system generated
(pg_d_<domainname>)
- put a records into pg_attribute and pg_attrdef with "column
(attribute) definition" - real type, size, default value etc., owner
will the fictional table from the previous step

Then it will be required to modify functions that works with types. When
typtype of a retrieved type is 'd' then it will perform lookups into
pg_class, pg_attribute and pg_attrdef to find the real definition of the
domain. These additional lookups will also create a performace penalty
of using domains. But every feature has its costs. I know this paragraph
about the real implementation is very short, but I think there are
people that know the "type mechanism" better then I know. And can easier
tell if it is possible to go this way.

I hope you understand my explanation. It is also possible that I don't
know some aspects of the backend code that makes my idea wrong.

Dan

----------------------------------------------
Ing. Daniel Horak
network and system administrator
e-mail: horak(at)sit(dot)plzen-city(dot)cz
privat e-mail: dan(dot)horak(at)email(dot)cz ICQ:36448176
----------------------------------------------

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2001-05-17 15:50:07 Adding index flag showing tuple status
Previous Message jacky_shu 2001-05-17 15:19:06 Need Postgresql ODBC Driver