db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "shahbaz chaudhary" <c_shah...@hotmail.com>
Subject RE: [PATCH] Cleanup of special function nodes
Date Thu, 20 Jan 2005 20:43:00 GMT
<html><div style='background-color:'><DIV class=RTE>
<P>Thanks!<BR><BR>Shahbaz</P></DIV>
<DIV></DIV>&gt;From: Daniel John Debrunner &lt;djd@debrunners.com&gt;
<DIV></DIV>&gt;Reply-To: "Derby Development" &lt;derby-dev@db.apache.org&gt;
<DIV></DIV>&gt;To: derby-dev &lt;derby-dev@db.apache.org&gt;
<DIV></DIV>&gt;Subject: [PATCH] Cleanup of special function nodes
<DIV></DIV>&gt;Date: Thu, 20 Jan 2005 11:21:38 -0800
<DIV></DIV>&gt;
<DIV></DIV>&gt;-----BEGIN PGP SIGNED MESSAGE-----
<DIV></DIV>&gt;Hash: SHA1
<DIV></DIV>&gt;
<DIV></DIV>&gt;I'll apply this patch by next Monday if there are no objections.
<DIV></DIV>&gt;
<DIV></DIV>&gt;This patch replaces two compile time query tree nodes
<DIV></DIV>&gt;CurrentUserNode.java and CurrentIsolationNode.java with a single node
<DIV></DIV>&gt;SpecialFunctionNode.java.
<DIV></DIV>&gt;
<DIV></DIV>&gt;The driving force behind this is footprint, the Java class file format
<DIV></DIV>&gt;imposes a penalty for multiple classes as String constants such as
<DIV></DIV>&gt;method names, signatures and class names are repeated in each class.
<DIV></DIV>&gt;E.g. if each class has a toString() method then each class will have the
<DIV></DIV>&gt;constants 'java/lang/String', 'toString' etc. In addition the jar file
<DIV></DIV>&gt;format has a per-class overhead. Thus moving common functionality into a
<DIV></DIV>&gt;single class can reduce footprint.
<DIV></DIV>&gt;
<DIV></DIV>&gt;In this case the classes CurrentUserNode (3801 bytes) and
<DIV></DIV>&gt;CurrentIsolation (2757) are replaced with a single class
<DIV></DIV>&gt;SpecialFunctionNode (4208).
<DIV></DIV>&gt;
<DIV></DIV>&gt;The downside to moving functionality into single classes is that
<DIV></DIV>&gt;typically more conditional code (if or switch statements) have to be
<DIV></DIV>&gt;executed at runtime, and thus performance can degrade. Thus a decision
<DIV></DIV>&gt;to consolidate should depend on the situation. The general rule of thumb
<DIV></DIV>&gt;has been that additional conditional logic at SQL compile time is not an
<DIV></DIV>&gt;issue, but is an issue at SQL execution time. Obviously in the case of
<DIV></DIV>&gt;SQL execution time it depends on how frequently the piece of code is
<DIV></DIV>&gt;likely to be executed by a typical application. Another consideration is
<DIV></DIV>&gt;how much visual complexity is added by combining classes, if the code is
<DIV></DIV>&gt;easier to understand in multiple classes then it should remain so.
<DIV></DIV>&gt;
<DIV></DIV>&gt;
<DIV></DIV>&gt;I saw this opportunity to consolidate classes when chaging
<DIV></DIV>&gt;IDENITY_VALUE_LOCAL to use Long instead of BigDecimal for the JSR 169
<DIV></DIV>&gt;preperation work. That function was implemented in CurrentUserNode.java
<DIV></DIV>&gt;which seemed misleading, and then I saw that node implemented other
<DIV></DIV>&gt;non-user releated functions. Looking around in the other Nodes I saw a
<DIV></DIV>&gt;pattern of special functions with near identical nodes. A blatent
<DIV></DIV>&gt;example was CurrentIsolationNode where it was obviously copied from
<DIV></DIV>&gt;CurrentUserNode as most of the comments still indicated CurrentUserNode.
<DIV></DIV>&gt;
<DIV></DIV>&gt;Thus I created SpecialFunctionNode and made it have correct up to date
<DIV></DIV>&gt;comments. It handles Special SQL functions which seem to have a pattern
<DIV></DIV>&gt;of being implemented as a method call in LanguageConnectionContext,
<DIV></DIV>&gt;though I believe other functions could be added here which are
<DIV></DIV>&gt;implemented as method calls in Activation. Basically a SQL special
<DIV></DIV>&gt;function returns state of the connection (session) or of the statement.
<DIV></DIV>&gt;
<DIV></DIV>&gt;Other Nodes I think could be consolidated into SpecialFunctionNodes are:
<DIV></DIV>&gt;
<DIV></DIV>&gt;GetCurrentConnectionNode - though this functionality should be removed,
<DIV></DIV>&gt;it has been replaced by the standard jdbc:default:connection. There is
<DIV></DIV>&gt;only one internal use of it at the moment.
<DIV></DIV>&gt;
<DIV></DIV>&gt;CurrentDatetimeOperatorNode - a little more involved, as some setup
<DIV></DIV>&gt;state manipulation has to be added.
<DIV></DIV>&gt;
<DIV></DIV>&gt;
<DIV></DIV>&gt;Hope this the type of explaination that shahbaz chaudhary was looking for.
<DIV></DIV>&gt;
<DIV></DIV>&gt;Dan.
<DIV></DIV>&gt;
<DIV></DIV>&gt;svn status outpur
<DIV></DIV>&gt;
<DIV></DIV>&gt;M&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;java\engine\org\apache\derby\impl\sql\compile\NodeFactoryImpl.java
<DIV></DIV>&gt;M&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;java\engine\org\apache\derby\impl\sql\compile\C_NodeNames.java
<DIV></DIV>&gt;M
<DIV></DIV>&gt;java\engine\org\apache\derby\impl\sql\compile\ColumnDefinitionNode.java
<DIV></DIV>&gt;M&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;java\engine\org\apache\derby\impl\sql\compile\sqlgrammar.jj
<DIV></DIV>&gt;M&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;java\engine\org\apache\derby\iapi\sql\compile\C_NodeTypes.java
<DIV></DIV>&gt;A
<DIV></DIV>&gt;java\engine\org\apache\derby\impl\sql\compile\SpecialFunctionNode.java
<DIV></DIV>&gt;D
<DIV></DIV>&gt;java\engine\org\apache\derby\impl\sql\compile\CurrentIsolationNode.java
<DIV></DIV>&gt;D&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;java\engine\org\apache\derby\impl\sql\compile\CurrentUserNode.java
<DIV></DIV>&gt;
<DIV></DIV>&gt;
<DIV></DIV>&gt;-----BEGIN PGP SIGNATURE-----
<DIV></DIV>&gt;Version: GnuPG v1.2.5 (MingW32)
<DIV></DIV>&gt;Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
<DIV></DIV>&gt;
<DIV></DIV>&gt;iD8DBQFB8ATBIv0S4qsbfuQRAnPyAJsEsNy9xpnK3GBJVkCwaceho9WragCfXf+S
<DIV></DIV>&gt;JToMu3+IEFk3zNGdmA06U4k=
<DIV></DIV>&gt;=qRdp
<DIV></DIV>&gt;-----END PGP SIGNATURE-----
<DIV></DIV>&gt;Index: java/engine/org/apache/derby/impl/sql/compile/NodeFactoryImpl.java
<DIV></DIV>&gt;===================================================================
<DIV></DIV>&gt;--- java/engine/org/apache/derby/impl/sql/compile/NodeFactoryImpl.java (revision 125645)
<DIV></DIV>&gt;+++ java/engine/org/apache/derby/impl/sql/compile/NodeFactoryImpl.java (working copy)
<DIV></DIV>&gt;@@ -197,9 +197,6 @@
<DIV></DIV>&gt;&nbsp;&nbsp; &nbsp;&nbsp;case C_NodeTypes.GROUP_BY_LIST:
<DIV></DIV>&gt;&nbsp;&nbsp; &nbsp;&nbsp; return C_NodeNames.GROUP_BY_LIST_NAME;
<DIV></DIV>&gt;
<DIV></DIV>&gt;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case C_NodeTypes.CURRENT_ISOLATION_NODE:
<DIV></DIV>&gt;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return C_NodeNames.CURRENT_ISOLATION_NAME;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;&nbsp;&nbsp; &nbsp;&nbsp;case C_NodeTypes.ORDER_BY_LIST:
<DIV></DIV>&gt;&nbsp;&nbsp; &nbsp;&nbsp; return C_NodeNames.ORDER_BY_LIST_NAME;
<DIV></DIV>&gt;
<DIV></DIV>&gt;@@ -420,8 +417,14 @@
<DIV></DIV>&gt;&nbsp;&nbsp; &nbsp;&nbsp;case C_NodeTypes.CURRENT_DATETIME_OPERATOR_NODE:
<DIV></DIV>&gt;&nbsp;&nbsp; &nbsp;&nbsp; return C_NodeNames.CURRENT_DATETIME_OPERATOR_NODE_NAME;
<DIV></DIV>&gt;
<DIV></DIV>&gt;+ &nbsp;&nbsp;case C_NodeTypes.USER_NODE:
<DIV></DIV>&gt;&nbsp;&nbsp; &nbsp;&nbsp;case C_NodeTypes.CURRENT_USER_NODE:
<DIV></DIV>&gt;- &nbsp;&nbsp; return C_NodeNames.CURRENT_USER_NODE_NAME;
<DIV></DIV>&gt;+ &nbsp;&nbsp;case C_NodeTypes.SESSION_USER_NODE:
<DIV></DIV>&gt;+ &nbsp;&nbsp;case C_NodeTypes.SYSTEM_USER_NODE:
<DIV></DIV>&gt;+ &nbsp;&nbsp;case C_NodeTypes.CURRENT_ISOLATION_NODE:
<DIV></DIV>&gt;+ &nbsp;&nbsp;case C_NodeTypes.IDENTITY_VAL_NODE:
<DIV></DIV>&gt;+ &nbsp;&nbsp;case C_NodeTypes.CURRENT_SCHEMA_NODE:
<DIV></DIV>&gt;+ &nbsp;&nbsp; return C_NodeNames.SPECIAL_FUNCTION_NODE_NAME;
<DIV></DIV>&gt;
<DIV></DIV>&gt;&nbsp;&nbsp; &nbsp;&nbsp;case C_NodeTypes.IS_NODE:
<DIV></DIV>&gt;&nbsp;&nbsp; &nbsp;&nbsp; return C_NodeNames.IS_NODE_NAME;
<DIV></DIV>&gt;Index: java/engine/org/apache/derby/impl/sql/compile/C_NodeNames.java
<DIV></DIV>&gt;===================================================================
<DIV></DIV>&gt;--- java/engine/org/apache/derby/impl/sql/compile/C_NodeNames.java (revision 125645)
<DIV></DIV>&gt;+++ java/engine/org/apache/derby/impl/sql/compile/C_NodeNames.java (working copy)
<DIV></DIV>&gt;@@ -94,13 +94,11 @@
<DIV></DIV>&gt;
<DIV></DIV>&gt;&nbsp;&nbsp; static final String CURRENT_DATETIME_OPERATOR_NODE_NAME = "org.apache.derby.impl.sql.compile.CurrentDatetimeOperatorNode";
<DIV></DIV>&gt;
<DIV></DIV>&gt;- static final String CURRENT_ISOLATION_NAME = "org.apache.derby.impl.sql.compile.CurrentIsolationNode";
<DIV></DIV>&gt;-
<DIV></DIV>&gt;&nbsp;&nbsp; static final String CURRENT_OF_NODE_NAME = "org.apache.derby.impl.sql.compile.CurrentOfNode";
<DIV></DIV>&gt;
<DIV></DIV>&gt;&nbsp;&nbsp; static final String CURRENT_ROW_LOCATION_NODE_NAME = "org.apache.derby.impl.sql.compile.CurrentRowLocationNode";
<DIV></DIV>&gt;
<DIV></DIV>&gt;- static final String CURRENT_USER_NODE_NAME = "org.apache.derby.impl.sql.compile.CurrentUserNode";
<DIV></DIV>&gt;+ static final String SPECIAL_FUNCTION_NODE_NAME = "org.apache.derby.impl.sql.compile.SpecialFunctionNode";
<DIV></DIV>&gt;
<DIV></DIV>&gt;&nbsp;&nbsp; static final String CURSOR_NODE_NAME = "org.apache.derby.impl.sql.compile.CursorNode";
<DIV></DIV>&gt;
<DIV></DIV>&gt;Index: java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java
<DIV></DIV>&gt;===================================================================
<DIV></DIV>&gt;--- java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java (revision 125645)
<DIV></DIV>&gt;+++ java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java (working copy)
<DIV></DIV>&gt;@@ -611,24 +611,27 @@
<DIV></DIV>&gt;&nbsp;&nbsp; (colType == StoredFormatIds.VARCHAR_TYPE_ID) ||
<DIV></DIV>&gt;&nbsp;&nbsp; (colType == StoredFormatIds.LONGVARCHAR_TYPE_ID));
<DIV></DIV>&gt;
<DIV></DIV>&gt;- if (defaultNode instanceof CurrentUserNode) {
<DIV></DIV>&gt;+ if (defaultNode instanceof SpecialFunctionNode) {
<DIV></DIV>&gt;
<DIV></DIV>&gt;- defaultText = defaultText.toLowerCase(java.util.Locale.ENGLISH);
<DIV></DIV>&gt;- if (defaultText.indexOf("user") != -1)
<DIV></DIV>&gt;+ switch (defaultNode.getNodeType())
<DIV></DIV>&gt;+ {
<DIV></DIV>&gt;+ case C_NodeTypes.USER_NODE:
<DIV></DIV>&gt;+ case C_NodeTypes.CURRENT_USER_NODE:
<DIV></DIV>&gt;+ case C_NodeTypes.SESSION_USER_NODE:
<DIV></DIV>&gt;+ case C_NodeTypes.SYSTEM_USER_NODE:
<DIV></DIV>&gt;&nbsp;&nbsp; // DB2 enforces min length of 8.
<DIV></DIV>&gt;&nbsp;&nbsp; // Note also: any size under 30 gives a warning in DB2.
<DIV></DIV>&gt;&nbsp;&nbsp; return (charCol &amp;&amp; (columnDesc.getMaximumWidth() &gt;=
<DIV></DIV>&gt;&nbsp;&nbsp; DB2Limit.MIN_COL_LENGTH_FOR_CURRENT_USER));
<DIV></DIV>&gt;
<DIV></DIV>&gt;- if ((defaultText.indexOf("schema") != -1) ||
<DIV></DIV>&gt;- (defaultText.indexOf("sqlid") != -1))
<DIV></DIV>&gt;+ case C_NodeTypes.CURRENT_SCHEMA_NODE:
<DIV></DIV>&gt;&nbsp;&nbsp; // DB2 enforces min length of 128.
<DIV></DIV>&gt;&nbsp;&nbsp; return (charCol &amp;&amp; (columnDesc.getMaximumWidth() &gt;=
<DIV></DIV>&gt;&nbsp;&nbsp; DB2Limit.MIN_COL_LENGTH_FOR_CURRENT_SCHEMA));
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- // else, function not allowed.
<DIV></DIV>&gt;- return false;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;+ default:
<DIV></DIV>&gt;+ // else, function not allowed.
<DIV></DIV>&gt;+ return false;
<DIV></DIV>&gt;+ }
<DIV></DIV>&gt;&nbsp;&nbsp; }
<DIV></DIV>&gt;
<DIV></DIV>&gt;&nbsp;&nbsp; }
<DIV></DIV>&gt;Index: java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
<DIV></DIV>&gt;===================================================================
<DIV></DIV>&gt;--- java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (revision 125645)
<DIV></DIV>&gt;+++ java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (working copy)
<DIV></DIV>&gt;@@ -92,7 +92,6 @@
<DIV></DIV>&gt;&nbsp;&nbsp;import org.apache.derby.impl.sql.compile.ValueNode;
<DIV></DIV>&gt;&nbsp;&nbsp;import org.apache.derby.impl.sql.compile.ValueNodeList;
<DIV></DIV>&gt;&nbsp;&nbsp;import org.apache.derby.impl.sql.compile.GroupByColumn;
<DIV></DIV>&gt;-import org.apache.derby.impl.sql.compile.CurrentUserNode;
<DIV></DIV>&gt;&nbsp;&nbsp;import org.apache.derby.impl.sql.compile.CurrentDatetimeOperatorNode;
<DIV></DIV>&gt;&nbsp;&nbsp;import org.apache.derby.impl.sql.compile.CreateStatementNode;
<DIV></DIV>&gt;&nbsp;&nbsp;import org.apache.derby.impl.sql.compile.AlterTableNode;
<DIV></DIV>&gt;@@ -5511,8 +5510,7 @@
<DIV></DIV>&gt;&nbsp;&nbsp; &lt;IDENTITY_VAL_LOCAL&gt; &lt;LEFT_PAREN&gt; &lt;RIGHT_PAREN&gt;
<DIV></DIV>&gt;&nbsp;&nbsp; {
<DIV></DIV>&gt;&nbsp;&nbsp; return (ValueNode) nodeFactory.getNode(
<DIV></DIV>&gt;- C_NodeTypes.CURRENT_USER_NODE,
<DIV></DIV>&gt;- ReuseFactory.getInteger(CurrentUserNode.IDENTITY_VAL),
<DIV></DIV>&gt;+ C_NodeTypes.IDENTITY_VAL_NODE,
<DIV></DIV>&gt;&nbsp;&nbsp; getContextManager());
<DIV></DIV>&gt;&nbsp;&nbsp; }
<DIV></DIV>&gt;&nbsp;&nbsp;}
<DIV></DIV>&gt;@@ -5742,8 +5740,7 @@
<DIV></DIV>&gt;&nbsp;&nbsp; &lt;CURRENT&gt; (&lt;SCHEMA&gt; | &lt;SQLID&gt;)
<DIV></DIV>&gt;&nbsp;&nbsp; {
<DIV></DIV>&gt;&nbsp;&nbsp; return (ValueNode) nodeFactory.getNode(
<DIV></DIV>&gt;- C_NodeTypes.CURRENT_USER_NODE,
<DIV></DIV>&gt;- ReuseFactory.getInteger(CurrentUserNode.SCHEMA),
<DIV></DIV>&gt;+ C_NodeTypes.CURRENT_SCHEMA_NODE,
<DIV></DIV>&gt;&nbsp;&nbsp; getContextManager());
<DIV></DIV>&gt;&nbsp;&nbsp; }
<DIV></DIV>&gt;&nbsp;&nbsp;|
<DIV></DIV>&gt;@@ -6170,8 +6167,7 @@
<DIV></DIV>&gt;&nbsp;&nbsp; &lt;USER&gt;
<DIV></DIV>&gt;&nbsp;&nbsp; {
<DIV></DIV>&gt;&nbsp;&nbsp; return (ValueNode) nodeFactory.getNode(
<DIV></DIV>&gt;- C_NodeTypes.CURRENT_USER_NODE,
<DIV></DIV>&gt;- ReuseFactory.getInteger(CurrentUserNode.USER),
<DIV></DIV>&gt;+ C_NodeTypes.USER_NODE,
<DIV></DIV>&gt;&nbsp;&nbsp; getContextManager());
<DIV></DIV>&gt;&nbsp;&nbsp; }
<DIV></DIV>&gt;&nbsp;&nbsp;|
<DIV></DIV>&gt;@@ -6179,15 +6175,13 @@
<DIV></DIV>&gt;&nbsp;&nbsp; {
<DIV></DIV>&gt;&nbsp;&nbsp; return (ValueNode) nodeFactory.getNode(
<DIV></DIV>&gt;&nbsp;&nbsp; C_NodeTypes.CURRENT_USER_NODE,
<DIV></DIV>&gt;- ReuseFactory.getInteger(CurrentUserNode.CURRENT_USER),
<DIV></DIV>&gt;&nbsp;&nbsp; getContextManager());
<DIV></DIV>&gt;&nbsp;&nbsp; }
<DIV></DIV>&gt;&nbsp;&nbsp;|
<DIV></DIV>&gt;&nbsp;&nbsp; &lt;SESSION_USER&gt;
<DIV></DIV>&gt;&nbsp;&nbsp; {
<DIV></DIV>&gt;&nbsp;&nbsp; return (ValueNode) nodeFactory.getNode(
<DIV></DIV>&gt;- C_NodeTypes.CURRENT_USER_NODE,
<DIV></DIV>&gt;- ReuseFactory.getInteger(CurrentUserNode.SESSION_USER),
<DIV></DIV>&gt;+ C_NodeTypes.SESSION_USER_NODE,
<DIV></DIV>&gt;&nbsp;&nbsp; getContextManager());
<DIV></DIV>&gt;&nbsp;&nbsp; }
<DIV></DIV>&gt;&nbsp;&nbsp;}
<DIV></DIV>&gt;@@ -9210,16 +9204,14 @@
<DIV></DIV>&gt;&nbsp;&nbsp; &lt;CURRENT&gt; (&lt;SCHEMA&gt; | &lt;SQLID&gt;)
<DIV></DIV>&gt;&nbsp;&nbsp; {
<DIV></DIV>&gt;&nbsp;&nbsp; return (ValueNode) nodeFactory.getNode(
<DIV></DIV>&gt;- C_NodeTypes.CURRENT_USER_NODE,
<DIV></DIV>&gt;- ReuseFactory.getInteger(CurrentUserNode.SCHEMA),
<DIV></DIV>&gt;+ C_NodeTypes.CURRENT_SCHEMA_NODE,
<DIV></DIV>&gt;&nbsp;&nbsp; getContextManager());
<DIV></DIV>&gt;&nbsp;&nbsp; }
<DIV></DIV>&gt;&nbsp;&nbsp;|
<DIV></DIV>&gt;&nbsp;&nbsp; &lt;USER&gt;
<DIV></DIV>&gt;&nbsp;&nbsp; {
<DIV></DIV>&gt;&nbsp;&nbsp; return (ValueNode) nodeFactory.getNode(
<DIV></DIV>&gt;- C_NodeTypes.CURRENT_USER_NODE,
<DIV></DIV>&gt;- ReuseFactory.getInteger(CurrentUserNode.USER),
<DIV></DIV>&gt;+ C_NodeTypes.USER_NODE,
<DIV></DIV>&gt;&nbsp;&nbsp; getContextManager());
<DIV></DIV>&gt;&nbsp;&nbsp; }
<DIV></DIV>&gt;&nbsp;&nbsp;|
<DIV></DIV>&gt;Index: java/engine/org/apache/derby/iapi/sql/compile/C_NodeTypes.java
<DIV></DIV>&gt;===================================================================
<DIV></DIV>&gt;--- java/engine/org/apache/derby/iapi/sql/compile/C_NodeTypes.java (revision 125645)
<DIV></DIV>&gt;+++ java/engine/org/apache/derby/iapi/sql/compile/C_NodeTypes.java (working copy)
<DIV></DIV>&gt;@@ -34,8 +34,8 @@
<DIV></DIV>&gt;&nbsp;&nbsp; static final int CURRENT_ROW_LOCATION_NODE = 2;
<DIV></DIV>&gt;&nbsp;&nbsp; static final int GROUP_BY_LIST = 3;
<DIV></DIV>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static final int CURRENT_ISOLATION_NODE = 4;
<DIV></DIV>&gt;- // 5 available;
<DIV></DIV>&gt;- // 6 available
<DIV></DIV>&gt;+ static final int IDENTITY_VAL_NODE = 5;
<DIV></DIV>&gt;+ static final int CURRENT_SCHEMA_NODE = 6;
<DIV></DIV>&gt;&nbsp;&nbsp; static final int ORDER_BY_LIST = 7;
<DIV></DIV>&gt;&nbsp;&nbsp; static final int PREDICATE_LIST = 8;
<DIV></DIV>&gt;&nbsp;&nbsp; static final int RESULT_COLUMN_LIST = 9;
<DIV></DIV>&gt;@@ -137,8 +137,8 @@
<DIV></DIV>&gt;&nbsp;&nbsp; // 106 is available
<DIV></DIV>&gt;&nbsp;&nbsp; static final int VIRTUAL_COLUMN_NODE = 107;
<DIV></DIV>&gt;&nbsp;&nbsp; static final int CURRENT_DATETIME_OPERATOR_NODE = 108;
<DIV></DIV>&gt;- static final int CURRENT_USER_NODE = 109;
<DIV></DIV>&gt;- // 110 is available
<DIV></DIV>&gt;+ static final int CURRENT_USER_NODE = 109; // special function CURRENT_USER
<DIV></DIV>&gt;+ static final int USER_NODE = 110; // // special function USER
<DIV></DIV>&gt;&nbsp;&nbsp; static final int IS_NODE = 111;
<DIV></DIV>&gt;&nbsp;&nbsp; static final int LOCK_TABLE_NODE = 112;
<DIV></DIV>&gt;&nbsp;&nbsp; // 113
<DIV></DIV>&gt;@@ -153,8 +153,8 @@
<DIV></DIV>&gt;&nbsp;&nbsp; static final int NORMALIZE_RESULT_SET_NODE = 122;
<DIV></DIV>&gt;&nbsp;&nbsp; static final int SCROLL_INSENSITIVE_RESULT_SET_NODE = 123;
<DIV></DIV>&gt;&nbsp;&nbsp; static final int DISTINCT_NODE = 124;
<DIV></DIV>&gt;- // 125 available
<DIV></DIV>&gt;- // 126 available
<DIV></DIV>&gt;+ static final int SESSION_USER_NODE = 125; // // special function SESSION_USER
<DIV></DIV>&gt;+ static final int SYSTEM_USER_NODE = 126; // // special function SYSTEM_USER
<DIV></DIV>&gt;&nbsp;&nbsp; static final int TRIM_OPERATOR_NODE = 127;
<DIV></DIV>&gt;&nbsp;&nbsp; // 128 is available
<DIV></DIV>&gt;&nbsp;&nbsp; static final int SELECT_NODE = 129;
<DIV></DIV>&gt;Index: java/engine/org/apache/derby/impl/sql/compile/SpecialFunctionNode.java
<DIV></DIV>&gt;===================================================================
<DIV></DIV>&gt;--- java/engine/org/apache/derby/impl/sql/compile/SpecialFunctionNode.java (revision 0)
<DIV></DIV>&gt;+++ java/engine/org/apache/derby/impl/sql/compile/SpecialFunctionNode.java (revision 0)
<DIV></DIV>&gt;@@ -0,0 +1,224 @@
<DIV></DIV>&gt;+/*
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+&nbsp;&nbsp; Derby - Class org.apache.derby.impl.sql.compile.SpecialFunctionNode
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+&nbsp;&nbsp; Copyright 1999, 2005 The Apache Software Foundation or its licensors, as applicable.
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+&nbsp;&nbsp; Licensed under the Apache License, Version 2.0 (the "License");
<DIV></DIV>&gt;+&nbsp;&nbsp; you may not use this file except in compliance with the License.
<DIV></DIV>&gt;+&nbsp;&nbsp; You may obtain a copy of the License at
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://www.apache.org/licenses/LICENSE-2.0
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+&nbsp;&nbsp; Unless required by applicable law or agreed to in writing, software
<DIV></DIV>&gt;+&nbsp;&nbsp; distributed under the License is distributed on an "AS IS" BASIS,
<DIV></DIV>&gt;+&nbsp;&nbsp; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<DIV></DIV>&gt;+&nbsp;&nbsp; See the License for the specific language governing permissions and
<DIV></DIV>&gt;+&nbsp;&nbsp; limitations under the License.
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ */
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+package org.apache.derby.impl.sql.compile;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+import org.apache.derby.iapi.sql.compile.CompilerContext;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+import org.apache.derby.iapi.types.DataTypeDescriptor;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+import org.apache.derby.iapi.services.compiler.MethodBuilder;
<DIV></DIV>&gt;+import org.apache.derby.iapi.services.compiler.LocalField;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+import org.apache.derby.iapi.services.sanity.SanityManager;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+import org.apache.derby.iapi.store.access.Qualifier;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+import java.lang.reflect.Modifier;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+import org.apache.derby.iapi.error.StandardException;
<DIV></DIV>&gt;+import org.apache.derby.iapi.reference.ClassName;
<DIV></DIV>&gt;+import org.apache.derby.iapi.services.classfile.VMOpcode;
<DIV></DIV>&gt;+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+import java.sql.Types;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+import java.util.Vector;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+/**
<DIV></DIV>&gt;+&nbsp;&nbsp;&nbsp;&nbsp; SpecialFunctionNode handles system SQL functions.
<DIV></DIV>&gt;+ A function value is either obtained by a method
<DIV></DIV>&gt;+ call off the LanguageConnectionContext or Activation.
<DIV></DIV>&gt;+ LanguageConnectionContext functions are state related to the connection.
<DIV></DIV>&gt;+ Activation functions are those related to the statement execution.
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+&nbsp;&nbsp;&nbsp;&nbsp; Each SQL function takes no arguments and returns a SQLvalue.
<DIV></DIV>&gt;+ &lt;P&gt;
<DIV></DIV>&gt;+ Functions supported:
<DIV></DIV>&gt;+ &lt;UL&gt;
<DIV></DIV>&gt;+ &lt;LI&gt; USER
<DIV></DIV>&gt;+ &lt;LI&gt; CURRENT_USER
<DIV></DIV>&gt;+ &lt;LI&gt; SESSION_USER
<DIV></DIV>&gt;+ &lt;LI&gt; SYSTEM_USER
<DIV></DIV>&gt;+ &lt;LI&gt; CURRENT SCHEMA
<DIV></DIV>&gt;+ &lt;LI&gt; CURRENT ISOLATION
<DIV></DIV>&gt;+ &lt;LI&gt; IDENTITY_VAL_LOCAL
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ &lt;/UL&gt;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ &lt;P&gt;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ This node is used rather than some use of MethodCallNode for
<DIV></DIV>&gt;+ runtime performance. MethodCallNode does not provide a fast access
<DIV></DIV>&gt;+ to the current language connection or activatation, since it is geared
<DIV></DIV>&gt;+ towards user defined routines.
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+*/
<DIV></DIV>&gt;+public class SpecialFunctionNode extends ValueNode
<DIV></DIV>&gt;+{
<DIV></DIV>&gt;+ /**
<DIV></DIV>&gt;+ Name of SQL function
<DIV></DIV>&gt;+ */
<DIV></DIV>&gt;+ String sqlName;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ /**
<DIV></DIV>&gt;+ Java method name
<DIV></DIV>&gt;+ */
<DIV></DIV>&gt;+ private String methodName;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ /**
<DIV></DIV>&gt;+ Return type of Java method.
<DIV></DIV>&gt;+ */
<DIV></DIV>&gt;+ private String methodType;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ /**
<DIV></DIV>&gt;+ */
<DIV></DIV>&gt;+ //private boolean isActivationCall;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ /**
<DIV></DIV>&gt;+ * Binding this special function means setting the result DataTypeServices.
<DIV></DIV>&gt;+ * In this case, the result type is based on the operation requested.
<DIV></DIV>&gt;+ *
<DIV></DIV>&gt;+ * @param fromList The FROM list for the statement.&nbsp;&nbsp;This parameter
<DIV></DIV>&gt;+ * is not used in this case.
<DIV></DIV>&gt;+ * @param subqueryList The subquery list being built as we find
<DIV></DIV>&gt;+ * SubqueryNodes. Not used in this case.
<DIV></DIV>&gt;+ * @param aggregateVector The aggregate vector being built as we find
<DIV></DIV>&gt;+ * AggregateNodes. Not used in this case.
<DIV></DIV>&gt;+ *
<DIV></DIV>&gt;+ * @return The new top of the expression tree.
<DIV></DIV>&gt;+ *
<DIV></DIV>&gt;+ * @exception StandardException Thrown on error
<DIV></DIV>&gt;+ */
<DIV></DIV>&gt;+ public ValueNode bindExpression(FromList fromList, SubqueryList subqueryList,
<DIV></DIV>&gt;+ Vector aggregateVector)
<DIV></DIV>&gt;+ throws StandardException
<DIV></DIV>&gt;+ { DataTypeDescriptor dtd;
<DIV></DIV>&gt;+ int nodeType = getNodeType();
<DIV></DIV>&gt;+ switch (nodeType)
<DIV></DIV>&gt;+ {
<DIV></DIV>&gt;+ case C_NodeTypes.USER_NODE:
<DIV></DIV>&gt;+ case C_NodeTypes.CURRENT_USER_NODE:
<DIV></DIV>&gt;+ case C_NodeTypes.SESSION_USER_NODE:
<DIV></DIV>&gt;+ case C_NodeTypes.SYSTEM_USER_NODE:
<DIV></DIV>&gt;+ switch (nodeType)
<DIV></DIV>&gt;+ {
<DIV></DIV>&gt;+ case C_NodeTypes.USER_NODE: sqlName = "USER"; break;
<DIV></DIV>&gt;+ case C_NodeTypes.CURRENT_USER_NODE: sqlName = "CURRENT_USER"; break;
<DIV></DIV>&gt;+ case C_NodeTypes.SESSION_USER_NODE: sqlName = "SESSION_USER"; break;
<DIV></DIV>&gt;+ case C_NodeTypes.SYSTEM_USER_NODE: sqlName = "SYSTEM_USER"; break;
<DIV></DIV>&gt;+ }
<DIV></DIV>&gt;+ methodName = "getAuthorizationId";
<DIV></DIV>&gt;+ methodType = "java.lang.String";
<DIV></DIV>&gt;+ dtd = DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR, false, 128);
<DIV></DIV>&gt;+ break;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ case C_NodeTypes.CURRENT_SCHEMA_NODE:
<DIV></DIV>&gt;+ sqlName = "CURRENT SCHEMA";
<DIV></DIV>&gt;+ methodName = "getCurrentSchemaName";
<DIV></DIV>&gt;+ methodType = "java.lang.String";
<DIV></DIV>&gt;+ dtd = DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR, false, 128);
<DIV></DIV>&gt;+ break;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ case C_NodeTypes.IDENTITY_VAL_NODE:
<DIV></DIV>&gt;+ sqlName = "IDENTITY_VAL_LOCAL";
<DIV></DIV>&gt;+ methodName = "getIdentityValue";
<DIV></DIV>&gt;+ methodType = "java.lang.Long";
<DIV></DIV>&gt;+ dtd = DataTypeDescriptor.getSQLDataTypeDescriptor("java.math.BigDecimal", 31, 0, true, 31);
<DIV></DIV>&gt;+ break;
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ case C_NodeTypes.CURRENT_ISOLATION_NODE:
<DIV></DIV>&gt;+ sqlName = "CURRENT ISOLATION";
<DIV></DIV>&gt;+ methodName = "getCurrentIsolationLevelStr";
<DIV></DIV>&gt;+ methodType = "java.lang.String";
<DIV></DIV>&gt;+ dtd = DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.CHAR, 2);
<DIV></DIV>&gt;+ break;
<DIV></DIV>&gt;+ default:
<DIV></DIV>&gt;+ if (SanityManager.DEBUG)
<DIV></DIV>&gt;+ {
<DIV></DIV>&gt;+ SanityManager.THROWASSERT("Invalid type for SpecialFunctionNode " + nodeType);
<DIV></DIV>&gt;+ }
<DIV></DIV>&gt;+ dtd = null;
<DIV></DIV>&gt;+ break;
<DIV></DIV>&gt;+ }
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ checkReliability(sqlName, CompilerContext.USER_ILLEGAL );
<DIV></DIV>&gt;+ setType(dtd);
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ return this;
<DIV></DIV>&gt;+ }
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ /**
<DIV></DIV>&gt;+ * Return the variant type for the underlying expression.
<DIV></DIV>&gt;+ &nbsp;&nbsp; All supported special functions are QUERY_INVARIANT
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ *
<DIV></DIV>&gt;+ * @return The variant type for the underlying expression.
<DIV></DIV>&gt;+ */
<DIV></DIV>&gt;+ protected int getOrderableVariantType()
<DIV></DIV>&gt;+ {
<DIV></DIV>&gt;+ return Qualifier.QUERY_INVARIANT;
<DIV></DIV>&gt;+ }
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ /**
<DIV></DIV>&gt;+ Generate an expression that returns a DataValueDescriptor and
<DIV></DIV>&gt;+ calls a method off the language connection or the activation.
<DIV></DIV>&gt;+ *
<DIV></DIV>&gt;+ * @param acb The ExpressionClassBuilder for the class being built
<DIV></DIV>&gt;+ * @param mb The method the code to place the code
<DIV></DIV>&gt;+ *
<DIV></DIV>&gt;+ *
<DIV></DIV>&gt;+ * @exception StandardException Thrown on error
<DIV></DIV>&gt;+ */
<DIV></DIV>&gt;+ public void generateExpression(ExpressionClassBuilder acb,
<DIV></DIV>&gt;+ MethodBuilder mb)
<DIV></DIV>&gt;+ throws StandardException
<DIV></DIV>&gt;+ {
<DIV></DIV>&gt;+ mb.pushThis();
<DIV></DIV>&gt;+ mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.Activation, "getLanguageConnectionContext",
<DIV></DIV>&gt;+ ClassName.LanguageConnectionContext, 0);
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null, methodName, methodType, 0);
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ String fieldType = getTypeCompiler().interfaceName();
<DIV></DIV>&gt;+ LocalField field = acb.newFieldDeclaration(Modifier.PRIVATE, fieldType);
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ acb.generateDataValue(mb, getTypeCompiler(), field);
<DIV></DIV>&gt;+ }
<DIV></DIV>&gt;+
<DIV></DIV>&gt;+ /*
<DIV></DIV>&gt;+ print the non-node subfields
<DIV></DIV>&gt;+ */
<DIV></DIV>&gt;+ public String toString() {
<DIV></DIV>&gt;+ if (SanityManager.DEBUG)
<DIV></DIV>&gt;+ {
<DIV></DIV>&gt;+ return super.toString()+ sqlName;
<DIV></DIV>&gt;+ }
<DIV></DIV>&gt;+ else
<DIV></DIV>&gt;+ {
<DIV></DIV>&gt;+ return "";
<DIV></DIV>&gt;+ }
<DIV></DIV>&gt;+ }
<DIV></DIV>&gt;+}
<DIV></DIV>&gt;Index: java/engine/org/apache/derby/impl/sql/compile/CurrentIsolationNode.java
<DIV></DIV>&gt;===================================================================
<DIV></DIV>&gt;--- java/engine/org/apache/derby/impl/sql/compile/CurrentIsolationNode.java (revision 125645)
<DIV></DIV>&gt;+++ java/engine/org/apache/derby/impl/sql/compile/CurrentIsolationNode.java (working copy)
<DIV></DIV>&gt;@@ -1,136 +0,0 @@
<DIV></DIV>&gt;-/*
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-&nbsp;&nbsp; Derby - Class org.apache.derby.impl.sql.compile.CurrentIsolationNode
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-&nbsp;&nbsp; Copyright 2004 The Apache Software Foundation or its licensors, as applicable.
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-&nbsp;&nbsp; Licensed under the Apache License, Version 2.0 (the "License");
<DIV></DIV>&gt;-&nbsp;&nbsp; you may not use this file except in compliance with the License.
<DIV></DIV>&gt;-&nbsp;&nbsp; You may obtain a copy of the License at
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://www.apache.org/licenses/LICENSE-2.0
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-&nbsp;&nbsp; Unless required by applicable law or agreed to in writing, software
<DIV></DIV>&gt;-&nbsp;&nbsp; distributed under the License is distributed on an "AS IS" BASIS,
<DIV></DIV>&gt;-&nbsp;&nbsp; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<DIV></DIV>&gt;-&nbsp;&nbsp; See the License for the specific language governing permissions and
<DIV></DIV>&gt;-&nbsp;&nbsp; limitations under the License.
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- */
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-package org.apache.derby.impl.sql.compile;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import org.apache.derby.iapi.store.access.Qualifier;
<DIV></DIV>&gt;-import org.apache.derby.iapi.error.StandardException;
<DIV></DIV>&gt;-import org.apache.derby.iapi.types.DataTypeDescriptor;
<DIV></DIV>&gt;-import org.apache.derby.iapi.services.compiler.MethodBuilder;
<DIV></DIV>&gt;-import org.apache.derby.iapi.services.compiler.LocalField;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import org.apache.derby.iapi.services.sanity.SanityManager;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import org.apache.derby.iapi.services.classfile.VMOpcode;
<DIV></DIV>&gt;-import org.apache.derby.iapi.reference.ClassName;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import java.lang.reflect.Modifier;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import java.sql.Types;
<DIV></DIV>&gt;-import java.util.Vector;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-/**
<DIV></DIV>&gt;- * The CurrentIsolationNode is for the CURRENT ISOLATION special register
<DIV></DIV>&gt;- *
<DIV></DIV>&gt;- * @author Jack Klebanoff
<DIV></DIV>&gt;- */
<DIV></DIV>&gt;-public class CurrentIsolationNode extends ValueNode
<DIV></DIV>&gt;-{
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- /**
<DIV></DIV>&gt;- * Return the variant type for the underlying expression.
<DIV></DIV>&gt;- * The variant type can be:
<DIV></DIV>&gt;- * VARIANT - variant within a scan
<DIV></DIV>&gt;- * &nbsp;&nbsp;(method calls and non-static field access)
<DIV></DIV>&gt;- * SCAN_INVARIANT - invariant within a scan
<DIV></DIV>&gt;- * &nbsp;&nbsp;(column references from outer tables)
<DIV></DIV>&gt;- * QUERY_INVARIANT - invariant within the life of a query
<DIV></DIV>&gt;- * &nbsp;&nbsp;(constant expressions)
<DIV></DIV>&gt;- *
<DIV></DIV>&gt;- * @return The variant type for the underlying expression.
<DIV></DIV>&gt;- */
<DIV></DIV>&gt;- protected int getOrderableVariantType()
<DIV></DIV>&gt;- {
<DIV></DIV>&gt;- // CurrentDate, Time, Timestamp are invariant for the life of the query
<DIV></DIV>&gt;- return Qualifier.QUERY_INVARIANT;
<DIV></DIV>&gt;- }
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- //
<DIV></DIV>&gt;- // QueryTreeNode interface
<DIV></DIV>&gt;- //
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- /**
<DIV></DIV>&gt;- * Binding this expression means setting the result DataTypeServices.
<DIV></DIV>&gt;- * In this case, the result type is based on the operation requested.
<DIV></DIV>&gt;- *
<DIV></DIV>&gt;- * @param fromList The FROM list for the statement.&nbsp;&nbsp;This parameter
<DIV></DIV>&gt;- * is not used in this case.
<DIV></DIV>&gt;- * @param subqueryList The subquery list being built as we find
<DIV></DIV>&gt;- * SubqueryNodes. Not used in this case.
<DIV></DIV>&gt;- * @param aggregateVector The aggregate vector being built as we find
<DIV></DIV>&gt;- * AggregateNodes. Not used in this case.
<DIV></DIV>&gt;- *
<DIV></DIV>&gt;- * @return The new top of the expression tree.
<DIV></DIV>&gt;- *
<DIV></DIV>&gt;- * @exception StandardException Thrown on error
<DIV></DIV>&gt;- */
<DIV></DIV>&gt;- public ValueNode bindExpression(FromList fromList, SubqueryList subqueryList,
<DIV></DIV>&gt;- Vector aggregateVector)
<DIV></DIV>&gt;- throws StandardException
<DIV></DIV>&gt;- {
<DIV></DIV>&gt;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setType( DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.CHAR, 2));
<DIV></DIV>&gt;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return this;
<DIV></DIV>&gt;-&nbsp;&nbsp;&nbsp;&nbsp;}
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- /**
<DIV></DIV>&gt;- * CurrentDatetimeOperatorNode is used in expressions.
<DIV></DIV>&gt;- * The expression generated for it invokes a static method
<DIV></DIV>&gt;- * on a special Cloudscape type to get the system time and
<DIV></DIV>&gt;- * wrap it in the right java.sql type, and then wrap it
<DIV></DIV>&gt;- * into the right shape for an arbitrary value, i.e. a column
<DIV></DIV>&gt;- * holder. This is very similar to what constants do.
<DIV></DIV>&gt;- *
<DIV></DIV>&gt;- * @param acb The ExpressionClassBuilder for the class being built
<DIV></DIV>&gt;- * @param mb The method the code to place the code
<DIV></DIV>&gt;- *
<DIV></DIV>&gt;- *
<DIV></DIV>&gt;- * @exception StandardException Thrown on error
<DIV></DIV>&gt;- */
<DIV></DIV>&gt;- public void generateExpression(ExpressionClassBuilder acb,
<DIV></DIV>&gt;- MethodBuilder mb)
<DIV></DIV>&gt;- throws StandardException
<DIV></DIV>&gt;- {
<DIV></DIV>&gt;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mb.pushThis();
<DIV></DIV>&gt;- mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.Activation, "getLanguageConnectionContext",
<DIV></DIV>&gt;- ClassName.LanguageConnectionContext, 0);
<DIV></DIV>&gt;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null, "getCurrentIsolationLevelStr", "java.lang.String", 0);
<DIV></DIV>&gt;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String fieldType = getTypeCompiler().interfaceName();
<DIV></DIV>&gt;- LocalField field = acb.newFieldDeclaration(Modifier.PRIVATE, fieldType);
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- acb.generateDataValue(mb, getTypeCompiler(), field);
<DIV></DIV>&gt;- } // end of generateExpression
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-&nbsp;&nbsp;&nbsp;&nbsp;public String toString()
<DIV></DIV>&gt;-&nbsp;&nbsp;&nbsp;&nbsp;{
<DIV></DIV>&gt;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (SanityManager.DEBUG)
<DIV></DIV>&gt;- {
<DIV></DIV>&gt;- return super.toString() + "\n";
<DIV></DIV>&gt;- }
<DIV></DIV>&gt;- else
<DIV></DIV>&gt;- {
<DIV></DIV>&gt;- return "";
<DIV></DIV>&gt;- }
<DIV></DIV>&gt;- }
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-}
<DIV></DIV>&gt;Index: java/engine/org/apache/derby/impl/sql/compile/CurrentUserNode.java
<DIV></DIV>&gt;===================================================================
<DIV></DIV>&gt;--- java/engine/org/apache/derby/impl/sql/compile/CurrentUserNode.java (revision 125645)
<DIV></DIV>&gt;+++ java/engine/org/apache/derby/impl/sql/compile/CurrentUserNode.java (working copy)
<DIV></DIV>&gt;@@ -1,210 +0,0 @@
<DIV></DIV>&gt;-/*
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-&nbsp;&nbsp; Derby - Class org.apache.derby.impl.sql.compile.CurrentUserNode
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-&nbsp;&nbsp; Copyright 1999, 2004 The Apache Software Foundation or its licensors, as applicable.
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-&nbsp;&nbsp; Licensed under the Apache License, Version 2.0 (the "License");
<DIV></DIV>&gt;-&nbsp;&nbsp; you may not use this file except in compliance with the License.
<DIV></DIV>&gt;-&nbsp;&nbsp; You may obtain a copy of the License at
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://www.apache.org/licenses/LICENSE-2.0
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-&nbsp;&nbsp; Unless required by applicable law or agreed to in writing, software
<DIV></DIV>&gt;-&nbsp;&nbsp; distributed under the License is distributed on an "AS IS" BASIS,
<DIV></DIV>&gt;-&nbsp;&nbsp; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<DIV></DIV>&gt;-&nbsp;&nbsp; See the License for the specific language governing permissions and
<DIV></DIV>&gt;-&nbsp;&nbsp; limitations under the License.
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- */
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-package org.apache.derby.impl.sql.compile;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import org.apache.derby.iapi.sql.compile.CompilerContext;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import org.apache.derby.iapi.sql.dictionary.DataDictionary;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import org.apache.derby.iapi.types.DataTypeDescriptor;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import org.apache.derby.iapi.services.compiler.MethodBuilder;
<DIV></DIV>&gt;-import org.apache.derby.iapi.services.compiler.LocalField;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import org.apache.derby.iapi.services.sanity.SanityManager;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import org.apache.derby.iapi.store.access.Qualifier;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import java.lang.reflect.Modifier;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import org.apache.derby.iapi.error.StandardException;
<DIV></DIV>&gt;-import org.apache.derby.iapi.reference.ClassName;
<DIV></DIV>&gt;-import org.apache.derby.iapi.services.classfile.VMOpcode;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import java.sql.Types;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-import java.util.Vector;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;-/**
<DIV></DIV>&gt;- * The CurrentUser operator is for the builtin USER, CURRENT_USER,
<DIV></DIV>&gt;- * SESSION_USER, CURRENT SCHEMA AND IDENTITY_VAL_LOCAL() operations.
<DIV></DIV>&gt;- *
<DIV></DIV>&gt;- * @author jerry
<DIV></DIV>&gt;- */
<DIV></DIV>&gt;-public class CurrentUserNode extends ValueNode
<DIV></DIV>&gt;-{
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- public static final int USER = 0;
<DIV></DIV>&gt;- public static final int CURRENT_USER = 1;
<DIV></DIV>&gt;- public static final int SESSION_USER = 2;
<DIV></DIV>&gt;- public static final int SYSTEM_USER = 3;
<DIV></DIV>&gt;- public static final int SCHEMA = 4;
<DIV></DIV>&gt;- public static final int IDENTITY_VAL = 5;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- private int whichType;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- public void init(Object whichType)
<DIV></DIV>&gt;- {
<DIV></DIV>&gt;- this.whichType = ((Integer) whichType).intValue();
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- if (SanityManager.DEBUG)
<DIV></DIV>&gt;- {
<DIV></DIV>&gt;- SanityManager.ASSERT(((this.whichType &gt;= 0 &amp;&amp; this.whichType &lt;= 2) ||
<DIV></DIV>&gt;- this.whichType == 4 || this.whichType == 5),
<DIV></DIV>&gt;- "whichType expected to be between 0 and 2 or 4 and 5");
<DIV></DIV>&gt;- }
<DIV></DIV>&gt;- }
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- //
<DIV></DIV>&gt;- // QueryTreeNode interface
<DIV></DIV>&gt;- //
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- /**
<DIV></DIV>&gt;- * Binding this expression means setting the result DataTypeServices.
<DIV></DIV>&gt;- * In this case, the result type is based on the operation requested.
<DIV></DIV>&gt;- *
<DIV></DIV>&gt;- * @param fromList The FROM list for the statement.&nbsp;&nbsp;This parameter
<DIV></DIV>&gt;- * is not used in this case.
<DIV></DIV>&gt;- * @param subqueryList The subquery list being built as we find
<DIV></DIV>&gt;- * SubqueryNodes. Not used in this case.
<DIV></DIV>&gt;- * @param aggregateVector The aggregate vector being built as we find
<DIV></DIV>&gt;- * AggregateNodes. Not used in this case.
<DIV></DIV>&gt;- *
<DIV></DIV>&gt;- * @return The new top of the expression tree.
<DIV></DIV>&gt;- *
<DIV></DIV>&gt;- * @exception StandardException Thrown on error
<DIV></DIV>&gt;- */
<DIV></DIV>&gt;- public ValueNode bindExpression(FromList fromList, SubqueryList subqueryList,
<DIV></DIV>&gt;- Vector aggregateVector)
<DIV></DIV>&gt;- throws StandardException
<DIV></DIV>&gt;- {
<DIV></DIV>&gt;- String errorString = null;
<DIV></DIV>&gt;- switch (whichType)
<DIV></DIV>&gt;- {
<DIV></DIV>&gt;- case USER:
<DIV></DIV>&gt;- errorString = "USER";
<DIV></DIV>&gt;- break;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- case CURRENT_USER:
<DIV></DIV>&gt;- errorString = "CURRENT_USER";
<DIV></DIV>&gt;- break;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- case SESSION_USER:
<DIV></DIV>&gt;- errorString = "SESSION_USER";
<DIV></DIV>&gt;- break;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- case SYSTEM_USER:
<DIV></DIV>&gt;- errorString = "SYSTEM_USER";
<DIV></DIV>&gt;- break;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- case SCHEMA:
<DIV></DIV>&gt;- errorString = "CURRENT SCHEMA";
<DIV></DIV>&gt;- break;
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- case IDENTITY_VAL:
<DIV></DIV>&gt;- errorString = "IDENTITY_VAL_LOCAL";
<DIV></DIV>&gt;- break;
<DIV></DIV>&gt;- }
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- if (whichType == SCHEMA)
<DIV></DIV>&gt;- checkReliability( errorString, CompilerContext.SCHEMA_ILLEGAL );
<DIV></DIV>&gt;- else
<DIV></DIV>&gt;- checkReliability( errorString, CompilerContext.USER_ILLEGAL );
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- if (whichType == IDENTITY_VAL)
<DIV></DIV>&gt;- setType(DataTypeDescriptor.getSQLDataTypeDescriptor("java.math.BigDecimal", 31, 0, true, 31));
<DIV></DIV>&gt;- else
<DIV></DIV>&gt;- setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR, false, 128));
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- return this;
<DIV></DIV>&gt;- }
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- /**
<DIV></DIV>&gt;- * Return the variant type for the underlying expression.
<DIV></DIV>&gt;- * The variant type can be:
<DIV></DIV>&gt;- * VARIANT - variant within a scan
<DIV></DIV>&gt;- * &nbsp;&nbsp;(method calls and non-static field access)
<DIV></DIV>&gt;- * SCAN_INVARIANT - invariant within a scan
<DIV></DIV>&gt;- * &nbsp;&nbsp;(column references from outer tables)
<DIV></DIV>&gt;- * QUERY_INVARIANT - invariant within the life of a query
<DIV></DIV>&gt;- * &nbsp;&nbsp;(constant expressions)
<DIV></DIV>&gt;- *
<DIV></DIV>&gt;- * @return The variant type for the underlying expression.
<DIV></DIV>&gt;- */
<DIV></DIV>&gt;- protected int getOrderableVariantType()
<DIV></DIV>&gt;- {
<DIV></DIV>&gt;- // CurrentDate, Time, Timestamp are invariant for the life of the query
<DIV></DIV>&gt;- return Qualifier.QUERY_INVARIANT;
<DIV></DIV>&gt;- }
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- /**
<DIV></DIV>&gt;- * CurrentDatetimeOperatorNode is used in expressions.
<DIV></DIV>&gt;- * The expression generated for it invokes a static method
<DIV></DIV>&gt;- * on a special Cloudscape type to get the system time and
<DIV></DIV>&gt;- * wrap it in the right java.sql type, and then wrap it
<DIV></DIV>&gt;- * into the right shape for an arbitrary value, i.e. a column
<DIV></DIV>&gt;- * holder. This is very similar to what constants do.
<DIV></DIV>&gt;- *
<DIV></DIV>&gt;- * @param acb The ExpressionClassBuilder for the class being built
<DIV></DIV>&gt;- * @param mb The method the code to place the code
<DIV></DIV>&gt;- *
<DIV></DIV>&gt;- *
<DIV></DIV>&gt;- * @exception StandardException Thrown on error
<DIV></DIV>&gt;- */
<DIV></DIV>&gt;- public void generateExpression(ExpressionClassBuilder acb,
<DIV></DIV>&gt;- MethodBuilder mb)
<DIV></DIV>&gt;- throws StandardException
<DIV></DIV>&gt;- {
<DIV></DIV>&gt;- mb.pushThis();
<DIV></DIV>&gt;- mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.Activation, "getLanguageConnectionContext",
<DIV></DIV>&gt;- ClassName.LanguageConnectionContext, 0);
<DIV></DIV>&gt;- if (whichType == IDENTITY_VAL)
<DIV></DIV>&gt;- mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null, "getIdentityValue", "java.lang.Long", 0);
<DIV></DIV>&gt;- else if (whichType == SCHEMA)
<DIV></DIV>&gt;- mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null, "getCurrentSchemaName", "java.lang.String", 0);
<DIV></DIV>&gt;- else
<DIV></DIV>&gt;- mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null, "getAuthorizationId", "java.lang.String", 0);
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- String fieldType = getTypeCompiler().interfaceName();
<DIV></DIV>&gt;- LocalField field = acb.newFieldDeclaration(Modifier.PRIVATE, fieldType);
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- acb.generateDataValue(mb, getTypeCompiler(), field);
<DIV></DIV>&gt;- }
<DIV></DIV>&gt;-
<DIV></DIV>&gt;- /*
<DIV></DIV>&gt;- print the non-node subfields
<DIV></DIV>&gt;- */
<DIV></DIV>&gt;- public String toString() {
<DIV></DIV>&gt;- if (SanityManager.DEBUG)
<DIV></DIV>&gt;- {
<DIV></DIV>&gt;- return super.toString()+"whichType = "+whichType+"\n";
<DIV></DIV>&gt;- }
<DIV></DIV>&gt;- else
<DIV></DIV>&gt;- {
<DIV></DIV>&gt;- return "";
<DIV></DIV>&gt;- }
<DIV></DIV>&gt;- }
<DIV></DIV>&gt;-}
<DIV></DIV></div></html>


Mime
View raw message