Le 27/03/2010 02:51, Guillaume Lelarge a écrit : > Le 27/03/2010 01:07, Erwin Brandstetter a écrit : >> On 26.03.2010 20:47, guilla...@lelarge.info wrote: >>> Le 26/03/2010 17:10, Erwin Brandstetter a écrit : >>> >>>> [...] >>>> Column statistcs are lost in the re-engineered SQL in the SQL pane in >>>> pgAdmin 1.10.2. >>>> I have just filed ticket #160 in trac describing the problem. >>>> >>>> >>> Not sure this really is a bug. We don't put in the SQL pane of the table >>> all changes about the columns. People can still get that part by >>> clicking on the column node. >>> >> >> My understanding up until now was, that the displayed SQL can be used to >> recreate an identical table. But maybe that's where I am going wrong? >> > > I tried a few things and it seems you're right. For example, comments on > columns are available both in the Column SQL pane and in the Table SQL pane. >
OK, I have a patch (attached) that seems to work. It adds some functions, and I'm not sure I should push this into the 1.10 branch. What do you guys think about this? only in trunk or in trunk and in the 1.10 branch? -- Guillaume. http://www.postgresqlfr.org http://dalibo.com
Index: pgadmin/include/schema/pgColumn.h =================================================================== --- pgadmin/include/schema/pgColumn.h (révision 8245) +++ pgadmin/include/schema/pgColumn.h (copie de travail) @@ -95,6 +95,8 @@ bool GetSystemObject() const { return colNumber < 0; } wxString GetSql(ctlTree *browser); wxString GetCommentSql(); + wxString GetStorageSql(); + wxString GetAttstattargetSql(); wxString GetPrivileges(); wxString GetHelpPage(bool forCreate) const { return wxT("pg/sql-altertable"); } Index: pgadmin/schema/pgTable.cpp =================================================================== --- pgadmin/schema/pgTable.cpp (révision 8245) +++ pgadmin/schema/pgTable.cpp (copie de travail) @@ -304,11 +304,18 @@ prevComment = column->GetComment(); // Whilst we are looping round the columns, grab their comments as well. - // Perhaps we should also get storage types here? colDetails += column->GetCommentSql(); if (colDetails.Length() > 0) if (colDetails.Last() != '\n') colDetails += wxT("\n"); + colDetails += column->GetStorageSql(); + if (colDetails.Length() > 0) + if (colDetails.Last() != '\n') + colDetails += wxT("\n"); + colDetails += column->GetAttstattargetSql(); + if (colDetails.Length() > 0) + if (colDetails.Last() != '\n') + colDetails += wxT("\n"); colCount++; columnPrivileges += column->GetPrivileges(); Index: pgadmin/schema/pgColumn.cpp =================================================================== --- pgadmin/schema/pgColumn.cpp (révision 8245) +++ pgadmin/schema/pgColumn.cpp (copie de travail) @@ -102,11 +102,10 @@ + wxT(" DROP COLUMN ") + GetQuotedIdentifier() + wxT(";") + wxT("\n\nALTER TABLE ") + GetQuotedFullTable() - + wxT(" ADD COLUMN ") + GetQuotedIdentifier() + wxT(" ") + GetQuotedTypename() + + wxT(" ADD COLUMN ") + GetQuotedIdentifier() + wxT(" ") + + GetQuotedTypename() + wxT(";\n"); - + wxT(";\nALTER TABLE ")+ GetQuotedFullTable() - + wxT(" ALTER COLUMN ") + GetQuotedIdentifier() - + wxT(" SET STORAGE ") + GetStorage() + wxT(";\n"); + sql += GetStorageSql(); if (GetNotNull()) sql += wxT("ALTER TABLE ") + GetQuotedFullTable() @@ -116,10 +115,7 @@ sql += wxT("ALTER TABLE ") + GetQuotedFullTable() + wxT(" ALTER COLUMN ") + GetQuotedIdentifier() + wxT(" SET DEFAULT ") + GetDefault() + wxT(";\n"); - if (GetAttstattarget() >= 0) - sql += wxT("ALTER TABLE ") + GetQuotedFullTable() - + wxT(" ALTER COLUMN ") + GetQuotedIdentifier() - + wxT(" SET STATISTICS ") + NumToStr(GetAttstattarget()) + wxT(";\n"); + sql += GetAttstattargetSql(); size_t i; for (i=0 ; i < variables.GetCount() ; i++) @@ -149,6 +145,30 @@ return commentSql; } +wxString pgColumn::GetStorageSql() +{ + wxString storageSql; + + if (!GetStorage().IsEmpty()) + storageSql = wxT("ALTER TABLE ")+ GetQuotedFullTable() + + wxT(" ALTER COLUMN ") + GetQuotedIdentifier() + + wxT(" SET STORAGE ") + GetStorage() + wxT(";\n"); + + return storageSql; +} + +wxString pgColumn::GetAttstattargetSql() +{ + wxString attstattargetSql; + + if (GetAttstattarget() >= 0) + attstattargetSql = wxT("ALTER TABLE ") + GetQuotedFullTable() + + wxT(" ALTER COLUMN ") + GetQuotedIdentifier() + + wxT(" SET STATISTICS ") + NumToStr(GetAttstattarget()) + wxT(";\n"); + + return attstattargetSql; +} + wxString pgColumn::GetPrivileges() { wxString privileges;
-- Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers