How postgreSQL9 implicit type conversion

Said since 8.3 after removing the characteristics, do not know whether it can be through what function can achieve the effect.

No need to modify the SQL, before the old SQL can continue to use.

For example:
SELECT * from TRIGGERS WHERE ISVOLATILE = 1;

ISVOLATILE is of type varchar, this statement in 9 reported the following error:
Operator does not exist: character varying = integer
The first line... _NAME, TRIGGER_GROUP FROM jk_TRIGGERS WHERE IS_VOLATILE = 0;
^
Tip: do not comply with the specified name and parameter type operator. You may need to add explicit type conversion.

Thank you!

Started by Carter at May 04, 2016 - 12:54 PM

It seems 9 but also strictly.

Posted by Victoria at May 14, 2016 - 1:03 PM

postgres=# create table t (id varchar);
CREATE TABLE
postgres=# insert into t values ('1');
INSERT 0 1
postgres=# CREATE FUNCTION varcharinteq(varchar,int) RETURNS boolean
postgres-# AS $$ SELECT $1=$2::varchar $$
postgres-# LANGUAGE SQL;
CREATE FUNCTION
postgres=# create operator = (procedure=varcharinteq,LEFTARG='varchar',RIGHTARG='int4');
CREATE OPERATOR
postgres=# 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 FUNCTION
postgres=# create operator = (procedure=intvarchareq,LEFTARG='int4',RIGHTARG='varchar');
CREATE OPERATOR
postgres=# select * from t where 1=id;
id
----
1
(1 row)

Posted by Payne at May 28, 2016 - 1:47 PM

Thank you, it seems quite complicated

Posted by Carter at June 03, 2016 - 2:38 PM