1 21 22 package org.apache.derby.impl.sql.compile; 23 24 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 25 26 import org.apache.derby.iapi.error.StandardException; 27 28 import org.apache.derby.iapi.services.sanity.SanityManager; 29 30 36 37 public class SubqueryList extends QueryTreeNodeVector 38 { 39 40 46 47 public void printSubNodes(int depth) 48 { 49 if (SanityManager.DEBUG) 50 { 51 SubqueryNode subqueryNode; 52 53 super.printSubNodes(depth); 54 55 for (int index = 0; index < size(); index++) 56 { 57 subqueryNode = (SubqueryNode) elementAt(index); 58 subqueryNode.treePrint(depth + 1); 59 } 60 } 61 } 62 63 69 70 public void addSubqueryNode(SubqueryNode subqueryNode) throws StandardException 71 { 72 addElement(subqueryNode); 73 } 74 75 86 public void preprocess(int numTables, 87 FromList outerFromList, 88 SubqueryList outerSubqueryList, 89 PredicateList outerPredicateList) 90 throws StandardException 91 { 92 SubqueryNode subqueryNode; 93 94 int size = size(); 95 for (int index = 0; index < size; index++) 96 { 97 subqueryNode = (SubqueryNode) elementAt(index); 98 subqueryNode.preprocess(numTables, outerFromList, 99 outerSubqueryList, 100 outerPredicateList); 101 } 102 } 103 104 113 114 public void optimize(DataDictionary dataDictionary, double outerRows) 115 throws StandardException 116 { 117 int size = size(); 118 for (int index = 0; index < size; index++) 119 { 120 SubqueryNode subqueryNode; 121 subqueryNode = (SubqueryNode) elementAt(index); 122 subqueryNode.optimize(dataDictionary, outerRows); 123 } 124 } 125 126 133 public void modifyAccessPaths() 134 throws StandardException 135 { 136 int size = size(); 137 for (int index = 0; index < size; index++) 138 { 139 SubqueryNode subqueryNode; 140 subqueryNode = (SubqueryNode) elementAt(index); 141 subqueryNode.modifyAccessPaths(); 142 } 143 } 144 145 155 public boolean referencesTarget(String name, boolean baseTable) 156 throws StandardException 157 { 158 int size = size(); 159 for (int index = 0; index < size; index++) 160 { 161 SubqueryNode subqueryNode; 162 163 subqueryNode = (SubqueryNode) elementAt(index); 164 if (subqueryNode.isMaterializable()) 165 { 166 continue; 167 } 168 169 if (subqueryNode.getResultSet().referencesTarget(name, baseTable)) 170 { 171 return true; 172 } 173 } 174 175 return false; 176 } 177 178 185 public boolean referencesSessionSchema() 186 throws StandardException 187 { 188 int size = size(); 189 for (int index = 0; index < size; index++) 190 { 191 SubqueryNode subqueryNode; 192 193 subqueryNode = (SubqueryNode) elementAt(index); 194 195 if (subqueryNode.getResultSet().referencesSessionSchema()) 196 { 197 return true; 198 } 199 } 200 201 return false; 202 } 203 204 211 public void setPointOfAttachment(int pointOfAttachment) 212 throws StandardException 213 { 214 int size = size(); 215 216 for (int index = 0; index < size; index++) 217 { 218 SubqueryNode subqueryNode; 219 220 subqueryNode = (SubqueryNode) elementAt(index); 221 subqueryNode.setPointOfAttachment(pointOfAttachment); 222 } 223 } 224 225 232 void decrementLevel(int decrement) 233 { 234 int size = size(); 235 236 for (int index = 0; index < size; index++) 237 { 238 ((SubqueryNode) elementAt(index)).getResultSet().decrementLevel(decrement); 239 } 240 } 241 } 242 243 | Popular Tags |