本文整理汇总了C++中PG_RETURN_NULL函数的典型用法代码示例。如果您正苦于以下问题:C++ PG_RETURN_NULL函数的具体用法?C++ PG_RETURN_NULL怎么用?C++ PG_RETURN_NULL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PG_RETURN_NULL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: x509_get_version
Datum x509_get_version(PG_FUNCTION_ARGS) {
bytea *raw;
X509 *cert;
int version;
// check for null value.
raw = PG_GETARG_BYTEA_P(0);
if (raw == NULL || VARSIZE(raw) == VARHDRSZ) {
PG_RETURN_NULL();
}
cert = x509_from_bytea(raw);
if (cert == NULL) {
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED), errmsg(
"unable to decode X509 record")));
}
version = X509_get_version(cert);
X509_free(cert);
PG_RETURN_INT32(version);
}
开发者ID:beargiles,项目名称:pgopenssltypes,代码行数:23,代码来源:x509.c
示例2: pg_stat_get_backend_wait_event_type
Datum
pg_stat_get_backend_wait_event_type(PG_FUNCTION_ARGS)
{
int32 beid = PG_GETARG_INT32(0);
PgBackendStatus *beentry;
PGPROC *proc;
const char *wait_event_type;
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
wait_event_type = "<backend information not available>";
else if (!has_privs_of_role(GetUserId(), beentry->st_userid))
wait_event_type = "<insufficient privilege>";
else
{
proc = BackendPidGetProc(beentry->st_procpid);
wait_event_type = pgstat_get_wait_event_type(proc->wait_event_info);
}
if (!wait_event_type)
PG_RETURN_NULL();
PG_RETURN_TEXT_P(cstring_to_text(wait_event_type));
}
开发者ID:BenjaminYu,项目名称:postgres,代码行数:23,代码来源:pgstatfuncs.c
示例3: fetchval
Datum
fetchval(PG_FUNCTION_ARGS)
{
HStore *hs = PG_GETARG_HS(0);
text *key = PG_GETARG_TEXT_P(1);
HEntry *entry;
text *out;
if ((entry = findkey(hs, VARDATA(key), VARSIZE(key) - VARHDRSZ)) == NULL || entry->valisnull)
{
PG_FREE_IF_COPY(hs, 0);
PG_FREE_IF_COPY(key, 1);
PG_RETURN_NULL();
}
out = palloc(VARHDRSZ + entry->vallen);
memcpy(VARDATA(out), STRPTR(hs) + entry->pos + entry->keylen, entry->vallen);
SET_VARSIZE(out, VARHDRSZ + entry->vallen);
PG_FREE_IF_COPY(hs, 0);
PG_FREE_IF_COPY(key, 1);
PG_RETURN_POINTER(out);
}
开发者ID:KMU-embedded,项目名称:mosbench-ext,代码行数:23,代码来源:hstore_op.c
示例4: lexize_bycurrent
Datum
lexize_bycurrent(PG_FUNCTION_ARGS)
{
Datum res;
SET_FUNCOID();
if (currect_dictionary_id == 0)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("no currect dictionary"),
errhint("Execute select set_curdict().")));
res = DirectFunctionCall3(
lexize,
ObjectIdGetDatum(currect_dictionary_id),
PG_GETARG_DATUM(0),
(Datum) 0
);
if (res)
PG_RETURN_DATUM(res);
else
PG_RETURN_NULL();
}
开发者ID:CraigBryan,项目名称:PostgresqlFun,代码行数:23,代码来源:dict.c
示例5: 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_TEXT_P(cstring_to_text(result));
}
开发者ID:adunstan,项目名称:pg-cvs-mirror,代码行数:49,代码来源:format_type.c
示例6: LWGEOM_x_point
Datum LWGEOM_x_point(PG_FUNCTION_ARGS)
{
GSERIALIZED *geom;
LWGEOM *lwgeom;
LWPOINT *point = NULL;
POINT2D p;
geom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
if ( gserialized_get_type(geom) != POINTTYPE )
lwerror("Argument to X() must be a point");
lwgeom = lwgeom_from_gserialized(geom);
point = lwgeom_as_lwpoint(lwgeom);
if ( lwgeom_is_empty(lwgeom) )
PG_RETURN_NULL();
getPoint2d_p(point->point, 0, &p);
PG_FREE_IF_COPY(geom, 0);
PG_RETURN_FLOAT8(p.x);
}
开发者ID:gravitystorm,项目名称:postgis,代码行数:23,代码来源:lwgeom_ogc.c
示例7: LWGEOM_line_desegmentize
Datum LWGEOM_line_desegmentize(PG_FUNCTION_ARGS)
{
GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
GSERIALIZED *ret;
LWGEOM *igeom = NULL, *ogeom = NULL;
POSTGIS_DEBUG(2, "LWGEOM_line_desegmentize.");
igeom = lwgeom_from_gserialized(geom);
ogeom = lwgeom_unstroke(igeom);
lwgeom_free(igeom);
if (ogeom == NULL)
{
PG_FREE_IF_COPY(geom, 0);
PG_RETURN_NULL();
}
ret = geometry_serialize(ogeom);
lwgeom_free(ogeom);
PG_FREE_IF_COPY(geom, 0);
PG_RETURN_POINTER(ret);
}
开发者ID:gbroccolo,项目名称:postgis,代码行数:23,代码来源:lwgeom_sqlmm.c
示例8: hello
PGDLLEXPORT
Datum
hello( PG_FUNCTION_ARGS )
{
// variable declarations
char greet[] = "Hello, ";
text *towhom;
int greetlen;
int towhomlen;
text *greeting;
int greeting_size;
// Get arguments. If we declare our function as STRICT, then
// this check is superfluous.
if(PG_ARGISNULL(0)) {
PG_RETURN_NULL();
}
towhom = PG_GETARG_TEXT_P(0);
// Calculate string sizes.
greetlen = strlen(greet);
towhomlen = VARSIZE(towhom)-VARHDRSZ;
// Allocate memory and set data structure size.
greeting = (text *)palloc( greetlen + towhomlen );
//VARATT_SIZEP( greeting ) = greetlen + towhomlen + VARHDRSZ;//postgres 7.4
greeting_size=greetlen+towhomlen+VARHDRSZ;
SET_VARSIZE(greeting,greeting_size);
// Construct greeting string.
strncpy( VARDATA(greeting), greet, greetlen );
strncpy( VARDATA(greeting) + greetlen,
VARDATA(towhom),
towhomlen );
PG_RETURN_TEXT_P( greeting );
}
开发者ID:lcp580,项目名称:nlpir_parser,代码行数:37,代码来源:nlpir_parser.c
示例9: pg_read_file
/*
* Read a section of a file, returning it as text
*/
Datum
pg_read_file(PG_FUNCTION_ARGS)
{
text *filename_t = PG_GETARG_TEXT_PP(0);
int64 seek_offset = 0;
int64 bytes_to_read = -1;
bool missing_ok = false;
char *filename;
text *result;
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
(errmsg("must be superuser to read files"))));
/* handle optional arguments */
if (PG_NARGS() >= 3)
{
seek_offset = PG_GETARG_INT64(1);
bytes_to_read = PG_GETARG_INT64(2);
if (bytes_to_read < 0)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("requested length cannot be negative")));
}
if (PG_NARGS() >= 4)
missing_ok = PG_GETARG_BOOL(3);
filename = convert_and_check_filename(filename_t);
result = read_text_file(filename, seek_offset, bytes_to_read, missing_ok);
if (result)
PG_RETURN_TEXT_P(result);
else
PG_RETURN_NULL();
}
开发者ID:BertrandAreal,项目名称:postgres,代码行数:40,代码来源:genfile.c
示例10: pcpatch_in
Datum pcpatch_in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
/* Datum geog_oid = PG_GETARG_OID(1); Not needed. */
uint32 typmod = 0, pcid = 0;
PCPATCH *patch;
SERIALIZED_PATCH *serpatch = NULL;
if ( (PG_NARGS()>2) && (!PG_ARGISNULL(2)) )
{
typmod = PG_GETARG_INT32(2);
pcid = pcid_from_typmod(typmod);
}
/* Empty string. */
if ( str[0] == '\0' )
{
ereport(ERROR,(errmsg("pcpatch parse error - empty string")));
}
/* Binary or text form? Let's find out. */
if ( str[0] == '0' )
{
/* Hex-encoded binary */
patch = pc_patch_from_hexwkb(str, strlen(str), fcinfo);
pcid_consistent(patch->schema->pcid, pcid);
serpatch = pc_patch_serialize(patch, NULL);
pc_patch_free(patch);
}
else
{
ereport(ERROR,(errmsg("parse error - support for text format not yet implemented")));
}
if ( serpatch ) PG_RETURN_POINTER(serpatch);
else PG_RETURN_NULL();
}
开发者ID:achidlow,项目名称:pointcloud,代码行数:37,代码来源:pc_inout.c
示例11: linterp_int32
Datum
linterp_int32(PG_FUNCTION_ARGS)
{
float8 y0;
float8 y1;
float8 p;
float8 r;
int32 result;
bool eq_bounds = false;
bool eq_abscissas = false;
/* Common */
p = linterp_abscissa(fcinfo, &eq_bounds, &eq_abscissas);
/* Ordinate type specific code*/
y0 = (float8)PG_GETARG_INT32(2);
y1 = (float8)PG_GETARG_INT32(4);
if ( eq_bounds )
{
if ( eq_abscissas && y0 == y1 )
r = y0;
else
PG_RETURN_NULL();
}
else
{
r = round(y0+p*(y1-y0));
if ( r < INT_MIN || r > INT_MAX )
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("value \"%f\" is out of range for type integer", r)));
}
result = (int32)r;
PG_RETURN_INT32(result);
}
开发者ID:hsyuan,项目名称:gpdb,代码行数:37,代码来源:interpolate.c
示例12: xpath_string
Datum
xpath_string(PG_FUNCTION_ARGS)
{
text *document = PG_GETARG_TEXT_P(0);
text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
xmlChar *xpath;
int32 pathsize;
text *xpres;
xmlXPathObjectPtr res;
xpath_workspace workspace;
pathsize = VARSIZE(xpathsupp) - VARHDRSZ;
/*
* We encapsulate the supplied path with "string()" = 8 chars + 1 for NUL
* at end
*/
/* We could try casting to string using the libxml function? */
xpath = (xmlChar *) palloc(pathsize + 9);
strncpy((char *) xpath, "string(", 7);
memcpy((char *) (xpath + 7), VARDATA(xpathsupp), pathsize);
xpath[pathsize + 7] = ')';
xpath[pathsize + 8] = '\0';
res = pgxml_xpath(document, xpath, &workspace);
xpres = pgxml_result_to_text(res, NULL, NULL, NULL);
cleanup_workspace(&workspace);
pfree(xpath);
if (xpres == NULL)
PG_RETURN_NULL();
PG_RETURN_TEXT_P(xpres);
}
开发者ID:42penguins,项目名称:postgres,代码行数:37,代码来源:xpath.c
示例13: xpath_string
Datum
xpath_string(PG_FUNCTION_ARGS)
{
xmlChar *xpath;
int32 pathsize;
text
*xpathsupp,
*xpres;
/* PG_GETARG_TEXT_P(0) is document buffer */
xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
pathsize = VARSIZE(xpathsupp) - VARHDRSZ;
/*
* We encapsulate the supplied path with "string()" = 8 chars + 1 for NUL
* at end
*/
/* We could try casting to string using the libxml function? */
xpath = (xmlChar *) palloc(pathsize + 9);
memcpy((char *) (xpath + 7), VARDATA(xpathsupp), pathsize);
strncpy((char *) xpath, "string(", 7);
xpath[pathsize + 7] = ')';
xpath[pathsize + 8] = '\0';
xpres = pgxml_result_to_text(
pgxml_xpath(PG_GETARG_TEXT_P(0), xpath),
NULL, NULL, NULL);
xmlCleanupParser();
pfree(xpath);
if (xpres == NULL)
PG_RETURN_NULL();
PG_RETURN_TEXT_P(xpres);
}
开发者ID:CraigBryan,项目名称:PostgresqlFun,代码行数:37,代码来源:xpath.c
示例14: pgx_complex_near
Datum
pgx_complex_near(PG_FUNCTION_ARGS) {
double re[2];
double im[2];
double p, q;
int i;
// unwrap values.
for (i = 0; i < 2; i++) {
HeapTupleHeader t = PG_GETARG_HEAPTUPLEHEADER(i);
bool isnull[2];
Datum dr = GetAttributeByName(t, "re", &isnull[0]);
Datum di = GetAttributeByName(t, "im", &isnull[1]);
// STRICT prevents the 'complex' value from being null but does
// not prevent its components from being null.
if (isnull[0] || isnull[1]) {
PG_RETURN_NULL();
}
re[i] = DatumGetFloat8(dr);
im[i] = DatumGetFloat8(di);
}
// compute distance between points, distance of points from origin.
p = hypot(re[0] - re[1], im[0] - im[1]);
q = hypot(re[0], im[0]) + hypot(re[1], im[1]);
if (q == 0) {
PG_RETURN_BOOL(1);
}
// we consider the points 'near' each other if the distance between them is small
// relative to the size of them.
PG_RETURN_BOOL(p / q < 1e-8);
}
开发者ID:beargiles,项目名称:pg-complex,代码行数:37,代码来源:complex.c
示例15: quantile_numeric_array
Datum
quantile_numeric_array(PG_FUNCTION_ARGS)
{
int i, idx = 0;
struct_numeric * data;
Numeric * result;
CHECK_AGG_CONTEXT("quantile_numeric_array", fcinfo);
if (PG_ARGISNULL(0)) {
PG_RETURN_NULL();
}
data = (struct_numeric*)PG_GETARG_POINTER(0);
result = palloc(data->nquantiles * sizeof(Numeric));
qsort(data->elements, data->next, sizeof(Numeric), &numeric_comparator);
for (i = 0; i < data->nquantiles; i++) {
if ((data->quantiles[i] > 0) && (data->quantiles[i] < 1)) {
idx = (int)ceil(data->next * data->quantiles[i]) - 1;
} else if (data->quantiles[i] <= 0) {
idx = 0;
} else if (data->quantiles[i] >= 1) {
idx = data->next - 1;
}
result[i] = data->elements[idx];
}
return numeric_to_array(fcinfo, result, data->nquantiles);
}
开发者ID:kimhanse,项目名称:quantile,代码行数:37,代码来源:quantile.c
示例16: regress_dist_ptpath
Datum
regress_dist_ptpath(PG_FUNCTION_ARGS)
{
Point *pt = PG_GETARG_POINT_P(0);
PATH *path = PG_GETARG_PATH_P(1);
float8 result = 0.0; /* keep compiler quiet */
float8 tmp;
int i;
LSEG lseg;
switch (path->npts)
{
case 0:
PG_RETURN_NULL();
case 1:
result = point_dt(pt, &path->p[0]);
break;
default:
/*
* the distance from a point to a path is the smallest distance
* from the point to any of its constituent segments.
*/
Assert(path->npts > 1);
for (i = 0; i < path->npts - 1; ++i)
{
regress_lseg_construct(&lseg, &path->p[i], &path->p[i + 1]);
tmp = DatumGetFloat8(DirectFunctionCall2(dist_ps,
PointPGetDatum(pt),
LsegPGetDatum(&lseg)));
if (i == 0 || tmp < result)
result = tmp;
}
break;
}
PG_RETURN_FLOAT8(result);
}
开发者ID:meibenjin,项目名称:postgres,代码行数:37,代码来源:regress.c
示例17: pg_tablespace_size_name
Datum
pg_tablespace_size_name(PG_FUNCTION_ARGS)
{
Name tblspcName = PG_GETARG_NAME(0);
Oid tblspcOid = get_tablespace_oid(NameStr(*tblspcName), false);
int64 size;
size = calculate_tablespace_size(tblspcOid);
if (Gp_role == GP_ROLE_DISPATCH)
{
char *sql;
sql = psprintf("select pg_catalog.pg_tablespace_size(%s)",
quote_literal_cstr(NameStr(*tblspcName)));
size += get_size_from_segDBs(sql);
}
if (size < 0)
PG_RETURN_NULL();
PG_RETURN_INT64(size);
}
开发者ID:pf-qiu,项目名称:gpdb,代码行数:24,代码来源:dbsize.c
示例18: ssl_client_serial
Datum
ssl_client_serial(PG_FUNCTION_ARGS)
{
Datum result;
Port *port = MyProcPort;
X509 *peer = port->peer;
ASN1_INTEGER *serial = NULL;
BIGNUM *b;
char *decimal;
if (!peer)
PG_RETURN_NULL();
serial = X509_get_serialNumber(peer);
b = ASN1_INTEGER_to_BN(serial, NULL);
decimal = BN_bn2dec(b);
BN_free(b);
result = DirectFunctionCall3(numeric_in,
CStringGetDatum(decimal),
ObjectIdGetDatum(0),
Int32GetDatum(-1));
OPENSSL_free(decimal);
return result;
}
开发者ID:Aslai,项目名称:postgres,代码行数:24,代码来源:sslinfo.c
示例19: pg_relation_size_name
Datum
pg_relation_size_name(PG_FUNCTION_ARGS)
{
text *relname = PG_GETARG_TEXT_P(0);
RangeVar *relrv;
Relation rel;
int64 size;
if (GP_ROLE_EXECUTE == Gp_role)
{
ereport(ERROR,
(errcode(ERRCODE_GP_COMMAND_ERROR),
errmsg("pg_relation_size: cannot be executed in segment")));
}
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
rel = try_relation_openrv(relrv, AccessShareLock, false);
/*
* While we scan pg_class with an MVCC snapshot,
* someone else might drop the table. It's better to return NULL for
* already-dropped tables than throw an error and abort the whole query.
*/
if (!RelationIsValid(rel))
PG_RETURN_NULL();
if (rel->rd_node.relNode == 0)
size = 0;
else
size = calculate_relation_size(rel);
relation_close(rel, AccessShareLock);
PG_RETURN_INT64(size);
}
开发者ID:BALDELab,项目名称:incubator-hawq,代码行数:36,代码来源:dbsize.c
示例20: pcpatch_bytea_envelope
Datum pcpatch_bytea_envelope(PG_FUNCTION_ARGS)
{
SERIALIZED_PATCH *serpatch = PG_GETARG_SERPATCH_P(0);
uint8 *bytes;
size_t bytes_size;
bytea *wkb;
size_t wkb_size;
PCSCHEMA *schema = pc_schema_from_pcid(serpatch->pcid, fcinfo);
PCPATCH *pa = pc_patch_deserialize(serpatch, schema);
if ( ! pa )
PG_RETURN_NULL();
bytes = pc_patch_to_geometry_wkb_envelope(pa, &bytes_size);
wkb_size = VARHDRSZ + bytes_size;
wkb = palloc(wkb_size);
memcpy(VARDATA(wkb), bytes, bytes_size);
SET_VARSIZE(wkb, wkb_size);
pc_patch_free(pa);
pfree(bytes);
PG_RETURN_BYTEA_P(wkb);
}
开发者ID:gijs,项目名称:pointcloud,代码行数:24,代码来源:pc_inout.c
注:本文中的PG_RETURN_NULL函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论