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

Commit

Permalink
Fix the saving and reverse engineering of parameters for database, ta…
Browse files Browse the repository at this point in the history
…ble, and function, according to a report from Erwin Brandstetter.

Fixes #169.


git-svn-id: svn://svn.pgadmin.org/branches/REL-1_10_0_PATCHES@8287 a7884b65-44f6-0310-8a51-81a127f17b15
  • Loading branch information
gleu committed Apr 20, 2010
1 parent 3d8b613 commit f73710b
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 24 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ Changes

Date Dev Ver Change details
---------- --- ------ --------------
2010-04-21 GL 1.10.3 Fix the saving and reverse engineering of parameters for
database, table, and function, according to a report
from Erwin Brandstetter.
2010-04-20 GL 1.10.3 Specify the schema of the table/function to restore if
pg_restore's release is 8.2 or later, per a report from
Kieran McCusker.
Expand Down
14 changes: 10 additions & 4 deletions pgadmin/dlg/dlgDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,10 +589,16 @@ wxString dlgDatabase::GetSql()
}
if (oldVal != newVal)
{
sql += wxT("ALTER DATABASE ") + qtIdent(name)
+ wxT(" SET ") + newVar
+ wxT("='") + newVal
+ wxT("';\n");
if (newVar != wxT("search_path") && newVar != wxT("temp_tablespaces"))
sql += wxT("ALTER DATABASE ") + qtIdent(name)
+ wxT(" SET ") + newVar
+ wxT("='") + newVal
+ wxT("';\n");
else
sql += wxT("ALTER DATABASE ") + qtIdent(name)
+ wxT(" SET ") + newVar
+ wxT("=") + newVal
+ wxT(";\n");
}
}

Expand Down
14 changes: 10 additions & 4 deletions pgadmin/dlg/dlgFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,10 +983,16 @@ wxString dlgFunction::GetSql()
// changed, which will remove them all :-(
if ((oldVal != newVal) || didChange)
{
sql += wxT("ALTER FUNCTION ") + name
+ wxT(" SET ") + newVar
+ wxT("='") + newVal
+ wxT("';\n");
if (newVar != wxT("search_path") && newVar != wxT("temp_tablespaces"))
sql += wxT("ALTER FUNCTION ") + name
+ wxT(" SET ") + newVar
+ wxT("='") + newVal
+ wxT("';\n");
else
sql += wxT("ALTER FUNCTION ") + name
+ wxT(" SET ") + newVar
+ wxT("=") + newVal
+ wxT(";\n");
}
}

Expand Down
14 changes: 10 additions & 4 deletions pgadmin/dlg/dlgRole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,10 +745,16 @@ wxString dlgRole::GetSql()
}
if (oldVal != newVal)
{
sql += wxT("ALTER ROLE ") + qtIdent(name)
+ wxT(" SET ") + newVar
+ wxT("='") + newVal
+ wxT("';\n");
if (newVar != wxT("search_path") && newVar != wxT("temp_tablespaces"))
sql += wxT("ALTER ROLE ") + qtIdent(name)
+ wxT(" SET ") + newVar
+ wxT("='") + newVal
+ wxT("';\n");
else
sql += wxT("ALTER ROLE ") + qtIdent(name)
+ wxT(" SET ") + newVar
+ wxT("=") + newVal
+ wxT(";\n");
}
}

Expand Down
14 changes: 10 additions & 4 deletions pgadmin/dlg/dlgUser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,10 +539,16 @@ wxString dlgUser::GetSql()
}
if (oldVal != newVal)
{
sql += wxT("ALTER USER ") + qtIdent(name)
+ wxT(" SET ") + newVar
+ wxT("='") + newVal
+ wxT("';\n");
if (newVar != wxT("search_path") && newVar != wxT("temp_tablespaces"))
sql += wxT("ALTER USER ") + qtIdent(name)
+ wxT(" SET ") + newVar
+ wxT("='") + newVal
+ wxT("';\n");
else
sql += wxT("ALTER USER ") + qtIdent(name)
+ wxT(" SET ") + newVar
+ wxT("=") + newVal
+ wxT(";\n");
}
}

Expand Down
11 changes: 9 additions & 2 deletions pgadmin/schema/pgDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,15 @@ wxString pgDatabase::GetSql(ctlTree *browser)

size_t i;
for (i=0 ; i < variables.GetCount() ; i++)
sql += wxT("ALTER DATABASE ") + GetQuotedFullIdentifier()
+ wxT(" SET ") + variables.Item(i).BeforeFirst('=') + wxT("='") + variables.Item(i).AfterFirst('=') + wxT("';\n");
{
if (variables.Item(i).BeforeFirst('=') != wxT("search_path") &&
variables.Item(i).BeforeFirst('=') != wxT("temp_tablespaces"))
sql += wxT("ALTER DATABASE ") + GetQuotedFullIdentifier()
+ wxT(" SET ") + variables.Item(i).BeforeFirst('=') + wxT("='") + variables.Item(i).AfterFirst('=') + wxT("';\n");
else
sql += wxT("ALTER DATABASE ") + GetQuotedFullIdentifier()
+ wxT(" SET ") + variables.Item(i).BeforeFirst('=') + wxT("=") + variables.Item(i).AfterFirst('=') + wxT(";\n");
}

if (myConn)
{
Expand Down
11 changes: 9 additions & 2 deletions pgadmin/schema/pgFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,15 @@ wxString pgFunction::GetSql(ctlTree *browser)

size_t i;
for (i=0 ; i < configList.GetCount() ; i++)
sql += wxT("\nALTER FUNCTION ") + qtSig
+ wxT(" SET ") + configList.Item(i).BeforeFirst('=') + wxT("='") + configList.Item(i).AfterFirst('=') + wxT("';\n");
{
if (configList.Item(i).BeforeFirst('=') != wxT("search_path") &&
configList.Item(i).BeforeFirst('=') != wxT("temp_tablespaces"))
sql += wxT("\nALTER FUNCTION ") + qtSig
+ wxT(" SET ") + configList.Item(i).BeforeFirst('=') + wxT("='") + configList.Item(i).AfterFirst('=') + wxT("';\n");
else
sql += wxT("\nALTER FUNCTION ") + qtSig
+ wxT(" SET ") + configList.Item(i).BeforeFirst('=') + wxT("=") + configList.Item(i).AfterFirst('=') + wxT(";\n");
}

sql += wxT("\n")
+ GetOwnerSql(8, 0, wxT("FUNCTION ") + qtSig)
Expand Down
9 changes: 7 additions & 2 deletions pgadmin/schema/pgRole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ wxString pgRole::GetSql(ctlTree *browser)
size_t index;
for (index=0 ; index < configList.GetCount() ; index++)
{
sql += wxT("ALTER ROLE ") + GetQuotedIdentifier()
+ wxT(" SET ") + configList.Item(index).BeforeFirst('=') + wxT("='") + configList.Item(index).AfterFirst('=') + wxT("';\n");
if (configList.Item(index).BeforeFirst('=') != wxT("search_path") &&
configList.Item(index).BeforeFirst('=') != wxT("temp_tablespaces"))
sql += wxT("ALTER ROLE ") + GetQuotedIdentifier()
+ wxT(" SET ") + configList.Item(index).BeforeFirst('=') + wxT("='") + configList.Item(index).AfterFirst('=') + wxT("';\n");
else
sql += wxT("ALTER ROLE ") + GetQuotedIdentifier()
+ wxT(" SET ") + configList.Item(index).BeforeFirst('=') + wxT("=") + configList.Item(index).AfterFirst('=') + wxT(";\n");
}
for (index=0 ; index < rolesIn.GetCount() ; index++)
{
Expand Down
9 changes: 7 additions & 2 deletions pgadmin/schema/pgUser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@ wxString pgUser::GetSql(ctlTree *browser)
size_t index;
for (index=0 ; index < configList.GetCount() ; index++)
{
sql += wxT("ALTER USER ") + GetQuotedIdentifier()
+ wxT(" SET ") + configList.Item(index).BeforeFirst('=') + wxT("='") + configList.Item(index).AfterFirst('=') + wxT("';\n");
if (configList.Item(index).BeforeFirst('=') != wxT("search_path") &&
configList.Item(index).BeforeFirst('=') != wxT("temp_tablespaces"))
sql += wxT("ALTER USER ") + GetQuotedIdentifier()
+ wxT(" SET ") + configList.Item(index).BeforeFirst('=') + wxT("='") + configList.Item(index).AfterFirst('=') + wxT("';\n");
else
sql += wxT("ALTER USER ") + GetQuotedIdentifier()
+ wxT(" SET ") + configList.Item(index).BeforeFirst('=') + wxT("=") + configList.Item(index).AfterFirst('=') + wxT(";\n");
}
for (index=0 ; index < groupsIn.GetCount() ; index++)
sql += wxT("ALTER GROUP ") + qtIdent(groupsIn.Item(index))
Expand Down

0 comments on commit f73710b

Please sign in to comment.