참고

사용자 정의 연산자 예시

-----------------------------------------------------------------
--                           도메인
-----------------------------------------------------------------
CREATE DOMAIN YES_OR_NO AS CHAR(1)
CHECK(
   VALUE IN ('0', '1')
)
DEFAULT '0'
NOT NULL;
-----------------------------------------------------------------
--                    도메인 커스텀 연산자
-----------------------------------------------------------------
-- YES_OR_NO = INTEGER
CREATE OR REPLACE FUNCTION EQUALS_YN_INT
(
    _left  YES_OR_NO
   ,_right INTEGER
)
RETURNS BOOLEAN
AS $$
BEGIN
    RETURN _left::INTEGER = _right;
END; $$
LANGUAGE 'plpgsql';

-- YES_OR_NO = BOOLEAN
CREATE OR REPLACE FUNCTION EQUALS_YN_BOOL
(
    _left  YES_OR_NO
   ,_right BOOLEAN
)
RETURNS BOOLEAN
AS $$
BEGIN
    RETURN _left::BOOLEAN = _right;
END; $$
LANGUAGE 'plpgsql';

CREATE OPERATOR = (FUNCTION = EQUALS_YN_INT,  leftarg = YES_OR_NO, rightarg = INTEGER);
CREATE OPERATOR = (FUNCTION = EQUALS_YN_BOOL, leftarg = YES_OR_NO, rightarg = BOOLEAN);