5
#include "catalog/pg_proc.h"
6
#include "catalog/pg_namespace.h"
7
#include "utils/syscache.h"
24
Oid TSNSP_FunctionOid = InvalidOid;
30
return charl2text(in, strlen(in));
34
charl2text(char *in, int len)
36
text *out = (text *) palloc(len + VARHDRSZ);
38
memcpy(VARDATA(out), in, len);
39
VARATT_SIZEP(out) = len + VARHDRSZ;
47
char *out = palloc(VARSIZE(in));
49
memcpy(out, VARDATA(in), VARSIZE(in) - VARHDRSZ);
50
out[VARSIZE(in) - VARHDRSZ] = '\0';
56
pnstrdup(char *in, int len)
58
char *out = palloc(len + 1);
69
text *out = (text *) palloc(VARSIZE(in));
71
memcpy(out, in, VARSIZE(in));
79
text *out = (text *) malloc(VARSIZE(in));
82
ts_error(ERROR, "No memory");
83
memcpy(out, in, VARSIZE(in));
88
ts_error(int state, const char *format,...)
99
va_start(args, format);
101
len = vsnprintf(buf, tlen - 1, format, args);
105
buf = repalloc(buf, tlen);
106
vsnprintf(buf, tlen - 1, format, args);
110
/* ?? internal error ?? */
111
elog(state, "%s", buf);
116
text_cmp(text *a, text *b)
118
if (VARSIZE(a) == VARSIZE(b))
119
return strncmp(VARDATA(a), VARDATA(b), VARSIZE(a) - VARHDRSZ);
120
return (int) VARSIZE(a) - (int) VARSIZE(b);
125
get_namespace(Oid funcoid)
129
Form_pg_namespace nsp;
133
tuple = SearchSysCache(PROCOID, ObjectIdGetDatum(funcoid), 0, 0, 0);
134
if (!HeapTupleIsValid(tuple))
135
elog(ERROR, "cache lookup failed for proc oid %u", funcoid);
136
proc = (Form_pg_proc) GETSTRUCT(tuple);
137
nspoid = proc->pronamespace;
138
ReleaseSysCache(tuple);
140
tuple = SearchSysCache(NAMESPACEOID, ObjectIdGetDatum(nspoid), 0, 0, 0);
141
if (!HeapTupleIsValid(tuple))
142
elog(ERROR, "cache lookup failed for namespace oid %u", nspoid);
143
nsp = (Form_pg_namespace) GETSTRUCT(tuple);
144
txt = pstrdup(NameStr((nsp->nspname)));
145
ReleaseSysCache(tuple);
151
get_oidnamespace(Oid funcoid)
157
tuple = SearchSysCache(PROCOID, ObjectIdGetDatum(funcoid), 0, 0, 0);
158
if (!HeapTupleIsValid(tuple))
159
elog(ERROR, "cache lookup failed for proc oid %u", funcoid);
160
proc = (Form_pg_proc) GETSTRUCT(tuple);
161
nspoid = proc->pronamespace;
162
ReleaseSysCache(tuple);