本文整理汇总了C++中PG_GETARG_DATUM函数的典型用法代码示例。如果您正苦于以下问题:C++ PG_GETARG_DATUM函数的具体用法?C++ PG_GETARG_DATUM怎么用?C++ PG_GETARG_DATUM使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PG_GETARG_DATUM函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: get_semester
Datum get_semester(PG_FUNCTION_ARGS) {
pg_tm current_date;
GetCurrentDateTime(¤t_date);
DateADT entering_date = DatumGetDateADT(PG_GETARG_DATUM(0));
int entering_year, entering_month, entering_day;
j2date(entering_date + date2j(2000, 1, 1), &entering_year, &entering_month, &entering_day);
int semester = (current_date.tm_year - entering_year) * 2;
if (current_date.tm_mon > 6)
semester++;
PG_RETURN_INT32(semester);
}
开发者ID:AhmetsafinV,项目名称:db36,代码行数:15,代码来源:libdb36.c
示例2: hashoptions
Datum
hashoptions(PG_FUNCTION_ARGS)
{
Datum reloptions = PG_GETARG_DATUM(0);
bool validate = PG_GETARG_BOOL(1);
bytea *result;
result = default_reloptions(reloptions, validate,
RELKIND_INDEX,
HASH_MIN_FILLFACTOR,
HASH_DEFAULT_FILLFACTOR);
if (result)
PG_RETURN_BYTEA_P(result);
PG_RETURN_NULL();
}
开发者ID:qiuyesuifeng,项目名称:gpdb,代码行数:15,代码来源:hashutil.c
示例3: on_partitions_removed
Datum
on_partitions_removed(PG_FUNCTION_ARGS)
{
Oid relid;
LWLockAcquire(pmstate->load_config_lock, LW_EXCLUSIVE);
/* parent relation oid */
relid = DatumGetInt32(PG_GETARG_DATUM(0));
remove_relation_info(relid);
LWLockRelease(pmstate->load_config_lock);
PG_RETURN_NULL();
}
开发者ID:VladimirMikhailov,项目名称:pg_pathman,代码行数:15,代码来源:pl_funcs.c
示例4: geography_from_binary
Datum geography_from_binary(PG_FUNCTION_ARGS)
{
char *wkb_bytea = (char*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
GSERIALIZED *gser = NULL;
size_t wkb_size = VARSIZE(wkb_bytea);
uint8_t *wkb = (uint8_t*)VARDATA(wkb_bytea);
LWGEOM *lwgeom = lwgeom_from_wkb(wkb, wkb_size, LW_PARSER_CHECK_NONE);
if ( ! lwgeom )
lwerror("Unable to parse WKB");
gser = gserialized_geography_from_lwgeom(lwgeom, 0);
lwgeom_free(lwgeom);
PG_RETURN_POINTER(gser);
}
开发者ID:mborne,项目名称:sfcgal-with-postgis,代码行数:15,代码来源:geography_inout.c
示例5: ts_rankcd_wtt
Datum
ts_rankcd_wtt(PG_FUNCTION_ARGS)
{
ArrayType *win = (ArrayType *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
TSVector txt = PG_GETARG_TSVECTOR(1);
TSQuery query = PG_GETARG_TSQUERY(2);
float res;
res = calc_rank_cd(getWeights(win), txt, query, DEF_NORM_METHOD);
PG_FREE_IF_COPY(win, 0);
PG_FREE_IF_COPY(txt, 1);
PG_FREE_IF_COPY(query, 2);
PG_RETURN_FLOAT4(res);
}
开发者ID:avontd2868,项目名称:postgres,代码行数:15,代码来源:tsrank.c
示例6: LWGEOM_line_locate_point
Datum LWGEOM_line_locate_point(PG_FUNCTION_ARGS)
{
GSERIALIZED *geom1 = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
GSERIALIZED *geom2 = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
LWLINE *lwline;
LWPOINT *lwpoint;
POINTARRAY *pa;
POINT2D p;
double ret;
if ( gserialized_get_type(geom1) != LINETYPE )
{
elog(ERROR,"line_locate_point: 1st arg isnt a line");
PG_RETURN_NULL();
}
if ( gserialized_get_type(geom2) != POINTTYPE )
{
elog(ERROR,"line_locate_point: 2st arg isnt a point");
PG_RETURN_NULL();
}
if ( gserialized_get_srid(geom1) != gserialized_get_srid(geom2) )
{
elog(ERROR, "Operation on two geometries with different SRIDs");
PG_RETURN_NULL();
}
lwline = lwgeom_as_lwline(lwgeom_from_gserialized(geom1));
lwpoint = lwgeom_as_lwpoint(lwgeom_from_gserialized(geom2));
pa = lwline->points;
lwpoint_getPoint2d_p(lwpoint, &p);
ret = ptarray_locate_point(pa, &p, NULL);
PG_RETURN_FLOAT8(ret);
}
开发者ID:bnordgren,项目名称:postgis,代码行数:36,代码来源:lwgeom_functions_analytic.c
示例7: lwgeom_eq
Datum lwgeom_eq(PG_FUNCTION_ARGS)
{
GSERIALIZED *geom1 = (GSERIALIZED *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
GSERIALIZED *geom2 = (GSERIALIZED *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
GBOX box1;
GBOX box2;
bool result;
POSTGIS_DEBUG(2, "lwgeom_eq called");
if (gserialized_get_srid(geom1) != gserialized_get_srid(geom2))
{
elog(BTREE_SRID_MISMATCH_SEVERITY,
"Operation on two GEOMETRIES with different SRIDs\n");
PG_FREE_IF_COPY(geom1, 0);
PG_FREE_IF_COPY(geom2, 1);
PG_RETURN_NULL();
}
gserialized_get_gbox_p(geom1, &box1);
gserialized_get_gbox_p(geom2, &box2);
PG_FREE_IF_COPY(geom1, 0);
PG_FREE_IF_COPY(geom2, 1);
if ( ! (FPeq(box1.xmin, box2.xmin) && FPeq(box1.ymin, box2.ymin) &&
FPeq(box1.xmax, box2.xmax) && FPeq(box1.ymax, box2.ymax)) )
{
result = FALSE;
}
else
{
result = TRUE;
}
PG_RETURN_BOOL(result);
}
开发者ID:bnordgren,项目名称:postgis,代码行数:36,代码来源:lwgeom_btree.c
示例8: geography_le
Datum geography_le(PG_FUNCTION_ARGS)
{
/* Put aside some stack memory and use it for GIDX pointers. */
char gboxmem1[GIDX_MAX_SIZE];
char gboxmem2[GIDX_MAX_SIZE];
GIDX *gbox1 = (GIDX*)gboxmem1;
GIDX *gbox2 = (GIDX*)gboxmem2;
POINT3D p1, p2;
/* Must be able to build box for each argument (ie, not empty geometry) */
if ( ! gserialized_datum_get_gidx_p(PG_GETARG_DATUM(0), gbox1) ||
! gserialized_datum_get_gidx_p(PG_GETARG_DATUM(1), gbox2) )
{
PG_RETURN_BOOL(FALSE);
}
geography_gidx_center(gbox1, &p1);
geography_gidx_center(gbox2, &p2);
if ( p1.x <= p2.x || p1.y <= p2.y || p1.z <= p2.z )
PG_RETURN_BOOL(TRUE);
PG_RETURN_BOOL(FALSE);
}
开发者ID:NianYue,项目名称:pipelinedb,代码行数:24,代码来源:geography_btree.c
示例9: pgq_set_connection_context
Datum pgq_set_connection_context(PG_FUNCTION_ARGS)
{
char *ctx;
if (current_context)
pfree(current_context);
current_context = NULL;
if (PG_NARGS() > 0 && !PG_ARGISNULL(0)) {
ctx = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(0)));
current_context = MemoryContextStrdup(TopMemoryContext, ctx);
pfree(ctx);
}
PG_RETURN_VOID();
}
开发者ID:ssinger,项目名称:skytools-cvs,代码行数:15,代码来源:denytriga.c
示例10: mol_murckoscaffold
Datum
mol_murckoscaffold(PG_FUNCTION_ARGS) {
CROMol mol;
fcinfo->flinfo->fn_extra = SearchMolCache(
fcinfo->flinfo->fn_extra,
fcinfo->flinfo->fn_mcxt,
PG_GETARG_DATUM(0),
NULL, &mol, NULL);
CROMol scaffold=MolMurckoScaffold(mol);
if(!scaffold) PG_RETURN_NULL();
Mol *res = deconstructROMol(scaffold);
freeCROMol(scaffold);
PG_RETURN_MOL_P(res);
}
开发者ID:Acpharis,项目名称:rdkit,代码行数:15,代码来源:mol_op.c
示例11: fingerprint
Datum fingerprint(PG_FUNCTION_ARGS){
Datum mol_datum = PG_GETARG_DATUM(0);
Datum options_datum = PG_GETARG_DATUM(1);
void* result = 0;
PG_BINGO_BEGIN
{
BingoPgCommon::BingoSessionHandler bingo_handler(fcinfo->flinfo->fn_oid);
bingo_handler.setFunctionName("fingerprint");
BingoPgText mol_text(mol_datum);
BingoPgText mol_options(options_datum);
int buf_size;
const char* mol_buf = mol_text.getText(buf_size);
int res_buf;
const char* bingo_result = mangoFingerprint(mol_buf, buf_size, mol_options.getString(), &res_buf);
if(bingo_result == 0) {
CORE_HANDLE_WARNING(0, 1, "bingo.fingerprint", bingoGetError());
PG_RETURN_NULL();
}
BingoPgText result_data;
result_data.initFromBuffer(bingo_result, res_buf);
result = result_data.release();
}
PG_BINGO_END
if(result == 0)
PG_RETURN_NULL();
PG_RETURN_BYTEA_P(result);
}
开发者ID:equilion,项目名称:indigo,代码行数:36,代码来源:pg_mango_utils.cpp
示例12: mol_inchikey
Datum
mol_inchikey(PG_FUNCTION_ARGS) {
CROMol mol;
const char *str;
fcinfo->flinfo->fn_extra = SearchMolCache(
fcinfo->flinfo->fn_extra,
fcinfo->flinfo->fn_mcxt,
PG_GETARG_DATUM(0),
NULL, &mol, NULL);
str = MolInchiKey(mol);
char *res=pnstrdup(str, strlen(str));
free((void *)str);
PG_RETURN_CSTRING( res );
}
开发者ID:Acpharis,项目名称:rdkit,代码行数:15,代码来源:mol_op.c
示例13: LWGEOM_to_BOX3D
Datum LWGEOM_to_BOX3D(PG_FUNCTION_ARGS)
{
GSERIALIZED *geom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
GBOX gbox;
BOX3D *result;
int rv = lwgeom_calculate_gbox(lwgeom, &gbox);
if ( rv == LW_FAILURE )
PG_RETURN_NULL();
result = box3d_from_gbox(&gbox);
PG_RETURN_POINTER(result);
}
开发者ID:netconstructor,项目名称:postgis-1,代码行数:15,代码来源:lwgeom_box3d.c
示例14: mol_adjust_query_properties
Datum mol_adjust_query_properties(PG_FUNCTION_ARGS) {
CROMol mol;
fcinfo->flinfo->fn_extra =
searchMolCache(fcinfo->flinfo->fn_extra, fcinfo->flinfo->fn_mcxt,
PG_GETARG_DATUM(0), NULL, &mol, NULL);
Assert(mol != 0);
char *data = PG_GETARG_CSTRING(1);
CROMol adj = MolAdjustQueryProperties(mol, data);
if (!adj) PG_RETURN_NULL();
Mol *res = deconstructROMol(adj);
freeCROMol(adj);
PG_RETURN_MOL_P(res);
}
开发者ID:Richard-Hall,项目名称:rdkit,代码行数:15,代码来源:mol_op.c
示例15: gserialized_gist_distance_2d
Datum gserialized_gist_distance_2d(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY*) PG_GETARG_POINTER(0);
BOX2DF query_box;
BOX2DF *entry_box;
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
double distance;
POSTGIS_DEBUG(4, "[GIST] 'distance' function called");
/* We are using '13' as the gist distance-betweeen-centroids strategy number
* and '14' as the gist distance-between-boxes strategy number */
if ( strategy != 13 && strategy != 14 ) {
elog(ERROR, "unrecognized strategy number: %d", strategy);
PG_RETURN_FLOAT8(MAXFLOAT);
}
/* Null box should never make this far. */
if ( gserialized_datum_get_box2df_p(PG_GETARG_DATUM(1), &query_box) == LW_FAILURE )
{
POSTGIS_DEBUG(4, "[GIST] null query_gbox_index!");
PG_RETURN_FLOAT8(MAXFLOAT);
}
/* Get the entry box */
entry_box = (BOX2DF*)DatumGetPointer(entry->key);
/* Box-style distance test */
if ( strategy == 14 )
{
distance = (double)box2df_distance(entry_box, &query_box);
PG_RETURN_FLOAT8(distance);
}
/* Treat leaf node tests different from internal nodes */
if (GIST_LEAF(entry))
{
/* Calculate distance to leaves */
distance = (double)box2df_distance_leaf_centroid(entry_box, &query_box);
}
else
{
/* Calculate distance for internal nodes */
distance = (double)box2df_distance_node_centroid(entry_box, &query_box);
}
PG_RETURN_FLOAT8(distance);
}
开发者ID:JeremyGrosser,项目名称:postgis,代码行数:48,代码来源:gserialized_gist_2d.c
示例16: adaptive_add_item_agg2
Datum
adaptive_add_item_agg2(PG_FUNCTION_ARGS)
{
AdaptiveCounter acounter;
/* info for anyelement */
Oid element_type = get_fn_expr_argtype(fcinfo->flinfo, 1);
Datum element = PG_GETARG_DATUM(1);
int16 typlen;
bool typbyval;
char typalign;
/* is the counter created (if not, create it with default parameters) */
if (PG_ARGISNULL(0)) {
acounter = ac_init(DEFAULT_ERROR, DEFAULT_NDISTINCT);
} else {
acounter = (AdaptiveCounter)PG_GETARG_BYTEA_P(0);
}
/* add the item to the estimator */
if (! PG_ARGISNULL(1)) {
/* TODO The requests for type info shouldn't be a problem (thanks to lsyscache),
* but if it turns out to have a noticeable impact it's possible to cache that
* between the calls (in the estimator). */
/* get type information for the second parameter (anyelement item) */
get_typlenbyvalalign(element_type, &typlen, &typbyval, &typalign);
/* it this a varlena type, passed by reference or by value ? */
if (typlen == -1) {
/* varlena */
ac_add_item(acounter, VARDATA(element), VARSIZE(element) - VARHDRSZ);
} else if (typbyval) {
/* fixed-length, passed by value */
ac_add_item(acounter, (char*)&element, typlen);
} else {
/* fixed-length, passed by reference */
ac_add_item(acounter, (char*)element, typlen);
}
}
/* return the updated bytea */
PG_RETURN_BYTEA_P(acounter);
}
开发者ID:pjaromin,项目名称:distinct_estimators,代码行数:48,代码来源:adaptive_counter.c
示例17: subarray
Datum
subarray(PG_FUNCTION_ARGS)
{
ArrayType *a = (ArrayType *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(0)));
ArrayType *result;
int32 start = (PG_GETARG_INT32(1) > 0) ? PG_GETARG_INT32(1) - 1 : PG_GETARG_INT32(1);
int32 len = (fcinfo->nargs == 3) ? PG_GETARG_INT32(2) : 0;
int32 end = 0;
int32 c;
CHECKARRVALID(a);
if (ARRISVOID(a))
{
PG_FREE_IF_COPY(a, 0);
PG_RETURN_POINTER(new_intArrayType(0));
}
c = ARRNELEMS(a);
if (start < 0)
start = c + start;
if (len < 0)
end = c + len;
else if (len == 0)
end = c;
else
end = start + len;
if (end > c)
end = c;
if (start < 0)
start = 0;
if (start >= end || end <= 0)
{
PG_FREE_IF_COPY(a, 0);
PG_RETURN_POINTER(new_intArrayType(0));
}
result = new_intArrayType(end - start);
if (end - start > 0)
memcpy(ARRPTR(result), ARRPTR(a) + start, (end - start) * sizeof(int32));
PG_FREE_IF_COPY(a, 0);
PG_RETURN_POINTER(result);
}
开发者ID:KMU-embedded,项目名称:mosbench-ext,代码行数:48,代码来源:_int_op.c
示例18: metaphone
Datum
metaphone(PG_FUNCTION_ARGS)
{
char *str_i = TextDatumGetCString(PG_GETARG_DATUM(0));
size_t str_i_len = strlen(str_i);
int reqlen;
char *metaph;
int retval;
/* return an empty string if we receive one */
if (!(str_i_len > 0))
PG_RETURN_TEXT_P(cstring_to_text(""));
if (str_i_len > MAX_METAPHONE_STRLEN)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("argument exceeds the maximum length of %d bytes",
MAX_METAPHONE_STRLEN)));
if (!(str_i_len > 0))
ereport(ERROR,
(errcode(ERRCODE_ZERO_LENGTH_CHARACTER_STRING),
errmsg("argument is empty string")));
reqlen = PG_GETARG_INT32(1);
if (reqlen > MAX_METAPHONE_STRLEN)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("output exceeds the maximum length of %d bytes",
MAX_METAPHONE_STRLEN)));
if (!(reqlen > 0))
ereport(ERROR,
(errcode(ERRCODE_ZERO_LENGTH_CHARACTER_STRING),
errmsg("output cannot be empty string")));
retval = _metaphone(str_i, reqlen, &metaph);
if (retval == META_SUCCESS)
PG_RETURN_TEXT_P(cstring_to_text(metaph));
else
{
/* internal error */
elog(ERROR, "metaphone: failure");
/* keep the compiler quiet */
PG_RETURN_NULL();
}
}
开发者ID:a1exsh,项目名称:postgres,代码行数:48,代码来源:fuzzystrmatch.c
示例19: consistencyCheck
/**
* @brief Return the n-th element from a composite value
*
* To the user, AnyType is a fully recursive type: Each AnyType object can be a
* composite object and be composed of a number of other AnyType objects.
* On top of the C++ abstraction layer, function have a single-top level
* AnyType object as parameter.
*/
inline
AbstractionLayer::AnyType
AbstractionLayer::AnyType::operator[](uint16_t inID) const {
consistencyCheck();
if (isNull())
throw std::invalid_argument("Unexpected Null value in function "
"argument.");
if (!isComposite())
throw std::invalid_argument("Invalid type conversion requested. "
"Expected composite type but got simple type.");
if (mContent == ReturnComposite)
return mChildren[inID];
Oid typeID = 0;
bool isMutable = false;
Datum datum = 0;
bool isTuple = false;
HeapTupleHeader pgTuple = NULL;
try {
if (mContent == FunctionComposite) {
if (inID >= size_t(PG_NARGS()))
throw std::out_of_range("Access behind end of argument list");
if (PG_ARGISNULL(inID))
return AnyType();
backendGetTypeIDForFunctionArg(inID, typeID, isMutable);
datum = PG_GETARG_DATUM(inID);
} else if (mContent == NativeComposite)
backendGetTypeIDAndDatumForTupleElement(inID, typeID, datum);
if (typeID == InvalidOid)
throw std::invalid_argument("Backend returned invalid type ID.");
backendGetIsCompositeTypeAndHeapTupleHeader(typeID, datum, isTuple,
pgTuple);
} catch (PGException &e) {
throw std::invalid_argument("An exception occurred while "
"gathering information about PostgreSQL function arguments.");
}
return isTuple ?
AnyType(pgTuple, datum, typeID) :
AnyType(datum, typeID, isMutable);
}
开发者ID:agorajek,项目名称:madlib,代码行数:56,代码来源:AnyType_impl.hpp
示例20: pointcloud_agg_transfn
Datum pointcloud_agg_transfn(PG_FUNCTION_ARGS)
{
Oid arg1_typeid = get_fn_expr_argtype(fcinfo->flinfo, 1);
MemoryContext aggcontext;
abs_trans *a;
ArrayBuildState *state;
Datum elem;
if (arg1_typeid == InvalidOid)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("could not determine input data type")));
if (fcinfo->context && IsA(fcinfo->context, AggState))
{
aggcontext = ((AggState *) fcinfo->context)->aggcontext;
}
else if (fcinfo->context && IsA(fcinfo->context, WindowAggState))
{
aggcontext = ((WindowAggState *) fcinfo->context)->aggcontext;
}
else
{
/* cannot be called directly because of dummy-type argument */
elog(ERROR, "pointcloud_agg_transfn called in non-aggregate context");
aggcontext = NULL; /* keep compiler quiet */
}
if ( PG_ARGISNULL(0) )
{
a = (abs_trans*) palloc(sizeof(abs_trans));
a->s = NULL;
}
else
{
a = (abs_trans*) PG_GETARG_POINTER(0);
}
state = a->s;
elem = PG_ARGISNULL(1) ? (Datum) 0 : PG_GETARG_DATUM(1);
state = accumArrayResult(state,
elem,
PG_ARGISNULL(1),
arg1_typeid,
aggcontext);
a->s = state;
PG_RETURN_POINTER(a);
}
开发者ID:kjartab,项目名称:pointcloud,代码行数:48,代码来源:pc_access.c
注:本文中的PG_GETARG_DATUM函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论