Exemplo n.º 1
0
void ElemDDLUdfOptimizationHint::synthesize(void)
{
  if (getOptimizationKind() NEQ COM_UDF_NUMBER_OF_UNIQUE_OUTPUT_VALUES OR
      uniqueOutputValuesParseTree_ EQU NULL)
    return;

  NABoolean    isErrMsgIssued = FALSE;
  ComSInt64    value = 0;
  ItemExpr   * pItemExpr = NULL;
  ConstValue * pConstVal = NULL;
  for (CollIndex i = 0; i < uniqueOutputValuesParseTree_->entries(); i++)
  {
    pItemExpr = (*uniqueOutputValuesParseTree_)[i];
    pConstVal = (ConstValue *)pItemExpr;
    if (NOT pConstVal->canGetExactNumericValue() AND NOT isErrMsgIssued)
    {
      *SqlParser_Diags << DgSqlCode(-3017) << DgString0(pConstVal->getConstStr());
      isErrMsgIssued = TRUE;
    }
    value = pConstVal->getExactNumericValue();
    uniqueOutputValues_.insert(value);
    if (value < -1 AND NOT isErrMsgIssued) // only issue the error message once
    {
      // Error: Expected a positive value or -1 (representing the default SYSTEM setting option)
      NAString valueStr = Int64ToNAString(value);
      *SqlParser_Diags << DgSqlCode(-3017) << DgString0(valueStr);
      isErrMsgIssued = TRUE;
    }
  } // for
} // ElemDDLUdfOptimizationHint::synthesize()
Exemplo n.º 2
0
NABoolean CmpSPOutputFormat::ElemDDLColDef2ColumnDescStruct
  (ElemDDLColDef* elem,
  const char* tableName,
  columns_desc_struct* colDesc)
{
  // Just copy the pointer for this name --
  // no need to alloc + strcpy a la copyString
  colDesc->tablename = (char *)tableName;

  colDesc->colname = copyString(elem->getColumnName());

  // colDesc->colnumber, filled outside
  
  NAType* genericType = elem->getColumnDataType();  
  colDesc->datatype = (DataType) genericType->getFSDatatype();
  colDesc->length = genericType->getNominalSize();
  colDesc->pictureText = (char *)emptyString;

  // The logic for converting from an NAType to column_desc is also
  // in the catman code -- readRealArk.cpp::convertColumn(). Any changes
  // there must be reflected here as well and vice versa.

  if ( genericType->getTypeQualifier() == NA_NUMERIC_TYPE )
    {
      NumericType & nt = *((NumericType*)genericType);
      colDesc->scale = nt.getScale();

      // if this is a float (real or double) datatype,
      // then get the precision. Otherwise, for other
      // numeric type, get the precision only if it
      // is not binary precision.
      if(nt.isExact() && nt.binaryPrecision() &&
       (nt.getFSDatatype() != REC_BPINT_UNSIGNED))
      {
        colDesc->precision = 0;
      }
      else
      {
        colDesc->precision = nt.getPrecision();
      }
    }
  else 
    {
      colDesc->scale = 0;
      colDesc->precision = 0;      
    }

#pragma nowarn(1506)   // warning elimination 
  if ( genericType->getTypeQualifier() == NA_CHARACTER_TYPE )
    {
      CharType & charType = (CharType &) *genericType;
      colDesc->character_set	  = charType.getCharSet();
      colDesc->encoding_charset	  = charType.getEncodingCharSet();
      colDesc->collation_sequence = charType.getCollation();
      colDesc->upshift		  = charType.isUpshifted();
    }

  if ( genericType->getTypeQualifier() == NA_DATETIME_TYPE ||
       genericType->getTypeQualifier() == NA_INTERVAL_TYPE )
  {
      DatetimeIntervalCommonType& dti = 
        (DatetimeIntervalCommonType& )*genericType;
      colDesc->datetimestart = dti.getStartField();
      colDesc->datetimeend = dti.getEndField();
      colDesc->datetimefractprec = dti.getFractionPrecision();
      colDesc->intervalleadingprec = dti.getLeadingPrecision();
  }
#pragma warn(1506)   // warning elimination 
  
  // offset, to be done (do we need it?)

  colDesc->null_flag = NOT elem->isNotNullConstraintSpecified();
  
  colDesc->colclass = 'U';
  colDesc->addedColumn = 0;
  colDesc->uec = (Cardinality)0;
  colDesc->highval = colDesc->lowval = 0;
  
  // defaultclass, to be done? (not referenced, not needed)

  ConstValue *pDefVal = (ConstValue*)elem->getDefaultValueExpr();
  if (!pDefVal || pDefVal->isNull())
    colDesc->defaultvalue = NULL;
  else
    colDesc->defaultvalue = copyString(pDefVal->getConstStr());
  
  return TRUE;
}