Index: metastore/if/hive_metastore.thrift =================================================================== --- metastore/if/hive_metastore.thrift (revision 1060489) +++ metastore/if/hive_metastore.thrift (working copy) @@ -343,6 +343,7 @@ bool create_role(1:Role role) throws(1:MetaException o1) bool drop_role(1:string role_name) throws(1:MetaException o1) + list get_role_names() throws(1:MetaException o1) bool grant_role(1:string role_name, 2:string principal_name, 3:PrincipalType principal_type, 4:string grantor, 5:PrincipalType grantorType, 6:bool grant_option) throws(1:MetaException o1) bool revoke_role(1:string role_name, 2:string principal_name, 3:PrincipalType principal_type) Index: metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp =================================================================== --- metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp (revision 1060489) +++ metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp (working copy) @@ -10477,6 +10477,202 @@ return xfer; } +uint32_t ThriftHiveMetastore_get_role_names_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t ThriftHiveMetastore_get_role_names_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_role_names_args"); + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +uint32_t ThriftHiveMetastore_get_role_names_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_role_names_pargs"); + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +uint32_t ThriftHiveMetastore_get_role_names_result::read(::apache::thrift::protocol::TProtocol* iprot) { + + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->success.clear(); + uint32_t _size431; + ::apache::thrift::protocol::TType _etype434; + iprot->readListBegin(_etype434, _size431); + this->success.resize(_size431); + uint32_t _i435; + for (_i435 = 0; _i435 < _size431; ++_i435) + { + xfer += iprot->readString(this->success[_i435]); + } + iprot->readListEnd(); + } + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->o1.read(iprot); + this->__isset.o1 = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t ThriftHiveMetastore_get_role_names_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("ThriftHiveMetastore_get_role_names_result"); + + if (this->__isset.success) { + xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, this->success.size()); + std::vector ::const_iterator _iter436; + for (_iter436 = this->success.begin(); _iter436 != this->success.end(); ++_iter436) + { + xfer += oprot->writeString((*_iter436)); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + } else if (this->__isset.o1) { + xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->o1.write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +uint32_t ThriftHiveMetastore_get_role_names_presult::read(::apache::thrift::protocol::TProtocol* iprot) { + + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + (*(this->success)).clear(); + uint32_t _size437; + ::apache::thrift::protocol::TType _etype440; + iprot->readListBegin(_etype440, _size437); + (*(this->success)).resize(_size437); + uint32_t _i441; + for (_i441 = 0; _i441 < _size437; ++_i441) + { + xfer += iprot->readString((*(this->success))[_i441]); + } + iprot->readListEnd(); + } + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->o1.read(iprot); + this->__isset.o1 = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + uint32_t ThriftHiveMetastore_grant_role_args::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; @@ -10515,9 +10711,9 @@ break; case 3: if (ftype == ::apache::thrift::protocol::T_I32) { - int32_t ecast431; - xfer += iprot->readI32(ecast431); - this->principal_type = (PrincipalType::type)ecast431; + int32_t ecast442; + xfer += iprot->readI32(ecast442); + this->principal_type = (PrincipalType::type)ecast442; this->__isset.principal_type = true; } else { xfer += iprot->skip(ftype); @@ -10533,9 +10729,9 @@ break; case 5: if (ftype == ::apache::thrift::protocol::T_I32) { - int32_t ecast432; - xfer += iprot->readI32(ecast432); - this->grantorType = (PrincipalType::type)ecast432; + int32_t ecast443; + xfer += iprot->readI32(ecast443); + this->grantorType = (PrincipalType::type)ecast443; this->__isset.grantorType = true; } else { xfer += iprot->skip(ftype); @@ -10767,9 +10963,9 @@ break; case 3: if (ftype == ::apache::thrift::protocol::T_I32) { - int32_t ecast433; - xfer += iprot->readI32(ecast433); - this->principal_type = (PrincipalType::type)ecast433; + int32_t ecast444; + xfer += iprot->readI32(ecast444); + this->principal_type = (PrincipalType::type)ecast444; this->__isset.principal_type = true; } else { xfer += iprot->skip(ftype); @@ -10967,9 +11163,9 @@ break; case 2: if (ftype == ::apache::thrift::protocol::T_I32) { - int32_t ecast434; - xfer += iprot->readI32(ecast434); - this->principal_type = (PrincipalType::type)ecast434; + int32_t ecast445; + xfer += iprot->readI32(ecast445); + this->principal_type = (PrincipalType::type)ecast445; this->__isset.principal_type = true; } else { xfer += iprot->skip(ftype); @@ -11039,14 +11235,14 @@ if (ftype == ::apache::thrift::protocol::T_LIST) { { this->success.clear(); - uint32_t _size435; - ::apache::thrift::protocol::TType _etype438; - iprot->readListBegin(_etype438, _size435); - this->success.resize(_size435); - uint32_t _i439; - for (_i439 = 0; _i439 < _size435; ++_i439) + uint32_t _size446; + ::apache::thrift::protocol::TType _etype449; + iprot->readListBegin(_etype449, _size446); + this->success.resize(_size446); + uint32_t _i450; + for (_i450 = 0; _i450 < _size446; ++_i450) { - xfer += this->success[_i439].read(iprot); + xfer += this->success[_i450].read(iprot); } iprot->readListEnd(); } @@ -11085,10 +11281,10 @@ xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, this->success.size()); - std::vector ::const_iterator _iter440; - for (_iter440 = this->success.begin(); _iter440 != this->success.end(); ++_iter440) + std::vector ::const_iterator _iter451; + for (_iter451 = this->success.begin(); _iter451 != this->success.end(); ++_iter451) { - xfer += (*_iter440).write(oprot); + xfer += (*_iter451).write(oprot); } xfer += oprot->writeListEnd(); } @@ -11127,14 +11323,14 @@ if (ftype == ::apache::thrift::protocol::T_LIST) { { (*(this->success)).clear(); - uint32_t _size441; - ::apache::thrift::protocol::TType _etype444; - iprot->readListBegin(_etype444, _size441); - (*(this->success)).resize(_size441); - uint32_t _i445; - for (_i445 = 0; _i445 < _size441; ++_i445) + uint32_t _size452; + ::apache::thrift::protocol::TType _etype455; + iprot->readListBegin(_etype455, _size452); + (*(this->success)).resize(_size452); + uint32_t _i456; + for (_i456 = 0; _i456 < _size452; ++_i456) { - xfer += (*(this->success))[_i445].read(iprot); + xfer += (*(this->success))[_i456].read(iprot); } iprot->readListEnd(); } @@ -11203,14 +11399,14 @@ if (ftype == ::apache::thrift::protocol::T_LIST) { { this->group_names.clear(); - uint32_t _size446; - ::apache::thrift::protocol::TType _etype449; - iprot->readListBegin(_etype449, _size446); - this->group_names.resize(_size446); - uint32_t _i450; - for (_i450 = 0; _i450 < _size446; ++_i450) + uint32_t _size457; + ::apache::thrift::protocol::TType _etype460; + iprot->readListBegin(_etype460, _size457); + this->group_names.resize(_size457); + uint32_t _i461; + for (_i461 = 0; _i461 < _size457; ++_i461) { - xfer += iprot->readString(this->group_names[_i450]); + xfer += iprot->readString(this->group_names[_i461]); } iprot->readListEnd(); } @@ -11243,10 +11439,10 @@ xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 3); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, this->group_names.size()); - std::vector ::const_iterator _iter451; - for (_iter451 = this->group_names.begin(); _iter451 != this->group_names.end(); ++_iter451) + std::vector ::const_iterator _iter462; + for (_iter462 = this->group_names.begin(); _iter462 != this->group_names.end(); ++_iter462) { - xfer += oprot->writeString((*_iter451)); + xfer += oprot->writeString((*_iter462)); } xfer += oprot->writeListEnd(); } @@ -11268,10 +11464,10 @@ xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 3); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, (*(this->group_names)).size()); - std::vector ::const_iterator _iter452; - for (_iter452 = (*(this->group_names)).begin(); _iter452 != (*(this->group_names)).end(); ++_iter452) + std::vector ::const_iterator _iter463; + for (_iter463 = (*(this->group_names)).begin(); _iter463 != (*(this->group_names)).end(); ++_iter463) { - xfer += oprot->writeString((*_iter452)); + xfer += oprot->writeString((*_iter463)); } xfer += oprot->writeListEnd(); } @@ -11427,9 +11623,9 @@ break; case 2: if (ftype == ::apache::thrift::protocol::T_I32) { - int32_t ecast453; - xfer += iprot->readI32(ecast453); - this->principal_type = (PrincipalType::type)ecast453; + int32_t ecast464; + xfer += iprot->readI32(ecast464); + this->principal_type = (PrincipalType::type)ecast464; this->__isset.principal_type = true; } else { xfer += iprot->skip(ftype); @@ -11513,14 +11709,14 @@ if (ftype == ::apache::thrift::protocol::T_LIST) { { this->success.clear(); - uint32_t _size454; - ::apache::thrift::protocol::TType _etype457; - iprot->readListBegin(_etype457, _size454); - this->success.resize(_size454); - uint32_t _i458; - for (_i458 = 0; _i458 < _size454; ++_i458) + uint32_t _size465; + ::apache::thrift::protocol::TType _etype468; + iprot->readListBegin(_etype468, _size465); + this->success.resize(_size465); + uint32_t _i469; + for (_i469 = 0; _i469 < _size465; ++_i469) { - xfer += this->success[_i458].read(iprot); + xfer += this->success[_i469].read(iprot); } iprot->readListEnd(); } @@ -11559,10 +11755,10 @@ xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, this->success.size()); - std::vector ::const_iterator _iter459; - for (_iter459 = this->success.begin(); _iter459 != this->success.end(); ++_iter459) + std::vector ::const_iterator _iter470; + for (_iter470 = this->success.begin(); _iter470 != this->success.end(); ++_iter470) { - xfer += (*_iter459).write(oprot); + xfer += (*_iter470).write(oprot); } xfer += oprot->writeListEnd(); } @@ -11601,14 +11797,14 @@ if (ftype == ::apache::thrift::protocol::T_LIST) { { (*(this->success)).clear(); - uint32_t _size460; - ::apache::thrift::protocol::TType _etype463; - iprot->readListBegin(_etype463, _size460); - (*(this->success)).resize(_size460); - uint32_t _i464; - for (_i464 = 0; _i464 < _size460; ++_i464) + uint32_t _size471; + ::apache::thrift::protocol::TType _etype474; + iprot->readListBegin(_etype474, _size471); + (*(this->success)).resize(_size471); + uint32_t _i475; + for (_i475 = 0; _i475 < _size471; ++_i475) { - xfer += (*(this->success))[_i464].read(iprot); + xfer += (*(this->success))[_i475].read(iprot); } iprot->readListEnd(); } @@ -14979,6 +15175,68 @@ throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "drop_role failed: unknown result"); } +void ThriftHiveMetastoreClient::get_role_names(std::vector & _return) +{ + send_get_role_names(); + recv_get_role_names(_return); +} + +void ThriftHiveMetastoreClient::send_get_role_names() +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("get_role_names", ::apache::thrift::protocol::T_CALL, cseqid); + + ThriftHiveMetastore_get_role_names_pargs args; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->flush(); + oprot_->getTransport()->writeEnd(); +} + +void ThriftHiveMetastoreClient::recv_get_role_names(std::vector & _return) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + iprot_->readMessageBegin(fname, mtype, rseqid); + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::INVALID_MESSAGE_TYPE); + } + if (fname.compare("get_role_names") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::WRONG_METHOD_NAME); + } + ThriftHiveMetastore_get_role_names_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + // _return pointer has now been filled + return; + } + if (result.__isset.o1) { + throw result.o1; + } + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "get_role_names failed: unknown result"); +} + bool ThriftHiveMetastoreClient::grant_role(const std::string& role_name, const std::string& principal_name, const PrincipalType::type principal_type, const std::string& grantor, const PrincipalType::type grantorType, const bool grant_option) { send_grant_role(role_name, principal_name, principal_type, grantor, grantorType, grant_option); @@ -16981,6 +17239,37 @@ oprot->getTransport()->writeEnd(); } +void ThriftHiveMetastoreProcessor::process_get_role_names(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot) +{ + ThriftHiveMetastore_get_role_names_args args; + args.read(iprot); + iprot->readMessageEnd(); + iprot->getTransport()->readEnd(); + + ThriftHiveMetastore_get_role_names_result result; + try { + iface_->get_role_names(result.success); + result.__isset.success = true; + } catch (MetaException &o1) { + result.o1 = o1; + result.__isset.o1 = true; + } catch (const std::exception& e) { + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("get_role_names", ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->flush(); + oprot->getTransport()->writeEnd(); + return; + } + + oprot->writeMessageBegin("get_role_names", ::apache::thrift::protocol::T_REPLY, seqid); + result.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->flush(); + oprot->getTransport()->writeEnd(); +} + void ThriftHiveMetastoreProcessor::process_grant_role(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot) { ThriftHiveMetastore_grant_role_args args; Index: metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.h =================================================================== --- metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.h (revision 1060489) +++ metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.h (working copy) @@ -60,6 +60,7 @@ virtual void get_index_names(std::vector & _return, const std::string& db_name, const std::string& tbl_name, const int16_t max_indexes) = 0; virtual bool create_role(const Role& role) = 0; virtual bool drop_role(const std::string& role_name) = 0; + virtual void get_role_names(std::vector & _return) = 0; virtual bool grant_role(const std::string& role_name, const std::string& principal_name, const PrincipalType::type principal_type, const std::string& grantor, const PrincipalType::type grantorType, const bool grant_option) = 0; virtual bool revoke_role(const std::string& role_name, const std::string& principal_name, const PrincipalType::type principal_type) = 0; virtual void list_roles(std::vector & _return, const std::string& principal_name, const PrincipalType::type principal_type) = 0; @@ -214,6 +215,9 @@ bool _return = false; return _return; } + void get_role_names(std::vector & /* _return */) { + return; + } bool grant_role(const std::string& /* role_name */, const std::string& /* principal_name */, const PrincipalType::type /* principal_type */, const std::string& /* grantor */, const PrincipalType::type /* grantorType */, const bool /* grant_option */) { bool _return = false; return _return; @@ -5535,6 +5539,102 @@ }; + +class ThriftHiveMetastore_get_role_names_args { + public: + + ThriftHiveMetastore_get_role_names_args() { + } + + virtual ~ThriftHiveMetastore_get_role_names_args() throw() {} + + + bool operator == (const ThriftHiveMetastore_get_role_names_args & /* rhs */) const + { + return true; + } + bool operator != (const ThriftHiveMetastore_get_role_names_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const ThriftHiveMetastore_get_role_names_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class ThriftHiveMetastore_get_role_names_pargs { + public: + + + virtual ~ThriftHiveMetastore_get_role_names_pargs() throw() {} + + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _ThriftHiveMetastore_get_role_names_result__isset { + _ThriftHiveMetastore_get_role_names_result__isset() : success(false), o1(false) {} + bool success; + bool o1; +} _ThriftHiveMetastore_get_role_names_result__isset; + +class ThriftHiveMetastore_get_role_names_result { + public: + + ThriftHiveMetastore_get_role_names_result() { + } + + virtual ~ThriftHiveMetastore_get_role_names_result() throw() {} + + std::vector success; + MetaException o1; + + _ThriftHiveMetastore_get_role_names_result__isset __isset; + + bool operator == (const ThriftHiveMetastore_get_role_names_result & rhs) const + { + if (!(success == rhs.success)) + return false; + if (!(o1 == rhs.o1)) + return false; + return true; + } + bool operator != (const ThriftHiveMetastore_get_role_names_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const ThriftHiveMetastore_get_role_names_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _ThriftHiveMetastore_get_role_names_presult__isset { + _ThriftHiveMetastore_get_role_names_presult__isset() : success(false), o1(false) {} + bool success; + bool o1; +} _ThriftHiveMetastore_get_role_names_presult__isset; + +class ThriftHiveMetastore_get_role_names_presult { + public: + + + virtual ~ThriftHiveMetastore_get_role_names_presult() throw() {} + + std::vector * success; + MetaException o1; + + _ThriftHiveMetastore_get_role_names_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + typedef struct _ThriftHiveMetastore_grant_role_args__isset { _ThriftHiveMetastore_grant_role_args__isset() : role_name(false), principal_name(false), principal_type(false), grantor(false), grantorType(false), grant_option(false) {} bool role_name; @@ -6484,6 +6584,9 @@ bool drop_role(const std::string& role_name); void send_drop_role(const std::string& role_name); bool recv_drop_role(); + void get_role_names(std::vector & _return); + void send_get_role_names(); + void recv_get_role_names(std::vector & _return); bool grant_role(const std::string& role_name, const std::string& principal_name, const PrincipalType::type principal_type, const std::string& grantor, const PrincipalType::type grantorType, const bool grant_option); void send_grant_role(const std::string& role_name, const std::string& principal_name, const PrincipalType::type principal_type, const std::string& grantor, const PrincipalType::type grantorType, const bool grant_option); bool recv_grant_role(); @@ -6558,6 +6661,7 @@ void process_get_index_names(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot); void process_create_role(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot); void process_drop_role(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot); + void process_get_role_names(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot); void process_grant_role(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot); void process_revoke_role(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot); void process_list_roles(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot); @@ -6614,6 +6718,7 @@ processMap_["get_index_names"] = &ThriftHiveMetastoreProcessor::process_get_index_names; processMap_["create_role"] = &ThriftHiveMetastoreProcessor::process_create_role; processMap_["drop_role"] = &ThriftHiveMetastoreProcessor::process_drop_role; + processMap_["get_role_names"] = &ThriftHiveMetastoreProcessor::process_get_role_names; processMap_["grant_role"] = &ThriftHiveMetastoreProcessor::process_grant_role; processMap_["revoke_role"] = &ThriftHiveMetastoreProcessor::process_revoke_role; processMap_["list_roles"] = &ThriftHiveMetastoreProcessor::process_list_roles; @@ -7137,6 +7242,18 @@ } } + void get_role_names(std::vector & _return) { + uint32_t sz = ifaces_.size(); + for (uint32_t i = 0; i < sz; ++i) { + if (i == sz - 1) { + ifaces_[i]->get_role_names(_return); + return; + } else { + ifaces_[i]->get_role_names(_return); + } + } + } + bool grant_role(const std::string& role_name, const std::string& principal_name, const PrincipalType::type principal_type, const std::string& grantor, const PrincipalType::type grantorType, const bool grant_option) { uint32_t sz = ifaces_.size(); for (uint32_t i = 0; i < sz; ++i) { Index: metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore_server.skeleton.cpp =================================================================== --- metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore_server.skeleton.cpp (revision 1060489) +++ metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore_server.skeleton.cpp (working copy) @@ -247,6 +247,11 @@ printf("drop_role\n"); } + void get_role_names(std::vector & _return) { + // Your implementation goes here + printf("get_role_names\n"); + } + bool grant_role(const std::string& role_name, const std::string& principal_name, const PrincipalType::type principal_type, const std::string& grantor, const PrincipalType::type grantorType, const bool grant_option) { // Your implementation goes here printf("grant_role\n"); Index: metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ThriftHiveMetastore.java =================================================================== --- metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ThriftHiveMetastore.java (revision 1060489) +++ metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ThriftHiveMetastore.java (working copy) @@ -123,6 +123,8 @@ public boolean drop_role(String role_name) throws MetaException, TException; + public List get_role_names() throws MetaException, TException; + public boolean grant_role(String role_name, String principal_name, PrincipalType principal_type, String grantor, PrincipalType grantorType, boolean grant_option) throws MetaException, TException; public boolean revoke_role(String role_name, String principal_name, PrincipalType principal_type) throws MetaException, TException; @@ -231,6 +233,8 @@ public void drop_role(String role_name, AsyncMethodCallback resultHandler) throws TException; + public void get_role_names(AsyncMethodCallback resultHandler) throws TException; + public void grant_role(String role_name, String principal_name, PrincipalType principal_type, String grantor, PrincipalType grantorType, boolean grant_option, AsyncMethodCallback resultHandler) throws TException; public void revoke_role(String role_name, String principal_name, PrincipalType principal_type, AsyncMethodCallback resultHandler) throws TException; @@ -2190,6 +2194,44 @@ throw new TApplicationException(TApplicationException.MISSING_RESULT, "drop_role failed: unknown result"); } + public List get_role_names() throws MetaException, TException + { + send_get_role_names(); + return recv_get_role_names(); + } + + public void send_get_role_names() throws TException + { + oprot_.writeMessageBegin(new TMessage("get_role_names", TMessageType.CALL, ++seqid_)); + get_role_names_args args = new get_role_names_args(); + args.write(oprot_); + oprot_.writeMessageEnd(); + oprot_.getTransport().flush(); + } + + public List recv_get_role_names() throws MetaException, TException + { + TMessage msg = iprot_.readMessageBegin(); + if (msg.type == TMessageType.EXCEPTION) { + TApplicationException x = TApplicationException.read(iprot_); + iprot_.readMessageEnd(); + throw x; + } + if (msg.seqid != seqid_) { + throw new TApplicationException(TApplicationException.BAD_SEQUENCE_ID, "get_role_names failed: out of sequence response"); + } + get_role_names_result result = new get_role_names_result(); + result.read(iprot_); + iprot_.readMessageEnd(); + if (result.isSetSuccess()) { + return result.success; + } + if (result.o1 != null) { + throw result.o1; + } + throw new TApplicationException(TApplicationException.MISSING_RESULT, "get_role_names failed: unknown result"); + } + public boolean grant_role(String role_name, String principal_name, PrincipalType principal_type, String grantor, PrincipalType grantorType, boolean grant_option) throws MetaException, TException { send_grant_role(role_name, principal_name, principal_type, grantor, grantorType, grant_option); @@ -4083,6 +4125,34 @@ } } + public void get_role_names(AsyncMethodCallback resultHandler) throws TException { + checkReady(); + get_role_names_call method_call = new get_role_names_call(resultHandler, this, protocolFactory, transport); + manager.call(method_call); + } + + public static class get_role_names_call extends TAsyncMethodCall { + public get_role_names_call(AsyncMethodCallback resultHandler, TAsyncClient client, TProtocolFactory protocolFactory, TNonblockingTransport transport) throws TException { + super(client, protocolFactory, transport, resultHandler, false); + } + + public void write_args(TProtocol prot) throws TException { + prot.writeMessageBegin(new TMessage("get_role_names", TMessageType.CALL, 0)); + get_role_names_args args = new get_role_names_args(); + args.write(prot); + prot.writeMessageEnd(); + } + + public List getResult() throws MetaException, TException { + if (getState() != State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + TMemoryInputTransport memoryTransport = new TMemoryInputTransport(getFrameBuffer().array()); + TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_get_role_names(); + } + } + public void grant_role(String role_name, String principal_name, PrincipalType principal_type, String grantor, PrincipalType grantorType, boolean grant_option, AsyncMethodCallback resultHandler) throws TException { checkReady(); grant_role_call method_call = new grant_role_call(role_name, principal_name, principal_type, grantor, grantorType, grant_option, resultHandler, this, protocolFactory, transport); @@ -4389,6 +4459,7 @@ processMap_.put("get_index_names", new get_index_names()); processMap_.put("create_role", new create_role()); processMap_.put("drop_role", new drop_role()); + processMap_.put("get_role_names", new get_role_names()); processMap_.put("grant_role", new grant_role()); processMap_.put("revoke_role", new revoke_role()); processMap_.put("list_roles", new list_roles()); @@ -6219,6 +6290,44 @@ } + private class get_role_names implements ProcessFunction { + public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException + { + get_role_names_args args = new get_role_names_args(); + try { + args.read(iprot); + } catch (TProtocolException e) { + iprot.readMessageEnd(); + TApplicationException x = new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage()); + oprot.writeMessageBegin(new TMessage("get_role_names", TMessageType.EXCEPTION, seqid)); + x.write(oprot); + oprot.writeMessageEnd(); + oprot.getTransport().flush(); + return; + } + iprot.readMessageEnd(); + get_role_names_result result = new get_role_names_result(); + try { + result.success = iface_.get_role_names(); + } catch (MetaException o1) { + result.o1 = o1; + } catch (Throwable th) { + LOGGER.error("Internal error processing get_role_names", th); + TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing get_role_names"); + oprot.writeMessageBegin(new TMessage("get_role_names", TMessageType.EXCEPTION, seqid)); + x.write(oprot); + oprot.writeMessageEnd(); + oprot.getTransport().flush(); + return; + } + oprot.writeMessageBegin(new TMessage("get_role_names", TMessageType.REPLY, seqid)); + result.write(oprot); + oprot.writeMessageEnd(); + oprot.getTransport().flush(); + } + + } + private class grant_role implements ProcessFunction { public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException { @@ -45213,39 +45322,14 @@ } - public static class grant_role_args implements TBase, java.io.Serializable, Cloneable { - private static final TStruct STRUCT_DESC = new TStruct("grant_role_args"); + public static class get_role_names_args implements TBase, java.io.Serializable, Cloneable { + private static final TStruct STRUCT_DESC = new TStruct("get_role_names_args"); - private static final TField ROLE_NAME_FIELD_DESC = new TField("role_name", TType.STRING, (short)1); - private static final TField PRINCIPAL_NAME_FIELD_DESC = new TField("principal_name", TType.STRING, (short)2); - private static final TField PRINCIPAL_TYPE_FIELD_DESC = new TField("principal_type", TType.I32, (short)3); - private static final TField GRANTOR_FIELD_DESC = new TField("grantor", TType.STRING, (short)4); - private static final TField GRANTOR_TYPE_FIELD_DESC = new TField("grantorType", TType.I32, (short)5); - private static final TField GRANT_OPTION_FIELD_DESC = new TField("grant_option", TType.BOOL, (short)6); - private String role_name; - private String principal_name; - private PrincipalType principal_type; - private String grantor; - private PrincipalType grantorType; - private boolean grant_option; /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements TFieldIdEnum { - ROLE_NAME((short)1, "role_name"), - PRINCIPAL_NAME((short)2, "principal_name"), - /** - * - * @see PrincipalType - */ - PRINCIPAL_TYPE((short)3, "principal_type"), - GRANTOR((short)4, "grantor"), - /** - * - * @see PrincipalType - */ - GRANTOR_TYPE((short)5, "grantorType"), - GRANT_OPTION((short)6, "grant_option"); +; private static final Map byName = new HashMap(); @@ -45260,18 +45344,6 @@ */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { - case 1: // ROLE_NAME - return ROLE_NAME; - case 2: // PRINCIPAL_NAME - return PRINCIPAL_NAME; - case 3: // PRINCIPAL_TYPE - return PRINCIPAL_TYPE; - case 4: // GRANTOR - return GRANTOR; - case 5: // GRANTOR_TYPE - return GRANTOR_TYPE; - case 6: // GRANT_OPTION - return GRANT_OPTION; default: return null; } @@ -45310,154 +45382,777 @@ return _fieldName; } } - - // isset id assignments - private static final int __GRANT_OPTION_ISSET_ID = 0; - private BitSet __isset_bit_vector = new BitSet(1); - public static final Map<_Fields, FieldMetaData> metaDataMap; static { Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.ROLE_NAME, new FieldMetaData("role_name", TFieldRequirementType.DEFAULT, - new FieldValueMetaData(TType.STRING))); - tmpMap.put(_Fields.PRINCIPAL_NAME, new FieldMetaData("principal_name", TFieldRequirementType.DEFAULT, - new FieldValueMetaData(TType.STRING))); - tmpMap.put(_Fields.PRINCIPAL_TYPE, new FieldMetaData("principal_type", TFieldRequirementType.DEFAULT, - new EnumMetaData(TType.ENUM, PrincipalType.class))); - tmpMap.put(_Fields.GRANTOR, new FieldMetaData("grantor", TFieldRequirementType.DEFAULT, - new FieldValueMetaData(TType.STRING))); - tmpMap.put(_Fields.GRANTOR_TYPE, new FieldMetaData("grantorType", TFieldRequirementType.DEFAULT, - new EnumMetaData(TType.ENUM, PrincipalType.class))); - tmpMap.put(_Fields.GRANT_OPTION, new FieldMetaData("grant_option", TFieldRequirementType.DEFAULT, - new FieldValueMetaData(TType.BOOL))); metaDataMap = Collections.unmodifiableMap(tmpMap); - FieldMetaData.addStructMetaDataMap(grant_role_args.class, metaDataMap); - } - - public grant_role_args() { + FieldMetaData.addStructMetaDataMap(get_role_names_args.class, metaDataMap); } - public grant_role_args( - String role_name, - String principal_name, - PrincipalType principal_type, - String grantor, - PrincipalType grantorType, - boolean grant_option) - { - this(); - this.role_name = role_name; - this.principal_name = principal_name; - this.principal_type = principal_type; - this.grantor = grantor; - this.grantorType = grantorType; - this.grant_option = grant_option; - setGrant_optionIsSet(true); + public get_role_names_args() { } /** * Performs a deep copy on other. */ - public grant_role_args(grant_role_args other) { - __isset_bit_vector.clear(); - __isset_bit_vector.or(other.__isset_bit_vector); - if (other.isSetRole_name()) { - this.role_name = other.role_name; - } - if (other.isSetPrincipal_name()) { - this.principal_name = other.principal_name; - } - if (other.isSetPrincipal_type()) { - this.principal_type = other.principal_type; - } - if (other.isSetGrantor()) { - this.grantor = other.grantor; - } - if (other.isSetGrantorType()) { - this.grantorType = other.grantorType; - } - this.grant_option = other.grant_option; + public get_role_names_args(get_role_names_args other) { } - public grant_role_args deepCopy() { - return new grant_role_args(this); + public get_role_names_args deepCopy() { + return new get_role_names_args(this); } @Override public void clear() { - this.role_name = null; - this.principal_name = null; - this.principal_type = null; - this.grantor = null; - this.grantorType = null; - setGrant_optionIsSet(false); - this.grant_option = false; - } - - public String getRole_name() { - return this.role_name; } - public void setRole_name(String role_name) { - this.role_name = role_name; + public void setFieldValue(_Fields field, Object value) { + switch (field) { + } } - public void unsetRole_name() { - this.role_name = null; + public Object getFieldValue(_Fields field) { + switch (field) { + } + throw new IllegalStateException(); } - /** Returns true if field role_name is set (has been asigned a value) and false otherwise */ - public boolean isSetRole_name() { - return this.role_name != null; - } + /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } - public void setRole_nameIsSet(boolean value) { - if (!value) { - this.role_name = null; + switch (field) { } + throw new IllegalStateException(); } - public String getPrincipal_name() { - return this.principal_name; + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof get_role_names_args) + return this.equals((get_role_names_args)that); + return false; } - public void setPrincipal_name(String principal_name) { - this.principal_name = principal_name; - } + public boolean equals(get_role_names_args that) { + if (that == null) + return false; - public void unsetPrincipal_name() { - this.principal_name = null; + return true; } - /** Returns true if field principal_name is set (has been asigned a value) and false otherwise */ - public boolean isSetPrincipal_name() { - return this.principal_name != null; + @Override + public int hashCode() { + return 0; } - public void setPrincipal_nameIsSet(boolean value) { - if (!value) { - this.principal_name = null; + public int compareTo(get_role_names_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); } - } - /** - * - * @see PrincipalType - */ - public PrincipalType getPrincipal_type() { - return this.principal_type; + int lastComparison = 0; + get_role_names_args typedOther = (get_role_names_args)other; + + return 0; } - /** - * - * @see PrincipalType - */ - public void setPrincipal_type(PrincipalType principal_type) { - this.principal_type = principal_type; + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); } - public void unsetPrincipal_type() { - this.principal_type = null; + public void read(TProtocol iprot) throws TException { + TField field; + iprot.readStructBegin(); + while (true) + { + field = iprot.readFieldBegin(); + if (field.type == TType.STOP) { + break; + } + switch (field.id) { + default: + TProtocolUtil.skip(iprot, field.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + validate(); + } + + public void write(TProtocol oprot) throws TException { + validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("get_role_names_args("); + boolean first = true; + + sb.append(")"); + return sb.toString(); + } + + public void validate() throws TException { + // check for required fields + } + + } + + public static class get_role_names_result implements TBase, java.io.Serializable, Cloneable { + private static final TStruct STRUCT_DESC = new TStruct("get_role_names_result"); + + private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.LIST, (short)0); + private static final TField O1_FIELD_DESC = new TField("o1", TType.STRUCT, (short)1); + + private List success; + private MetaException o1; + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements TFieldIdEnum { + SUCCESS((short)0, "success"), + O1((short)1, "o1"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + case 1: // O1 + return O1; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + + public static final Map<_Fields, FieldMetaData> metaDataMap; + static { + Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, + new ListMetaData(TType.LIST, + new FieldValueMetaData(TType.STRING)))); + tmpMap.put(_Fields.O1, new FieldMetaData("o1", TFieldRequirementType.DEFAULT, + new FieldValueMetaData(TType.STRUCT))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + FieldMetaData.addStructMetaDataMap(get_role_names_result.class, metaDataMap); + } + + public get_role_names_result() { + } + + public get_role_names_result( + List success, + MetaException o1) + { + this(); + this.success = success; + this.o1 = o1; + } + + /** + * Performs a deep copy on other. + */ + public get_role_names_result(get_role_names_result other) { + if (other.isSetSuccess()) { + List __this__success = new ArrayList(); + for (String other_element : other.success) { + __this__success.add(other_element); + } + this.success = __this__success; + } + if (other.isSetO1()) { + this.o1 = new MetaException(other.o1); + } + } + + public get_role_names_result deepCopy() { + return new get_role_names_result(this); + } + + @Override + public void clear() { + this.success = null; + this.o1 = null; + } + + public int getSuccessSize() { + return (this.success == null) ? 0 : this.success.size(); + } + + public java.util.Iterator getSuccessIterator() { + return (this.success == null) ? null : this.success.iterator(); + } + + public void addToSuccess(String elem) { + if (this.success == null) { + this.success = new ArrayList(); + } + this.success.add(elem); + } + + public List getSuccess() { + return this.success; + } + + public void setSuccess(List success) { + this.success = success; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been asigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public MetaException getO1() { + return this.o1; + } + + public void setO1(MetaException o1) { + this.o1 = o1; + } + + public void unsetO1() { + this.o1 = null; + } + + /** Returns true if field o1 is set (has been asigned a value) and false otherwise */ + public boolean isSetO1() { + return this.o1 != null; + } + + public void setO1IsSet(boolean value) { + if (!value) { + this.o1 = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((List)value); + } + break; + + case O1: + if (value == null) { + unsetO1(); + } else { + setO1((MetaException)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + case O1: + return getO1(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + case O1: + return isSetO1(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof get_role_names_result) + return this.equals((get_role_names_result)that); + return false; + } + + public boolean equals(get_role_names_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + boolean this_present_o1 = true && this.isSetO1(); + boolean that_present_o1 = true && that.isSetO1(); + if (this_present_o1 || that_present_o1) { + if (!(this_present_o1 && that_present_o1)) + return false; + if (!this.o1.equals(that.o1)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(get_role_names_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + get_role_names_result typedOther = (get_role_names_result)other; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = TBaseHelper.compareTo(this.success, typedOther.success); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetO1()).compareTo(typedOther.isSetO1()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetO1()) { + lastComparison = TBaseHelper.compareTo(this.o1, typedOther.o1); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(TProtocol iprot) throws TException { + TField field; + iprot.readStructBegin(); + while (true) + { + field = iprot.readFieldBegin(); + if (field.type == TType.STOP) { + break; + } + switch (field.id) { + case 0: // SUCCESS + if (field.type == TType.LIST) { + { + TList _list212 = iprot.readListBegin(); + this.success = new ArrayList(_list212.size); + for (int _i213 = 0; _i213 < _list212.size; ++_i213) + { + String _elem214; + _elem214 = iprot.readString(); + this.success.add(_elem214); + } + iprot.readListEnd(); + } + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + case 1: // O1 + if (field.type == TType.STRUCT) { + this.o1 = new MetaException(); + this.o1.read(iprot); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + default: + TProtocolUtil.skip(iprot, field.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + validate(); + } + + public void write(TProtocol oprot) throws TException { + oprot.writeStructBegin(STRUCT_DESC); + + if (this.isSetSuccess()) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + { + oprot.writeListBegin(new TList(TType.STRING, this.success.size())); + for (String _iter215 : this.success) + { + oprot.writeString(_iter215); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } else if (this.isSetO1()) { + oprot.writeFieldBegin(O1_FIELD_DESC); + this.o1.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("get_role_names_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + if (!first) sb.append(", "); + sb.append("o1:"); + if (this.o1 == null) { + sb.append("null"); + } else { + sb.append(this.o1); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws TException { + // check for required fields + } + + } + + public static class grant_role_args implements TBase, java.io.Serializable, Cloneable { + private static final TStruct STRUCT_DESC = new TStruct("grant_role_args"); + + private static final TField ROLE_NAME_FIELD_DESC = new TField("role_name", TType.STRING, (short)1); + private static final TField PRINCIPAL_NAME_FIELD_DESC = new TField("principal_name", TType.STRING, (short)2); + private static final TField PRINCIPAL_TYPE_FIELD_DESC = new TField("principal_type", TType.I32, (short)3); + private static final TField GRANTOR_FIELD_DESC = new TField("grantor", TType.STRING, (short)4); + private static final TField GRANTOR_TYPE_FIELD_DESC = new TField("grantorType", TType.I32, (short)5); + private static final TField GRANT_OPTION_FIELD_DESC = new TField("grant_option", TType.BOOL, (short)6); + + private String role_name; + private String principal_name; + private PrincipalType principal_type; + private String grantor; + private PrincipalType grantorType; + private boolean grant_option; + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements TFieldIdEnum { + ROLE_NAME((short)1, "role_name"), + PRINCIPAL_NAME((short)2, "principal_name"), + /** + * + * @see PrincipalType + */ + PRINCIPAL_TYPE((short)3, "principal_type"), + GRANTOR((short)4, "grantor"), + /** + * + * @see PrincipalType + */ + GRANTOR_TYPE((short)5, "grantorType"), + GRANT_OPTION((short)6, "grant_option"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // ROLE_NAME + return ROLE_NAME; + case 2: // PRINCIPAL_NAME + return PRINCIPAL_NAME; + case 3: // PRINCIPAL_TYPE + return PRINCIPAL_TYPE; + case 4: // GRANTOR + return GRANTOR; + case 5: // GRANTOR_TYPE + return GRANTOR_TYPE; + case 6: // GRANT_OPTION + return GRANT_OPTION; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __GRANT_OPTION_ISSET_ID = 0; + private BitSet __isset_bit_vector = new BitSet(1); + + public static final Map<_Fields, FieldMetaData> metaDataMap; + static { + Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.ROLE_NAME, new FieldMetaData("role_name", TFieldRequirementType.DEFAULT, + new FieldValueMetaData(TType.STRING))); + tmpMap.put(_Fields.PRINCIPAL_NAME, new FieldMetaData("principal_name", TFieldRequirementType.DEFAULT, + new FieldValueMetaData(TType.STRING))); + tmpMap.put(_Fields.PRINCIPAL_TYPE, new FieldMetaData("principal_type", TFieldRequirementType.DEFAULT, + new EnumMetaData(TType.ENUM, PrincipalType.class))); + tmpMap.put(_Fields.GRANTOR, new FieldMetaData("grantor", TFieldRequirementType.DEFAULT, + new FieldValueMetaData(TType.STRING))); + tmpMap.put(_Fields.GRANTOR_TYPE, new FieldMetaData("grantorType", TFieldRequirementType.DEFAULT, + new EnumMetaData(TType.ENUM, PrincipalType.class))); + tmpMap.put(_Fields.GRANT_OPTION, new FieldMetaData("grant_option", TFieldRequirementType.DEFAULT, + new FieldValueMetaData(TType.BOOL))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + FieldMetaData.addStructMetaDataMap(grant_role_args.class, metaDataMap); + } + + public grant_role_args() { + } + + public grant_role_args( + String role_name, + String principal_name, + PrincipalType principal_type, + String grantor, + PrincipalType grantorType, + boolean grant_option) + { + this(); + this.role_name = role_name; + this.principal_name = principal_name; + this.principal_type = principal_type; + this.grantor = grantor; + this.grantorType = grantorType; + this.grant_option = grant_option; + setGrant_optionIsSet(true); + } + + /** + * Performs a deep copy on other. + */ + public grant_role_args(grant_role_args other) { + __isset_bit_vector.clear(); + __isset_bit_vector.or(other.__isset_bit_vector); + if (other.isSetRole_name()) { + this.role_name = other.role_name; + } + if (other.isSetPrincipal_name()) { + this.principal_name = other.principal_name; + } + if (other.isSetPrincipal_type()) { + this.principal_type = other.principal_type; + } + if (other.isSetGrantor()) { + this.grantor = other.grantor; + } + if (other.isSetGrantorType()) { + this.grantorType = other.grantorType; + } + this.grant_option = other.grant_option; + } + + public grant_role_args deepCopy() { + return new grant_role_args(this); + } + + @Override + public void clear() { + this.role_name = null; + this.principal_name = null; + this.principal_type = null; + this.grantor = null; + this.grantorType = null; + setGrant_optionIsSet(false); + this.grant_option = false; + } + + public String getRole_name() { + return this.role_name; + } + + public void setRole_name(String role_name) { + this.role_name = role_name; + } + + public void unsetRole_name() { + this.role_name = null; + } + + /** Returns true if field role_name is set (has been asigned a value) and false otherwise */ + public boolean isSetRole_name() { + return this.role_name != null; + } + + public void setRole_nameIsSet(boolean value) { + if (!value) { + this.role_name = null; + } + } + + public String getPrincipal_name() { + return this.principal_name; + } + + public void setPrincipal_name(String principal_name) { + this.principal_name = principal_name; + } + + public void unsetPrincipal_name() { + this.principal_name = null; + } + + /** Returns true if field principal_name is set (has been asigned a value) and false otherwise */ + public boolean isSetPrincipal_name() { + return this.principal_name != null; + } + + public void setPrincipal_nameIsSet(boolean value) { + if (!value) { + this.principal_name = null; + } + } + + /** + * + * @see PrincipalType + */ + public PrincipalType getPrincipal_type() { + return this.principal_type; + } + + /** + * + * @see PrincipalType + */ + public void setPrincipal_type(PrincipalType principal_type) { + this.principal_type = principal_type; + } + + public void unsetPrincipal_type() { + this.principal_type = null; } /** Returns true if field principal_type is set (has been asigned a value) and false otherwise */ @@ -47845,14 +48540,14 @@ case 0: // SUCCESS if (field.type == TType.LIST) { { - TList _list212 = iprot.readListBegin(); - this.success = new ArrayList(_list212.size); - for (int _i213 = 0; _i213 < _list212.size; ++_i213) + TList _list216 = iprot.readListBegin(); + this.success = new ArrayList(_list216.size); + for (int _i217 = 0; _i217 < _list216.size; ++_i217) { - Role _elem214; - _elem214 = new Role(); - _elem214.read(iprot); - this.success.add(_elem214); + Role _elem218; + _elem218 = new Role(); + _elem218.read(iprot); + this.success.add(_elem218); } iprot.readListEnd(); } @@ -47884,9 +48579,9 @@ oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new TList(TType.STRUCT, this.success.size())); - for (Role _iter215 : this.success) + for (Role _iter219 : this.success) { - _iter215.write(oprot); + _iter219.write(oprot); } oprot.writeListEnd(); } @@ -48331,13 +49026,13 @@ case 3: // GROUP_NAMES if (field.type == TType.LIST) { { - TList _list216 = iprot.readListBegin(); - this.group_names = new ArrayList(_list216.size); - for (int _i217 = 0; _i217 < _list216.size; ++_i217) + TList _list220 = iprot.readListBegin(); + this.group_names = new ArrayList(_list220.size); + for (int _i221 = 0; _i221 < _list220.size; ++_i221) { - String _elem218; - _elem218 = iprot.readString(); - this.group_names.add(_elem218); + String _elem222; + _elem222 = iprot.readString(); + this.group_names.add(_elem222); } iprot.readListEnd(); } @@ -48372,9 +49067,9 @@ oprot.writeFieldBegin(GROUP_NAMES_FIELD_DESC); { oprot.writeListBegin(new TList(TType.STRING, this.group_names.size())); - for (String _iter219 : this.group_names) + for (String _iter223 : this.group_names) { - oprot.writeString(_iter219); + oprot.writeString(_iter223); } oprot.writeListEnd(); } @@ -49573,14 +50268,14 @@ case 0: // SUCCESS if (field.type == TType.LIST) { { - TList _list220 = iprot.readListBegin(); - this.success = new ArrayList(_list220.size); - for (int _i221 = 0; _i221 < _list220.size; ++_i221) + TList _list224 = iprot.readListBegin(); + this.success = new ArrayList(_list224.size); + for (int _i225 = 0; _i225 < _list224.size; ++_i225) { - HiveObjectPrivilege _elem222; - _elem222 = new HiveObjectPrivilege(); - _elem222.read(iprot); - this.success.add(_elem222); + HiveObjectPrivilege _elem226; + _elem226 = new HiveObjectPrivilege(); + _elem226.read(iprot); + this.success.add(_elem226); } iprot.readListEnd(); } @@ -49612,9 +50307,9 @@ oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new TList(TType.STRUCT, this.success.size())); - for (HiveObjectPrivilege _iter223 : this.success) + for (HiveObjectPrivilege _iter227 : this.success) { - _iter223.write(oprot); + _iter227.write(oprot); } oprot.writeListEnd(); } Index: metastore/src/gen/thrift/gen-php/hive_metastore/ThriftHiveMetastore.php =================================================================== --- metastore/src/gen/thrift/gen-php/hive_metastore/ThriftHiveMetastore.php (revision 1060489) +++ metastore/src/gen/thrift/gen-php/hive_metastore/ThriftHiveMetastore.php (working copy) @@ -55,6 +55,7 @@ public function get_index_names($db_name, $tbl_name, $max_indexes); public function create_role($role); public function drop_role($role_name); + public function get_role_names(); public function grant_role($role_name, $principal_name, $principal_type, $grantor, $grantorType, $grant_option); public function revoke_role($role_name, $principal_name, $principal_type); public function list_roles($principal_name, $principal_type); @@ -2666,6 +2667,59 @@ throw new Exception("drop_role failed: unknown result"); } + public function get_role_names() + { + $this->send_get_role_names(); + return $this->recv_get_role_names(); + } + + public function send_get_role_names() + { + $args = new metastore_ThriftHiveMetastore_get_role_names_args(); + $bin_accel = ($this->output_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'get_role_names', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('get_role_names', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_get_role_names() + { + $bin_accel = ($this->input_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, 'metastore_ThriftHiveMetastore_get_role_names_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new metastore_ThriftHiveMetastore_get_role_names_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + if ($result->o1 !== null) { + throw $result->o1; + } + throw new Exception("get_role_names failed: unknown result"); + } + public function grant_role($role_name, $principal_name, $principal_type, $grantor, $grantorType, $grant_option) { $this->send_grant_role($role_name, $principal_name, $principal_type, $grantor, $grantorType, $grant_option); @@ -13464,6 +13518,176 @@ } +class metastore_ThriftHiveMetastore_get_role_names_args { + static $_TSPEC; + + + public function __construct() { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + ); + } + } + + public function getName() { + return 'ThriftHiveMetastore_get_role_names_args'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ThriftHiveMetastore_get_role_names_args'); + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class metastore_ThriftHiveMetastore_get_role_names_result { + static $_TSPEC; + + public $success = null; + public $o1 = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 0 => array( + 'var' => 'success', + 'type' => TType::LST, + 'etype' => TType::STRING, + 'elem' => array( + 'type' => TType::STRING, + ), + ), + 1 => array( + 'var' => 'o1', + 'type' => TType::STRUCT, + 'class' => 'metastore_MetaException', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['success'])) { + $this->success = $vals['success']; + } + if (isset($vals['o1'])) { + $this->o1 = $vals['o1']; + } + } + } + + public function getName() { + return 'ThriftHiveMetastore_get_role_names_result'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 0: + if ($ftype == TType::LST) { + $this->success = array(); + $_size374 = 0; + $_etype377 = 0; + $xfer += $input->readListBegin($_etype377, $_size374); + for ($_i378 = 0; $_i378 < $_size374; ++$_i378) + { + $elem379 = null; + $xfer += $input->readString($elem379); + $this->success []= $elem379; + } + $xfer += $input->readListEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + case 1: + if ($ftype == TType::STRUCT) { + $this->o1 = new metastore_MetaException(); + $xfer += $this->o1->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ThriftHiveMetastore_get_role_names_result'); + if ($this->success !== null) { + if (!is_array($this->success)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('success', TType::LST, 0); + { + $output->writeListBegin(TType::STRING, count($this->success)); + { + foreach ($this->success as $iter380) + { + $xfer += $output->writeString($iter380); + } + } + $output->writeListEnd(); + } + $xfer += $output->writeFieldEnd(); + } + if ($this->o1 !== null) { + $xfer += $output->writeFieldBegin('o1', TType::STRUCT, 1); + $xfer += $this->o1->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + class metastore_ThriftHiveMetastore_grant_role_args { static $_TSPEC; @@ -14085,15 +14309,15 @@ case 0: if ($ftype == TType::LST) { $this->success = array(); - $_size374 = 0; - $_etype377 = 0; - $xfer += $input->readListBegin($_etype377, $_size374); - for ($_i378 = 0; $_i378 < $_size374; ++$_i378) + $_size381 = 0; + $_etype384 = 0; + $xfer += $input->readListBegin($_etype384, $_size381); + for ($_i385 = 0; $_i385 < $_size381; ++$_i385) { - $elem379 = null; - $elem379 = new metastore_Role(); - $xfer += $elem379->read($input); - $this->success []= $elem379; + $elem386 = null; + $elem386 = new metastore_Role(); + $xfer += $elem386->read($input); + $this->success []= $elem386; } $xfer += $input->readListEnd(); } else { @@ -14129,9 +14353,9 @@ { $output->writeListBegin(TType::STRUCT, count($this->success)); { - foreach ($this->success as $iter380) + foreach ($this->success as $iter387) { - $xfer += $iter380->write($output); + $xfer += $iter387->write($output); } } $output->writeListEnd(); @@ -14229,14 +14453,14 @@ case 3: if ($ftype == TType::LST) { $this->group_names = array(); - $_size381 = 0; - $_etype384 = 0; - $xfer += $input->readListBegin($_etype384, $_size381); - for ($_i385 = 0; $_i385 < $_size381; ++$_i385) + $_size388 = 0; + $_etype391 = 0; + $xfer += $input->readListBegin($_etype391, $_size388); + for ($_i392 = 0; $_i392 < $_size388; ++$_i392) { - $elem386 = null; - $xfer += $input->readString($elem386); - $this->group_names []= $elem386; + $elem393 = null; + $xfer += $input->readString($elem393); + $this->group_names []= $elem393; } $xfer += $input->readListEnd(); } else { @@ -14277,9 +14501,9 @@ { $output->writeListBegin(TType::STRING, count($this->group_names)); { - foreach ($this->group_names as $iter387) + foreach ($this->group_names as $iter394) { - $xfer += $output->writeString($iter387); + $xfer += $output->writeString($iter394); } } $output->writeListEnd(); @@ -14566,15 +14790,15 @@ case 0: if ($ftype == TType::LST) { $this->success = array(); - $_size388 = 0; - $_etype391 = 0; - $xfer += $input->readListBegin($_etype391, $_size388); - for ($_i392 = 0; $_i392 < $_size388; ++$_i392) + $_size395 = 0; + $_etype398 = 0; + $xfer += $input->readListBegin($_etype398, $_size395); + for ($_i399 = 0; $_i399 < $_size395; ++$_i399) { - $elem393 = null; - $elem393 = new metastore_HiveObjectPrivilege(); - $xfer += $elem393->read($input); - $this->success []= $elem393; + $elem400 = null; + $elem400 = new metastore_HiveObjectPrivilege(); + $xfer += $elem400->read($input); + $this->success []= $elem400; } $xfer += $input->readListEnd(); } else { @@ -14610,9 +14834,9 @@ { $output->writeListBegin(TType::STRUCT, count($this->success)); { - foreach ($this->success as $iter394) + foreach ($this->success as $iter401) { - $xfer += $iter394->write($output); + $xfer += $iter401->write($output); } } $output->writeListEnd(); Index: metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore-remote =================================================================== --- metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore-remote (revision 1060489) +++ metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore-remote (working copy) @@ -66,6 +66,7 @@ print ' get_index_names(string db_name, string tbl_name, i16 max_indexes)' print ' bool create_role(Role role)' print ' bool drop_role(string role_name)' + print ' get_role_names()' print ' bool grant_role(string role_name, string principal_name, PrincipalType principal_type, string grantor, PrincipalType grantorType, bool grant_option)' print ' bool revoke_role(string role_name, string principal_name, PrincipalType principal_type)' print ' list_roles(string principal_name, PrincipalType principal_type)' @@ -393,6 +394,12 @@ sys.exit(1) pp.pprint(client.drop_role(args[0],)) +elif cmd == 'get_role_names': + if len(args) != 0: + print 'get_role_names requires 0 args' + sys.exit(1) + pp.pprint(client.get_role_names()) + elif cmd == 'grant_role': if len(args) != 6: print 'grant_role requires 6 args' Index: metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore.py =================================================================== --- metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore.py (revision 1060489) +++ metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore.py (working copy) @@ -397,6 +397,9 @@ """ pass + def get_role_names(self, ): + pass + def grant_role(self, role_name, principal_name, principal_type, grantor, grantorType, grant_option): """ Parameters: @@ -2101,6 +2104,33 @@ raise result.o1 raise TApplicationException(TApplicationException.MISSING_RESULT, "drop_role failed: unknown result"); + def get_role_names(self, ): + self.send_get_role_names() + return self.recv_get_role_names() + + def send_get_role_names(self, ): + self._oprot.writeMessageBegin('get_role_names', TMessageType.CALL, self._seqid) + args = get_role_names_args() + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_get_role_names(self, ): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = get_role_names_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + if result.success != None: + return result.success + if result.o1 != None: + raise result.o1 + raise TApplicationException(TApplicationException.MISSING_RESULT, "get_role_names failed: unknown result"); + def grant_role(self, role_name, principal_name, principal_type, grantor, grantorType, grant_option): """ Parameters: @@ -2398,6 +2428,7 @@ self._processMap["get_index_names"] = Processor.process_get_index_names self._processMap["create_role"] = Processor.process_create_role self._processMap["drop_role"] = Processor.process_drop_role + self._processMap["get_role_names"] = Processor.process_get_role_names self._processMap["grant_role"] = Processor.process_grant_role self._processMap["revoke_role"] = Processor.process_revoke_role self._processMap["list_roles"] = Processor.process_list_roles @@ -3135,6 +3166,20 @@ oprot.writeMessageEnd() oprot.trans.flush() + def process_get_role_names(self, seqid, iprot, oprot): + args = get_role_names_args() + args.read(iprot) + iprot.readMessageEnd() + result = get_role_names_result() + try: + result.success = self._handler.get_role_names() + except MetaException, o1: + result.o1 = o1 + oprot.writeMessageBegin("get_role_names", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + def process_grant_role(self, seqid, iprot, oprot): args = grant_role_args() args.read(iprot) @@ -10577,6 +10622,126 @@ def __ne__(self, other): return not (self == other) +class get_role_names_args: + + thrift_spec = ( + ) + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_role_names_args') + oprot.writeFieldStop() + oprot.writeStructEnd() + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class get_role_names_result: + """ + Attributes: + - success + - o1 + """ + + thrift_spec = ( + (0, TType.LIST, 'success', (TType.STRING,None), None, ), # 0 + (1, TType.STRUCT, 'o1', (MetaException, MetaException.thrift_spec), None, ), # 1 + ) + + def __init__(self, success=None, o1=None,): + self.success = success + self.o1 = o1 + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype377, _size374) = iprot.readListBegin() + for _i378 in xrange(_size374): + _elem379 = iprot.readString(); + self.success.append(_elem379) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.o1 = MetaException() + self.o1.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('get_role_names_result') + if self.success != None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.STRING, len(self.success)) + for iter380 in self.success: + oprot.writeString(iter380) + oprot.writeListEnd() + oprot.writeFieldEnd() + if self.o1 != None: + oprot.writeFieldBegin('o1', TType.STRUCT, 1) + self.o1.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + class grant_role_args: """ Attributes: @@ -11020,11 +11185,11 @@ if fid == 0: if ftype == TType.LIST: self.success = [] - (_etype377, _size374) = iprot.readListBegin() - for _i378 in xrange(_size374): - _elem379 = Role() - _elem379.read(iprot) - self.success.append(_elem379) + (_etype384, _size381) = iprot.readListBegin() + for _i385 in xrange(_size381): + _elem386 = Role() + _elem386.read(iprot) + self.success.append(_elem386) iprot.readListEnd() else: iprot.skip(ftype) @@ -11047,8 +11212,8 @@ if self.success != None: oprot.writeFieldBegin('success', TType.LIST, 0) oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter380 in self.success: - iter380.write(oprot) + for iter387 in self.success: + iter387.write(oprot) oprot.writeListEnd() oprot.writeFieldEnd() if self.o1 != None: @@ -11115,10 +11280,10 @@ elif fid == 3: if ftype == TType.LIST: self.group_names = [] - (_etype384, _size381) = iprot.readListBegin() - for _i385 in xrange(_size381): - _elem386 = iprot.readString(); - self.group_names.append(_elem386) + (_etype391, _size388) = iprot.readListBegin() + for _i392 in xrange(_size388): + _elem393 = iprot.readString(); + self.group_names.append(_elem393) iprot.readListEnd() else: iprot.skip(ftype) @@ -11143,8 +11308,8 @@ if self.group_names != None: oprot.writeFieldBegin('group_names', TType.LIST, 3) oprot.writeListBegin(TType.STRING, len(self.group_names)) - for iter387 in self.group_names: - oprot.writeString(iter387) + for iter394 in self.group_names: + oprot.writeString(iter394) oprot.writeListEnd() oprot.writeFieldEnd() oprot.writeFieldStop() @@ -11348,11 +11513,11 @@ if fid == 0: if ftype == TType.LIST: self.success = [] - (_etype391, _size388) = iprot.readListBegin() - for _i392 in xrange(_size388): - _elem393 = HiveObjectPrivilege() - _elem393.read(iprot) - self.success.append(_elem393) + (_etype398, _size395) = iprot.readListBegin() + for _i399 in xrange(_size395): + _elem400 = HiveObjectPrivilege() + _elem400.read(iprot) + self.success.append(_elem400) iprot.readListEnd() else: iprot.skip(ftype) @@ -11375,8 +11540,8 @@ if self.success != None: oprot.writeFieldBegin('success', TType.LIST, 0) oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter394 in self.success: - iter394.write(oprot) + for iter401 in self.success: + iter401.write(oprot) oprot.writeListEnd() oprot.writeFieldEnd() if self.o1 != None: Index: metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb =================================================================== --- metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb (revision 1060489) +++ metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb (working copy) @@ -766,6 +766,22 @@ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'drop_role failed: unknown result') end + def get_role_names() + send_get_role_names() + return recv_get_role_names() + end + + def send_get_role_names() + send_message('get_role_names', Get_role_names_args) + end + + def recv_get_role_names() + result = receive_message(Get_role_names_result) + return result.success unless result.success.nil? + raise result.o1 unless result.o1.nil? + raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get_role_names failed: unknown result') + end + def grant_role(role_name, principal_name, principal_type, grantor, grantorType, grant_option) send_grant_role(role_name, principal_name, principal_type, grantor, grantorType, grant_option) return recv_grant_role() @@ -1462,6 +1478,17 @@ write_result(result, oprot, 'drop_role', seqid) end + def process_get_role_names(seqid, iprot, oprot) + args = read_args(iprot, Get_role_names_args) + result = Get_role_names_result.new() + begin + result.success = @handler.get_role_names() + rescue MetaException => o1 + result.o1 = o1 + end + write_result(result, oprot, 'get_role_names', seqid) + end + def process_grant_role(seqid, iprot, oprot) args = read_args(iprot, Grant_role_args) result = Grant_role_result.new() @@ -3272,6 +3299,39 @@ ::Thrift::Struct.generate_accessors self end + class Get_role_names_args + include ::Thrift::Struct, ::Thrift::Struct_Union + + FIELDS = { + + } + + def struct_fields; FIELDS; end + + def validate + end + + ::Thrift::Struct.generate_accessors self + end + + class Get_role_names_result + include ::Thrift::Struct, ::Thrift::Struct_Union + SUCCESS = 0 + O1 = 1 + + FIELDS = { + SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRING}}, + O1 => {:type => ::Thrift::Types::STRUCT, :name => 'o1', :class => MetaException} + } + + def struct_fields; FIELDS; end + + def validate + end + + ::Thrift::Struct.generate_accessors self + end + class Grant_role_args include ::Thrift::Struct, ::Thrift::Struct_Union ROLE_NAME = 1 Index: metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java =================================================================== --- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (revision 1060489) +++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (working copy) @@ -2194,7 +2194,7 @@ } return ret; } - + @Override public List get_indexes(final String dbName, final String tblName, final short maxIndexes) throws NoSuchObjectException, MetaException, @@ -2467,6 +2467,27 @@ } return ret; } + + @Override + public List get_role_names() throws MetaException, TException { + incrementCounter("get_role_names"); + + List ret = null; + try { + ret = executeWithRetry(new Command>() { + @Override + List run(RawStore ms) throws Exception { + return ms.listRoleNames(); + } + }); + } catch (MetaException e) { + throw e; + } catch (Exception e) { + assert(e instanceof RuntimeException); + throw (RuntimeException)e; + } + return ret; + } @Override public boolean grant_privileges(final PrivilegeBag privileges) throws MetaException, @@ -2812,6 +2833,7 @@ } return ret; } + } /** Index: metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java =================================================================== --- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java (revision 1060489) +++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java (working copy) @@ -988,6 +988,11 @@ PrincipalType principalType) throws MetaException, TException { return client.list_roles(principalName, principalType); } + + @Override + public List listRoleNames() throws MetaException, TException { + return client.get_role_names(); + } @Override public boolean grant_privileges(PrivilegeBag privileges) Index: metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java =================================================================== --- metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java (revision 1060489) +++ metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java (working copy) @@ -554,6 +554,14 @@ public boolean drop_role(String role_name) throws MetaException, TException; /** + * list all role names + * @return + * @throws TException + * @throws MetaException + */ + public List listRoleNames() throws MetaException, TException; + + /** * * @param role_name * @param user_name Index: metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java =================================================================== --- metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java (revision 1060489) +++ metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java (working copy) @@ -426,6 +426,10 @@ MDatabase db = getMDatabase(dbname); pm.retrieve(db); if (db != null) { + List dbGrants = this.listDatabaseGrants(dbname); + if (dbGrants != null && dbGrants.size() > 0) { + pm.deletePersistentAll(dbGrants); + } pm.deletePersistent(db); } success = commitTransaction(); @@ -1832,7 +1836,6 @@ return mRoleMember; } - @SuppressWarnings("unchecked") private List listMSecurityPrincipalMembershipRole(final String roleName, final PrincipalType principalType) { @@ -1869,7 +1872,7 @@ .getOwnerName()); return ret; } - + private MRole getMRole(String roleName) { MRole mrole = null; boolean commited = false; @@ -1889,6 +1892,27 @@ return mrole; } + public List listRoleNames() { + boolean success = false; + try { + openTransaction(); + LOG.debug("Executing listAllRoleNames"); + Query query = pm.newQuery("select roleName from org.apache.hadoop.hive.metastore.model.MRole"); + query.setResult("roleName"); + Collection names = (Collection) query.execute(); + List roleNames = new ArrayList(); + for (Iterator i = names.iterator(); i.hasNext();) { + roleNames.add((String) i.next()); + } + success = commitTransaction(); + return roleNames; + } finally { + if (!success) { + rollbackTransaction(); + } + } + } + @Override public PrincipalPrivilegeSet getUserPrivilegeSet(String userName, List groupNames) throws InvalidObjectException, MetaException { @@ -2888,6 +2912,30 @@ return mSecurityColList; } + @SuppressWarnings("unchecked") + private List listDatabaseGrants(String dbName) { + dbName = dbName.toLowerCase().trim(); + + boolean success = false; + try { + openTransaction(); + LOG.debug("Executing listDatabaseGrants"); + Query query = pm.newQuery(MDBPrivilege.class, + "database.name == t1"); + query.declareParameters("java.lang.String t1"); + List mSecurityDBList = (List) query + .executeWithArray(dbName); + LOG.debug("Done executing query for listDatabaseGrants"); + pm.retrieveAll(mSecurityDBList); + success = commitTransaction(); + LOG.debug("Done retrieving all objects for listDatabaseGrants"); + return mSecurityDBList; + } finally { + if (!success) { + rollbackTransaction(); + } + } + } @SuppressWarnings("unchecked") private List listPartitionGrants(String dbName, String tableName, @@ -2917,7 +2965,7 @@ } return mSecurityTabPartList; } - + @SuppressWarnings("unchecked") public List listAllTableGrants( String principalName, PrincipalType principalType, String dbName, Index: metastore/src/java/org/apache/hadoop/hive/metastore/RawStore.java =================================================================== --- metastore/src/java/org/apache/hadoop/hive/metastore/RawStore.java (revision 1060489) +++ metastore/src/java/org/apache/hadoop/hive/metastore/RawStore.java (working copy) @@ -200,7 +200,10 @@ public abstract boolean revokePrivileges (PrivilegeBag privileges) throws InvalidObjectException, MetaException, NoSuchObjectException; - public abstract org.apache.hadoop.hive.metastore.api.Role getRole(String roleName) throws NoSuchObjectException; + public abstract org.apache.hadoop.hive.metastore.api.Role getRole( + String roleName) throws NoSuchObjectException; + + public List listRoleNames(); public List listRoles(String principalName, PrincipalType principalType); Index: metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java =================================================================== --- metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java (revision 1060489) +++ metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java (working copy) @@ -79,7 +79,7 @@ handlerClass, conf); return handler; } catch (ClassNotFoundException e) { - throw new MetaException("Error in loading index handler." + throw new MetaException("Error in loading MetaStoreFS handler." + e.getMessage()); } } Index: ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java (revision 1060489) +++ ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java (working copy) @@ -616,20 +616,20 @@ } } else { org.apache.hadoop.hive.metastore.api.Partition partObj = null; - - if ((!tableObj.isPartitioned()) - && privSubjectDesc.getPartSpec() != null) { - throw new HiveException( - "Table is not partitioned, but partition name is present: partSpec=" - + privSubjectDesc.getPartSpec().toString()); - } - - List partValues = null; - if (privSubjectDesc.getPartSpec() != null) { - partObj = db.getPartition(tableObj, privSubjectDesc.getPartSpec(), - false).getTPartition(); - partValues = partObj.getValues(); + if (tableObj != null) { + if ((!tableObj.isPartitioned()) + && privSubjectDesc.getPartSpec() != null) { + throw new HiveException( + "Table is not partitioned, but partition name is present: partSpec=" + + privSubjectDesc.getPartSpec().toString()); + } + + if (privSubjectDesc.getPartSpec() != null) { + partObj = db.getPartition(tableObj, privSubjectDesc.getPartSpec(), + false).getTPartition(); + partValues = partObj.getValues(); + } } for (PrivilegeDesc privDesc : privileges) { Index: ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java (revision 1060489) +++ ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java (working copy) @@ -1476,6 +1476,20 @@ throw new HiveException(e); } } + + /** + * Get all existing role names. + * + * @return List of role names. + * @throws HiveException + */ + public List getAllRoleNames() throws HiveException { + try { + return getMSC().listRoleNames(); + } catch (Exception e) { + throw new HiveException(e); + } + } public List showRoleGrant(String principalName, PrincipalType principalType) throws HiveException { try { Index: ql/src/test/org/apache/hadoop/hive/ql/QTestUtil.java =================================================================== --- ql/src/test/org/apache/hadoop/hive/ql/QTestUtil.java (revision 1060489) +++ ql/src/test/org/apache/hadoop/hive/ql/QTestUtil.java (working copy) @@ -338,7 +338,11 @@ } } db.setCurrentDatabase(DEFAULT_DATABASE_NAME); - + + List roleNames = db.getAllRoleNames(); + for (String roleName : roleNames) { + db.dropRole(roleName); + } // allocate and initialize a new conf since a test can // modify conf by using 'set' commands conf = new HiveConf (Driver.class); Index: ql/src/test/queries/clientpositive/authorization_5.q =================================================================== --- ql/src/test/queries/clientpositive/authorization_5.q (revision 0) +++ ql/src/test/queries/clientpositive/authorization_5.q (revision 0) @@ -0,0 +1,18 @@ +CREATE DATABASE IF NOT EXISTS test_db COMMENT 'Hive test database'; +SHOW DATABASES; + +GRANT `drop` ON DATABASE test_db TO USER hive_test_user; +GRANT `select` ON DATABASE test_db TO USER hive_test_user; + +SHOW GRANT USER hive_test_user ON DATABASE test_db; + +CREATE ROLE db_test_role; +GRANT ROLE db_test_role TO USER hive_test_user; +SHOW ROLE GRANT USER hive_test_user; + +GRANT `drop` ON DATABASE test_db TO ROLE db_test_role; +GRANT `select` ON DATABASE test_db TO ROLE db_test_role; + +SHOW GRANT ROLE db_test_role ON DATABASE test_db; + +DROP DATABASE IF EXISTS test_db; Index: ql/src/test/results/clientpositive/authorization_5.q.out =================================================================== --- ql/src/test/results/clientpositive/authorization_5.q.out (revision 0) +++ ql/src/test/results/clientpositive/authorization_5.q.out (revision 0) @@ -0,0 +1,80 @@ +PREHOOK: query: CREATE DATABASE IF NOT EXISTS test_db COMMENT 'Hive test database' +PREHOOK: type: CREATEDATABASE +POSTHOOK: query: CREATE DATABASE IF NOT EXISTS test_db COMMENT 'Hive test database' +POSTHOOK: type: CREATEDATABASE +PREHOOK: query: SHOW DATABASES +PREHOOK: type: SHOWDATABASES +POSTHOOK: query: SHOW DATABASES +POSTHOOK: type: SHOWDATABASES +default +test_db +PREHOOK: query: GRANT `drop` ON DATABASE test_db TO USER hive_test_user +PREHOOK: type: GRANT_PRIVILEGE +POSTHOOK: query: GRANT `drop` ON DATABASE test_db TO USER hive_test_user +POSTHOOK: type: GRANT_PRIVILEGE +PREHOOK: query: GRANT `select` ON DATABASE test_db TO USER hive_test_user +PREHOOK: type: GRANT_PRIVILEGE +POSTHOOK: query: GRANT `select` ON DATABASE test_db TO USER hive_test_user +POSTHOOK: type: GRANT_PRIVILEGE +PREHOOK: query: SHOW GRANT USER hive_test_user ON DATABASE test_db +PREHOOK: type: SHOW_GRANT +POSTHOOK: query: SHOW GRANT USER hive_test_user ON DATABASE test_db +POSTHOOK: type: SHOW_GRANT + +database test_db +principalName hive_test_user +principalType USER +privilege Drop +grantTime 1295394398 +grantor hive_test_user + +database test_db +principalName hive_test_user +principalType USER +privilege Select +grantTime 1295394398 +grantor hive_test_user +PREHOOK: query: CREATE ROLE db_test_role +PREHOOK: type: CREATEROLE +POSTHOOK: query: CREATE ROLE db_test_role +POSTHOOK: type: CREATEROLE +PREHOOK: query: GRANT ROLE db_test_role TO USER hive_test_user +PREHOOK: type: GRANT_ROLE +POSTHOOK: query: GRANT ROLE db_test_role TO USER hive_test_user +POSTHOOK: type: GRANT_ROLE +PREHOOK: query: SHOW ROLE GRANT USER hive_test_user +PREHOOK: type: SHOW_ROLE_GRANT +POSTHOOK: query: SHOW ROLE GRANT USER hive_test_user +POSTHOOK: type: SHOW_ROLE_GRANT +role name:db_test_role +role name:db_test_role +PREHOOK: query: GRANT `drop` ON DATABASE test_db TO ROLE db_test_role +PREHOOK: type: GRANT_PRIVILEGE +POSTHOOK: query: GRANT `drop` ON DATABASE test_db TO ROLE db_test_role +POSTHOOK: type: GRANT_PRIVILEGE +PREHOOK: query: GRANT `select` ON DATABASE test_db TO ROLE db_test_role +PREHOOK: type: GRANT_PRIVILEGE +POSTHOOK: query: GRANT `select` ON DATABASE test_db TO ROLE db_test_role +POSTHOOK: type: GRANT_PRIVILEGE +PREHOOK: query: SHOW GRANT ROLE db_test_role ON DATABASE test_db +PREHOOK: type: SHOW_GRANT +POSTHOOK: query: SHOW GRANT ROLE db_test_role ON DATABASE test_db +POSTHOOK: type: SHOW_GRANT + +database test_db +principalName db_test_role +principalType ROLE +privilege Drop +grantTime 1295394399 +grantor hive_test_user + +database test_db +principalName db_test_role +principalType ROLE +privilege Select +grantTime 1295394399 +grantor hive_test_user +PREHOOK: query: DROP DATABASE IF EXISTS test_db +PREHOOK: type: DROPDATABASE +POSTHOOK: query: DROP DATABASE IF EXISTS test_db +POSTHOOK: type: DROPDATABASE