void CmpCompileInfo::packVars(char * buffer, CmpCompileInfo *ci, Lng32 &nextOffset) { if (sqltext_ && (sqlTextLen_ > 0)) { str_cpy_all(&buffer[nextOffset], sqltext_, sqlTextLen_); ci->sqltext_ = (char *)nextOffset; nextOffset += ROUND8(sqlTextLen_); } if (rlnil_ && (rlnilLen_ > 0)) { str_cpy_all(&buffer[nextOffset], (char *)rlnil_, rlnilLen_); ci->rlnil_ = (RecompLateNameInfoList *)nextOffset; nextOffset += ROUND8(rlnilLen_); } if (schemaName_ && (schemaNameLen_ > 0)) { str_cpy_all(&buffer[nextOffset], (char *)schemaName_, schemaNameLen_); ci->schemaName_ = (char *)nextOffset; nextOffset += ROUND8(schemaNameLen_); } if (recompControlInfo_ && (recompControlInfoLen_ > 0)) { str_cpy_all(&buffer[nextOffset], (char *)recompControlInfo_, recompControlInfoLen_); ci->recompControlInfo_ = (char *)nextOffset; nextOffset += ROUND8(recompControlInfoLen_); } }
/* ** Like malloc(), but remember the size of the allocation ** so that we can find it later using sqlite3MemSize(). ** ** For this low-level routine, we are guaranteed that nByte>0 because ** cases of nByte<=0 will be intercepted and dealt with by higher level ** routines. */ static void *sqlite3MemMalloc(int nByte){ #ifdef SQLITE_MALLOCSIZE void *p; testcase( ROUND8(nByte)==nByte ); p = SQLITE_MALLOC( nByte ); if( p==0 ){ testcase( sqlite3GlobalConfig.xLog!=0 ); sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte); } return p; #else sqlite3_int64 *p; assert( nByte>0 ); testcase( ROUND8(nByte)!=nByte ); p = SQLITE_MALLOC( nByte+8 ); if( p ){ p[0] = nByte; p++; }else{ testcase( sqlite3GlobalConfig.xLog!=0 ); sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte); } return (void *)p; #endif }
Lng32 CmpDDLwithStatusInfo::getLength() { Lng32 sizeOfThis = getClassSize(); Lng32 totalLength = ROUND8(sizeOfThis) + getVarLength(); if ((blackBoxLen_ > 0) && (blackBox_)) totalLength += ROUND8(blackBoxLen_); return totalLength; }
/* ** Turn bulk memory into a RowSet object. N bytes of memory ** are available at pSpace. The db pointer is used as a memory context ** for any subsequent allocations that need to occur. ** Return a pointer to the new RowSet object. ** ** It must be the case that N is sufficient to make a Rowset. If not ** an assertion fault occurs. ** ** If N is larger than the minimum, use the surplus as an initial ** allocation of entries available to be filled. */ SQLITE_PRIVATE RowSet *sqlite3RowSetInit(sqlite3 *db, void *pSpace, unsigned int N){ RowSet *p; assert( N >= ROUND8(sizeof(*p)) ); p = pSpace; p->pChunk = 0; p->db = db; p->pEntry = 0; p->pLast = 0; p->pForest = 0; p->pFresh = (struct RowSetEntry*)(ROUND8(sizeof(*p)) + (char*)p); p->nFresh = (u16)((N - ROUND8(sizeof(*p)))/sizeof(struct RowSetEntry)); p->rsFlags = ROWSET_SORTED; p->iBatch = 0; return p; }
/* ** Turn bulk memory into a RowSet object. N bytes of memory ** are available at pSpace. The db pointer is used as a memory context ** for any subsequent allocations that need to occur. ** Return a pointer to the new RowSet object. ** ** It must be the case that N is sufficient to make a Rowset. If not ** an assertion fault occurs. ** ** If N is larger than the minimum, use the surplus as an initial ** allocation of entries available to be filled. */ RowSet *sqlite3RowSetInit(sqlite3 *db, void *pSpace, unsigned int N){ RowSet *p; assert( N >= ROUND8(sizeof(*p)) ); p = pSpace; p->pChunk = 0; p->db = db; p->pEntry = 0; p->pLast = 0; p->pTree = 0; p->pFresh = (struct RowSetEntry*)(ROUND8(sizeof(*p)) + (char*)p); p->nFresh = (u16)((N - ROUND8(sizeof(*p)))/sizeof(struct RowSetEntry)); p->isSorted = 1; p->iBatch = 0; return p; }
/* ** Like realloc(). Resize an allocation previously obtained from ** sqlite4MemMalloc(). ** ** For this low-level interface, we know that pPrior!=0. Cases where ** pPrior==0 while have been intercepted by higher-level routine and ** redirected to xMalloc. Similarly, we know that nByte>0 becauses ** cases where nByte<=0 will have been intercepted by higher-level ** routines and redirected to xFree. */ static void *sqlite4MemRealloc(void *NotUsed, void *pPrior, int nByte){ #ifdef SQLITE4_MALLOCSIZE void *p = SQLITE4_REALLOC(pPrior, nByte); UNUSED_PARAMETER(NotUsed); if( p==0 ){ testcase( sqlite4DefaultEnv.xLog!=0 ); sqlite4_log(0,SQLITE4_NOMEM, "failed memory resize %u to %u bytes", SQLITE4_MALLOCSIZE(pPrior), nByte); } return p; #else sqlite4_int64 *p = (sqlite4_int64*)pPrior; assert( pPrior!=0 && nByte>0 ); assert( nByte==ROUND8(nByte) ); /* EV: R-46199-30249 */ UNUSED_PARAMETER(NotUsed); p--; p = SQLITE4_REALLOC(p, nByte+8 ); if( p ){ p[0] = nByte; p++; }else{ testcase( sqlite4DefaultEnv.xLog!=0 ); sqlite4_log(0,SQLITE4_NOMEM, "failed memory resize %u to %u bytes", sqlite4MemSize(0, pPrior), nByte); } return (void*)p; #endif }
/* ** Like realloc(). Resize an allocation previously obtained from ** sqlite3MemMalloc(). ** ** For this low-level interface, we know that pPrior!=0. Cases where ** pPrior==0 while have been intercepted by higher-level routine and ** redirected to xMalloc. Similarly, we know that nByte>0 becauses ** cases where nByte<=0 will have been intercepted by higher-level ** routines and redirected to xFree. */ static void *sqlite3MemRealloc(void *pPrior, int nByte){ #ifdef SQLITE_MALLOCSIZE void *p = SQLITE_REALLOC(pPrior, nByte); if( p==0 ){ testcase( sqlite3GlobalConfig.xLog!=0 ); sqlite3_log(SQLITE_NOMEM, "failed memory resize %u to %u bytes", SQLITE_MALLOCSIZE(pPrior), nByte); } return p; #else sqlite3_int64 *p = (sqlite3_int64*)pPrior; assert( pPrior!=0 && nByte>0 ); assert( nByte==ROUND8(nByte) ); /* EV: R-46199-30249 */ p--; p = SQLITE_REALLOC(p, nByte+8 ); if( p ){ p[0] = nByte; p++; }else{ testcase( sqlite3GlobalConfig.xLog!=0 ); sqlite3_log(SQLITE_NOMEM, "failed memory resize %u to %u bytes", sqlite3MemSize(pPrior), nByte); } return (void*)p; #endif }
void *sqlite4_wsd_find(void *K, int L){ int i; int iHash = 0; ProcessLocalVar *pVar; /* Calculate a hash of K */ for(i=0; i<sizeof(void*); i++){ iHash = (iHash<<3) + ((unsigned char *)&K)[i]; } iHash = iHash%PLS_HASHSIZE; /* Search the hash table for K. */ for(pVar=pGlobal->aData[iHash]; pVar && pVar->pKey!=K; pVar=pVar->pNext); /* If no entry for K was found, create and populate a new one. */ if( !pVar ){ int nByte = ROUND8(sizeof(ProcessLocalVar) + L); assert( pGlobal->nFree>=nByte ); pVar = (ProcessLocalVar *)pGlobal->pFree; pVar->pKey = K; pVar->pNext = pGlobal->aData[iHash]; pGlobal->aData[iHash] = pVar; pGlobal->nFree -= nByte; pGlobal->pFree += nByte; memcpy(&pVar[1], K, L); } return (void *)&pVar[1]; }
/* ** Like malloc(), but remember the size of the allocation ** so that we can find it later using sqlite4MemSize(). ** ** For this low-level routine, we are guaranteed that nByte>0 because ** cases of nByte<=0 will be intercepted and dealt with by higher level ** routines. */ static void *sqlite4MemMalloc(void *NotUsed, sqlite4_size_t nByte){ #ifdef SQLITE4_MALLOCSIZE void *p = SQLITE4_MALLOC( nByte ); UNUSED_PARAMETER(NotUsed); if( p==0 ){ testcase( sqlite4DefaultEnv.xLog!=0 ); sqlite4_log(0,SQLITE4_NOMEM, "failed to allocate %u bytes of memory", nByte); } return p; #else sqlite4_int64 *p; assert( nByte>0 ); UNUSED_PARAMETER(NotUsed); nByte = ROUND8(nByte); p = SQLITE4_MALLOC( nByte+8 ); if( p ){ p[0] = nByte; p++; }else{ testcase( sqlite4DefaultEnv.xLog!=0 ); sqlite4_log(0,SQLITE4_NOMEM, "failed to allocate %u bytes of memory", nByte); } return (void *)p; #endif }
/////////////////////////////////////////////////////////////////// // Methods for the Probe Cache Manager /////////////////////////////////////////////////////////////////// ExPCMgr::ExPCMgr(Space *space, ULng32 numEntries, ULng32 probeLength, ExProbeCacheTcb *tcb) : space_(space), numBuckets_(numEntries), probeLen_(probeLength), tcb_(tcb), buckets_(NULL), entries_(NULL), nextVictim_(0) { buckets_ = new(space_) ExPCE *[numBuckets_]; // Initialize all the buckets to "empty". memset((char *)buckets_, 0, numBuckets_ * sizeof(ExPCE *)); // Calculate the real size for each ExPCE -- the probeData_ // array is one byte so subtract that from probeLength. sizeofExPCE_ = ROUND8(sizeof(ExPCE) + (probeLength - 1)); // Get the size in bytes of the ExPCE array. const Int32 totalExPCEsizeInBytes = numEntries * sizeofExPCE_; entries_ = new(space_) char[totalExPCEsizeInBytes]; memset(entries_, 0, totalExPCEsizeInBytes); };
void CmpDDLwithStatusInfo::pack(char * buffer) { CmpDDLwithStatusInfo * ci = (CmpDDLwithStatusInfo *)buffer; Lng32 classSize = getClassSize(); Lng32 nextOffset = 0; str_cpy_all(buffer, (char *)this, classSize); nextOffset += ROUND8(classSize); packVars(buffer, ci, nextOffset); if (blackBox_ && (blackBoxLen_ > 0)) { str_cpy_all(&buffer[nextOffset], blackBox_, blackBoxLen_); ci->blackBox_ = (char *)nextOffset; nextOffset += ROUND8(blackBoxLen_); } }
/* ** Like malloc(), but remember the size of the allocation ** so that we can find it later using sqlite3MemSize(). ** ** For this low-level routine, we are guaranteed that nByte>0 because ** cases of nByte<=0 will be intercepted and dealt with by higher level ** routines. */ static void *sqlite3MemMalloc(int nByte){ sqlite3_int64 *p; assert( nByte>0 ); nByte = ROUND8(nByte); p = malloc( nByte+8 ); if( p ){ p[0] = nByte; p++; } return (void *)p; }
void CmpCompileInfo::pack(char * buffer) { CmpCompileInfo * ci = (CmpCompileInfo *)buffer; Lng32 classSize = getClassSize(); Lng32 nextOffset = 0; str_cpy_all(buffer, (char *)this, classSize); nextOffset += ROUND8(classSize); packVars(buffer, ci, nextOffset); }
/* ** Like realloc(). Resize an allocation previously obtained from ** sqlite3MemMalloc(). ** ** For this low-level interface, we know that pPrior!=0. Cases where ** pPrior==0 while have been intercepted by higher-level routine and ** redirected to xMalloc. Similarly, we know that nByte>0 becauses ** cases where nByte<=0 will have been intercepted by higher-level ** routines and redirected to xFree. */ static void *sqlite3MemRealloc(void *pPrior, int nByte){ sqlite3_int64 *p = (sqlite3_int64*)pPrior; assert( pPrior!=0 && nByte>0 ); nByte = ROUND8(nByte); p = (sqlite3_int64*)pPrior; p--; p = realloc(p, nByte+8 ); if( p ){ p[0] = nByte; p++; } return (void*)p; }
/* ** Like malloc(), but remember the size of the allocation ** so that we can find it later using sqlite3MemSize(). ** ** For this low-level routine, we are guaranteed that nByte>0 because ** cases of nByte<=0 will be intercepted and dealt with by higher level ** routines. */ static void *sqlite3MemMalloc(int nByte){ sqlite3_int64 *p; assert( nByte>0 ); nByte = ROUND8(nByte); p = (sqlite3_int64 *) malloc( nByte+8 ); if( p ){ p[0] = nByte; p++; }else{ testcase( sqlite3GlobalConfig.xLog!=0 ); sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte); } return (void *)p; }
char *LmCBuffer::init(ComUInt32 len) { release(); // Make sure len_ is a multiple of 8 and then add 8 bytes for safety len_ = ROUND8(len); len_ += 8; // malloc returns a buffer "suitably aligned for storage of any // type" according to the man page. We can assume the buffer will be // aligned on an 8-byte boundary. buf_ = (char *) malloc(len_); LMCOMMON_ASSERT(buf_); set(0); return buf_; }
/* ** Change the page size for PCache object. The caller must ensure that there ** are no outstanding page references when this function is called. */ int sqlite3PcacheSetPageSize(PCache *pCache, int szPage){ assert( pCache->nRefSum==0 && pCache->pDirty==0 ); if( pCache->szPage ){ sqlite3_pcache *pNew; pNew = sqlite3GlobalConfig.pcache2.xCreate( szPage, pCache->szExtra + ROUND8(sizeof(PgHdr)), pCache->bPurgeable ); if( pNew==0 ) return SQLITE_NOMEM_BKPT; sqlite3GlobalConfig.pcache2.xCachesize(pNew, numberOfCachePages(pCache)); if( pCache->pCache ){ sqlite3GlobalConfig.pcache2.xDestroy(pCache->pCache); } pCache->pCache = pNew; pCache->szPage = szPage; pcacheTrace(("%p.PAGESIZE %d\n",pCache,szPage)); } return SQLITE_OK; }
// copy_and_pad(): create a copy of the given buffer on the C runtime // heap. Optionally add zeroed-out padding at the end. char *copy_and_pad(const char *src, ComUInt32 len, ComUInt32 pad) { char *tgt = NULL; if (src) { // Make sure the buffer size is a multiple of 8 so that it's // always aligned to store binary integers and floating point // values if necessary ComUInt32 actualLen = ROUND8(len + pad); ComUInt32 actualPad = actualLen - len; tgt = (char *) malloc(actualLen); LMCOMMON_ASSERT(tgt); if (len > 0) memcpy(tgt, src, len); if (actualPad) memset(tgt + len, 0, actualPad); } return tgt; }
CCallbackParcel::~CCallbackParcel() { mElemPtr = mElemBuf; for (Int32 i = 0; i < mElemCount; i++) { switch(mElemTypes[i]) { case Type_InterfacePtr: if (*(IInterface**)mElemPtr != NULL) { (*(IInterface**)mElemPtr)->Release(); } mElemPtr += 4; break; case Type_Int64: case Type_Double: #if defined(_arm) && defined(__GNUC__) && (__GNUC__ >= 4) mElemPtr = (Byte*)ROUND8((Int32)mElemPtr); #endif mElemPtr += 8; break; case Type_String: { String* p = *(String**)mElemPtr; delete p; *(String**)mElemPtr = NULL; break; } default: mElemPtr += 4; break; } } free(mElemTypes); free(mElemBuf); free(mDataBuf); }
ECode CCallbackParcel::Clone( /* [in] */ IParcel* srcParcel) { Byte type, bv, *srcElemPtr; Int16 i16v; Int32 i32v, size; Int64 i64v; char *str; CCallbackParcel *src; src = (CCallbackParcel*)srcParcel; srcElemPtr = src->mElemBuf; for(Int32 i = 0; i < src->mElemCount; i++) { type = src->mElemTypes[i]; switch(type) { case Type_Byte: case Type_Boolean: bv = *srcElemPtr; WriteValue((PVoid)&bv, type, sizeof(Byte)); srcElemPtr += 4; break; case Type_Int16: i16v = *(Int16*)srcElemPtr; WriteValue((PVoid)&i16v, type, sizeof(Int16)); srcElemPtr += 4; break; case Type_Char32: case Type_Int32: case Type_Float: case Type_InterfacePtr: i32v = *(Int32*)srcElemPtr; WriteValue((PVoid)&i32v, type, sizeof(Int32)); srcElemPtr += 4; break; case Type_Int64: case Type_Double: #if defined(_arm) && defined(__GNUC__) && (__GNUC__ >= 4) srcElemPtr = (Byte*)ROUND8((Int32)srcElemPtr); #endif i64v = *(UInt32*)(srcElemPtr + 4); i64v = (i64v << 32) | *(UInt32*)srcElemPtr; WriteValue((PVoid)&i64v, type, sizeof(Int64)); srcElemPtr += 8; break; case Type_String: str = *(char**)srcElemPtr; if (str == NULL) { size = 0; } else { size = strlen(str) + 1; } WriteValue((PVoid)str, type, size); srcElemPtr += 4; break; case Type_Struct: size = *((*(Int32**)srcElemPtr) - 1); WriteValue((PVoid)(*(Byte**)srcElemPtr), type, size); srcElemPtr += 4; break; case Type_EMuid: WriteValue((PVoid)(*(EMuid**)srcElemPtr), type, sizeof(EMuid)); srcElemPtr += 4; break; case Type_EGuid: WriteValue((PVoid)(*(EGuid**)srcElemPtr), type, sizeof(EGuid)); srcElemPtr += 4; break; case Type_ArrayOf: case Type_ArrayOfString: size = *(Int32*)(*(Byte**)srcElemPtr - 4); WriteValue((PVoid)(*(CarQuintet**)srcElemPtr), type, size); srcElemPtr += 4; break; default: assert(0); break; } } return NOERROR; }
ExFastExtractTcb::ExFastExtractTcb( const ExFastExtractTdb &fteTdb, const ex_tcb & childTcb, ex_globals *glob) : ex_tcb(fteTdb, 1, glob), workAtp_(NULL), outputPool_(NULL), inputPool_(NULL), childTcb_(&childTcb) , inSqlBuffer_(NULL) , childOutputTD_(NULL) , sourceFieldsConvIndex_(NULL) , currBuffer_(NULL) , bufferAllocFailuresCount_(0) , modTS_(-1) { ex_globals *stmtGlobals = getGlobals(); Space *globSpace = getSpace(); CollHeap *globHeap = getHeap(); heap_ = globHeap; //convert to non constant to access the members. ExFastExtractTdb *mytdb = (ExFastExtractTdb*)&fteTdb; numBuffers_ = mytdb->getNumIOBuffers(); // Allocate queues to communicate with parent allocateParentQueues(qParent_); // get the queue that child use to communicate with me qChild_ = childTcb.getParentQueue(); // Allocate the work ATP if (myTdb().getWorkCriDesc()) workAtp_ = allocateAtp(myTdb().getWorkCriDesc(), globSpace); // Fixup expressions // NOT USED in M9 /* if (myTdb().getInputExpression()) myTdb().getInputExpression()->fixup(0, getExpressionMode(), this, globSpace, globHeap); if (myTdb().getOutputExpression()) myTdb().getOutputExpression()->fixup(0, getExpressionMode(), this, globSpace, globHeap); */ if (myTdb().getChildDataExpr()) myTdb().getChildDataExpr()->fixup(0,getExpressionMode(),this, globSpace, globHeap, FALSE, glob); //maybe we can move the below few line to the init section od work methods?? UInt32 numAttrs = myTdb().getChildTuple()->numAttrs(); sourceFieldsConvIndex_ = (int *)((NAHeap *)heap_)->allocateAlignedHeapMemory((UInt32)(sizeof(int) * numAttrs), 512, FALSE); maxExtractRowLength_ = ROUND8(myTdb().getChildDataRowLen()) ; const ULng32 sqlBufferSize = maxExtractRowLength_ + ROUND8(sizeof(SqlBufferNormal)) + sizeof(tupp_descriptor) + 16 ;//just in case inSqlBuffer_ = (SqlBuffer *) new (heap_) char[sqlBufferSize]; inSqlBuffer_->driveInit(sqlBufferSize, TRUE, SqlBuffer::NORMAL_); childOutputTD_ = inSqlBuffer_->add_tuple_desc(maxExtractRowLength_); endOfData_ = FALSE; } // ExFastExtractTcb::ExFastExtractTcb
short PhysSequence::codeGen(Generator *generator) { // Get a local handle on some of the generator objects. // CollHeap *wHeap = generator->wHeap(); Space *space = generator->getSpace(); ExpGenerator *expGen = generator->getExpGenerator(); MapTable *mapTable = generator->getMapTable(); // Allocate a new map table for this node. This must be done // before generating the code for my child so that this local // map table will be sandwiched between the map tables already // generated and the map tables generated by my offspring. // // Only the items available as output from this node will // be put in the local map table. Before exiting this function, all of // my offsprings map tables will be removed. Thus, none of the outputs // from nodes below this node will be visible to nodes above it except // those placed in the local map table and those that already exist in // my ancestors map tables. This is the standard mechanism used in the // generator for managing the access to item expressions. // MapTable *localMapTable = generator->appendAtEnd(); // Since this operation doesn't modify the row on the way down the tree, // go ahead and generate the child subtree. Capture the given composite row // descriptor and the child's returned TDB and composite row descriptor. // ex_cri_desc * givenCriDesc = generator->getCriDesc(Generator::DOWN); child(0)->codeGen(generator); ComTdb *childTdb = (ComTdb*)generator->getGenObj(); ex_cri_desc * childCriDesc = generator->getCriDesc(Generator::UP); ExplainTuple *childExplainTuple = generator->getExplainTuple(); // Make all of my child's outputs map to ATP 1. The child row is only // accessed in the project expression and it will be the second ATP // (ATP 1) passed to this expression. // localMapTable->setAllAtp(1); // My returned composite row has an additional tupp. // Int32 numberTuples = givenCriDesc->noTuples() + 1; ex_cri_desc * returnCriDesc #pragma nowarn(1506) // warning elimination = new (space) ex_cri_desc(numberTuples, space); #pragma warn(1506) // warning elimination // For now, the history buffer row looks just the return row. Later, // it may be useful to add an additional tupp for sequence function // itermediates that are not needed above this node -- thus, this // ATP is kept separate from the returned ATP. // const Int32 historyAtp = 0; const Int32 historyAtpIndex = numberTuples-1; #pragma nowarn(1506) // warning elimination ex_cri_desc *historyCriDesc = new (space) ex_cri_desc(numberTuples, space); #pragma warn(1506) // warning elimination ExpTupleDesc *historyDesc = 0; //seperate the read and retur expressions seperateReadAndReturnItems(wHeap); // The history buffer consists of items projected directly from the // child, the root sequence functions, the value arguments of the // offset functions, and running sequence functions. These elements must // be materialized in the history buffer in order to be able to compute // the outputs of this node -- the items projected directly from the child // (projectValues) and the root sequence functions (sequenceFunctions). // // Compute the set of sequence function items that must be materialized // int the history buffer. -- sequenceItems // // Compute the set of items in the history buffer: the union of the // projected values and the value arguments. -- historyIds // // Compute the set of items in the history buffer that are computed: // the difference between all the elements in the history buffer // and the projected items. -- computedHistoryIds // // KB---will need to return atp with 3 tups only 0,1 and 2 // 2 -->values from history buffer after ther are moved to it addCheckPartitionChangeExpr(generator, TRUE); ValueIdSet historyIds; historyIds += movePartIdsExpr(); historyIds += sequencedColumns(); ValueIdSet outputFromChild = child(0)->getGroupAttr()->getCharacteristicOutputs(); getHistoryAttributes(readSeqFunctions(),outputFromChild, historyIds, TRUE, wHeap); // Add in the top level sequence functions. historyIds += readSeqFunctions(); getHistoryAttributes(returnSeqFunctions(),outputFromChild, historyIds, TRUE, wHeap); // Add in the top level functions. historyIds += returnSeqFunctions(); // Layout the work tuple format which consists of the projected // columns and the computed sequence functions. First, compute // the number of attributes in the tuple. // ULng32 numberAttributes = ((NOT historyIds.isEmpty()) ? historyIds.entries() : 0); // Allocate an attribute pointer vector from the working heap. // Attributes **attrs = new(wHeap) Attributes*[numberAttributes]; // Fill in the attributes vector for the history buffer including // adding the entries to the map table. Also, compute the value ID // set for the elements to project from the child row. // //??????????re-visit this function?? computeHistoryAttributes(generator, localMapTable, attrs, historyIds); // Create the tuple descriptor for the history buffer row and // assign the offsets to the attributes. For now, this layout is // identical to the returned row. Set the tuple descriptors for // the return and history rows. // ULng32 historyRecLen; expGen->processAttributes(numberAttributes, attrs, ExpTupleDesc::SQLARK_EXPLODED_FORMAT, historyRecLen, historyAtp, historyAtpIndex, &historyDesc, ExpTupleDesc::SHORT_FORMAT); NADELETEBASIC(attrs, wHeap); #pragma nowarn(1506) // warning elimination returnCriDesc->setTupleDescriptor(historyAtpIndex, historyDesc); #pragma warn(1506) // warning elimination #pragma nowarn(1506) // warning elimination historyCriDesc->setTupleDescriptor(historyAtpIndex, historyDesc); #pragma warn(1506) // warning elimination // If there are any sequence function items, generate the sequence // function expressions. // ex_expr * readSeqExpr = NULL; if(NOT readSeqFunctions().isEmpty()) { ValueIdSet seqVals = readSeqFunctions(); seqVals += sequencedColumns(); seqVals += movePartIdsExpr(); expGen->generateSequenceExpression(seqVals, readSeqExpr); } ex_expr *checkPartChangeExpr = NULL; if (!checkPartitionChangeExpr().isEmpty()) { ItemExpr * newCheckPartitionChangeTree= checkPartitionChangeExpr().rebuildExprTree(ITM_AND,TRUE,TRUE); expGen->generateExpr(newCheckPartitionChangeTree->getValueId(), ex_expr::exp_SCAN_PRED, &checkPartChangeExpr); } //unsigned long rowLength; ex_expr * returnExpr = NULL; if(NOT returnSeqFunctions().isEmpty()) { expGen->generateSequenceExpression(returnSeqFunctions(), returnExpr); } // Generate expression to evaluate predicate on the output // ex_expr *postPred = 0; if (! selectionPred().isEmpty()) { ItemExpr * newPredTree = selectionPred().rebuildExprTree(ITM_AND,TRUE,TRUE); expGen->generateExpr(newPredTree->getValueId(), ex_expr::exp_SCAN_PRED, &postPred); } // Reset ATP's to zero for parent. // localMapTable->setAllAtp(0); // Generate expression to evaluate the cancel expression // ex_expr *cancelExpression = 0; if (! cancelExpr().isEmpty()) { ItemExpr * newCancelExprTree = cancelExpr().rebuildExprTree(ITM_AND,TRUE,TRUE); expGen->generateExpr(newCancelExprTree->getValueId(), ex_expr::exp_SCAN_PRED, &cancelExpression); } // // For overflow // // ( The following are meaningless if ! unlimitedHistoryRows() ) NABoolean noOverflow = CmpCommon::getDefault(EXE_BMO_DISABLE_OVERFLOW) == DF_ON ; NABoolean logDiagnostics = CmpCommon::getDefault(EXE_DIAGNOSTIC_EVENTS) == DF_ON ; NABoolean possibleMultipleCalls = generator->getRightSideOfFlow() ; short scratchTresholdPct = (short) CmpCommon::getDefaultLong(SCRATCH_FREESPACE_THRESHOLD_PERCENT); // determione the memory usage (amount of memory as percentage from total // physical memory used to initialize data structures) unsigned short memUsagePercent = (unsigned short) getDefault(BMO_MEMORY_USAGE_PERCENT); short memPressurePct = (short)getDefault(GEN_MEM_PRESSURE_THRESHOLD); historyRecLen = ROUND8(historyRecLen); Lng32 maxNumberOfOLAPBuffers; Lng32 maxRowsInOLAPBuffer; Lng32 minNumberOfOLAPBuffers; Lng32 numberOfWinOLAPBuffers; Lng32 olapBufferSize; computeHistoryParams(historyRecLen, maxRowsInOLAPBuffer, minNumberOfOLAPBuffers, numberOfWinOLAPBuffers, maxNumberOfOLAPBuffers, olapBufferSize); ComTdbSequence *sequenceTdb = new(space) ComTdbSequence(readSeqExpr, returnExpr, postPred, cancelExpression, getMinFollowingRows(), #pragma nowarn(1506) // warning elimination historyRecLen, historyAtpIndex, childTdb, givenCriDesc, returnCriDesc, (queue_index)getDefault(GEN_SEQFUNC_SIZE_DOWN), (queue_index)getDefault(GEN_SEQFUNC_SIZE_UP), getDefault(GEN_SEQFUNC_NUM_BUFFERS), getDefault(GEN_SEQFUNC_BUFFER_SIZE), olapBufferSize, maxNumberOfOLAPBuffers, numHistoryRows(), getUnboundedFollowing(), logDiagnostics, possibleMultipleCalls, scratchTresholdPct, memUsagePercent, memPressurePct, maxRowsInOLAPBuffer, minNumberOfOLAPBuffers, numberOfWinOLAPBuffers, noOverflow, checkPartChangeExpr); #pragma warn(1506) // warning elimination generator->initTdbFields(sequenceTdb); // update the estimated value of HistoryRowLength with actual value //setEstHistoryRowLength(historyIds.getRowLength()); double sequenceMemEst = getEstimatedRunTimeMemoryUsage(sequenceTdb); generator->addToTotalEstimatedMemory(sequenceMemEst); if(!generator->explainDisabled()) { Lng32 seqMemEstInKBPerCPU = (Lng32)(sequenceMemEst / 1024) ; seqMemEstInKBPerCPU = seqMemEstInKBPerCPU/ (MAXOF(generator->compilerStatsInfo().dop(),1)); generator->setOperEstimatedMemory(seqMemEstInKBPerCPU); generator-> setExplainTuple(addExplainInfo(sequenceTdb, childExplainTuple, 0, generator)); generator->setOperEstimatedMemory(0); } sequenceTdb->setScratchIOVectorSize((Int16)getDefault(SCRATCH_IO_VECTOR_SIZE_HASH)); sequenceTdb->setOverflowMode(generator->getOverflowMode()); sequenceTdb->setBmoMinMemBeforePressureCheck((Int16)getDefault(EXE_BMO_MIN_SIZE_BEFORE_PRESSURE_CHECK_IN_MB)); if(generator->getOverflowMode() == ComTdb::OFM_SSD ) sequenceTdb->setBMOMaxMemThresholdMB((UInt16)(ActiveSchemaDB()-> getDefaults()). getAsLong(SSD_BMO_MAX_MEM_THRESHOLD_IN_MB)); else sequenceTdb->setBMOMaxMemThresholdMB((UInt16)(ActiveSchemaDB()-> getDefaults()). getAsLong(EXE_MEMORY_AVAILABLE_IN_MB)); // The CQD EXE_MEM_LIMIT_PER_BMO_IN_MB has precedence over the mem quota sys NADefaults &defs = ActiveSchemaDB()->getDefaults(); UInt16 mmu = (UInt16)(defs.getAsDouble(EXE_MEM_LIMIT_PER_BMO_IN_MB)); UInt16 numBMOsInFrag = (UInt16)generator->getFragmentDir()->getNumBMOs(); if (mmu != 0) sequenceTdb->setMemoryQuotaMB(mmu); else { // Apply quota system if either one the following two is true: // 1. the memory limit feature is turned off and more than one BMOs // 2. the memory limit feature is turned on NABoolean mlimitPerCPU = defs.getAsDouble(EXE_MEMORY_LIMIT_PER_CPU) > 0; if ( mlimitPerCPU || numBMOsInFrag > 1 ) { double memQuota = computeMemoryQuota(generator->getEspLevel() == 0, mlimitPerCPU, generator->getBMOsMemoryLimitPerCPU().value(), generator->getTotalNumBMOsPerCPU(), generator->getTotalBMOsMemoryPerCPU().value(), numBMOsInFrag, generator->getFragmentDir()->getBMOsMemoryUsage() ); sequenceTdb->setMemoryQuotaMB( UInt16(memQuota) ); } } generator->setCriDesc(givenCriDesc, Generator::DOWN); generator->setCriDesc(returnCriDesc, Generator::UP); generator->setGenObj(this, sequenceTdb); return 0; }
void PhysSequence::computeHistoryParams(Lng32 histRecLength, Lng32 &maxRowsInOLAPBuffer, Lng32 &minNumberOfOLAPBuffers, Lng32 &numberOfWinOLAPBuffers, Lng32 &maxNumberOfOLAPBuffers, Lng32 &olapBufferSize) { Lng32 maxFWAdditionalBuffers = getDefault(OLAP_MAX_FIXED_WINDOW_EXTRA_BUFFERS); maxNumberOfOLAPBuffers = getDefault(OLAP_MAX_NUMBER_OF_BUFFERS); // For testing we may force a smaller max # rows in a buffer Lng32 forceMaxRowsInOLAPBuffer = getDefault(OLAP_MAX_ROWS_IN_OLAP_BUFFER); minNumberOfOLAPBuffers = 0; numberOfWinOLAPBuffers = 0; olapBufferSize = getDefault(OLAP_BUFFER_SIZE); Lng32 olapAvailableBufferSize = olapBufferSize - ROUND8(sizeof(HashBufferHeader)); // header // also consider the trailer reserved for DP2's checksum, for overflow only if ( getUnboundedFollowing() ) olapAvailableBufferSize -= 8 ; if ( histRecLength > olapAvailableBufferSize) { // history row exceeds size limit fir the overflow if (getUnboundedFollowing()) { *CmpCommon::diags() << DgSqlCode(-4390) << DgInt0(olapAvailableBufferSize); GenExit(); return ; } else { olapAvailableBufferSize = histRecLength; // Buffer needs to accomodate the header, but not the trailer (no O/F) olapBufferSize = histRecLength + ROUND8(sizeof(HashBufferHeader)) ; } } // Calculate the max # rows in a buffer maxRowsInOLAPBuffer = olapAvailableBufferSize / histRecLength ; // For testing - we may override the above max # rows if ( forceMaxRowsInOLAPBuffer > 0 && forceMaxRowsInOLAPBuffer < maxRowsInOLAPBuffer ) maxRowsInOLAPBuffer = forceMaxRowsInOLAPBuffer ; minNumberOfOLAPBuffers = numHistoryRows_ / maxRowsInOLAPBuffer; if ( numHistoryRows_ % maxRowsInOLAPBuffer >0) { minNumberOfOLAPBuffers++; } if (getUnboundedFollowing()) { numberOfWinOLAPBuffers = minFollowingRows_/maxRowsInOLAPBuffer ; if (minFollowingRows_ % maxRowsInOLAPBuffer >0) { numberOfWinOLAPBuffers++; } if (numberOfWinOLAPBuffers +1 > minNumberOfOLAPBuffers) { minNumberOfOLAPBuffers = numberOfWinOLAPBuffers +1 ; } //produce an error here if maxNumberOfOLAPBuffers < minNumberOfOLAPBuffers } else { maxNumberOfOLAPBuffers = minNumberOfOLAPBuffers + maxFWAdditionalBuffers; } }
// ExSequenceTcb constructor // // 1. Allocate buffer pool. // 2. Allocate parent queues and initialize private state. // 3. Fixup expressions. // ExSequenceTcb::ExSequenceTcb (const ExSequenceTdb & myTdb, const ex_tcb & child_tcb, ex_globals * glob) : ex_tcb(myTdb, 1, glob), lastRow_(NULL), clusterDb_(NULL), cluster_(NULL), ioEventHandler_(NULL), OLAPBuffersFlushed_(FALSE), firstOLAPBuffer_(NULL), lastOLAPBuffer_(NULL), rc_(EXE_OK), olapBufferSize_(0), maxNumberOfOLAPBuffers_(0), numberOfOLAPBuffers_(0), minNumberOfOLAPBuffers_(0), memoryPressureDetected_(FALSE) { Space * space = (glob ? glob->getSpace() : 0); CollHeap * heap = (glob ? glob->getDefaultHeap() : 0); heap_ = heap; childTcb_ = &child_tcb; // Allocate the buffer pool #pragma nowarn(1506) // warning elimination pool_ = new(space) sql_buffer_pool(myTdb.numBuffers_, myTdb.bufferSize_, space); allocRowLength_ = ROUND8(myTdb.recLen_); #pragma warn(1506) // warning elimination // Initialize the machinery for maintaining the row history for // computing sequence functions. // maxNumberHistoryRows_ = myTdb.maxHistoryRows_; minFollowing_ = myTdb.minFollowing_; unboundedFollowing_ = myTdb.isUnboundedFollowing(); maxNumberOfOLAPBuffers_ = myTdb.maxNumberOfOLAPBuffers_;//testing olapBufferSize_ = myTdb.OLAPBufferSize_ ; maxRowsInOLAPBuffer_ = myTdb.maxRowsInOLAPBuffer_; minNumberOfOLAPBuffers_ = myTdb.minNumberOfOLAPBuffers_; numberOfWinOLAPBuffers_ = myTdb.numberOfWinOLAPBuffers_; overflowEnabled_ = ! myTdb.isNoOverflow(); ex_assert( maxNumberOfOLAPBuffers_ >= minNumberOfOLAPBuffers_ , "maxNumberOfOLAPBuffers is too small"); // Initialize history parameters // For unbounded following -- also create/initialize clusterDb, cluster initializeHistory(); // get the queue that child use to communicate with me qchild_ = child_tcb.getParentQueue(); // Allocate the queue to communicate with parent qparent_.down = new(space) ex_queue(ex_queue::DOWN_QUEUE, myTdb.initialQueueSizeDown_, myTdb.criDescDown_, space); // Allocate the private state in each entry of the down queue ExSequencePrivateState *p = new(space) ExSequencePrivateState(this); qparent_.down->allocatePstate(p, this); delete p; qparent_.up = new(space) ex_queue(ex_queue::UP_QUEUE, myTdb.initialQueueSizeUp_, myTdb.criDescUp_, space); // Intialized processedInputs_ to the next request to process processedInputs_ = qparent_.down->getTailIndex(); workAtp_ = allocateAtp(myTdb.criDescUp_, space); // Fixup the sequence function expression. This requires the standard // expression fixup plus initializing the GetRow method for the sequence // clauses. // if (sequenceExpr()) { ((ExpSequenceExpression*)sequenceExpr())->seqFixup ((void*)this, GetHistoryRow, GetHistoryRowOLAP); sequenceExpr()->fixup(0, getExpressionMode(), this, space, heap_, FALSE, glob); } if (returnExpr()) { ((ExpSequenceExpression*)returnExpr())->seqFixup ((void*)this, GetHistoryRow, GetHistoryRowFollowingOLAP); returnExpr()->fixup(0, getExpressionMode(), this, space, heap_, FALSE, glob); } if (postPred()) postPred()->fixup(0, getExpressionMode(), this, space, heap_, FALSE, glob); if (cancelExpr()) cancelExpr()->fixup(0, getExpressionMode(), this, space, heap_, FALSE, glob); if (checkPartitionChangeExpr()) { ((ExpSequenceExpression*)checkPartitionChangeExpr())->seqFixup ((void*)this, GetHistoryRow, GetHistoryRowOLAP); checkPartitionChangeExpr()->fixup(0, getExpressionMode(), this, space, heap_, FALSE, glob); } }
/* ** Return the size of the header added by this middleware layer ** in the page-cache hierarchy. */ int sqlite3HeaderSizePcache(void){ return ROUND8(sizeof(PgHdr)); }
Lng32 CmpCompileInfo::getVarLength() { return ROUND8(sqlTextLen_) + ROUND8(schemaNameLen_) + ROUND8(recompControlInfoLen_); }
/* ** Round up a request size to the next valid allocation size. */ static int sqlite3MemRoundup(int n){ return ROUND8(n); }
ECode CCallbackParcel::WriteValue( /* [in] */ PVoid value, /* [in] */ Int32 type, /* [in] */ Int32 size) { ECode ec; Int32 used, len; if (mElemCount >= mTypeBufCapacity) { ec = GrowTypeBuffer(); if (FAILED(ec)) return ec; } if (mElemPtr - mElemBuf + 4 > mElemBufCapacity) { ec = GrowElemBuffer(); if (FAILED(ec)) return ec; } mElemTypes[mElemCount] = (Byte)type; switch(type) { case Type_Byte: case Type_Boolean: *(Int32*)(mElemPtr) = *((Byte*)value); mElemPtr += 4; break; case Type_Int16: *(Int32*)(mElemPtr) = *((Int16*)value); mElemPtr += 4; break; case Type_Char32: case Type_Int32: case Type_Float: *(Int32*)(mElemPtr) = *(Int32*)value; mElemPtr += 4; break; case Type_Int64: case Type_Double: if (mElemPtr - mElemBuf + 4 + 4 > mElemBufCapacity) { ec = GrowElemBuffer(); if (FAILED(ec)) return ec; } #if defined(_arm) && defined(__GNUC__) && (__GNUC__ >= 4) mElemPtr = (Byte*)ROUND8((Int32)mElemPtr); #endif *(Int32*)(mElemPtr) = (Int32)(*((Int64*)value) & 0xffffffff); *(Int32*)(mElemPtr + 4) = (Int32)((*((Int64*)value) >> 32) & 0xffffffff); mElemPtr += 8; break; case Type_String: { String* p = new String(); *p = *(String*)value; *(String**)mElemPtr = p; mElemPtr += 4; break; } case Type_InterfacePtr: *(IInterface**)mElemPtr = *(IInterface**)value; if ((*(IInterface**)mElemPtr) != NULL) { (*(IInterface**)mElemPtr)->AddRef(); } mElemPtr += 4; break; case Type_Struct: if (mDataPtr - mDataBuf + ROUND4(size) + 4 > mDataBufCapacity) { ec = GrowDataBuffer(ROUND4(size) + 4); if (FAILED(ec)) return ec; } *(Int32*)mDataPtr = size; mDataPtr += 4; *(Byte**)(mElemPtr) = mDataPtr; mElemPtr += 4; memcpy(mDataPtr, value, size); mDataPtr += ROUND4(size); break; case Type_EMuid: if (mDataPtr - mDataBuf + ROUND4(size) > mDataBufCapacity) { ec = GrowDataBuffer(ROUND4(size)); if (FAILED(ec)) return ec; } *(EMuid**)(mElemPtr) = (EMuid*)mDataPtr; mElemPtr += 4; memcpy(mDataPtr, value, size); mDataPtr += size; break; case Type_EGuid: if (mDataPtr - mDataBuf + ROUND4(size) > mDataBufCapacity) { ec = GrowDataBuffer(ROUND4(size)); if (FAILED(ec)) return ec; } *(EGuid**)(mElemPtr) = (EGuid*)mDataPtr; mElemPtr += 4; memcpy(mDataPtr, value, sizeof(EGuid)); ((EGuid*)mDataPtr)->mUunm = (char*)(mDataPtr + sizeof(EGuid)); strcpy(((EGuid*)mDataPtr)->mUunm, ((EGuid*)value)->mUunm); mDataPtr += ROUND4(size); break; case Type_ArrayOf: if (value == NULL) { *(Byte**)(mElemPtr) = NULL; mElemPtr += 4; } else { if (mDataPtr - mDataBuf + ROUND4(size + 4) + 4 > mDataBufCapacity) { ec = GrowDataBuffer(ROUND4(size + 4) + 4); if (FAILED(ec)) return ec; } *(Int32*)mDataPtr = size; mDataPtr += 4; *(Byte**)(mElemPtr) = mDataPtr; mElemPtr += 4; memcpy(mDataPtr, value, sizeof(CarQuintet)); mDataPtr += ROUND4(sizeof(CarQuintet)); (*(CarQuintet**)(mElemPtr - 4))->mBuf = (PVoid)(mDataPtr); memcpy(mDataPtr, ((CarQuintet*)value)->mBuf, size - sizeof(CarQuintet)); mDataPtr += ROUND4(size - sizeof(CarQuintet)); } break; case Type_ArrayOfString: used = ((ArrayOf<String>*)value)->GetLength(); if (mDataPtr - mDataBuf + ROUND4(size) + 4 > mDataBufCapacity) { ec = GrowDataBuffer(ROUND4(size) + 4); if (FAILED(ec)) return ec; } *(Int32*)mDataPtr = size; mDataPtr += 4; *(Byte**)(mElemPtr) = mDataPtr; mElemPtr += 4; memcpy(mDataPtr, value, sizeof(CarQuintet)); mDataPtr += ROUND4(sizeof(CarQuintet)); (*(CarQuintet**)(mElemPtr - 4))->mBuf = (PVoid)(mDataPtr); mDataPtr += ROUND4(((CarQuintet*)value)->mSize); for(Int32 i = 0; i < used; i++) { (**(ArrayOf<String>**)(mElemPtr - 4))[i] = (const char*)mDataPtr; if ((*(ArrayOf<String>*)value)[i]) { len = (strlen((*(ArrayOf<String>*)value)[i]) + 1); memcpy((void*)(const char*)(**(ArrayOf<String>**)(mElemPtr - 4))[i], (*(ArrayOf<String>*)value)[i], len); mDataPtr += ROUND4(len); } else (**(ArrayOf<String>**)(mElemPtr - 4))[i] = NULL; } break; default: assert(0); break; } mElemCount += 1; return NOERROR; }
LmRoutineCSql::LmRoutineCSql(const char *sqlName, const char *externalName, const char *librarySqlName, ComUInt32 numSqlParam, char *routineSig, ComUInt32 maxResultSets, ComRoutineTransactionAttributes transactionAttrs, ComRoutineSQLAccess sqlAccessMode, ComRoutineExternalSecurity externalSecurity, Int32 routineOwnerId, const char *parentQid, ComUInt32 inputRowLen, ComUInt32 outputRowLen, const char *currentUserName, const char *sessionUserName, LmParameter *parameters, LmLanguageManagerC *lm, LmHandle routine, LmContainer *container, ComDiagsArea *diagsArea) : LmRoutineC(sqlName, externalName, librarySqlName, numSqlParam, routineSig, maxResultSets, COM_LANGUAGE_C, COM_STYLE_SQL, transactionAttrs, sqlAccessMode, externalSecurity, routineOwnerId, parentQid, inputRowLen, outputRowLen, currentUserName, sessionUserName, parameters, lm, routine, container, diagsArea), cBuf_(NULL), data_(NULL), ind_(numSqlParam * sizeof(short)) { ComUInt32 i = 0; data_ = (char **) collHeap()->allocateMemory(numSqlParam * sizeof(char *)); // Allocate C data buffers. Each LmCBuffer instance points to a C // buffer and the data_ buffer is an array of pointers to the C data // buffers. The LmCBuffer is mainly used to track the actual size of // the C buffers because each buffer has some extra bytes at the end // to protect against buffer overwrites. // // cBuf_ -> LmCBuffer LmCBuffer LmCBuffer ... // | | | // v v v // buffer buffer buffer ... // ^ ^ ^ // | | | // data_[0] data_[1] data_[2] ... // // NOTE: the cBuf_ array is allocated on the C++ heap because we // want to manage the collection as a single array, and we want // constructors and destructors to be called when the collection is // created and destroyed. Right now, NAMemory and NABasic object // interfaces do not provide the appropriate array versions of new // and delete operators to accomplish these things. cBuf_ = new LmCBuffer[numSqlParam_]; LM_ASSERT(cBuf_); for (i = 0; i < numSqlParam_; i++) { LmParameter &p = lmParams_[i]; LmCBuffer &cBuf = cBuf_[i]; ComUInt32 dataBytes = 0; switch (p.direction()) { // NOTE: The code currently supports IN and OUT parameters for C // routines. There is no reason we couldn't support INOUT as // well, which will be needed if we ever provide stored // procedures written in C. But the INOUT code paths have not // been implemented yet. case COM_INPUT_COLUMN: dataBytes = p.inSize(); break; case COM_OUTPUT_COLUMN: dataBytes = p.outSize(); break; default: LM_ASSERT(0); break; } switch (p.fsType()) { case COM_VCHAR_FSDT: case COM_VCHAR_DBL_FSDT: { // VARCHAR(N) CHARACTER SET ISO88591 // VARCHAR(N) CHARACTER SET UCS2 // This is a VARCHAR parameter. Allocate one buffer that will // hold the VC struct and the data. Data will begin at the first // 8-byte boundary following the VC struct. ComUInt32 vcBytes = ROUND8(sizeof(SQLUDR_VC_STRUCT)) + dataBytes; cBuf.init(vcBytes); data_[i] = cBuf.getBuffer(); // Initialize the VC struct SQLUDR_VC_STRUCT *vc = (SQLUDR_VC_STRUCT *) cBuf.getBuffer(); char *charPtr = (char *) vc; vc->data = charPtr + ROUND8(sizeof(SQLUDR_VC_STRUCT)); vc->length = dataBytes; } break; case COM_FCHAR_FSDT: case COM_FCHAR_DBL_FSDT: case COM_SIGNED_DECIMAL_FSDT: case COM_UNSIGNED_DECIMAL_FSDT: case COM_DATETIME_FSDT: case COM_SIGNED_NUM_BIG_FSDT: case COM_UNSIGNED_NUM_BIG_FSDT: { // CHAR(N) CHARACTER SET ISO88591 // CHAR(N) CHARACTER SET UCS2 // DECIMAL [UNSIGNED] // DATE, TIME, TIMESTAMP // NUMERIC precision > 18 // These types require a null-terminated C string. Add one to // dataBytes to account for the null terminator. cBuf.init(dataBytes + 1); data_[i] = cBuf.getBuffer(); } break; default: { // All other types cBuf.init(dataBytes); data_[i] = cBuf.getBuffer(); } break; } // switch (p.fsType()) } // for each param } // LmRoutineCSql::LmRoutineCSql
Lng32 CmpCompileInfo::getLength() { Lng32 sizeOfThis = getClassSize(); Lng32 totalLength = ROUND8(sizeOfThis) + getVarLength(); return totalLength; }