Optimize funcion CDB_COlumnType

This commit is contained in:
Javier Goizueta 2016-04-18 19:07:33 +02:00
parent 06ebb27160
commit 65415bb335

View File

@ -2,15 +2,13 @@
CREATE OR REPLACE FUNCTION CDB_ColumnType(REGCLASS, TEXT) CREATE OR REPLACE FUNCTION CDB_ColumnType(REGCLASS, TEXT)
RETURNS information_schema.character_data RETURNS information_schema.character_data
AS $$ AS $$
SELECT
SELECT c.data_type pg_catalog.format_type(a.atttypid, NULL)::information_schema.character_data data_type
FROM information_schema.columns c, pg_class _tn, pg_namespace _sn FROM pg_class c
WHERE table_name = _tn.relname LEFT JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid
AND table_schema = _sn.nspname WHERE c.oid = $1::oid
AND column_name = $2 AND a.attname = $2
AND _tn.oid = $1::oid AND a.attstattarget = -1;
AND _sn.oid = _tn.relnamespace;
$$ LANGUAGE SQL; $$ LANGUAGE SQL;
-- This is to migrate from pre-0.2.0 version -- This is to migrate from pre-0.2.0 version