System vs non-system casts - Mailing list pgsql-hackers

From Jim C. Nasby
Subject System vs non-system casts
Date
Msg-id 20050410231029.GR93835@decibel.org
Whole thread Raw
Responses Re: System vs non-system casts
List pgsql-hackers
In working on the newsysviews project we've discovered that there's no
definitive way to determine if a cast is a system cast (system as in
part of postgresql/created by createdb) or not. What pg_dump does (and
what we're doing now for lack of a better solution) is any cast that
doesn't involve a user-created type, or a user-created conversion
function is considered a system cast. This means if a user creates a
cast between two different system types using a system function (to use
a bad example, say text->int), that cast won't show up in pg_user_casts,
and more important, it won't be backed up by pg_dump.

This seems sub-optimal. :)

Is there a reasonable way to fix this? For most objects, you can
determine if it's a system object or not based on the schema it lives
in. So, one possibility is to put casts into schemas. This would have
the added effect of allowing you to 'hide' a cast by removing it's
schema from search_path.

Another possibility would be to add an is_system column to pg_cast.
Casts created by the system as part of database creation (or at least
the initial creation of the template databases) would have this field
set to true, whereas user created casts would have it set to false.
Instead of having two seperate methods to create casts, you could do a
bulk update of pg_cast as part of database creation.

Thoughts?
-- 
Jim C. Nasby, Database Consultant               decibel@decibel.org 
Give your computer some brain candy! www.distributed.net Team #1828

Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"


pgsql-hackers by date:

Previous
From: Josh Berkus
Date:
Subject: Re: [PATCHES] DELETE ... USING
Next
From: Oliver Jowett
Date:
Subject: Re: Unicode problems on IRC