本文整理汇总了C++中PG_GETARG_OID函数的典型用法代码示例。如果您正苦于以下问题:C++ PG_GETARG_OID函数的具体用法?C++ PG_GETARG_OID怎么用?C++ PG_GETARG_OID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PG_GETARG_OID函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: repack_get_table_and_inheritors
/**
* @fn Datum get_table_and_inheritors(PG_FUNCTION_ARGS)
* @brief Return array containing Oids of parent table and its children.
* Note that this function does not release relation locks.
*
* get_table_and_inheritors(table)
*
* @param table parent table.
* @retval regclass[]
*/
Datum
repack_get_table_and_inheritors(PG_FUNCTION_ARGS)
{
Oid parent = PG_GETARG_OID(0);
List *relations;
Datum *relations_array;
int relations_array_size;
ArrayType *result;
ListCell *lc;
int i;
LockRelationOid(parent, AccessShareLock);
/* Check that parent table exists */
if (!SearchSysCacheExists1(RELOID, ObjectIdGetDatum(parent)))
PG_RETURN_ARRAYTYPE_P(construct_empty_array(OIDOID));
/* Also check that children exist */
relations = find_all_inheritors(parent, AccessShareLock, NULL);
relations_array_size = list_length(relations);
if (relations_array_size == 0)
PG_RETURN_ARRAYTYPE_P(construct_empty_array(OIDOID));
relations_array = palloc(relations_array_size * sizeof(Datum));
i = 0;
foreach (lc, relations)
relations_array[i++] = ObjectIdGetDatum(lfirst_oid(lc));
result = construct_array(relations_array,
relations_array_size,
OIDOID, sizeof(Oid),
true, 'i');
pfree(relations_array);
PG_RETURN_ARRAYTYPE_P(result);
}
开发者ID:reorg,项目名称:pg_repack,代码行数:49,代码来源:repack.c
示例2: 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 = SearchSysCache(ENUMTYPOIDNAME,
ObjectIdGetDatum(enumtypoid),
CStringGetDatum(name),
0, 0);
if (!HeapTupleIsValid(tup))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input value for enum %s: \"%s\"",
format_type_be(enumtypoid),
name)));
enumoid = HeapTupleGetOid(tup);
ReleaseSysCache(tup);
pfree(name);
PG_RETURN_OID(enumoid);
}
开发者ID:Aldizh,项目名称:buffer_manager,代码行数:40,代码来源:enum.c
示例3: parse
Datum
parse(PG_FUNCTION_ARGS)
{
FuncCallContext *funcctx;
Datum result;
SET_FUNCOID();
if (SRF_IS_FIRSTCALL())
{
text *txt = PG_GETARG_TEXT_P(1);
funcctx = SRF_FIRSTCALL_INIT();
prs_setup_firstcall(fcinfo, funcctx, PG_GETARG_OID(0), txt);
PG_FREE_IF_COPY(txt, 1);
}
funcctx = SRF_PERCALL_SETUP();
if ((result = prs_process_call(funcctx)) != (Datum) 0)
SRF_RETURN_NEXT(funcctx, result);
SRF_RETURN_DONE(funcctx);
}
开发者ID:shubham2094,项目名称:postgresql_8.2,代码行数:22,代码来源:wparser.c
示例4: mysql_fdw_validator
/*
* Validate the generic options given to a FOREIGN DATA WRAPPER, SERVER,
* USER MAPPING or FOREIGN TABLE that uses file_fdw.
*
* Raise an ERROR if the option or its value is considered invalid.
*/
Datum
mysql_fdw_validator(PG_FUNCTION_ARGS)
{
List *options_list = untransformRelOptions(PG_GETARG_DATUM(0));
Oid catalog = PG_GETARG_OID(1);
ListCell *cell;
/*
* Check that only options supported by mysql_fdw,
* and allowed for the current object type, are given.
*/
foreach(cell, options_list)
{
DefElem *def = (DefElem *) lfirst(cell);
if (!mysql_is_valid_option(def->defname, catalog))
{
struct MySQLFdwOption *opt;
StringInfoData buf;
/*
* Unknown option specified, complain about it. Provide a hint
* with list of valid options for the object.
*/
initStringInfo(&buf);
for (opt = valid_options; opt->optname; opt++)
{
if (catalog == opt->optcontext)
appendStringInfo(&buf, "%s%s", (buf.len > 0) ? ", " : "",
opt->optname);
}
ereport(ERROR,
(errcode(ERRCODE_FDW_INVALID_OPTION_NAME),
errmsg("invalid option \"%s\"", def->defname),
errhint("Valid options in this context are: %s", buf.len ? buf.data : "<none>")
));
}
}
开发者ID:wafs,项目名称:mysql_fdw,代码行数:45,代码来源:option.c
示例5: currtid_byreloid
Datum
currtid_byreloid(PG_FUNCTION_ARGS)
{
Oid reloid = PG_GETARG_OID(0);
ItemPointer tid = PG_GETARG_ITEMPOINTER(1);
ItemPointer result;
Relation rel;
AclResult aclresult;
/*
* Immediately inform client that the function is not supported
*/
elog(ERROR, "Function currtid is not supported by GPDB");
result = (ItemPointer) palloc(sizeof(ItemPointerData));
if (!reloid)
{
*result = Current_last_tid;
PG_RETURN_ITEMPOINTER(result);
}
rel = heap_open(reloid, AccessShareLock);
aclresult = pg_class_aclcheck(RelationGetRelid(rel), GetUserId(),
ACL_SELECT);
if (aclresult != ACLCHECK_OK)
aclcheck_error(aclresult, ACL_KIND_CLASS,
RelationGetRelationName(rel));
if (rel->rd_rel->relkind == RELKIND_VIEW)
return currtid_for_view(rel, tid);
ItemPointerCopy(tid, result);
heap_get_latest_tid(rel, SnapshotNow, result);
heap_close(rel, AccessShareLock);
PG_RETURN_ITEMPOINTER(result);
}
开发者ID:LJoNe,项目名称:gpdb,代码行数:39,代码来源:tid.c
示例6: lo_unlink
Datum
lo_unlink(PG_FUNCTION_ARGS)
{
Oid lobjId = PG_GETARG_OID(0);
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("large objects are not supported")));
/* Must be owner of the largeobject */
if (!lo_compat_privileges &&
!pg_largeobject_ownercheck(lobjId, GetUserId()))
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be owner of large object %u", lobjId)));
/*
* If there are any open LO FDs referencing that ID, close 'em.
*/
if (fscxt != NULL)
{
int i;
for (i = 0; i < cookies_size; i++)
{
if (cookies[i] != NULL && cookies[i]->id == lobjId)
{
inv_close(cookies[i]);
deleteLOfd(i);
}
}
}
/*
* inv_drop does not create a need for end-of-transaction cleanup and
* hence we don't need to have created fscxt.
*/
PG_RETURN_INT32(inv_drop(lobjId));
}
开发者ID:adam8157,项目名称:gpdb,代码行数:39,代码来源:be-fsstubs.c
示例7: enum_out
Datum
enum_out(PG_FUNCTION_ARGS)
{
Oid enumval = PG_GETARG_OID(0);
char *result;
HeapTuple tup;
Form_pg_enum en;
tup = SearchSysCache1(ENUMOID, ObjectIdGetDatum(enumval));
if (!HeapTupleIsValid(tup))
ereport(ERROR,
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("invalid internal value for enum: %u",
enumval)));
en = (Form_pg_enum) GETSTRUCT(tup);
result = pstrdup(NameStr(en->enumlabel));
ReleaseSysCache(tup);
PG_RETURN_CSTRING(result);
}
开发者ID:CadillacBupt,项目名称:recdb-postgresql,代码行数:22,代码来源:enum.c
示例8: pg_visibility_map_rel
/*
* Visibility map information for every block in a relation.
*/
Datum
pg_visibility_map_rel(PG_FUNCTION_ARGS)
{
FuncCallContext *funcctx;
vbits *info;
if (SRF_IS_FIRSTCALL())
{
Oid relid = PG_GETARG_OID(0);
MemoryContext oldcontext;
funcctx = SRF_FIRSTCALL_INIT();
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
funcctx->tuple_desc = pg_visibility_tupdesc(true, false);
funcctx->user_fctx = collect_visibility_data(relid, false);
MemoryContextSwitchTo(oldcontext);
}
funcctx = SRF_PERCALL_SETUP();
info = (vbits *) funcctx->user_fctx;
if (info->next < info->count)
{
Datum values[3];
bool nulls[3];
HeapTuple tuple;
MemSet(nulls, 0, sizeof(nulls));
values[0] = Int64GetDatum(info->next);
values[1] = BoolGetDatum((info->bits[info->next] & (1 << 0)) != 0);
values[2] = BoolGetDatum((info->bits[info->next] & (1 << 1)) != 0);
info->next++;
tuple = heap_form_tuple(funcctx->tuple_desc, values, nulls);
SRF_RETURN_NEXT(funcctx, HeapTupleGetDatum(tuple));
}
SRF_RETURN_DONE(funcctx);
}
开发者ID:0x0FFF,项目名称:postgres,代码行数:42,代码来源:pg_visibility.c
示例9: acl_check_access_int4_oid
Datum
acl_check_access_int4_oid(PG_FUNCTION_ARGS)
{
ArrayType *acl;
uint32 mask;
Oid who;
bool implicit_allow;
if (!check_access_extract_args(fcinfo, &acl, &mask, NULL, &implicit_allow,
false, true))
PG_RETURN_NULL();
if (PG_ARGISNULL(2))
PG_RETURN_NULL();
who = PG_GETARG_OID(2);
PG_RETURN_UINT32(check_access(acl, ACL_TYPE_LENGTH, ACL_TYPE_ALIGNMENT,
extract_acl_entry_base, mask,
(intptr_t) who, who_matches,
implicit_allow));
}
开发者ID:mlt,项目名称:acl,代码行数:22,代码来源:acl_oid.c
示例10: pg_relpagesbyid
Datum
pg_relpagesbyid(PG_FUNCTION_ARGS)
{
Oid relid = PG_GETARG_OID(0);
int64 relpages;
Relation rel;
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
(errmsg("must be superuser to use pgstattuple functions"))));
rel = relation_open(relid, AccessShareLock);
/* note: this will work OK on non-local temp tables */
relpages = RelationGetNumberOfBlocks(rel);
relation_close(rel, AccessShareLock);
PG_RETURN_INT64(relpages);
}
开发者ID:42penguins,项目名称:postgres,代码行数:22,代码来源:pgstatindex.c
示例11: currtid_byreloid
Datum
currtid_byreloid(PG_FUNCTION_ARGS)
{
Oid reloid = PG_GETARG_OID(0);
ItemPointer tid = PG_GETARG_ITEMPOINTER(1);
ItemPointer result;
Relation rel;
AclResult aclresult;
Snapshot snapshot;
result = (ItemPointer) palloc(sizeof(ItemPointerData));
if (!reloid)
{
*result = Current_last_tid;
PG_RETURN_ITEMPOINTER(result);
}
rel = heap_open(reloid, AccessShareLock);
aclresult = pg_class_aclcheck(RelationGetRelid(rel), GetUserId(),
ACL_SELECT);
if (aclresult != ACLCHECK_OK)
aclcheck_error(aclresult, ACL_KIND_CLASS,
RelationGetRelationName(rel));
if (rel->rd_rel->relkind == RELKIND_VIEW || rel->rd_rel->relkind == RELKIND_CONTVIEW)
return currtid_for_view(rel, tid);
ItemPointerCopy(tid, result);
snapshot = RegisterSnapshot(GetLatestSnapshot());
heap_get_latest_tid(rel, snapshot, result);
UnregisterSnapshot(snapshot);
heap_close(rel, AccessShareLock);
PG_RETURN_ITEMPOINTER(result);
}
开发者ID:myechuri,项目名称:pipelinedb,代码行数:38,代码来源:tid.c
示例12: plainto_tsquery_byid
Datum
plainto_tsquery_byid(PG_FUNCTION_ARGS)
{
Oid cfgid = PG_GETARG_OID(0);
text *in = PG_GETARG_TEXT_P(1);
TSQuery query;
QueryItem *res;
int4 len;
query = parse_tsquery(text_to_cstring(in), pushval_morph, ObjectIdGetDatum(cfgid), true);
if (query->size == 0)
PG_RETURN_TSQUERY(query);
res = clean_fakeval(GETQUERY(query), &len);
if (!res)
{
SET_VARSIZE(query, HDRSIZETQ);
query->size = 0;
PG_RETURN_POINTER(query);
}
memcpy((void *) GETQUERY(query), (void *) res, len * sizeof(QueryItem));
if (len != query->size)
{
char *oldoperand = GETOPERAND(query);
int4 lenoperand = VARSIZE(query) - (oldoperand - (char *) query);
Assert(len < query->size);
query->size = len;
memcpy((void *) GETOPERAND(query), oldoperand, lenoperand);
SET_VARSIZE(query, COMPUTESIZE(len, lenoperand));
}
pfree(res);
PG_RETURN_POINTER(query);
}
开发者ID:a1exsh,项目名称:postgres,代码行数:38,代码来源:to_tsany.c
示例13: pg_freespace
/*
* HASKELL GENERATED:
*
* (mostly static, except symname)
*
* Datum
* symname(PG_FUNCTION_ARGS)
*/
Datum
pg_freespace(PG_FUNCTION_ARGS)
{
/*
* HASKELL GENERATED:
*
* (May also have to generate the PG_GETARG_CTypeSym Macro)
*
* CTypeSym gensym = PG_GETARG_CTypeSym
*/
Oid relid = PG_GETARG_OID(0);
int64 blkno = PG_GETARG_INT64(1);
Datum retval;
/*
* HASKELL GENERATED:
*
* Prelude Args can be useful for passing additional interesting
* information or out-parameters like ErrData. Retval may be nonsensical
* should errdata be set. I think it's okay to have a fixed number of
* prelude args that every haskell function gets for free (ex: suppose
* haskell wants to know the current memory context).
*
* mangled_func_name(prelude_arg0, prelude_arg1, gensym_arg0, gensym_argn);
*/
retval = call_my_hs_function(&errdata, relid, blkno, ...);
/* Static C boilerplate, assuming prelude arg0 is the error data structure */
if (prelude_arg0 != NULL) {
/*
* Stuff to raise the error from errdata structures via
* longjmp-wrapping PG Constructs
*/
}
PG_RETURN_CTypeSym(retval);
}
开发者ID:fdr,项目名称:pghsxs,代码行数:46,代码来源:pg_freespacemap.c
示例14: enum_send
Datum
enum_send(PG_FUNCTION_ARGS)
{
Oid enumval = PG_GETARG_OID(0);
StringInfoData buf;
HeapTuple tup;
Form_pg_enum en;
tup = SearchSysCache1(ENUMOID, ObjectIdGetDatum(enumval));
if (!HeapTupleIsValid(tup))
ereport(ERROR,
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("invalid internal value for enum: %u",
enumval)));
en = (Form_pg_enum) GETSTRUCT(tup);
pq_begintypsend(&buf);
pq_sendtext(&buf, NameStr(en->enumlabel), strlen(NameStr(en->enumlabel)));
ReleaseSysCache(tup);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
开发者ID:Tao-Ma,项目名称:postgres,代码行数:23,代码来源:enum.c
示例15: noTypmodYet
/*
* Fail openly rather than mysteriously if an INPUT or RECEIVE function is
* called with a non-default typmod. It seems possible that, aside from COPY
* operations, that doesn't happen much, and values are usually produced as if
* with no typmod, then fed through a typmod application cast. So even
* without this implemented, there may be usable typmod capability except for
* COPY.
*/
static void noTypmodYet(UDT udt, PG_FUNCTION_ARGS)
{
Oid toid;
int mod;
if ( 3 > PG_NARGS() )
return;
toid = PG_GETARG_OID(1);
mod = PG_GETARG_INT32(2);
if ( -1 != mod )
ereport(ERROR, (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg(
"PL/Java UDT with non-default type modifier not yet supported")
));
if ( Type_getOid((Type)udt) != toid )
ereport(ERROR, (
errcode(ERRCODE_INTERNAL_ERROR),
errmsg("Unexpected type Oid %d passed to PL/Java UDT", toid)));
}
开发者ID:greenplum-db,项目名称:pljava,代码行数:31,代码来源:UDT.c
示例16: format_type
/*
* SQL function: format_type(type_oid, typemod)
*
* `type_oid' is from pg_type.oid, `typemod' is from
* pg_attribute.atttypmod. This function will get the type name and
* format it and the modifier to canonical SQL format, if the type is
* a standard type. Otherwise you just get pg_type.typname back,
* double quoted if it contains funny characters or matches a keyword.
*
* If typemod is NULL then we are formatting a type name in a context where
* no typemod is available, eg a function argument or result type. This
* yields a slightly different result from specifying typemod = -1 in some
* cases. Given typemod = -1 we feel compelled to produce an output that
* the parser will interpret as having typemod -1, so that pg_dump will
* produce CREATE TABLE commands that recreate the original state. But
* given NULL typemod, we assume that the parser's interpretation of
* typemod doesn't matter, and so we are willing to output a slightly
* "prettier" representation of the same type. For example, type = bpchar
* and typemod = NULL gets you "character", whereas typemod = -1 gets you
* "bpchar" --- the former will be interpreted as character(1) by the
* parser, which does not yield typemod -1.
*
* XXX encoding a meaning in typemod = NULL is ugly; it'd have been
* cleaner to make two functions of one and two arguments respectively.
* Not worth changing it now, however.
*/
Datum
format_type(PG_FUNCTION_ARGS)
{
Oid type_oid;
int32 typemod;
char *result;
/* Since this function is not strict, we must test for null args */
if (PG_ARGISNULL(0))
PG_RETURN_NULL();
type_oid = PG_GETARG_OID(0);
if (PG_ARGISNULL(1))
result = format_type_internal(type_oid, -1, false, true);
else
{
typemod = PG_GETARG_INT32(1);
result = format_type_internal(type_oid, typemod, true, true);
}
PG_RETURN_DATUM(_textin(result));
}
开发者ID:50wu,项目名称:gpdb,代码行数:49,代码来源:format_type.c
示例17: fmgr_internal_validator
/*
* Validator for internal functions
*
* Check that the given internal function name (the "prosrc" value) is
* a known builtin function.
*/
Datum
fmgr_internal_validator(PG_FUNCTION_ARGS)
{
Oid funcoid = PG_GETARG_OID(0);
HeapTuple tuple;
Form_pg_proc proc;
bool isnull;
Datum tmp;
char *prosrc;
/*
* We do not honor check_function_bodies since it's unlikely the function
* name will be found later if it isn't there now.
*/
tuple = SearchSysCache(PROCOID,
ObjectIdGetDatum(funcoid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
proc = (Form_pg_proc) GETSTRUCT(tuple);
tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_prosrc, &isnull);
if (isnull)
elog(ERROR, "null prosrc");
prosrc = DatumGetCString(DirectFunctionCall1(textout, tmp));
if (fmgr_internal_function(prosrc) == InvalidOid)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("there is no built-in function named \"%s\"",
prosrc)));
ReleaseSysCache(tuple);
PG_RETURN_VOID();
}
开发者ID:CraigBryan,项目名称:PostgresqlFun,代码行数:43,代码来源:pg_proc.c
示例18: reorg_disable_autovacuum
Datum
reorg_disable_autovacuum(PG_FUNCTION_ARGS)
{
Oid oid = PG_GETARG_OID(0);
/* connect to SPI manager */
reorg_init();
#if PG_VERSION_NUM >= 80400
execute_with_format(
SPI_OK_UTILITY,
"ALTER TABLE %s SET (autovacuum_enabled = off)",
get_relation_name(oid));
#else
execute_with_format(
SPI_OK_INSERT,
"INSERT INTO pg_catalog.pg_autovacuum VALUES (%u, false, -1, -1, -1, -1, -1, -1, -1, -1)",
oid);
#endif
SPI_finish();
PG_RETURN_VOID();
}
开发者ID:dvarrazzo,项目名称:pg_reorg,代码行数:24,代码来源:reorg.c
示例19: 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)));
/*
* 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);
}
开发者ID:LittleForker,项目名称:postgres,代码行数:36,代码来源:enum.c
示例20: pg_is_all_visible
/*
* Return the page is all-visible or not, according to the visibility map.
*/
Datum
pg_is_all_visible(PG_FUNCTION_ARGS)
{
Oid relid = PG_GETARG_OID(0);
int64 blkno = PG_GETARG_INT64(1);
Relation rel;
Buffer vmbuffer = InvalidBuffer;
bool result = false;
rel = relation_open(relid, AccessShareLock);
if (blkno < 0 || blkno > MaxBlockNumber)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid block number")));
result = visibilitymap_test(rel, blkno, &vmbuffer);
if (BufferIsValid(vmbuffer))
ReleaseBuffer(vmbuffer);
relation_close(rel, AccessShareLock);
PG_RETURN_BOOL(result);
}
开发者ID:snaga,项目名称:pg_visibilitymap,代码行数:27,代码来源:pg_visibilitymap.c
注:本文中的PG_GETARG_OID函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论