diff --git a/README.md b/README.md index 447826a..276cff8 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,10 @@ This text Russian language. Особенности: SQL текст создания последовательностей игнорируется, секции таблиц не учитываются. Полность одинаковые объекты скрываются. Служебные объекты игнорируются. - выполнен переход на новые библиотеки dll wxWidgets 3.0.4 скомпилированные под VS2012. Необходимо обновить файлы *.dll +04.03.2020 + - добавлен вывод CREATE STATISTICS для таблиц + * исправлен вывод SQL команды для создания задания для комманд заданных в виде массива + diff --git a/Release_(3.0)/pgAdmin3.exe b/Release_(3.0)/pgAdmin3.exe index 4f6e58a..e066a6e 100644 Binary files a/Release_(3.0)/pgAdmin3.exe and b/Release_(3.0)/pgAdmin3.exe differ diff --git a/include/schema/pgTable.h b/include/schema/pgTable.h index e3e205f..03a9598 100644 --- a/include/schema/pgTable.h +++ b/include/schema/pgTable.h @@ -336,6 +336,15 @@ public: { partexp = s; } + void iSetStatExt(const wxString &s) + { + statext = s; + } + wxString GetStatExt() + { + return statext; + } + bool GetIsPartitioned() const { return isPartitioned || partitionDef.Length() > 0; @@ -584,6 +593,7 @@ private: wxString partkeydef; // partition feature 10 version wxString partexp; // partition feature 10 version wxString partitionDef; + wxString statext; bool isPartitioned; bool hasOids, unlogged, hasSubclass, rowsCounted, isReplicated, showExtendedStatistics, distributionIsRandom; diff --git a/pro_scheduler/pgproJob.cpp b/pro_scheduler/pgproJob.cpp index 81d3271..1b664b9 100644 --- a/pro_scheduler/pgproJob.cpp +++ b/pro_scheduler/pgproJob.cpp @@ -209,8 +209,9 @@ pgObject *pgproJobFactory::CreateObjects(pgCollection *collection, ctlTree *brow wxString tmp; tmp = jobs->GetVal(wxT("commands")); - tmp.Replace(wxT("{"), wxT("")); - tmp.Replace(wxT("}"), wxT("")); + if (tmp.find('{',0)==0) { tmp=wxT("[")+tmp.Mid(1,tmp.Len()-2)+wxT("]"); } + //tmp.Replace(wxT("{"), wxT("["),false); + //tmp.Replace(wxT("}"), wxT("]")); job->iSetCommands(tmp); diff --git a/schema/pgTable.cpp b/schema/pgTable.cpp index 1a1adba..581ee33 100644 --- a/schema/pgTable.cpp +++ b/schema/pgTable.cpp @@ -696,7 +696,8 @@ wxString pgTable::GetSql(ctlTree *browser) sql += GetGrant(wxT("arwdxt")); else sql += GetGrant(wxT("arwdRxt")); - + wxString st=GetStatExt(); + if (!st.IsEmpty()) sql += st + wxT(";\n"); sql += GetCommentSql(); if (GetConnection()->BackendMinimumVersion(9, 1)) @@ -1531,7 +1532,13 @@ pgObject *pgTableFactory::CreateObjects(pgCollection *collection, ctlTree *brows pg10=wxT("(rel.relpartbound is null and i.inhrelid is null) and"); //query += wxT(",\n(SELECT array_agg(provider) FROM pg_seclabels sl2 WHERE sl2.objoid=rel.oid AND sl2.objsubid=0) AS providers"); } +// 'ALTER STATISTICS '||substring('CREATE STATISTICS public.tab_a (dependencies) ON c1, c3 FROM a' from 'ICS (.+?)\s\(')||' OWNER TO '|| //select relation from pg_locks where locktype='relation' and granted=true and mode='AccessExclusiveLock' + if (collection->GetDatabase()->BackendMinimumVersion(10, 0)) + { + query += wxT(",\n pg_get_statisticsobjdef(stat_ext.oid) AS stat_stmt"); + query += wxT(",\nCASE WHEN stat_ext.stxowner<>rel.relowner then 'ALTER STATISTICS '||substring(pg_get_statisticsobjdef(stat_ext.oid) from 'ICS (.+?)\\s\\(')||' OWNER TO '||stat_ext.stxowner::regrole else null end AS alter_stmt"); + } query += wxT(" FROM pg_class rel\n") wxT(" LEFT JOIN pg_locks lk ON locktype='relation' and granted=true and mode='AccessExclusiveLock' and relation=rel.oid\n") wxT(" LEFT OUTER JOIN pg_tablespace spc on spc.oid=rel.reltablespace\n") @@ -1548,6 +1555,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()->BackendMinimumVersion(10, 0)) + query += wxT("LEFT JOIN pg_statistic_ext stat_ext ON rel.oid=stat_ext.stxrelid\n"); query += wxT(" WHERE ")+pg10+wxT(" rel.relkind IN ('r','s','t','p') AND rel.relnamespace = ") + collection->GetSchema()->GetOidStr() + wxT("\n"); @@ -1624,6 +1633,7 @@ pgObject *pgTableFactory::CreateObjects(pgCollection *collection, ctlTree *brows { table->iSetFillFactor(tables->GetVal(wxT("fillfactor"))); } + if (collection->GetConnection()->BackendMinimumVersion(8, 4)) { table->iSetRelOptions(tables->GetVal(wxT("reloptions"))); @@ -1684,6 +1694,11 @@ pgObject *pgTableFactory::CreateObjects(pgCollection *collection, ctlTree *brows table->iSetPartKeyDef(tables->GetVal(wxT("partkeydef"))); table->iSetPartExp(tables->GetVal(wxT("partexp"))); table->iSetIsPartitioned(tables->GetBool(wxT("ispartitioned"))); + wxString st = tables->GetVal(wxT("stat_stmt")); + wxString at = tables->GetVal(wxT("alter_stmt")); + if (!st.IsEmpty()&&!at.IsEmpty()) st=st+wxT(";\n")+at; + table->iSetStatExt(st); + } if (collection->GetConnection()->GetIsGreenplum()) {