Skip to content

Conversation

@luozenglin
Copy link
Contributor

…ges table in information_schema database.

Proposed changes

Add table_privileges, schema_privileges and user_privileges table in information_schema database.

Types of changes

What types of changes does your code introduce to Doris?
Put an x in the boxes that apply

  • [] Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [] Documentation Update (if none of the other choices apply)
  • [] Code refactor (Modify the code structure, format the code, etc...)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

.column("GRANTEE", ScalarType.createVarchar(NAME_CHAR_LEN))
.column("TABLE_CATALOG", ScalarType.createVarchar(FN_REFLEN))
.column("TABLE_SCHEMA", ScalarType.createVarchar(NAME_CHAR_LEN))
.column("PRIVILEGE_TYPE", ScalarType.createVarchar(64))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a constant variables like 'PRIVILEGE_TYPE_LEN' is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.


String grantee = new String("\'").concat(ClusterNamespace.getNameFromFullName(tblPrivEntry.getOrigUser()))
.concat("\'@\'").concat(tblPrivEntry.getOrigHost()).concat("\'");
String isGrantable = tblPrivEntry.getPrivSet().get(2) ? "yes" : "no"; //Grant_priv
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are word of yes or no case sensitive ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use uppercase, I will modify it.

}
TPrivilegeStatus status = new TPrivilegeStatus();
status.setTableName(tblName);
status.setPrivilegeType(privilegesInMysql[paloPriv.getIdx()]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a map is better? such as <PaloPrivilege, String> ?

@EmmyMiao87 EmmyMiao87 added area/compact Issues or PRs related to the compact area/sql/compatibility Issues or PRs related to the SQL compatibililty and removed area/sql/compatibility Issues or PRs related to the SQL compatibililty labels Nov 13, 2020
@EmmyMiao87
Copy link
Contributor

Could you please add some description about this pr?

luozenglin and others added 2 commits November 13, 2020 22:12
…rivileges table in information_schema database.
…r_privileges to the information_schema database (apache#4897)

to improve compatibility with the mysql
@morningman morningman added area/mysql-compatibility Issues or PRs related to the mysql compatibility and removed area/compact Issues or PRs related to the compact labels Nov 15, 2020
// set all bit to not null
memset((void *)tuple, 0, _tuple_desc->num_null_bytes());
const TPrivilegeStatus& tbl_priv_status = _priv_result.privileges[_priv_index];
// grantee
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    {
        void *slot = tuple->get_slot(_tuple_desc->slots()[0]->tuple_offset());
        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
        const std::string* src = &tbl_priv_status.grantee;
        str_slot->len = src->length();
        str_slot->ptr = (char *)pool->allocate(str_slot->len);
        if (NULL == str_slot->ptr) {
            return Status::InternalError("Allocate memcpy failed.");
        }
        memcpy(str_slot->ptr, src->c_str(), str_slot->len);
    }

This kind of code block is used everywhere, I think we can extract a common method for it.

Copy link
Contributor

@EmmyMiao87 EmmyMiao87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…r_privileges to the information_schema database (apache#4897)

to improve compatibility with the mysql
Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@morningman morningman added the approved Indicates a PR has been approved by one committer. label Nov 15, 2020
@morningman morningman merged commit 448df42 into apache:master Nov 16, 2020
@yangzhg yangzhg mentioned this pull request Feb 9, 2021
@luozenglin luozenglin deleted the dev branch May 8, 2021 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. area/mysql-compatibility Issues or PRs related to the mysql compatibility good first issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add table_privileges, schema_privileges and user_privileges table in information_schema database.

3 participants