Beispiel #1
0
/*
 * make_oper_cache_key
 *		Fill the lookup key struct given operator name and arg types.
 *
 * Returns TRUE if successful, FALSE if the search_path overflowed
 * (hence no caching is possible).
 */
static bool
make_oper_cache_key(OprCacheKey *key, List *opname, Oid ltypeId, Oid rtypeId)
{
	char	   *schemaname;
	char	   *opername;

	/* deconstruct the name list */
	DeconstructQualifiedName(opname, &schemaname, &opername);

	/* ensure zero-fill for stable hashing */
	MemSet(key, 0, sizeof(OprCacheKey));

	/* save operator name and input types into key */
	strlcpy(key->oprname, opername, NAMEDATALEN);
	key->left_arg = ltypeId;
	key->right_arg = rtypeId;

	if (schemaname)
	{
		/* search only in exact schema given */
		key->search_path[0] = LookupExplicitNamespace(schemaname);
	}
	else
	{
		/* get the active search path */
		if (fetch_search_path_array(key->search_path,
								  MAX_CACHED_PATH_LEN) > MAX_CACHED_PATH_LEN)
			return false;		/* oops, didn't fit */
	}

	return true;
}
Beispiel #2
0
/*
 * make_opr_cache_key
 *		Fill the lookup key struct given operator name and arg types.
 *
 * Returns TRUE if successful, FALSE if the search_path overflowed
 * (hence no caching is possible).
 */
static bool
make_opr_cache_key(struct opr_cache_key *key, struct list *opname, oid_t ltypeId, oid_t rtypeId)
{
	char* schemaname;
	char* opername;

	/* deconstruct the name list */
	split_qualified_name(opname, &schemaname, &opername);

	/* ensure zero-fill for stable hashing */
	pg_memset(key, 0, sizeof(struct opr_cache_key));

	/* save operator name and input types into key */
	strlcpy(key->oprname, opername, NAMEDATALEN);
	key->left_arg = ltypeId;
	key->right_arg = rtypeId;

	if (schemaname) {
		/* search only in exact schema given */
		key->search_path[0] = lookup_explicit_ns(schemaname);
	} else {
		/* get the active search path */
		if (fetch_search_path_array(key->search_path, MAX_CACHED_PATH_LEN) > MAX_CACHED_PATH_LEN)
			return false;		/* oops, didn't fit */
	}

	return true;
}