StmtDDLDropModule::StmtDDLDropModule(const QualifiedName & modulename) : StmtDDLNode(DDL_DROP_MODULE), moduleName_(PARSERHEAP()), moduleQualName_(modulename, PARSERHEAP()) { moduleName_ = moduleQualName_.getQualifiedNameAsAnsiString(); }
// // constructor // StmtDDLDropSchema::StmtDDLDropSchema(//const SchemaName & schemaName, const ElemDDLSchemaName & aSchemaNameParseNode, ComDropBehavior dropBehavior, ComBoolean cleanupMode, ComBoolean dropObjectsOnly) : StmtDDLNode(DDL_DROP_SCHEMA), schemaQualName_(aSchemaNameParseNode.getSchemaName(), PARSERHEAP()), dropBehavior_(dropBehavior), cleanupMode_(cleanupMode), dropObjectsOnly_(dropObjectsOnly), dropIfExists_(FALSE), schemaName_(PARSERHEAP()) { if (schemaQualName_.getCatalogName().isNull()) { schemaName_ = ToAnsiIdentifier(schemaQualName_.getSchemaName()); } else { schemaName_ = ToAnsiIdentifier(schemaQualName_.getCatalogName()) + "." + ToAnsiIdentifier(schemaQualName_.getSchemaName()); } // If the schema name specified is reserved name, users cannot drop them. // They can only be dropped internally. if ((! Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)) && (ComIsTrafodionReservedSchemaName(schemaQualName_.getSchemaName()))) { // error. *SqlParser_Diags << DgSqlCode(-1430) << DgSchemaName(schemaName_); } }
ElemDDLPartitionSystem::ElemDDLPartitionSystem() : ElemDDLPartition(ELM_PARTITION_SYSTEM_ELEM), option_(ADD_OPTION), locationName_(PARSERHEAP()), guardianLocation_(PARSERHEAP()), partitionName_(PARSERHEAP()) { setChild(INDEX_LOCATION, NULL); setChild(INDEX_PARTITION_ATTR_LIST, NULL); initializeDataMembers(); }
// // constructor // StmtDDLDropIndex::StmtDDLDropIndex(const QualifiedName & indexName, ComDropBehavior dropBehavior, NABoolean cleanupSpec, NABoolean validateSpec, NAString * pLogFile) : StmtDDLNode(DDL_DROP_INDEX), origIndexQualName_(PARSERHEAP()), indexQualName_(indexName, PARSERHEAP()), dropBehavior_(dropBehavior), isCleanupSpec_(cleanupSpec), isValidateSpec_(validateSpec), pLogFile_(pLogFile) {}
StmtDDLDropExceptionTable::StmtDDLDropExceptionTable(const QualifiedName & exceptionName, const QualifiedName & objectReference, ComDropBehavior dropBehavior, NABoolean cleanupSpec, NAString * pLogFile) : StmtDDLNode (DDL_DROP_EXCEPTION_TABLE), exceptionName_(exceptionName, PARSERHEAP()), objectReference_(objectReference, PARSERHEAP()), dropBehavior_(dropBehavior), isCleanupSpec_(cleanupSpec), dropType_(COM_DROP_SINGLE), pLogFile_(pLogFile) { }
// // constructor // StmtDDLDropTable::StmtDDLDropTable(const QualifiedName & tableQualName, ComDropBehavior dropBehavior) : StmtDDLNode(DDL_DROP_TABLE), origTableQualName_(PARSERHEAP()), tableQualName_(tableQualName, PARSERHEAP()), dropBehavior_(dropBehavior), tableType_(ExtendedQualName::NORMAL_TABLE), //++ MV isSpecialTypeSpecified_(FALSE), //++ MV isCleanupSpec_(FALSE), isValidateSpec_(FALSE), pLogFile_(NULL), dropIfExists_(FALSE) { }
ElemDDLPartitionSystem::ElemDDLPartitionSystem( ElemDDLPartition::optionEnum option, ElemDDLNode * pLocation, ElemDDLNode * pPartitionAttrList) : ElemDDLPartition(ELM_PARTITION_SYSTEM_ELEM), option_(option), locationName_(PARSERHEAP()), guardianLocation_(PARSERHEAP()), partitionName_(PARSERHEAP()) { setChild(INDEX_LOCATION, pLocation); setChild(INDEX_PARTITION_ATTR_LIST, pPartitionAttrList); initializeDataMembers(); }
StmtDDLDropLibrary::StmtDDLDropLibrary( const QualifiedName & libraryName, ComDropBehavior dropBehavior) : StmtDDLNode(DDL_DROP_LIBRARY), libraryName_(libraryName, PARSERHEAP()), dropBehavior_(dropBehavior) { }
// // constructor // StmtDDLDropTrigger::StmtDDLDropTrigger(const QualifiedName & triggerQualName, NABoolean cleanupSpec, NABoolean validateSpec, NAString * pLogFile) : StmtDDLNode(DDL_DROP_TRIGGER), triggerQualName_(triggerQualName, PARSERHEAP()), isCleanupSpec_(cleanupSpec), isValidateSpec_(validateSpec), pLogFile_(pLogFile) {}
//---------------------------------------------------------------------------- // CLASS StmtDDLAlterTableAlterColumn //---------------------------------------------------------------------------- StmtDDLAlterTableAlterColumn::StmtDDLAlterTableAlterColumn( OperatorTypeEnum operatorType , const NAString &columnName , ElemDDLNode *pColDefault , CollHeap *heap) : StmtDDLAlterTable(operatorType, QualifiedName(PARSERHEAP()) /*no table name*/, pColDefault), columnName_(columnName, heap) { }
// constructor ElemDDLColViewDef::ElemDDLColViewDef(const NAString & columnName, ElemDDLNode * pColAttrList) : ElemDDLNode(ELM_COL_VIEW_DEF_ELEM), columnName_(columnName, PARSERHEAP()), heading_(PARSERHEAP()), isHeadingSpec_(FALSE) { setChild(INDEX_ELEM_DDL_COL_ATTR_LIST, pColAttrList); // Traverse the list of column attributes to check for // duplicate HEADING clause if (pColAttrList NEQ NULL) { for (CollIndex index = 0; index < pColAttrList->entries(); index++) { setColumnAttribute((*pColAttrList)[index]); } } } // ElemDDLColViewDef()
// // constructor // StmtDDLDropMV::StmtDDLDropMV(const QualifiedName & MVQualName, ComDropBehavior dropBehavior, NABoolean cleanupSpec, NABoolean validateSpec, NAString * pLogFile) : StmtDDLNode(DDL_DROP_MV), MVQualName_(MVQualName, PARSERHEAP()), dropBehavior_(dropBehavior), isCleanupSpec_(cleanupSpec), isValidateSpec_(validateSpec), pLogFile_(pLogFile) { }
// // constructor // StmtDDLDropView::StmtDDLDropView(const QualifiedName & viewQualName, ComDropBehavior dropBehavior, NABoolean cleanupSpec, NABoolean validateSpec, NAString * pLogFile) : StmtDDLNode(DDL_DROP_VIEW), viewQualName_(viewQualName, PARSERHEAP()), dropBehavior_(dropBehavior), isCleanupSpec_(cleanupSpec), isValidateSpec_(validateSpec), pLogFile_(pLogFile) { }
// // assignment operator // ParDDLLikeOptsCreateTable & ParDDLLikeOptsCreateTable::operator=( const ParDDLLikeOptsCreateTable & likeOptions) { if (this EQU &likeOptions) return *this; ParDDLLikeOpts::operator=(likeOptions); isLikeOptWithCommentsSpec_ = likeOptions.isLikeOptWithCommentsSpec_; isLikeOptWithoutConstraintsSpec_ = likeOptions.isLikeOptWithoutConstraintsSpec_; isLikeOptWithHeadingsSpec_ = likeOptions.isLikeOptWithHeadingsSpec_; isLikeOptWithHelpTextSpec_ = likeOptions.isLikeOptWithHelpTextSpec_; isLikeOptWithHorizontalPartitionsSpec_ = likeOptions.isLikeOptWithHorizontalPartitionsSpec_; isLikeOptWithoutSaltSpec_ = likeOptions.isLikeOptWithoutSaltSpec_; isLikeOptSaltClauseSpec_ = likeOptions.isLikeOptSaltClauseSpec_; isLikeOptWithoutDivisionSpec_ = likeOptions.isLikeOptWithoutDivisionSpec_; isLikeOptLimitColumnLengthSpec_ = likeOptions.isLikeOptLimitColumnLengthSpec_; isLikeOptWithoutRowFormatSpec_ = likeOptions.isLikeOptWithoutRowFormatSpec_; isLikeOptWithComments_ = likeOptions.isLikeOptWithComments_; isLikeOptWithoutConstraints_ = likeOptions.isLikeOptWithoutConstraints_; isLikeOptWithHeadings_ = likeOptions.isLikeOptWithHeadings_; isLikeOptWithHelpText_ = likeOptions.isLikeOptWithHelpText_; isLikeOptWithHorizontalPartitions_ = likeOptions.isLikeOptWithHorizontalPartitions_; isLikeOptWithoutSalt_ = likeOptions.isLikeOptWithoutSalt_; isLikeOptWithoutDivision_ = likeOptions.isLikeOptWithoutDivision_; isLikeOptColumnLengthLimit_ = likeOptions.isLikeOptColumnLengthLimit_; isLikeOptWithoutRowFormat_ = likeOptions.isLikeOptWithoutRowFormat_; if (this != &likeOptions) // make sure not assigning to self { if (likeOptions.isLikeOptSaltClause_) { delete isLikeOptSaltClause_; isLikeOptSaltClause_ = new (PARSERHEAP()) NAString(*likeOptions.isLikeOptSaltClause_); } else if (isLikeOptSaltClause_) { delete isLikeOptSaltClause_; isLikeOptSaltClause_ = NULL; } // else both are NULL; nothing to do } return *this; }
// initialize constructor StmtDDLDropMvRGroup::StmtDDLDropMvRGroup(const QualifiedName & mvGroupName) :StmtDDLNode(DDL_DROP_MV_REFRESH_GROUP), mvRGroupQualName_(mvGroupName, PARSERHEAP()) { // XXXXXXXXXMVSXXXXXXXXXXXXXXX }
// // constructor // StmtDDLDropHbaseTable::StmtDDLDropHbaseTable(const QualifiedName & tableQualName) : StmtDDLNode(DDL_DROP_HBASE_TABLE), origTableQualName_(PARSERHEAP()), tableQualName_(tableQualName, PARSERHEAP()) { }
void ElemDDLColDef::setColumnAttribute(ElemDDLNode * pColAttr) { switch(pColAttr->getOperatorType()) { case ELM_COL_HEADING_ELEM : if (isHeadingSpec_) { // Duplicate HEADING clauses in column definition. *SqlParser_Diags << DgSqlCode(-3051) << DgColumnName(ToAnsiIdentifier(getColumnName())); } ComASSERT(pColAttr->castToElemDDLColHeading() NEQ NULL); heading_ = pColAttr->castToElemDDLColHeading()->getColumnHeading(); isHeadingSpec_ = TRUE; // Report an error if heading_ is too long. if (heading_.length() > ElemDDLColHeading::maxHeadingLength) { *SqlParser_Diags << DgSqlCode(-3132) << DgColumnName(ToAnsiIdentifier(getColumnName())); } break; case ELM_CONSTRAINT_CHECK_ELEM : ComASSERT(pColAttr->castToElemDDLConstraintCheck() NEQ NULL); columnConstraintArray_.insert(pColAttr->castToElemDDLConstraint()); break; case ELM_CONSTRAINT_NOT_NULL_ELEM : ComASSERT(pColAttr->castToElemDDLConstraintNotNull() NEQ NULL); if (isNotNullSpec_) { // Duplicate NOT NULL clauses in column definition. *SqlParser_Diags << DgSqlCode(-3052) << DgString0("NOT NULL") << DgColumnName(ToAnsiIdentifier(getColumnName())); } isNotNullSpec_ = TRUE; pConstraintNotNull_ = pColAttr->castToElemDDLConstraintNotNull(); if (NOT pConstraintNotNull_->isDroppable()) { isNotNullNondroppable_ = TRUE; if (columnDataType_) columnDataType_->setNullable(FALSE); } // Note that we do not insert pConstraintNotNull_ into // columnConstraintArray_ even though Not Null constraint is // also a column constraint. The user can use the accessors // getIsConstraintNotNullSpecified and getConstraintNotNull // instead. break; case ELM_LOGGABLE: ComASSERT( NULL NEQ pColAttr->castToElemDDLLoggable()) if(TRUE == isLoggableSpec_) { // Duplicate LOGGABLE in column definition. *SqlParser_Diags << DgSqlCode(-12064) << DgColumnName(ToAnsiIdentifier(getColumnName())); } isLoggableSpec_ = TRUE; isLoggable_ = pColAttr->castToElemDDLLoggable()->getIsLoggable(); break; case ELM_CONSTRAINT_PRIMARY_KEY_COLUMN_ELEM : { ComASSERT(pColAttr->castToElemDDLConstraintPKColumn() NEQ NULL); ComASSERT(pColAttr->castToElemDDLConstraintPKColumn() ->getConstraintKind() EQU ElemDDLConstraint::COLUMN_CONSTRAINT_DEF); if (isPrimaryKeySpec_) { // Duplicate PRIMARY KEY clauses in column definition. *SqlParser_Diags << DgSqlCode(-3053) << DgColumnName(ToAnsiIdentifier(getColumnName())); } isPrimaryKeySpec_ = TRUE; ElemDDLConstraintPKColumn * pColPKConstraint = pColAttr->castToElemDDLConstraintPKColumn(); // // Copies the pointer to the parse node representing the column // primary key constraint to pConstraintPK_ so the user (caller) // can access the information easier. Note that this pointer is // not inserted into columnConstraintArray_ because primary key // constraint is special. (There can only be one primary key // constraint associating with a table.) The user (caller) can // use method getIsConstraintPKSpecified() and getConstraintPK() // to get the primary key constraint information. // pConstraintPK_ = pColPKConstraint; // The column name is not specified in the column primary key // constraint definition. To make the user (caller) to access // to this information easier, creates a parse node containing // the column name. ComASSERT(pColPKConstraint->getColumnRefList() EQU NULL); ElemDDLColRef * pColRef = new(PARSERHEAP()) ElemDDLColRef(getColumnName(), pColPKConstraint-> getColumnOrdering(), PARSERHEAP()); pColPKConstraint->setColumnRefList(pColRef); primaryKeyColRefArray_.insert(pColRef); } break; case ELM_CONSTRAINT_REFERENTIAL_INTEGRITY_ELEM : { ComASSERT(pColAttr->castToElemDDLConstraintRI() NEQ NULL); ComASSERT(pColAttr->castToElemDDLConstraintRI()->getConstraintKind() EQU ElemDDLConstraint::COLUMN_CONSTRAINT_DEF); columnConstraintArray_.insert(pColAttr->castToElemDDLConstraint()); // // The column name is not specified in the column referential // integrity constraint definition. To make the user (caller) // to access to this information easier, creates a parse node // containing the column name. // ElemDDLConstraintRI * pColRIConstraint = pColAttr->castToElemDDLConstraintRI(); ComASSERT(pColRIConstraint->getReferencingColumnNameList() EQU NULL); ElemDDLColName * pColName = new(PARSERHEAP()) ElemDDLColName(getColumnName()); pColRIConstraint->setReferencingColumnNameList(pColName); } break; case ELM_CONSTRAINT_UNIQUE_ELEM : { ComASSERT(pColAttr->castToElemDDLConstraintUnique() NEQ NULL); ComASSERT(pColAttr->castToElemDDLConstraintUnique()->getConstraintKind() EQU ElemDDLConstraint::COLUMN_CONSTRAINT_DEF); columnConstraintArray_.insert(pColAttr->castToElemDDLConstraint()); // // The column name is not specified in the column unique // constraint definition. To make the user (caller) to access // to this information easier, creates a parse node containing // the column name. // ElemDDLConstraintUnique * pColUniqueConstraint = pColAttr->castToElemDDLConstraintUnique(); ComASSERT(pColUniqueConstraint->getColumnRefList() EQU NULL); ElemDDLColRef * pColRef = new(PARSERHEAP()) ElemDDLColRef(getColumnName(), COM_ASCENDING_ORDER, PARSERHEAP()); pColUniqueConstraint->setColumnRefList(pColRef); } break; case ELM_LOBATTRS: { ComASSERT( NULL NEQ pColAttr->castToElemDDLLobAttrs()) if(TRUE == isLobAttrsSpec_) { // Duplicate LOB attrs in column definition. *SqlParser_Diags << DgSqlCode(-3052) << DgString0("LOB") << DgColumnName(ToAnsiIdentifier(getColumnName())); } isLobAttrsSpec_ = TRUE; lobStorage_ = pColAttr->castToElemDDLLobAttrs()->getLobStorage(); } break; case ELM_SEABASE_SERIALIZED: { ComASSERT( NULL NEQ pColAttr->castToElemDDLSeabaseSerialized()) if(TRUE == isSeabaseSerializedSpec_) { // Duplicate SERIALIZED attrs in column definition. *SqlParser_Diags << DgSqlCode(-3052) << DgString0("SERIALIZED") << DgColumnName(ToAnsiIdentifier(getColumnName())); } isSeabaseSerializedSpec_ = TRUE; seabaseSerialized_ = pColAttr->castToElemDDLSeabaseSerialized()->serialized(); } break; case ELM_COL_DEFAULT_ELEM: { ComASSERT( NULL NEQ pColAttr->castToElemDDLColDefault()); if(TRUE == isColDefaultSpec_) { // Duplicate DEFAULT attrs in column definition. *SqlParser_Diags << DgSqlCode(-3052) << DgString0("DEFAULT") << DgColumnName(ToAnsiIdentifier(getColumnName())); } isColDefaultSpec_ = TRUE; setDefaultAttribute(pColAttr->castToElemDDLColDefault()); } break; default : ABORT("internal logic error"); break; } // switch }
// constructor ElemDDLColDef::ElemDDLColDef( const NAString *columnFamily, const NAString *columnName, NAType * pColumnDataType, ElemDDLNode * pColAttrList, CollHeap * heap) : ElemDDLNode(ELM_COL_DEF_ELEM), columnName_(*columnName, heap), columnDataType_(pColumnDataType), defaultClauseStatus_(DEFAULT_CLAUSE_NOT_SPEC), isNewAdjustedDefaultConstValueNode_(FALSE), pDefault_(NULL), isHeadingSpec_(FALSE), heading_(heap), columnClass_(COM_USER_COLUMN), isNotNullSpec_(FALSE), isNotNullNondroppable_(FALSE), isLoggableSpec_(FALSE), isLoggable_(TRUE), pConstraintNotNull_(NULL), isPrimaryKeySpec_(FALSE), pConstraintPK_(NULL), columnConstraintArray_(heap), primaryKeyColRefArray_(heap), direction_(COM_OUTPUT_COLUMN), pSGOptions_(NULL), pSGLocation_(NULL), isDivisionColumn_(FALSE), divisionColumnSeqNum_(-1), isLobAttrsSpec_(FALSE), lobStorage_(Lob_HDFS_File), isSeabaseSerializedSpec_(FALSE), seabaseSerialized_(FALSE), isColDefaultSpec_(FALSE) { // ComASSERT(pColumnDataType NEQ NULL); if (columnFamily) columnFamily_ = *columnFamily; if (pColumnDataType NEQ NULL) { const NAString dataTypeName = pColumnDataType->getTypeName(); // Create table with data type DATETIME not supported. Must check for DATE, // TIME, and TIMESTAMP as well since DATETIME might be converted into these, if( dataTypeName == "DATETIME" || dataTypeName == "DATE" || dataTypeName == "TIME" || dataTypeName == "TIMESTAMP" ) { // Check flag to see if DATETIME originally specified if( ((DatetimeIntervalCommonType *)pColumnDataType)-> getDTIFlag(DatetimeIntervalCommonType::UNSUPPORTED_DDL_DATA_TYPE)) { // Only put error into diags if it doesn't already contain it if(!SqlParser_Diags->contains(-3195)) { *SqlParser_Diags << DgSqlCode(-3195) << DgString0("DATETIME"); } return; } } // Create table with data type INTERVAL with FRACTION field(s) not supported else if (dataTypeName == "INTERVAL") { // Check flag to see if FRACTION was originally specified if( ((DatetimeIntervalCommonType *)pColumnDataType)-> getDTIFlag(DatetimeIntervalCommonType::UNSUPPORTED_DDL_DATA_TYPE)) { // Only put error into diags if it doesn't already contain it if(!SqlParser_Diags->contains(-3195)) { *SqlParser_Diags << DgSqlCode(-3195) << DgString0("INTERVAL with FRACTION field(s)"); } return; } // Check to see if interval second is specified with leading // precision of 0 if(!((SQLInterval *)pColumnDataType)->isSupportedType()) { // Only put error into diags if it doesn't already contain it if(!SqlParser_Diags->contains(-3195)) { *SqlParser_Diags << DgSqlCode(-3195) << DgString0("INTERVAL SECOND with leading precision 0"); } return; } } } setChild(INDEX_ELEM_DDL_COL_ATTR_LIST, pColAttrList); // initialize data member pDefault_ ComBoolean isIdentityColumn = FALSE; // // Traverse the list of column attributes to check for duplicate // HEADING clause and duplicate NOT NULL column constraint definition // if (pColAttrList NEQ NULL) { for (CollIndex index = 0; index < pColAttrList->entries(); index++) { setColumnAttribute((*pColAttrList)[index]); } } // At this point we will know if the user // has specified NOT NULL NOT DROPPABLE for IDENTITY // column. If not specified, then automatically add // it. if (pSGOptions_) //isIdentityColumn { // if NOT NULL not specified, then specify it here. if(NOT getIsConstraintNotNullSpecified()) isNotNullSpec_ = TRUE; // [NOT] DROPPABLE is the only attribute for NOT NULL. if (pConstraintNotNull_) { // if DROPPABLE was specified explicity then raise an error. if (pConstraintNotNull_->isDroppableSpecifiedExplicitly()) { *SqlParser_Diags << DgSqlCode(-3413) << DgColumnName(ToAnsiIdentifier(getColumnName())); return; } else { // add the NOT DROPPABLE attribute to the NOT NULL . pConstraintNotNull_->setConstraintAttributes (new (PARSERHEAP()) ElemDDLConstraintAttrDroppable(FALSE)); } } else { // by default NOT NULLs are NOT DROPPABLEs as well in SQL/MX pConstraintNotNull_ = new (PARSERHEAP()) ElemDDLConstraintNotNull(PARSERHEAP()); pConstraintNotNull_->setConstraintAttributes (new (PARSERHEAP()) ElemDDLConstraintAttrDroppable(FALSE)); } } //if isIdentityColumn // // All column attributes has been checked and saved. // If there exists a NOT NULL NONDROPPABLE constraint // associating with the currently defined column, makes // sure that the associating NAType (data type) parse // node does not allow null values. // if (getIsConstraintNotNullSpecified() AND NOT getConstraintNotNull()->isDroppable()) { isNotNullNondroppable_ = TRUE; if (columnDataType_) columnDataType_->setNullable(FALSE); } } // ElemDDLColDef()
// // constructor // StmtDDLDropCatalog::StmtDDLDropCatalog(const NAString & catalogName, ComDropBehavior dropBehavior) : StmtDDLNode(DDL_DROP_CATALOG), catalogName_(catalogName, PARSERHEAP()), dropBehavior_(dropBehavior) { }
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()
StmtDDLDropSynonym::StmtDDLDropSynonym(const QualifiedName & synonymName) : StmtDDLNode (DDL_DROP_SYNONYM), synonymName_(synonymName, PARSERHEAP()) { }
void ElemDDLColDef::setDefaultAttribute(ElemDDLNode * pColDefaultNode) { ElemDDLColDefault * pColDefault = NULL; ComBoolean isIdentityColumn = FALSE; NAType * pColumnDataType = columnDataType_; if (pColDefaultNode NEQ NULL) { ComASSERT(pColDefaultNode->castToElemDDLColDefault() NEQ NULL); pColDefault = pColDefaultNode->castToElemDDLColDefault(); } if (pColDefault NEQ NULL) { switch (pColDefault->getColumnDefaultType()) { case ElemDDLColDefault::COL_NO_DEFAULT: defaultClauseStatus_ = NO_DEFAULT_CLAUSE_SPEC; break; case ElemDDLColDefault::COL_DEFAULT: { defaultClauseStatus_ = DEFAULT_CLAUSE_SPEC; if (pColDefault->getSGOptions()) { isIdentityColumn = TRUE; pSGOptions_ = pColDefault->getSGOptions(); pSGLocation_ = pColDefault->getSGLocation(); } else { ComASSERT(pColDefault->getDefaultValueExpr() NEQ NULL); pDefault_ = pColDefault->getDefaultValueExpr(); } // The cast ItemExpr to ConstValue for (ConstValue *)pDefault_; // statement below sets arbitary value for the isNULL_. // Bypass these checks for ID column (basically ITM_IDENTITY). ConstValue *cvDef = (ConstValue *)pDefault_; if ((cvDef && !cvDef->isNull()) && (!isIdentityColumn)) { const NAType *cvTyp = cvDef->getType(); NABoolean isAnErrorAlreadyIssued = FALSE; if ( cvTyp->getTypeQualifier() == NA_CHARACTER_TYPE ) { CharInfo::CharSet defaultValueCS = ((const CharType *)cvTyp)->getCharSet(); // Always check for INFER_CHARSET setting before the ICAT setting. NAString inferCharSetFlag; if (getCharSetInferenceSetting(inferCharSetFlag) == TRUE && NOT cvDef->isStrLitWithCharSetPrefixSpecified()) { if (pColumnDataType->getTypeQualifier() == NA_CHARACTER_TYPE && ((const CharType *)pColumnDataType)->getCharSet() == CharInfo::UCS2 && SqlParser_DEFAULT_CHARSET == CharInfo::UCS2 && defaultValueCS == CharInfo::ISO88591 ) { *SqlParser_Diags << DgSqlCode(-1186) << DgColumnName(ToAnsiIdentifier(getColumnName())) << DgString0(pColumnDataType->getTypeSQLname(TRUE/*terse*/)) << DgString1(cvTyp->getTypeSQLname(TRUE/*terse*/)); isAnErrorAlreadyIssued = TRUE; } else { cvTyp = cvDef -> pushDownType(*columnDataType_, NA_CHARACTER_TYPE); } } else if (CmpCommon::getDefault(ALLOW_IMPLICIT_CHAR_CASTING) == DF_ON && NOT cvDef->isStrLitWithCharSetPrefixSpecified() && cvTyp->getTypeQualifier() == NA_CHARACTER_TYPE && SqlParser_DEFAULT_CHARSET == CharInfo::ISO88591 && defaultValueCS == CharInfo::UnknownCharSet) { cvTyp = cvDef -> pushDownType(*columnDataType_, NA_CHARACTER_TYPE); } } // column default value has character data type if (NOT isAnErrorAlreadyIssued && pColumnDataType->getTypeQualifier() == NA_CHARACTER_TYPE && cvTyp->getTypeQualifier() == NA_CHARACTER_TYPE && ( CmpCommon::getDefault(ALLOW_IMPLICIT_CHAR_CASTING) == DF_ON || NOT cvDef->isStrLitWithCharSetPrefixSpecified())) { const CharType *cdCharType = (const CharType *)pColumnDataType; const CharType *cvCharType = (const CharType *)cvTyp; CharInfo::CharSet cdCharSet = cdCharType->getCharSet(); // cd = column definition CharInfo::CharSet cvCharSet = cvCharType->getCharSet(); // cv = constant value if (cvCharSet == CharInfo::ISO88591) // default value is a _ISO88591 str lit { } else if ( (cvCharSet == CharInfo::UNICODE || // default value is a _UCS2 string literal cvCharSet == CharInfo::UTF8) && // or a _UTF8 string literal cdCharSet != cvCharSet ) { // // Check to see if all characters in the specified column default // string literal value can be successfully converted/translated // to the actual character set of the column. // char buf[2032]; // the output buffer - should be big enough buf[0] = '\0'; enum cnv_charset eCnvCS = convertCharsetEnum( cdCharSet ); const char * pInStr = cvDef->getRawText()->data(); Int32 inStrLen = cvDef->getRawText()->length(); char * p1stUnstranslatedChar = NULL; UInt32 outStrLenInBytes = 0; unsigned charCount = 0; // number of characters translated/converted Int32 cnvErrStatus = 0; char *pSubstitutionChar = NULL; Int32 convFlags = 0; if ( cvCharSet == CharInfo::UNICODE ) { cnvErrStatus = UTF16ToLocale ( cnv_version1 // in - const enum cnv_version version , pInStr // in - const char *in_bufr , inStrLen // in - const int in_len , buf // out - const char *out_bufr , 2016 // in - const int out_len , eCnvCS // in - enum cnv_charset charset , p1stUnstranslatedChar // out - char * & first_untranslated_char , &outStrLenInBytes // out - unsigned int *output_data_len_p , convFlags // in - const int cnv_flags , (Int32)TRUE // in - const int addNullAtEnd_flag , (Int32)FALSE // in - const int allow_invalids , &charCount // out - unsigned int * translated_char_cnt_p , pSubstitutionChar // in - const char *substitution_char ); } else // cvCharSet must be CharInfo::UTF8 { cnvErrStatus = UTF8ToLocale ( cnv_version1 // in - const enum cnv_version version , pInStr // in - const char *in_bufr , inStrLen // in - const int in_len , buf // out - const char *out_bufr , 2016 // in - const int out_len , eCnvCS // in - enum cnv_charset charset , p1stUnstranslatedChar // out - char * & first_untranslated_char , &outStrLenInBytes // out - unsigned int *output_data_len_p , (Int32)TRUE // in - const int addNullAtEnd_flag , (Int32)FALSE // in - const int allow_invalids , &charCount // out - unsigned int * translated_char_cnt_p , pSubstitutionChar // in - const char *substitution_char ); } switch (cnvErrStatus) { case 0: // success case CNV_ERR_NOINPUT: // an empty input string will get this error code { ConstValue *pMBStrLitConstValue ; // convert the string literal saved in cvDef (column default value) // from UNICODE (e.g. UTF16) to the column character data type if ( cdCharSet != CharInfo::UNICODE) { NAString mbs2(buf, PARSERHEAP()); // note that buf is NULL terminated pMBStrLitConstValue = new(PARSERHEAP()) ConstValue ( mbs2 , cdCharSet // use this for str lit prefix , CharInfo::DefaultCollation , CharInfo::COERCIBLE , PARSERHEAP() ); } else { NAWString mbs2((NAWchar*)buf, PARSERHEAP()); // note that buf is NULL terminated pMBStrLitConstValue = new(PARSERHEAP()) ConstValue ( mbs2 , cdCharSet // use this for str lit prefix , CharInfo::DefaultCollation , CharInfo::COERCIBLE , PARSERHEAP() ); } delete pDefault_; // deallocate the old ConstValue object cvDef = NULL; // do not use cvDef anymore pDefault_ = pMBStrLitConstValue; pColDefault->setDefaultValueExpr(pDefault_); } break; case CNV_ERR_INVALID_CHAR: { // 1401 == CAT_UNABLE_TO_CONVERT_COLUMN_DEFAULT_VALUE_TO_CHARSET *SqlParser_Diags << DgSqlCode(-1401) << DgColumnName(ToAnsiIdentifier(getColumnName())) << DgString0(CharInfo::getCharSetName(cdCharSet)); } break; case CNV_ERR_BUFFER_OVERRUN: // output buffer not big enough case CNV_ERR_INVALID_CS: default: CMPABORT_MSG("Parser internal logic error"); break; } // switch } else if(!pColumnDataType->isCompatible(*cvTyp)) { if (NOT isAnErrorAlreadyIssued) { *SqlParser_Diags << DgSqlCode(-1186) << DgColumnName(ToAnsiIdentifier(getColumnName())) << DgString0(pColumnDataType->getTypeSQLname(TRUE/*terse*/)) << DgString1(cvTyp->getTypeSQLname(TRUE/*terse*/)); isAnErrorAlreadyIssued = TRUE; } } } // column has character data type else // if interval data type, the default value must have the same // interval qualifier as the column. if (NOT isAnErrorAlreadyIssued && (!pColumnDataType->isCompatible(*cvTyp) || (pColumnDataType->getTypeQualifier() == NA_INTERVAL_TYPE && pColumnDataType->getFSDatatype() != cvTyp->getFSDatatype()))) { *SqlParser_Diags << DgSqlCode(-1186) << DgColumnName(ToAnsiIdentifier(getColumnName())) << DgString0(pColumnDataType->getTypeSQLname(TRUE/*terse*/)) << DgString1(cvTyp->getTypeSQLname(TRUE/*terse*/)); isAnErrorAlreadyIssued = TRUE; } } } break; case ElemDDLColDefault::COL_COMPUTED_DEFAULT: { defaultClauseStatus_ = DEFAULT_CLAUSE_SPEC; computedDefaultExpr_ = pColDefault->getComputedDefaultExpr(); } break; default: CMPABORT_MSG("Parser internal logic error"); break; } } }