示例#1
0
qryproc()
{
	register QTREE			*root;
	register QTREE			*q;
	register int			i;
	register int			mode;
	register int			result_num;
	register int			retr_uniq;
	extern long			AAccuread;
	extern long			AAccuwrite;
	extern long			AAccusread;
	extern int			derror();
	extern QTREE			*trbuild();
	extern QTREE			*readqry();

#	ifdef xDTM
	if (AAtTf(76, 1))
		timtrace(23, 0);
#	endif
#	ifdef xDTR1
	if (AAtTf(50, 0))
		AAccuread = AAccusread = AAccuwrite = 0;
#	endif

	/* initialize query buffer */
	initbuf(Qbuf, QBUFSIZ, QBUFFULL, derror);

	/* init various variables in decomp for start of this query */
	startdecomp();

	/* Read in query, range table and mode */
	root = readqry();
	mode = Qmode;

	/* Initialize relation descriptors */
	initdesc(mode);

	/* re-build the tree */
	root = trbuild(root);
	if (!root)
		derror(STACKFULL);


	/* locate pointers to QLEND and TREE nodes */
	for (q = root->right; q->sym.type != QLEND; q = q->right)
		continue;
	Qle = q;

	for (q = root->left; q->sym.type != TREE; q = q->left)
		continue;
	Tr = q;


	/* map the complete tree */
	mapvar(root, 0);

	/* set logical locks */
	lockit(root, Resultvar);

	/* If there is no result variable then this must be a retrieve to the terminal */
	Qry_mode = Resultvar < 0 ? (int) mdRETTERM : mode;

	/* if the mode is retrieve_unique, then make a result rel */
	retr_uniq = mode == (int) mdRET_UNI;
	if (retr_uniq)
	{
		mk_unique(root);
		mode = (int) mdRETR;
	}

	/* get id of result relation */
	if (Resultvar < 0)
		result_num = NORESULT;
	else
		result_num = Rangev[Resultvar].relnum;

	/* evaluate aggregates in query */
	aggregate(root);

	/* decompose and process aggregate free query */
	decomp(root, mode, result_num);

	/* If this is a retrieve unique, then retrieve results */
	if (retr_uniq)
		pr_unique(root, Resultvar);

	if (mode != (int) mdRETR)
		i = ACK;
	else
		i = NOACK;
	i = endovqp(i);

	/* call update processor if batch mode */
	if (i == UPDATE)
	{
		initp();
		call_dbu(mdUPDATE, -1);
	}


	/*
	** send eop back to parser to indicate completion
	** if UPDATE then return block comes from dbu else
	** return block comes from decomp
	*/
	writeback(i == UPDATE ? -1 : 1);

#	ifdef xDTM
	if(AAtTf(76, 1))
		timtrace(24, 0);
#	endif
#	ifdef xDTR1
	AAtTfp(50, 1, "DECOMP read %ld pages,%ld catalog pages,wrote %ld pages\n",
		AAccuread, AAccusread, AAccuwrite);
#	endif

	/* clean decomp */
	reinit();

	/* return */
}
示例#2
0
HRESULT LightOPCServer::internalAddGroup(
        LightOPCGroup *grp,
        LPCWSTR szName,
        BOOL bActive,
        DWORD UpdateRate,
        OPCHANDLE hClientGroup,
        LONG *pTimeBias,
        FLOAT *pPercentDeadband,
        DWORD dwLCID,
        OPCHANDLE *phServerGroup,
        REFIID riid,
        LPUNKNOWN *ppUnk
        )
{
 HRESULT hr = S_OK;
 unsigned servindex = 0;
 OPCHANDLE servhandle = 0;
 loWchar tname[loUNIQUE_LEN];

 if (phServerGroup) *phServerGroup = 0;
 if (!ppUnk) { hr = E_INVALIDARG; goto Exit; }
 *ppUnk = 0;

/*    if (!grp && !(grp = new LightOPCGroup()) ||
     grp->sstate != loST_READY) { hr = E_OUTOFMEMORY; goto Exit; }*/
/*  need assign all group atributes */
 grp->ClientHandle = hClientGroup;
 grp->UpdateRate = UpdateRate;
 grp->Active = bActive != 0;
 grp->Deadband = .0f;
 if (pPercentDeadband)
   {
    if (lo_IsNANf(*pPercentDeadband) ||
        *pPercentDeadband < 0. ||
        *pPercentDeadband > 100.) { hr = E_INVALIDARG; goto Exit; }
    grp->Deadband = *pPercentDeadband;
   }
 if (se->driver.ldCheckLocale && 
     se->driver.ldCheckLocale(&ctxt.cactx, dwLCID))
   GetLocaleID(&dwLCID);
 grp->grLCID = dwLCID;

 if (pTimeBias) grp->TimeBias = *pTimeBias;
 else
   {
    TIME_ZONE_INFORMATION tzi;
    tzi.Bias = 0;
    GetTimeZoneInformation(&tzi);
    grp->TimeBias = tzi.Bias;
   }

 if (szName)
   if (!*szName) szName = 0;
   else if (S_OK != grp->set_name(szName)) { hr = E_OUTOFMEMORY; goto Exit; }

// grp->sstate = loST_READY;
 hr = grp->QueryInterface(riid, (void**)ppUnk);
// grp->sstate = loST_DOWN;
 if (S_OK != hr) goto Exit;

 lock_write();
    if (!szName)
      {
       if (S_OK == (hr = mk_unique(tname, grp)))
         hr = grp->set_name(szName = tname);
      }
    else if (by_name(szName)) hr = OPC_E_DUPLICATENAME;

    if (S_OK == hr)
      if (servindex = add(grp))
        {
         do {
             if ((servhandle = ++unique_GroupHandle) == 0)
               servhandle = ++unique_GroupHandle;
            }
         while(by_handle(servhandle));

         grp->ServerHandle = servhandle;
         ostatus.dwGroupCount++;
        }
      else { hr = E_OUTOFMEMORY; /* delete grp; will be deleted by caller */ }
 unlock();

 if (phServerGroup) *phServerGroup = servhandle;

Exit:
 if (S_OK == hr)
   {
    UL_TRACE((LOG_SR("intAddGroup(%ls) i:%u h:%u /%p"),
              szName? szName: tname, servindex, servhandle, *ppUnk));
   }
 else
   {
     UL_TRACE((LOG_SR("intAddGroup(%ls) =%s"), loWnul(szName), loStrError(hr)));
//	 if (grp) delete grp;
    *ppUnk = 0;
   }

 return hr;
}