DatabaseProcApplicationCreatedLinks
sybsystemprocssp_helpgroup  31 Aug 14Defects Dependencies

1     
2     /* Sccsid = "%Z% generic/sproc/%M% %I% %G%" */
3     /*	4.8	1.1	06/14/90	sproc/src/help */
4     /*
5     ** Messages for "sp_helpgroup"          17630
6     **
7     ** 17333, "No group with the specified name exists."
8     */
9     create procedure sp_helpgroup
10        @grpname varchar(30) = NULL /* group name of interest */
11    as
12    
13        declare @msg varchar(1024)
14        declare @len1 int, @len2 int
15    
16    
17        if @@trancount = 0
18        begin
19            set chained off
20        end
21    
22        set transaction isolation level 1
23    
24        /*
25        **  If no group name given, list all the groups.
26        */
27        if @grpname is NULL
28        begin
29            select Group_name = name, Group_id = gid
30            into #helpgrouprs
31            from sysusers G
32            where ((G.uid between @@mingroupid and @@maxgroupid) or G.uid = 0)
33                and not exists (select * from sysroles R where G.uid = R.lrid)
34            exec sp_autoformat @fulltabname = #helpgrouprs,
35                @orderby = "order by Group_name"
36            drop table #helpgrouprs
37    
38            return (0)
39        end
40    
41        /*
42        **  Check to see if group exists.
43        */
44        if not exists (select * from sysusers where name = @grpname
45                    and ((uid between @@mingroupid and @@maxgroupid) or uid = 0))
46            or exists (select name from master.dbo.syssrvroles
47                where name = @grpname)
48        begin
49            /* 17333, "No group with the specified name exists." */
50            exec sp_getmessage 17333, @msg output
51            print @msg
52            return (1)
53        end
54    
55        if (@grpname != "public")
56        begin
57            /*
58            **  List the particulars for the group.
59            */
60            select Group_name = g.name, Group_id = g.gid,
61                Users_in_group = u.name, Userid = u.uid
62            into #helpgroup1rs
63            from sysusers u, sysusers g where g.name like @grpname
64                and g.uid = u.gid and
65                ((g.uid between @@mingroupid and @@maxgroupid) or g.uid = 0)
66                and u.uid != u.gid
67            exec sp_autoformat @fulltabname = #helpgroup1rs,
68                @orderby = "order by Group_name,Users_in_group"
69            drop table #helpgroup1rs
70        end
71        else
72        begin
73            /*
74            **  Special case for "public" group.  List all users, including users
75            **  in other groups.  They also belong to "public" group.
76            */
77            select Group_name = g.name, Group_id = g.gid,
78                Users_in_group = u.name, Userid = u.uid
79            into #helpgroup2rs
80            from sysusers u, sysusers g
81            where g.name like @grpname and
82                ((g.uid between @@mingroupid and @@maxgroupid) or g.uid = 0)
83                and u.uid != u.gid
84            exec sp_autoformat @fulltabname = #helpgroup2rs,
85                @orderby = "order by Group_name,Users_in_group"
86            drop table #helpgroup2rs
87        end
88        return (0)
89    


exec sp_procxmode 'sp_helpgroup', 'AnyMode'
go

Grant Execute on sp_helpgroup to public
go
DEFECTS
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: @fulltabname 34
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: @fulltabname 67
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: @fulltabname 84
 QCAS 4 Cartesian product with single row between tables sybsystemprocs..sysusers u and [sybsystemprocs..sysusers g], 3 tables with rc=1 77
 MGTP 3 Grant to public master..syssrvroles  
 MGTP 3 Grant to public sybsystemprocs..sp_helpgroup  
 MGTP 3 Grant to public sybsystemprocs..sysroles  
 MGTP 3 Grant to public sybsystemprocs..sysusers  
 MNEJ 3 'Not Equal' join 66
 MNEJ 3 'Not Equal' join 83
 MNER 3 No Error Check should check @@error after select into 29
 MNER 3 No Error Check should check return value of exec 34
 MNER 3 No Error Check should check return value of exec 50
 MNER 3 No Error Check should check @@error after select into 60
 MNER 3 No Error Check should check return value of exec 67
 MNER 3 No Error Check should check @@error after select into 77
 MNER 3 No Error Check should check return value of exec 84
 MUCO 3 Useless Code Useless Brackets 38
 MUCO 3 Useless Code Useless Brackets 52
 MUCO 3 Useless Code Useless Brackets 55
 MUCO 3 Useless Code Useless Brackets 88
 QCTC 3 Conditional Table Creation 29
 QCTC 3 Conditional Table Creation 60
 QCTC 3 Conditional Table Creation 77
 QISO 3 Set isolation level 22
 QNAJ 3 Not using ANSI Inner Join 63
 QNAJ 3 Not using ANSI Inner Join 80
 VUNU 3 Variable is not used @len1 14
 VUNU 3 Variable is not used @len2 14
 MSUB 2 Subquery Marker 44
 MSUB 2 Subquery Marker 46
 MSUC 2 Correlated Subquery Marker 33
 MTR1 2 Metrics: Comments Ratio Comments: 23% 9
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 19 = 20dec - 3exi + 2 9
 MTR3 2 Metrics: Query Complexity Complexity: 56 9
 PRED_QUERY_COLLECTION 2 {r=sybsystemprocs..sysroles, u=sybsystemprocs..sysusers} 0 33
 PRED_QUERY_COLLECTION 2 {u=sybsystemprocs..sysusers, u2=sybsystemprocs..sysusers} 0 60

DEPENDENCIES
PROCS AND TABLES USED
calls proc sybsystemprocs..sp_getmessage  
   reads table master..sysmessages (1)  
   calls proc sybsystemprocs..sp_validlang  
      reads table master..syslanguages (1)  
   reads table master..syslanguages (1)  
   reads table sybsystemprocs..sysusermessages  
reads table sybsystemprocs..sysusers  
writes table tempdb..#helpgroup1rs (1) 
writes table tempdb..#helpgrouprs (1) 
writes table tempdb..#helpgroup2rs (1) 
calls proc sybsystemprocs..sp_autoformat  
   calls proc sybsystemprocs..sp_autoformat  
   reads table master..syscolumns (1)  
   reads table tempdb..syscolumns (1)  
   calls proc sybsystemprocs..sp_namecrack  
   reads table master..systypes (1)  
   read_writes table tempdb..#colinfo_af (1) 
   reads table tempdb..systypes (1)  
reads table sybsystemprocs..sysroles  
reads table master..syssrvroles (1)  

CALLERS
called by proc sybsystemprocs..sp_helpuser