mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Add transforms feature
This provides a mechanism for specifying conversions between SQL data types and procedural languages. As examples, there are transforms for hstore and ltree for PL/Perl and PL/Python. reviews by Pavel Stěhule and Andres Freund
This commit is contained in:
71
src/backend/utils/cache/lsyscache.c
vendored
71
src/backend/utils/cache/lsyscache.c
vendored
@ -24,12 +24,14 @@
|
||||
#include "catalog/pg_amproc.h"
|
||||
#include "catalog/pg_collation.h"
|
||||
#include "catalog/pg_constraint.h"
|
||||
#include "catalog/pg_language.h"
|
||||
#include "catalog/pg_namespace.h"
|
||||
#include "catalog/pg_opclass.h"
|
||||
#include "catalog/pg_operator.h"
|
||||
#include "catalog/pg_proc.h"
|
||||
#include "catalog/pg_range.h"
|
||||
#include "catalog/pg_statistic.h"
|
||||
#include "catalog/pg_transform.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "miscadmin.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
@ -977,6 +979,30 @@ get_constraint_name(Oid conoid)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ---------- LANGUAGE CACHE ---------- */
|
||||
|
||||
char *
|
||||
get_language_name(Oid langoid, bool missing_ok)
|
||||
{
|
||||
HeapTuple tp;
|
||||
|
||||
tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid));
|
||||
if (HeapTupleIsValid(tp))
|
||||
{
|
||||
Form_pg_language lantup = (Form_pg_language) GETSTRUCT(tp);
|
||||
char *result;
|
||||
|
||||
result = pstrdup(NameStr(lantup->lanname));
|
||||
ReleaseSysCache(tp);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!missing_ok)
|
||||
elog(ERROR, "cache lookup failed for language %u",
|
||||
langoid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ---------- OPCLASS CACHE ---------- */
|
||||
|
||||
/*
|
||||
@ -1743,6 +1769,51 @@ get_rel_tablespace(Oid relid)
|
||||
}
|
||||
|
||||
|
||||
/* ---------- TRANSFORM CACHE ---------- */
|
||||
|
||||
Oid
|
||||
get_transform_fromsql(Oid typid, Oid langid, List *trftypes)
|
||||
{
|
||||
HeapTuple tup;
|
||||
|
||||
if (!list_member_oid(trftypes, typid))
|
||||
return InvalidOid;
|
||||
|
||||
tup = SearchSysCache2(TRFTYPELANG, typid, langid);
|
||||
if (HeapTupleIsValid(tup))
|
||||
{
|
||||
Oid funcid;
|
||||
|
||||
funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
|
||||
ReleaseSysCache(tup);
|
||||
return funcid;
|
||||
}
|
||||
else
|
||||
return InvalidOid;
|
||||
}
|
||||
|
||||
Oid
|
||||
get_transform_tosql(Oid typid, Oid langid, List *trftypes)
|
||||
{
|
||||
HeapTuple tup;
|
||||
|
||||
if (!list_member_oid(trftypes, typid))
|
||||
return InvalidOid;
|
||||
|
||||
tup = SearchSysCache2(TRFTYPELANG, typid, langid);
|
||||
if (HeapTupleIsValid(tup))
|
||||
{
|
||||
Oid funcid;
|
||||
|
||||
funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
|
||||
ReleaseSysCache(tup);
|
||||
return funcid;
|
||||
}
|
||||
else
|
||||
return InvalidOid;
|
||||
}
|
||||
|
||||
|
||||
/* ---------- TYPE CACHE ---------- */
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user