/* OCLASS_POLICY */
{
"policy", OBJECT_POLICY
+ },
+ /* OCLASS_TRANSFORM */
+ {
+ "transform", OBJECT_TRANSFORM
}
};
* exceptions.
*/
if (type == OBJECT_TYPE || type == OBJECT_DOMAIN || type == OBJECT_CAST ||
- type == OBJECT_DOMCONSTRAINT)
+ type == OBJECT_TRANSFORM || type == OBJECT_DOMCONSTRAINT)
{
Datum *elems;
bool *nulls;
case OBJECT_CAST:
case OBJECT_USER_MAPPING:
case OBJECT_DEFACL:
+ case OBJECT_TRANSFORM:
if (list_length(args) != 1)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
appendStringInfoString(&buffer, "policy");
break;
+ case OCLASS_TRANSFORM:
+ appendStringInfoString(&buffer, "transform");
+ break;
+
default:
appendStringInfo(&buffer, "unrecognized %u", object->classId);
break;
break;
}
+ case OCLASS_TRANSFORM:
+ {
+ Relation transformDesc;
+ HeapTuple tup;
+ Form_pg_transform transform;
+ char *transformLang;
+ char *transformType;
+
+ transformDesc = heap_open(TransformRelationId, AccessShareLock);
+
+ tup = get_catalog_object_by_oid(transformDesc, object->objectId);
+
+ if (!HeapTupleIsValid(tup))
+ elog(ERROR, "could not find tuple for transform %u",
+ object->objectId);
+
+ transform = (Form_pg_transform) GETSTRUCT(tup);
+
+ transformType = format_type_be_qualified(transform->trftype);
+ transformLang = get_language_name(transform->trflang, false);
+
+ appendStringInfo(&buffer, "for %s on language %s",
+ transformType,
+ transformLang);
+ if (objname)
+ {
+ *objname = list_make1(transformType);
+ *objargs = list_make1(pstrdup(transformLang));
+ }
+
+ heap_close(transformDesc, AccessShareLock);
+ }
+ break;
+
default:
appendStringInfo(&buffer, "unrecognized object %u %u %d",
object->classId,
CREATE USER MAPPING FOR regtest_addr_user SERVER "integer";
ALTER DEFAULT PRIVILEGES FOR ROLE regtest_addr_user IN SCHEMA public GRANT ALL ON TABLES TO regtest_addr_user;
ALTER DEFAULT PRIVILEGES FOR ROLE regtest_addr_user REVOKE DELETE ON TABLES FROM regtest_addr_user;
+CREATE TRANSFORM FOR int LANGUAGE SQL (
+ FROM SQL WITH FUNCTION varchar_transform(internal),
+ TO SQL WITH FUNCTION int4recv(internal));
-- test some error cases
SELECT pg_get_object_address('stone', '{}', '{}');
ERROR: unrecognized object type "stone"
('operator'), ('operator class'), ('operator family'), ('rule'), ('trigger'),
('text search parser'), ('text search dictionary'),
('text search template'), ('text search configuration'),
- ('policy'), ('user mapping'), ('default acl'),
+ ('policy'), ('user mapping'), ('default acl'), ('transform'),
('operator of access method'), ('function of access method')
LOOP
FOR names IN VALUES ('{eins}'), ('{addr_nsp, zwei}'), ('{eins, zwei, drei}')
WARNING: error for default acl,{addr_nsp,zwei},{integer}: unrecognized default ACL object type i
WARNING: error for default acl,{eins,zwei,drei},{}: argument list length must be exactly 1
WARNING: error for default acl,{eins,zwei,drei},{integer}: unrecognized default ACL object type i
+WARNING: error for transform,{eins},{}: argument list length must be exactly 1
+WARNING: error for transform,{eins},{integer}: type "eins" does not exist
+WARNING: error for transform,{addr_nsp,zwei},{}: name list length must be exactly 1
+WARNING: error for transform,{addr_nsp,zwei},{integer}: name list length must be exactly 1
+WARNING: error for transform,{eins,zwei,drei},{}: name list length must be exactly 1
+WARNING: error for transform,{eins,zwei,drei},{integer}: name list length must be exactly 1
WARNING: error for operator of access method,{eins},{}: name list length must be at least 3
WARNING: error for operator of access method,{eins},{integer}: name list length must be at least 3
WARNING: error for operator of access method,{addr_nsp,zwei},{}: name list length must be at least 3
('default acl', '{regtest_addr_user}', '{r}'),
-- extension
-- event trigger
- ('policy', '{addr_nsp, gentable, genpol}', '{}')
+ ('policy', '{addr_nsp, gentable, genpol}', '{}'),
+ ('transform', '{int}', '{sql}')
)
SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.subobjid)).*,
-- test roundtrip through pg_identify_object_as_address
operator family | pg_catalog | integer_ops | pg_catalog.integer_ops USING btree | t
policy | | | genpol on addr_nsp.gentable | t
collation | pg_catalog | "default" | pg_catalog."default" | t
+ transform | | | for integer on language sql | t
text search dictionary | addr_nsp | addr_ts_dict | addr_nsp.addr_ts_dict | t
text search parser | addr_nsp | addr_ts_prs | addr_nsp.addr_ts_prs | t
text search configuration | addr_nsp | addr_ts_conf | addr_nsp.addr_ts_conf | t
text search template | addr_nsp | addr_ts_temp | addr_nsp.addr_ts_temp | t
-(40 rows)
+(41 rows)
---
--- Cleanup resources
CREATE USER MAPPING FOR regtest_addr_user SERVER "integer";
ALTER DEFAULT PRIVILEGES FOR ROLE regtest_addr_user IN SCHEMA public GRANT ALL ON TABLES TO regtest_addr_user;
ALTER DEFAULT PRIVILEGES FOR ROLE regtest_addr_user REVOKE DELETE ON TABLES FROM regtest_addr_user;
+CREATE TRANSFORM FOR int LANGUAGE SQL (
+ FROM SQL WITH FUNCTION varchar_transform(internal),
+ TO SQL WITH FUNCTION int4recv(internal));
-- test some error cases
SELECT pg_get_object_address('stone', '{}', '{}');
('operator'), ('operator class'), ('operator family'), ('rule'), ('trigger'),
('text search parser'), ('text search dictionary'),
('text search template'), ('text search configuration'),
- ('policy'), ('user mapping'), ('default acl'),
+ ('policy'), ('user mapping'), ('default acl'), ('transform'),
('operator of access method'), ('function of access method')
LOOP
FOR names IN VALUES ('{eins}'), ('{addr_nsp, zwei}'), ('{eins, zwei, drei}')
('default acl', '{regtest_addr_user}', '{r}'),
-- extension
-- event trigger
- ('policy', '{addr_nsp, gentable, genpol}', '{}')
+ ('policy', '{addr_nsp, gentable, genpol}', '{}'),
+ ('transform', '{int}', '{sql}')
)
SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.subobjid)).*,
-- test roundtrip through pg_identify_object_as_address