您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CStringGetDatum函数代码示例

51自学网 2021-06-01 20:06:38
  C++
这篇教程C++ CStringGetDatum函数代码示例写得很实用,希望能帮到您。

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

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

示例1: makeArrayTypeName

/* * makeArrayTypeName *	  - given a base type name, make an array type name for it * * the caller is responsible for pfreeing the result */char *makeArrayTypeName(const char *typeName, Oid typeNamespace){	char	   *arr = (char *) palloc(NAMEDATALEN);	int			namelen = strlen(typeName);	Relation	pg_type_desc;	int			i;	/*	 * The idea is to prepend underscores as needed until we make a name that	 * doesn't collide with anything...	 */	pg_type_desc = heap_open(TypeRelationId, AccessShareLock);	for (i = 1; i < NAMEDATALEN - 1; i++)	{		arr[i - 1] = '_';		if (i + namelen < NAMEDATALEN)			strcpy(arr + i, typeName);		else		{			memcpy(arr + i, typeName, NAMEDATALEN - i);			truncate_identifier(arr, NAMEDATALEN, false);		}		if (!SearchSysCacheExists2(TYPENAMENSP,								   CStringGetDatum(arr),								   ObjectIdGetDatum(typeNamespace)))			break;	}	heap_close(pg_type_desc, AccessShareLock);	if (i >= NAMEDATALEN - 1)		ereport(ERROR,				(errcode(ERRCODE_DUPLICATE_OBJECT),				 errmsg("could not form array type name for type /"%s/"",						typeName)));	return arr;}
开发者ID:machack666,项目名称:postgres,代码行数:46,


示例2: GetRoleTupleByName

/** GetRoleTupleByOid -- as above, but search by role OID*/static HeapTupleGetRoleTupleByName(const char * rolename){	HeapTuple tuple;	Relation relation;	SysScanDesc scan;	ScanKeyData key[1];	/*	* form a scan key	*/	ScanKeyInit(&key[0],				Anum_pg_authid_rolname,				BTEqualStrategyNumber, F_NAMEEQ,				CStringGetDatum(rolename));	/*	* Open pg_authid and fetch a tuple. Force heap scan if we haven't yet	* built the critical shared relcache entries (i.e., we're starting up	* without a shared relcache cache file).	*/	relation = heap_open(AuthIdRelationId, AccessShareLock);	scan = systable_beginscan(relation, AuthIdRolnameIndexId,							criticalSharedRelcachesBuilt,							SNAPSHOT,							1, key);	tuple = systable_getnext(scan);	/* Must copy tuple before releasing buffer */	if (HeapTupleIsValid(tuple))		tuple = heap_copytuple(tuple);	/* all done */	systable_endscan(scan);	heap_close(relation, AccessShareLock);	return tuple;}
开发者ID:tvondra,项目名称:connection_limits,代码行数:42,


示例3: enum_recv

/* Binary I/O support */Datumenum_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,


示例4: enum_in

Datumenum_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)));	/* check it's safe to use in SQL */	check_safe_enum_use(tup);	/*	 * 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:Tao-Ma,项目名称:postgres,代码行数:39,


示例5: current_schemas

Datumcurrent_schemas(PG_FUNCTION_ARGS){    List	   *search_path = fetch_search_path(PG_GETARG_BOOL(0));    ListCell   *l;    Datum	   *names;    int			i;    ArrayType  *array;    names = (Datum *) palloc(list_length(search_path) * sizeof(Datum));    i = 0;    foreach(l, search_path)    {        char	   *nspname;        nspname = get_namespace_name(lfirst_oid(l));        if (nspname)			/* watch out for deleted namespace */        {            names[i] = DirectFunctionCall1(namein, CStringGetDatum(nspname));            i++;        }    }
开发者ID:qiuyesuifeng,项目名称:gpdb,代码行数:22,


示例6: _String_coerceObject

Datum _String_coerceObject(Type self, jobject jstr){	char* tmp;	Datum ret;	if(jstr == 0)		return 0;	jstr = JNI_callObjectMethod(jstr, s_Object_toString);	if(JNI_exceptionCheck())		return 0;	tmp = String_createNTS(jstr);	JNI_deleteLocalRef(jstr);	ret = FunctionCall3(					&((String)self)->textInput,					CStringGetDatum(tmp),					ObjectIdGetDatum(((String)self) -> Type_extension.typeId /* elementType */ ),					Int32GetDatum(-1));	pfree(tmp);	return ret;}
开发者ID:DacKiller,项目名称:pljava,代码行数:22,


示例7: get_rewrite_oid_without_relid

/* * Find rule oid, given only a rule name but no rel OID. * * If there's more than one, it's an error.  If there aren't any, that's an * error, too.  In general, this should be avoided - it is provided to support * syntax that is compatible with pre-7.3 versions of PG, where rule names * were unique across the entire database. */Oidget_rewrite_oid_without_relid(const char *rulename, Oid *reloid){	Relation	RewriteRelation;	HeapScanDesc scanDesc;	ScanKeyData scanKeyData;	HeapTuple	htup;	Oid			ruleoid;	/* Search pg_rewrite for such a rule */	ScanKeyInit(&scanKeyData,				Anum_pg_rewrite_rulename,				BTEqualStrategyNumber, F_NAMEEQ,				CStringGetDatum(rulename));	RewriteRelation = heap_open(RewriteRelationId, AccessShareLock);	scanDesc = heap_beginscan(RewriteRelation, SnapshotNow, 1, &scanKeyData);	htup = heap_getnext(scanDesc, ForwardScanDirection);	if (!HeapTupleIsValid(htup))		ereport(ERROR,				(errcode(ERRCODE_UNDEFINED_OBJECT),				 errmsg("rule /"%s/" does not exist", rulename)));	ruleoid = HeapTupleGetOid(htup);	if (reloid != NULL)		*reloid = ((Form_pg_rewrite) GETSTRUCT(htup))->ev_class;	if (HeapTupleIsValid(htup = heap_getnext(scanDesc, ForwardScanDirection)))		ereport(ERROR,				(errcode(ERRCODE_DUPLICATE_OBJECT),				 errmsg("there are multiple rules named /"%s/"", rulename),				 errhint("Specify a relation name as well as a rule name.")));	heap_endscan(scanDesc);	heap_close(RewriteRelation, AccessShareLock);	return ruleoid;}
开发者ID:Joe-xXx,项目名称:postgres-old-soon-decommissioned,代码行数:47,


示例8: DropProceduralLanguage

/* --------------------------------------------------------------------- * DROP PROCEDURAL LANGUAGE * --------------------------------------------------------------------- */voidDropProceduralLanguage(DropPLangStmt *stmt){	char	   *languageName;	HeapTuple	langTup;	ObjectAddress object;	/*	 * Check permission	 */	if (!superuser())		ereport(ERROR,				(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),				 errmsg("must be superuser to drop procedural language")));	/*	 * Translate the language name, check that the language exists	 */	languageName = case_translate_language_name(stmt->plname);	langTup = SearchSysCache(LANGNAME,							 CStringGetDatum(languageName),							 0, 0, 0);	if (!HeapTupleIsValid(langTup))		ereport(ERROR,				(errcode(ERRCODE_UNDEFINED_OBJECT),				 errmsg("language /"%s/" does not exist", languageName)));	object.classId = LanguageRelationId;	object.objectId = HeapTupleGetOid(langTup);	object.objectSubId = 0;	ReleaseSysCache(langTup);	/*	 * Do the deletion	 */	performDeletion(&object, stmt->behavior);}
开发者ID:CraigBryan,项目名称:PostgresqlFun,代码行数:43,


示例9: GetResourceTypeByName

/* MPP-6923:  * GetResourceTypeByName: find the named resource in pg_resourcetype * * Input: name of resource * Output: resourcetypid (int2), oid of entry * * updates output and returns true if named resource found **/static boolGetResourceTypeByName(char *pNameIn, int *pTypeOut, Oid *pOidOut){	Relation	pg_resourcetype;	ScanKeyData scankey;	SysScanDesc sscan;	HeapTuple	tuple;	bool		bStat = false;	/*	 * SELECT * FROM pg_resourcetype WHERE resname = :1 FOR UPDATE	 *	 * XXX XXX: maybe should be share lock, ie remove FOR UPDATE ?	 * XXX XXX: only one	 */	pg_resourcetype = heap_open(ResourceTypeRelationId, RowExclusiveLock);	ScanKeyInit(&scankey,				Anum_pg_resourcetype_resname,				BTEqualStrategyNumber, F_NAMEEQ,				CStringGetDatum(pNameIn));	sscan = systable_beginscan(pg_resourcetype, ResourceTypeResnameIndexId, true,							   SnapshotNow, 1, &scankey);	tuple = systable_getnext(sscan);	if (HeapTupleIsValid(tuple))	{		*pOidOut = HeapTupleGetOid(tuple);		*pTypeOut =				((Form_pg_resourcetype) GETSTRUCT(tuple))->restypid;		bStat = true;	}	systable_endscan(sscan);	heap_close(pg_resourcetype, RowExclusiveLock);	return (bStat);} /* end GetResourceTypeByName */
开发者ID:HaozhouWang,项目名称:gpdb,代码行数:46,


示例10: dbms_assert_schema_name

Datumdbms_assert_schema_name(PG_FUNCTION_ARGS){	Oid			namespaceId;	AclResult	aclresult;	text *sname;	char *nspname;	List	*names;	if (PG_ARGISNULL(0))		INVALID_SCHEMA_NAME_EXCEPTION();	sname = PG_GETARG_TEXT_P(0);	if (EMPTY_STR(sname))		INVALID_SCHEMA_NAME_EXCEPTION();	nspname = text_to_cstring(sname);#ifdef GP_VERSION_NUM	names = stringToQualifiedNameList(nspname, "dbms");#else	names = stringToQualifiedNameList(nspname);#endif	if (list_length(names) != 1)		INVALID_SCHEMA_NAME_EXCEPTION();	namespaceId = GetSysCacheOid(NAMESPACENAME,							CStringGetDatum(strVal(linitial(names))),							0, 0, 0);	if (!OidIsValid(namespaceId))		INVALID_SCHEMA_NAME_EXCEPTION();	aclresult = pg_namespace_aclcheck(namespaceId, GetUserId(), ACL_USAGE);	if (aclresult != ACLCHECK_OK)		INVALID_SCHEMA_NAME_EXCEPTION();	PG_RETURN_TEXT_P(sname);}
开发者ID:AnLingm,项目名称:gpdb,代码行数:37,


示例11: LookupExtProtocolOid

/* * Same as LookupExtProtocolFunction but returns the actual * protocol Oid. */OidLookupExtProtocolOid(const char *prot_name, bool missing_ok){	Oid			protOid = InvalidOid;	Relation	rel;	ScanKeyData skey;	SysScanDesc scan;	HeapTuple	tup;	rel = heap_open(ExtprotocolRelationId, AccessShareLock);	/*	 * Check the pg_extprotocol relation to be certain the protocol	 * is there.	 */	ScanKeyInit(&skey,				Anum_pg_extprotocol_ptcname,				BTEqualStrategyNumber, F_NAMEEQ,				CStringGetDatum(prot_name));	scan = systable_beginscan(rel, ExtprotocolPtcnameIndexId, true,							  SnapshotNow, 1, &skey);	tup = systable_getnext(scan);	if (HeapTupleIsValid(tup))		protOid = HeapTupleGetOid(tup);	else if (!missing_ok)		ereport(ERROR,				(errcode(ERRCODE_UNDEFINED_OBJECT),				 errmsg("protocol /"%s/" does not exist",						prot_name)));	systable_endscan(scan);	heap_close(rel, AccessShareLock);	return protOid;}
开发者ID:PengJi,项目名称:gpdb-comments,代码行数:41,


示例12: getExtensionLoadPath

static void getExtensionLoadPath(){	MemoryContext curr;	Datum dtm;	bool isnull;	StringInfoData buf;	/*	 * Check whether sqlj.loadpath exists before querying it. I would more	 * happily just PG_CATCH() the error and compare to ERRCODE_UNDEFINED_TABLE	 * but what's required to make that work right is "not terribly well	 * documented, but the exception-block handling in plpgsql provides a	 * working model" and that code is a lot more fiddly than you would guess.	 */	if ( InvalidOid == get_relname_relid(LOADPATH_TBL_NAME,		GetSysCacheOid1(NAMESPACENAME, CStringGetDatum("sqlj"))) )		return;	SPI_connect();	curr = CurrentMemoryContext;	initStringInfo(&buf);	appendStringInfo(&buf, "SELECT path, exnihilo FROM sqlj.%s",		quote_identifier(LOADPATH_TBL_NAME));	if ( SPI_OK_SELECT == SPI_execute(buf.data,	true, 1) && 1 == SPI_processed )	{		MemoryContextSwitchTo(TopMemoryContext);		pljavaLoadPath = (char const *)SPI_getvalue(			SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1);		MemoryContextSwitchTo(curr);		dtm = SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 2,			&isnull);		if ( isnull )			elog(ERROR, "defect in CREATE EXTENSION script");		extensionExNihilo = DatumGetBool(dtm);	}	SPI_finish();}
开发者ID:greenplum-db,项目名称:pljava,代码行数:37,


示例13: AlterLanguageOwner

/* * Change language owner */voidAlterLanguageOwner(const char *name, Oid newOwnerId){	HeapTuple	tup;	Relation	rel;	/* Translate name for consistency with CREATE */	name = case_translate_language_name(name);	rel = heap_open(LanguageRelationId, RowExclusiveLock);	tup = SearchSysCache1(LANGNAME, CStringGetDatum(name));	if (!HeapTupleIsValid(tup))		ereport(ERROR,				(errcode(ERRCODE_UNDEFINED_OBJECT),				 errmsg("language /"%s/" does not exist", name)));	AlterLanguageOwner_internal(tup, rel, newOwnerId);	ReleaseSysCache(tup);	heap_close(rel, RowExclusiveLock);}
开发者ID:cbbrowne,项目名称:postgres,代码行数:27,


示例14: ssl_client_serial

Datumssl_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,


示例15: plperl_modify_tuple

static HeapTupleplperl_modify_tuple(HV *hvTD, TriggerData *tdata, HeapTuple otup){	SV		  **svp;	HV		   *hvNew;	HeapTuple	rtup;	SV		   *val;	char	   *key;	I32			klen;	int			slotsused;	int		   *modattrs;	Datum	   *modvalues;	char	   *modnulls;	TupleDesc	tupdesc;	tupdesc = tdata->tg_relation->rd_att;	svp = hv_fetch(hvTD, "new", 3, FALSE);	if (!svp)		ereport(ERROR,				(errcode(ERRCODE_UNDEFINED_COLUMN),				 errmsg("$_TD->{new} does not exist")));	if (!SvOK(*svp) || SvTYPE(*svp) != SVt_RV || SvTYPE(SvRV(*svp)) != SVt_PVHV)		ereport(ERROR,				(errcode(ERRCODE_DATATYPE_MISMATCH),				 errmsg("$_TD->{new} is not a hash reference")));	hvNew = (HV *) SvRV(*svp);	modattrs = palloc(tupdesc->natts * sizeof(int));	modvalues = palloc(tupdesc->natts * sizeof(Datum));	modnulls = palloc(tupdesc->natts * sizeof(char));	slotsused = 0;	hv_iterinit(hvNew);	while ((val = hv_iternextsv(hvNew, &key, &klen)))	{		int			attn = SPI_fnumber(tupdesc, key);		if (attn <= 0 || tupdesc->attrs[attn - 1]->attisdropped)			ereport(ERROR,					(errcode(ERRCODE_UNDEFINED_COLUMN),					 errmsg("Perl hash contains nonexistent column /"%s/"",							key)));		if (SvOK(val) && SvTYPE(val) != SVt_NULL)		{			Oid			typinput;			Oid			typioparam;			FmgrInfo	finfo;			/* XXX would be better to cache these lookups */			getTypeInputInfo(tupdesc->attrs[attn - 1]->atttypid,							 &typinput, &typioparam);			fmgr_info(typinput, &finfo);			modvalues[slotsused] = FunctionCall3(&finfo,										   CStringGetDatum(SvPV(val, PL_na)),												 ObjectIdGetDatum(typioparam),						 Int32GetDatum(tupdesc->attrs[attn - 1]->atttypmod));			modnulls[slotsused] = ' ';		}		else		{			modvalues[slotsused] = (Datum) 0;			modnulls[slotsused] = 'n';		}		modattrs[slotsused] = attn;		slotsused++;	}	hv_iterinit(hvNew);	rtup = SPI_modifytuple(tdata->tg_relation, otup, slotsused,						   modattrs, modvalues, modnulls);	pfree(modattrs);	pfree(modvalues);	pfree(modnulls);	if (rtup == NULL)		elog(ERROR, "SPI_modifytuple failed: %s",			 SPI_result_code_string(SPI_result));	return rtup;}
开发者ID:shubham2094,项目名称:postgresql_8.1,代码行数:83,


示例16: AggregateCreate

//.........这里部分代码省略.........	}	Assert(OidIsValid(finaltype));	/*	 * If finaltype (i.e. aggregate return type) is polymorphic, basetype	 * must be polymorphic also, else parser will fail to deduce result	 * type.  (Note: given the previous test on transtype and basetype,	 * this cannot happen, unless someone has snuck a finalfn definition	 * into the catalogs that itself violates the rule against polymorphic	 * result with no polymorphic input.)	 */	if ((finaltype == ANYARRAYOID || finaltype == ANYELEMENTOID) &&		!(aggBaseType == ANYARRAYOID || aggBaseType == ANYELEMENTOID))		ereport(ERROR,				(errcode(ERRCODE_DATATYPE_MISMATCH),				 errmsg("cannot determine result data type"),			   errdetail("An aggregate returning /"anyarray/" or /"anyelement/" "						 "must have one of them as its base type.")));	/*	 * Everything looks okay.  Try to create the pg_proc entry for the	 * aggregate.  (This could fail if there's already a conflicting	 * entry.)	 */	MemSet(fnArgs, 0, FUNC_MAX_ARGS * sizeof(Oid));	fnArgs[0] = aggBaseType;	procOid = ProcedureCreate(aggName,							  aggNamespace,							  false,	/* no replacement */							  false,	/* doesn't return a set */							  finaltype,		/* returnType */							  INTERNALlanguageId,		/* languageObjectId */							  0,							  "aggregate_dummy",		/* placeholder proc */							  "-",		/* probin */							  true,		/* isAgg */							  false,	/* security invoker (currently not										 * definable for agg) */							  false,	/* isStrict (not needed for agg) */							  PROVOLATILE_IMMUTABLE,	/* volatility (not														 * needed for agg) */							  1,	/* parameterCount */							  fnArgs);	/* parameterTypes */	/*	 * Okay to create the pg_aggregate entry.	 */	/* initialize nulls and values */	for (i = 0; i < Natts_pg_aggregate; i++)	{		nulls[i] = ' ';		values[i] = (Datum) NULL;	}	values[Anum_pg_aggregate_aggfnoid - 1] = ObjectIdGetDatum(procOid);	values[Anum_pg_aggregate_aggtransfn - 1] = ObjectIdGetDatum(transfn);	values[Anum_pg_aggregate_aggfinalfn - 1] = ObjectIdGetDatum(finalfn);	values[Anum_pg_aggregate_aggtranstype - 1] = ObjectIdGetDatum(aggTransType);	if (agginitval)		values[Anum_pg_aggregate_agginitval - 1] =			DirectFunctionCall1(textin, CStringGetDatum(agginitval));	else		nulls[Anum_pg_aggregate_agginitval - 1] = 'n';	aggdesc = heap_openr(AggregateRelationName, RowExclusiveLock);	tupDesc = aggdesc->rd_att;	tup = heap_formtuple(tupDesc, values, nulls);	simple_heap_insert(aggdesc, tup);	CatalogUpdateIndexes(aggdesc, tup);	heap_close(aggdesc, RowExclusiveLock);	/*	 * Create dependencies for the aggregate (above and beyond those	 * already made by ProcedureCreate).  Note: we don't need an explicit	 * dependency on aggTransType since we depend on it indirectly through	 * transfn.	 */	myself.classId = RelOid_pg_proc;	myself.objectId = procOid;	myself.objectSubId = 0;	/* Depends on transition function */	referenced.classId = RelOid_pg_proc;	referenced.objectId = transfn;	referenced.objectSubId = 0;	recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);	/* Depends on final function, if any */	if (OidIsValid(finalfn))	{		referenced.classId = RelOid_pg_proc;		referenced.objectId = finalfn;		referenced.objectSubId = 0;		recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);	}}
开发者ID:sunyangkobe,项目名称:cscd43,代码行数:101,


示例17: regtypein

/* * regtypein		- converts "typename" to type OID * * We also accept a numeric OID, for symmetry with the output routine. * * '-' signifies unknown (OID 0).  In all other cases, the input must * match an existing pg_type entry. * * In bootstrap mode the name must just equal some existing name in pg_type. * In normal mode the type name can be specified using the full type syntax * recognized by the parser; for example, DOUBLE PRECISION and INTEGER[] will * work and be translated to the correct type names.  (We ignore any typmod * info generated by the parser, however.) */Datumregtypein(PG_FUNCTION_ARGS){	char	   *typ_name_or_oid = PG_GETARG_CSTRING(0);	Oid			result = InvalidOid;	int32		typmod;	/* '-' ? */	if (strcmp(typ_name_or_oid, "-") == 0)		PG_RETURN_OID(InvalidOid);	/* Numeric OID? */	if (typ_name_or_oid[0] >= '0' &&		typ_name_or_oid[0] <= '9' &&		strspn(typ_name_or_oid, "0123456789") == strlen(typ_name_or_oid))	{		result = DatumGetObjectId(DirectFunctionCall1(oidin,										  CStringGetDatum(typ_name_or_oid)));		PG_RETURN_OID(result);	}	/* Else it's a type name, possibly schema-qualified or decorated */	/*	 * In bootstrap mode we assume the given name is not schema-qualified, and	 * just search pg_type for a match.  This is needed for initializing other	 * system catalogs (pg_namespace may not exist yet, and certainly there	 * are no schemas other than pg_catalog).	 */	if (IsBootstrapProcessingMode())	{		int			matches = 0;		result = 				caql_getoid_plus(						NULL,						&matches,						NULL,						cql("SELECT oid FROM pg_type "							" WHERE typname = :1 ",							CStringGetDatum(typ_name_or_oid)));		if (0 == matches)		{			ereport(ERROR,					(errcode(ERRCODE_UNDEFINED_OBJECT),					 errmsg("type /"%s/" does not exist", typ_name_or_oid)));		}		/* We assume there can be only one match */		PG_RETURN_OID(result);	}	/*	 * Normal case: invoke the full parser to deal with special cases such as	 * array syntax.	 */	parseTypeString(typ_name_or_oid, &result, &typmod);	PG_RETURN_OID(result);}
开发者ID:BALDELab,项目名称:incubator-hawq,代码行数:75,


示例18: regclassin

/* * regclassin		- converts "classname" to class OID * * We also accept a numeric OID, for symmetry with the output routine. * * '-' signifies unknown (OID 0).  In all other cases, the input must * match an existing pg_class entry. */Datumregclassin(PG_FUNCTION_ARGS){	char	   *class_name_or_oid = PG_GETARG_CSTRING(0);	Oid			result = InvalidOid;	List	   *names;	/* '-' ? */	if (strcmp(class_name_or_oid, "-") == 0)		PG_RETURN_OID(InvalidOid);	/* Numeric OID? */	if (class_name_or_oid[0] >= '0' &&		class_name_or_oid[0] <= '9' &&		strspn(class_name_or_oid, "0123456789") == strlen(class_name_or_oid))	{		result = DatumGetObjectId(DirectFunctionCall1(oidin,										CStringGetDatum(class_name_or_oid)));		PG_RETURN_OID(result);	}	/* Else it's a name, possibly schema-qualified */	/*	 * In bootstrap mode we assume the given name is not schema-qualified, and	 * just search pg_class for a match.  This is needed for initializing	 * other system catalogs (pg_namespace may not exist yet, and certainly	 * there are no schemas other than pg_catalog).	 */	if (IsBootstrapProcessingMode())	{		int			matches = 0;		result = 				caql_getoid_plus(						NULL,						&matches,						NULL,						cql("SELECT oid FROM pg_class "							" WHERE relname = :1 ",							CStringGetDatum(class_name_or_oid)));		if (0 == matches)		{			ereport(ERROR,					(errcode(ERRCODE_UNDEFINED_TABLE),			   errmsg("relation /"%s/" does not exist", class_name_or_oid)));		}		/* We assume there can be only one match */		PG_RETURN_OID(result);	}	/*	 * Normal case: parse the name into components and see if it matches any	 * pg_class entries in the current search path.	 */	names = stringToQualifiedNameList(class_name_or_oid, "regclassin");	result = RangeVarGetRelid(makeRangeVarFromNameList(names), false, true /*allowHcatalog*/);	PG_RETURN_OID(result);}
开发者ID:BALDELab,项目名称:incubator-hawq,代码行数:71,


示例19: regprocin

/* * regprocin		- converts "proname" to proc OID * * We also accept a numeric OID, for symmetry with the output routine. * * '-' signifies unknown (OID 0).  In all other cases, the input must * match an existing pg_proc entry. */Datumregprocin(PG_FUNCTION_ARGS){	char	   *pro_name_or_oid = PG_GETARG_CSTRING(0);	RegProcedure result = InvalidOid;	List	   *names;	FuncCandidateList clist;	/* '-' ? */	if (strcmp(pro_name_or_oid, "-") == 0)		PG_RETURN_OID(InvalidOid);	/* Numeric OID? */	if (pro_name_or_oid[0] >= '0' &&		pro_name_or_oid[0] <= '9' &&		strspn(pro_name_or_oid, "0123456789") == strlen(pro_name_or_oid))	{		result = DatumGetObjectId(DirectFunctionCall1(oidin,										  CStringGetDatum(pro_name_or_oid)));		PG_RETURN_OID(result);	}	/* Else it's a name, possibly schema-qualified */	/*	 * In bootstrap mode we assume the given name is not schema-qualified, and	 * just search pg_proc for a unique match.	This is needed for	 * initializing other system catalogs (pg_namespace may not exist yet, and	 * certainly there are no schemas other than pg_catalog).	 */	if (IsBootstrapProcessingMode())	{		int			matches = 0;		result = 				(RegProcedure) caql_getoid_plus(						NULL,						&matches,						NULL,						cql("SELECT oid FROM pg_proc "							" WHERE proname = :1 ",							CStringGetDatum(pro_name_or_oid)));		if (matches == 0)			ereport(ERROR,					(errcode(ERRCODE_UNDEFINED_FUNCTION),				 errmsg("function /"%s/" does not exist", pro_name_or_oid)));		else if (matches > 1)			ereport(ERROR,					(errcode(ERRCODE_AMBIGUOUS_FUNCTION),					 errmsg("more than one function named /"%s/"",							pro_name_or_oid)));		PG_RETURN_OID(result);	}	/*	 * Normal case: parse the name into components and see if it matches any	 * pg_proc entries in the current search path.	 */	names = stringToQualifiedNameList(pro_name_or_oid, "regprocin");	clist = FuncnameGetCandidates(names, -1);	if (clist == NULL)		ereport(ERROR,				(errcode(ERRCODE_UNDEFINED_FUNCTION),				 errmsg("function /"%s/" does not exist", pro_name_or_oid)));	else if (clist->next != NULL)		ereport(ERROR,				(errcode(ERRCODE_AMBIGUOUS_FUNCTION),				 errmsg("more than one function named /"%s/"",						pro_name_or_oid)));	result = clist->oid;	PG_RETURN_OID(result);}
开发者ID:BALDELab,项目名称:incubator-hawq,代码行数:86,


示例20: timetravel

Datum							/* have to return HeapTuple to Executor */timetravel(PG_FUNCTION_ARGS){	TriggerData *trigdata = (TriggerData *) fcinfo->context;	Trigger    *trigger;		/* to get trigger name */	int			argc;	char	  **args;			/* arguments */	int			attnum[MaxAttrNum];		/* fnumbers of start/stop columns */	Datum		oldtimeon,				oldtimeoff;	Datum		newtimeon,				newtimeoff,				newuser,				nulltext;	Datum	   *cvals;			/* column values */	char	   *cnulls;			/* column nulls */	char	   *relname;		/* triggered relation name */	Relation	rel;			/* triggered relation */	HeapTuple	trigtuple;	HeapTuple	newtuple = NULL;	HeapTuple	rettuple;	TupleDesc	tupdesc;		/* tuple description */	int			natts;			/* # of attributes */	EPlan	   *plan;			/* prepared plan */	char		ident[2 * NAMEDATALEN];	bool		isnull;			/* to know is some column NULL or not */	bool		isinsert = false;	int			ret;	int			i;	/*	 * Some checks first...	 */	/* Called by trigger manager ? */	if (!CALLED_AS_TRIGGER(fcinfo))		elog(ERROR, "timetravel: not fired by trigger manager");	/* Should be called for ROW trigger */	if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event))		elog(ERROR, "timetravel: can't process STATEMENT events");	/* Should be called BEFORE */	if (TRIGGER_FIRED_AFTER(trigdata->tg_event))		elog(ERROR, "timetravel: must be fired before event");	/* INSERT ? */	if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event))		isinsert = true;	if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))		newtuple = trigdata->tg_newtuple;	trigtuple = trigdata->tg_trigtuple;	rel = trigdata->tg_relation;	relname = SPI_getrelname(rel);	/* check if TT is OFF for this relation */	if (0 == findTTStatus(relname))	{		/* OFF - nothing to do */		pfree(relname);		return PointerGetDatum((newtuple != NULL) ? newtuple : trigtuple);	}	trigger = trigdata->tg_trigger;	argc = trigger->tgnargs;	if (argc != MinAttrNum && argc != MaxAttrNum)		elog(ERROR, "timetravel (%s): invalid (!= %d or %d) number of arguments %d",			 relname, MinAttrNum, MaxAttrNum, trigger->tgnargs);	args = trigger->tgargs;	tupdesc = rel->rd_att;	natts = tupdesc->natts;	for (i = 0; i < MinAttrNum; i++)	{		attnum[i] = SPI_fnumber(tupdesc, args[i]);		if (attnum[i] < 0)			elog(ERROR, "timetravel (%s): there is no attribute %s", relname, args[i]);		if (SPI_gettypeid(tupdesc, attnum[i]) != ABSTIMEOID)			elog(ERROR, "timetravel (%s): attribute %s must be of abstime type",				 relname, args[i]);	}	for (; i < argc; i++)	{		attnum[i] = SPI_fnumber(tupdesc, args[i]);		if (attnum[i] < 0)			elog(ERROR, "timetravel (%s): there is no attribute %s", relname, args[i]);		if (SPI_gettypeid(tupdesc, attnum[i]) != TEXTOID)			elog(ERROR, "timetravel (%s): attribute %s must be of text type",				 relname, args[i]);	}	/* create fields containing name */	newuser = DirectFunctionCall1(textin, CStringGetDatum(GetUserNameFromId(GetUserId())));	nulltext = (Datum) NULL;//.........这里部分代码省略.........
开发者ID:berkeley-cs186,项目名称:course-fa07,代码行数:101,


示例21: plperl_func_handler

//.........这里部分代码省略.........	if (prodesc->fn_retisset)	{		/*		 * If the Perl function returned an arrayref, we pretend that it		 * called return_next() for each element of the array, to handle old		 * SRFs that didn't know about return_next(). Any other sort of return		 * value is an error.		 */		if (SvTYPE(perlret) == SVt_RV &&			SvTYPE(SvRV(perlret)) == SVt_PVAV)		{			int			i = 0;			SV		  **svp = 0;			AV		   *rav = (AV *) SvRV(perlret);			while ((svp = av_fetch(rav, i, FALSE)) != NULL)			{				plperl_return_next(*svp);				i++;			}		}		else if (SvTYPE(perlret) != SVt_NULL)		{			ereport(ERROR,					(errcode(ERRCODE_DATATYPE_MISMATCH),					 errmsg("set-returning Perl function must return "							"reference to array or use return_next")));		}		rsi->returnMode = SFRM_Materialize;		if (plperl_current_tuple_store)		{			rsi->setResult = plperl_current_tuple_store;			rsi->setDesc = plperl_current_tuple_desc;		}		retval = (Datum) 0;	}	else if (SvTYPE(perlret) == SVt_NULL)	{		/* Return NULL if Perl code returned undef */		if (rsi && IsA(rsi, ReturnSetInfo))			rsi->isDone = ExprEndResult;		fcinfo->isnull = true;		retval = (Datum) 0;	}	else if (prodesc->fn_retistuple)	{		/* Return a perl hash converted to a Datum */		TupleDesc	td;		AttInMetadata *attinmeta;		HeapTuple	tup;		if (!SvOK(perlret) || SvTYPE(perlret) != SVt_RV ||			SvTYPE(SvRV(perlret)) != SVt_PVHV)		{			ereport(ERROR,					(errcode(ERRCODE_DATATYPE_MISMATCH),					 errmsg("composite-returning Perl function "							"must return reference to hash")));		}		/* XXX should cache the attinmeta data instead of recomputing */		if (get_call_result_type(fcinfo, NULL, &td) != TYPEFUNC_COMPOSITE)		{			ereport(ERROR,					(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),					 errmsg("function returning record called in context "							"that cannot accept type record")));		}		attinmeta = TupleDescGetAttInMetadata(td);		tup = plperl_build_tuple_result((HV *) SvRV(perlret), attinmeta);		retval = HeapTupleGetDatum(tup);	}	else	{		/* Return a perl string converted to a Datum */		char	   *val;		if (prodesc->fn_retisarray && SvROK(perlret) &&			SvTYPE(SvRV(perlret)) == SVt_PVAV)		{			array_ret = plperl_convert_to_pg_array(perlret);			SvREFCNT_dec(perlret);			perlret = array_ret;		}		val = SvPV(perlret, PL_na);		retval = FunctionCall3(&prodesc->result_in_func,							   CStringGetDatum(val),							   ObjectIdGetDatum(prodesc->result_typioparam),							   Int32GetDatum(-1));	}	if (array_ret == NULL)		SvREFCNT_dec(perlret);	return retval;}
开发者ID:shubham2094,项目名称:postgresql_8.1,代码行数:101,


示例22: RemoveRewriteRule

/* * RemoveRewriteRule * * Delete a rule given its name. */voidRemoveRewriteRule(Oid owningRel, const char *ruleName, DropBehavior behavior,				  bool missing_ok){	HeapTuple	tuple;	Oid			eventRelationOid;	ObjectAddress object;	cqContext	*pcqCtx;	/*	 * Find the tuple for the target rule.	 */	pcqCtx = caql_beginscan(			NULL,			cql("SELECT * FROM pg_rewrite "				" WHERE ev_class = :1 "				" AND rulename = :2 "				" FOR UPDATE ",				ObjectIdGetDatum(owningRel),				CStringGetDatum((char *) ruleName)));	tuple = caql_getnext(pcqCtx);	/*	 * complain if no rule with such name exists	 */	if (!HeapTupleIsValid(tuple))	{		if (!missing_ok)			ereport(ERROR,					(errcode(ERRCODE_UNDEFINED_OBJECT),					 errmsg("rule /"%s/" for relation /"%s/" does not exist",							ruleName, get_rel_name(owningRel))));		else			ereport(NOTICE,					(errmsg("rule /"%s/" for relation /"%s/" does not exist, skipping",							ruleName, get_rel_name(owningRel))));		caql_endscan(pcqCtx);		return;	}	/*	 * Verify user has appropriate permissions.	 */	eventRelationOid = ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class;	Assert(eventRelationOid == owningRel);	if (!pg_class_ownercheck(eventRelationOid, GetUserId()))		aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CLASS,					   get_rel_name(eventRelationOid));	/*	 * Do the deletion	 */	object.classId = RewriteRelationId;	object.objectId = HeapTupleGetOid(tuple);	object.objectSubId = 0;	caql_endscan(pcqCtx);	performDeletion(&object, behavior);}
开发者ID:AnLingm,项目名称:gpdb,代码行数:67,


示例23: CreateConversionCommand

/* * CREATE CONVERSION */ObjectAddressCreateConversionCommand(CreateConversionStmt *stmt){	Oid			namespaceId;	char	   *conversion_name;	AclResult	aclresult;	int			from_encoding;	int			to_encoding;	Oid			funcoid;	const char *from_encoding_name = stmt->for_encoding_name;	const char *to_encoding_name = stmt->to_encoding_name;	List	   *func_name = stmt->func_name;	static const Oid funcargs[] = {INT4OID, INT4OID, CSTRINGOID, INTERNALOID, INT4OID};	char		result[1];	/* Convert list of names to a name and namespace */	namespaceId = QualifiedNameGetCreationNamespace(stmt->conversion_name,													&conversion_name);	/* Check we have creation rights in target namespace */	aclresult = pg_namespace_aclcheck(namespaceId, GetUserId(), ACL_CREATE);	if (aclresult != ACLCHECK_OK)		aclcheck_error(aclresult, ACL_KIND_NAMESPACE,					   get_namespace_name(namespaceId));	/* Check the encoding names */	from_encoding = pg_char_to_encoding(from_encoding_name);	if (from_encoding < 0)		ereport(ERROR,				(errcode(ERRCODE_UNDEFINED_OBJECT),				 errmsg("source encoding /"%s/" does not exist",						from_encoding_name)));	to_encoding = pg_char_to_encoding(to_encoding_name);	if (to_encoding < 0)		ereport(ERROR,				(errcode(ERRCODE_UNDEFINED_OBJECT),				 errmsg("destination encoding /"%s/" does not exist",						to_encoding_name)));	/*	 * Check the existence of the conversion function. Function name could be	 * a qualified name.	 */	funcoid = LookupFuncName(func_name, sizeof(funcargs) / sizeof(Oid),							 funcargs, false);	/* Check it returns VOID, else it's probably the wrong function */	if (get_func_rettype(funcoid) != VOIDOID)		ereport(ERROR,				(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),				 errmsg("encoding conversion function %s must return type %s",						NameListToString(func_name), "void")));	/* Check we have EXECUTE rights for the function */	aclresult = pg_proc_aclcheck(funcoid, GetUserId(), ACL_EXECUTE);	if (aclresult != ACLCHECK_OK)		aclcheck_error(aclresult, ACL_KIND_PROC,					   NameListToString(func_name));	/*	 * Check that the conversion function is suitable for the requested source	 * and target encodings. We do that by calling the function with an empty	 * string; the conversion function should throw an error if it can't	 * perform the requested conversion.	 */	OidFunctionCall5(funcoid,					 Int32GetDatum(from_encoding),					 Int32GetDatum(to_encoding),					 CStringGetDatum(""),					 CStringGetDatum(result),					 Int32GetDatum(0));	/*	 * All seem ok, go ahead (possible failure would be a duplicate conversion	 * name)	 */	return ConversionCreate(conversion_name, namespaceId, GetUserId(),							from_encoding, to_encoding, funcoid, stmt->def);}
开发者ID:0x0FFF,项目名称:postgres,代码行数:83,


示例24: pg_stat_get_activity

//.........这里部分代码省略.........				values[6] = TimestampTzGetDatum(beentry->st_xact_start_timestamp);			else				nulls[6] = true;			if (beentry->st_activity_start_timestamp != 0)				values[7] = TimestampTzGetDatum(beentry->st_activity_start_timestamp);			else				nulls[7] = true;			if (beentry->st_proc_start_timestamp != 0)				values[8] = TimestampTzGetDatum(beentry->st_proc_start_timestamp);			else				nulls[8] = true;			/* A zeroed client addr means we don't know */			memset(&zero_clientaddr, 0, sizeof(zero_clientaddr));			if (memcmp(&(beentry->st_clientaddr), &zero_clientaddr,					   sizeof(zero_clientaddr) == 0))			{				nulls[9] = true;				nulls[10] = true;			}			else			{				if (beentry->st_clientaddr.addr.ss_family == AF_INET#ifdef HAVE_IPV6					|| beentry->st_clientaddr.addr.ss_family == AF_INET6#endif					)				{					char		remote_host[NI_MAXHOST];					char		remote_port[NI_MAXSERV];					int			ret;					remote_host[0] = '/0';					remote_port[0] = '/0';					ret = pg_getnameinfo_all(&beentry->st_clientaddr.addr,											 beentry->st_clientaddr.salen,											 remote_host, sizeof(remote_host),											 remote_port, sizeof(remote_port),											 NI_NUMERICHOST | NI_NUMERICSERV);					if (ret)					{						nulls[9] = true;						nulls[10] = true;					}					else					{						clean_ipv6_addr(beentry->st_clientaddr.addr.ss_family, remote_host);						values[9] = DirectFunctionCall1(inet_in,											   CStringGetDatum(remote_host));						values[10] = Int32GetDatum(atoi(remote_port));					}				}				else if (beentry->st_clientaddr.addr.ss_family == AF_UNIX)				{					/*					 * Unix sockets always reports NULL for host and -1 for					 * port, so it's possible to tell the difference to					 * connections we have no permissions to view, or with					 * errors.					 */					nulls[9] = true;					values[10] = DatumGetInt32(-1);				}				else				{					/* Unknown address type, should never happen */					nulls[9] = true;					nulls[10] = true;				}			}			values[12] = BoolGetDatum(beentry->st_waiting_resource);		}		else		{			/* No permissions to view data about this session */			values[4] = CStringGetTextDatum("<insufficient privilege>");			nulls[5] = true;			nulls[6] = true;			nulls[7] = true;			nulls[8] = true;			nulls[9] = true;			nulls[10] = true;			nulls[12] = true;		}				values[11] = Int32GetDatum(beentry->st_session_id);  /* GPDB */		tuple = heap_form_tuple(funcctx->tuple_desc, values, nulls);		SRF_RETURN_NEXT(funcctx, HeapTupleGetDatum(tuple));	}	else	{		/* nothing left */		SRF_RETURN_DONE(funcctx);	}}
开发者ID:BALDELab,项目名称:incubator-hawq,代码行数:101,


示例25: regclassin

/* * regclassin		- converts "classname" to class OID * * We also accept a numeric OID, for symmetry with the output routine. * * '-' signifies unknown (OID 0).  In all other cases, the input must * match an existing pg_class entry. */Datumregclassin(PG_FUNCTION_ARGS){	char	   *class_name_or_oid = PG_GETARG_CSTRING(0);	Oid			result = InvalidOid;	List	   *names;	/* '-' ? */	if (strcmp(class_name_or_oid, "-") == 0)		PG_RETURN_OID(InvalidOid);	/* Numeric OID? */	if (class_name_or_oid[0] >= '0' &&		class_name_or_oid[0] <= '9' &&		strspn(class_name_or_oid, "0123456789") == strlen(class_name_or_oid))	{		result = DatumGetObjectId(DirectFunctionCall1(oidin,										CStringGetDatum(class_name_or_oid)));		PG_RETURN_OID(result);	}	/* Else it's a name, possibly schema-qualified */	/*	 * In bootstrap mode we assume the given name is not schema-qualified, and	 * just search pg_class for a match.  This is needed for initializing	 * other system catalogs (pg_namespace may not exist yet, and certainly	 * there are no schemas other than pg_catalog).	 */	if (IsBootstrapProcessingMode())	{		Relation	hdesc;		ScanKeyData skey[1];		SysScanDesc sysscan;		HeapTuple	tuple;		ScanKeyInit(&skey[0],					Anum_pg_class_relname,					BTEqualStrategyNumber, F_NAMEEQ,					CStringGetDatum(class_name_or_oid));		hdesc = heap_open(RelationRelationId, AccessShareLock);		sysscan = systable_beginscan(hdesc, ClassNameNspIndexId, true,									 NULL, 1, skey);		if (HeapTupleIsValid(tuple = systable_getnext(sysscan)))			result = HeapTupleGetOid(tuple);		else			ereport(ERROR,					(errcode(ERRCODE_UNDEFINED_TABLE),			   errmsg("relation /"%s/" does not exist", class_name_or_oid)));		/* We assume there can be only one match */		systable_endscan(sysscan);		heap_close(hdesc, AccessShareLock);		PG_RETURN_OID(result);	}	/*	 * Normal case: parse the name into components and see if it matches any	 * pg_class entries in the current search path.	 */	names = stringToQualifiedNameList(class_name_or_oid);	/* We might not even have permissions on this relation; don't lock it. */	result = RangeVarGetRelid(makeRangeVarFromNameList(names), NoLock, false);	PG_RETURN_OID(result);}
开发者ID:WiserTogether,项目名称:postgres,代码行数:79,


示例26: regprocin

/* * regprocin		- converts "proname" to proc OID * * We also accept a numeric OID, for symmetry with the output routine. * * '-' signifies unknown (OID 0).  In all other cases, the input must * match an existing pg_proc entry. */Datumregprocin(PG_FUNCTION_ARGS){	char	   *pro_name_or_oid = PG_GETARG_CSTRING(0);	RegProcedure result = InvalidOid;	List	   *names;	FuncCandidateList clist;	/* '-' ? */	if (strcmp(pro_name_or_oid, "-") == 0)		PG_RETURN_OID(InvalidOid);	/* Numeric OID? */	if (pro_name_or_oid[0] >= '0' &&		pro_name_or_oid[0] <= '9' &&		strspn(pro_name_or_oid, "0123456789") == strlen(pro_name_or_oid))	{		result = DatumGetObjectId(DirectFunctionCall1(oidin,										  CStringGetDatum(pro_name_or_oid)));		PG_RETURN_OID(result);	}	/* Else it's a name, possibly schema-qualified */	/*	 * In bootstrap mode we assume the given name is not schema-qualified, and	 * just search pg_proc for a unique match.	This is needed for	 * initializing other system catalogs (pg_namespace may not exist yet, and	 * certainly there are no schemas other than pg_catalog).	 */	if (IsBootstrapProcessingMode())	{		int			matches = 0;		Relation	hdesc;		ScanKeyData skey[1];		SysScanDesc sysscan;		HeapTuple	tuple;		ScanKeyInit(&skey[0],					Anum_pg_proc_proname,					BTEqualStrategyNumber, F_NAMEEQ,					CStringGetDatum(pro_name_or_oid));		hdesc = heap_open(ProcedureRelationId, AccessShareLock);		sysscan = systable_beginscan(hdesc, ProcedureNameArgsNspIndexId, true,									 NULL, 1, skey);		while (HeapTupleIsValid(tuple = systable_getnext(sysscan)))		{			result = (RegProcedure) HeapTupleGetOid(tuple);			if (++matches > 1)				break;		}		systable_endscan(sysscan);		heap_close(hdesc, AccessShareLock);		if (matches == 0)			ereport(ERROR,					(errcode(ERRCODE_UNDEFINED_FUNCTION),				 errmsg("function /"%s/" does not exist", pro_name_or_oid)));		else if (matches > 1)			ereport(ERROR,					(errcode(ERRCODE_AMBIGUOUS_FUNCTION),					 errmsg("more than one function named /"%s/"",							pro_name_or_oid)));		PG_RETURN_OID(result);	}	/*	 * Normal case: parse the name into components and see if it matches any	 * pg_proc entries in the current search path.	 */	names = stringToQualifiedNameList(pro_name_or_oid);	clist = FuncnameGetCandidates(names, -1, NIL, false, false, false);	if (clist == NULL)		ereport(ERROR,				(errcode(ERRCODE_UNDEFINED_FUNCTION),				 errmsg("function /"%s/" does not exist", pro_name_or_oid)));	else if (clist->next != NULL)		ereport(ERROR,				(errcode(ERRCODE_AMBIGUOUS_FUNCTION),				 errmsg("more than one function named /"%s/"",						pro_name_or_oid)));	result = clist->oid;	PG_RETURN_OID(result);}
开发者ID:WiserTogether,项目名称:postgres,代码行数:100,


示例27: DeserializeTuple

//.........这里部分代码省略.........#endif				SET_VARSIZE(num, numSize + VARHDRSZ);				pq_copymsgbytes(serialTup, VARDATA(num), numSize);				skipPadding(serialTup);				pSerInfo->values[i] = NumericGetDatum(num);				break;			}			case ACLITEMOID:			{				int		aclSize, k, cnt;				char		*inputstring, *starsfree;				aclSize = stringInfoGetInt32(serialTup);				inputstring = (char*) palloc(aclSize  + 1);				starsfree = (char*) palloc(aclSize  + 1);				cnt = 0;					pq_copymsgbytes(serialTup, inputstring, aclSize);				skipPadding(serialTup);				inputstring[aclSize] = '/0';				for(k=0; k<aclSize; k++)				{										if( inputstring[k] != '*')					{						starsfree[cnt] = inputstring[k];						cnt++;					}				}				starsfree[cnt] = '/0';				pSerInfo->values[i] = DirectFunctionCall1(aclitemin, CStringGetDatum(starsfree));				pfree(inputstring);				break;			}			case 210:			{				int 		strsize;				char		*smgrstr;				strsize = stringInfoGetInt32(serialTup);				smgrstr = (char*) palloc(strsize + 1);				pq_copymsgbytes(serialTup, smgrstr, strsize);				skipPadding(serialTup);				smgrstr[strsize] = '/0';				pSerInfo->values[i] = DirectFunctionCall1(smgrin, CStringGetDatum(smgrstr));				break;			}			default:				fHandled = false;		}		if (fHandled)			continue;		attr_size = stringInfoGetInt32(serialTup);		/* reset attr_data to empty, and load raw data into it */		attr_data.len = 0;		attr_data.data[0] = '/0';		attr_data.cursor = 0;
开发者ID:50wu,项目名称:gpdb,代码行数:67,


示例28: regtypein

/* * regtypein		- converts "typename" to type OID * * We also accept a numeric OID, for symmetry with the output routine. * * '-' signifies unknown (OID 0).  In all other cases, the input must * match an existing pg_type entry. * * In bootstrap mode the name must just equal some existing name in pg_type. * In normal mode the type name can be specified using the full type syntax * recognized by the parser; for example, DOUBLE PRECISION and INTEGER[] will * work and be translated to the correct type names.  (We ignore any typmod * info generated by the parser, however.) */Datumregtypein(PG_FUNCTION_ARGS){	char	   *typ_name_or_oid = PG_GETARG_CSTRING(0);	Oid			result = InvalidOid;	int32		typmod;	/* '-' ? */	if (strcmp(typ_name_or_oid, "-") == 0)		PG_RETURN_OID(InvalidOid);	/* Numeric OID? */	if (typ_name_or_oid[0] >= '0' &&		typ_name_or_oid[0] <= '9' &&		strspn(typ_name_or_oid, "0123456789") == strlen(typ_name_or_oid))	{		result = DatumGetObjectId(DirectFunctionCall1(oidin,										  CStringGetDatum(typ_name_or_oid)));		PG_RETURN_OID(result);	}	/* Else it's a type name, possibly schema-qualified or decorated */	/*	 * In bootstrap mode we assume the given name is not schema-qualified, and	 * just search pg_type for a match.  This is needed for initializing other	 * system catalogs (pg_namespace may not exist yet, and certainly there	 * are no schemas other than pg_catalog).	 */	if (IsBootstrapProcessingMode())	{		Relation	hdesc;		ScanKeyData skey[1];		SysScanDesc sysscan;		HeapTuple	tuple;		ScanKeyInit(&skey[0],					Anum_pg_type_typname,					BTEqualStrategyNumber, F_NAMEEQ,					CStringGetDatum(typ_name_or_oid));		hdesc = heap_open(TypeRelationId, AccessShareLock);		sysscan = systable_beginscan(hdesc, TypeNameNspIndexId, true,									 NULL, 1, skey);		if (HeapTupleIsValid(tuple = systable_getnext(sysscan)))			result = HeapTupleGetOid(tuple);		else			ereport(ERROR,					(errcode(ERRCODE_UNDEFINED_OBJECT),					 errmsg("type /"%s/" does not exist", typ_name_or_oid)));		/* We assume there can be only one match */		systable_endscan(sysscan);		heap_close(hdesc, AccessShareLock);		PG_RETURN_OID(result);	}	/*	 * Normal case: invoke the full parser to deal with special cases such as	 * array syntax.	 */	parseTypeString(typ_name_or_oid, &result, &typmod);	PG_RETURN_OID(result);}
开发者ID:WiserTogether,项目名称:postgres,代码行数:82,


示例29: TypeCreate

//.........这里部分代码省略.........	/*	 * initialize the default binary value for this type.  Check for nulls of	 * course.	 */	if (defaultTypeBin)		values[Anum_pg_type_typdefaultbin - 1] = CStringGetTextDatum(defaultTypeBin);	else		nulls[Anum_pg_type_typdefaultbin - 1] = true;	/*	 * initialize the default value for this type.	 */	if (defaultTypeValue)		values[Anum_pg_type_typdefault - 1] = CStringGetTextDatum(defaultTypeValue);	else		nulls[Anum_pg_type_typdefault - 1] = true;	typacl = get_user_default_acl(ACL_OBJECT_TYPE, ownerId,								  typeNamespace);	if (typacl != NULL)		values[Anum_pg_type_typacl - 1] = PointerGetDatum(typacl);	else		nulls[Anum_pg_type_typacl - 1] = true;	/*	 * open pg_type and prepare to insert or update a row.	 *	 * NOTE: updating will not work correctly in bootstrap mode; but we don't	 * expect to be overwriting any shell types in bootstrap mode.	 */	pg_type_desc = heap_open(TypeRelationId, RowExclusiveLock);	tup = SearchSysCacheCopy2(TYPENAMENSP,							  CStringGetDatum(typeName),							  ObjectIdGetDatum(typeNamespace));	if (HeapTupleIsValid(tup))	{		/*		 * check that the type is not already defined.	It may exist as a		 * shell type, however.		 */		if (((Form_pg_type) GETSTRUCT(tup))->typisdefined)			ereport(ERROR,					(errcode(ERRCODE_DUPLICATE_OBJECT),					 errmsg("type /"%s/" already exists", typeName)));		/*		 * shell type must have been created by same owner		 */		if (((Form_pg_type) GETSTRUCT(tup))->typowner != ownerId)			aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TYPE, typeName);		/* trouble if caller wanted to force the OID */		if (OidIsValid(newTypeOid))			elog(ERROR, "cannot assign new OID to existing shell type");		/*		 * Okay to update existing shell type tuple		 */		tup = heap_modify_tuple(tup,								RelationGetDescr(pg_type_desc),								values,								nulls,								replaces);		simple_heap_update(pg_type_desc, &tup->t_self, tup);
开发者ID:adunstan,项目名称:postgresql-dev,代码行数:67,



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


C++ CStringGetTextDatum函数代码示例
C++ CStringA函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。