Log Message:
-----------
Set column stats and comments correctly when creating tables.

Modified Files:
--------------
    pgadmin3:
        CHANGELOG.txt (r1.194 -> r1.195)
    pgadmin3/src/include:
        dlgColumn.h (r1.11 -> r1.12)
    pgadmin3/src/ui:
        dlgTable.cpp (r1.50 -> r1.51)

Index: CHANGELOG.txt
===================================================================
RCS file: /projects/pgadmin3/CHANGELOG.txt,v
retrieving revision 1.194
retrieving revision 1.195
diff -LCHANGELOG.txt -LCHANGELOG.txt -u -w -r1.194 -r1.195
--- CHANGELOG.txt
+++ CHANGELOG.txt
@@ -17,6 +17,7 @@
 </ul>
 <br>
 <ul>
+    <li>2005-03-18 DP  1.2.1 Set column stats and comments correctly when 
creating tables.
     <li>2005-03-18 DP  1.2.1 Include the hostname in the connect string for 
Kerberos support, per Magnus Hagander
     <li>2005-03-15 DP        Fix for non-SSL enabled libpq builds [Florian G. 
Pflug]
     <li>2005-03-15 HS        Mask the password on the main tab of the user 
properties dialogue
Index: dlgColumn.h
===================================================================
RCS file: /projects/pgadmin3/src/include/dlgColumn.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -Lsrc/include/dlgColumn.h -Lsrc/include/dlgColumn.h -u -w -r1.11 -r1.12
--- src/include/dlgColumn.h
+++ src/include/dlgColumn.h
@@ -29,6 +29,8 @@
     pgObject *GetObject();
     wxString GetDefinition();
     wxString GetPreviousDefinition() { return previousDefinition; }
+       wxString GetComment() { return txtComment->GetValue(); }
+       wxString GetStatistics() {      return 
CTRL_TEXT("txtAttstattarget")->GetValue(); }
 
     int Go(bool modal);
 
Index: dlgTable.cpp
===================================================================
RCS file: /projects/pgadmin3/src/ui/dlgTable.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -Lsrc/ui/dlgTable.cpp -Lsrc/ui/dlgTable.cpp -u -w -r1.50 -r1.51
--- src/ui/dlgTable.cpp
+++ src/ui/dlgTable.cpp
@@ -86,6 +86,8 @@
     lstColumns->CreateColumns(frame, _("Column name"), _("Definition"), 90);
     lstColumns->AddColumn(wxT("Inherited from table"), 0);
     lstColumns->AddColumn(wxT("Column definition"), 0);
+       lstColumns->AddColumn(wxT("Column comment"), 0);
+       lstColumns->AddColumn(wxT("Column statistics"), 0);
     lstColumns->AddColumn(wxT("Column"), 0);
 
     lstConstraints->CreateColumns(frame, _("Constraint name"), 
_("Definition"), 90);
@@ -169,7 +171,7 @@
                             column->GetName(), column->GetDefinition());
                         previousColumns.Add(column->GetQuotedIdentifier() 
                             + wxT(" ") + column->GetDefinition());
-                        lstColumns->SetItem(pos, 4, NumToStr((long)column));
+                        lstColumns->SetItem(pos, 6, NumToStr((long)column));
                         if (inherited)
                             lstColumns->SetItem(pos, 2, _("Inherited"));
                     }
@@ -326,7 +328,7 @@
             {
                 sql += definition;
 
-                pgColumn *column=(pgColumn*) 
StrToLong(lstColumns->GetText(pos, 4));
+                pgColumn *column=(pgColumn*) 
StrToLong(lstColumns->GetText(pos, 6));
                 if (column)
                 {
                     index=tmpDef.Index(column->GetQuotedIdentifier() 
@@ -462,6 +464,31 @@
 
         AppendOwnerNew(sql, wxT("TABLE ") + tabname);
     }
+
+       // Extra column info
+       int pos;
+
+       // Statistics
+    for (pos=0 ; pos < lstColumns->GetItemCount() ; pos++)
+    {
+        if (!lstColumns->GetText(pos, 4).IsEmpty())
+                       sql += wxT("ALTER TABLE ") + tabname
+                               + wxT(" ALTER COLUMN ") + 
qtIdent(lstColumns->GetText(pos, 0))
+                               + wxT(" SET STATISTICS ") + 
lstColumns->GetText(pos, 4)
+                               + wxT(";\n");
+       }
+
+       // Comments
+    for (pos=0 ; pos < lstColumns->GetItemCount() ; pos++)
+    {
+        if (!lstColumns->GetText(pos, 5).IsEmpty())
+                       sql += wxT("COMMENT ON COLUMN ") + tabname
+                               + wxT(".") + qtIdent(lstColumns->GetText(pos, 
0))
+                               + wxT(" IS ") + 
qtString(lstColumns->GetText(pos, 5))
+                               + wxT(";\n");
+       }
+
+
     AppendComment(sql, wxT("TABLE"), schema, table);
     sql +=  GetGrant(wxT("arwdRxt"), wxT("TABLE ") + tabname);
 
@@ -599,7 +626,7 @@
 void dlgTable::OnChangeCol(wxCommandEvent &ev)
 {
     long pos=lstColumns->GetSelection();
-    pgColumn *column=(pgColumn*) StrToLong(lstColumns->GetText(pos, 4));
+    pgColumn *column=(pgColumn*) StrToLong(lstColumns->GetText(pos, 6));
 
     dlgColumn col(mainForm, column, table);
     col.CenterOnParent();
@@ -609,6 +636,8 @@
         lstColumns->SetItem(pos, 0, col.GetName());
         lstColumns->SetItem(pos, 1, col.GetDefinition());
         lstColumns->SetItem(pos, 3, col.GetSql());
+               lstColumns->SetItem(pos, 4, col.GetStatistics());
+               lstColumns->SetItem(pos, 5, col.GetComment());
     }
     CheckChange();
 }
@@ -624,6 +653,9 @@
         long pos = lstColumns->AppendItem(PGICON_COLUMN, col.GetName(), 
col.GetDefinition());
         if (table && !connection->BackendMinimumVersion(8, 0))
             lstColumns->SetItem(pos, 3, col.GetSql());
+               lstColumns->SetItem(pos, 4, col.GetStatistics());
+               lstColumns->SetItem(pos, 5, col.GetComment());
+
     }
 
     CheckChange();
@@ -646,7 +678,7 @@
     wxString inheritedFromTable=lstColumns->GetText(pos, 2);
     
     btnRemoveCol->Enable(inheritedFromTable.IsEmpty());
-    btnChangeCol->Enable(table != 0 && !lstColumns->GetText(pos, 4).IsEmpty());
+    btnChangeCol->Enable(table != 0 && !lstColumns->GetText(pos, 6).IsEmpty());
 }
 
 
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply via email to