Exemplo n.º 1
0
boolean_t	gvcst_query(void)
{	/* Similar to gvcst_order and gvcst_zprevious. In each case we skip over hidden subscripts as needed.
	 *
	 *     1  2  3  NULL                           <--- order/zprev...
	 *     1  2  3  NULL  NULL
	 *     1  2  3  NULL  NULL  NULL                                <--- query from here...
	 *     1  2  3  NULL  NULL  NULL  hidden
	 *     1  2  3  NULL  NULL  hidden
	 *     1  2  3  NULL  hidden
	 *     1  2  3  hidden                         <--- ... skip this guy and go to bottom/top, respectively
	 *     1  2  3  7                                               <--- ... needs to end up here
	 */
	boolean_t	found, is_hidden, sn_tpwrapped;
	boolean_t	est_first_pass;
	gv_key		save_currkey[DBKEYALLOC(MAX_KEY_SZ)];
	int		i;
	int		save_dollar_tlevel;

	DEBUG_ONLY(save_dollar_tlevel = dollar_tlevel);
	found = gvcst_query2();
#	ifdef UNIX
	assert(save_dollar_tlevel == dollar_tlevel);
	CHECK_HIDDEN_SUBSCRIPT_AND_RETURN(found, gv_altkey, is_hidden);
	IF_SN_DISALLOWED_AND_NO_SPAN_IN_DB(return found);
	assert(found && is_hidden);
	SAVE_GV_CURRKEY(save_currkey);
	if (!dollar_tlevel)
	{
		sn_tpwrapped = TRUE;
		op_tstart((IMPLICIT_TSTART), TRUE, &literal_batch, 0);
		ESTABLISH_NORET(gvcst_query_ch, est_first_pass);
		GVCST_ROOT_SEARCH_AND_PREP(est_first_pass);
	} else
		sn_tpwrapped = FALSE;
	for (i = 0; i <= MAX_GVSUBSCRIPTS; i++)
	{
		INCR_GVSTATS_COUNTER(cs_addrs, cs_addrs->nl, n_query, (gtm_uint64_t) -1);
		found = gvcst_query2();
		CHECK_HIDDEN_SUBSCRIPT_AND_BREAK(found, gv_altkey, is_hidden);
		assert(found && is_hidden);
		/* Replace last subscript to be the highest possible hidden subscript so another
		 * gvcst_query2 will give us the next non-hidden subscript.
		 */
		REPLACE_HIDDEN_SUB_TO_HIGHEST(gv_altkey, gv_currkey);	/* uses gv_altkey to modify gv_currkey */
	}
	if (sn_tpwrapped)
	{
		op_tcommit();
		REVERT; /* remove our condition handler */
	}
	RESTORE_GV_CURRKEY(save_currkey);
	assert(save_dollar_tlevel == dollar_tlevel);
#	endif
	return found;
}
Exemplo n.º 2
0
boolean_t gvcst_queryget(mval *val)
{
	bool		found, is_hidden, is_dummy = FALSE, sn_tpwrapped;
	boolean_t	est_first_pass;
	gv_key		save_currkey[DBKEYALLOC(MAX_KEY_SZ)];
	int		save_dollar_tlevel;

	DEBUG_ONLY(save_dollar_tlevel = dollar_tlevel);
	found = gvcst_queryget2(val, NULL);
#	ifdef UNIX
	assert(save_dollar_tlevel == dollar_tlevel);
	CHECK_HIDDEN_SUBSCRIPT(gv_altkey, is_hidden);
	if (found && IS_SN_DUMMY(val->str.len, val->str.addr))
		is_dummy = TRUE;
	if (!found || (!is_dummy && !is_hidden))
		return found;
	IF_SN_DISALLOWED_AND_NO_SPAN_IN_DB(return found);
	SAVE_GV_CURRKEY(save_currkey);
	if (!dollar_tlevel)
	{
		sn_tpwrapped = TRUE;
		op_tstart((IMPLICIT_TSTART), TRUE, &literal_batch, 0);
		ESTABLISH_NORET(gvcst_queryget_ch, est_first_pass);
		GVCST_ROOT_SEARCH_AND_PREP(est_first_pass);
	} else
		sn_tpwrapped = FALSE;
	found = gvcst_query();
	COPY_KEY(gv_currkey, gv_altkey); /* set gv_currkey to gv_altkey */
	found = gvcst_get(val);
	INCR_GVSTATS_COUNTER(cs_addrs, cs_addrs->nl, n_get, (gtm_uint64_t) -1); /* only counted externally as one get */
	INCR_GVSTATS_COUNTER(cs_addrs, cs_addrs->nl, n_query, (gtm_uint64_t) -1);
	if (sn_tpwrapped)
	{
		op_tcommit();
		REVERT; /* remove our condition handler */
	}
	RESTORE_GV_CURRKEY(save_currkey);
	assert(save_dollar_tlevel == dollar_tlevel);
#	endif
	return found;
}