+#if EXPERIMENTAL_WXDB_FUNCTIONS // will be added in 2.4
+/********** wxDB::TablePrivileges() **********/
+bool wxDB::TablePrivileges(const char *tableName, const char* priv,
+ const char *userID, const char *tablePath)
+{
+ wxDbTablePrivilegeInfo result;
+ SDWORD cbRetVal;
+ RETCODE retcode;
+
+ //We probably need to be able to dynamically set this based on
+ //the driver type, and state.
+ char curRole[]="public";
+
+ //Prologue here similar to db::TableExists()
+ wxString UserID;
+ wxString TableName;
+
+ assert(tableName && wxStrlen(tableName));
+
+ if (userID)
+ {
+ if (!wxStrlen(userID))
+ UserID = uid;
+ else
+ UserID = userID;
+ }
+ else
+ UserID = "";
+
+ // Oracle user names may only be in uppercase, so force
+ // the name to uppercase
+ if (Dbms() == dbmsORACLE)
+ UserID = UserID.Upper();
+
+ TableName = tableName;
+ // Oracle table names are uppercase only, so force
+ // the name to uppercase just in case programmer forgot to do this
+ if (Dbms() == dbmsORACLE)
+ TableName = TableName.Upper();
+
+ SQLFreeStmt(hstmt, SQL_CLOSE);
+
+ retcode = SQLTablePrivileges(hstmt,
+ NULL, 0, // All qualifiers
+ NULL, 0, // All owners
+ (UCHAR FAR *)TableName.GetData(), SQL_NTS);
+
+#ifdef DBDEBUG_CONSOLE
+ fprintf(stderr ,"SQLTablePrivileges() returned %i \n",retcode);
+#endif
+ retcode = SQLBindCol (hstmt, 1, SQL_C_CHAR , &result.tableQual, 128, &cbRetVal);
+
+ retcode = SQLBindCol (hstmt, 2, SQL_C_CHAR , &result.tableOwner, 128, &cbRetVal);
+
+ retcode = SQLBindCol (hstmt, 3, SQL_C_CHAR , &result.tableName, 128, &cbRetVal);
+
+ retcode = SQLBindCol (hstmt, 4, SQL_C_CHAR , &result.grantor, 128, &cbRetVal);
+
+ retcode = SQLBindCol (hstmt, 5, SQL_C_CHAR , &result.grantee, 128, &cbRetVal);
+
+ retcode = SQLBindCol (hstmt, 6, SQL_C_CHAR , &result.privilege, 128, &cbRetVal);
+
+ retcode = SQLBindCol (hstmt, 7, SQL_C_CHAR , &result.grantable, 3, &cbRetVal);
+
+ retcode = SQLFetch(hstmt);
+ while (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
+ {
+#ifdef DBDEBUG_CONSOLE
+ fprintf(stderr,"Scanning %s privilege on table %s.%s granted by %s to %s\n",
+ result.privilege,result.tabowner,result.tabname,
+ result.grantor, result.grantee);
+#endif
+ if (UserID.IsSameAs(result.tableOwner,false) )
+ return TRUE;
+
+ if (UserID.IsSameAs(result.grantee,false) &&
+ !strcmp(result.privilege,priv))
+ return TRUE;
+
+ if (!strcmp(result.grantee,curRole) &&
+ !strcmp(result.privilege,priv))
+ return TRUE;
+
+ retcode = SQLFetch(hstmt);
+ }
+
+ return FALSE;
+
+} // wxDB::TablePrivileges
+#endif
+
+