Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Commit

Permalink
Fix dropping/renaming of indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay-joshi authored and dpage committed Nov 8, 2012
1 parent 7e13753 commit 027aec1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -37,6 +37,7 @@ Changes

Date Dev Ver Change details
---------- --- ------ --------------
2012-11-08 DP 1.16.1 Fix dropping/renaming of indexes [Akshay Joshi]
2012-11-08 DP 1.16.1 Avoid updating the GQB model on every key press in
the query tool [Dhiraj Chawla]
2012-11-02 DP 1.16.1 Fix a crash that can occur when renaming objects.
Expand Down
6 changes: 3 additions & 3 deletions pgadmin/dlg/dlgIndex.cpp
Expand Up @@ -601,20 +601,20 @@ wxString dlgIndex::GetSql()
else
{
if (connection->BackendMinimumVersion(8, 2) && txtFillFactor->GetValue().Length() > 0)
sql += wxT("ALTER INDEX ") + qtIdent(index->GetSchema()->GetSchema()->GetName()) + wxT(".")
sql += wxT("ALTER INDEX ") + qtIdent(index->GetSchema()->GetName()) + wxT(".")
+ qtIdent(index->GetName()) + wxT("\n SET (FILLFACTOR=")
+ txtFillFactor->GetValue() + wxT(");\n");

if(connection->BackendMinimumVersion(8, 0))
{
if (index->GetName() != txtName->GetValue() &&
!txtName->GetValue().IsEmpty())
sql += wxT("ALTER INDEX ") + qtIdent(index->GetSchema()->GetSchema()->GetName()) + wxT(".")
sql += wxT("ALTER INDEX ") + qtIdent(index->GetSchema()->GetName()) + wxT(".")
+ qtIdent(index->GetName()) + wxT("\n RENAME TO ")
+ qtIdent(txtName->GetValue()) + wxT(";\n");

if (cbTablespace->GetOIDKey() != index->GetTablespaceOid())
sql += wxT("ALTER INDEX ") + qtIdent(index->GetSchema()->GetSchema()->GetName()) + wxT(".") + qtIdent(name)
sql += wxT("ALTER INDEX ") + qtIdent(index->GetSchema()->GetName()) + wxT(".") + qtIdent(name)
+ wxT("\n SET TABLESPACE ") + qtIdent(cbTablespace->GetValue())
+ wxT(";\n");
}
Expand Down
4 changes: 2 additions & 2 deletions pgadmin/dlg/dlgIndexConstraint.cpp
Expand Up @@ -569,14 +569,14 @@ wxString dlgIndexConstraint::GetSql()
}
if (connection->BackendMinimumVersion(8, 0) && cbTablespace->GetOIDKey() != index->GetTablespaceOid())
{
sql += wxT("ALTER INDEX ") + index->GetSchema()->GetSchema()->GetQuotedIdentifier() + wxT(".") + qtIdent(name)
sql += wxT("ALTER INDEX ") + index->GetSchema()->GetQuotedIdentifier() + wxT(".") + qtIdent(name)
+ wxT("\n SET TABLESPACE ") + qtIdent(cbTablespace->GetValue())
+ wxT(";\n");
}

if (txtFillFactor->GetValue().Trim().Length() > 0 && txtFillFactor->GetValue() != index->GetFillFactor())
{
sql += wxT("ALTER INDEX ") + index->GetSchema()->GetSchema()->GetQuotedIdentifier() + wxT(".") + qtIdent(name)
sql += wxT("ALTER INDEX ") + index->GetSchema()->GetQuotedIdentifier() + wxT(".") + qtIdent(name)
+ wxT("\n SET (FILLFACTOR=")
+ txtFillFactor->GetValue() + wxT(");\n");
}
Expand Down
2 changes: 1 addition & 1 deletion pgadmin/schema/pgIndex.cpp
Expand Up @@ -102,7 +102,7 @@ wxString pgIndexBase::GetTranslatedMessage(int kindOfMessage) const

bool pgIndexBase::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
{
wxString sql = wxT("DROP INDEX ") + this->GetSchema()->GetSchema()->GetQuotedIdentifier() + wxT(".") + this->GetQuotedIdentifier();
wxString sql = wxT("DROP INDEX ") + this->GetSchema()->GetQuotedIdentifier() + wxT(".") + this->GetQuotedIdentifier();
if (cascaded)
sql += wxT(" CASCADE");
return GetDatabase()->ExecuteVoid(sql);
Expand Down

0 comments on commit 027aec1

Please sign in to comment.