Skip to content

Commit 96ca795

Browse files
committed
fix issue levinsv#6 (Child tables are not dispayed)
fix issue levinsv#6
1 parent 63ccdb0 commit 96ca795

File tree

5 files changed

+45
-6
lines changed

5 files changed

+45
-6
lines changed

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,12 @@ This text Russian language.
126126

127127
06.05.2020
128128
* исправлена проблема #4 (Crash after close sql editor)
129-
129+
130+
08.05.2020
131+
* исправлена проблема #6 (Child tables are not dispayed). Отображение секций из других схем нарушает строгую иерархичность обектов
132+
и нужно убедиться что всё нормально в вашем случае. Секции всегда группируются в узел Partitions который находиться в родительской таблице.
133+
В родной схеме, секции как таблицы увидеть нельзя.
134+
* мелкие улучшения
130135

131136

132137

Release_(3.0)/pgAdmin3.exe

12 KB
Binary file not shown.

frm/frmQuery.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -4133,6 +4133,12 @@ void frmQuery::OnNotebookOutpaneTabRDown(wxAuiNotebookEvent &event) {
41334133
if (b.IsOk()) {
41344134
if (sqlQuery!=NULL) {
41354135
wxString sql=sqlResult->sqlquerytext;
4136+
if (sql.StartsWith("EXPLAIN")) sql=sql.AfterFirst(')');
4137+
if (sql.StartsWith("\nBEGIN;\nEXPLAIN")) {
4138+
sql=sql.AfterFirst(')');
4139+
//"\n;\nROLLBACK;"
4140+
sql=sql.Mid(0,sql.Length()-12);
4141+
}
41364142
if (!sqlQuery->Find(sql,false,false,false,true,false,true)) {
41374143
wxString t=sqlQuery->GetText();
41384144
if (t.Find(sql)>-1) {

schema/pgPartition.cpp

+32-4
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ pgObject *pgPartitionFactory::CreateObjects(pgCollection *coll, ctlTree *browser
210210

211211
pgSet *tables;
212212

213-
query = wxT("SELECT rel.oid, rel.relname, rel.reltablespace AS spcoid, spc.spcname, pg_get_userbyid(rel.relowner) AS relowner, rel.relacl, ")
213+
query = wxT("SELECT rel.oid, rel.relname,rel.relnamespace::regnamespace AS nspace, rel.reltablespace AS spcoid, spc.spcname, pg_get_userbyid(rel.relowner) AS relowner, rel.relacl, ")
214214
wxT("rel.relhassubclass, rel.reltuples, des.description, con.conname, con.conkey,\n")
215215
wxT(" EXISTS(select 1 FROM pg_trigger\n")
216216
wxT(" JOIN pg_proc pt ON pt.oid=tgfoid AND pt.proname='logtrigger'\n")
@@ -262,7 +262,9 @@ pgObject *pgPartitionFactory::CreateObjects(pgCollection *coll, ctlTree *browser
262262
query += wxT(" LEFT OUTER JOIN pg_class tst ON tst.oid = rel.reltoastrelid\n");
263263
query += wxT("LEFT JOIN pg_type typ ON rel.reloftype=typ.oid\n");
264264

265-
query += wxT(" WHERE rel.relkind IN ('r','s','t','p') AND rel.relnamespace = ") + collection->GetSchema()->GetOidStr() + wxT("\n");
265+
query += wxT(" WHERE rel.relkind IN ('r','s','t','p')\n");
266+
// show partitions in other schema
267+
//query += wxT(" AND rel.relnamespace = ") + collection->GetSchema()->GetOidStr() + wxT("\n");
266268
query += wxT("--AND (not (rel.relkind='r' and rel.relpartbound IS NOT NULL))\n ")
267269
wxT(" AND i.inhparent = ") + collection->GetOidStr() + wxT("\n");
268270

@@ -273,9 +275,35 @@ pgObject *pgPartitionFactory::CreateObjects(pgCollection *coll, ctlTree *browser
273275
tables = collection->GetDatabase()->ExecuteSet(query);
274276
if (tables)
275277
{
278+
wxString currns=collection->GetSchema()->GetName();
279+
// wxArrayObject schemaArr;
280+
std::vector<pgSchema*> schemaArr;
276281
while (!tables->Eof())
277282
{
278-
table = new pgPartition(collection->GetSchema(), tables->GetVal(wxT("relname")));
283+
wxString ns=tables->GetVal(wxT("nspace"));
284+
if (currns!=ns) {
285+
// find pgSchema object in tree
286+
if (!(schemaArr.size()>0)) {
287+
wxTreeItemId currentItem = collection->GetSchema()->GetId();
288+
pgCollection *collsch;
289+
wxTreeItemId scItem;
290+
if (currentItem) scItem = browser->GetItemParent(currentItem);
291+
collsch = (pgCollection *) browser->GetObject(scItem);
292+
if (!collsch) continue;
293+
treeObjectIterator schemaIterator(browser, collsch);
294+
pgSchema *s;
295+
while ((s = (pgSchema *)schemaIterator.GetNextObject()) != 0)
296+
schemaArr.push_back(s);
297+
}
298+
table = 0;
299+
for (size_t j=0;j<schemaArr.size();j++) {
300+
if (ns==schemaArr[j]->GetName()) {
301+
table = new pgPartition(schemaArr[j], tables->GetVal(wxT("relname")));
302+
break;
303+
}
304+
}
305+
if (!table) continue;
306+
} else table = new pgPartition(collection->GetSchema(), tables->GetVal(wxT("relname")));
279307

280308
table->iSetOid(tables->GetOid(wxT("oid")));
281309
table->iSetOwner(tables->GetVal(wxT("relowner")));
@@ -394,7 +422,7 @@ pgObject *pgPartitionFactory::CreateObjects(pgCollection *coll, ctlTree *browser
394422
else
395423
break;
396424
}
397-
425+
if (schemaArr.size()>0) schemaArr.clear();
398426
delete tables;
399427
}
400428
return table;

schema/pgTable.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ pgObject *pgTableFactory::CreateObjects(pgCollection *collection, ctlTree *brows
15561556
query += wxT(",\n(SELECT array_agg(provider) FROM pg_seclabels sl2 WHERE sl2.objoid=rel.oid AND sl2.objsubid=0) AS providers");
15571557
}
15581558
wxString pg10=wxEmptyString;
1559-
if (collection->GetDatabase()->BackendMinimumVersion(10, 1))
1559+
if (collection->GetDatabase()->BackendMinimumVersion(10, 0))
15601560
{
15611561
query += wxT(",case when lk.relation=rel.oid then null else pg_get_partkeydef(rel.oid) end \n AS partkeydef");
15621562
query += wxT(",case when lk.relation=rel.oid then null else pg_get_expr(rel.relpartbound, rel.oid) end \n AS partexp");

0 commit comments

Comments
 (0)