~ubuntu-branches/ubuntu/utopic/pgadmin3/utopic-proposed

« back to all changes in this revision

Viewing changes to pgadmin/schema/pgTable.cpp

  • Committer: Package Import Robot
  • Author(s): Christoph Berg
  • Date: 2013-09-10 16:16:38 UTC
  • mfrom: (1.3.4)
  • Revision ID: package-import@ubuntu.com-20130910161638-wwup1q553ylww7dr
Tags: 1.18.0-1
* New upstream release.
* Don't install /usr/bin/png2c anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
//
3
3
// pgAdmin III - PostgreSQL Tools
4
4
//
5
 
// Copyright (C) 2002 - 2012, The pgAdmin Development Team
 
5
// Copyright (C) 2002 - 2013, The pgAdmin Development Team
6
6
// This software is released under the PostgreSQL Licence
7
7
//
8
8
// pgTable.cpp - Table class
34
34
pgTable::pgTable(pgSchema *newSchema, const wxString &newName)
35
35
        : pgSchemaObject(newSchema, tableFactory, newName)
36
36
{
37
 
        inheritedTableCount = 0;
38
 
        rowsCounted = false;
39
 
        showExtendedStatistics = false;
40
 
        distributionIsRandom = false;
 
37
        Init();
41
38
}
42
39
 
43
40
pgTable::pgTable(pgSchema *newSchema, pgaFactory &newFactory, const wxString &newName)
44
41
        : pgSchemaObject(newSchema, newFactory, newName)
45
42
{
46
 
        inheritedTableCount = 0;
47
 
        rowsCounted = false;
48
 
        showExtendedStatistics = false;
49
 
        distributionIsRandom = false;
 
43
        Init();
50
44
}
51
45
 
52
46
pgTable::~pgTable()
54
48
}
55
49
 
56
50
 
 
51
void pgTable::Init()
 
52
{
 
53
        rows = 0;
 
54
        estimatedRows = 0.0;
 
55
 
 
56
        hasToastTable = false;
 
57
        autovacuum_enabled = 0;
 
58
        toast_autovacuum_enabled = 0;
 
59
 
 
60
        isPartitioned = false;
 
61
        hasOids = false;
 
62
        unlogged = false;
 
63
        hasSubclass = false;
 
64
        rowsCounted = false;
 
65
        isReplicated = false;
 
66
        showExtendedStatistics = false;
 
67
        distributionIsRandom = false;
 
68
 
 
69
        inheritedTableCount = 0;
 
70
        triggerCount = 0;
 
71
 
 
72
        tablespaceOid = 0;
 
73
        ofTypeOid = 0;
 
74
}
 
75
 
 
76
 
57
77
wxString pgTable::GetTranslatedMessage(int kindOfMessage) const
58
78
{
59
79
        wxString message = wxEmptyString;
121
141
                case DEPENDENTS:
122
142
                        message = _("Table dependents");
123
143
                        break;
 
144
                case BACKUPTITLE:
 
145
                        message = wxString::Format(_("Backup table \"%s\""),
 
146
                                                   GetFullIdentifier().c_str());
 
147
                        break;
 
148
                case RESTORETITLE:
 
149
                        message = wxString::Format(_("Restore table \"%s\""),
 
150
                                                   GetFullIdentifier().c_str());
 
151
                        break;
124
152
        }
125
153
 
126
154
        return message;
1451
1479
                                 wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age \n")
1452
1480
                                 wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age \n")
1453
1481
                                 wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age \n")
1454
 
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') AS toast_autovacuum_enabled \n")
1455
 
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold \n")
1456
 
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.][0-9]*)') AS toast_autovacuum_vacuum_scale_factor \n")
1457
 
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold \n")
1458
 
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.][0-9]*)') AS toast_autovacuum_analyze_scale_factor \n")
1459
 
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS toast_autovacuum_vacuum_cost_delay \n")
1460
 
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS toast_autovacuum_vacuum_cost_limit \n")
1461
 
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS toast_autovacuum_freeze_min_age \n")
1462
 
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS toast_autovacuum_freeze_max_age \n")
1463
 
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age \n")
 
1482
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') AS toast_autovacuum_enabled \n")
 
1483
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold \n")
 
1484
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.][0-9]*)') AS toast_autovacuum_vacuum_scale_factor \n")
 
1485
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold \n")
 
1486
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.][0-9]*)') AS toast_autovacuum_analyze_scale_factor \n")
 
1487
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS toast_autovacuum_vacuum_cost_delay \n")
 
1488
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS toast_autovacuum_vacuum_cost_limit \n")
 
1489
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS toast_autovacuum_freeze_min_age \n")
 
1490
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS toast_autovacuum_freeze_max_age \n")
 
1491
                                 wxT(", substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age \n")
1464
1492
                                 wxT(", rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions \n")
1465
1493
                                 wxT(", (CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable\n");
1466
1494
                }
1474
1502
 
1475
1503
                query += wxT("  FROM pg_class rel\n")
1476
1504
                         wxT("  LEFT OUTER JOIN pg_tablespace spc on spc.oid=rel.reltablespace\n")
1477
 
                         wxT("  LEFT OUTER JOIN pg_description des ON (des.objoid=rel.oid AND des.objsubid=0)\n")
 
1505
                         wxT("  LEFT OUTER JOIN pg_description des ON (des.objoid=rel.oid AND des.objsubid=0 AND des.classoid='pg_class'::regclass)\n")
1478
1506
                         wxT("  LEFT OUTER JOIN pg_constraint con ON con.conrelid=rel.oid AND con.contype='p'\n");
1479
1507
 
1480
1508
                // Add the toast table for vacuum parameters.
1508
1536
                        wxT("                       JOIN pg_proc pc ON pc.pronamespace=pt.pronamespace AND pc.proname='slonyversion'\n")
1509
1537
                        wxT("                     WHERE tgrelid=rel.oid) AS isrepl\n")
1510
1538
                        wxT("  FROM pg_class rel\n")
1511
 
                        wxT("  LEFT OUTER JOIN pg_description des ON (des.objoid=rel.oid AND des.objsubid=0)\n")
 
1539
                        wxT("  LEFT OUTER JOIN pg_description des ON (des.objoid=rel.oid AND des.objsubid=0 AND des.classoid='pg_class'::regclass)\n")
1512
1540
                        wxT("  LEFT OUTER JOIN pg_constraint con ON con.conrelid=rel.oid AND con.contype='p'\n")
1513
1541
                        wxT(" WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = ") + collection->GetSchema()->GetOidStr() + wxT("\n")
1514
1542
                        + restriction +
1822
1850
 
1823
1851
wxWindow *truncateFactory::StartDialog(frmMain *form, pgObject *obj)
1824
1852
{
1825
 
        if (wxMessageBox(_("Are you sure you wish to truncate this table?\n\nWARNING: This action will delete ALL data in the table!"), _("Truncate table"), wxYES_NO) != wxYES)
 
1853
        if (wxMessageBox(_("Are you sure you wish to truncate this table?\n\nWARNING: This action will delete ALL data in the table!"), _("Truncate table"), wxYES_NO | wxICON_QUESTION | wxNO_DEFAULT) != wxYES)
1826
1854
                return 0;
1827
1855
 
1828
1856
        ((pgTable *)obj)->Truncate(false);
1849
1877
 
1850
1878
wxWindow *truncateCascadedFactory::StartDialog(frmMain *form, pgObject *obj)
1851
1879
{
1852
 
        if (wxMessageBox(_("Are you sure you wish to truncate this table and all tables that have foreign key references to this table?\n\nWARNING: This action will delete ALL data in the tables!"), _("Truncate table cascaded"), wxYES_NO) != wxYES)
 
1880
        if (wxMessageBox(_("Are you sure you wish to truncate this table and all tables that have foreign key references to this table?\n\nWARNING: This action will delete ALL data in the tables!"), _("Truncate table cascaded"), wxYES_NO | wxICON_QUESTION | wxNO_DEFAULT) != wxYES)
1853
1881
                return 0;
1854
1882
 
1855
1883
        ((pgTable *)obj)->Truncate(true);