Re: CREATE CAST question - Mailing list pgsql-novice

From Tom Lane
Subject Re: CREATE CAST question
Date
Msg-id 15155.1123302024@sss.pgh.pa.us
Whole thread Raw
In response to CREATE CAST question  ("Robert Wimmer" <seppwimmer@hotmail.com>)
List pgsql-novice
"Robert Wimmer" <seppwimmer@hotmail.com> writes:
> I want to define a schema qualified domain and create a cast to cast a
> string in the new domain.

Casts between domains and their underlying types are hard-wired into the
system: you don't get to muck with the semantics by doing CREATE CAST.

The correct way to do this is to define a constraint on the domain,
along the lines of

    create function is_ok_ident(text) returns bool as '
        ... return true if you like the string ...
    ' language plpgsql;

    create domain ident as text check (is_ok_ident(value));

            regards, tom lane

pgsql-novice by date:

Previous
From: "Robert Wimmer"
Date:
Subject: CREATE CAST question
Next
From: Tom Lane
Date:
Subject: Re: Monitoring postmaster.log