mirror of
https://github.com/levinsv/pgadmin3.git
synced 2026-05-15 14:15:49 -06:00
Add table properties "Create table timestamp"
Для серверов с установленным track_commit_timestamp=on у таблиц можно определить время создания. Это время равно значению запроса: "select pg_xact_commit_timestamp(xmin) create_ts from pg_type where typrelid=$oid_table". Если это время определить не удалось то "Create table timestamp" не отображается.
This commit is contained in:
parent
282cf08716
commit
38b4b4a5ed
5 changed files with 35 additions and 5 deletions
|
|
@ -556,7 +556,8 @@ bool pgConn::HasFeature(int featureNo, bool forceCheck)
|
|||
wxT( " 'pg_postmaster_starttime', 'pg_terminate_backend', 'pg_reload_conf',")
|
||||
wxT( " 'pgstattuple', 'pgstatindex','bt_index_parent_check')\n")
|
||||
wxT(" AND nspname IN ('pg_catalog', 'public','profile')")
|
||||
wxT(" union all select current_setting('log_destination'),555,null,null,null");
|
||||
wxT(" union all select current_setting('log_destination'),555,null,null,null")
|
||||
wxT(" union all select setting,666,null,null,null from pg_settings s where s.name='track_commit_timestamp'");
|
||||
|
||||
pgSet *set = ExecuteSet(sql);
|
||||
|
||||
|
|
@ -591,6 +592,9 @@ bool pgConn::HasFeature(int featureNo, bool forceCheck)
|
|||
features[FEATURE_PGCHECKINDEX] = true;
|
||||
else if (proname == wxT("csvlog") && pronargs == 555)
|
||||
features[FEATURE_CSVLOG] = true;
|
||||
else if (proname == "on" && pronargs == 666)
|
||||
features[FEATURE_TRACK_COMMIT_TS] = true;
|
||||
|
||||
set->MoveNext();
|
||||
}
|
||||
delete set;
|
||||
|
|
|
|||
|
|
@ -142,6 +142,15 @@ public:
|
|||
{
|
||||
tablespace = newVal;
|
||||
}
|
||||
wxString GetCreateTableTS() const
|
||||
{
|
||||
return create_table_TS;
|
||||
};
|
||||
void iSetCreateTableTS(const wxString& newVal)
|
||||
{
|
||||
create_table_TS = newVal;
|
||||
}
|
||||
|
||||
wxString GetRatio() const
|
||||
{
|
||||
return ratio;
|
||||
|
|
@ -613,7 +622,7 @@ private:
|
|||
|
||||
long inheritedTableCount, triggerCount;
|
||||
wxString quotedInheritedTables, inheritedTables, primaryKey, quotedPrimaryKey,
|
||||
primaryKeyName, primaryKeyColNumbers, tablespace, ratio,
|
||||
primaryKeyName, primaryKeyColNumbers, tablespace, ratio, create_table_TS,
|
||||
distributionColNumbers, ofType;
|
||||
wxArrayString quotedInheritedTablesList, inheritedTablesOidList;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ enum
|
|||
FEATURE_FUNCTION_DEFAULTS,
|
||||
FEATURE_CSVLOG,
|
||||
FEATURE_PGPRO_PWR,
|
||||
FEATURE_TRACK_COMMIT_TS,
|
||||
FEATURE_LAST
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -231,6 +231,8 @@ pgObject *pgPartitionFactory::CreateObjects(pgCollection *coll, ctlTree *browser
|
|||
query += wxT(", rel.relpersistence \n");
|
||||
if (collection->GetDatabase()->connection()->GetIsPgProEnt()) query += wxT(",left((cfs_fragmentation(rel.oid)*100)::text,5)::text AS cfs_ratio\n");
|
||||
else query += wxT(",null::text AS cfs_ratio\n");
|
||||
if (collection->GetConnection()->HasFeature(FEATURE_TRACK_COMMIT_TS))
|
||||
query += wxT(", pg_xact_commit_timestamp(typ2.xmin) create_ts\n");
|
||||
|
||||
query += wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor \n");
|
||||
query += wxT(", substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') AS autovacuum_enabled \n")
|
||||
|
|
@ -282,6 +284,8 @@ pgObject *pgPartitionFactory::CreateObjects(pgCollection *coll, ctlTree *browser
|
|||
wxT(" LEFT OUTER JOIN pg_constraint con ON con.conrelid=rel.oid AND con.contype='p'\n");
|
||||
query += wxT(" LEFT OUTER JOIN pg_class tst ON tst.oid = rel.reltoastrelid\n");
|
||||
query += wxT("LEFT JOIN pg_type typ ON rel.reloftype=typ.oid\n");
|
||||
if (collection->GetConnection()->HasFeature(FEATURE_TRACK_COMMIT_TS))
|
||||
query += wxT("LEFT JOIN pg_type typ2 ON rel.oid=typ2.typrelid\n");
|
||||
|
||||
query += wxT(" WHERE rel.relkind IN ('r','s','t','p')\n");
|
||||
// show partitions in other schema
|
||||
|
|
@ -330,7 +334,10 @@ pgObject *pgPartitionFactory::CreateObjects(pgCollection *coll, ctlTree *browser
|
|||
table->iSetOwner(tables->GetVal(wxT("relowner")));
|
||||
table->iSetAcl(tables->GetVal(wxT("relacl")));
|
||||
table->iSetRatio(tables->GetVal(wxT("cfs_ratio")));
|
||||
if (tables->GetOid(wxT("spcoid")) == 0)
|
||||
if (collection->GetConnection()->HasFeature(FEATURE_TRACK_COMMIT_TS)) {
|
||||
table->iSetCreateTableTS(tables->GetVal(wxT("create_ts")));
|
||||
}
|
||||
if (tables->GetOid(wxT("spcoid")) == 0)
|
||||
table->iSetTablespaceOid(collection->GetDatabase()->GetTablespaceOid());
|
||||
else
|
||||
table->iSetTablespaceOid(tables->GetOid(wxT("spcoid")));
|
||||
|
|
|
|||
|
|
@ -1086,9 +1086,11 @@ void pgTable::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *prope
|
|||
properties->AppendYesNoItem(_("Has OIDs?"), GetHasOids());
|
||||
if (!GetConnection()->BackendMinimumVersion(12, 0))
|
||||
properties->AppendYesNoItem(_("System table?"), GetSystemObject());
|
||||
if (GetConnection()->GetIsPgProEnt())
|
||||
if (GetConnection()->GetIsPgProEnt() && GetRatio().Len()>0)
|
||||
properties->AppendItem(_("CFS fragmentation"), GetRatio());
|
||||
|
||||
if (GetConnection()->HasFeature(FEATURE_TRACK_COMMIT_TS) && GetCreateTableTS().Len()>0)
|
||||
properties->AppendItem(_("Create table timestamp"), GetCreateTableTS());
|
||||
|
||||
/* Custom AutoVacuum Settings */
|
||||
if (GetConnection()->BackendMinimumVersion(8, 4) && GetCustomAutoVacuumEnabled())
|
||||
{
|
||||
|
|
@ -1563,6 +1565,8 @@ pgObject *pgTableFactory::CreateObjects(pgCollection *collection, ctlTree *brows
|
|||
}
|
||||
if (collection->GetConnection()->BackendMinimumVersion(9, 0))
|
||||
query += wxT(", rel.reloftype, typ.typname\n");
|
||||
if (collection->GetConnection()->HasFeature(FEATURE_TRACK_COMMIT_TS))
|
||||
query += wxT(", pg_xact_commit_timestamp(typ2.xmin) create_ts\n");
|
||||
if (collection->GetDatabase()->BackendMinimumVersion(9, 1))
|
||||
{
|
||||
query += wxT(",\n(SELECT array_agg(label) FROM pg_seclabels sl1 WHERE sl1.objoid=rel.oid AND sl1.objsubid=0) AS labels");
|
||||
|
|
@ -1610,6 +1614,8 @@ pgObject *pgTableFactory::CreateObjects(pgCollection *collection, ctlTree *brows
|
|||
|
||||
if (collection->GetConnection()->BackendMinimumVersion(9, 0))
|
||||
query += wxT("LEFT JOIN pg_type typ ON rel.reloftype=typ.oid\n");
|
||||
if (collection->GetConnection()->HasFeature(FEATURE_TRACK_COMMIT_TS))
|
||||
query += wxT("LEFT JOIN pg_type typ2 ON rel.oid=typ2.typrelid\n");
|
||||
|
||||
query += wxT(" WHERE ")+pg10+wxT(" rel.relkind IN ('r','s','t','p') AND rel.relnamespace = ") + collection->GetSchema()->GetOidStr() + wxT("\n");
|
||||
|
||||
|
|
@ -1654,6 +1660,9 @@ pgObject *pgTableFactory::CreateObjects(pgCollection *collection, ctlTree *brows
|
|||
table->iSetOwner(tables->GetVal(wxT("relowner")));
|
||||
table->iSetAcl(tables->GetVal(wxT("relacl")));
|
||||
table->iSetRatio(tables->GetVal(wxT("cfs_ratio")));
|
||||
if (collection->GetConnection()->HasFeature(FEATURE_TRACK_COMMIT_TS)) {
|
||||
table->iSetCreateTableTS(tables->GetVal(wxT("create_ts")));
|
||||
}
|
||||
if (collection->GetConnection()->BackendMinimumVersion(8, 0))
|
||||
{
|
||||
if (tables->GetOid(wxT("spcoid")) == 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue