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

📄 valuenode.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
	{		if (! underNotNode)		{			return this;		}		/* bind() has ensured that this node's type is SQLBoolean */		if (SanityManager.DEBUG)		SanityManager.ASSERT(				dataTypeServices.getTypeId().equals(												TypeId.BOOLEAN_ID),					"Node's type (" +					dataTypeServices.getTypeId().getSQLTypeName() +					") is expected to be boolean");		/* Return ValueNode = false */		return genEqualsFalseTree();	}	/**	 * Transform this into this = false.  Useful for NOT elimination.	 *	 *	 * @return		The modified expression	 *	 * @exception StandardException		Thrown on error	 */	public ValueNode genEqualsFalseTree()			throws StandardException	{		BinaryRelationalOperatorNode equalsNode;		BooleanConstantNode		 falseNode;		boolean 				nullableResult;		NodeFactory				nodeFactory = getNodeFactory();		falseNode = (BooleanConstantNode) nodeFactory.getNode(									C_NodeTypes.BOOLEAN_CONSTANT_NODE,									Boolean.FALSE,									getContextManager());		equalsNode = (BinaryRelationalOperatorNode)							nodeFactory.getNode(								C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,								this,								falseNode,								getContextManager());		nullableResult = dataTypeServices.isNullable();		equalsNode.setType(new DataTypeDescriptor(									TypeId.BOOLEAN_ID,									nullableResult)						  );		return equalsNode;	}	/**	 * Transform this into this is null.  Useful for NOT elimination.	 *	 * @return		The modified expression	 *	 * @exception StandardException		Thrown on error	 */	public ValueNode genIsNullTree()			throws StandardException	{		IsNullNode isNullNode;		isNullNode = (IsNullNode)							getNodeFactory().getNode(													C_NodeTypes.IS_NULL_NODE,													this,													getContextManager());		isNullNode.setType(new DataTypeDescriptor(									TypeId.BOOLEAN_ID,									false)						  );		return isNullNode;	}	/**	 * Verify that eliminateNots() did its job correctly.  Verify that	 * there are no NotNodes above the top level comparison operators	 * and boolean expressions.	 *	 * @return		Boolean which reflects validity of the tree.	 */	boolean verifyEliminateNots()	{		if (SanityManager.ASSERT)		{			return (! (this instanceof NotNode));		}		else		{			return true;		}	}	/**	 * Do the 1st step in putting an expression into conjunctive normal	 * form.  This step ensures that the top level of the expression is	 * a chain of AndNodes.	 *	 * @return		The modified expression	 *	 * @exception StandardException		Thrown on error	 */	public ValueNode putAndsOnTop() 					throws StandardException	{		NodeFactory		nodeFactory = getNodeFactory();        QueryTreeNode trueNode = nodeFactory.getNode(										C_NodeTypes.BOOLEAN_CONSTANT_NODE,										Boolean.TRUE,										getContextManager());		AndNode andNode = (AndNode) nodeFactory.getNode(										C_NodeTypes.AND_NODE,										this,										trueNode,										getContextManager());		andNode.postBindFixup();		return andNode;	}	/**	 * Verify that putAndsOnTop() did its job correctly.  Verify that the top level 	 * of the expression is a chain of AndNodes.	 *	 * @return		Boolean which reflects validity of the tree.	 */	public boolean verifyPutAndsOnTop()	{		return true;	}	/**	 * Finish putting an expression into conjunctive normal	 * form.  An expression tree in conjunctive normal form meets	 * the following criteria:	 *		o  If the expression tree is not null,	 *		   the top level will be a chain of AndNodes terminating	 *		   in a true BooleanConstantNode.	 *		o  The left child of an AndNode will never be an AndNode.	 *		o  Any right-linked chain that includes an AndNode will	 *		   be entirely composed of AndNodes terminated by a true BooleanConstantNode.	 *		o  The left child of an OrNode will never be an OrNode.	 *		o  Any right-linked chain that includes an OrNode will	 *		   be entirely composed of OrNodes terminated by a false BooleanConstantNode.	 *		o  ValueNodes other than AndNodes and OrNodes are considered	 *		   leaf nodes for purposes of expression normalization.	 *		   In other words, we won't do any normalization under	 *		   those nodes.	 *	 * In addition, we track whether or not we are under a top level AndNode.  	 * SubqueryNodes need to know this for subquery flattening.	 *	 * @param	underTopAndNode		Whether or not we are under a top level AndNode.	 *								 *	 * @return		The modified expression	 *	 * @exception StandardException		Thrown on error	 */	public ValueNode changeToCNF(boolean underTopAndNode) 					throws StandardException	{		return this;	}	/**	 * Verify that changeToCNF() did its job correctly.  Verify that:	 *		o  AndNode  - rightOperand is not instanceof OrNode	 *				      leftOperand is not instanceof AndNode	 *		o  OrNode	- rightOperand is not instanceof AndNode	 *					  leftOperand is not instanceof OrNode	 *	 * @return		Boolean which reflects validity of the tree.	 */	public boolean verifyChangeToCNF()	{		return true;	}	/**	 * Categorize this predicate.  Initially, this means	 * building a bit map of the referenced tables for each predicate.	 * If the source of this ColumnReference (at the next underlying level) 	 * is not a ColumnReference or a VirtualColumnNode then this predicate	 * will not be pushed down.	 *	 * For example, in:	 *		select * from (select 1 from s) a (x) where x = 1	 * we will not push down x = 1.	 * NOTE: It would be easy to handle the case of a constant, but if the	 * inner SELECT returns an arbitrary expression, then we would have to copy	 * that tree into the pushed predicate, and that tree could contain	 * subqueries and method calls.	 * RESOLVE - revisit this issue once we have views.	 *	 * @param referencedTabs	JBitSet with bit map of referenced FromTables	 * @param simplePredsOnly	Whether or not to consider method	 *							calls, field references and conditional nodes	 *							when building bit map	 *	 * @return boolean		Whether or not source.expression is a ColumnReference	 *						or a VirtualColumnNode.	 *	 * @exception StandardException			Thrown on error	 */	public boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)		throws StandardException	{		return true;	}	/**	 * This returns the user-supplied schema name of the column.	 * At this class level, it simply returns null. But, the subclasses	 * of ValueNode will overwrite this method to return the	 * user-supplied schema name.	 * 	 * When the value node is in a result column of a select list,	 * the user can request metadata information. The result column	 * won't have a column descriptor, so we return some default	 * information through the expression. This lets expressions that	 * are simply columns return all of the info, and others use	 * this supertype's default values.	 *	 * @return the default schema name for an expression -- null	 */	public String getSchemaName() throws StandardException	{		return null;	}	/**	 * This returns the user-supplied table name of the column.	 * At this class level, it simply returns null. But, the subclasses	 * of ValueNode will overwrite this method to return the	 * user-supplied table name.	 *	 * When the value node is in a result column of a select list,	 * the user can request metadata information. The result column	 * won't have a column descriptor, so we return some default	 * information through the expression. This lets expressions that	 * are simply columns return all of the info, and others use	 * this supertype's default values.	 *	 * @return the default table name for an expression -- null	 */	public String getTableName()	{		return null;	}	/**	 * @return the default updatability for an expression - false	 */	public boolean updatableByCursor()	{		return false;	}	/**	 * This is null so that the caller will substitute in the resultset generated	 * name as needed.	 *	 * @return the default column name for an expression -- null.	 */	public String getColumnName()	{		return null;	}	/**	 * Get a bit map of table references in this expression	 *	 * @return	A bit map of table numbers referred to in this expression	 *	 * @exception StandardException			Thrown on error	 */	JBitSet getTablesReferenced()		throws StandardException	{		ReferencedTablesVisitor rtv = new ReferencedTablesVisitor(new JBitSet(0));		accept(rtv);		return rtv.getTableMap();	}	/**	 * Return whether or not this expression tree is cloneable.	 *	 * @return boolean	Whether or not this expression tree is cloneable.	 */	public boolean isCloneable()	{		return false;	}	/**	 * Return a clone of this node.	 *	 * @return ValueNode	A clone of this node.	 *	 * @exception StandardException			Thrown on error	 */	public ValueNode getClone() throws StandardException	{		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(false,				"getClone() not expected to be called for " +				getClass().getName());		}		return null;	}	/**	 * Copy all of the "appropriate fields" for a shallow copy.	 *	 * @param oldVN		The ValueNode to copy from.	 *	 */	public void copyFields(ValueNode oldVN)	{		dataTypeServices = oldVN.getTypeServices();		typeId = oldVN.getTypeId();	}	/**	 * Remap all ColumnReferences in this tree to be clones of the	 * underlying expression.	 *	 * @return ValueNode			The remapped expression tree.	 *	 * @exception StandardException			Thrown on error	 */	public ValueNode remapColumnReferencesToExpressions() throws StandardException	{		return this;	}	/**	 * Return whether or not this expression tree represents a constant expression.	 *	 * @return	Whether or not this expression tree represents a constant expression.	 */	public boolean isConstantExpression()	{		return false;	}	/**	 * Return whether or not this expression tree represents a constant value.	 * In this case, "constant" means that it will always evaluate to the	 * same thing, even if it includes columns.  A column is constant if it	 * is compared to a constant expression.	 *	 * @return	True means this expression tree represents a constant value.	 */	public boolean constantExpression(PredicateList whereClause)	{		return false;	}	/**	  * Bind time logic. Raises an error if this ValueNode, once compiled, returns	  * unstable results AND if we're in a context where unstable results are	  * forbidden.	  *	  * Called by children who may NOT appear in the WHERE subclauses of ADD TABLE clauses.	  *	  *	@param	fragmentType	Type of fragment as a String, for inclusion in error messages.	  *	@param	fragmentBitMask	Type of fragment as a bitmask of possible fragment types	  *	  * @exception StandardException		Thrown on error	  */	public	void	checkReliability( String fragmentType, int fragmentBitMask )		throws StandardException	{		// if we're in a context that forbids unreliable fragments, raise an error		if ( ( getCompilerContext().getReliability() & fragmentBitMask ) != 0 )		{            throwReliabilityException( fragmentType );		}	}	/**	  * Bind time logic. Raises an error if this ValueNode, once compiled, returns	  * unstable results AND if we're in a context where unstable results are	  * forbidden.	  *	  * Called by children who may NOT appear in the WHERE subclauses of ADD TABLE clauses.	  *	  *	@param	fragmentBitMask	Type of fragment as a bitmask of possible fragment types	  *	@param	fragmentType	Type of fragment as a String, to be fetch for the error message.	  *	  * @exception StandardException		Thrown on error	  */	public	void	checkReliability( int fragmentBitMask, String fragmentType )		throws StandardException	{		// if we're in a context that forbids unreliable fragments, raise an error		if ( ( getCompilerContext().getReliability() & fragmentBitMask ) != 0 )		{            String fragmentTypeTxt = MessageService.getTextMessage( fragmentType );            throwReliabilityException( fragmentTypeTxt );		}	}    /**     * Common code for the 2 checkReliability functions.  Always throws StandardException.     *     * @param fragmentType Type of fragment as a string, for inclusion in error messages.     * @exception StandardException        Throws an error, always.     */    private void throwReliabilityException( String fragmentType ) throws StandardException    {        String sqlState;		/* Error string somewhat dependent on operation due to different		 * nodes being allowed for different operations.		 */		if (getCompilerContext().getReliability() == CompilerContext.DEFAULT_RESTRICTION)		{            sqlState = SQLState.LANG_INVALID_DEFAULT_DEFINITION;		}		else		{            sqlState = SQLState.LANG_UNRELIABLE_QUERY_FRAGMENT;		}		throw StandardException.newException(sqlState, fragmentType);    }	/**	 * Return the variant type for the underlying expression.	 * The variant type can be:	 *		VARIANT				- variant within a scan	 *							  (method calls and non-static field access)	 *		SCAN_INVARIANT		- invariant within a scan	 *							  (column references from outer tables)	 *		QUERY_INVARIANT		- invariant within the life of a query	 *							  (constant expressions)	 *	 * @return	The variant type for the underlying expression.	 * @exception StandardException		Thrown on error	 */	protected int getOrderableVariantType() throws StandardException	{		// The default is VARIANT

⌨️ 快捷键说明

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