Ejemplo n.º 1
0
const NAString
StmtDDLDropView::displayLabel2() const
{
  NAString label2("Drop behavior: ");
  switch (getDropBehavior())
  {
  case COM_CASCADE_DROP_BEHAVIOR :
    return label2 + "Cascade";

  case COM_RESTRICT_DROP_BEHAVIOR :
    return label2 + "Restrict";

  default :
    NAAbort("StmtDDLDrop.C", __LINE__, "internal logic error");
    return NAString();
  }
}
void
ParDDLLikeOptsCreateTable::setLikeOption(ElemDDLLikeOpt * pLikeOption)
{
  ComASSERT(pLikeOption != NULL);
  
  switch (pLikeOption->getOperatorType())
  {
  case ELM_LIKE_OPT_WITHOUT_CONSTRAINTS_ELEM :
    if (isLikeOptWithoutConstraintsSpec_)
    {
      *SqlParser_Diags << DgSqlCode(-3149);

      //  "*** Error *** Duplicate WITHOUT CONSTRAINTS phrases "
      //  << "in LIKE clause" << endl;
    }
    ComASSERT(pLikeOption->castToElemDDLLikeOptWithoutConstraints() != NULL);
    isLikeOptWithoutConstraints_ = TRUE;
    isLikeOptWithoutConstraintsSpec_ = TRUE;
    break;

  case ELM_LIKE_OPT_WITH_HEADINGS_ELEM :
    if (isLikeOptWithHeadingsSpec_)
    {
      *SqlParser_Diags << DgSqlCode(-3150);
      //      cout << "*** Error *** Duplicate WITH HEADING phrases "
      //  << "in LIKE clause" << endl;
    }
    ComASSERT(pLikeOption->castToElemDDLLikeOptWithHeadings() != NULL);
    isLikeOptWithHeadings_ = TRUE;
    isLikeOptWithHeadingsSpec_ = TRUE;
    break;

  case ELM_LIKE_OPT_WITH_HORIZONTAL_PARTITIONS_ELEM :
    if (isLikeOptWithHorizontalPartitionsSpec_)
    {
      *SqlParser_Diags << DgSqlCode(-3151);
      //cout << "*** Error *** Duplicate WITH HORIZONTAL PARTITIONS phrases "
      //  << "in LIKE clause" << endl;
    }
    ComASSERT(pLikeOption->castToElemDDLLikeOptWithHorizontalPartitions() != NULL);
    isLikeOptWithHorizontalPartitions_ = TRUE;
    isLikeOptWithHorizontalPartitionsSpec_ = TRUE;
    break;

  case ELM_LIKE_OPT_WITHOUT_SALT_ELEM :
    if (isLikeOptWithoutSaltSpec_)
    {
      // ERROR[3152] Duplicate WITHOUT SALT phrases were specified
      //             in LIKE clause in CREATE TABLE statement.
      *SqlParser_Diags << DgSqlCode(-3152) << DgString0("SALT");
    }
    ComASSERT(pLikeOption->castToElemDDLLikeOptWithoutSalt() != NULL);
    isLikeOptWithoutSalt_ = TRUE;
    isLikeOptWithoutSaltSpec_ = TRUE;
    break;

  case ELM_LIKE_OPT_WITHOUT_DIVISION_ELEM :
    if (isLikeOptWithoutDivisionSpec_)
    {
      // ERROR[3152] Duplicate WITHOUT DIVISION phrases were specified
      //             in LIKE clause in CREATE TABLE statement.
      *SqlParser_Diags << DgSqlCode(-3152) << DgString0("DIVISION");
    }
    ComASSERT(pLikeOption->castToElemDDLLikeOptWithoutDivision() != NULL);
    isLikeOptWithoutDivision_ = TRUE;
    isLikeOptWithoutDivisionSpec_ = TRUE;
    break;

  default :
    NAAbort("ParDDLLikeOpts.C", __LINE__, "internal logic error");
    break;
  }
} // ParDDLLikeOptsCreateTable::setLikeOption()
Ejemplo n.º 3
0
const NAString
StmtDDLNode::getText() const
{
    NAAbort("StmtDDLNode.C", __LINE__, "internal logic error");
    return "StmtDDLNode";
}
void
ParDDLLikeOptsCreateTable::setLikeOption(ElemDDLLikeOpt * pLikeOption)
{
  ComASSERT(pLikeOption != NULL);
  
  switch (pLikeOption->getOperatorType())
  {
  case ELM_LIKE_OPT_WITHOUT_CONSTRAINTS_ELEM :
    if (isLikeOptWithoutConstraintsSpec_)
    {
      *SqlParser_Diags << DgSqlCode(-3149);

      //  "*** Error *** Duplicate WITHOUT CONSTRAINTS phrases "
      //  << "in LIKE clause" << endl;
    }
    ComASSERT(pLikeOption->castToElemDDLLikeOptWithoutConstraints() != NULL);
    isLikeOptWithoutConstraints_ = TRUE;
    isLikeOptWithoutConstraintsSpec_ = TRUE;
    break;

  case ELM_LIKE_OPT_WITH_HEADINGS_ELEM :
    if (isLikeOptWithHeadingsSpec_)
    {
      *SqlParser_Diags << DgSqlCode(-3150);
      //      cout << "*** Error *** Duplicate WITH HEADING phrases "
      //  << "in LIKE clause" << endl;
    }
    ComASSERT(pLikeOption->castToElemDDLLikeOptWithHeadings() != NULL);
    isLikeOptWithHeadings_ = TRUE;
    isLikeOptWithHeadingsSpec_ = TRUE;
    break;

  case ELM_LIKE_OPT_WITH_HORIZONTAL_PARTITIONS_ELEM :
    if (isLikeOptWithHorizontalPartitionsSpec_)
    {
      *SqlParser_Diags << DgSqlCode(-3151);
      //cout << "*** Error *** Duplicate WITH HORIZONTAL PARTITIONS phrases "
      //  << "in LIKE clause" << endl;
    }
    ComASSERT(pLikeOption->castToElemDDLLikeOptWithHorizontalPartitions() != NULL);
    isLikeOptWithHorizontalPartitions_ = TRUE;
    isLikeOptWithHorizontalPartitionsSpec_ = TRUE;
    break;

  case ELM_LIKE_OPT_WITHOUT_SALT_ELEM :
    if (isLikeOptWithoutSaltSpec_)
    {
      // ERROR[3152] Duplicate WITHOUT SALT phrases were specified
      //             in LIKE clause in CREATE TABLE statement.
      *SqlParser_Diags << DgSqlCode(-3152) << DgString0("SALT");
    }
    if (isLikeOptSaltClauseSpec_)
    {
      // ERROR[3154] The WITHOUT SALT clause is not allowed with the SALT clause.
      *SqlParser_Diags << DgSqlCode(-3154) << DgString0("WITHOUT SALT") << DgString1("SALT");
    }
    ComASSERT(pLikeOption->castToElemDDLLikeOptWithoutSalt() != NULL);
    isLikeOptWithoutSalt_ = TRUE;
    isLikeOptWithoutSaltSpec_ = TRUE;
    break;

  case ELM_LIKE_OPT_SALT_CLAUSE_ELEM:
    {  // braces needed since we declare some variables in this case
      if (isLikeOptSaltClauseSpec_)
      {
        // ERROR[3183] Duplicate SALT clauses were specified.
        *SqlParser_Diags << DgSqlCode(-3183) << DgString0("SALT");
      }
      if (isLikeOptWithoutSaltSpec_)
      {
        // ERROR[3154] The WITHOUT SALT clause is not allowed with the SALT clause.
        *SqlParser_Diags << DgSqlCode(-3154) << DgString0("WITHOUT SALT") << DgString1("SALT");
      }
      ComASSERT(pLikeOption->castToElemDDLLikeSaltClause() != NULL);
      isLikeOptSaltClauseSpec_ = TRUE;
      isLikeOptSaltClause_ = new (PARSERHEAP()) NAString();
      ElemDDLLikeSaltClause * saltClauseWrapper = pLikeOption->castToElemDDLLikeSaltClause();
      const ElemDDLSaltOptionsClause * saltOptions = saltClauseWrapper->getSaltClause();
      saltOptions->unparseIt(*isLikeOptSaltClause_ /* side-effected */);
      isLikeOptWithoutSalt_ = TRUE;  // suppresses any SALT clause from the source table
    }
    break;

  case ELM_LIKE_OPT_WITHOUT_DIVISION_ELEM :
    if (isLikeOptWithoutDivisionSpec_)
    {
      // ERROR[3152] Duplicate WITHOUT DIVISION phrases were specified
      //             in LIKE clause in CREATE TABLE statement.
      *SqlParser_Diags << DgSqlCode(-3152) << DgString0("DIVISION");
    }
    ComASSERT(pLikeOption->castToElemDDLLikeOptWithoutDivision() != NULL);
    isLikeOptWithoutDivision_ = TRUE;
    isLikeOptWithoutDivisionSpec_ = TRUE;
    break;

  case ELM_LIKE_OPT_LIMIT_COLUMN_LENGTH:
    {
      if (isLikeOptLimitColumnLengthSpec_)
      {
        // ERROR[3152] Duplicate LIMIT COLUMN LENGTH phrases were specified
        //             in LIKE clause in CREATE TABLE statement.
        *SqlParser_Diags << DgSqlCode(-3152) << DgString0("LIMIT COLUMN LENGTH");
      }
      ComASSERT(pLikeOption->castToElemDDLLikeLimitColumnLength() != NULL);
      ElemDDLLikeLimitColumnLength * limitColumnLength = 
        pLikeOption->castToElemDDLLikeLimitColumnLength();
      isLikeOptColumnLengthLimit_ = limitColumnLength->getColumnLengthLimit();
      isLikeOptLimitColumnLengthSpec_ = TRUE;
    }
    break;

  case ELM_LIKE_OPT_WITHOUT_ROW_FORMAT_ELEM :
    if (isLikeOptWithoutRowFormatSpec_)
    {
      // ERROR[3152] Duplicate WITHOUT ROW FORMAT phrases were specified
      //             in LIKE clause in CREATE TABLE statement.
      *SqlParser_Diags << DgSqlCode(-3152) << DgString0("ROW FORMAT");
    }
    ComASSERT(pLikeOption->castToElemDDLLikeOptWithoutRowFormat() != NULL);
    isLikeOptWithoutRowFormat_ = TRUE;
    isLikeOptWithoutRowFormatSpec_ = TRUE;
    break;

  default :
    NAAbort("ParDDLLikeOpts.C", __LINE__, "internal logic error");
    break;
  }
} // ParDDLLikeOptsCreateTable::setLikeOption()
ExprNode *
ElemDDLPartitionSystem::bindNode(BindWA * /*pBindWA*/)
{
  //
  // location
  //
  ComLocationName defaultLocName;  // empty object

  if (getLocationName().isNull())
    //
    // location clause not specified (only allowed for primary partition)
    //
    guardianLocation_ =
      defaultLocName.getGuardianFullyQualifiedName();
  else  // LOCATION clause was specified
  {
    ComLocationName locName;         // empty object
    switch (getLocationNameType())
    {
    case ElemDDLLocation::LOCATION_GUARDIAN_NAME :
      locName.copy(getLocationName(),
                   ComLocationName::GUARDIAN_LOCATION_NAME_FORMAT);
      if (NOT locName.isValid())
      {
        // Illegal location name format.
        *SqlParser_Diags << DgSqlCode(-3061) << DgString0(getLocationName());
        guardianLocation_ =
          defaultLocName.getGuardianFullyQualifiedName();
      }
      else  // valid location
        guardianLocation_ =
          locName.getGuardianFullyQualifiedName();
      break;

    case ElemDDLLocation::LOCATION_OSS_NAME :
      locName.copy(getLocationName(),
                   ComLocationName::OSS_LOCATION_NAME_FORMAT);
      if (NOT locName.isValid())
      {
        // Illegal location name format.
        *SqlParser_Diags << DgSqlCode(-3061) << DgString0(getLocationName());
        guardianLocation_ =
          defaultLocName.getGuardianFullyQualifiedName();
      }
      else  // valid location
        guardianLocation_ =
          locName.getGuardianFullyQualifiedName();
      break;

#if 0
      //
      // Currently we do not handle this case
      // The grammar productions don't accept this syntax.
      // So comment out the following code for now.
      //
    case ElemDDLLocation::LOCATION_ENVIRONMENT_VARIABLE :
      {
        NAString envVarName(getLocationName());
        //
        // if the specified OSS environment variable has the
        // dollar sign prefix, removes it.
        //
	    if (envVarName[(size_t) 0] EQU '$')            // NT_PORT FIX SK 07/15/96
        {
          envVarName = envVarName(1/*startpos*/, envVarName.length() - 1);
        }
        const char * pEnvVarValue = getenv((const char *)envVarName);
        NAString locationName;
        if (pEnvVarValue NEQ NULL)
        {
          locationName = pEnvVarValue;
        }
        if (locationName.isNull())
        {
          guardianLocation_ = defaultLocName.
                              getGuardianFullyQualifiedName();
        }
        else
        {
          guardianLocationName = locationName;
          if (guardianLocationName.isValid())
          {
            guardianLocation_ = (guardianLocationName.
                                 getGuardianFullyQualifiedName());
            
          }
          else
          {
            ossLocationName = locationName;
            if (ossLocationName.isValid())
            {
              guardianLocation_ = (ossLocationName.
                                   getGuardianFullyQualifiedName());
            }
            else
            {
              // OSS environment variable $1~string1 contains illegal
              // location name $0~string0.
              *SqlParser_Diags << DgSqlCode(-3061) 
		<< DgString0(locationName)
	        << DgString1(envVarName)
		;
            }
          }
        }
      }
      break;
#endif // 0

    default :
      NAAbort("ElemDDLPartition.C", __LINE__, "internal logic error");
      break;
    }
  }

  markAsBound();
  return this;
}