From: <ibr...@us...> - 2011-10-07 23:27:44
|
Revision: 4107 http://tora.svn.sourceforge.net/tora/?rev=4107&view=rev Author: ibre5041 Date: 2011-10-07 23:27:37 +0000 (Fri, 07 Oct 2011) Log Message: ----------- Modified Paths: -------------- branches/tora-trotl/sandbox/tests/query_factoring01.sql branches/tora-trotl/src/docklets/toastwalk.cpp branches/tora-trotl/src/parsing/tsqlparse.cpp branches/tora-trotl/src/parsing/tsqlparse.h branches/tora-trotl/src/parsing/tsqlparseoracle.cpp Modified: branches/tora-trotl/sandbox/tests/query_factoring01.sql =================================================================== --- branches/tora-trotl/sandbox/tests/query_factoring01.sql 2011-10-07 15:13:29 UTC (rev 4106) +++ branches/tora-trotl/sandbox/tests/query_factoring01.sql 2011-10-07 23:27:37 UTC (rev 4107) @@ -10,6 +10,7 @@ WHERE R.EID = E.MANAGER_ID ) SELECT EID, EMP_LAST, MGR_ID, REPORTLEVEL -FROM REPORTS_TO_101 +FROM REPORTS_TO_101 R, AUTO A +WHERE R.C1 = A.C2 ORDER BY REPORTLEVEL, EID ; Modified: branches/tora-trotl/src/docklets/toastwalk.cpp =================================================================== --- branches/tora-trotl/src/docklets/toastwalk.cpp 2011-10-07 15:13:29 UTC (rev 4106) +++ branches/tora-trotl/src/docklets/toastwalk.cpp 2011-10-07 23:27:37 UTC (rev 4107) @@ -1,4 +1,3 @@ - #include "toastwalk.h" #include "../tologger.h" #include "../ermodel/dotgraph.h" @@ -33,16 +32,17 @@ o->addTable(SQLParser::ObjectCache::TableInfo(QString("SERVICEDESK"), QString("ITSM_INCIDENTS"), cols)); cols.clear(); - // REP_CODES_TEXT // T2 + // REP_CODES_TEXT // T2 T12 T99 cols.append(QString("RCT_NAME")); cols.append(QString("RCT_RCD_OID")); o->addTable(SQLParser::ObjectCache::TableInfo(QString("SERVICEDESKREPO"), QString("REP_CODES_TEXT"), cols)); cols.clear(); - + // ITSM_INC_CUSTOM_FIELDS // T3 cols.append(QString("ICF_INCSHORTTEXT2")); cols.append(QString("ICF_INCSHORTTEXT3")); cols.append(QString("ICF_INCSHORTTEXT4")); + cols.append(QString("ICF_INC_OID")); o->addTable(SQLParser::ObjectCache::TableInfo(QString("SERVICEDESK"), QString("ITSM_INC_CUSTOM_FIELDS"), cols)); cols.clear(); @@ -51,7 +51,38 @@ cols.append(QString("WOG_SEARCHCODE")); o->addTable(SQLParser::ObjectCache::TableInfo(QString("SERVICEDESK"), QString("ITSM_WORKGROUPS"), cols)); cols.clear(); - + + // ITSM_PERSONS // T5 + cols.append(QString("PER_SEARCHCODE")); + cols.append(QString("PER_OID")); + o->addTable(SQLParser::ObjectCache::TableInfo(QString("SERVICEDESK"), QString("ITSM_PERSONS"), cols)); + cols.clear(); + + // ITSM_CODES_LOCALE // T6 T7 T8 T9 T11 T13 T16 + cols.append(QString("CDL_NAME")); + cols.append(QString("CDL_COD_OID")); + o->addTable(SQLParser::ObjectCache::TableInfo(QString("SERVICEDESK"), QString("ITSM_CODES_LOCALE"), cols)); + cols.clear(); + + // ITSM_CONFIGURATION_ITEMS // T10 + cols.append(QString("CIT_SEARCHCODE")); + cols.append(QString("CIT_OID")); + o->addTable(SQLParser::ObjectCache::TableInfo(QString("SERVICEDESK"), QString("ITSM_CONFIGURATION_ITEMS"), cols)); + cols.clear(); + + // ITSM_HISTORYLINES_INCIDENT // a d + cols.append("HIN_SUBJECT"); + cols.append("HIN_INC_OID"); + cols.append("REG_CREATED"); + o->addTable(SQLParser::ObjectCache::TableInfo(QString("SERVICEDESK"), QString("ITSM_HISTORYLINES_INCIDENT"), cols)); + cols.clear(); + + // ITSM_CODES // T14 T15 + cols.append(QString("COD_OID")); + cols.append(QString("COD_COD_OID")); + o->addTable(SQLParser::ObjectCache::TableInfo(QString("SERVICEDESK"), QString("ITSM_CODES"), cols)); + cols.clear(); + source->scanTree(o, QString("SERVICEDESK")); //target->initEmpty(); @@ -273,8 +304,8 @@ TLOG(0,toDecorator,__HERE__) << "!?" << firstTable->toStringRecursive(false) << "->" << secondTable->toStringRecursive(false) << std::endl; } - SQLParser::Token const *t1 = source->translateAlias(firstTable->child(0)->toStringRecursive(false).toUpper(), &*node); - SQLParser::Token const *t2 = source->translateAlias(secondTable->child(0)->toStringRecursive(false).toUpper(), &*node); + SQLParser::Token const *t1 = firstTable ? source->translateAlias(firstTable->child(0)->toStringRecursive(false).toUpper(), &*node) : NULL; + SQLParser::Token const *t2 = secondTable ? source->translateAlias(secondTable->child(0)->toStringRecursive(false).toUpper(), &*node) : NULL; QString e1, e2; if( t1 && ( Modified: branches/tora-trotl/src/parsing/tsqlparse.cpp =================================================================== --- branches/tora-trotl/src/parsing/tsqlparse.cpp 2011-10-07 15:13:29 UTC (rev 4106) +++ branches/tora-trotl/src/parsing/tsqlparse.cpp 2011-10-07 23:27:37 UTC (rev 4107) @@ -47,8 +47,8 @@ TSQLPARSER_EXPORT QMap<QPair<QString, QString>, ObjectCache::TableInfo>::const_iterator ObjectCache::getTable(QString const& currentSchema, QString const& schema, QString const& table) const { QMap<QPair<QString, QString>, ObjectCache::TableInfo>::const_iterator retval; - QMap<QPair<QString, QString>, QPair<QString,QString>>::const_iterator synonymTranslationNew, synonymTranslationLast = _mSynonymMap.end(); - QSet<QPair<QString, QString>> loopStack; + QMap<QPair<QString, QString>, QPair<QString,QString> >::const_iterator synonymTranslationNew, synonymTranslationLast = _mSynonymMap.end(); + QSet<QPair<QString, QString> > loopStack; // 1st try - schema is empty if( schema.isEmpty()) @@ -96,8 +96,8 @@ return retval; // 2st try (b) - "schema.table" is a synonym - QMap<QPair<QString, QString>, QPair<QString,QString>>::const_iterator synonymTranslationNew, synonymTranslationLast; - QSet<QPair<QString, QString>> loopStack; + QMap<QPair<QString, QString>, QPair<QString,QString> >::const_iterator synonymTranslationNew, synonymTranslationLast; + QSet<QPair<QString, QString> > loopStack; synonymTranslationNew = _mSynonymMap.constFind(QPair<QString,QString>(schema, table)); if( synonymTranslationNew != _mSynonymMap.end()) @@ -142,8 +142,17 @@ k->getTokenType() == Token::X_ROOT) { TokenSubquery const &s = static_cast<TokenSubquery const&>(*k); - if(s.aliasTranslation().contains(alias.toUpper())) - return s.aliasTranslation().value(alias); + if( s.aliasTranslation().contains(alias.toUpper())) + { + Token const* a1 = s.aliasTranslation().value(alias); + if( a1->getTokenType() == Token::S_TABLE_REF && a1->childCount() == 1 ) // In fact S_TABLE_REF can be alias for S_SUBQUERY_FACTORED + { + Token const* a2 = translateAlias( a1->toStringRecursive(false), &*k); + if( a2) + return a2; + } + return a1; + } } } return NULL; Modified: branches/tora-trotl/src/parsing/tsqlparse.h =================================================================== --- branches/tora-trotl/src/parsing/tsqlparse.h 2011-10-07 15:13:29 UTC (rev 4106) +++ branches/tora-trotl/src/parsing/tsqlparse.h 2011-10-07 23:27:37 UTC (rev 4107) @@ -79,7 +79,7 @@ QMap<QPair<QString, QString>, TableInfo>::const_iterator getTable(QString const& currentSchema, QString const& schema, QString const& table) const; QMap<QPair<QString, QString>, TableInfo> _mTableMap; - QMap<QPair<QString, QString>, QPair<QString,QString>> _mSynonymMap; + QMap<QPair<QString, QString>, QPair<QString,QString> > _mSynonymMap; }; /* Modified: branches/tora-trotl/src/parsing/tsqlparseoracle.cpp =================================================================== --- branches/tora-trotl/src/parsing/tsqlparseoracle.cpp 2011-10-07 15:13:29 UTC (rev 4106) +++ branches/tora-trotl/src/parsing/tsqlparseoracle.cpp 2011-10-07 23:27:37 UTC (rev 4107) @@ -572,7 +572,7 @@ stopToken = k->toString(); if( k->getTokenType() == Token::S_COLUMN_LIST) { - TLOG(0,toDecorator,__HERE__) << " Dont Resolve identifier: " << i->toStringRecursive().toStdString() << "\t under: " << stopToken.toStdString() << std::endl; + TLOG(0,toDecorator,__HERE__) << " Dont Resolve identifier: " << i->toStringRecursive(false).toStdString() << "\t under: " << stopToken.toStdString() << std::endl; insideColumnList = true; break; } @@ -590,7 +590,7 @@ continue; TokenIdentifier const& id = static_cast<TokenIdentifier const&>(*i); - TLOG(0,toDecorator,__HERE__) << "Resolve identifier: " << id.toStringRecursive().toStdString() << "\t under: " << stopToken.toStdString() << std::endl; + TLOG(0,toDecorator,__HERE__) << "Resolve identifier: " << id.toStringRecursive(false).toStdString() << "\t under: " << stopToken.toStdString() << std::endl; QString schemaName, tableName, columnName; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |