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

multi_sth.t fails due to use of "suid" on MS SQL [rt.cpan.org #93040] #38

Closed
mpeppler opened this issue Feb 4, 2021 · 2 comments
Closed

Comments

@mpeppler
Copy link
Owner

mpeppler commented Feb 4, 2021

Migrated from rt.cpan.org#93040 (status was 'new')

Requestors:

From https://www.google.com/accounts/o8/id?id=AItOawlVEP5IYeRHpH3ZT4ELVsJ3INWz0Lpegpo on 2014-02-14 17:33:15
:

multi_sth.t uses master..sysprocesses' "suid" column which isn't available on SQL Server. Change the test so that when connecting to SQL Server it would use the "uid" column instead.

According to http://stackoverflow.com/a/8245884/1540600, "uid" = 1 is "dbo" i.e. it has the same semantics as Sybase's "suid" = 1.

--- t\multi_sth#1.t	2014-02-14 18:32:51.000000000 +-0100
+++ t\multi_sth.t	2014-02-14 18:29:22.000000000 +-0100
@@ -78,20 +78,22 @@
 }
 
 # Same thing, with placeholders.
 sub test2 {
     my $dbh = shift;
 
+	my $suidColumn = $dbh->{syb_server_version} eq 'Unknown' ? 'uid' : 'suid';
+
  SKIP: {
 	skip '? placeholders not supported', 6 unless $dbh->{syb_dynamic_supported};
 
 	my $rc;
 
 	my $sth1 = $dbh->prepare("select * from master..sysprocesses where spid = ?");
 	ok(defined($sth1), 'test2 prepare1');
-	my $sth2 = $dbh->prepare("select * from sysusers where suid = ?");
+	my $sth2 = $dbh->prepare("select * from sysusers where $suidColumn = ?");
 	ok(defined($sth2), 'test2 prepare2');
 	
 	$rc = $sth1->execute(1);
 	ok(defined($rc), 'test2 execute1');
 	$rc = 0;
 	while(my $d = $sth1->fetch) {
@@ -92,25 +94,27 @@
 	ok(defined($sth2), 'test2 prepare2');
 	
 	$rc = $sth1->execute(1);
 	ok(defined($rc), 'test2 execute1');
 	$rc = 0;
 	while(my $d = $sth1->fetch) {
 }
 
 # Same thing, with placeholders.
 sub test3 {
     my $dbh = shift;
 
+	my $suidColumn = $dbh->{syb_server_version} eq 'Unknown' ? 'uid' : 'suid';
+
  SKIP: {
 	skip '? placeholders not supported', 6 unless $dbh->{syb_dynamic_supported};
 	my $rc;
 
 	my $sth1 = $dbh->prepare("select * from master..sysprocesses where spid = ?");
 	ok(defined($sth1), 'test3 prepare1');
-	my $sth2 = $dbh->prepare("select * from sysusers where suid = ?");
+	my $sth2 = $dbh->prepare("select * from sysusers where $suidColumn = ?");
 	ok(defined($sth2), 'test3 prepare2');
 
 	$rc = $sth1->execute(1);
 	ok(defined($rc), 'test3 execute1');
 	# Interleaved execute()
 


@mpeppler
Copy link
Owner Author

mpeppler commented Feb 6, 2021

suid is the login id (at the server level) while uid is at the database level. So suid 1 is the "sa" login, whereas uid 1 is the DBO of any specific database. I don't know how MS-SQL does this - but for Sybase the suid field in sysusers allows you to link the user (in the DB) to the login (at the server level).
That said your patch is probably fine...

@mpeppler
Copy link
Owner Author

mpeppler commented Feb 6, 2021

Actually - this has already been fixed in the code - the suid column has been replaced by uid :-)

@mpeppler mpeppler closed this as completed Feb 6, 2021
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

No branches or pull requests

1 participant