postgres=# create table t (id varchar);CREATE TABLEpostgres=# insert into t values ('1');INSERT 0 1postgres=# CREATE FUNCTION varcharinteq(varchar,int) RETURNS booleanpostgres-# AS $$ SELECT $1=$2::varchar $$postgres-# LANGUAGE SQL;CREATE FUNCTIONpostgres=# create operator = (procedure=varcharinteq,LEFTARG='varchar',RIGHTARG='int4');CREATE OPERATORpostgres=# select * from t where id=1; id ---- 1(1 row)postgres=# CREATE FUNCTION intvarchareq(int,varchar) RETURNS boolean AS $$ SELECT $1::varchar=$2 $$ LANGUAGE SQL;CREATE FUNCTIONpostgres=# create operator = (procedure=intvarchareq,LEFTARG='int4',RIGHTARG='varchar');CREATE OPERATORpostgres=# select * from t where 1=id; id ---- 1(1 row)
回复 digoal 多谢,看来相当复杂
看来9还反而严格了..
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....