Github user DaveBirdsall commented on a diff in the pull request: https://github.com/apache/incubator-trafodion/pull/729#discussion_r80748650 --- Diff: core/sql/sqlcomp/PrivMgrPrivileges.cpp --- @@ -6134,6 +5870,79 @@ static bool isDelimited( const std::string &strToScan) // ***************************************************************************** +// method: reportPrivWarnings +// +// Ansi states that when a grant statement is executed, a set of privilege +// descriptors (CPD) is created based on existing privileges for the object and +// objectâs columns. Each CPD contains the grantee, action (privileges), object, +// column and grantor. A similar list of privilege descriptors is created based +// on the grant/revoke statement (GPD). +// +// If there is an element in the GPD (what the user requested) that is not in +// the CPD (what was actually granted/revoked), then a warning â privilege not +// granted/revoked is displayed. +// +// This method compares the list of actual privileges granted/revoked +// (actualPrivs)to the list privileges requested (origPrivs). If a privilege +// was requested but not granted/revoked report a warning. +// ***************************************************************************** +void PrivMgrPrivileges::reportPrivWarnings( + const PrivMgrDesc &origPrivs, + const PrivMgrDesc &actualPrivs, + const CatErrorCode warningCode) +{ + PrivMgrCoreDesc objPrivsNotApplied = origPrivs.getTablePrivs(); + objPrivsNotApplied.suppressDuplicatedPrivs(actualPrivs.getTablePrivs()); + if (!objPrivsNotApplied.isNull()) + { + for ( size_t i = FIRST_DML_PRIV; i <= LAST_DML_PRIV; i++ ) + { + PrivType privType = PrivType(i); + if (objPrivsNotApplied.getPriv(privType)) + { + *pDiags_ << DgSqlCode(warningCode) + << DgString0(PrivMgrUserPrivs::convertPrivTypeToLiteral(privType).c_str()); + } + } + } + + NAList<PrivMgrCoreDesc> colPrivs = origPrivs.getColumnPrivs(); + for (int i = 0; i < colPrivs.entries(); i++) + { + PrivMgrCoreDesc colPrivsNotApplied = colPrivs[i]; + + int index = actualPrivs.getColumnPriv(i); + if (index >= 0) + { + PrivMgrCoreDesc colPrivsActual = actualPrivs.getColumnPrivs()[index]; + colPrivsNotApplied.suppressDuplicatedPrivs(colPrivsActual); + } + + if (!colPrivsNotApplied.isNull()) + { + for ( size_t j = FIRST_DML_PRIV; j <= LAST_DML_PRIV; j++ ) + { + PrivType privType = PrivType(j); + if (colPrivsNotApplied.getPriv(privType)) + { + // would be better to add column name instead of number + // would require an I/O to read COLUMNS to get the name --- End diff -- Might be available in the NATables cache, but I know you don't want that dependency in this code.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---