2014-05-05 23:13:06 +08:00
|
|
|
-- Function returning the column names of a table
|
2019-05-31 21:29:28 +08:00
|
|
|
CREATE OR REPLACE FUNCTION @extschema@.CDB_ColumnNames(REGCLASS)
|
2014-05-05 23:13:06 +08:00
|
|
|
RETURNS SETOF information_schema.sql_identifier
|
|
|
|
AS $$
|
2016-04-19 00:49:58 +08:00
|
|
|
SELECT
|
|
|
|
a.attname::information_schema.sql_identifier column_name
|
|
|
|
FROM pg_class c
|
2016-04-25 22:30:58 +08:00
|
|
|
LEFT JOIN pg_attribute a ON a.attrelid = c.oid
|
2016-04-19 00:49:58 +08:00
|
|
|
WHERE c.oid = $1::oid
|
2016-04-25 22:30:58 +08:00
|
|
|
AND a.attstattarget < 0 -- exclude system columns
|
2016-04-19 00:49:58 +08:00
|
|
|
ORDER BY a.attnum;
|
2017-10-24 20:16:56 +08:00
|
|
|
$$ LANGUAGE SQL STABLE PARALLEL SAFE;
|
2014-05-05 23:13:06 +08:00
|
|
|
|
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
|
2019-05-31 21:29:28 +08:00
|
|
|
GRANT EXECUTE ON FUNCTION @extschema@.CDB_ColumnNames(REGCLASS) TO PUBLIC;
|