本文整理汇总了C++中PG_RETURN_OID函数的典型用法代码示例。如果您正苦于以下问题:C++ PG_RETURN_OID函数的具体用法?C++ PG_RETURN_OID怎么用?C++ PG_RETURN_OID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PG_RETURN_OID函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: text_regclass
/*
* text_regclass: convert text to regclass
*
* This could be replaced by CoerceViaIO, except that we need to treat
* text-to-regclass as an implicit cast to support legacy forms of nextval()
* and related functions.
*/
Datum
text_regclass(PG_FUNCTION_ARGS)
{
text *relname = PG_GETARG_TEXT_P(0);
Oid result;
RangeVar *rv;
rv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
/* We might not even have permissions on this relation; don't lock it. */
result = RangeVarGetRelid(rv, NoLock, false);
PG_RETURN_OID(result);
}
示例2: lo_import
/*
* lo_import -
* imports a file as an (inversion) large object.
*/
Datum
lo_import(PG_FUNCTION_ARGS)
{
text *filename = PG_GETARG_TEXT_PP(0);
#ifdef PGXC
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("Postgres-XC does not support large object yet"),
errdetail("The feature is not currently supported")));
#endif
PG_RETURN_OID(lo_import_internal(filename, InvalidOid));
}
示例3: lo_create
Datum
lo_create(PG_FUNCTION_ARGS)
{
Oid lobjId = PG_GETARG_OID(0);
/*
* We don't actually need to store into fscxt, but create it anyway to
* ensure that AtEOXact_LargeObject knows there is state to clean up
*/
CreateFSContext();
lobjId = inv_create(lobjId);
PG_RETURN_OID(lobjId);
}
示例4: i8tooid
Datum
i8tooid(PG_FUNCTION_ARGS)
{
int64 arg = PG_GETARG_INT64(0);
Oid result;
result = (Oid) arg;
/* Test for overflow by reverse-conversion. */
if ((int64) result != arg)
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("OID out of range")));
PG_RETURN_OID(result);
}
示例5: to_regtype
/*
* to_regtype - converts "typename" to type OID
*
* If the name is not found, we return NULL.
*/
Datum
to_regtype(PG_FUNCTION_ARGS)
{
char *typ_name = PG_GETARG_CSTRING(0);
Oid result;
int32 typmod;
/*
* Invoke the full parser to deal with special cases such as array syntax.
*/
parseTypeString(typ_name, &result, &typmod, true);
if (OidIsValid(result))
PG_RETURN_OID(result);
else
PG_RETURN_NULL();
}
示例6: lo_from_bytea
/*
* Create LO with initial contents given by a bytea argument
*/
Datum
lo_from_bytea(PG_FUNCTION_ARGS)
{
Oid loOid = PG_GETARG_OID(0);
bytea *str = PG_GETARG_BYTEA_PP(1);
LargeObjectDesc *loDesc;
int written PG_USED_FOR_ASSERTS_ONLY;
CreateFSContext();
loOid = inv_create(loOid);
loDesc = inv_open(loOid, INV_WRITE, fscxt);
written = inv_write(loDesc, VARDATA_ANY(str), VARSIZE_ANY_EXHDR(str));
Assert(written == VARSIZE_ANY_EXHDR(str));
inv_close(loDesc);
PG_RETURN_OID(loOid);
}
示例7: pg_highest_oid
Datum
pg_highest_oid(PG_FUNCTION_ARGS __attribute__((unused)))
{
Oid result;
Oid max_from_segdbs;
result = ShmemVariableCache->nextOid;
if (Gp_role == GP_ROLE_DISPATCH)
{
max_from_segdbs = get_max_oid_from_segDBs();
if (max_from_segdbs > result)
result = max_from_segdbs;
}
PG_RETURN_OID(result);
}
示例8: lo_create
Datum
lo_create(PG_FUNCTION_ARGS)
{
Oid lobjId = PG_GETARG_OID(0);
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("large objects are not supported")));
/*
* We don't actually need to store into fscxt, but create it anyway to
* ensure that AtEOXact_LargeObject knows there is state to clean up
*/
CreateFSContext();
lobjId = inv_create(lobjId);
PG_RETURN_OID(lobjId);
}
示例9: to_regproc
/*
* to_regproc - converts "proname" to proc OID
*
* If the name is not found, we return NULL.
*/
Datum
to_regproc(PG_FUNCTION_ARGS)
{
char *pro_name = PG_GETARG_CSTRING(0);
List *names;
FuncCandidateList clist;
/*
* Parse the name into components and see if it matches any pg_proc
* entries in the current search path.
*/
names = stringToQualifiedNameList(pro_name);
clist = FuncnameGetCandidates(names, -1, NIL, false, false, true);
if (clist == NULL || clist->next != NULL)
PG_RETURN_NULL();
PG_RETURN_OID(clist->oid);
}
示例10: to_regoper
/*
* to_regoper - converts "oprname" to operator OID
*
* If the name is not found, we return NULL.
*/
Datum
to_regoper(PG_FUNCTION_ARGS)
{
char *opr_name = PG_GETARG_CSTRING(0);
List *names;
FuncCandidateList clist;
/*
* Parse the name into components and see if it matches any pg_operator
* entries in the current search path.
*/
names = stringToQualifiedNameList(opr_name);
clist = OpernameGetCandidates(names, '\0', true);
if (clist == NULL || clist->next != NULL)
PG_RETURN_NULL();
PG_RETURN_OID(clist->oid);
}
示例11: text_oid
Datum
text_oid(PG_FUNCTION_ARGS)
{
text *string = PG_GETARG_TEXT_P(0);
Oid result;
int len;
char *str;
len = (VARSIZE(string) - VARHDRSZ);
str = palloc(len + 1);
memcpy(str, VARDATA(string), len);
*(str + len) = '\0';
result = oidin_subr("text_oid", str, NULL);
pfree(str);
PG_RETURN_OID(result);
}
示例12: enum_recv
/* Binary I/O support */
Datum
enum_recv(PG_FUNCTION_ARGS)
{
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
Oid enumtypoid = PG_GETARG_OID(1);
Oid enumoid;
HeapTuple tup;
char *name;
int nbytes;
name = pq_getmsgtext(buf, buf->len - buf->cursor, &nbytes);
/* must check length to prevent Assert failure within SearchSysCache */
if (strlen(name) >= NAMEDATALEN)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input value for enum %s: \"%s\"",
format_type_be(enumtypoid),
name)));
tup = SearchSysCache2(ENUMTYPOIDNAME,
ObjectIdGetDatum(enumtypoid),
CStringGetDatum(name));
if (!HeapTupleIsValid(tup))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input value for enum %s: \"%s\"",
format_type_be(enumtypoid),
name)));
/* check it's safe to use in SQL */
check_safe_enum_use(tup);
enumoid = HeapTupleGetOid(tup);
ReleaseSysCache(tup);
pfree(name);
PG_RETURN_OID(enumoid);
}
示例13: to_regclass
/*
* to_regclass - converts "classname" to class OID
*
* If the name is not found, we return NULL.
*/
Datum
to_regclass(PG_FUNCTION_ARGS)
{
char *class_name = PG_GETARG_CSTRING(0);
Oid result;
List *names;
/*
* Parse the name into components and see if it matches any pg_class
* entries in the current search path.
*/
names = stringToQualifiedNameList(class_name);
/* We might not even have permissions on this relation; don't lock it. */
result = RangeVarGetRelid(makeRangeVarFromNameList(names), NoLock, true);
if (OidIsValid(result))
PG_RETURN_OID(result);
else
PG_RETURN_NULL();
}
示例14: enum_last
Datum
enum_last(PG_FUNCTION_ARGS)
{
Oid enumtypoid;
Oid max = InvalidOid;
CatCList *list;
int num,
i;
/*
* We rely on being able to get the specific enum type from the calling
* expression tree. Notice that the actual value of the argument isn't
* examined at all; in particular it might be NULL.
*/
enumtypoid = get_fn_expr_argtype(fcinfo->flinfo, 0);
if (enumtypoid == InvalidOid)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("could not determine actual enum type")));
list = SearchSysCacheList(ENUMTYPOIDNAME, 1,
ObjectIdGetDatum(enumtypoid),
0, 0, 0);
num = list->n_members;
for (i = 0; i < num; i++)
{
Oid valoid = HeapTupleHeaderGetOid(list->members[i]->tuple.t_data);
if (!OidIsValid(max) || valoid > max)
max = valoid;
}
ReleaseCatCacheList(list);
if (!OidIsValid(max)) /* should not happen */
elog(ERROR, "no values found for enum %s",
format_type_be(enumtypoid));
PG_RETURN_OID(max);
}
示例15: enum_in
Datum
enum_in(PG_FUNCTION_ARGS)
{
char *name = PG_GETARG_CSTRING(0);
Oid enumtypoid = PG_GETARG_OID(1);
Oid enumoid;
HeapTuple tup;
/* must check length to prevent Assert failure within SearchSysCache */
if (strlen(name) >= NAMEDATALEN)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input value for enum %s: \"%s\"",
format_type_be(enumtypoid),
name)));
tup = SearchSysCache2(ENUMTYPOIDNAME,
ObjectIdGetDatum(enumtypoid),
CStringGetDatum(name));
if (!HeapTupleIsValid(tup))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input value for enum %s: \"%s\"",
format_type_be(enumtypoid),
name)));
/* check it's safe to use in SQL */
check_safe_enum_use(tup);
/*
* This comes from pg_enum.oid and stores system oids in user tables. This
* oid must be preserved by binary upgrades.
*/
enumoid = HeapTupleGetOid(tup);
ReleaseSysCache(tup);
PG_RETURN_OID(enumoid);
}