本文整理汇总了C++中PG_GETARG_DATUM函数的典型用法代码示例。如果您正苦于以下问题:C++ PG_GETARG_DATUM函数的具体用法?C++ PG_GETARG_DATUM怎么用?C++ PG_GETARG_DATUM使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PG_GETARG_DATUM函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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 );
}
示例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);
}
示例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);
}
示例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);
}