Ejemplo n.º 1
0
void SimpleColumn::setOID()
{
	boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(fSessionID);
	CalpontSystemCatalog::TableColName tcn;
	tcn = make_tcn(fSchemaName, fTableName, fColumnName);

	fOid = csc->lookupOID (tcn);
	if (fOid == -1)
	{
		// get colMap from CalpontSelectExecutionPlan
		// and try to map the schema and table name
		CalpontSelectExecutionPlan::ColumnMap::iterator iter;
		CalpontSelectExecutionPlan::ColumnMap colMap = CalpontSelectExecutionPlan::colMap();

		// if this is the only column name exist in the map, return it ??
		for (iter = colMap.find(fColumnName); iter != colMap.end(); ++iter)
		{
			SRCP srcp = iter->second;
			SimpleColumn* scp = dynamic_cast<SimpleColumn*>(srcp.get());
			if (colMap.count(fColumnName) == 1 ||
			    scp->tableName().compare(fTableName) == 0)
			{
				fOid = scp->oid();
				//@bug 221 fix
				fTableName = scp->tableName();
				fSchemaName = scp->schemaName();
				//@info assign tableAlias also. watch for other conflict
				fTableAlias = scp->tableAlias();
				fResultType = scp->resultType();
				return;
			}
		}
	}
	fResultType = csc->colType(fOid);
}
Ejemplo n.º 2
0
void* ing_opentbl(void* qctx, const char* sn, const char* tn)
{
try {
	if (!qctx) return 0;
	if (!sn) return 0;
	if (!tn) return 0;
	if (strlen(sn) == 0) return 0;
	if (strlen(tn) == 0) return 0;

	IngQCtx* ingQctx = reinterpret_cast<IngQCtx*>(qctx);
	cpsm_conhdl_t* cal_conn_hndl = reinterpret_cast<cpsm_conhdl_t*>(ingQctx->dhcs_ses_ctx);
	IngTCtx* tctx = new IngTCtx();

	dhcs_tableid_t tableid = 0;
	//tableid = tbname2id(sn, tn, cal_conn_hndl);
	tableid = tbname2id("te", "f_trans", cal_conn_hndl);

	RequiredColOidSet requiredColOidSet;
	const CalpontSelectExecutionPlan::ColumnMap colMap = ingQctx->csep.columnMap();
	CalpontSelectExecutionPlan::ColumnMap::const_iterator colIter = colMap.begin();
	CalpontSelectExecutionPlan::ColumnMap::const_iterator colend = colMap.end();
	while (colIter != colend)
	{
		SRCP srcp = colIter->second;
		SimpleColumn* scp = dynamic_cast<SimpleColumn*>(srcp.get());
		if (scp)
			requiredColOidSet.insert(scp->oid());
		++colIter;
	}
	tctx->dhcs_tpl_ctx = new cpsm_tplh_t();
	dhcs_tpl_open(tableid, &tctx->dhcs_tpl_ctx, ingQctx->dhcs_ses_ctx, requiredColOidSet);
	tctx->dhcs_tpl_scan_ctx = new cpsm_tplsch_t();
	dhcs_tpl_scan_open(tableid, DHCS_TPL_FH_READ, &tctx->dhcs_tpl_scan_ctx, ingQctx->dhcs_ses_ctx);

	return tctx;
} catch (...) {
}
	return NULL;
}