begin;

drop table if exists inttest;
drop type if exists myint cascade;

create type myint;

create function myintin(cstring) returns myint strict immutable language
  internal as 'int4in';

create function myintout(myint) returns cstring strict immutable language
  internal as 'int4out';

create function myinthash(myint) returns integer strict immutable language
  internal as 'hashint4';

create type myint (input = myintin, output = myintout, like = int4);

create cast (int4 as myint) without function;
create cast (myint as int4) without function;

create function myinteq(myint, myint) returns bool as $$
begin
  return null;
end;
$$ language plpgsql strict immutable;

create operator = (
  leftarg    = myint,
  rightarg   = myint,
  commutator = =,
  procedure  = myinteq,
  restrict   = eqsel,
  join       = eqjoinsel,
  merges
);

create operator class myint_ops
default for type myint using hash as
  operator    1   = (myint, myint),
  function    1   myinthash(myint);

create table inttest (a myint);
insert into inttest values (1::myint);

select (a in
        (0::myint,1::myint,2::myint,3::myint,4::myint,
         5::myint,6::myint,7::myint,8::myint,9::myint)) is null
from inttest;

select (a in
        (0::myint,1::myint,2::myint,3::myint,4::myint,5::myint)) is null
from inttest;

rollback;
