From: <mrj...@us...> - 2008-01-13 20:24:58
|
Revision: 2439 http://tora.svn.sourceforge.net/tora/?rev=2439&view=rev Author: mrjohnson0 Date: 2008-01-13 12:24:40 -0800 (Sun, 13 Jan 2008) Log Message: ----------- these classes basically did a subselect to deal with oracle long types. i figured out a way to do it in sql instead. Modified Paths: -------------- branches/tora-1.4/tora/src/CMakeLists.txt branches/tora-1.4/tora/src/Makefile.am Removed Paths: ------------- branches/tora-1.4/tora/src/toresultconstraint.cpp branches/tora-1.4/tora/src/toresultconstraint.h branches/tora-1.4/tora/src/toresultindexes.cpp branches/tora-1.4/tora/src/toresultindexes.h branches/tora-1.4/tora/src/toresultreferences.cpp branches/tora-1.4/tora/src/toresultreferences.h Modified: branches/tora-1.4/tora/src/CMakeLists.txt =================================================================== --- branches/tora-1.4/tora/src/CMakeLists.txt 2008-01-13 20:19:49 UTC (rev 2438) +++ branches/tora-1.4/tora/src/CMakeLists.txt 2008-01-13 20:24:40 UTC (rev 2439) @@ -118,13 +118,11 @@ toresultcolscomment.h toresultcols.h toresultcombo.h - toresultconstraint.h toresultcontent.h toresultdepend.h toresultextract.h toresultfield.h toresult.h - toresultindexes.h toresultitem.h toresultlabel.h toresultline.h @@ -134,7 +132,6 @@ toresultparam.h toresultpie.h toresultplan.h - toresultreferences.h # toresultresources.h toresultstats.h toresultstorage.h @@ -238,13 +235,11 @@ toresultcolscomment.cpp toresultcols.cpp toresultcombo.cpp - toresultconstraint.cpp toresultcontent.cpp toresult.cpp toresultdepend.cpp toresultextract.cpp toresultfield.cpp - toresultindexes.cpp toresultitem.cpp toresultlabel.cpp toresultline.cpp @@ -254,7 +249,6 @@ toresultparam.cpp toresultpie.cpp toresultplan.cpp - toresultreferences.cpp toresultstats.cpp toresultstorage.cpp toresulttableview.cpp Modified: branches/tora-1.4/tora/src/Makefile.am =================================================================== --- branches/tora-1.4/tora/src/Makefile.am 2008-01-13 20:19:49 UTC (rev 2438) +++ branches/tora-1.4/tora/src/Makefile.am 2008-01-13 20:24:40 UTC (rev 2439) @@ -169,7 +169,6 @@ toeditextensionsetupui.h \ toextract.cpp toextract.h \ toreport.cpp toreport.h \ - toresultconstraint.cpp toresultconstraint.h \ toresultextract.cpp toresultextract.h \ toresultcols.cpp toresultcols.h \ toresultcolscomment.cpp toresultcolscomment.h \ @@ -177,13 +176,11 @@ toresultcontent.cpp toresultcontent.h \ toresultcontentfilterui.h \ toresultdepend.cpp toresultdepend.h \ - toresultindexes.cpp toresultindexes.h \ toresultlabel.cpp toresultlabel.h \ toresultlock.cpp toresultlock.h \ toresultlong.cpp toresultlong.h \ toresultplan.cpp toresultplan.h \ toresultparam.cpp toresultparam.h \ - toresultreferences.cpp toresultreferences.h \ toresultstorage.cpp toresultstorage.h \ torollbackdialogui.h \ toscriptui.h \ @@ -330,12 +327,10 @@ moc_toresultcols.cpp \ moc_toresultcolscomment.cpp \ moc_toresultcombo.cpp \ - moc_toresultconstraint.cpp \ moc_toresultcontent.cpp \ moc_toresultdepend.cpp \ moc_toresultextract.cpp \ moc_toresultfield.cpp \ - moc_toresultindexes.cpp \ moc_toresultitem.cpp \ moc_toresultlabel.cpp \ moc_toresultline.cpp \ @@ -344,7 +339,6 @@ moc_toresultparam.cpp \ moc_toresultpie.cpp \ moc_toresultplan.cpp \ - moc_toresultreferences.cpp \ moc_toresultstats.cpp \ moc_toresultstorage.cpp \ moc_toresultview.cpp \ Deleted: branches/tora-1.4/tora/src/toresultconstraint.cpp =================================================================== --- branches/tora-1.4/tora/src/toresultconstraint.cpp 2008-01-13 20:19:49 UTC (rev 2438) +++ branches/tora-1.4/tora/src/toresultconstraint.cpp 2008-01-13 20:24:40 UTC (rev 2439) @@ -1,351 +0,0 @@ -/***** -* -* TOra - An Oracle Toolkit for DBA's and developers -* Copyright (C) 2003-2005 Quest Software, Inc -* Portions Copyright (C) 2005 Other Contributors -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; only version 2 of -* the License is valid for this program. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -* As a special exception, you have permission to link this program -* with the Oracle Client libraries and distribute executables, as long -* as you follow the requirements of the GNU GPL in regard to all of the -* software in the executable aside from Oracle client libraries. -* -* Specifically you are not permitted to link this program with the -* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech. -* And you are not permitted to distribute binaries compiled against -* these libraries without written consent from Quest Software, Inc. -* Observe that this does not disallow linking to the Qt Free Edition. -* -* You may link this product with any GPL'd Qt library such as Qt/Free -* -* All trademarks belong to their respective owners. -* -*****/ - -#include "utils.h" - -#include "toconf.h" -#include "toconnection.h" -#include "toextract.h" -#include "tonoblockquery.h" -#include "toresultconstraint.h" -#include "tosql.h" -#include "totool.h" - - -toResultConstraint::toResultConstraint(QWidget *parent, const char *name) - : toResultView(false, false, parent, name) -{ - setReadAll(true); - addColumn(tr("Constraint Name")); - addColumn(tr("Condition")); -#ifndef TO_NO_ORACLE - - addColumn(tr("Enabled")); - addColumn(tr("Delete Rule")); - addColumn(tr("Generated")); -#endif - - setSQLName(QString::fromLatin1("toResultConstraint")); - - setSorting(0); - - Query = NULL; - connect(&Poll, SIGNAL(timeout()), this, SLOT(poll())); -} - -bool toResultConstraint::canHandle(toConnection &conn) -{ - return toIsOracle(conn) || - toIsPostgreSQL(conn) || - toExtract::canHandle(conn); -} - -static toSQL SQLConsColumns("toResultConstraint:ForeignColumns", - "SELECT Column_Name,Table_Name FROM sys.All_Cons_Columns\n" - " WHERE Owner = :f1<char[101]> AND Constraint_Name = :f2<char[101]>\n" - " ORDER BY Position", - "Get columns of foreign constraint, must return same number of cols"); - -static toSQL PGSQLConsColumns("toResultConstraint:ForeignColumns", - " SELECT column_name,\n" - " table_name\n" - " FROM information_schema.constraint_column_usage\n" - " WHERE lower ( table_schema ) = lower ( :f1<char[101]> )\n" - " AND lower ( constraint_name ) = lower ( :f2<char[101]> )\n" - " ORDER BY constraint_name\n", - "", - "7.1", - "PostgreSQL"); - -QString toResultConstraint::constraintCols(const QString &conOwner, const QString &conName) -{ - toSQL sql = SQLConsColumns; - toQuery query(connection(), SQLConsColumns, conOwner, conName); - - QString ret; - while (!query.eof()) - { - QString value = query.readValue(); - if (!ret.isEmpty()) - ret.append(QString::fromLatin1(",")); - ret.append(value); - LastTable = query.readValue(); - } - return ret; -} - -static toSQL SQLConstraints("toResultConstraint:ListConstraints", - "SELECT Constraint_Name,\n" - " Search_Condition,\n" - " R_Owner,\n" - " R_Constraint_Name,\n" - " Status,\n" - " Constraint_Type,\n" - " Delete_Rule,\n" - " Generated\n" - " FROM sys.All_Constraints\n" - " WHERE Owner = :f1<char[101]>\n" - " AND Table_Name = :f2<char[101]>\n" - " ORDER BY Constraint_Name", - "List constraints on a table. Must have same column order", - "0800"); - -static toSQL SQLConstraints7("toResultConstraint:ListConstraints", - "SELECT Constraint_Name,\n" - " Search_Condition,\n" - " R_Owner,\n" - " R_Constraint_Name,\n" - " Status,\n" - " Constraint_Type,\n" - " Delete_Rule,\n" - " 'N/A'\n" - " FROM sys.All_Constraints\n" - " WHERE Owner = :f1<char[101]>\n" - " AND Table_Name = :f2<char[101]>\n" - " ORDER BY Constraint_Name", - "", - "0703"); - -static toSQL PGSQLConstraints("toResultConstraint:ListConstraints", - " SELECT cu.constraint_name,\n" - " pg_get_constraintdef ( ct.OID ) AS Search_Condition,\n" - " NULL AS r_owner,\n" - " NULL AS r_constraint_name,\n" - " NOT ct.condeferred AS status,\n" - " ct.contype AS TYPE,\n" - " NULL AS Delete_rule,\n" - " NULL AS GENERATED\n" - " FROM information_schema.constraint_column_usage cu,\n" - " pg_constraint ct\n" - " WHERE lower ( cu.table_schema ) = lower ( :f1<char[101]> )\n" - " AND lower ( Table_Name ) = lower ( :f2<char[101]> )\n" - " AND cu.constraint_name = ct.conname\n" - " ORDER BY constraint_name\n", - "", - "7.4", - "PostgreSQL"); - - -void toResultConstraint::addConstraint(const QString &name, const QString &definition, const QString &status) -{ - toTreeWidgetItem *item = new toResultViewItem(this, NULL); - item->setText(0, name); - item->setText(1, definition); - item->setText(2, status); -} - -void toResultConstraint::query(const QString &sql, const toQList ¶m) -{ - if (!handled()) - return ; - - toQList::iterator cp = ((toQList &)param).begin(); - if (cp != ((toQList &)param).end()) - Owner = *cp; - cp++; - if (cp != ((toQList &)param).end()) - TableName = (*cp); - - if (!setSQLParams(sql, param)) - return ; - - clear(); - - if (toIsOracle(connection())) - { - if (Query) - delete Query; - Query = NULL; - - try - { - toQList par; - par.insert(par.end(), Owner); - par.insert(par.end(), TableName); - Query = new toNoBlockQuery(connection(), toQuery::Background, - toSQL::string(SQLConstraints, connection()), - par); - Poll.start(100); - } - TOCATCH - } - else if (toIsPostgreSQL(connection())) - { - if (Query) - delete Query; - Query = NULL; - - try - { - toQList par; - par.insert(par.end(), Owner); - par.insert(par.end(), TableName); - Query = new toNoBlockQuery(connection(), - toQuery::Background, - toSQL::string(PGSQLConstraints, - connection()), - par); - Poll.start(100); - } - TOCATCH; - } - else - { - std::list<QString> objects; - objects.insert(objects.end(), "TABLE FAMILY:" + Owner + "." + TableName); - objects.insert(objects.end(), "TABLE REFERENCES:" + Owner + "." + TableName); - - toExtract extract(connection(), NULL); - extract.setCode(true); - extract.setHeading(false); - extract.setConstraints(true); - std::list<QString> dsc = extract.describe(objects); - - QString name; - QString definition; - QString status; - - for (std::list<QString>::iterator i = dsc.begin();i != dsc.end();i++) - { - std::list<QString> ctx = toExtract::splitDescribe(*i); - toShift(ctx); // Schema; - toShift(ctx); // Table; - toShift(ctx); // Name; - if (toShift(ctx) == "CONSTRAINT") - { - QString nname = toShift(ctx); - if (nname != name && !name.isEmpty()) - addConstraint(name, definition, status); - name = nname; - QString extra = toShift(ctx); - if (extra == "DEFINITION") - definition = toShift(ctx); - else if (extra == "STATUS") - status = toShift(ctx); - } - } - if (!name.isEmpty()) - addConstraint(name, definition, status); - } -} - -toResultConstraint::~toResultConstraint() -{ - delete Query; -} - -void toResultConstraint::poll() -{ - try - { - if (Query && Query->poll()) - { - while (Query->poll() && !Query->eof()) - { - toTreeWidgetItem *item = new toResultViewItem(this, NULL); - - QString consName = Query->readValue(); - QString check = Query->readValue(); - QString colNames = constraintCols(Owner, consName); - item->setText(0, consName); - QString rConsOwner = Query->readValue(); - QString rConsName = Query->readValue(); - item->setText(2, Query->readValue()); - QString type = Query->readValue(); - - // for pg, the check string is already good - if (toIsPostgreSQL(connection())) - item->setText(1, check); - else - { - QString Condition; - char t = (type.latin1())[0]; - switch (t) - { - case 'U': - Condition = QString::fromLatin1("unique ("); - Condition.append(colNames); - Condition.append(QString::fromLatin1(")")); - break; - case 'P': - Condition = QString::fromLatin1("primary key ("); - Condition.append(colNames); - Condition.append(QString::fromLatin1(")")); - break; - case 'C': - case 'V': - case 'O': - Condition = QString::fromLatin1("check ("); - Condition.append(check); - Condition.append(QString::fromLatin1(")")); - break; - case 'R': - Condition = QString::fromLatin1("foreign key ("); - Condition.append(colNames); - Condition.append(QString::fromLatin1(") references ")); - Condition.append(rConsOwner); - Condition.append(QString::fromLatin1(".")); - QString cols(constraintCols(rConsOwner, rConsName)); - - Condition.append(LastTable); - Condition.append(QString::fromLatin1("(")); - Condition.append(cols); - Condition.append(QString::fromLatin1(")")); - break; - } - item->setText(1, Condition); - } - - item->setText(3, Query->readValueNull()); - item->setText(4, Query->readValue()); - } - if (Query->eof()) - { - delete Query; - Query = NULL; - Poll.stop(); - } - } - } - catch (const QString &exc) - { - delete Query; - Query = NULL; - Poll.stop(); - toStatusMessage(exc); - } -} Deleted: branches/tora-1.4/tora/src/toresultconstraint.h =================================================================== --- branches/tora-1.4/tora/src/toresultconstraint.h 2008-01-13 20:19:49 UTC (rev 2438) +++ branches/tora-1.4/tora/src/toresultconstraint.h 2008-01-13 20:24:40 UTC (rev 2439) @@ -1,91 +0,0 @@ -/***** -* -* TOra - An Oracle Toolkit for DBA's and developers -* Copyright (C) 2003-2005 Quest Software, Inc -* Portions Copyright (C) 2005 Other Contributors -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; only version 2 of -* the License is valid for this program. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -* As a special exception, you have permission to link this program -* with the Oracle Client libraries and distribute executables, as long -* as you follow the requirements of the GNU GPL in regard to all of the -* software in the executable aside from Oracle client libraries. -* -* Specifically you are not permitted to link this program with the -* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech. -* And you are not permitted to distribute binaries compiled against -* these libraries without written consent from Quest Software, Inc. -* Observe that this does not disallow linking to the Qt Free Edition. -* -* You may link this product with any GPL'd Qt library such as Qt/Free -* -* All trademarks belong to their respective owners. -* -*****/ - -#ifndef TORESULTCONSTRAINT_H -#define TORESULTCONSTRAINT_H - -#include "config.h" -#include "tobackground.h" -#include "toresultview.h" - -class toNoBlockQuery; - -/** This widget displays information about the constraints of an object - * specified by the first and second parameter in the query. The sql is not - * used in the query. - */ - -class toResultConstraint : public toResultView -{ - Q_OBJECT - - /** The last table queried. - */ - QString LastTable; - /** Get columns for a constraints. - * @param conOwner Owner of constraint. - * @param conName Name of constraint. - * @return String with column names separated by a ',' character. - */ - QString constraintCols(const QString &conOwner, const QString &conName); - - QString Owner; - QString TableName; - - toNoBlockQuery *Query; - toBackground Poll; - void addConstraint(const QString &name, const QString &definition, const QString &status); -public: - /** Create the widget. - * @param parent Parent widget. - * @param name Name of widget. - */ - toResultConstraint(QWidget *parent, const char *name = NULL); - /** Destroy object - */ - ~toResultConstraint(); - /** Reimplemented for internal reasons. - */ - virtual void query(const QString &sql, const toQList ¶m); - /** Support Oracle - */ - virtual bool canHandle(toConnection &conn); -private slots: - void poll(void); -}; - -#endif Deleted: branches/tora-1.4/tora/src/toresultindexes.cpp =================================================================== --- branches/tora-1.4/tora/src/toresultindexes.cpp 2008-01-13 20:19:49 UTC (rev 2438) +++ branches/tora-1.4/tora/src/toresultindexes.cpp 2008-01-13 20:24:40 UTC (rev 2439) @@ -1,293 +0,0 @@ -/***** -* -* TOra - An Oracle Toolkit for DBA's and developers -* Copyright (C) 2003-2005 Quest Software, Inc -* Portions Copyright (C) 2005 Other Contributors -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; only version 2 of -* the License is valid for this program. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -* As a special exception, you have permission to link this program -* with the Oracle Client libraries and distribute executables, as long -* as you follow the requirements of the GNU GPL in regard to all of the -* software in the executable aside from Oracle client libraries. -* -* Specifically you are not permitted to link this program with the -* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech. -* And you are not permitted to distribute binaries compiled against -* these libraries without written consent from Quest Software, Inc. -* Observe that this does not disallow linking to the Qt Free Edition. -* -* You may link this product with any GPL'd Qt library such as Qt/Free -* -* All trademarks belong to their respective owners. -* -*****/ - -#include "utils.h" - -#include "toconf.h" -#include "toconnection.h" -#include "tonoblockquery.h" -#include "toresultindexes.h" -#include "tosql.h" -#include "totool.h" - - -bool toResultIndexes::canHandle(toConnection &conn) -{ - return toIsOracle(conn) || toIsMySQL(conn) || toIsPostgreSQL(conn) || toIsSapDB(conn); -} - -toResultIndexes::toResultIndexes(QWidget *parent, const char *name) - : toResultView(false, false, parent, name) -{ - setReadAll(true); - addColumn(tr("Index Name")); - addColumn(tr("Columns")); - addColumn(tr("Type")); - addColumn(tr("Unique")); - setSQLName(QString::fromLatin1("toResultIndexes")); - Query = NULL; - connect(&Poll, SIGNAL(timeout()), this, SLOT(poll())); -} - -toResultIndexes::~toResultIndexes() -{ - delete Query; -} - -static toSQL SQLColumnsPgSQL("toResultIndexes:Columns", - "SELECT a.attname, a.attname as x\n" - " FROM pg_class c, pg_attribute a, pg_user u\n" - " WHERE c.relowner=u.usesysid AND u.usename = :f1\n" - " AND a.attrelid = c.oid AND c.relname = :f2\n" - " AND a.attnum > 0\n" - " ORDER BY a.attnum", - "List columns an index is built on", - "7.1", - "PostgreSQL"); -static toSQL SQLColumns("toResultIndexes:Columns", - "SELECT b.Column_Expression,a.Column_Name\n" - " FROM sys.All_Ind_Columns a,\n" - " sys.All_Ind_Expressions b\n" - " WHERE a.Index_Owner = b.Index_Owner(+)\n" - " AND a.Index_Name = b.Index_Name(+)\n" - " AND a.Column_Position = b.Column_Position(+)\n" - " AND a.Index_Owner = :own<char[101]>\n" - " AND a.Index_Name = :nam<char[101]>\n" - " ORDER BY a.Column_Position", - "", - "0801"); -static toSQL SQLColumns8("toResultIndexes:Columns", - "SELECT Column_Name,NULL FROM sys.All_Ind_Columns\n" - " WHERE Index_Owner = :f1<char[101]> AND Index_Name = :f2<char[101]>\n" - " ORDER BY Column_Position", - "", - "0800"); - -static toSQL SQLColumnsSapDB("toResultIndexes:Columns", - "SELECT columnname,datatype\n" - " FROM indexcolumns\n" - " WHERE owner = :f1<char101> and indexname = :f2<char[101]>\n" - " ORDER BY columnno\n", - "", - "", - "SapDB"); - -QString toResultIndexes::indexCols(const QString &indOwner, const QString &indName) -{ - toQuery query(connection(), SQLColumns, indOwner, indName); - - QString ret; - while (!query.eof()) - { - if (!ret.isEmpty()) - ret.append(QString::fromLatin1(",")); - QString t = query.readValueNull(); - if (t.isEmpty()) - t = query.readValue(); - else - query.readValue(); - ret.append(t); - } - return ret; -} - -static toSQL SQLListIndexMySQL("toResultIndexes:ListIndex", - "SHOW INDEX FROM :f1<noquote>.:tab<noquote>", - "List the indexes available on a table", - "3.0", - "MySQL"); - -static toSQL SQLListIndex("toResultIndexes:ListIndex", - "SELECT Owner,\n" - " Index_Name,\n" - " Index_Type,\n" - " Uniqueness\n" - " FROM sys.All_Indexes\n" - " WHERE Table_Owner = :f1<char[101]>\n" - " AND Table_Name = :f2<char[101]>\n" - " ORDER BY Index_Name", - "", - "0800"); -static toSQL SQLListIndex7("toResultIndexes:ListIndex", - "SELECT Owner,\n" - " Index_Name,\n" - " 'NORMAL',\n" - " Uniqueness\n" - " FROM sys.All_Indexes\n" - " WHERE Table_Owner = :f1<char[101]>\n" - " AND Table_Name = :f2<char[101]>\n" - " ORDER BY Index_Name", - "", - "0703"); - -static toSQL SQLListIndexPgSQL("toResultIndexes:ListIndex", - "SELECT u.usename as Owner,\n" - " c2.relname as Index_Name,\n" - " CASE WHEN i.indisprimary = TRUE THEN 'PRIMARY'\n" - " ELSE 'NORMAL'\n" - " END AS Index_Type,\n" - " CASE WHEN i.indisunique = TRUE THEN 'UNIQUE'\n" - " ELSE 'NON UNIQUE'\n" - " END AS non_unique\n" - " FROM pg_class c, pg_class c2, pg_index i, pg_user u\n" - " WHERE c.relowner=u.usesysid and u.usename = :f1\n" - " AND c.relname = :f2\n" - " AND c.oid = i.indrelid\n" - " AND i.indexrelid = c2.oid\n" - " ORDER BY c2.relname", - "", - "7.1", - "PostgreSQL"); -static toSQL SQLListIndexSapDB("toResultIndexes:ListIndex", - "SELECT owner,\n" - " indexname \"Index_Name\",\n" - " 'NORMAL',\n" - " type\n" - " FROM indexes \n" - " WHERE owner = :f1<char[101]> and tablename = :f2<char[101]> \n" - " ORDER by indexname", - "", - "", - "SapDB"); - -void toResultIndexes::query(const QString &, const toQList ¶m) -{ - if (!handled()) - return ; - - if (Query) - delete Query; - Query = NULL; - - try - { - toConnection &conn = connection(); - if (toIsOracle(conn)) - Type = Oracle; - else if (toIsMySQL(conn)) - Type = MySQL; - else if (toIsPostgreSQL(conn)) - Type = PostgreSQL; - else if (toIsSapDB(conn)) - Type = SapDB; - else - return ; - - toQList::iterator cp = ((toQList &)param).begin(); - if (cp != ((toQList &)param).end()) - Owner = *cp; - cp++; - if (cp != ((toQList &)param).end()) - TableName = (*cp); - - RowNumber = 0; - - clear(); - - toQuery query(connection()); - toQList par; - par.insert(par.end(), Owner); - par.insert(par.end(), TableName); - Last = NULL; - - Query = new toNoBlockQuery(connection(), toQuery::Background, - toSQL::string(SQLListIndex, conn), par); - Poll.start(100); - } - TOCATCH -} - -void toResultIndexes::poll(void) -{ - try - { - if (!toCheckModal(this)) - return ; - if (Query && Query->poll()) - { - while (Query->poll() && !Query->eof()) - { - if (Type == Oracle || Type == PostgreSQL || Type == SapDB) - { - Last = new toResultViewItem(this, NULL); - - QString indexOwner(Query->readValue()); - QString indexName(Query->readValue()); - Last->setText(0, indexName); - Last->setText(1, indexCols(indexOwner, indexName)); - Last->setText(2, Query->readValue()); - Last->setText(3, Query->readValue()); - } - else if (Type == MySQL) - { - Query->readValue(); // Tablename - int unique = Query->readValue().toInt(); - QString name = Query->readValue(); - Query->readValue(); // SeqID - QString col = Query->readValue(); - - toQDescList &desc = Query->describe(); - for (unsigned int i = 5;i < desc.size();i++) - Query->readValue(); - if (Last && Last->text(0) == name) - Last->setText(1, Last->text(1) + QString::fromLatin1(",") + col); - else - { - Last = new toResultViewItem(this, NULL); - Last->setText(0, name); - Last->setText(1, col); - Last->setText(2, name == "PRIMARY" ? "PRIMARY" : "INDEX"); - Last->setText(3, unique ? "NONUNIQUE" : "UNIQUE"); - } - } - } - if (Query->eof()) - { - delete Query; - Query = NULL; - Poll.stop(); - } - } - } - catch (const QString &exc) - { - delete Query; - Query = NULL; - Poll.stop(); - toStatusMessage(exc); - } -} Deleted: branches/tora-1.4/tora/src/toresultindexes.h =================================================================== --- branches/tora-1.4/tora/src/toresultindexes.h 2008-01-13 20:19:49 UTC (rev 2438) +++ branches/tora-1.4/tora/src/toresultindexes.h 2008-01-13 20:24:40 UTC (rev 2439) @@ -1,96 +0,0 @@ -/***** -* -* TOra - An Oracle Toolkit for DBA's and developers -* Copyright (C) 2003-2005 Quest Software, Inc -* Portions Copyright (C) 2005 Other Contributors -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; only version 2 of -* the License is valid for this program. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -* As a special exception, you have permission to link this program -* with the Oracle Client libraries and distribute executables, as long -* as you follow the requirements of the GNU GPL in regard to all of the -* software in the executable aside from Oracle client libraries. -* -* Specifically you are not permitted to link this program with the -* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech. -* And you are not permitted to distribute binaries compiled against -* these libraries without written consent from Quest Software, Inc. -* Observe that this does not disallow linking to the Qt Free Edition. -* -* You may link this product with any GPL'd Qt library such as Qt/Free -* -* All trademarks belong to their respective owners. -* -*****/ - -#ifndef TORESULTINDEXES_H -#define TORESULTINDEXES_H - -#include "config.h" -#include "tobackground.h" -#include "toresultview.h" - -class toNoBlockQuery; - -/** This widget displays information about indexes of an object - * specified by the first and second parameter in the query. The sql is not - * used in the query. - */ - -class toResultIndexes : public toResultView -{ - Q_OBJECT - - /** Get columns of index. - * @param conOwner Owner of object. - * @param conName Name of index. - * @return Columns separated by ','. - */ - QString indexCols(const QString &conOwner, const QString &conName); - - QString Owner; - QString TableName; - - enum - { - Oracle, - MySQL, - PostgreSQL, - SapDB - } Type; - - toNoBlockQuery *Query; - toBackground Poll; - toTreeWidgetItem *Last; -public: - /** Create the widget. - * @param parent Parent widget. - * @param name Name of widget. - */ - toResultIndexes(QWidget *parent, const char *name = NULL); - /** Destroy object - */ - ~toResultIndexes(); - /** Reimplemented for internal reasons. - */ - virtual void query(const QString &sql, const toQList ¶m); - /** Support Oracle & MySQL - */ - virtual bool canHandle(toConnection &conn); -private slots: - void poll(void); -}; - -#endif Deleted: branches/tora-1.4/tora/src/toresultreferences.cpp =================================================================== --- branches/tora-1.4/tora/src/toresultreferences.cpp 2008-01-13 20:19:49 UTC (rev 2438) +++ branches/tora-1.4/tora/src/toresultreferences.cpp 2008-01-13 20:24:40 UTC (rev 2439) @@ -1,227 +0,0 @@ -/***** -* -* TOra - An Oracle Toolkit for DBA's and developers -* Copyright (C) 2003-2005 Quest Software, Inc -* Portions Copyright (C) 2005 Other Contributors -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; only version 2 of -* the License is valid for this program. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -* As a special exception, you have permission to link this program -* with the Oracle Client libraries and distribute executables, as long -* as you follow the requirements of the GNU GPL in regard to all of the -* software in the executable aside from Oracle client libraries. -* -* Specifically you are not permitted to link this program with the -* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech. -* And you are not permitted to distribute binaries compiled against -* these libraries without written consent from Quest Software, Inc. -* Observe that this does not disallow linking to the Qt Free Edition. -* -* You may link this product with any GPL'd Qt library such as Qt/Free -* -* All trademarks belong to their respective owners. -* -*****/ - -#include "utils.h" - -#include "toconf.h" -#include "toconnection.h" -#include "tonoblockquery.h" -#include "toresultreferences.h" -#include "tosql.h" -#include "totool.h" - - -toResultReferences::toResultReferences(QWidget *parent, const char *name) - : toResultView(false, false, parent, name) -{ - setReadAll(true); - addColumn(tr("Owner")); - addColumn(tr("Object")); - addColumn(tr("Constraint")); - addColumn(tr("Condition")); - addColumn(tr("Enabled")); - addColumn(tr("Delete Rule")); - setSQLName(QString::fromLatin1("toResultReferences")); - - Query = NULL; - connect(&Poll, SIGNAL(timeout()), this, SLOT(poll())); -} - -toResultReferences::~toResultReferences() -{ - delete Query; -} - -static toSQL SQLConsColumns("toResultReferences:ForeignColumns", - "SELECT Column_Name FROM sys.All_Cons_Columns\n" - " WHERE Owner = :f1<char[101]> AND Constraint_Name = :f2<char[101]>\n" - " ORDER BY Position", - "Get columns of foreign constraint, must return same number of cols"); - -QString toResultReferences::constraintCols(const QString &conOwner, const QString &conName) -{ - toQuery query(connection(), SQLConsColumns, conOwner, conName); - - QString ret; - while (!query.eof()) - { - QString value = query.readValue(); - if (!ret.isEmpty()) - ret.append(QString::fromLatin1(",")); - ret.append(value); - } - return ret; -} - -static toSQL SQLConstraints("toResultReferences:References", - "SELECT Owner,\n" - " Table_Name,\n" - " Constraint_Name,\n" - " R_Owner,\n" - " R_Constraint_Name,\n" - " Status,\n" - " Delete_Rule\n" - " FROM sys.all_constraints a\n" - " WHERE constraint_type = 'R'\n" - " AND (r_owner,r_constraint_name) IN (SELECT b.owner,b.constraint_name\n" - " FROM sys.all_constraints b\n" - " WHERE b.OWNER = :owner<char[101]>\n" - " AND b.TABLE_NAME = :tab<char[101]>)\n" - " ORDER BY Constraint_Name", - "List the references from foreign constraints to specified table, must return same columns"); -static toSQL SQLDependencies("toResultReferences:Dependencies", - "SELECT owner,name,type||' '||dependency_type\n" - " FROM sys.all_dependencies\n" - " WHERE referenced_owner = :owner<char[101]>\n" - " AND referenced_name = :tab<char[101]>\n" - " ORDER BY owner,type,name", - "List the dependencies from other objects to this object, must return same number of columns", - "0800"); -static toSQL SQLDependencies7("toResultReferences:Dependencies", - "SELECT owner,name,type\n" - " FROM sys.all_dependencies\n" - " WHERE referenced_owner = :owner<char[101]>\n" - " AND referenced_name = :tab<char[101]>\n" - " ORDER BY owner,type,name", - "", - "0703"); - -void toResultReferences::query(const QString &, const toQList ¶m) -{ - if (!handled()) - return ; - - toQList::iterator cp = ((toQList &)param).begin(); - if (cp != ((toQList &)param).end()) - Owner = *cp; - cp++; - if (cp != ((toQList &)param).end()) - TableName = (*cp); - - if (Query) - { - delete Query; - Query = NULL; - } - - clear(); - - try - { - toQList par; - par.insert(par.end(), Owner); - par.insert(par.end(), TableName); - Query = new toNoBlockQuery(connection(), toQuery::Background, - toSQL::string(SQLConstraints, connection()), par); - Dependencies = false; - LastItem = NULL; - Poll.start(100); - } - TOCATCH -} - -void toResultReferences::poll(void) -{ - try - { - if (!toCheckModal(this)) - return ; - if (Query && Query->poll()) - { - if (!Dependencies) - { - while (Query->poll() && !Query->eof()) - { - LastItem = new toResultViewItem(this, LastItem, QString::null); - - QString consOwner(Query->readValue()); - LastItem->setText(1, Query->readValue()); - QString consName(Query->readValue()); - QString colNames(constraintCols(Owner, consName)); - LastItem->setText(0, consOwner); - LastItem->setText(2, consName); - QString rConsOwner(Query->readValue()); - QString rConsName(Query->readValue()); - LastItem->setText(4, Query->readValue()); - QString Condition; - - Condition = tr("foreign key (%1) references %2.%3(%4)"). - arg(colNames).arg(rConsOwner).arg(TableName).arg(constraintCols(rConsOwner, rConsName)); - - LastItem->setText(3, Condition); - LastItem->setText(5, Query->readValue()); - } - if (Query->eof()) - { - delete Query; - Query = NULL; - toQList par; - par.insert(par.end(), Owner); - par.insert(par.end(), TableName); - Query = new toNoBlockQuery(connection(), toQuery::Background, - toSQL::string(SQLDependencies, connection()), - par); - Dependencies = true; - } - } - else - { - while (Query->poll() && !Query->eof()) - { - LastItem = new toTreeWidgetItem(this, LastItem, QString::null); - LastItem->setText(0, Query->readValue()); - LastItem->setText(1, Query->readValue()); - LastItem->setText(3, Query->readValue()); - LastItem->setText(4, tr("DEPENDENCY")); - } - if (Query->eof()) - { - delete Query; - Query = NULL; - Poll.stop(); - } - } - } - } - catch (const QString &exc) - { - delete Query; - Query = NULL; - Poll.stop(); - toStatusMessage(exc); - } -} Deleted: branches/tora-1.4/tora/src/toresultreferences.h =================================================================== --- branches/tora-1.4/tora/src/toresultreferences.h 2008-01-13 20:19:49 UTC (rev 2438) +++ branches/tora-1.4/tora/src/toresultreferences.h 2008-01-13 20:24:40 UTC (rev 2439) @@ -1,93 +0,0 @@ -/***** -* -* TOra - An Oracle Toolkit for DBA's and developers -* Copyright (C) 2003-2005 Quest Software, Inc -* Portions Copyright (C) 2005 Other Contributors -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; only version 2 of -* the License is valid for this program. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -* As a special exception, you have permission to link this program -* with the Oracle Client libraries and distribute executables, as long -* as you follow the requirements of the GNU GPL in regard to all of the -* software in the executable aside from Oracle client libraries. -* -* Specifically you are not permitted to link this program with the -* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech. -* And you are not permitted to distribute binaries compiled against -* these libraries without written consent from Quest Software, Inc. -* Observe that this does not disallow linking to the Qt Free Edition. -* -* You may link this product with any GPL'd Qt library such as Qt/Free -* -* All trademarks belong to their respective owners. -* -*****/ - -#ifndef TORESULTREFERENCES_H -#define TORESULTREFERENCES_H - -#include "config.h" -#include "tobackground.h" -#include "toresultview.h" -// due the toIsOracle -#include "utils.h" - -class toNoBlockQuery; - -/** This widget displays information about other tables that references this one. - * The table is specified by the first and second parameter in the query. The sql is not - * used in the query. - */ - -class toResultReferences : public toResultView -{ - Q_OBJECT - - QString Owner; - QString TableName; - bool Dependencies; - toBackground Poll; - toNoBlockQuery *Query; - toTreeWidgetItem *LastItem; - - /** Get columns for a constraints. - * @param conOwner Owner of constraint. - * @param conName Name of constraint. - * @return String with column names separated by a ',' character. - */ - QString constraintCols(const QString &conOwner, const QString &conName); -public: - /** Create the widget. - * @param parent Parent widget. - * @param name Name of widget. - */ - toResultReferences(QWidget *parent, const char *name = NULL); - /** Destruct object - */ - ~toResultReferences(); - /** Reimplemented for internal reasons. - */ - virtual void query(const QString &sql, const toQList ¶m); - /** Support Oracle - */ - virtual bool canHandle(toConnection &conn) - { - return toIsOracle(conn); - } -private slots: - void poll(void); -}; - -#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |