Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to create database with different owner #7718

Merged
merged 5 commits into from
Nov 20, 2023

Conversation

aafemt
Copy link
Contributor

@aafemt aafemt commented Aug 23, 2023

No description provided.

Copy link
Member

@AlexPeshkoff AlexPeshkoff left a comment

Choose a reason for hiding this comment

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

Feature is for sure useful, and I finally agree with removing parameter from getUserInfo() as related with this PR - but please remove unrelated changes from .pas file.

@hvlad
Copy link
Member

hvlad commented Aug 23, 2023

It is always good idea to explain why you consider proposed feature useful and how it could/should be used.

@aafemt
Copy link
Contributor Author

aafemt commented Aug 23, 2023

please remove unrelated changes from .pas file

Ok, but should I really edit autogenerated file by hand after every build?

@aafemt
Copy link
Contributor Author

aafemt commented Aug 23, 2023

why you consider proposed feature useful and how it could/should be used.

Among other purposes it is planned to be used as a base for other feature: gbak preserving DB owner on restore. It would bring consistency between nbackup preserving owner and gbak rewriting it.

@AlexPeshkoff
Copy link
Member

AlexPeshkoff commented Aug 23, 2023 via email

@AlexPeshkoff
Copy link
Member

Ok, but should I really edit autogenerated file by hand after every build?

Certainly not. I will fix file in master branch and after it pls fix PR.

@aafemt
Copy link
Contributor Author

aafemt commented Aug 23, 2023

That's why I insisted that this file must not be in the repository years ago...

@AlexPeshkoff
Copy link
Member

@aafemt Look like you've created PR against rather old copy of this file. If you make fresh clone of master branch and run something like:
git log -L 14927,14935:Firebird.pas
you will see why I think so.
I do not pretend to understand how exactly you've achieved this :)

@aafemt
Copy link
Contributor Author

aafemt commented Aug 23, 2023

Sorry, I don't understand this as well. I've forked the branch from master after "git pull".

Perhaps, CLOOP works differently on Linux and Windows.

@AlexPeshkoff
Copy link
Member

Last fix was done by Vlad and I doubt he used linux build for that :-)
Well , I suggest to treat this incident as resolved :)

What about PR as a whole - let's wait for DE cause list of features to be added to FB5 was already discussed and currently is closed. Personally I see no problems adding it - your code appears quite clear here, but let's wait what others say.

@aafemt
Copy link
Contributor Author

aafemt commented Aug 23, 2023

Last fix was done by Vlad and I doubt he used linux build for that :-)

But you are looking at different line. Here is link to current master version:

function ITraceProcedureImpl_getStmtIDDispatcher(this: ITraceProcedure): Int64; cdecl;

@aafemt
Copy link
Contributor Author

aafemt commented Aug 23, 2023

Personally I see no problems adding it - your code appears quite clear here, but let's wait what others say.

I don't expect this PR to be accepted into v5. V6 is fine. I just need to reserve DPB item number.

PS: More controversial changes will follow. That's why the PR is marked as a draft.

@sim1984
Copy link

sim1984 commented Aug 23, 2023

I did not see support for specifying the owner of the database in the create database statement. It is clear that this pseudo-statement in reality calls the api to create a database, but it also needs to be done. If it is, then why is it not reflected in the documentation?

@aafemt
Copy link
Contributor Author

aafemt commented Aug 23, 2023

That will be in the next commit(s) as mentioned above.

@AlexPeshkoff
Copy link
Member

AlexPeshkoff commented Aug 23, 2023 via email

@aafemt
Copy link
Contributor Author

aafemt commented Aug 23, 2023

Wrong link. Coorect one is https://github.com/FirebirdSQL/firebird/blob/master/src/include/gen/Firebird.pas#L14927 Your link is not to master.

It was to the last relevant commit to master but ok, here is the really right link:
https://github.com/FirebirdSQL/firebird/blob/master/src/include/gen/Firebird.pas#L15197

@AlexPeshkoff
Copy link
Member

AlexPeshkoff commented Aug 23, 2023 via email

src/jrd/DbCreators.h Outdated Show resolved Hide resolved
src/jrd/jrd.cpp Outdated Show resolved Hide resolved
src/jrd/jrd.cpp Outdated Show resolved Hide resolved
@AlexPeshkoff
Copy link
Member

AlexPeshkoff commented Aug 24, 2023 via email

@aafemt
Copy link
Contributor Author

aafemt commented Aug 24, 2023

When they represent constants - may be not too ugly.

Ok, though it is a scoped enum and its members cannot be mistaken for anything else.

@aafemt aafemt marked this pull request as ready for review August 27, 2023 11:25
@livius2
Copy link

livius2 commented Nov 1, 2023

Wouldn't it be better to make the options available
grant DATABASE_OWNER to USER_NAME?

@aafemt
Copy link
Contributor Author

aafemt commented Nov 1, 2023

Wouldn't it be better to make the options available grant DATABASE_OWNER to USER_NAME?

Changing of existing database is problematic. Set owner during creation is simpler.

@dyemanov dyemanov merged commit b495b3f into FirebirdSQL:master Nov 20, 2023
23 checks passed
@pavel-zotov
Copy link

Is it possible to implement similar for ALTER database ? I mean:

alter database set owner to <some_other_user>;

@sim1984
Copy link

sim1984 commented Nov 23, 2023

Implementing changing the owner of just the database will not solve the problems. By introducing this feature, you will also have to provide the ability to change owners for other database objects. And also think about recursively changing the owner of all database objects.

ALTER <object_type> <object_name> SET OWNER TO <user>

<object_type> ::=
  TABLE | VIEW | PROCEDURE | FUNCTION | TRIGGER | PACKAGE |
  DOMAIN | EXCEPTION | FILTER | ROLE

And special case for database:

ALTER DATABASE SET OWNER TO <user> [WITH RECURSIVE]

@pavel-zotov
Copy link

And also think about recursively changing the owner of all database objects.

Yes, number of these objects can be huge. But not infinite.
And not all of objects must be affected but only those who were created by previous owner.
So, several minutes usually must be enough to complete this job :-)

PS. Of course, i speak about 'service time' interval when SYSDBA has exclusive access to DB

@aafemt
Copy link
Contributor Author

aafemt commented Nov 23, 2023

Is it possible to implement similar for ALTER database ?

In theory - yes. On practice it is much harder task than impersonation during single call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants