mirror of
https://github.com/levinsv/pgadmin3.git
synced 2026-05-15 06:05:49 -06:00
Fast dlgTable for GTK. Fix errors.
This commit is contained in:
parent
e65781aa65
commit
c78b09ad2e
8 changed files with 64 additions and 27 deletions
|
|
@ -68,13 +68,19 @@ int ctlComboBoxFix::FillOidKey(pgConn *conn, const wxChar *qry)
|
|||
int cnt = 0;
|
||||
pgSetIterator set(conn->ExecuteSet(qry));
|
||||
Freeze();
|
||||
std::vector<void*> pointer;
|
||||
wxArrayString name;
|
||||
while (set.RowsLeft())
|
||||
{
|
||||
OID oid = set.GetOid(0);
|
||||
wxString txt = set.GetVal(1);
|
||||
Append(txt, oid);
|
||||
name.Add(txt);
|
||||
pointer.push_back((void*) oid);
|
||||
cnt++;
|
||||
}
|
||||
|
||||
if (cnt>0) wxComboBox::Append(name, pointer.data());
|
||||
|
||||
Thaw();
|
||||
return cnt;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -420,18 +420,31 @@ int dlgFunction::Go(bool modal)
|
|||
DatatypeReader tr(database, restrict);
|
||||
cbDatatype->Freeze();
|
||||
cbReturntype->Freeze();
|
||||
wxArrayString arr_dt,arr_rt;
|
||||
wxString prevnametype;
|
||||
while (tr.HasMore())
|
||||
{
|
||||
pgDatatype dt = tr.GetDatatype();
|
||||
|
||||
typOids.Add(tr.GetOidStr());
|
||||
types.Add(dt.GetQuotedSchemaPrefix(database) + dt.QuotedFullName());
|
||||
|
||||
cbDatatype->Append(dt.GetQuotedSchemaPrefix(database) + dt.QuotedFullName());
|
||||
if (factory != &triggerFunctionFactory)
|
||||
cbReturntype->Append(dt.GetQuotedSchemaPrefix(database) + dt.QuotedFullName());
|
||||
if (!tr.IsPartition()) {
|
||||
wxString tname=tr.GetTypename();
|
||||
bool isnext=true;
|
||||
if (tname.Right(2)=="[]")
|
||||
if (prevnametype!=tname.substr(0,tname.Length()-2)) isnext=false;
|
||||
if (isnext) {
|
||||
pgDatatype dt = tr.GetDatatype();
|
||||
typOids.Add(tr.GetOidStr());
|
||||
wxString tmp_str=dt.GetQuotedSchemaPrefix(database) + dt.QuotedFullName();
|
||||
types.Add(tmp_str);
|
||||
arr_dt.Add(tmp_str);
|
||||
//cbDatatype->Append(dt.GetQuotedSchemaPrefix(database) + dt.QuotedFullName());
|
||||
if (factory != &triggerFunctionFactory)
|
||||
arr_rt.Add(tmp_str);
|
||||
}
|
||||
prevnametype=tname;
|
||||
}
|
||||
tr.MoveNext();
|
||||
}
|
||||
cbDatatype->Append(arr_dt);
|
||||
cbReturntype->Append(arr_rt);
|
||||
cbDatatype->Thaw();
|
||||
cbReturntype->Thaw();
|
||||
long sel;
|
||||
|
|
|
|||
|
|
@ -266,9 +266,9 @@ int dlgTable::Go(bool modal)
|
|||
|
||||
// new "of type" combobox
|
||||
wxString typeQuery = wxT("SELECT t.oid, t.typname ")
|
||||
wxT("FROM pg_type t, pg_namespace n ")
|
||||
wxT("WHERE t.typtype='c' AND t.typnamespace=n.oid ")
|
||||
wxT("AND NOT (n.nspname like 'pg_%' OR n.nspname='information_schema') ")
|
||||
wxT("FROM pg_type t, pg_namespace n,pg_class c ")
|
||||
wxT("WHERE t.typtype='c'and c.relkind='c' AND t.typnamespace=n.oid and c.oid=t.typrelid ")
|
||||
wxT("AND NOT (n.nspname like 'pg_%' OR n.nspname='information_schema' or c.relkind in ('I','i') or c.relpartbound is not null) ")
|
||||
wxT("ORDER BY typname");
|
||||
cbOfType->Insert(wxEmptyString, 0, (void *)0);
|
||||
cbOfType->FillOidKey(connection, typeQuery);
|
||||
|
|
@ -439,7 +439,7 @@ int dlgTable::Go(bool modal)
|
|||
// new "like relation" combobox
|
||||
wxString likeRelationQuery = wxT("SELECT c.oid, quote_ident(n.nspname)||'.'||quote_ident(c.relname) ")
|
||||
wxT("FROM pg_class c, pg_namespace n ")
|
||||
wxT("WHERE c.relnamespace=n.oid AND c.relkind IN ");
|
||||
wxT("WHERE c.relnamespace=n.oid and c.relpartbound is null AND c.relkind IN ");
|
||||
if (connection->BackendMinimumVersion(9, 2))
|
||||
{
|
||||
likeRelationQuery += wxT("('r', 'v', 'f')");
|
||||
|
|
@ -490,7 +490,7 @@ int dlgTable::Go(bool modal)
|
|||
wxT("SELECT c.oid, c.relname , nspname\n")
|
||||
wxT(" FROM pg_class c\n")
|
||||
wxT(" JOIN pg_namespace n ON n.oid=c.relnamespace\n")
|
||||
wxT(" WHERE relkind='r'\n")
|
||||
wxT(" WHERE relkind='r' and c.relpartbound is null\n")
|
||||
+ systemRestriction +
|
||||
wxT(" ORDER BY relnamespace, c.relname"));
|
||||
if (set)
|
||||
|
|
@ -1886,15 +1886,23 @@ void dlgTable::OnChangeCol(wxCommandEvent &ev)
|
|||
void dlgTable::PopulateDatatypeCache()
|
||||
{
|
||||
DatatypeReader tr(database, true, true);
|
||||
wxString prevnametype;
|
||||
while (tr.HasMore())
|
||||
{
|
||||
pgDatatype dt = tr.GetDatatype();
|
||||
|
||||
dataType *dType = new dataType();
|
||||
dType->SetOid(tr.GetOid());
|
||||
dType->SetTypename(dt.GetQuotedSchemaPrefix(database) + dt.QuotedFullName());
|
||||
dtCache.Add(dType);
|
||||
|
||||
if (!tr.IsPartition()) {
|
||||
wxString tname=tr.GetTypename();
|
||||
bool isnext=true;
|
||||
if (tname.Right(2)=="[]")
|
||||
if (prevnametype!=tname.substr(0,tname.Length()-2)) isnext=false;
|
||||
if (isnext) {
|
||||
dataType *dType = new dataType();
|
||||
dType->SetOid(tr.GetOid());
|
||||
dType->SetTypename(dt.GetQuotedSchemaPrefix(database) + dt.QuotedFullName());
|
||||
dtCache.Add(dType);
|
||||
}
|
||||
prevnametype=tname;
|
||||
}
|
||||
tr.MoveNext();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3595,7 +3595,7 @@ void frmStatus::OnLoadLogfile(wxCommandEvent &event)
|
|||
{
|
||||
if (logThread) logThread->BreakRead();
|
||||
|
||||
logList->DeleteAllItems();
|
||||
logList->DeleteAllItemsWithLong();
|
||||
nav->ClearMark();
|
||||
//bgColor = wxColour("#afafaf");
|
||||
//bgColor = logList->GetBackgroundColour();
|
||||
|
|
|
|||
|
|
@ -39,6 +39,10 @@ public:
|
|||
{
|
||||
return wxComboBox::Append(item);
|
||||
}
|
||||
int Append(const wxArrayString &item)
|
||||
{
|
||||
return wxComboBox::Append(item);
|
||||
}
|
||||
int Append(const wxString &item, void *data)
|
||||
{
|
||||
return wxComboBox::Append(item, data);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public:
|
|||
bool ReSort();
|
||||
bool IsNumberColumn(const wxString& columnlabel);
|
||||
void SetModeStoreLongString() { storelongstring = true; }
|
||||
bool DeleteAllItems() {
|
||||
bool DeleteAllItemsWithLong() {
|
||||
longstring.clear();
|
||||
return wxListView::DeleteAllItems();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ public:
|
|||
}
|
||||
|
||||
bool IsDomain() const;
|
||||
bool IsPartition() const;
|
||||
bool IsVarlen() const;
|
||||
bool MaySpecifyLength() const;
|
||||
bool MaySpecifyPrecision() const;
|
||||
|
|
|
|||
|
|
@ -206,19 +206,19 @@ void DatatypeReader::init(pgDatabase *db, const wxString &condition, bool addSer
|
|||
{
|
||||
database = db;
|
||||
wxString sql = wxT("SELECT * FROM (SELECT format_type(t.oid,NULL) AS typname, CASE WHEN typelem > 0 THEN typelem ELSE t.oid END as elemoid, typlen, typtype, t.oid, nspname,\n")
|
||||
wxT(" (SELECT COUNT(1) FROM pg_type t2 WHERE t2.typname = t.typname) > 1 AS isdup\n")
|
||||
wxT(" (SELECT COUNT(1) FROM pg_type t2 WHERE t2.typname = t.typname) > 1 AS isdup, c.relpartbound is not null or c.relkind in('i','I') AS ispart\n")
|
||||
wxT(" FROM pg_type t\n")
|
||||
wxT(" JOIN pg_namespace nsp ON typnamespace=nsp.oid\n")
|
||||
wxT(" JOIN pg_namespace nsp ON typnamespace=nsp.oid left join pg_class c on c.oid=t.typrelid\n")
|
||||
wxT(" WHERE (NOT (typname = 'unknown' AND nspname = 'pg_catalog')) AND ") + condition + wxT("\n");
|
||||
|
||||
if (addSerials)
|
||||
{
|
||||
if (db->GetConnection()->BackendMinimumVersion(9, 2))
|
||||
{
|
||||
sql += wxT(" UNION SELECT 'smallserial', 0, 2, 'b', 0, 'pg_catalog', false\n");
|
||||
sql += wxT(" UNION SELECT 'smallserial', 0, 2, 'b', 0, 'pg_catalog', false, false\n");
|
||||
}
|
||||
sql += wxT(" UNION SELECT 'bigserial', 0, 8, 'b', 0, 'pg_catalog', false\n");
|
||||
sql += wxT(" UNION SELECT 'serial', 0, 4, 'b', 0, 'pg_catalog', false\n");
|
||||
sql += wxT(" UNION SELECT 'bigserial', 0, 8, 'b', 0, 'pg_catalog', false, false\n");
|
||||
sql += wxT(" UNION SELECT 'serial', 0, 4, 'b', 0, 'pg_catalog', false, false\n");
|
||||
}
|
||||
|
||||
sql += wxT(" ) AS dummy ORDER BY nspname <> 'pg_catalog', nspname <> 'public', nspname, 1");
|
||||
|
|
@ -232,6 +232,11 @@ bool DatatypeReader::IsDomain() const
|
|||
return set->GetVal(wxT("typtype")) == 'd';
|
||||
}
|
||||
|
||||
bool DatatypeReader::IsPartition() const
|
||||
{
|
||||
return set->GetBool(wxT("ispart"));
|
||||
}
|
||||
|
||||
|
||||
bool DatatypeReader::IsVarlen() const
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue