⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resultcolumn.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
	 *	 * @exception StandardException		Thrown on error	 *//*PUSHCOMPILE	public void generateNulls(ExpressionClassBuilder acb,									MethodBuilder mb,									Expression getColumnExpress) 			throws StandardException	{		acb.pushDataValueFactory(mb);		getTypeCompiler().generateNull(mb, acb.getBaseClassName());				mb.cast(ClassName.DataValueDescriptor);		return eb.newCastExpression(					ClassName.DataValueDescriptor, 					getTypeCompiler().						generateNull(									eb,									acb.getBaseClassName(),									acb.getDataValueFactory(eb),									getColumnExpress));	}*/	/**		Generate the code to create a column the same shape and		size as this ResultColumn.		Used in ResultColumnList.generateHolder().		@exception StandardException  thrown on failure	*/	public void generateHolder(ExpressionClassBuilder acb,									MethodBuilder mb)		throws StandardException	{		// generate expression of the form		// (DataValueDescriptor) columnSpace		acb.generateNull(mb, getTypeCompiler());		mb.upCast(ClassName.DataValueDescriptor);	}	/*	** Check whether the column length and type of this result column	** match the expression under the columns.  This is useful for	** INSERT and UPDATE statements.  For SELECT statements this method	** should always return true.  There is no need to call this for a	** DELETE statement.	**	** @return	true means the column matches its expressions,	**			false means it doesn't match.	*/	boolean columnTypeAndLengthMatch()		throws StandardException	{		DataTypeDescriptor	resultColumnType;		DataTypeDescriptor	expressionType = expression.getTypeServices();		/*		** We can never make any assumptions about		** parameters.  So don't even bother in this		** case.		*/		if (expression.isParameterNode())		{			return false;		}		resultColumnType = getType();		if (SanityManager.DEBUG)		{			if (! (resultColumnType != null))			{				SanityManager.THROWASSERT("Type is null for column " + 										  this);			}		}		/* Are they the same type? */		if ( ! resultColumnType.getTypeId().getSQLTypeName().equals(			expressionType.getTypeId().getSQLTypeName()				)			)		{			return false;		}		/* Are they the same precision? */		if (resultColumnType.getPrecision() != expressionType.getPrecision())		{			return false;		}		/* Are they the same scale? */		if (resultColumnType.getScale() != expressionType.getScale())		{			return false;		}		/* Are they the same width? */		if (resultColumnType.getMaximumWidth() != expressionType.getMaximumWidth())		{			return false;		}		/* Is the source nullable and the target non-nullable? */		if ((! resultColumnType.isNullable()) && expressionType.isNullable())		{			return false;		}		return true;	}	boolean columnTypeAndLengthMatch(ResultColumn otherColumn)		throws StandardException	{		DataTypeDescriptor	resultColumnType;		DataTypeDescriptor	otherResultColumnType;		ValueNode otherExpression = otherColumn.getExpression();		resultColumnType = getType();		otherResultColumnType = otherColumn.getType();		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(resultColumnType != null,					"Type is null for column " + this);			SanityManager.ASSERT(otherResultColumnType != null,					"Type is null for column " + otherColumn);		}		/*		** We can never make any assumptions about		** parameters.  So don't even bother in this		** case.		*/		if ((otherExpression != null) && (otherExpression.isParameterNode()) ||			(expression.isParameterNode()))		{			return false;		}		/* Are they the same type? */		if ( ! resultColumnType.getTypeId().equals(			otherResultColumnType.getTypeId()				)			)		{			/* If the source is a constant of a different type then			 * we try to convert that constant to a constant of our			 * type. (The initial implementation only does the conversion			 * to string types because the most common problem is a char			 * constant with a varchar column.)  			 * NOTE: We do not attempt any conversion here if the source			 * is a string type and the target is not or vice versa in 			 * order to avoid problems with implicit varchar conversions.			 * Anyway, we will check if the "converted" constant has the			 * same type as the original constant.  If not, then the conversion			 * happened.  In that case, we will reuse the ConstantNode, for simplicity,			 * and reset the type to match the desired type.			 */			if (otherExpression instanceof ConstantNode)			{				ConstantNode constant = (ConstantNode)otherColumn.getExpression();				DataValueDescriptor oldValue = constant.getValue();				DataValueDescriptor newValue = convertConstant(					resultColumnType.getTypeId(),					resultColumnType.getMaximumWidth(), oldValue);				if ((oldValue != newValue) &&					(oldValue instanceof StringDataValue ==					 newValue instanceof StringDataValue))				{					constant.setValue(newValue);					constant.setType(getTypeServices());					otherColumn.bindResultColumnToExpression();					otherResultColumnType = otherColumn.getType();				}			}			if ( ! resultColumnType.getTypeId().equals(				otherResultColumnType.getTypeId()					)				)			{				return false;			}		}		/* Are they the same precision? */		if (resultColumnType.getPrecision() !=										otherResultColumnType.getPrecision())		{			return false;		}		/* Are they the same scale? */		if (resultColumnType.getScale() != otherResultColumnType.getScale())		{			return false;		}		/* Are they the same width? */		if (resultColumnType.getMaximumWidth() !=										otherResultColumnType.getMaximumWidth())		{			return false;		}		/* Is the source nullable and the target non-nullable? 		 * The source is nullable if it is nullable or if the target is generated		 * for an unmatched column in an insert with a column list.		 * This additional check is needed because when we generate any additional		 * source RCs for an insert with a column list the generated RCs for any 		 * non-specified columns get the type info from the column.  Thus, 		 * for t1(non_nullable, nullable)		 *	insert into t2 (nullable) values 1;		 * RCType.isNullable() returns false for the generated source RC for 		 * non_nullable.  In this case, we want to see it as		 */		if ((! resultColumnType.isNullable()) &&					(otherResultColumnType.isNullable() || 					 otherColumn.isGeneratedForUnmatchedColumnInInsert()))		{			return false;		}		return true;	}	/**	 * Is this a generated column?	 *	 * @return Boolean - whether or not this column is a generated column.	 */	public boolean isGenerated()	{		return (isGenerated == true);	}	/**	 * Is this columm generated for an unmatched column in an insert?	 *	 * @return Boolean - whether or not this columm was generated for an unmatched column in an insert.	 */	public boolean isGeneratedForUnmatchedColumnInInsert()	{		return (isGeneratedForUnmatchedColumnInInsert == true);	}	/**	 * Mark this a columm as a generated column	 *	 * @return None.	 */	public void markGenerated()	{		isGenerated = true;		/* A generated column is a referenced column */		isReferenced = true;	}	/**	 * Mark this a columm as generated for an unmatched column in an insert	 *	 * @return None.	 */	public void markGeneratedForUnmatchedColumnInInsert()	{		isGeneratedForUnmatchedColumnInInsert = true;		/* A generated column is a referenced column */		isReferenced = true;	}	/**	 * Is this a referenced column?	 *	 * @return Boolean - whether or not this column is a referenced column.	 */	public boolean isReferenced()	{		return isReferenced;	}	/**	 * Mark this column as a referenced column.	 *	 * @return None.	 */	public void setReferenced()	{		isReferenced = true;	}    /**     * Mark this column as a referenced column if it is already marked as referenced or if any result column in     * its chain of virtual columns is marked as referenced.     */    void pullVirtualIsReferenced()    {        if( isReferenced())            return;                for( ValueNode expr = expression; expr != null && (expr instanceof VirtualColumnNode);)        {            VirtualColumnNode vcn = (VirtualColumnNode) expr;            ResultColumn src = vcn.getSourceColumn();            if( src.isReferenced())            {                setReferenced();                return;            }            expr = src.getExpression();        }    } // end of pullVirtualIsReferenced	/**	 * Mark this column as an unreferenced column.	 *	 * @return None.	 */	public void setUnreferenced()	{		isReferenced = false;	}	/** 	 * Mark this RC and all RCs in the underlying	 * RC/VCN chain as referenced.	 *	 * @return Nothing.	 */	void markAllRCsInChainReferenced()	{		setReferenced();		ValueNode vn = expression;		while (vn instanceof VirtualColumnNode)		{			VirtualColumnNode vcn = (VirtualColumnNode) vn;			ResultColumn rc = vcn.getSourceColumn();			rc.setReferenced();			vn = rc.getExpression();		}	}	/**	 * Is this a redundant ResultColumn?	 *	 * @return Boolean - whether or not this RC is redundant.	 */	public boolean isRedundant()	{		return isRedundant;	}	/**	 * Mark this ResultColumn as redundant.	 *	 * @return None.	 */	public void setRedundant()	{		isRedundant = true;	}	/**	 * Mark this ResultColumn as a grouping column in the SELECT list	 *	 * @return Nothing.	 */	public void markAsGroupingColumn()	{		isGroupingColumn = true;	}	/**	 * Look for and reject ? parameter under this ResultColumn.  This is	 * called for SELECT statements.	 *	 * @return	Nothing	 *	 * @exception StandardException		Thrown if a ? parameter was found	 *									directly under this ResultColumn.	 */	void rejectParameter() throws StandardException	{		if ((expression != null) && (expression.isParameterNode()))			throw StandardException.newException(SQLState.LANG_PARAM_IN_SELECT_LIST);	}	/*	** The following methods implement the Comparable interface.	*/	public int compareTo(Object other)	{		ResultColumn otherResultColumn = (ResultColumn) other;		return this.getColumnPosition() - otherResultColumn.getColumnPosition();	}	/**	 * Mark this column as being updated by an update statemment.	 */	void markUpdated()	{		updated = true;	}	/**	 * Mark this column as being updatable, so we can make sure it is in the	 * "for update" list of a positioned update.	 */	void markUpdatableByCursor()	{		updatableByCursor = true;	}	/**	 * Tell whether this column is being updated.	 *	 * @return	true means this column is being updated.	 */	boolean updated()	{		return updated;	}	/**	 * Tell whether this column is updatable by a positioned update.	 *	 * @return	true means this column is updatable	 */	public boolean updatableByCursor()	{		return updatableByCursor;	}	/**	 * Make a copy of this ResultColumn in a new ResultColumn	 *	 * @return	A new ResultColumn with the same contents as this one	 *	 * @exception StandardException		Thrown on error	 */	ResultColumn cloneMe() throws StandardException

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -