Skip to content

Added sp_helplogins - stored proc that provides information about logins and users associated with those logins. #3733

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

Open
wants to merge 60 commits into
base: BABEL_5_X_DEV
Choose a base branch
from

Conversation

ayushdsh
Copy link

@ayushdsh ayushdsh commented May 1, 2025

Description

sp_helplogins [ [ @LoginNamePattern = ] N'LoginNamePattern' ] [ ; ] @LoginNamePattern is sys.sysname, with a default of NULL . If specified, @loginnamepattern must exist.

It returns two result sets -
First view - information about all logins present on the server. Second view - information about each login and its mapping with a user in a database or its membership with a database-role

Task - BABEL-5742

Note

Since sp_helplogins returns two result sets and one of them has a uniquely generated SID, tests for now have been disabled.

Issues Resolved

[List any issues this PR will resolve]

Test Scenarios Covered

  • Use case based -

    • Logged-in user is a member of sysadmin role (superuser)
    • Logged-in user is a member of securityadmin role
    • Logged-in user is a member of securityadmin role and also a member of db_securityadmin or db_accessadmin
    • Logged-in user is not a member of securityadmin role
    • Login does not have any users
  • Boundary conditions -

    • Parameter passed is an invalid login
  • Arbitrary inputs -

    • Parameter passed is an invalid login
  • Negative test cases -

    • Parameter passed is empty
    • Parameter passed contains padded spaces L-R
  • Minor version upgrade tests -

    • NA
  • Major version upgrade tests -

    • NA
  • Performance tests -

    • NA
  • Tooling impact -

    • NA
  • Client tests -

    • NA

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

ayushdsh added 2 commits May 1, 2025 20:22
…information about logins (both SQL and Windows) and users associated with those logins.

sp_helplogins [ [ @LoginNamePattern = ] N'LoginNamePattern' ] [ ; ]
@LoginNamePattern is sys.sysname, with a default of NULL . If specified, @loginnamepattern must exist.

It returns two result sets -
First view - information about all logins present on the server. Second view - information about each login and its mapping with a user in a database or its membership with a database-role

Task - BABEL-5742
@ayushdsh ayushdsh self-assigned this May 1, 2025
@ayushdsh ayushdsh marked this pull request as ready for review May 1, 2025 20:38
@coveralls
Copy link
Collaborator

coveralls commented May 1, 2025

Pull Request Test Coverage Report for Build 15582496067

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.003%) to 75.507%

Files with Coverage Reduction New Missed Lines %
contrib/babelfishpg_tds/src/backend/tds/tdscomm.c 2 76.03%
Totals Coverage Status
Change from base Build 15576294290: -0.003%
Covered Lines: 48819
Relevant Lines: 64655

💛 - Coveralls

@ayushdsh ayushdsh closed this May 6, 2025
@ayushdsh ayushdsh reopened this May 6, 2025
@ayushdsh ayushdsh closed this May 6, 2025
@ayushdsh ayushdsh reopened this May 6, 2025
@ayushdsh ayushdsh closed this May 6, 2025
@ayushdsh ayushdsh reopened this May 6, 2025
@ayushdsh ayushdsh closed this May 7, 2025
@ayushdsh ayushdsh reopened this May 7, 2025
@ayushdsh ayushdsh closed this May 26, 2025
@ayushdsh ayushdsh reopened this May 26, 2025
…information about logins (both SQL and Windows) and users associated with those logins.

sp_helplogins [ [ @LoginNamePattern = ] N'LoginNamePattern' ] [ ; ]
@LoginNamePattern is sys.sysname, with a default of NULL . If specified, @loginnamepattern must exist.

It returns two result sets -
First view - information about all logins present on the server.
Second view - information about each login and its mapping with a user in a database or its membership with a database-role

Task - BABEL-5742

Signed-off-by: Ayush Shah <[email protected]>
@ayushdsh ayushdsh closed this May 27, 2025
@ayushdsh ayushdsh reopened this May 27, 2025
@@ -39,6 +39,10 @@ go
drop user guest;
go

-- re-enabling connect on guest user
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this to fix intermittent test failures which is not related to your changes, right?

Copy link
Author

Choose a reason for hiding this comment

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

That's correct. In this test, we are removing the guest user but never adding them back. This is to add the guest access back

Copy link
Contributor

Choose a reason for hiding this comment

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

Please think about cherry-picking this stabilizing changes to other branches as well if we are observing the same.

@@ -39,6 +39,10 @@ go
drop user guest;
go

-- re-enabling connect on guest user
Copy link
Contributor

Choose a reason for hiding this comment

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

Please think about cherry-picking this stabilizing changes to other branches as well if we are observing the same.

ayushdsh added 6 commits May 29, 2025 15:46
…information about logins (both SQL and Windows) and users associated with those logins.

sp_helplogins [ [ @LoginNamePattern = ] N'LoginNamePattern' ] [ ; ]
@LoginNamePattern is sys.sysname, with a default of NULL . If specified, @loginnamepattern must exist.

It returns two result sets -
First view - information about all logins present on the server.
Second view - information about each login and its mapping with a user in a database or its membership with a database-role

Task - BABEL-5742

Signed-off-by: Ayush Shah <[email protected]>
…information about logins (both SQL and Windows) and users associated with those logins.

sp_helplogins [ [ @LoginNamePattern = ] N'LoginNamePattern' ] [ ; ]
@LoginNamePattern is sys.sysname, with a default of NULL . If specified, @loginnamepattern must exist.

It returns two result sets -
First view - information about all logins present on the server.
Second view - information about each login and its mapping with a user in a database or its membership with a database-role

Task - BABEL-5742

Signed-off-by: Ayush Shah <[email protected]>
…information about logins (both SQL and Windows) and users associated with those logins.

sp_helplogins [ [ @LoginNamePattern = ] N'LoginNamePattern' ] [ ; ]
@LoginNamePattern is sys.sysname, with a default of NULL . If specified, @loginnamepattern must exist.

It returns two result sets -
First view - information about all logins present on the server.
Second view - information about each login and its mapping with a user in a database or its membership with a database-role

Task - BABEL-5742

Signed-off-by: Ayush Shah <[email protected]>
…information about logins (both SQL and Windows) and users associated with those logins.

sp_helplogins [ [ @LoginNamePattern = ] N'LoginNamePattern' ] [ ; ]
@LoginNamePattern is sys.sysname, with a default of NULL . If specified, @loginnamepattern must exist.

It returns two result sets -
First view - information about all logins present on the server.
Second view - information about each login and its mapping with a user in a database or its membership with a database-role

Task - BABEL-5742

Signed-off-by: Ayush Shah <[email protected]>
ayushdsh added 3 commits June 3, 2025 07:18
…smallmoney arithmetic and math functions.

There were certain issues found both w.r.t overflow handling and certain functions and operations giving incorrect result for money and smallmoney datatype. This commit addresses those issues.

Issue babelfish-for-postgresql#1: Overflow of smallmoney arithmetic leading to TDS hang.
Issue babelfish-for-postgresql#2: Unhandled overflow cases leading to incorrect output.
Issue babelfish-for-postgresql#3: Fixeddecimal operators being resolved for smallmoney functions and operations leading to incorrect results.

Task: BABEL-5745, BABEL-5757, BABEL-5756, BABEL-5747, BABEL-5754

Signed-off-by: Ayush Shah <[email protected]>
…smallmoney arithmetic and math functions.

There were certain issues found both w.r.t overflow handling and certain functions and operations giving incorrect result for money and smallmoney datatype. This commit addresses those issues.

Issue babelfish-for-postgresql#1: Overflow of smallmoney arithmetic leading to TDS hang.
Issue babelfish-for-postgresql#2: Unhandled overflow cases leading to incorrect output.
Issue babelfish-for-postgresql#3: Fixeddecimal operators being resolved for smallmoney functions and operations leading to incorrect results.

Task: BABEL-5745, BABEL-5757, BABEL-5756, BABEL-5747, BABEL-5754

Signed-off-by: Ayush Shah <[email protected]>
…information about logins (both SQL and Windows) and users associated with those logins.

sp_helplogins [ [ @LoginNamePattern = ] N'LoginNamePattern' ] [ ; ]
@LoginNamePattern is sys.sysname, with a default of NULL . If specified, @loginnamepattern must exist.

It returns two result sets -
First view - information about all logins present on the server.
Second view - information about each login and its mapping with a user in a database or its membership with a database-role

Task - BABEL-5742

Signed-off-by: Ayush Shah <[email protected]>
ayushdsh added 2 commits June 9, 2025 02:16
…information about logins (both SQL and Windows) and users associated with those logins.

sp_helplogins [ [ @LoginNamePattern = ] N'LoginNamePattern' ] [ ; ]
@LoginNamePattern is sys.sysname, with a default of NULL . If specified, @loginnamepattern must exist.

It returns two result sets -
First view - information about all logins present on the server.
Second view - information about each login and its mapping with a user in a database or its membership with a database-role

Task - BABEL-5742

Signed-off-by: Ayush Shah <[email protected]>
@ayushdsh ayushdsh closed this Jun 9, 2025
@ayushdsh ayushdsh reopened this Jun 9, 2025
CAST(LExt.orig_loginname AS sys.SYSNAME) AS LoginName,
CAST(UExt2.database_name AS sys.SYSNAME) AS DBName,
CAST(UExt1.orig_username AS sys.SYSNAME) AS UserName,
CAST('Member of' AS sys.varchar(10)) AS UserOrAlias
Copy link
Contributor

Choose a reason for hiding this comment

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

The column type should be char(8), please fix it at other places as well.

WHEN Db.owner COLLATE database_default = LExt.orig_loginname THEN CAST('YES' AS sys.char(5))
ELSE CAST('NO' AS sys.char(5))
END AS AUser,
CAST('NO' AS sys.char(7)) AS ARemote -- Currently we do not support linking local logins to remote logins
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you missed to fix the column type at other places.

CAST(LExt.orig_loginname AS sys.SYSNAME) AS LoginName,
CAST(UExt.database_name AS sys.SYSNAME) AS DBName,
CAST(UExt.orig_username AS SYS.SYSNAME) AS UserName,
CAST('User' AS sys.char(8)) AS UserOrAlias
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you missed to fix the column type at other places.

ayushdsh added 3 commits June 10, 2025 06:10
…smallmoney arithmetic and math functions.

There were certain issues found both w.r.t overflow handling and certain functions and operations giving incorrect result for money and smallmoney datatype. This commit addresses those issues.

Issue babelfish-for-postgresql#1: Overflow of smallmoney arithmetic leading to TDS hang.
Issue babelfish-for-postgresql#2: Unhandled overflow cases leading to incorrect output.
Issue babelfish-for-postgresql#3: Fixeddecimal operators being resolved for smallmoney functions and operations leading to incorrect results.

Task: BABEL-5745, BABEL-5757, BABEL-5756, BABEL-5747, BABEL-5754

Signed-off-by: Ayush Shah <[email protected]>
…information about logins (both SQL and Windows) and users associated with those logins.

sp_helplogins [ [ @LoginNamePattern = ] N'LoginNamePattern' ] [ ; ]
@LoginNamePattern is sys.sysname, with a default of NULL . If specified, @loginnamepattern must exist.

It returns two result sets -
First view - information about all logins present on the server.
Second view - information about each login and its mapping with a user in a database or its membership with a database-role

Task - BABEL-5742

Signed-off-by: Ayush Shah <[email protected]>
…information about logins (both SQL and Windows) and users associated with those logins.

sp_helplogins [ [ @LoginNamePattern = ] N'LoginNamePattern' ] [ ; ]
@LoginNamePattern is sys.sysname, with a default of NULL . If specified, @loginnamepattern must exist.

It returns two result sets -
First view - information about all logins present on the server.
Second view - information about each login and its mapping with a user in a database or its membership with a database-role

Task - BABEL-5742

Signed-off-by: Ayush Shah <[email protected]>
@ayushdsh ayushdsh closed this Jun 11, 2025
@ayushdsh ayushdsh reopened this Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants