Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Operator Test Functions Not Ideal #43

Open
theory opened this Issue · 0 comments

1 participant

@theory
Owner

The has_operator(), has_leftop(), and has_rightop() functions do not allow schema names to be passed for the type parameters. I think it makes sense to just let them be included in the strings, and use pg_format_type() to format the type names.

Once that's done, add operator_owner_is(), leftop_owner_is(), and rightop_owner_is(). Here are some functions to get started on those:

CREATE OR REPLACE FUNCTION _get_operator_owner ( NAME, NAME, NAME, NAME )
RETURNS NAME AS $$
    SELECT pg_catalog.pg_get_userbyid(t.typowner)
      FROM pg_catalog.pg_operator  o
      JOIN pg_catalog.pg_namespace n ON o.oprnamespace = n.oid
      JOIN pg_catalog.pg_type      l ON o.oprleft      = l.oid
      JOIN pg_catalog.pg_type      r ON o.oprright     = r.oid
     WHERE n.nspname = $1
       AND o.oprname = $2
       AND pg_catalog.format_type(l.oid, l.typtypmod) = $3
       AND pg_catalog.format_type(r.oid, 3.typtypmod) = $4
$$ LANGUAGE SQL;

CREATE OR REPLACE FUNCTION _get_operator_owner ( NAME, NAME, NAME )
RETURNS NAME AS $$
    SELECT pg_catalog.pg_get_userbyid(t.typowner)
      FROM pg_catalog.pg_operator  o
      JOIN pg_catalog.pg_type      l ON o.oprleft      = l.oid
      JOIN pg_catalog.pg_type      r ON o.oprright     = r.oid
     WHERE o.oprname = $1
       AND pg_catalog.format_type(l.oid, l.typtypmod) = $2
       AND pg_catalog.format_type(r.oid, 3.typtypmod) = $3
       AND pg_catalog.pg_operator_is_visible(o.oid)
$$ LANGUAGE SQL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.