1 package com.daffodilwoods.daffodildb.server.sql99.dql.semanticchecker; 2 3 import java.util.*; 4 import com.daffodilwoods.daffodildb.server.datadictionarysystem.*; 5 import com.daffodilwoods.daffodildb.server.serversystem.*; 6 import com.daffodilwoods.daffodildb.server.sql99.common.*; 7 import com.daffodilwoods.daffodildb.server.sql99.dql.listenerevents.*; 8 import com.daffodilwoods.daffodildb.server.sql99.dql.queryexpression. 9 queryspecification.*; 10 import com.daffodilwoods.daffodildb.server.sql99.expression.expressionprimary.*; 11 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 12 import com.daffodilwoods.daffodildb.utils.field.*; 13 import com.daffodilwoods.database.general.*; 14 import com.daffodilwoods.database.resource.*; 15 import com.daffodilwoods.daffodildb.server.sql99.common. 16 GeneralPurposeStaticClass; 17 import com.daffodilwoods.daffodildb.server.sql99.dql.queryexpression. 18 queryspecification.selectlist; 19 import com.daffodilwoods.daffodildb.server.sql99.fulltext.dml. 20 _FullTextIndexInformation; 21 import com.daffodilwoods.daffodildb.server.sql99.common.Datatypes; 22 import java.util.ArrayList ; 23 import com.daffodilwoods.daffodildb.server.sql99.utils._Reference; 24 import com.daffodilwoods.daffodildb.server.sql99.common.ColumnDetails; 25 import com.daffodilwoods.database.utility.P; 26 import com.daffodilwoods.database.resource.DException; 27 import com.daffodilwoods.daffodildb.server.sessionsystem.GlobalSession; 28 29 50 public class SemanticChecker 51 implements TypeConstants, _SemanticChecker { 52 53 56 private TableDetails[] tableDetails; 57 58 61 62 private ColumnDetails[] whereClauseColumnDetails; 63 64 67 68 private ColumnDetails[] groupByClauseColumnDetails; 69 70 73 74 private ColumnDetails[] havingClauseColumnDetails; 75 76 79 80 private ColumnDetails[] orderByClauseColumnDetails; 81 82 85 private ColumnDetails[] selectListColumnDetails; 86 87 94 private ColumnDetails[] userDefinedColumnDetails; 95 96 99 100 private ColumnDetails[] clonedUserDefinedColumnDetails; 101 102 105 106 private ColumnDetails[] fromClauseColumnDetails; 107 108 115 116 private ColumnDetails[] orderByClauseKeyColumnColumnDetails; 118 121 122 private _ServerSession serverSession; 123 124 127 private selectlist selectList; 128 129 132 133 private _Reference[] unKnownReferences; 134 135 138 private ColumnDetails[] queryColumns; 139 140 143 144 private ColumnDetails[] aggregateColumnsPresentInQuery; 145 146 149 150 private boolean isDistinct; 151 152 155 156 public boolean containsClauseFlag; 157 158 161 162 private _PrivilegeTable privileges; 163 164 165 private int count = 0; 166 167 public SemanticChecker(_ServerSession severSession0, 168 ColumnDetails[] whereClauseColumnDetails0, 169 ColumnDetails[] groupByClauseColumnDetails0, 170 ColumnDetails[] havingClauseColumnDetails0, 171 ColumnDetails[] orderByClauseColumnDetails0, 172 ColumnDetails[] selectListColumnDetails0, 173 ColumnDetails[] fromClauseColumnDetails0, 174 selectlist selectList0, 175 ColumnDetails[] orderByClauseKeyColumnColumnDetails0, 176 boolean isDistinct0) { 177 serverSession = severSession0; 178 whereClauseColumnDetails = whereClauseColumnDetails0; 179 groupByClauseColumnDetails = groupByClauseColumnDetails0; 180 havingClauseColumnDetails = havingClauseColumnDetails0; 181 orderByClauseColumnDetails = orderByClauseColumnDetails0; 182 selectListColumnDetails = selectListColumnDetails0; 183 selectList = selectList0; 184 fromClauseColumnDetails = fromClauseColumnDetails0; 185 orderByClauseKeyColumnColumnDetails = orderByClauseKeyColumnColumnDetails0; 186 isDistinct = isDistinct0; 187 initializeContainFlag(whereClauseColumnDetails); 188 } 189 190 public SemanticChecker(TableDetails[] tableDetails0, ColumnDetails[] whereCD) { 191 tableDetails = tableDetails0; 192 whereClauseColumnDetails = whereCD; 193 } 194 195 200 private void initializeContainFlag(ColumnDetails[] whereCD) { 201 if (whereCD != null) 202 for (int i = 0; i < whereCD.length; i++) { 203 if (!containsClauseFlag) 204 containsClauseFlag = whereCD[i].getContainClauseFlag(); 205 } 206 } 207 208 212 213 public void setTableDetails(TableDetails[] tableDetails0) { 214 tableDetails = tableDetails0; 215 } 216 217 240 241 public void check(_ServerSession serverSession0) throws DException { 242 serverSession = serverSession0; 243 checkTableSemantic(serverSession0); 245 246 247 setDatatypeOfConstantColunmsInSelectList(selectListColumnDetails, 248 serverSession0); 249 250 if (havingClauseColumnDetails != null) { 251 setDatatypeOfConstantColunmsInSelectList(havingClauseColumnDetails, 252 serverSession0); 253 } 254 255 unKnownReferences = whereClauseColumnDetails == null 256 ? unKnownReferences : 257 GeneralPurposeStaticClass.getJointReferences(unKnownReferences, 258 checkWhereColumnSemantic()); 259 260 261 262 unKnownReferences = GeneralPurposeStaticClass.getJointReferences( 263 unKnownReferences, checkSelectListColumnSemantic()); 264 265 aggregateColumnsPresentInQuery = getAllAggregateColumns(); 266 267 unKnownReferences = groupByClauseColumnDetails == null 268 ? unKnownReferences : 269 GeneralPurposeStaticClass.getJointReferences(unKnownReferences, 270 checkGroupColumnSemantic()); 271 272 unKnownReferences = havingClauseColumnDetails == null 273 ? unKnownReferences : 274 GeneralPurposeStaticClass.getJointReferences(unKnownReferences, 275 checkHavingColumnSemantic()); 276 277 278 _Reference[] orderByUnKnownReferences = orderByClauseColumnDetails == null ? null : 279 checkOrderColumnSemantic(); 280 281 282 283 if (containsClauseFlag) { 284 checkSemanticCheckingForContains(); 285 } 286 else { 287 if (havingClauseColumnDetails != null) 288 checkHavingSemanticCheckingForContainClause(); 289 } 290 if ( (groupByClauseColumnDetails != null || aggregateColumnsPresentInQuery != null) && 291 havingClauseColumnDetails != null) { 292 unKnownReferences = GeneralPurposeStaticClass.getJointReferences( 293 unKnownReferences, 294 checkGroupByHavingSemantic(havingClauseColumnDetails)); 295 } 296 if (groupByClauseColumnDetails != null || aggregateColumnsPresentInQuery != null) { 297 unKnownReferences = GeneralPurposeStaticClass.getJointReferences( 298 unKnownReferences, 299 checkGroupBySelectOrOrderSemantic(userDefinedColumnDetails)); 300 } 301 if (orderByClauseColumnDetails != null) { 302 unKnownReferences = GeneralPurposeStaticClass.getJointReferences( 303 unKnownReferences, 304 checkOrderByAndSelectColumnSemantic(orderByUnKnownReferences)); 305 } 306 if (unKnownReferences != null) 307 initializingTypeOfUnKnownReferencesAsConstant(unKnownReferences); 308 309 if (unKnownReferences != null) { 310 for (int i = 0; i < unKnownReferences.length; i++) { 311 if (unKnownReferences[i].getReferenceType() == SimpleConstants.SEQUENCE) { 312 throw new DException("DSE6008", null); 313 } 314 } 315 } 316 317 } 318 319 private void setAliasNameOfFunctionalColumn(ColumnDetails[] 320 selectListColumnDetails) throws 321 DException { 322 for (int i = 0; i < selectListColumnDetails.length; i++) { 323 int type = selectListColumnDetails[i].getType(); 324 if ( (selectListColumnDetails[i].getAliasName() == null) && 325 (type == SCALARFUNCTION || type == CASEEXPRESSION || type == GROUPING || 326 type == FUNCTIONAL || type == USERFUNCTION )) { 327 selectListColumnDetails[i].setAliasName("Expr" + i); 328 } 329 } 330 } 331 332 339 340 private void checkSemanticCheckingForContains() throws DException { 341 checkTableSemanticForContainClause(); 342 checkOrderByGroupByHavingSemanticForContainClause(); 343 checkForOneBooleanExpressionWhenContainsClauseIsPresent(); 344 } 345 346 351 352 private void checkTableSemanticForContainClause() throws DException { 353 if (tableDetails.length == 1 && 354 tableDetails[0].getTableType() != TypeConstants.VIEW) 355 return; 356 else 357 throw new DException("DSE0", new Object [] {"Tables Involved in Query not to be greater than one and must be of type TABLE "}); } 359 360 365 366 private void checkOrderByGroupByHavingSemanticForContainClause() throws 367 DException { 368 if (orderByClauseColumnDetails == null && groupByClauseColumnDetails == null && 369 havingClauseColumnDetails == null) 370 return; 371 else 372 throw new DException("DSE0", new Object [] {"GroupBy,OrderBy and HavingClause Clause Should not be Exist with Contains Clause"}); } 374 375 382 383 private void checkHavingSemanticCheckingForContainClause() throws DException { 384 for (int i = 0; i < havingClauseColumnDetails.length; i++) 385 if (havingClauseColumnDetails[i].getContainClauseFlag()) 386 throw new DException("DSE6005", null); } 388 389 397 private void checkTableSemantic(_ServerSession serverSession) throws com. 398 daffodilwoods.database.resource.DException { 399 int length = tableDetails.length; 400 for (int index1 = 0; index1 < length - 1; ++index1) { 401 TableDetails tableDetailSource = tableDetails[index1]; 402 for (int index2 = index1 + 1; index2 < length; ++index2) { 403 TableDetails tableDetailTarget = tableDetails[index2]; 404 if (tableDetailSource.toString().equalsIgnoreCase(tableDetailTarget. 405 toString())) { 406 throw new DException("DSE954", 407 new Object [] {tableDetailSource.getName(), 408 tableDetailTarget.getName()}); 409 } 410 } 411 } 412 } 413 414 428 429 private _Reference[] checkSelectListColumnSemantic() throws DException { 430 _Reference[] unKnownReferences = setTableNamesAndDatatypesOfAllColumns( 431 serverSession, selectListColumnDetails, tableDetails); 432 433 initializingTypeOfUnKnownReferencesAsConstant(unKnownReferences); userDefinedColumnDetails = selectList.getDerivedColumnDetails(); 435 436 437 checkForScalarSubQueryInSelectList(serverSession); 438 439 440 441 clonedUserDefinedColumnDetails = isDistinct ? 442 getClonedColumns(userDefinedColumnDetails) : null; 443 444 unKnownReferences = changeReferenceAccToClonedColumns(unKnownReferences, 445 clonedUserDefinedColumnDetails != null ? clonedUserDefinedColumnDetails : 446 userDefinedColumnDetails); 447 448 if (groupByClauseColumnDetails == null) 449 checkingForAggregateAndNonAggregateSemantic(userDefinedColumnDetails, false, false); 450 451 checkOrderByDistinctSemantic(orderByClauseKeyColumnColumnDetails, 452 userDefinedColumnDetails); 453 454 return unKnownReferences; 455 } 456 457 466 467 private _Reference[] changeReferenceAccToClonedColumns(_Reference[] source, 468 _Reference[] target) throws DException { 469 if (source != null) { 470 ArrayList aList = new ArrayList (Arrays.asList(source)); 471 for (int i = 0; i < source.length; i++) { 472 for (int j = 0; j < target.length; j++) { 473 if (source[i].getQualifiedColumnName().trim().equalsIgnoreCase(target[ 474 j].getQualifiedColumnName().trim())) 475 aList.add(target[j]); 476 } 477 } 478 return (_Reference[]) aList.toArray(new _Reference[aList.size()]); 479 } 480 return source; 481 } 482 483 489 490 public static ColumnDetails[] getClonedColumns(ColumnDetails[] cd) throws 491 DException { 492 int length = cd.length; 493 ColumnDetails[] result = new ColumnDetails[length]; 494 for (int i = 0; i < length; i++) { 495 try { 496 result[i] = (ColumnDetails) cd[i].clone(); 497 } 498 catch (CloneNotSupportedException ex) { 499 throw new DException("DSE0", new Object [] {"Clone Not Supported"}); 500 } 501 } 502 return result; 503 } 504 505 517 private _Reference[] checkWhereColumnSemantic() throws DException { 518 522 resolveWhereClauseColumnAmbiguity(tableDetails,whereClauseColumnDetails); 523 _Reference[] unKnownReferences = setTableNamesAndDatatypesOfAllColumns( 524 serverSession, whereClauseColumnDetails, tableDetails); 525 initializingTypeOfUnKnownReferencesAsConstant(unKnownReferences); 527 if (checkForAggregateColumns(whereClauseColumnDetails)) throw new DException("DSE14", extractStrings(whereClauseColumnDetails)); 529 530 return unKnownReferences; 531 } 532 533 547 548 private void resolveWhereClauseColumnAmbiguity(TableDetails[] tableDetails, 549 ColumnDetails[] whereClauseCDs) throws 550 DException { 551 for (int c = 0; c < whereClauseCDs.length; c++) { 552 if (whereClauseCDs[c].getType() == REFERENCE && 553 whereClauseCDs[c].getColumnName().length == 1 && 554 !whereClauseCDs[c].getColumn().trim().equalsIgnoreCase("?") && 555 ! (serverSession instanceof GlobalSession)) { 556 for (int t = 0; t < tableDetails.length; t++) { 557 String [] columnName = tableDetails[t].getColumnCharacteristics(). 558 getColumnNames(); 559 if(P.indexOfIgnoreCase(columnName,whereClauseCDs[c].getAppropriateColumn()) != -1){; 560 whereClauseCDs[c].setTableDetails(tableDetails[t]); 561 whereClauseCDs[c].setColumnName(new String [] {tableDetails[t]. 562 getActualName(), 563 whereClauseCDs[c]. 564 getAppropriateColumn()}); 565 566 break; 567 } 568 569 } 570 571 } 572 } 573 } 574 575 581 582 private String [] extractStrings(ColumnDetails[] cds) throws DException { 583 String [] s = new String [cds.length]; 584 for (int i = 0; i < cds.length; i++) { 585 s[i] = cds[i].getColumn(); 586 } 587 return s; 588 } 589 590 597 598 private _Reference[] checkGroupColumnSemantic() throws DException { 599 checkingForsubqueryInGroupByClause(groupByClauseColumnDetails); 600 _Reference[] unKnownReferences = setTableNamesAndDatatypesOfAllColumns( 601 serverSession, groupByClauseColumnDetails, tableDetails); 602 603 initializingTypeOfUnKnownReferencesAsConstant(unKnownReferences); checkingForSequence(groupByClauseColumnDetails); 605 if (unKnownReferences != null) { 606 for (int j = 0, length1 = unKnownReferences.length; 607 j < length1; ++j) { 608 for (int i = 0, length = userDefinedColumnDetails.length; i < length; 609 ++i) { 610 String selecListColumnName = userDefinedColumnDetails[i]. 611 getAliasName(); 612 if (selecListColumnName != null) 613 if (selecListColumnName.equalsIgnoreCase( ( (ColumnDetails) 614 unKnownReferences[j]).getAppropriateColumn())) 615 throw new DException("DSE260", 616 extractStrings(groupByClauseColumnDetails)); 617 618 } 619 621 unKnownReferences[j].setReason("DSE256"); 622 623 } 624 } 625 626 return unKnownReferences; 627 } 628 629 642 private _Reference[] checkHavingColumnSemantic() throws DException { 643 _Reference[] unKnownReferences = setTableNamesAndDatatypesOfAllColumns( 644 serverSession, havingClauseColumnDetails, tableDetails); 645 initializingTypeOfUnKnownReferencesAsConstant(unKnownReferences); if (groupByClauseColumnDetails == null && aggregateColumnsPresentInQuery == null) 647 throw new DException("DSE3566", null); return unKnownReferences; 649 } 650 651 666 private _Reference[] checkOrderColumnSemantic() throws DException { 667 668 669 resolveColumnAmbiguityInOrder(userDefinedColumnDetails,orderByClauseColumnDetails); 670 671 _Reference[] unKnownReferences = setTableNamesAndDatatypesOfAllColumns( 672 serverSession, orderByClauseColumnDetails, tableDetails); 673 checkingForOrder(orderByClauseKeyColumnColumnDetails); 674 675 checkingForSequence(orderByClauseKeyColumnColumnDetails); 676 677 return unKnownReferences; 678 } 679 680 697 private void resolveColumnAmbiguityInOrder(ColumnDetails[] userDefinedCDs, 698 ColumnDetails[] orderByCDs) throws 699 DException { 700 for (int i = 0; i < orderByCDs.length; i++) { 701 if (orderByCDs[i].getAppropriateTableName() == null && orderByCDs[i].getType() == REFERENCE) { 702 for (int j = 0; j < userDefinedCDs.length; j++) { 703 if (userDefinedCDs[j].getColumn().equalsIgnoreCase(orderByCDs[i]. 704 getColumn()) ) { 705 orderByCDs[i].setTableDetails(userDefinedCDs[j].getTable()); 706 orderByCDs[i].setColumnName(new String [] {userDefinedCDs[j]. 707 getTable().getActualName(), 708 userDefinedCDs[j].getAppropriateColumn()}); 709 break; 710 } 711 } 712 } 713 } 714 } 715 716 726 727 public static void checkingForOrder(ColumnDetails[] orderKeyColumns) throws 728 DException { 729 checkForQuestion(orderKeyColumns); 730 731 } 732 733 749 private _Reference[] checkGroupByHavingSemantic(ColumnDetails[] 750 havingClauseColumnDetails) throws 751 DException { 752 ArrayList refs = new ArrayList (); 753 for (int i = 0; i < havingClauseColumnDetails.length; i++) { 754 int type = havingClauseColumnDetails[i].getType(); 755 if (type != GROUPING && type != CONSTANT) { 756 if (type == SCALARFUNCTION || type == CASEEXPRESSION || 757 type == FUNCTIONAL) { 758 _Reference[] re=checkGroupByHavingSemantic(havingClauseColumnDetails[i].getExistingColumnDetails()); 759 if(re!=null) 760 refs.addAll(Arrays.asList(re)); 761 continue; 762 } 763 String havingColumn = havingClauseColumnDetails[i].getStringOfColumn(); 764 if (groupByClauseColumnDetails == null) 765 throw new DException("DSE918", new Object [] {havingColumn}); 766 int j = 0, length = groupByClauseColumnDetails.length; 767 for (; j < length; j++) { 768 if (groupByClauseColumnDetails[j].getStringOfColumn(). 769 equalsIgnoreCase(havingColumn)) { 770 break; 771 } 772 } 773 if (j == length) { refs.add(havingClauseColumnDetails[i]); 775 havingClauseColumnDetails[i].setReason("DSE918"); 776 777 } 778 } 779 } 780 return refs.isEmpty() ? null : (_Reference[]) refs.toArray(new _Reference[0]); 781 } 782 783 796 private _Reference[] checkGroupBySelectOrOrderSemantic(ColumnDetails[] 797 orderOrSelectListColumns) throws DException { 798 ArrayList refs = new ArrayList (); 799 for (int i = 0, length = orderOrSelectListColumns.length; i < length; ++i) { 800 boolean state = false; 801 int type = orderOrSelectListColumns[i].getType(); 802 if (type != GROUPING && type != CONSTANT) { 803 String selecListColumnName = orderOrSelectListColumns[i]. 804 getStringOfColumn(); 805 if (type == HAS_RECORD) 806 throw new DException("DSE3540", null); 807 if (type == SCALARFUNCTION || type == FUNCTIONAL || 808 type == CASEEXPRESSION || type == USERFUNCTION){ 809 boolean directMatch = false; 810 if(groupByClauseColumnDetails !=null){ 811 for (int j = 0, length1 = groupByClauseColumnDetails.length; 812 j < length1; ++j) { 813 if (selecListColumnName.equalsIgnoreCase( 814 groupByClauseColumnDetails[ 815 j].getStringOfColumn()) && (type != USERFUNCTION)) { 816 directMatch = true; 817 break; 818 } 819 } 820 } 821 if (directMatch == false) { 822 state = checkingForAggregateColumn(orderOrSelectListColumns[i]. 823 getExistingColumnDetails()); 824 } 825 else 826 state = true; } 828 else { 829 if (groupByClauseColumnDetails == null) 830 throw new DException("DSE918", new Object [] {selecListColumnName}); for (int j = 0, length1 = groupByClauseColumnDetails.length; 832 j < length1; ++j) { 833 if (selecListColumnName.equalsIgnoreCase(groupByClauseColumnDetails[ 834 j].getStringOfColumn())) { 835 state = true; 836 break; 837 } 838 } 839 } 840 841 if( type == SCALARSUBQUERY){ 842 state = true; 843 } 844 845 if (!state) { 846 refs.add(orderOrSelectListColumns[i]); 847 orderOrSelectListColumns[i].setReason("DSE918"); 848 } 849 } 850 } 851 return refs.isEmpty() ? null : (_Reference[]) refs.toArray(new _Reference[0]); 852 } 853 854 865 private _Reference[] checkOrderByAndSelectColumnSemantic(_Reference[] 866 unKnownReferences) throws DException { 867 if (unKnownReferences != null) 868 unKnownReferences = checkOrderByAliasNameSemantic(unKnownReferences, 869 userDefinedColumnDetails); 870 checkOrderByAmbiguousColumnSemantic(orderByClauseColumnDetails, 871 userDefinedColumnDetails); 872 checkOrderByOrdinalNoSemantic(userDefinedColumnDetails, 873 orderByClauseColumnDetails); 874 875 876 877 if (groupByClauseColumnDetails != null || aggregateColumnsPresentInQuery != null) 878 unKnownReferences = GeneralPurposeStaticClass.getJointReferences( 879 unKnownReferences, 880 checkGroupBySelectOrOrderSemantic(orderByClauseColumnDetails)); 881 return unKnownReferences; 882 883 } 884 885 897 private void initializingTypeOfUnKnownReferencesAsConstant(_Reference[] 898 unKnownReferences) throws DException { 899 if(unKnownReferences!=null) 900 for (int i = 0, length = unKnownReferences.length; i < length; ++i) { 901 if ( ( (ColumnDetails) unKnownReferences[i]).getType() == REFERENCE) { 902 ( (ColumnDetails) unKnownReferences[i]).setUnderLyingReference(true); 903 ( (ColumnDetails) unKnownReferences[i]).setType(CONSTANT); 904 } 905 } 906 } 907 908 915 private static void checkDuplicateOrderColumnSemantic(ColumnDetails[] 916 orderByClauseKeyColumnColumnDetails) throws DException { 917 for (int i = 0, length = orderByClauseKeyColumnColumnDetails.length; 918 i < length - 1; i++) { 919 String columnName = orderByClauseKeyColumnColumnDetails[i]. 920 getQualifiedColumnName(); 921 for (int j = i + 1; j < length; j++) { 922 if (orderByClauseKeyColumnColumnDetails[j].getQualifiedColumnName(). 923 equalsIgnoreCase(columnName)) 924 throw new DException("DSE3541", null); 925 } 926 } 927 } 928 929 936 private static void checkDuplicateOrdinalPositionSemantic(ColumnDetails[] 937 orderByClauseKeyColumnColumnDetails) throws DException { 938 for (int i = 0, length = orderByClauseKeyColumnColumnDetails.length; 939 i < length - 1; i++) { 940 if (orderByClauseKeyColumnColumnDetails[i].getType() == CONSTANT) { 941 Integer obj = getOrdinalNoValue(orderByClauseKeyColumnColumnDetails[i]); 942 if (obj == null) 943 continue; 944 int value = obj.intValue(); 945 for (int j = i + 1; j < length; j++) { 946 if (orderByClauseKeyColumnColumnDetails[i].getType() == CONSTANT) { 947 obj = getOrdinalNoValue(orderByClauseKeyColumnColumnDetails[j]); 948 if (obj == null) 949 continue; 950 int value1 = obj.intValue(); 951 if (value == value1) 952 throw new DException("DSE3541", null); 953 } 954 } 955 } 956 } 957 } 958 959 967 968 969 private static Integer getOrdinalNoValue(ColumnDetails orderByColumn) throws 970 DException { 971 Integer value = null; 972 try { 973 974 value = new Integer ( ( (FieldBase) orderByColumn.getObject()).getObject(). 975 hashCode()); 976 } 977 catch (ClassCastException ce) { 978 } return value; 980 } 981 982 983 994 private static _Reference[] checkOrderByAliasNameSemantic(_Reference[] 995 unKnownReferences, ColumnDetails[] userDefinedColumnDetails) throws 996 DException { 997 ArrayList unKnownReferencesList = new ArrayList (Arrays.asList( 998 unKnownReferences)); 999 for (int i = 0; i < unKnownReferencesList.size(); ++i) { 1000 ColumnDetails orderColumn = (ColumnDetails) unKnownReferencesList.get(i); 1001 String columnName = orderColumn.getColumn(); 1002 if (orderColumn.getType() == CONSTANT) 1003 continue; 1004 TableDetails table = orderColumn.getTable(); 1005 boolean matched = false; 1006 for (int j = 0, length1 = userDefinedColumnDetails.length; j < length1; 1007 ++j) { 1008 String columnNameSelectList = userDefinedColumnDetails[j].getAliasName(); 1009 if (columnNameSelectList != null && 1010 columnName.equalsIgnoreCase(columnNameSelectList)) { if (matched) throw new DException("DSE3542", null); 1013 unKnownReferencesList.remove(i); 1014 matched = true; 1015 --i; 1016 initializePropertiesOfOrderByColumn(orderColumn, 1017 userDefinedColumnDetails[j]); 1018 } 1019 } 1020 } 1021 return unKnownReferencesList.isEmpty() ? null : 1022 (_Reference[]) 1023 unKnownReferencesList.toArray(new _Reference[unKnownReferencesList.size()]); 1024 } 1025 1026 1040 private static void checkOrderByAmbiguousColumnSemantic(ColumnDetails[] 1041 orderByClauseColumnDetails, ColumnDetails[] userDefinedColumnDetails) throws 1042 DException { 1043 for (int i = 0; i < orderByClauseColumnDetails.length; ++i) { 1044 ColumnDetails orderColumn = (ColumnDetails) orderByClauseColumnDetails[i]; 1045 String columnName = orderColumn.getStringOfColumn(); 1046 if (orderColumn.getType() == CONSTANT) 1047 continue; 1048 boolean matched = false; 1049 for (int j = 0, length1 = userDefinedColumnDetails.length; j < length1; 1050 ++j) { 1051 String columnNameSelectList = userDefinedColumnDetails[j]. 1052 getAppropriateQualifiedName(); 1053 if (columnName.equalsIgnoreCase(columnNameSelectList)) { if (matched) 1055 throw new DException("DSE3542", null); 1056 matched = true; 1057 } 1058 } 1059 } 1060 } 1061 1062 1068 private static void initializePropertiesOfOrderByColumn(ColumnDetails gainer, 1069 ColumnDetails looser) throws DException { 1070 1071 1072 gainer.setColumnName(looser.getType() == REFERENCE ? looser.getColumnName() : 1073 new String [] {looser.getColumn()}); 1074 gainer.setTableDetails(looser.getTable()); 1075 gainer.setType(looser.getType()); 1076 gainer.setObject(looser.getObject()); 1077 gainer.setDatatype(looser.getDatatype()); 1078 gainer.setSize(looser.getSize()); 1079 gainer.setQuantifier(looser.getQuantifier()); 1080 gainer.setFunctionType(looser.getFunctionType()); 1081 gainer.setTableAliasArray(looser.getTableAliasArray()); 1082 } 1083 1084 1094 private boolean[] checkingForAggregateAndNonAggregateSemantic(ColumnDetails[] 1095 selectListColumnDetails, boolean stateForReference, boolean stateForGroup) throws 1096 DException { 1097 if (selectListColumnDetails == null) 1098 return new boolean[] { 1099 stateForReference, stateForGroup}; 1100 int length = length = selectListColumnDetails.length; 1101 for (int i = 0; i < length; ++i) { 1102 int type = selectListColumnDetails[i].getType(); 1103 if (type == HAS_RECORD) { 1104 checkingForHas_Record(selectListColumnDetails[i]); 1105 continue; 1106 } 1107 if (type != GROUPING && type != CONSTANT) { 1108 boolean[] booleanArray = null; 1109 if (type == SCALARFUNCTION || type == FUNCTIONAL || 1110 type == CASEEXPRESSION) { 1111 booleanArray = checkingForAggregateAndNonAggregateSemantic( 1112 selectListColumnDetails[i].getExistingColumnDetails(), 1113 stateForReference, stateForGroup); 1114 stateForReference = booleanArray[0]; 1115 stateForGroup = booleanArray[1]; 1116 } 1117 else if (type == REFERENCE) { 1118 if (stateForGroup) 1119 throw new DException("DSE918", 1120 new Object [] {selectListColumnDetails[i]. 1121 getColumn()}); stateForReference = true; 1123 } 1124 continue; 1125 } 1126 if (type != CONSTANT) { if (stateForReference) 1128 throw new DException("DSE918", 1129 new Object [] {selectListColumnDetails[i]. 1130 getColumn()}); stateForGroup = true; 1132 } 1133 } 1134 return new boolean[] { 1135 stateForReference, stateForGroup}; 1136 } 1137 1138 1146 public static void checkSemanticCheckingForOrderInSetOperatorsold( 1147 ColumnDetails[] selectedColumns, ColumnDetails[] orderByColumns) throws 1148 DException { 1149 1150 for (int i = 0; i < orderByColumns.length; i++) { 1151 boolean matched = false; 1152 if (orderByColumns[i].getType() != CONSTANT) { 1153 String [] columnName = orderByColumns[i].getColumnName(); 1154 for (int j = 0; j < selectedColumns.length; j++) { 1155 if (check(columnName, selectedColumns[j].getAppColumnName())) { 1156 if (matched) 1157 throw new DException("DSE3542", null); 1158 initializePropertiesOfOrderByColumn(orderByColumns[i], 1159 selectedColumns[j]); 1160 i++; 1161 matched = true; 1162 } 1163 } 1164 for (int k = 0; k < selectedColumns.length; k++) { 1165 matched = false; 1166 if(orderByColumns[i].getAppropriateColumn().equalsIgnoreCase(selectedColumns[k]. 1167 getOriginalColumn())) { 1168 if (matched) 1169 throw new DException("DSE3542", null); 1170 initializePropertiesOfOrderByColumn(orderByColumns[i], 1171 selectedColumns[k]); 1172 matched = true; 1173 } 1174 } 1175 if (!matched) 1176 throw new DException("DSE3544", 1177 new Object [] {orderByColumns[i].getColumn()}); i++; 1179 } } 1182 checkOrderByOrdinalNoSemantic(selectedColumns, orderByColumns); 1183 1184 } 1185 1186 public static void checkSemanticCheckingForOrderInSetOperators(ColumnDetails[] 1187 selectedColumns, ColumnDetails[] orderByColumns) throws DException { 1188 ArrayList orderColumns = new ArrayList (); 1189 boolean matched = false; 1190 for (int i = 0; i < orderByColumns.length; i++) { 1191 matched = false; 1192 if (orderByColumns[i].getType() != CONSTANT) { 1193 String [] ordercolumn = orderByColumns[i].getColumnName(); 1194 for (int j = 0; j < selectedColumns.length; j++) { 1195 if (check(ordercolumn, selectedColumns[j].getAppColumnName())) { 1196 if (matched) 1197 throw new DException("DSE3542", null); 1198 initializePropertiesOfOrderByColumn(orderByColumns[i], 1199 selectedColumns[j]); 1200 matched = true; 1201 } 1202 } 1203 if (!matched) 1204 orderColumns.add(orderByColumns[i]); 1205 } 1206 } 1207 int k = 0; 1208 ColumnDetails[] orderByColumns1 = (ColumnDetails[]) orderColumns.toArray(new 1209 ColumnDetails[orderColumns.size()]); 1210 for (k = 0; k < orderByColumns1.length; k++) { 1211 matched = false; 1212 if (orderByColumns1[k].getType() != CONSTANT) { 1213 for (int l = 0; l < selectedColumns.length; l++) { 1214 if (orderByColumns1[k].getAppropriateColumn().equalsIgnoreCase(selectedColumns[l]. 1215 getOriginalColumn())) { 1216 if (matched) 1217 throw new DException("DSE3542", null); 1218 initializePropertiesOfOrderByColumn(orderByColumns[k], 1219 selectedColumns[l]); 1220 matched = true; 1221 } 1222 } 1223 if (!matched) throw new DException("DSE3544", 1225 new Object [] {orderByColumns1[k].getColumn()}); 1227 } 1228 } 1229 checkOrderByOrdinalNoSemantic(selectedColumns, orderByColumns); 1230 1231 } 1232 1233 1242 1243 private static boolean check(String [] array1, String [] array2) throws 1244 DException { 1245 int i = array1.length - 1, j = array2.length - 1; 1246 for (; i >= 0 && j >= 0; i--, j--) { 1247 if (!array1[i].equalsIgnoreCase(array2[j])) 1248 return false; 1249 } 1250 return i < 0; 1251 } 1252 1253 private static boolean checknew(ColumnDetails orderCD, ColumnDetails selectCD) throws 1254 DException { 1255 if (orderCD.getTable().equals(selectCD.getTable())) { 1256 if (orderCD.getAppropriateColumn().equalsIgnoreCase(selectCD. 1257 getAppropriateColumn())) 1258 return true; 1259 else if (orderCD.getOriginalColumn().equalsIgnoreCase(selectCD. 1260 getOriginalColumn())) 1261 return true; 1262 else 1263 return false; 1264 } 1265 return false; 1266 1267 } 1268 1269 1276 public _Reference[] checkForUnderLyingReferences(ColumnDetails[] 1277 underLyingReferences) throws DException { 1278 ArrayList list = new ArrayList (); 1279 if (underLyingReferences == null) 1280 return null; 1281 try { 1282 SetColumnProperties.setTableNamesAndDatatypesOfAllColumns(serverSession, 1283 underLyingReferences, tableDetails, list, new ArrayList ()); 1284 } 1285 catch (NullPointerException ex) { 1286 throw ex; 1287 } 1288 if (list.size() == 0) 1289 return null; 1290 return (_Reference[]) list.toArray(new _Reference[list.size()]); 1291 } 1292 1293 1299 public HashMap getMappingOfTableDetailsAndColumnsBelonging() throws 1300 DException { 1301 HashMap listOfTableAndColumns = new HashMap(); 1302 if (queryColumns == null) 1303 getAllColumnDetails(); 1304 for (int i = 0, length = tableDetails.length; i < length; ++i) { 1305 ArrayList list = new ArrayList (); 1306 for (int j = 0, length1 = queryColumns.length; j < length1; ++j) { 1307 if (queryColumns[j].getType() == REFERENCE && queryColumns[j].getTable() != null) 1308 if (queryColumns[j].getTable().equals(tableDetails[i])) 1309 list.add(queryColumns[j]); 1310 } 1311 ColumnDetails[] matchedColumns = list.isEmpty() ? null : 1312 (ColumnDetails[]) list.toArray(new ColumnDetails[list.size()]); 1313 listOfTableAndColumns.put(tableDetails[i], matchedColumns); 1314 } 1315 return listOfTableAndColumns; 1316 } 1317 1318 1326 public ColumnDetails[] getDerivedColumnDetails() throws DException { 1327 return userDefinedColumnDetails; 1328 } 1329 1330 1335 1336 private void getAllColumnDetails() throws DException { 1337 ArrayList set = new ArrayList (); 1338 addColumns(set, userDefinedColumnDetails); 1339 if (clonedUserDefinedColumnDetails != null) 1340 addColumns(set, clonedUserDefinedColumnDetails); 1341 queryColumns = getAddedColumns(set); 1342 } 1343 1344 1350 1351 public ColumnDetails[] getAllColumnsInvolvedInQuery() throws DException { 1352 ArrayList set = new ArrayList (); 1353 addColumns(set, selectListColumnDetails); 1354 return getAddedColumns(set); 1355 } 1356 1357 1364 1365 private ColumnDetails[] getAddedColumns(ArrayList set) throws DException { 1366 addColumns(set, fromClauseColumnDetails); 1367 if (whereClauseColumnDetails != null) { 1368 addColumns(set, whereClauseColumnDetails); 1369 } 1370 if (groupByClauseColumnDetails != null) 1371 addColumns(set, groupByClauseColumnDetails); 1372 if (havingClauseColumnDetails != null) 1373 addColumns(set, havingClauseColumnDetails); 1374 if (orderByClauseColumnDetails != null) 1375 addColumns(set, orderByClauseColumnDetails); 1376 return (ColumnDetails[]) set.toArray(new ColumnDetails[set.size()]); 1377 } 1378 1379 1388 private boolean checkingForAggregateColumn(ColumnDetails[] columnDetails) throws 1389 DException { 1390 if (columnDetails == null) 1391 return true; 1392 for (int i = 0, length = columnDetails.length; i < length; ++i) { 1393 boolean state = false; 1394 int type = columnDetails[i].getType(); 1395 if (type == SCALARFUNCTION || type == CASEEXPRESSION ) 1396 state = checkingForAggregateColumn(columnDetails[i]. 1397 getExistingColumnDetails()); 1398 else if (type == REFERENCE) { 1399 for (int j = 0, length1 = groupByClauseColumnDetails.length; 1400 j < length1; ++j) { 1401 if (columnDetails[i].getStringOfColumn().equalsIgnoreCase( 1402 groupByClauseColumnDetails[j].getStringOfColumn())) { 1403 state = true; break; 1405 } 1406 } 1407 if (!state) throw new DException("DSE918", 1409 new Object [] {columnDetails[i].getColumn()}); } 1411 } 1412 return true; 1413 } 1414 1415 1423 public static void initializeCatalogNameAndSchemaNameOfTable(TableDetails 1424 tableDetails, _ServerSession serverSession) throws DException { 1425 String [] userTableSpecified = tableDetails.getTableName(); 1426 int length = userTableSpecified.length; 1427 String [] qualifiedTableName = new String [3]; 1428 if (length == 1) { 1429 qualifiedTableName[0] = serverSession.getCurrentCatalog(); 1430 qualifiedTableName[1] = serverSession.getCurrentSchema(); 1431 qualifiedTableName[2] = userTableSpecified[0]; 1432 } 1433 else if (length == 2) { 1434 qualifiedTableName[0] = serverSession.getCurrentCatalog(); 1435 qualifiedTableName[1] = userTableSpecified[0]; 1436 qualifiedTableName[2] = userTableSpecified[1]; 1437 } 1438 else 1439 qualifiedTableName = userTableSpecified; 1440 tableDetails.setTableName(qualifiedTableName); 1441 } 1442 1443 1453 public ColumnDetails[] getAllAggregateColumns() throws DException { 1454 if (aggregateColumnsPresentInQuery != null) 1455 return aggregateColumnsPresentInQuery; 1456 ArrayList groupByColumns = new ArrayList (8); 1457 getAggregateColumns(userDefinedColumnDetails, groupByColumns); 1458 getAggregateColumns(fromClauseColumnDetails, groupByColumns); 1459 getAggregateColumns(orderByClauseColumnDetails, groupByColumns); 1460 getAggregateColumns(havingClauseColumnDetails, groupByColumns); 1461 if (groupByColumns.isEmpty()) 1462 return null; 1463 aggregateColumnsPresentInQuery = (ColumnDetails[]) groupByColumns.toArray(new 1464 ColumnDetails[groupByColumns.size()]); 1465 return aggregateColumnsPresentInQuery; 1466 } 1467 1468 1477 1478 private void getAggregateColumns(ColumnDetails[] column, ArrayList list) throws 1479 DException { 1480 if (column == null) 1481 return; 1482 for (int i = 0, length = column.length; i < length; i++) { 1483 switch (column[i].getType()) { 1484 case GROUPING: 1485 TableDetails table = column[i].getTableForDisplay(); 1486 if (table == null) 1487 list.add(column[i]); 1488 break; 1489 case SCALARFUNCTION: 1490 case FUNCTIONAL: 1491 case CASEEXPRESSION: 1492 case USERFUNCTION : 1493 getAggregateColumns(column[i].getExistingColumnDetails(), list); 1494 } 1495 } 1496 } 1497 1498 1513 1514 public static void checkCardinalityAndDataTypeComptability(ColumnDetails[] 1515 columnDetailsLeft, ColumnDetails[] columnDetailsRight) throws DException { 1516 if (columnDetailsLeft.length != columnDetailsRight.length) 1517 throw new DException("DSE214", null); 1518 for (int i = 0; i < columnDetailsLeft.length; ++i) { 1519 1520 if (columnDetailsLeft[i].getColumnName()[0].equalsIgnoreCase("null")) { 1521 columnDetailsLeft[i].setDatatype(columnDetailsRight[i].getDatatype()); 1522 columnDetailsLeft[i].setSize(columnDetailsRight[i].getSize()); 1523 } 1524 else { 1525 if (columnDetailsRight[i].getColumnName()[0].equalsIgnoreCase("null")) { 1526 columnDetailsRight[i].setDatatype(columnDetailsLeft[i].getDatatype()); 1527 columnDetailsRight[i].setSize(columnDetailsLeft[i].getSize()); 1528 } 1529 } 1530 try { 1531 Check.checkForDatatype(columnDetailsLeft[i].getDatatype(), 1532 columnDetailsRight[i].getDatatype()); 1533 } 1534 catch (DException ex) { 1535 throw ex; 1536 } 1537 } 1538 } 1539 1540 1542 1554 1555 private void addColumns(ArrayList set, ColumnDetails[] columnDetails1) throws 1556 DException { 1557 if (columnDetails1.length > 0 && columnDetails1[0].getContainClauseFlag()) { 1558 return; 1559 } 1560 for (int i = 0, length = columnDetails1.length; i < length; i++) { 1561 int type = columnDetails1[i].getType(); 1562 if (type == FUNCTIONAL || type == GROUPING || type == SCALARFUNCTION || 1563 type == CASEEXPRESSION || type == USERFUNCTION ) { 1564 addColumns(set, columnDetails1[i].getExistingColumnDetails()); 1565 } 1566 else if (columnDetails1[i].getType() != CONSTANT || 1567 columnDetails1[i].getColumn().equalsIgnoreCase("*")) { 1568 set.add(columnDetails1[i]); 1569 } 1570 } 1571 } 1572 1573 1580 public static ColumnDetails[] addColumnDetails(ColumnDetails[] columnDetails1, 1581 ColumnDetails[] columnDetails2) throws 1582 DException { 1583 int len1 = columnDetails1.length; 1584 int len2 = columnDetails2.length; 1585 int len = len1 + len2; 1586 ColumnDetails[] result = new ColumnDetails[len]; 1587 System.arraycopy(columnDetails1, 0, result, 0, len1); 1588 System.arraycopy(columnDetails2, 0, result, len1, len2); 1589 return result; 1590 } 1591 1592 1606 public static void checkOrderByOrdinalNoSemantic(ColumnDetails[] 1607 userDefinedColumnDetails, ColumnDetails[] orderByClauseColumnDetails) throws 1608 DException { 1609 int max = 0; 1610 int lengthOfSelect = userDefinedColumnDetails.length; 1611 for (int i = 0, length = orderByClauseColumnDetails.length; i < length; ++i) { 1612 int type = orderByClauseColumnDetails[i].getType(); 1613 if (type == CONSTANT) { 1614 Integer obj = getOrdinalNoValue(orderByClauseColumnDetails[i]); 1615 if (obj == null) 1616 continue; 1617 int value = obj.intValue(); 1618 if (value <= 0) { 1619 1620 throw new DException("DSE3545", 1621 new Object [] {"-" + 1622 orderByClauseColumnDetails[i].getColumn()}); } 1624 if (value > lengthOfSelect ) { 1625 throw new DException("DSE3545", 1626 new Object [] {orderByClauseColumnDetails[i]. 1627 getColumn()}); } 1629 else { 1630 1632 Check.checkForAllowedDatatype(userDefinedColumnDetails[ (int) value - 1633 1].getDatatype()); 1634 1635 checkForQuestion(new ColumnDetails[]{userDefinedColumnDetails[value -1] }); initializePropertiesOfOrderByColumn(orderByClauseColumnDetails[i],userDefinedColumnDetails[ (int) 1637 value - 1]); 1638 } 1639 } 1640 } 1641 } 1642 1643 1649 public _Reference[] getUnderLyingReferences() throws DException { 1650 return unKnownReferences; 1651 } 1652 1653 1660 public void getGroupByPrimaryColumns(ArrayList listOfColumns) throws 1661 DException { 1662 try { 1663 if (groupByClauseColumnDetails == null) 1664 return; 1665 int length = groupByClauseColumnDetails.length; 1666 TableDetails td = null; 1667 for (int i = 0; i < length; i++) { 1668 if (td == null) 1669 td = groupByClauseColumnDetails[i].getTable(); 1670 else if (td != groupByClauseColumnDetails[i].getTable()) 1671 return; 1672 } 1673 String [] keyColumns = serverSession.getUniqueInformation(td. 1674 getQualifiedIdentifier()); 1675 if (keyColumns == null) 1676 return; 1677 ArrayList aList = new ArrayList (length); 1678 int j = 0, len = keyColumns.length; 1679 for (; j < len; j++) { 1680 for (int i = 0; i < length; i++) { 1681 String name = groupByClauseColumnDetails[i].getOriginalColumn(); 1682 if (name.equalsIgnoreCase(keyColumns[j])) { 1683 aList.add(groupByClauseColumnDetails[i].getQualifiedColumnName()); 1684 break; 1685 } 1686 } 1687 } 1688 if (j == len) 1689 listOfColumns.addAll(aList); 1690 } 1691 finally { 1692 } 1693 1694 } 1695 1696 1703 1704 public static void checkForDuplicateColumnsInvolved(ColumnDetails[] columns) throws 1705 DException { 1706 int length = columns.length; 1707 for (int i = 0; i < length - 1; ++i) { 1708 String columnName = columns[i].getAppropriateColumn(); 1709 for (int j = i + 1; j < length; ++j) { 1710 if (columnName.equalsIgnoreCase(columns[j].getAppropriateColumn())) 1711 throw new DException("DSE3535", null); 1712 } 1713 } 1714 } 1715 1716 1723 1724 public static boolean checkForAggregateColumns(ColumnDetails[] columns) throws 1725 DException { 1726 for (int i = 0, length = columns.length; i < length; i++) { 1727 switch (columns[i].getType()) { 1728 case GROUPING: 1729 return true; 1730 case SCALARFUNCTION: 1731 case FUNCTIONAL: 1732 case CASEEXPRESSION: 1733 case USERFUNCTION : 1734 if (checkForAggregateColumns(columns[i].getExistingColumnDetails())) 1735 return true; 1736 break; 1737 } 1738 } 1739 return false; 1740 } 1741 1742 1748 1749 public void checkingForHas_Record(ColumnDetails columnDetail) throws 1750 DException { 1751 TableDetails tableDetail = columnDetail.getTable(); 1752 String [] tableName = tableDetail.getTableName(); 1753 if (tableName.length == 1) { 1754 for (int i = 0; i < tableDetails.length; i++) { 1755 if ( (tableName[0].equalsIgnoreCase(tableDetails[i].getAliasName()) || 1756 tableName[0].equalsIgnoreCase(tableDetails[i].getActualName())) 1757 && tableDetails[i].getHasRecord()) { 1758 columnDetail.setTableDetails(tableDetails[i]); 1759 return; 1760 } 1761 } 1762 } 1763 else if (tableName.length == 2) { 1764 for (int i = 0; i < tableDetails.length; i++) { 1765 if ( (tableName[0].equalsIgnoreCase(tableDetails[i].getSchemaName()) || 1766 tableName[1].equalsIgnoreCase(tableDetails[i].getAliasName()) || 1767 tableName[1].equalsIgnoreCase(tableDetails[i].getActualName())) 1768 && tableDetails[i].getHasRecord()) { 1769 columnDetail.setTableDetails(tableDetails[i]); 1770 return; 1771 } 1772 } 1773 } 1774 else if (tableName.length == 3) { 1775 for (int i = 0; i < tableDetails.length; i++) { 1776 if ( (tableName[0].equalsIgnoreCase(tableDetails[i].getCatalogName()) || 1777 tableName[1].equalsIgnoreCase(tableDetails[i].getSchemaName()) || 1778 tableName[2].equalsIgnoreCase(tableDetails[i].getAliasName()) || 1779 tableName[2].equalsIgnoreCase(tableDetails[i].getActualName())) 1780 && tableDetails[i].getHasRecord()) { 1781 columnDetail.setTableDetails(tableDetails[i]); 1782 return; 1783 } 1784 } 1785 } 1786 throw new DException("DSE3546", 1787 new Object [] {java.util.Arrays.asList(tableName)}); 1788 } 1789 1790 1795 1796 public TableDetails[] getTableDetails() throws DException { 1797 return tableDetails; 1798 } 1799 1800 1828 1829 private _Reference[] setTableNamesAndDatatypesOfAllColumns(_ServerSession 1830 serverSession, ColumnDetails[] columnDetails, TableDetails[] tableDetails) throws 1831 com.daffodilwoods.database.resource.DException { 1832 ArrayList unKnownReferences = new ArrayList (5); 1833 1834 for (int indexOfColumnDetails = 0; 1835 indexOfColumnDetails < columnDetails.length; ++indexOfColumnDetails) { 1836 int type = columnDetails[indexOfColumnDetails].getType(); 1837 1838 if (type == CONSTANT && 1839 !columnDetails[indexOfColumnDetails].getUnderLyingReference()) { 1840 1841 if ( ( (String []) columnDetails[indexOfColumnDetails].getColumnName()). 1842 length == 1) { 1843 if ( ( (String ) columnDetails[indexOfColumnDetails].getColumn()). 1844 equals("*")) { 1845 setCount(serverSession, tableDetails, 1846 columnDetails[indexOfColumnDetails]); 1847 } 1848 } 1849 1850 else { 1851 for (int indexOfTableDetails = 0; 1852 indexOfTableDetails < tableDetails.length; 1853 ++indexOfTableDetails) { 1854 1855 String [] tableName = tableDetails[indexOfTableDetails]. 1856 getAppropriateTableName(); 1857 String columnName[] = columnDetails[indexOfColumnDetails]. 1858 getColumnName(); 1859 TableDetails tableDetailsn = tableDetails[indexOfTableDetails]; 1860 if (check(tableName, columnName, tableDetailsn, 1861 columnDetails[indexOfColumnDetails], serverSession)) { 1862 String [] keyArray1 = getDetailedColumn(columnName, 1863 tableDetailsn, 1864 columnDetails[indexOfColumnDetails], serverSession); 1865 columnDetails[indexOfColumnDetails].setColumn(keyArray1); 1866 columnDetails[indexOfColumnDetails].setTableForDisplay( 1867 tableDetailsn); 1868 columnDetails[indexOfColumnDetails].setTableDetails( 1869 tableDetailsn); 1870 columnDetails[indexOfColumnDetails].setObject(tableDetailsn. 1871 getColumnPropertiesExcludingCommonColumns()); 1872 break; 1873 } 1874 } 1875 } 1876 1877 continue; 1878 } 1879 1880 if (type == SCALARFUNCTION || type == CASEEXPRESSION || type == GROUPING || 1881 type == FUNCTIONAL || type == USERFUNCTION ) { 1882 1883 _Reference[] ref = setTableNamesAndDatatypesOfAllColumns(serverSession, 1884 columnDetails[indexOfColumnDetails].getExistingColumnDetails(), 1885 tableDetails); 1887 String oper = null; 1888 try { 1889 oper = (type == GROUPING) ? 1890 ( (generalsetfunction) columnDetails[indexOfColumnDetails]. 1891 getObject())._setfunctiontype4.run(null).toString() : "Kaushik"; 1892 } 1893 catch (ClassCastException ex) { 1894 oper = "Kaushik"; 1895 } 1896 if (oper.equalsIgnoreCase("max") || oper.equalsIgnoreCase("min")) { 1897 1898 if (! ( (generalsetfunction) columnDetails[indexOfColumnDetails]. 1899 getObject()).checkForSubQuery() && 1900 !columnDetails[indexOfColumnDetails].getExistingColumnDetails()[0]. 1901 getQuestion()) 1902 1903 columnDetails[indexOfColumnDetails].setSize(columnDetails[ 1904 indexOfColumnDetails].getExistingColumnDetails()[0].getSize()); 1905 } 1906 if (ref != null) 1907 unKnownReferences.addAll(Arrays.asList(ref)); 1908 continue; 1909 } 1910 checkForEachTable(serverSession, columnDetails[indexOfColumnDetails], 1911 tableDetails, unKnownReferences); 1912 } 1913 1914 return unKnownReferences.isEmpty() ? null : 1915 (_Reference[]) 1916 unKnownReferences.toArray(new _Reference[unKnownReferences.size()]); 1917 } 1918 1919 1929 1930 private void setCount(_ServerSession serverSession, 1931 TableDetails[] tableDetail, ColumnDetails columnDetails) throws 1932 com.daffodilwoods.database.resource.DException { 1933 ArrayList aList = new ArrayList (); for (int i = 0; i < tableDetail.length; ++i) 1935 aList.addAll(Arrays.asList(tableDetail[i]. 1936 getColumnPropertiesExcludingCommonColumns())); 1937 columnDetails.setObject( (ColumnDetails[]) aList.toArray(new ColumnDetails[ 1938 aList.size()])); 1939 1940 1941 } 1942 1943 1959 1960 private void checkForEachTable(_ServerSession serverSession, 1961 ColumnDetails columnDetail, 1962 TableDetails[] tableDetails, 1963 ArrayList unKnownReferences) throws com. 1964 daffodilwoods.database.resource.DException { 1965 String [] keyArray; 1966 boolean check = false; Object [] result = new Object [4]; 1968 for (int indexOfTableDetails = 0; indexOfTableDetails < tableDetails.length; 1969 ++indexOfTableDetails) { 1970 TableDetails tempTableDetails = tableDetails[indexOfTableDetails]; 1971 String columnName[] = columnDetail.getColumnName(); 1973 if (columnDetail.getType() == GROUPING) 1974 return; 1975 keyArray = getDetailedColumn(columnName, tempTableDetails, columnDetail, 1976 serverSession); if (keyArray == null) 1978 continue; if (columnDetail.getTableAliasArray() != null) { 1980 columnDetail.setColumn(keyArray); 1981 return; 1982 } 1983 1984 1985 1986 int key = tempTableDetails.checkForColumn(keyArray); 1987 if (key != -1) { 1988 if (check) throw new DException("DSE17", 1990 new Object [] {columnDetail.getNameOfTable()}); columnDetail.setTableDetails(tempTableDetails); columnDetail.setTableForDisplay(tempTableDetails); 1993 check = true; 1994 result[0] = columnDetail; 1995 result[1] = keyArray; 1996 result[2] = new Integer (tempTableDetails.getDatatype(key)); 1997 result[3] = new Integer (tempTableDetails.getSize(key)); 1998 } 1999 else if (containsClauseFlag) { 2000 if (columnDetail.getContainClauseFlag() && tableDetails.length == 1) { 2001 _FullTextIndexInformation[] fullTextIndexInfo = serverSession. 2002 getIndexTable(tempTableDetails.getQualifiedIdentifier()). 2003 getFullTextIndexInformation(); 2004 2005 if (fullTextIndexInfo == null) { 2006 throw new DException("DSE8119", 2007 new Object [] {columnDetail.getColumn()}); 2008 } 2009 2010 for (int i = 0; i < fullTextIndexInfo.length; i++) { 2011 if (columnDetail.getAppropriateColumn().equalsIgnoreCase(fullTextIndexInfo[i]. 2012 getIndexName())) { 2013 columnDetail.setTableDetails(tempTableDetails); 2014 columnDetail.setTableForDisplay(tempTableDetails); 2015 columnDetail.setDatatype(Datatypes.VARCHAR); 2016 return; 2017 } 2018 } 2019 throw new DException("DSE8119", new Object [] {columnDetail.getColumn()}); 2020 } 2021 } 2022 } 2023 if (!check) { unKnownReferences.add(columnDetail); return; 2026 } 2027 2028 if (!containsClauseFlag && 2029 ! ( ( (ColumnDetails) result[0]).ifBelongToSelectList() || 2030 ( (ColumnDetails) result[0]).ifBelongToAllowedPredicate())) { 2031 Check.checkForAllowedDatatype(result[2].hashCode()); 2032 } 2033 ( (ColumnDetails) result[0]).setColumn( (String []) result[1]); 2034 ( (ColumnDetails) result[0]).setDatatype(result[2].hashCode()); 2035 ( (ColumnDetails) result[0]).setSize(result[3].hashCode()); 2036 } 2037 2038 2090 2091 2105 private String [] getDetailedColumn(String columnName[], 2106 TableDetails tableDetails, 2107 ColumnDetails columnDetails, 2108 _ServerSession serverSession) throws 2109 DException { 2110 String [] appropriateTableName = tableDetails.getAppropriateTableName(); String [] originalTableName = tableDetails.getTableName(); 2112 if (check(appropriateTableName, columnName, tableDetails, columnDetails, 2113 serverSession)) 2114 return append(originalTableName, columnName); 2115 return null; 2116 } 2117 2118 2133 private boolean check(String [] tableName, String [] columnName, 2134 TableDetails tableDetails, ColumnDetails columnDetail, 2135 _ServerSession serverSession) throws DException { 2136 for (int i = columnName.length - 2, j = tableName.length - 1, 2137 length = columnName.length; i >= 0 && j >= 0; i--, j--) { 2138 if (!tableName[j].equalsIgnoreCase(columnName[i])) { 2139 if (length - 2 != 0 && i == length - 2 && j == tableName.length - 1) { 2140 String aliasName = tableDetails.getAliasName(); 2141 if (aliasName != null && aliasName.equalsIgnoreCase(columnName[0])) { 2142 checkForeignKeyCC(tableDetails, columnDetail, serverSession, 2143 columnName); 2144 2145 return true; 2146 } 2147 } 2148 2149 return false; 2150 } 2151 } 2152 2153 return true; 2154 } 2155 2156 2165 private void checkForeignKeyCC(TableDetails tableDetails, 2166 ColumnDetails columnDetail, 2167 _ServerSession serverSession, 2168 String [] columnName) throws DException { 2169 int length = columnName.length; 2170 QualifiedIdentifier identifier = tableDetails.getQualifiedIdentifier(); 2171 String [] tableAliasArray = new String [length - 2]; 2172 _ColumnCharacteristics columnCharacteristics = serverSession. 2173 getColumnCharacteristics(identifier); 2174 ArrayList listOfFKeyTables = new ArrayList (); 2175 TableDetails tempTable = tableDetails; 2176 int serverType = serverSession.getType(); 2177 2178 for (int i = 1, j = 0; i < length - 1; i++, j++) { 2179 if (!ifExistsColumnInCC(columnName[i], 2180 columnCharacteristics.getColumnNames())) 2181 throw new DException("DSE3557", new Object [] {columnName[i], identifier}); Object [] object = serverSession.getForeignConstraintCharacteritics( 2183 identifier, columnName[i]); 2184 2185 if (serverType == IteratorConstants.UPDATABLE) { 2186 identifier = (QualifiedIdentifier) object[0]; 2187 columnCharacteristics = (_ColumnCharacteristics) object[1]; 2188 2189 TableDetails table = new TableDetails(); 2190 table.setTableName(identifier.getTableName()); 2191 table.cc = columnCharacteristics; 2192 listOfFKeyTables.add(table); 2193 2194 tempTable = table; 2195 String [] referencedColumns = (String []) object[2]; 2196 } 2197 tableAliasArray[j] = columnName[i]; 2198 } 2199 columnDetail.setTableAliasArray(tableAliasArray); 2200 tableDetails.setUnderLyingFKeyTables( (TableDetails[]) listOfFKeyTables. 2201 toArray(new TableDetails[ 2202 listOfFKeyTables.size()])); 2203 if (columnName[length - 1].equalsIgnoreCase("*")) 2204 initializeAllColumnsOfForeign(columnDetail, columnCharacteristics, 2205 tableDetails, tableAliasArray); 2206 else { 2207 if (!ifExistsColumnInCC(columnName[length - 1], 2208 columnCharacteristics.getColumnNames())) 2209 throw new DException("DSE3557", new Object [] {columnName[length - 1], 2210 identifier}); columnDetail.setDatatype(columnCharacteristics.getColumnType( 2212 columnCharacteristics.getColumnIndex(columnName[length - 1]))); 2213 columnDetail.setSize(columnCharacteristics.getSize(columnCharacteristics. 2214 getColumnIndex(columnName[length - 1]))); 2215 columnDetail.setTableDetails(tableDetails); 2216 columnDetail.setQualifiedIdentifier(new QualifiedIdentifier( 2217 columnCharacteristics.getCatalogName(0), 2218 columnCharacteristics.getSchemaName(0), 2219 columnCharacteristics.getTableName(0))); 2220 columnDetail.setChainedColumnCC(columnCharacteristics); 2221 } 2222 } 2223 2224 2232 private void initializeAllColumnsOfForeign(ColumnDetails columnDetail, 2233 _ColumnCharacteristics 2234 columnCharacteristics, 2235 TableDetails table, 2236 String [] tableAliasArray) throws 2237 DException { 2238 String [] ccColumnNames = columnCharacteristics.getColumnNames(); 2239 int length = ccColumnNames.length; 2240 QualifiedIdentifier identifier = new QualifiedIdentifier( 2241 columnCharacteristics.getCatalogName(0), 2242 columnCharacteristics.getSchemaName(0), 2243 columnCharacteristics.getTableName(0)); 2244 ColumnDetails[] newColumns = new ColumnDetails[length - 5]; 2245 for (int i = 5, j = 0; i < length; i++, j++) { 2246 ColumnDetails columnDetails = new ColumnDetails(); 2247 String [] tableName = table.getTableName(); 2248 String [] column = new String [4]; 2249 System.arraycopy(tableName, 0, column, 0, tableName.length); 2250 column[3] = ccColumnNames[i]; 2251 columnDetails.setColumn(column); 2252 columnDetails.setChainedColumnCC(columnCharacteristics); 2253 columnDetails.setDatatype(columnCharacteristics.getColumnType(i)); 2254 columnDetails.setSize(columnCharacteristics.getSize(i)); 2255 columnDetails.setTableDetails(table); 2256 columnDetails.setTableForDisplay(table); 2257 columnDetails.setType(REFERENCE); 2258 2259 columnDetails.setTableAliasArray(tableAliasArray); 2260 columnDetails.setQualifiedIdentifier(identifier); 2261 newColumns[j] = columnDetails; 2262 } 2263 columnDetail.setObject(newColumns); 2264 columnDetail.setTableDetails(table); 2265 } 2266 2267 2274 2275 private boolean ifExistsColumnInCC(String columnName, String [] columns) { 2276 int length = columns.length; 2277 for (int i = 0; i < length; i++) { 2278 if (columns[i].equalsIgnoreCase(columnName)) 2279 return true; 2280 } 2281 return false; 2282 } 2283 2284 2292 private String [] append(String [] tableName, String [] columnName) throws 2293 DException { 2294 String [] result = new String [tableName.length + 1]; 2295 System.arraycopy(tableName, 0, result, 0, tableName.length); 2296 result[result.length - 1] = columnName[columnName.length - 1]; 2297 return result; 2298 } 2299 2300 2306 public Object [][] getHasRecordMapping() throws DException { 2307 Object [][] hasRecordMapping = null; 2308 for (int i = 0, length = userDefinedColumnDetails.length; i < length; i++) { 2309 ColumnDetails ud = userDefinedColumnDetails[i]; 2310 if (userDefinedColumnDetails[i].getType() == HAS_RECORD) { 2311 if (hasRecordMapping == null) { 2312 hasRecordMapping = new Object [1][2]; 2313 hasRecordMapping[0][0] = userDefinedColumnDetails[i].getTable(); 2314 ArrayList list = new ArrayList (); 2315 list.add(ud); 2316 hasRecordMapping[0][1] = list; 2317 continue; 2318 } 2319 int index = searchInMapping(ud.getTable(), hasRecordMapping); 2320 if (index == -1) { 2321 hasRecordMapping = makeAnEntry(ud, hasRecordMapping); 2322 continue; 2323 } 2324 ArrayList columns = (ArrayList ) hasRecordMapping[index][1]; 2325 columns.add(ud); 2326 } 2327 } 2328 return hasRecordMapping; 2329 } 2330 2331 2339 private int searchInMapping(TableDetails table, Object [][] hasRecordMapping) throws 2340 DException { 2341 for (int i = 0, length = hasRecordMapping.length; i < length; i++) { 2342 if (hasRecordMapping[i][0] == table) 2343 return i; 2344 } 2345 return -1; 2346 } 2347 2348 2356 private Object [][] makeAnEntry(ColumnDetails column, 2357 Object [][] hasRecordMapping) throws DException { 2358 int length = hasRecordMapping.length; 2359 Object [][] newMapping = new Object [length + 1][2]; 2360 System.arraycopy(hasRecordMapping, 0, newMapping, 0, length); 2361 newMapping[length][0] = column.getTable(); 2362 ArrayList list = new ArrayList (); 2363 list.add(column); 2364 newMapping[length][1] = list; 2365 return newMapping; 2366 } 2367 2368 2376 public void semanticCheckingUpdate(_ServerSession serverSession0, 2377 ArrayList listOfUnderLyingReferences) throws 2378 DException { 2379 serverSession = serverSession0; 2380 SetColumnProperties.checkingForAmbuityForTableNamesWithCC(serverSession, 2381 tableDetails); SetColumnProperties.setTableNamesAndDatatypesOfAllColumns(serverSession, 2383 whereClauseColumnDetails, tableDetails, listOfUnderLyingReferences, 2384 new ArrayList ()); 2385 } 2386 2387 2393 2394 public ColumnDetails[] getAppropriateUserDefinedColumns() { 2395 return clonedUserDefinedColumnDetails == null ? userDefinedColumnDetails : 2396 clonedUserDefinedColumnDetails; 2397 } 2398 2399 2405 2406 public void setDistinctRedundant() { 2407 isDistinct = false; 2408 clonedUserDefinedColumnDetails = null; 2409 } 2410 2411 2412 public void setDatatypeOfConstantColunmsInSelectList(ColumnDetails[] cd, 2413 _ServerSession session) throws DException { 2414 VariableValues vv = new VariableValues(session); 2415 2416 if(cd==null) return ; 2417 for (int i = 0; i < cd.length; i++) { 2418 int type=cd[i].getType(); 2419 if(type==SCALARFUNCTION || type==CASEEXPRESSION || type==FUNCTIONAL || type==USERFUNCTION) 2420 setDatatypeOfConstantColunmsInSelectList(cd[i].getChildColumnDetails(),session); 2421 else if(type==GROUPING){ 2422 2423 ColumnDetails[] cdChild = cd[i].getChildColumnDetails(); 2424 for (int j = 0; j < cdChild.length; j++) { 2425 if (cdChild[j].getType() == CONSTANT && !cdChild[j].getQuestion() && 2426 ! (cdChild[j].getTypeForSequence() == SEQUENCETYPE)) { 2427 ( (FieldBase) cdChild[j].run(vv)).setDatatype( -1); 2428 } 2429 } 2430 } 2431 } 2432 } 2433 2434 public void checkOrderByDistinctSemantic(ColumnDetails[] orderCD, 2435 ColumnDetails[] cd2) throws 2436 DException { 2437 2438 if (isDistinct && orderCD != null) { 2439 boolean c = false; 2440 for (int i = 0; i < orderCD.length; i++) { 2441 c = false; 2442 for (int j = 0; j < cd2.length; j++) { 2443 if (orderCD[i].getType() == TypeConstants.CONSTANT || 2444 ((orderCD[i].getAppropriateColumn().equalsIgnoreCase(cd2[j]. 2445 getAppropriateColumn()) ||( orderCD[i].getColumn().equalsIgnoreCase(cd2[j].getColumn()))) 2446 && 2447 (orderCD[i].getTable() == null || 2448 orderCD[i].getTable() == cd2[j].getTable()))) { 2449 c = true; 2450 } 2451 } 2452 if (!c) { 2453 throw new DException("DSE6006", null); 2454 } 2455 } 2456 } 2457 2462 } 2463 2464 2465 public void checkSelectListDistinctSemantic() throws DException { 2466 if (isDistinct) { 2467 for (int i = 0; i < userDefinedColumnDetails.length; i++) { 2468 if (userDefinedColumnDetails[i].getDatatype() == Datatypes.CLOB || 2469 userDefinedColumnDetails[i].getDatatype() == Datatypes.BLOB) { 2470 throw new DException("DSE6001", 2471 new Object [] {StaticClass. 2472 getDataTypeName(userDefinedColumnDetails[i]. 2473 getDatatype())}); 2474 } 2475 } 2476 } 2477 } 2478 2479 2543 2544 2545 private static void checkForQuestion(ColumnDetails[] cd) throws DException { 2546 for (int i = 0; i < cd.length; i++) { 2547 int type = cd[i].getType(); 2548 if (cd[i].getQuestion()) 2549 throw new DException("DSE3528", null); 2550 if (cd[i].getTypeForSequence() == SEQUENCETYPE) 2551 throw new DException("DSE6013", null); 2552 if ( ( (type == CASEEXPRESSION || type == FUNCTIONAL || 2553 type == SCALARFUNCTION 2554 || type == GROUPING || type == USERFUNCTION))) { 2555 ColumnDetails[] cd1 = cd[i].getChildColumnDetails(); 2556 for (int j = 0; j < cd1.length; j++) { 2557 checkForQuestion(cd1); 2558 2559 } 2560 } 2561 } 2562 } 2563 2564 private static void checkingForSequence(ColumnDetails[] cd) throws DException { 2565 for (int i = 0; i < cd.length; i++) { 2566 int type = cd[i].getType(); 2567 if (cd[i].getTypeForSequence() == SEQUENCETYPE) 2568 throw new DException("DSE6013", null); 2569 if ( ( (type == CASEEXPRESSION || type == FUNCTIONAL || 2570 type == SCALARFUNCTION 2571 || type == GROUPING || type == USERFUNCTION))) { 2572 ColumnDetails[] cd1 = cd[i].getChildColumnDetails(); 2573 for (int j = 0; j < cd1.length; j++) { 2574 checkingForSequence(cd1); 2575 2576 } 2577 } 2578 } 2579 } 2580 2581 2585 private void checkForDuplicateOrderColumnAndPositionSemantic( 2586 ColumnDetails[] cd) throws DException { 2587 2590 2591 for (int i = 0; i < cd.length; i++) { 2592 int value = 0; 2593 if(selectListColumnDetails[i].getType()==CONSTANT && selectListColumnDetails[i].getAppropriateColumn().equalsIgnoreCase("*") ) 2594 continue; 2595 Integer obj = getOrdinalNoValue(cd[i]); 2596 if (obj == null) 2597 continue; 2598 value = obj.intValue(); 2599 int j = value - 1; 2600 for (int k = 0; k < cd.length; k++) { 2601 if (selectListColumnDetails[j].getAppropriateColumn().equals(cd[k]. 2602 getAppropriateColumn())) { 2603 throw new DException("DSE3541", null); 2604 2605 } 2606 } 2607 } 2608 2609 } 2610 2611 2614 private void checkForOrderColumnSemantic( 2615 ColumnDetails[] cd) throws DException { 2616 2619 for (int i = 0; i < cd.length; i++) { 2620 if(selectListColumnDetails[i].getType()==CONSTANT && selectListColumnDetails[i].getAppropriateColumn().equalsIgnoreCase("*")) 2621 continue; 2622 int value = 0; 2623 Integer obj = getOrdinalNoValue(cd[i]); 2624 if (obj == null) 2625 continue; 2626 value = obj.intValue(); 2627 int j = value - 1; 2628 for (int k = 0; k < cd.length; k++) { 2629 checkForQuestion(new ColumnDetails[] {selectListColumnDetails[j]}); 2630 } 2631 } 2632 } 2633 2636 2637 private void checkForOneBooleanExpressionWhenContainsClauseIsPresent() throws 2638 DException { 2639 if (whereClauseColumnDetails.length > 1) 2640 throw new DException("DSE0", new Object [] {"Boolean expression can't be specified in where clause when Contains clause is present"}); 2641 } 2642 private static void checkingForsubqueryInGroupByClause(ColumnDetails[] cd) throws DException { 2643 if(cd.length == 0){ 2644 throw new DException("DSE6014",null); 2645 } 2646 for (int i = 0; i < cd.length; i++) { 2647 int type = cd[i].getType(); 2648 if ( ( (type == CASEEXPRESSION || type == FUNCTIONAL 2649 || type == GROUPING || type == USERFUNCTION))) { 2650 throw new DException("DSE6015",new Object []{cd[i].getColumn()}); } 2652 ColumnDetails[] cd1 ; 2653 if(type == SCALARFUNCTION){ 2654 cd1 = cd[i].getChildColumnDetails(); 2655 checkingForsubqueryInGroupByClause(cd1); 2656 } 2657 } 2658 } 2659 2660 private void checkForScalarSubQueryInSelectList(_ServerSession serverSession0) throws 2661 DException { 2662 selectsublist[] selectsublist = selectList._OptRepScomma94843605selectsublist0; 2663 for (int i = 0; i < selectsublist.length; i++) { 2664 if (selectsublist[i].getColumnDetails().length == 0) { 2665 if ( ( (derivedcolumn) selectsublist[i])._valueexpression1. 2666 checkForSubQuery()) { 2667 ( (derivedcolumn) selectsublist[i])._valueexpression1.checkSemantic( 2668 serverSession0); 2669 2670 } 2671 } 2672 ColumnDetails[] cd1 = selectsublist[i].getColumnDetails(); 2673 setTemp(cd1,selectsublist[i],serverSession0); 2674 } 2675 2676 } 2677 2678 void setTemp(ColumnDetails[] cd1,selectsublist selectsublist1 ,_ServerSession serverSession0) throws DException { 2679 for (int j = 0; j < cd1.length; j++) { 2680 if (cd1[j].getType() == USERFUNCTION) { 2681 ( (derivedcolumn) selectsublist1)._valueexpression1.checkSemantic( 2682 serverSession0); 2683 } 2684 if (cd1[j].getType() == FUNCTIONAL ) { 2685 ColumnDetails[] cdChild = cd1[j].getChildColumnDetails(); 2686 setTemp(cdChild,selectsublist1,serverSession0); 2687 } 2688 } 2689 } 2690 2691} 2692 | Popular Tags |