当前位置: 首页>>代码示例>>C++>>正文


C++ PG_GETARG_BYTEA_P函数代码示例

本文整理汇总了C++中PG_GETARG_BYTEA_P函数的典型用法代码示例。如果您正苦于以下问题:C++ PG_GETARG_BYTEA_P函数的具体用法?C++ PG_GETARG_BYTEA_P怎么用?C++ PG_GETARG_BYTEA_P使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PG_GETARG_BYTEA_P函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: __cmsketch_merge

Datum __cmsketch_merge(PG_FUNCTION_ARGS)
{
    bytea *     counterblob1 = PG_GETARG_BYTEA_P(0);
    bytea *     counterblob2 = PG_GETARG_BYTEA_P(1);
    cmtransval *transval1 = (cmtransval *)VARDATA(counterblob1);
    cmtransval *transval2 = (cmtransval *)VARDATA(counterblob2);
    cmtransval *newtrans;
    countmin *  sketches2 = (countmin *)
                            ((cmtransval *)(VARDATA(counterblob2)))->sketches;
    bytea *     newblob;
    countmin *  newsketches;
    uint32      i, j, k;
    int         sz;

    /* make sure they're initialized! */
    if (!CM_TRANSVAL_INITIALIZED(counterblob1)
        && !CM_TRANSVAL_INITIALIZED(counterblob2))
        /* if both are empty can return one of them */
        PG_RETURN_DATUM(PointerGetDatum(counterblob1));
    else if (!CM_TRANSVAL_INITIALIZED(counterblob1)) {
        counterblob1 = cmsketch_init_transval(transval2->typOid);
        transval1 = (cmtransval *)VARDATA(counterblob1);
    }
    else if (!CM_TRANSVAL_INITIALIZED(counterblob2)) {
        counterblob2 = cmsketch_init_transval(transval1->typOid);
        transval2 = (cmtransval *)VARDATA(counterblob2);
    }

    sz = VARSIZE(counterblob1);
    /* allocate a new transval as a copy of counterblob1 */
    newblob = (bytea *)palloc(sz);
    memcpy(newblob, counterblob1, sz);
    newtrans = (cmtransval *)(VARDATA(newblob));
    newsketches = (countmin *)(newtrans)->sketches;

    /* add in values from counterblob2 */
    for (i = 0; i < RANGES; i++)
        for (j = 0; j < DEPTH; j++)
            for (k = 0; k < NUMCOUNTERS; k++)
                newsketches[i][j][k] += sketches2[i][j][k];

    if (newtrans->nargs == -1) {
        /* transfer in the args from the other input */
        newtrans->nargs = transval2->nargs;
        for (i = 0; (int)i < transval2->nargs; i++)
            newtrans->args[i] = transval2->args[i];
    }

    PG_RETURN_DATUM(PointerGetDatum(newblob));
}
开发者ID:ErwanTremiot,项目名称:madlib,代码行数:50,代码来源:countmin.c

示例2: pg_decrypt_iv

Datum
pg_decrypt_iv(PG_FUNCTION_ARGS)
{
	int			err;
	bytea	   *data,
			   *key,
			   *iv,
			   *res;
	text	   *type;
	PX_Combo   *c;
	unsigned	dlen,
				klen,
				rlen,
				ivlen;

	type = PG_GETARG_TEXT_P(3);
	c = find_provider(type, (PFN) px_find_combo, "Cipher", 0);

	data = PG_GETARG_BYTEA_P(0);
	key = PG_GETARG_BYTEA_P(1);
	iv = PG_GETARG_BYTEA_P(2);
	dlen = VARSIZE(data) - VARHDRSZ;
	klen = VARSIZE(key) - VARHDRSZ;
	ivlen = VARSIZE(iv) - VARHDRSZ;

	rlen = px_combo_decrypt_len(c, dlen);
	res = palloc(VARHDRSZ + rlen);

	err = px_combo_init(c, (uint8 *) VARDATA(key), klen,
						(uint8 *) VARDATA(iv), ivlen);
	if (!err)
		px_combo_decrypt(c, (uint8 *) VARDATA(data), dlen,
						 (uint8 *) VARDATA(res), &rlen);

	px_combo_free(c);

	if (err)
		ereport(ERROR,
				(errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
				 errmsg("decrypt_iv error: %s", px_strerror(err))));

	SET_VARSIZE(res, VARHDRSZ + rlen);

	PG_FREE_IF_COPY(data, 0);
	PG_FREE_IF_COPY(key, 1);
	PG_FREE_IF_COPY(iv, 2);
	PG_FREE_IF_COPY(type, 3);

	PG_RETURN_BYTEA_P(res);
}
开发者ID:GisKook,项目名称:Gis,代码行数:50,代码来源:pgcrypto.c

示例3: pg_encrypt

Datum
pg_encrypt(PG_FUNCTION_ARGS)
{
	int			err;
	bytea	   *data,
			   *key,
			   *res;
	text	   *type;
	PX_Combo   *c;
	unsigned	dlen,
				klen,
				rlen;

	if (PG_ARGISNULL(0) || PG_ARGISNULL(1) || PG_ARGISNULL(2))
		PG_RETURN_NULL();

	type = PG_GETARG_TEXT_P(2);
	c = find_provider(type, (PFN) px_find_combo, "Cipher", 0);

	data = PG_GETARG_BYTEA_P(0);
	key = PG_GETARG_BYTEA_P(1);
	dlen = VARSIZE(data) - VARHDRSZ;
	klen = VARSIZE(key) - VARHDRSZ;

	rlen = px_combo_encrypt_len(c, dlen);
	res = palloc(VARHDRSZ + rlen);

	err = px_combo_init(c, (uint8 *) VARDATA(key), klen, NULL, 0);
	if (!err)
		err = px_combo_encrypt(c, (uint8 *) VARDATA(data), dlen,
							   (uint8 *) VARDATA(res), &rlen);
	px_combo_free(c);

	PG_FREE_IF_COPY(data, 0);
	PG_FREE_IF_COPY(key, 1);
	PG_FREE_IF_COPY(type, 2);

	if (err)
	{
		pfree(res);
		ereport(ERROR,
				(errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
				 errmsg("encrypt error: %s", px_strerror(err))));
	}

	VARATT_SIZEP(res) = VARHDRSZ + rlen;
	PG_RETURN_BYTEA_P(res);
}
开发者ID:CraigBryan,项目名称:PostgresqlFun,代码行数:48,代码来源:pgcrypto.c

示例4: adaptive_counter_update

Datum
adaptive_counter_update(PG_FUNCTION_ARGS)
{
    
    bytea * data;
    AdaptiveCounter ac;
  
    /* is the counter created (if not, create it - error 1%, 10mil items) */
    if (PG_ARGISNULL(0)) {
      ac = as_create(0.01, 4);
      data = (bytea*)palloc(ac->length + VARHDRSZ);
      SET_VARSIZE(data, ac->length);
      memcpy(VARDATA(data), ac, ac->length);
      elog(NOTICE, "Adaptive Counter: %d bytes", ac->length);
    } else {
      data = PG_GETARG_BYTEA_P(0);
    }
    
    ac = (AdaptiveCounter)VARDATA(data);
      
    /* get the new item */
    text * item = PG_GETARG_TEXT_P(1);
    
    /* in-place update works only if executed as aggregate */
    as_add_element(ac, VARDATA(item), VARSIZE(item) - VARHDRSZ);
    
    /* return the updated bytea */
    PG_RETURN_BYTEA_P(data);
    
}
开发者ID:dreamsxin,项目名称:pg_estimator,代码行数:30,代码来源:adaptive-agg.c

示例5: lowrite

Datum
lowrite(PG_FUNCTION_ARGS)
{
	int32		fd = PG_GETARG_INT32(0);
	bytea	   *wbuf = PG_GETARG_BYTEA_P(1);
	int			bytestowrite;
	int			totalwritten;

#ifdef PGXC
#ifdef XCP
	ereport(ERROR,
			(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
			 errmsg("Postgres-XL does not yet support large objects"),
			 errdetail("The feature is not currently supported")));
#else
	ereport(ERROR,
			(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
			 errmsg("Postgres-XC does not support large object yet"),
			 errdetail("The feature is not currently supported")));
#endif
#endif

	bytestowrite = VARSIZE(wbuf) - VARHDRSZ;
	totalwritten = lo_write(fd, VARDATA(wbuf), bytestowrite);
	PG_RETURN_INT32(totalwritten);
}
开发者ID:techdragon,项目名称:Postgres-XL,代码行数:26,代码来源:be-fsstubs.c

示例6: brin_page_type

Datum
brin_page_type(PG_FUNCTION_ARGS)
{
	bytea	   *raw_page = PG_GETARG_BYTEA_P(0);
	Page		page = VARDATA(raw_page);
	BrinSpecialSpace *special;
	char *type;

	special = (BrinSpecialSpace *) PageGetSpecialPointer(page);

	switch (special->type)
	{
		case BRIN_PAGETYPE_META:
			type = "meta";
			break;
		case BRIN_PAGETYPE_REVMAP:
			type = "revmap";
			break;
		case BRIN_PAGETYPE_REGULAR:
			type = "regular";
			break;
		default:
			type = psprintf("unknown (%02x)", special->type);
			break;
	}

	PG_RETURN_TEXT_P(cstring_to_text(type));
}
开发者ID:JiannengSun,项目名称:postgres,代码行数:28,代码来源:brinfuncs.c

示例7: brin_page_type

Datum
brin_page_type(PG_FUNCTION_ARGS)
{
    bytea	   *raw_page = PG_GETARG_BYTEA_P(0);
    Page		page = VARDATA(raw_page);
    char	   *type;

    switch (BrinPageType(page))
    {
    case BRIN_PAGETYPE_META:
        type = "meta";
        break;
    case BRIN_PAGETYPE_REVMAP:
        type = "revmap";
        break;
    case BRIN_PAGETYPE_REGULAR:
        type = "regular";
        break;
    default:
        type = psprintf("unknown (%02x)", BrinPageType(page));
        break;
    }

    PG_RETURN_TEXT_P(cstring_to_text(type));
}
开发者ID:linwanggm,项目名称:postgres,代码行数:25,代码来源:brinfuncs.c

示例8: __cmsketch_int8_trans

/*
 * This is the UDF interface.  It does sanity checks and preps values
 * for the interesting logic in countmin_dyadic_trans_c
 */
Datum __cmsketch_int8_trans(PG_FUNCTION_ARGS)
{
    bytea *     transblob = NULL;
    cmtransval *transval;

    /*
     * This function makes destructive updates to its arguments.
     * Make sure it's being called in an agg context.
     */

    if (!(fcinfo->context &&
          (IsA(fcinfo->context, AggState)
    #ifdef NOTGP
           || IsA(fcinfo->context, WindowAggState)
    #endif
          )))
        elog(ERROR,
             "destructive pass by reference outside agg");

    /* get the provided element, being careful in case it's NULL */
    if (!PG_ARGISNULL(1)) {
        transblob = cmsketch_check_transval(fcinfo, true);
        transval = (cmtransval *)(VARDATA(transblob));

        /* the following line modifies the contents of transval, and hence transblob */
        countmin_dyadic_trans_c(transval, PG_GETARG_DATUM(1));
        PG_RETURN_DATUM(PointerGetDatum(transblob));
    }
    else PG_RETURN_DATUM(PointerGetDatum(PG_GETARG_BYTEA_P(0)));
}
开发者ID:ErwanTremiot,项目名称:madlib,代码行数:34,代码来源:countmin.c

示例9: pg_armor

Datum
pg_armor(PG_FUNCTION_ARGS)
{
	bytea	   *data;
	text	   *res;
	int			data_len,
				res_len,
				guess_len;

	data = PG_GETARG_BYTEA_P(0);
	data_len = VARSIZE(data) - VARHDRSZ;

	guess_len = pgp_armor_enc_len(data_len);
	res = palloc(VARHDRSZ + guess_len);

	res_len = pgp_armor_encode((uint8 *) VARDATA(data), data_len,
							   (uint8 *) VARDATA(res));
	if (res_len > guess_len)
		ereport(ERROR,
				(errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
				 errmsg("Overflow - encode estimate too small")));
	SET_VARSIZE(res, VARHDRSZ + res_len);

	PG_FREE_IF_COPY(data, 0);
	PG_RETURN_TEXT_P(res);
}
开发者ID:adunstan,项目名称:pg-cvs-mirror,代码行数:26,代码来源:pgp-pgsql.c

示例10: bytea_size

/*
 * bytea_size
 *
 * Return the size of a bytea field, this data is useful to pass for
 * to a function doing decompression like decompress_data() above.
 */
Datum
bytea_size(PG_FUNCTION_ARGS)
{
	bytea  *data = PG_GETARG_BYTEA_P(0);

	PG_RETURN_INT32(VARSIZE(data) - VARHDRSZ);
}
开发者ID:jiaoyk,项目名称:pg_plugins,代码行数:13,代码来源:compression_test.c

示例11: HASHAPI_Hash_1_Bytea

Datum HASHAPI_Hash_1_Bytea(PG_FUNCTION_ARGS)
{
    int32 num_segs;            /* number of segments  */
	bytea    *val1;        	   /* bytea value		  */
    unsigned int targetbucket; /* 0-based             */
    int16 algorithm;  /* hashing algorithm   */
	Datum d1;
	Oid oid;

	/* Get number of segments */
    num_segs = PG_GETARG_INT32(0);
	
	/* Get hashing algoriithm */
	algorithm = PG_GETARG_INT16(1);
	
	/* Get the value to hash */
	val1 = PG_GETARG_BYTEA_P(2);
	
	d1 = PointerGetDatum(val1);
	
	/* create a CdbHash for this hash test. */
	h = makeCdbHash(num_segs, algorithm);
	
	cdbhashinit(h);
	oid = BYTEAOID;
	cdbhash(h, d1, oid);
	
	/* reduce the result hash value */
	targetbucket = cdbhashreduce(h);	
	
	/* Avoid leaking memory for toasted inputs */
	PG_FREE_IF_COPY(val1, 2);
	
	PG_RETURN_INT32(targetbucket); /* return target bucket (segID) */
}
开发者ID:PivotalBigData,项目名称:incubator-hawq,代码行数:35,代码来源:hashapi_access.c

示例12: pg_digest

Datum
pg_digest(PG_FUNCTION_ARGS)
{
	bytea	   *arg;
	text	   *name;
	unsigned	len,
				hlen;
	PX_MD	   *md;
	bytea	   *res;

	name = PG_GETARG_TEXT_P(1);

	/* will give error if fails */
	md = find_provider(name, (PFN) px_find_digest, "Digest", 0);

	hlen = px_md_result_size(md);

	res = (text *) palloc(hlen + VARHDRSZ);
	SET_VARSIZE(res, hlen + VARHDRSZ);

	arg = PG_GETARG_BYTEA_P(0);
	len = VARSIZE(arg) - VARHDRSZ;

	px_md_update(md, (uint8 *) VARDATA(arg), len);
	px_md_finish(md, (uint8 *) VARDATA(res));
	px_md_free(md);

	PG_FREE_IF_COPY(arg, 0);
	PG_FREE_IF_COPY(name, 1);

	PG_RETURN_BYTEA_P(res);
}
开发者ID:adunstan,项目名称:pg-cvs-mirror,代码行数:32,代码来源:pgcrypto.c

示例13: brin_metapage_info

Datum
brin_metapage_info(PG_FUNCTION_ARGS)
{
    bytea	   *raw_page = PG_GETARG_BYTEA_P(0);
    Page		page;
    BrinMetaPageData *meta;
    TupleDesc	tupdesc;
    Datum		values[4];
    bool		nulls[4];
    HeapTuple	htup;

    page = verify_brin_page(raw_page, BRIN_PAGETYPE_META, "metapage");

    /* Build a tuple descriptor for our result type */
    if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
        elog(ERROR, "return type must be a row type");
    tupdesc = BlessTupleDesc(tupdesc);

    /* Extract values from the metapage */
    meta = (BrinMetaPageData *) PageGetContents(page);
    MemSet(nulls, 0, sizeof(nulls));
    values[0] = CStringGetTextDatum(psprintf("0x%08X", meta->brinMagic));
    values[1] = Int32GetDatum(meta->brinVersion);
    values[2] = Int32GetDatum(meta->pagesPerRange);
    values[3] = Int64GetDatum(meta->lastRevmapPage);

    htup = heap_form_tuple(tupdesc, values, nulls);

    PG_RETURN_DATUM(HeapTupleGetDatum(htup));
}
开发者ID:linwanggm,项目名称:postgres,代码行数:30,代码来源:brinfuncs.c

示例14: binary_encode

Datum
binary_encode(PG_FUNCTION_ARGS)
{
	bytea	   *data = PG_GETARG_BYTEA_P(0);
	Datum		name = PG_GETARG_DATUM(1);
	text	   *result;
	char	   *namebuf;
	int			datalen,
				resultlen,
				res;
	const struct pg_encoding *enc;

	datalen = VARSIZE(data) - VARHDRSZ;

	namebuf = TextDatumGetCString(name);

	enc = pg_find_encoding(namebuf);
	if (enc == NULL)
		ereport(ERROR,
				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
				 errmsg("unrecognized encoding: \"%s\"", namebuf)));

	resultlen = enc->encode_len(VARDATA(data), datalen);
	result = palloc(VARHDRSZ + resultlen);

	res = enc->encode(VARDATA(data), datalen, VARDATA(result));

	/* Make this FATAL 'cause we've trodden on memory ... */
	if (res > resultlen)
		elog(FATAL, "overflow - encode estimate too small");

	SET_VARSIZE(result, VARHDRSZ + res);

	PG_RETURN_TEXT_P(result);
}
开发者ID:PengJi,项目名称:gpdb-comments,代码行数:35,代码来源:encode.c

示例15: x509_get_serial_number

Datum x509_get_serial_number(PG_FUNCTION_ARGS) {
	bytea *raw;
	bytea *result;
	BIGNUM *bn;
	X509 *cert;

	// 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")));
	}

	bn = ASN1_INTEGER_to_BN(X509_get_serialNumber(cert), NULL);
	result = bn_to_bytea(bn);
	BN_free(bn);
	X509_free(cert);

	PG_RETURN_BYTEA_P(result);
}
开发者ID:beargiles,项目名称:pgopenssltypes,代码行数:26,代码来源:x509.c


注:本文中的PG_GETARG_BYTEA_P函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。