@@ -210,7 +210,7 @@ pgObject *pgPartitionFactory::CreateObjects(pgCollection *coll, ctlTree *browser
210
210
211
211
pgSet *tables;
212
212
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, " )
214
214
wxT (" rel.relhassubclass, rel.reltuples, des.description, con.conname, con.conkey,\n " )
215
215
wxT (" EXISTS(select 1 FROM pg_trigger\n " )
216
216
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
262
262
query += wxT (" LEFT OUTER JOIN pg_class tst ON tst.oid = rel.reltoastrelid\n " );
263
263
query += wxT (" LEFT JOIN pg_type typ ON rel.reloftype=typ.oid\n " );
264
264
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");
266
268
query += wxT (" --AND (not (rel.relkind='r' and rel.relpartbound IS NOT NULL))\n " )
267
269
wxT (" AND i.inhparent = " ) + collection->GetOidStr () + wxT (" \n " );
268
270
@@ -273,9 +275,35 @@ pgObject *pgPartitionFactory::CreateObjects(pgCollection *coll, ctlTree *browser
273
275
tables = collection->GetDatabase ()->ExecuteSet (query);
274
276
if (tables)
275
277
{
278
+ wxString currns=collection->GetSchema ()->GetName ();
279
+ // wxArrayObject schemaArr;
280
+ std::vector<pgSchema*> schemaArr;
276
281
while (!tables->Eof ())
277
282
{
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" )));
279
307
280
308
table->iSetOid (tables->GetOid (wxT (" oid" )));
281
309
table->iSetOwner (tables->GetVal (wxT (" relowner" )));
@@ -394,7 +422,7 @@ pgObject *pgPartitionFactory::CreateObjects(pgCollection *coll, ctlTree *browser
394
422
else
395
423
break ;
396
424
}
397
-
425
+ if (schemaArr. size ()> 0 ) schemaArr. clear ();
398
426
delete tables;
399
427
}
400
428
return table;
0 commit comments