From: <tom...@us...> - 2010-01-20 10:40:39
|
Revision: 3392 http://tora.svn.sourceforge.net/tora/?rev=3392&view=rev Author: tomasstraupis Date: 2010-01-20 10:40:28 +0000 (Wed, 20 Jan 2010) Log Message: ----------- Fix statement used to "recompile" public synonyms in "Invalid Objects" tool. Modified Paths: -------------- trunk/tora/doc/help/invalid.html trunk/tora/doc/help/invalid.texi trunk/tora/src/toextract.cpp trunk/tora/src/toextract.h trunk/tora/src/toinvalid.cpp trunk/tora/src/tooracleextract.cpp trunk/tora/src/toresultextract.cpp Modified: trunk/tora/doc/help/invalid.html =================================================================== --- trunk/tora/doc/help/invalid.html 2010-01-18 13:49:35 UTC (rev 3391) +++ trunk/tora/doc/help/invalid.html 2010-01-20 10:40:28 UTC (rev 3392) @@ -41,7 +41,23 @@ <div class="block-image"><img src="images/invalid.png" alt="images/invalid.png"></div> - <p>To the left you see a list of invalid objects. Select an object and the left editor will be filled with code to recreate the code objects, you can then fix whatever problem may be with it. Rows with errors will have red background and you can see the error in the statusbar by putting the cursor on the row. You can also refresh the list or change the active connection by the buttons in the toolbar. + <p>To the left you see a list of invalid objects. Select an object and the editor on right hand side will be filled with code to recreate the object, you can then fix whatever problem may be with it. Rows with errors will have red background and you can see the error in the statusbar by putting the cursor on the row. You can also refresh the list or change the active connection by the buttons in the toolbar. + <dl> +<dt><strong>Recompile all invalid</strong><dd>This button will try recompiling all displayed invalid objects. Different types of objects are recompiled by callind different statements: +Index: +<pre class="verbatim"> alter index <schema.index_name> rebuild +</pre> +Package body: +<pre class="verbatim"> alter package <schema.package_name> compile body +</pre> +Public synonym: +<pre class="verbatim"> create or replace public synonym <synonym_name> for <synonym_target> +</pre> +All other objects are recompiled using: +<pre class="verbatim"> alter <object_type> <schema.object_name> compile +</pre> +</dl> + </body></html> Modified: trunk/tora/doc/help/invalid.texi =================================================================== --- trunk/tora/doc/help/invalid.texi 2010-01-18 13:49:35 UTC (rev 3391) +++ trunk/tora/doc/help/invalid.texi 2010-01-20 10:40:28 UTC (rev 3392) @@ -6,4 +6,25 @@ @image{images/invalid,15cm} -To the left you see a list of invalid objects. Select an object and the left editor will be filled with code to recreate the code objects, you can then fix whatever problem may be with it. Rows with errors will have red background and you can see the error in the statusbar by putting the cursor on the row. You can also refresh the list or change the active connection by the buttons in the toolbar. +To the left you see a list of invalid objects. Select an object and the editor on right hand side will be filled with code to recreate the object, you can then fix whatever problem may be with it. Rows with errors will have red background and you can see the error in the statusbar by putting the cursor on the row. You can also refresh the list or change the active connection by the buttons in the toolbar. + +@table @asis +@item @strong{Recompile all invalid} +This button will try recompiling all displayed invalid objects. Different types of objects are recompiled by callind different statements: +Index: +@verbatim +alter index <schema.index_name> rebuild +@end verbatim +Package body: +@verbatim +alter package <schema.package_name> compile body +@end verbatim +Public synonym: +@verbatim +create or replace public synonym <synonym_name> for <synonym_target> +@end verbatim +All other objects are recompiled using: +@verbatim +alter <object_type> <schema.object_name> compile +@end verbatim +@end table \ No newline at end of file Modified: trunk/tora/src/toextract.cpp =================================================================== --- trunk/tora/src/toextract.cpp 2010-01-18 13:49:35 UTC (rev 3391) +++ trunk/tora/src/toextract.cpp 2010-01-20 10:40:28 UTC (rev 3392) @@ -188,6 +188,7 @@ Contents = true; Comments = true; Partition = true; + Replace = false; Schema = "1"; Initialized = false; BlockSize = 8192; Modified: trunk/tora/src/toextract.h =================================================================== --- trunk/tora/src/toextract.h 2010-01-18 13:49:35 UTC (rev 3391) +++ trunk/tora/src/toextract.h 2010-01-20 10:40:28 UTC (rev 3392) @@ -264,6 +264,7 @@ bool Prompt; bool Storage; bool Initialized; + bool Replace; // if object creation extracts should support RE-creation of existing objects int CommitDistance; @@ -531,6 +532,13 @@ { Code = val; } + /** Support RE-creation of existing objects in "create" extracts. + * @param val Include code. + */ + void setReplace(bool val) + { + Replace = val; + } /** Set blocksize of database. * @param val New value of blocksize. */ @@ -619,6 +627,13 @@ { return Contents; } + /** Check if support RE-creation of existing objects in "create" extracts is enabled. + * @return If RE-creation is enabled. + */ + bool getReplace(void) + { + return Replace; + } /** Get the distance of the commits when content is generated. * @return Commit distance. */ Modified: trunk/tora/src/toinvalid.cpp =================================================================== --- trunk/tora/src/toinvalid.cpp 2010-01-18 13:49:35 UTC (rev 3391) +++ trunk/tora/src/toinvalid.cpp 2010-01-20 10:40:28 UTC (rev 3392) @@ -151,7 +151,7 @@ refresh(); setFocusProxy(Objects); } - +#include <QDebug> void toInvalid::recompileSelected(void) { QProgressDialog progress(tr("Recompiling all invalid"), @@ -177,14 +177,28 @@ break; QString type = Objects->model()->data((*it).row(), 3).toString(); + QString name = Objects->model()->data((*it).row(), 2).toString(); QString sql; if (type == "INDEX") - sql = "ALTER " + Objects->model()->data((*it).row(), 3).toString() + " " + + sql = "ALTER " + type + " " + conn.quote(Objects->model()->data((*it).row(), 1).toString()) + "." + - conn.quote(Objects->model()->data((*it).row(), 2).toString()) + " REBUILD"; + conn.quote(name) + " REBUILD"; else if (type == "PACKAGE BODY") sql = "ALTER PACKAGE " + conn.quote(Objects->model()->data((*it).row(), 1).toString()) + "." + conn.quote(Objects->model()->data((*it).row(), 2).toString()) + " COMPILE BODY"; + else if ((type == "SYNONYM") && (Objects->model()->data((*it).row(), 1).toString() == "PUBLIC")) + { + // only SYS user is allowed to do ALTER PUBLIC SYNONYM ... + // other users can only do CREATE OR REPLACE PUBLIC SYNONYM ... + std::list<QString> objects; + toExtract extract(conn, NULL); + extract.setCode(true); + extract.setHeading(false); + extract.setPrompt(false); + extract.setReplace(true); // get create OR REPLACE statement + objects.insert(objects.end(), type + QString::fromLatin1(":") + "PUBLIC" + QString::fromLatin1(".") + name); + sql = extract.create(objects); + } else sql = "ALTER " + Objects->model()->data((*it).row(), 3).toString() + " " + conn.quote(Objects->model()->data((*it).row(), 1).toString()) + "." + @@ -192,7 +206,16 @@ try { - conn.execute(sql); + // remove trailing newlines, spaces, tabs and semicolons from execution + // as this could cause "execution" of empty statement (doing nothing) + int l = sql.length() - 1; + while (l >= 0 && (sql.at(l) == ';' || sql.at(l).isSpace())) + l--; +#ifdef DEBUG + qDebug() << "statement=" << sql.mid(0, l + 1); +#endif + if (l >= 0) + conn.execute(sql.mid(0, l + 1)); } catch (...) {} Modified: trunk/tora/src/tooracleextract.cpp =================================================================== --- trunk/tora/src/tooracleextract.cpp 2010-01-18 13:49:35 UTC (rev 3391) +++ trunk/tora/src/tooracleextract.cpp 2010-01-20 10:40:28 UTC (rev 3392) @@ -4368,9 +4368,10 @@ QString useSchema = (schema == "PUBLIC") ? QString("") : schema; QString isPublic = (owner == "PUBLIC") ? " PUBLIC" : ""; QString tableSchema = ext.intSchema(tableOwner, false); + QString andReplace = (ext.getReplace()) ? " OR REPLACE" : ""; - QString sql = QString("CREATE%1 SYNONYM %2%3 FOR %4%5%6"). - arg(isPublic).arg(useSchema).arg(QUOTE(name)). + QString sql = QString("CREATE%1%2 SYNONYM %3%4 FOR %5%6%7"). + arg(andReplace).arg(isPublic).arg(useSchema).arg(QUOTE(name)). arg(tableSchema).arg(QUOTE(tableName)).arg(dbLink); QString ret; if (PROMPT) Modified: trunk/tora/src/toresultextract.cpp =================================================================== --- trunk/tora/src/toresultextract.cpp 2010-01-18 13:49:35 UTC (rev 3391) +++ trunk/tora/src/toresultextract.cpp 2010-01-20 10:40:28 UTC (rev 3392) @@ -142,6 +142,7 @@ extract.setCode(true); extract.setHeading(false); extract.setPrompt(Prompt); + extract.setReplace(true); // generate create OR REPLACE statements editor()->setText(extract.create(objects)); } TOCATCH This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |