July 2005
Intermediate to advanced
1032 pages
27h 10m
English
Now that you understand the difference between internal and external forms, it should be obvious that PostgreSQL needs to convert values between these forms. When you define a new data type, you tell PostgreSQL how to convert a value from external form to internal form and from internal form to external form.
Let's create a simple type that mimics the built-in TEXT data type. Data type descriptions are stored in the pg_type system table. We are interested in three of the columns:
movies=# SELECT typinput, typoutput, typlen movies-# FROM pg_type movies-# WHERE typname = 'text'; typinput | typoutput | typlen ----------+-----------+-------- textin | textout | -1
The typinput column tells you the name of ...
Read now
Unlock full access