X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/549c8cc2fe3ab03276745d546b0f81297c34a147..1aaf88d2208793f6a05f02c3e23ade668555d31e:/src/common/dbtable.cpp diff --git a/src/common/dbtable.cpp b/src/common/dbtable.cpp index da7aaa8f60..a07fa6e013 100644 --- a/src/common/dbtable.cpp +++ b/src/common/dbtable.cpp @@ -770,8 +770,18 @@ bool wxDbTable::Open(bool checkPrivileges, bool checkTableExists) } s.Empty(); + + bool exists = true; + if (checkTableExists) + { + if (pDb->Dbms() == dbmsPOSTGRES) + exists = pDb->TableExists(tableName, NULL, tablePath); + else + exists = pDb->TableExists(tableName, pDb->GetUsername(), tablePath); + } + // Verify that the table exists in the database - if (checkTableExists && !pDb->TableExists(tableName, pDb->GetUsername(), tablePath)) + if (!exists) { s = wxT("Table/view does not exist in the database"); if ( *(pDb->dbInf.accessibleTables) == wxT('Y')) @@ -782,21 +792,22 @@ bool wxDbTable::Open(bool checkPrivileges, bool checkTableExists) else if (checkPrivileges) { // Verify the user has rights to access the table. - // Shortcut boolean evaluation to optimize out call to - // TablePrivileges - // - // Unfortunately this optimization doesn't seem to be - // reliable! - if (// *(pDb->dbInf.accessibleTables) == 'N' && - !pDb->TablePrivileges(tableName, wxT("SELECT"), pDb->GetUsername(), pDb->GetUsername(), tablePath)) + bool hasPrivs wxDUMMY_INITIALIZE(true); + + if (pDb->Dbms() == dbmsPOSTGRES) + hasPrivs = pDb->TablePrivileges(tableName, wxT("SELECT"), pDb->GetUsername(), NULL, tablePath); + else + hasPrivs = pDb->TablePrivileges(tableName, wxT("SELECT"), pDb->GetUsername(), pDb->GetUsername(), tablePath); + + if (!hasPrivs) s = wxT("Connecting user does not have sufficient privileges to access this table.\n"); } - if (!s.IsEmpty()) + if (!s.empty()) { wxString p; - if (!tablePath.IsEmpty()) + if (!tablePath.empty()) p.Printf(wxT("Error opening '%s/%s'.\n"),tablePath.c_str(),tableName.c_str()); else p.Printf(wxT("Error opening '%s'.\n"), tableName.c_str()); @@ -1303,7 +1314,7 @@ void wxDbTable::BuildWhereClause(wxString &pWhereClause, int typeOfWhere, case SQL_C_CHAR: #ifndef __UNIX__ case SQL_C_WCHAR: -#endif +#endif //case SQL_C_WXCHAR: SQL_C_WXCHAR is covered by either SQL_C_CHAR or SQL_C_WCHAR colValue.Printf(wxT("'%s'"), (UCHAR FAR *) colDefs[colNumber].PtrDataObj); break; @@ -2703,6 +2714,8 @@ wxVariant wxDbTable::GetColumn(const int colNumber) const { switch (colDefs[colNumber].SqlCtype) { + case SQL_WCHAR: + case SQL_WVARCHAR: case SQL_CHAR: case SQL_VARCHAR: val = (wxChar *)(colDefs[colNumber].PtrDataObj); @@ -2767,6 +2780,8 @@ void wxDbTable::SetColumn(const int colNumber, const wxVariant val) switch (colDefs[colNumber].SqlCtype) { + case SQL_WCHAR: + case SQL_WVARCHAR: case SQL_CHAR: case SQL_VARCHAR: csstrncpyt((wxChar *)(colDefs[colNumber].PtrDataObj),