2014-05-05 23:13:06 +08:00
|
|
|
-- Function returning the column names of a table
|
|
|
|
CREATE OR REPLACE FUNCTION CDB_ColumnNames(REGCLASS)
|
|
|
|
RETURNS SETOF information_schema.sql_identifier
|
|
|
|
AS $$
|
|
|
|
|
2015-09-02 18:04:52 +08:00
|
|
|
SELECT c.column_name
|
|
|
|
FROM information_schema.columns c, pg_class _tn, pg_namespace _sn
|
|
|
|
WHERE table_name = _tn.relname
|
|
|
|
AND table_schema = _sn.nspname
|
|
|
|
AND _tn.oid = $1::regclass::oid
|
|
|
|
AND _sn.oid = _tn.relnamespace;
|
2014-05-05 23:13:06 +08:00
|
|
|
|
|
|
|
$$ LANGUAGE SQL;
|
|
|
|
|
2014-06-06 17:33:34 +08:00
|
|
|
-- This is to migrate from pre-0.2.0 version
|
|
|
|
-- See http://github.com/CartoDB/cartodb-postgresql/issues/36
|
|
|
|
GRANT EXECUTE ON FUNCTION CDB_ColumnNames(REGCLASS) TO PUBLIC;
|