SQL para hacer cast de postgres 8.2 para postgres 8.3

Cuando se realiza la migración de postgres 8.2 a postgres 8.3, no todos los tipos de datos son iguales, y es necesario hacer unos cast de tipo, y de funciones para que todo funcione correctamente. Para ello basta con ejecutar las siguientes sentencias SQL:

CREATE FUNCTION pg_catalog.text(INTEGER) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(int4out($1));';
CREATE CAST (INTEGER AS text) WITH FUNCTION pg_catalog.text(INTEGER) AS IMPLICIT;
CREATE FUNCTION pg_catalog.text(SMALLINT) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(int2out($1));';
CREATE CAST (SMALLINT AS text) WITH FUNCTION pg_catalog.text(SMALLINT) AS IMPLICIT;
CREATE FUNCTION pg_catalog.text(oid) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(oidout($1));';
CREATE CAST (oid AS text) WITH FUNCTION pg_catalog.text(oid) AS IMPLICIT;
CREATE FUNCTION pg_catalog.text(DATE) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(date_out($1));';
CREATE CAST (DATE AS text) WITH FUNCTION pg_catalog.text(DATE) AS IMPLICIT;
CREATE FUNCTION pg_catalog.text(DOUBLE PRECISION) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(float8out($1));';
CREATE CAST (DOUBLE PRECISION AS text) WITH FUNCTION pg_catalog.text(DOUBLE PRECISION) AS IMPLICIT;
CREATE FUNCTION pg_catalog.text(REAL) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(float4out($1));';
CREATE CAST (REAL AS text) WITH FUNCTION pg_catalog.text(REAL) AS IMPLICIT;
CREATE FUNCTION pg_catalog.text(TIME WITH TIME zone) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(timetz_out($1));';
CREATE CAST (TIME WITH TIME zone AS text) WITH FUNCTION pg_catalog.text(TIME WITH TIME zone) AS IMPLICIT;
CREATE FUNCTION pg_catalog.text(TIME WITHOUT TIME zone) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(time_out($1));';
CREATE CAST (TIME WITHOUT TIME zone AS text) WITH FUNCTION pg_catalog.text(TIME WITHOUT TIME zone) AS IMPLICIT;
CREATE FUNCTION pg_catalog.text(TIMESTAMP WITH TIME zone) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(timestamptz_out($1));';
CREATE CAST (TIMESTAMP WITH TIME zone AS text) WITH FUNCTION pg_catalog.text(TIMESTAMP WITH TIME zone) AS IMPLICIT;
CREATE FUNCTION pg_catalog.text(INTERVAL) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(interval_out($1));';
CREATE CAST (INTERVAL AS text) WITH FUNCTION pg_catalog.text(INTERVAL) AS IMPLICIT;
CREATE FUNCTION pg_catalog.text(BIGINT) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(int8out($1));';
CREATE CAST (BIGINT AS text) WITH FUNCTION pg_catalog.text(BIGINT) AS IMPLICIT;
CREATE FUNCTION pg_catalog.text(NUMERIC) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(numeric_out($1));';
CREATE CAST (NUMERIC AS text) WITH FUNCTION pg_catalog.text(NUMERIC) AS IMPLICIT;
CREATE FUNCTION pg_catalog.text(TIMESTAMP WITHOUT TIME zone) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(timestamp_out($1));';
CREATE CAST (TIMESTAMP WITHOUT TIME zone AS text) WITH FUNCTION pg_catalog.text(TIMESTAMP WITHOUT TIME zone) AS IMPLICIT;

3 Comments

  1. Carlos A. Lizcano D. 12 de junio, 2011
  2. jose vazquez 12 de enero, 2012
  3. David 29 de mayo, 2012

Leave a Reply