DatabaseProcApplicationCreatedLinks
sybsystemprocssp_bindrule  14 déc. 14Defects Propagation Dependencies

1     
2     /* Sccsid = "%Z% generic/sproc/src/%M% %I% %G%" */
3     /*	4.8	1.1	06/14/90	sproc/src/bindrule */
4     
5     /*
6     ** Messages for "sp_bindrule"           17350
7     **
8     ** 17344, "You do not own a column of that name." 
9     ** 17346, "You do not own a datatype of that name." 
10    ** 17350, "Rule and table or usertype must be in 'current' database."
11    ** 17351, "Usage: bindrule rulename, objectname [, 'futureonly']"
12    ** 17352, "No rule named '%1!' exists. You must create the rule first."
13    ** 17353, "You can't bind a rule to a text, image, unitext, off-row Java clas, or timestamp datatype column."
14    ** 17354, "Rule bound to table column."
15    ** 17355, "You can't bind a rule to a text, image, unitext, or timestamp datatype."
16    ** 17356, "Rule bound to datatype."
17    ** 17357, "The new rule has been bound to column(s) of the specified user datatype."
18    ** 17358, "You cannot bind a declared constraint. The rule must be created using create rule."
19    ** 17756, "The execution of the stored procedure '%1!' in database
20    **         '%2!' was aborted because there was an error in writing the
21    **         replication log record."
22    ** 17763, "The execution of the stored procedure '%1!' in database '%2!' was aborted because there
23    **         was an error in updating the schemacnt column in sysobjects."
24    ** 18293, "Auditing for '%1!' event has failed due to internal error. Contact a user with System Security Officer (SSO) role."
25    ** 17359, "You cannot bind a rule to a virtual computed column."
26    ** 19359, "You cannot bind a rule to a function-based index key."
27    */
28    
29    
30    /*
31    ** IMPORTANT NOTE:
32    ** This stored procedure uses the built-in function object_id() in the
33    ** where clause of a select query. If you intend to change this query
34    ** or use the object_id() or db_id() builtin in this procedure, please read the
35    ** READ.ME file in the $DBMS/generic/sproc directory to ensure that the rules
36    ** pertaining to object-id's and db-id's outlined there, are followed.
37    */
38    
39    create or replace procedure sp_bindrule
40        @rulename varchar(767), /* name of the rule */
41        @objname varchar(511), /* table or usertype name */
42        @futureonly varchar(15) = NULL /* column name */
43    as
44    
45        declare @futurevalue varchar(15) /* the value of @futureonly that causes
46        ** the binding to be limited */
47        declare @status tinyint /* column status */
48        declare @colid smallint /* column id */
49        declare @msg varchar(1024)
50        declare @returncode int /* return from ad_hoc_audit builtin */
51        declare @eventnum int /* event number for bind default auditing */
52        declare @mod_ok int /* successful bind default auditing  */
53        declare @mod_fail int /* failure bind default auditing  */
54        declare @maxobjlen int /* get the length of sysobject.name from syscolumns */
55        declare @maxuserlen int /* get the length of sysusers.name from syscolumns */
56        declare @maxtotlen int /* get the Total length of sysobjects.name + sysusers.name*/
57    
58        select @eventnum = 8 /* event number for bind rule */
59        select @mod_ok = 1
60        select @mod_fail = 2
61        declare @dbname varchar(255)
62        declare @tmp int
63        declare @rows_selected int
64    
65        declare @new_binding int /* 0 - new rule was not bound to columns of 
66        **     user's datatype.
67        ** 1 - new rule was bound to columns of the
68        **     user's datatype.
69        */
70        declare @access_rule int /* 0        - not an access rule.
71        ** 16777216 - is an access rule. This is
72        ** the bit in sysobjects.sysstat2 that
73        ** marks an access_rule.
74        */
75        declare @dbcc_dbid int /* Database id of updated objects */
76        declare @obj_id int /* Object id of updated objects */
77    
78        select @new_binding = 0
79    
80        if @@trancount = 0
81        begin
82            set chained off
83        end
84    
85        set transaction isolation level 1
86    
87        set nocount on
88    
89        select @futurevalue = "futureonly" /* initialize @futurevalue */
90    
91        /*
92        **  When a default or rule is bound to a user-defined datatype, it is also
93        **  bound, by default, to any columns of the user datatype that are currently
94        **  using the existing default or rule as their default or rule.  This default
95        **  action may be overridden by setting @futureonly = @futurevalue when the
96        **  procedure is invoked.  In this case existing columns with the user
97        **  datatype won't have their existing default or rule changed.
98        */
99    
100       /*
101       **  Check to see that the object names are local to the current database.
102       */
103       if (@objname like "%.%.%")
104           or
105           (@rulename like "%.%.%" and
106               substring(@rulename, 1, charindex(".", @rulename) - 1) != db_name())
107       begin
108           /*
109           ** 17350, "Rule and table or usertype must be in 'current' database."
110           */
111           raiserror 17350
112           return (1)
113       end
114   
115       /*
116       **  Check that the @futureonly argument, if supplied, is correct.
117       */
118       if (@futureonly is not null)
119       begin
120           if (@futureonly != @futurevalue)
121           begin
122               /*
123               ** 17351, "Usage: bindrule rulename, objectname [, 'futureonly']"
124               */
125               raiserror 17351
126               return (1)
127           end
128       end
129   
130       /*
131       **  Check to see that the rule exists and get it's id.
132       */
133       if not exists (select id
134               from sysobjects
135               where id = object_id(@rulename)
136                   and sysstat & 7 = 7) /* rule object */
137   
138       begin
139           /*
140           ** 17352, "No rule named '%1!' exists. You must create the rule first."
141           */
142           raiserror 17352, @rulename
143           return (1)
144       end
145   
146       /* Check for access-rule: status bit 0x01000000 (16777216)  is set */
147       select @access_rule = sysstat2 & 16777216
148       from sysobjects
149       where id = object_id(@rulename)
150           and sysstat & 7 = 7 /* rule object */
151   
152       /*
153       ** Check to see that the rule is not of declared type
154       */
155   
156       if exists (select * from sysprocedures
157               where id = object_id(@rulename)
158                   and sequence = 0
159                   and status & 4096 = 4096)
160       begin
161           /*
162           ** 17358, "You cannot bind a declared constraint. The rule must be created \
163           using create rule."
164           */
165           raiserror 17358
166           return (1)
167       end
168   
169       /*
170       **  If @objname is of the form tab.col then we are binding to a column.
171       **  Otherwise its a datatype.  In the column case, we need to extract
172       **  and verify the table and column names and make sure the user owns
173       **  the table that is getting the rule bound.
174       */
175       if @objname like "%.%"
176       begin
177           declare @tabname varchar(255) /* name of table */
178           declare @colname varchar(255) /* name of column */
179           select @maxobjlen = length from syscolumns
180           where id = object_id("sysobjects") and name = "name"
181           select @maxuserlen = length from syscolumns
182           where id = object_id("sysusers") and name = "name"
183           select @maxtotlen = (@maxobjlen + @maxuserlen) + 1
184   
185           /*
186           **  Get the table name out.
187           */
188           select @tabname = substring(@objname, 1, charindex(".", @objname) - 1)
189           select @colname = substring(@objname, charindex(".", @objname) + 1, @maxtotlen)
190   
191           /*
192           **  If the column type is image, text, unitext, off-row Java class,
193           **  or timestamp, disallow the bind. Rules can't be bound to image, 
194           **  text, unitext, off-row Java class, or timestamp columns.
195           **  The qualification to check for types is a little strange because
196           **  text and image are real, basic data types while timestamp is not.
197           **  Timestamp is really a binary.  The types are checked in case
198           **  there is a user-defined datatype that is an image or text.
199           **  User-defined datatypes mapping to timestamp are not allowed
200           **  by sp_addtype.
201           */
202           if exists (select *
203                   from sysobjects o, syscolumns c
204                   where c.id = object_id(@tabname)
205                       and c.name = @colname
206                       and c.name = @colname
207                       and o.id = object_id(@tabname)
208                       and o.sysstat & 7 = 3
209                       and (c.type in (35, 34, 174) or c.usertype = 80
210                           or (c.type = 36 and c.xstatus & 1 != 1)))
211           begin
212               /*
213               ** 17353, "You can't bind a rule to a text, image, unitext, off-row Java class, or timestamp datatype column."
214               */
215               raiserror 17353
216               return (1)
217           end
218   
219           /*
220           ** Cannot bind a rule to a virtual computed column. 
221           */
222           if exists (select 1 from syscolumns c
223                   where c.id = object_id(@tabname)
224                       and c.name = @colname
225                       and c.status2 & 16 = 16
226                       and c.status2 & 32 != 32)
227           begin
228               /*
229               ** 17359, "You cannot bind a rule to a virtual computed column."
230               */
231               raiserror 17359
232               return (1)
233           end
234   
235           /*
236           ** Cannot bind a rule to a function-based index key
237           */
238           if exists (select 1 from syscolumns c
239                   where c.id = object_id(@tabname)
240                       and c.name = @colname
241                       and c.status3 & 1 = 1)
242           begin
243               /*
244               ** 19359, "You cannot bind a rule to a function-based index key."
245               */
246               raiserror 19359
247               return (1)
248           end
249   
250           /*
251           ** If status of the column does not reflect having more than one
252           ** check constraint (declared rule), then update the status if
253           ** it has additional constraint(s).
254           */
255   
256           select @status = status, @colid = colid from syscolumns, sysobjects
257           where syscolumns.id = object_id(@tabname)
258               and syscolumns.name = @colname
259               and sysobjects.id = object_id(@tabname)
260               and uid = user_id()
261               and sysobjects.sysstat & 7 = 3 /* user table */
262   
263           /*
264           **  Did the bind happen?
265           */
266           if @@rowcount != 1
267           begin
268               /*
269               ** 17344, "You do not own a column of that name." 
270               */
271               /* Audit the failure to bind a rule */
272               select @returncode =
273                   ad_hoc_audit(@eventnum, @mod_fail, @rulename, db_name(),
274                       @tabname, user_name(), 0, object_id(@tabname)
275                   )
276               raiserror 17344
277               return (1)
278           end
279   
280           /* get the security label of the object */
281   
282           /* Audit the succesful permission to bind a rule */
283           select @returncode =
284               ad_hoc_audit(@eventnum, @mod_ok, @rulename, db_name(),
285                   @tabname, user_name(), 0, object_id(@tabname)
286               )
287           if (@returncode != 0)
288           begin
289               /* 
290               ** 18293, "Auditing for '%1!' event has failed due to 
291               ** internal error. Contact a user with System Security 
292               ** Officer (SSO) role."
293               */
294               raiserror 18293, @eventnum
295               return (1)
296           end
297   
298           if (@access_rule > 0)
299           begin
300               update syscolumns
301               set accessrule = object_id(@rulename)
302               from syscolumns, sysobjects
303               where syscolumns.id = object_id(@tabname)
304                   and syscolumns.name = @colname
305                   and sysobjects.id = object_id(@tabname)
306                   and uid = user_id()
307                   and sysobjects.sysstat & 7 = 3 /* user table */
308           end
309           else
310           begin
311               if @status & 16 = 0 and
312                   exists (select * from sysconstraints c, sysobjects o
313                       where c.tableid = object_id(@tabname)
314                           and c.colid = @colid
315                           and o.id = c.constrid
316                           and o.sysstat & 7 = 7)
317               begin
318                   update syscolumns
319                   set domain = object_id(@rulename),
320                       status = syscolumns.status | 16
321                   from syscolumns, sysobjects
322                   where syscolumns.id = object_id(@tabname)
323                       and syscolumns.name = @colname
324                       and sysobjects.id = object_id(@tabname)
325                       and uid = user_id()
326                       and sysobjects.sysstat & 7 = 3 /* user table */
327               end
328               else
329               begin
330                   update syscolumns
331                   set domain = object_id(@rulename)
332                   from syscolumns, sysobjects
333                   where syscolumns.id = object_id(@tabname)
334                       and syscolumns.name = @colname
335                       and sysobjects.id = object_id(@tabname)
336                       and uid = user_id()
337                       and sysobjects.sysstat & 7 = 3 /* user table */
338               end
339           end
340           /*
341           **  Since binding a rule is a schema change, update schema count
342           **  for the object in the sysobjects table.
343           */
344   
345           /* 
346           ** This transaction also writes a log record for replicating the
347           ** invocation of this procedure. If logexec() fails, the transaction
348           ** is aborted.
349           **
350           ** IMPORTANT: The name rs_logexec is significant and is used by
351           ** Replication Server.
352           */
353           begin transaction rs_logexec
354   
355           if (schema_inc(object_id(@tabname), 0) != 1)
356           begin
357               /*
358               ** 17763, "The execution of the stored procedure '%1!'
359               **         in database '%2!' was aborted because there
360               **         was an error in updating the column
361               **         schemacnt in sysobjects."
362               */
363               select @dbname = db_name()
364               raiserror 17763, "sp_bindrule", @dbname
365               rollback transaction rs_logexec
366               return (1)
367           end
368   
369           update sysobjects
370           set sysstat2 = sysstat2 | @access_rule
371           from sysobjects
372           where id = object_id(@tabname)
373               and uid = user_id()
374   
375           /*
376           ** If we bound an access rule to the column, we must make sure
377           ** that the DES is updated in the cache 
378           */
379           if @access_rule > 0
380           begin
381               select @tmp = set_accessrule(object_id(@tabname), 1)
382               if (@tmp = - 1)
383               begin
384                   rollback transaction rs_logexec
385                   /* FGAC_RESOLVE: Add a message */
386                   return 1
387               end
388           end
389   
390           /*
391           ** Write the log record to replicate this invocation 
392           ** of the stored procedure.
393           */
394           if (logexec() != 1)
395           begin
396               /*
397               ** 17756, "The execution of the stored procedure '%1!'
398               ** 	   in database '%2!' was aborted because there
399               ** 	   was an error in writing the replication log
400               **	   record."
401               */
402               select @dbname = db_name()
403               raiserror 17756, "sp_bindrule", @dbname
404   
405               rollback transaction rs_logexec
406               return (1)
407           end
408   
409           commit transaction
410   
411           /*
412           ** 17354, "Rule bound to table column."
413           */
414           exec sp_getmessage 17354, @msg output
415           print @msg
416   
417       end
418       else
419       begin
420           /*
421           **  We're binding to a user type.  In this case, the @objname
422           **  is really the name of the user datatype.
423           **  When we bind to a user type, any existing columns get changed
424           **  to the new binding unless their current binding is not equal
425           **  to the current binding for the usertype or if they set the
426           **  @futureonly parameter to @futurevalue.
427           */
428           declare @oldrule int /* current rule for type */
429   
430           /*
431           **  If the column type is image, text, unitext, or timestamp, 
432           **  disallow the bind.
433           **  Rules can't be bound to image, unitext or text columns.
434           */
435           if exists (select *
436                   from systypes
437                   where name = @objname
438                       and (type in (35, 34, 174) or usertype = 80))
439           begin
440               /*
441               ** 17355, "You can't bind a rule to a text, unitext, image, or timestamp datatype."
442               */
443               raiserror 17355
444               return (1)
445           end
446   
447           if not exists (select * from systypes
448                   where name = @objname
449                       and uid = user_id()
450                       and usertype > 100)
451           begin
452               /*
453               ** 17346, "You do not own a datatype of that name."
454               */
455               /* Audit the failure to bind a rule */
456               select @returncode =
457                   ad_hoc_audit(@eventnum, @mod_fail, @rulename,
458                       db_name(), @objname, user_name(), 0,
459                       object_id(@objname)
460                   )
461               raiserror 17346
462               return (1)
463           end
464   
465   
466           /*
467           **  Get the current rule for the datatype.
468           */
469           if (@access_rule = 0)
470           begin
471               select @oldrule = domain
472               from systypes
473               where name = @objname
474                   and uid = user_id()
475                   and usertype > 100
476           end
477           else
478           begin
479               select @oldrule = accessrule
480               from systypes
481               where name = @objname
482                   and uid = user_id()
483                   and usertype > 100
484           end
485   
486           /* get the security label of the object */
487           /* Audit the successful permission to bind a rule */
488           select @returncode =
489               ad_hoc_audit(@eventnum, @mod_ok, @rulename, db_name(),
490                   @objname, user_name(), 0, object_id(@objname)
491               )
492           if (@returncode != 0)
493           begin
494               /* 
495               ** 18293, "Auditing for '%1!' event has failed due to 
496               ** internal error. Contact a user with System Security 
497               ** Officer (SSO) role."
498               */
499               raiserror 18293, @eventnum
500               return (1)
501           end
502   
503           /*
504           ** This transaction also writes a log record for
505           ** replicating the invocation of this procedure. If
506           ** logexec() fails, the transaction is aborted.
507           **
508           ** IMPORTANT: The name rs_logexec is significant and is
509           ** used by Replication Server.
510           */
511           begin transaction rs_logexec
512   
513           if (@access_rule > 0)
514           begin
515               update systypes
516               set accessrule = object_id(@rulename)
517               from systypes
518               where name = @objname
519                   and uid = user_id()
520                   and usertype > 100
521           end
522           else
523           begin
524               update systypes
525               set domain = object_id(@rulename)
526               from systypes
527               where name = @objname
528                   and uid = user_id()
529                   and usertype > 100
530           end
531   
532           /*
533           ** 17356, "Rule bound to datatype."
534           */
535           exec sp_getmessage 17356, @msg output
536           print @msg
537   
538   
539           /*
540           **  Now see if there are any columns with the usertype that
541           **  need the new binding.
542           */
543   
544           select @rows_selected = 0
545           if isnull(@futureonly, "") != @futurevalue
546           begin
547               select @rows_selected = count(distinct syscolumns.id)
548               from syscolumns, systypes
549               where syscolumns.usertype = systypes.usertype
550                   and systypes.name = @objname
551                   and systypes.usertype > 100
552                   and systypes.uid = user_id()
553                   and ((syscolumns.domain = @oldrule
554                           or syscolumns.domain = 0)
555                       or (syscolumns.accessrule = @oldrule
556                           or syscolumns.accessrule is NULL
557                           or syscolumns.accessrule = 0))
558   
559   
560               if (@rows_selected > 0)
561               begin
562                   /*
563                   **  Update the table schema to indicate that something
564                   **  has changed in the table's schema.
565                   */
566   
567                   select @tmp = sum(schema_inc(s.id, 0))
568                   from sysobjects s
569                   where exists
570                           (select 1
571                           from syscolumns, systypes
572                           where s.id = syscolumns.id
573                               and syscolumns.usertype = systypes.usertype
574                               and systypes.name = @objname
575                               and systypes.usertype > 100
576                               and systypes.uid = user_id()
577                               and ((syscolumns.domain = @oldrule
578                                       or syscolumns.domain = 0)
579                                   or (syscolumns.accessrule = @oldrule
580                                       or syscolumns.accessrule is NULL
581                                       or syscolumns.accessrule = 0)))
582   
583   
584                   if (@rows_selected != @tmp)
585                   begin
586                       /*
587                       ** 17763, "The execution of the stored procedure '%1!'
588                       **         in database '%2!' was aborted because there
589                       **         was an error in updating the column
590                       **         schemacnt in sysobjects."
591                       */
592                       select @dbname = db_name()
593                       raiserror 17763, "sp_bindrule", @dbname
594                       rollback transaction rs_logexec
595                       return (1)
596                   end
597   
598                   if (@access_rule > 0)
599                   begin
600                       update sysobjects
601                       set sysstat2 = sysstat2 | @access_rule
602                       from sysobjects s
603                       where exists
604                               (select 1
605                               from syscolumns, systypes
606                               where s.id = syscolumns.id
607                                   and syscolumns.usertype = systypes.usertype
608                                   and systypes.name = @objname
609                                   and systypes.usertype > 100
610                                   and systypes.uid = user_id()
611                                   and (syscolumns.accessrule = @oldrule
612                                       or syscolumns.accessrule = 0
613                                       or syscolumns.accessrule is NULL))
614   
615                       /*
616                       **  Update syscolumns with new binding.
617                       */
618                       update syscolumns
619                       set accessrule = systypes.accessrule
620                       from syscolumns, systypes
621                       where syscolumns.usertype = systypes.usertype
622                           and systypes.name = @objname
623                           and systypes.usertype > 100
624                           and systypes.uid = user_id()
625                           and (syscolumns.accessrule = @oldrule
626                               or syscolumns.accessrule = 0
627                               or syscolumns.accessrule is NULL)
628                   end
629                   else
630                   begin
631                       update sysobjects
632                       set sysstat2 = sysstat2 | @access_rule
633                       from sysobjects s
634                       where exists
635                               (select 1
636                               from syscolumns, systypes
637                               where s.id = syscolumns.id
638                                   and syscolumns.usertype = systypes.usertype
639                                   and systypes.name = @objname
640                                   and systypes.usertype > 100
641                                   and systypes.uid = user_id()
642                                   and (syscolumns.domain = @oldrule
643                                       or syscolumns.domain = 0))
644   
645                       /*
646                       **  Update syscolumns with new binding.
647                       */
648                       update syscolumns
649                       set domain = systypes.domain
650                       from syscolumns, systypes
651                       where syscolumns.usertype = systypes.usertype
652                           and systypes.name = @objname
653                           and systypes.usertype > 100
654                           and systypes.uid = user_id()
655                           and (syscolumns.domain = @oldrule
656                               or syscolumns.domain = 0)
657                   end
658   
659                   /*
660                   ** Note that new binding has occurred.
661                   */
662                   select @new_binding = 1
663   
664                   /*
665                   ** If we bound an access rule to a column of one or 
666                   ** more tables, we must make sure that the DESs for these
667                   ** tables flushed from the cache and re-read to pick up
668                   ** the new sysstat2 value.
669                   */
670                   if @access_rule > 0
671                   begin
672                       select @dbcc_dbid = db_id()
673   
674                       declare tab_cursor cursor for
675                       select distinct sysobjects.id
676                       from sysobjects, syscolumns
677                       where sysobjects.id = syscolumns.id
678                           and syscolumns.accessrule = object_id(@rulename)
679   
680                       open tab_cursor
681   
682                       fetch tab_cursor into @obj_id
683   
684                       while (@@sqlstatus = 0)
685                       begin
686                           select @tmp = set_accessrule(@obj_id, 1)
687                           /* FGAC RESOLVE -- Add a new messsage */
688                           if (@tmp = - 1)
689                           begin
690                               rollback transaction rs_logexec
691                               close tab_cursor
692                               deallocate cursor tab_cursor
693                               return (1)
694                           end
695   
696                           fetch tab_cursor into @obj_id
697                       end
698   
699                       close tab_cursor
700                       deallocate cursor tab_cursor
701                   end
702               end
703           end
704   
705           /*
706           ** Write the log record to replicate this invocation 
707           ** of the stored procedure.
708           */
709           if (logexec() != 1)
710           begin
711               /*
712               ** 17756, "The execution of the stored procedure
713               **         '%1!' in database '%2!' was aborted
714               **	    because there was an error in writing
715               **	    the replication log record."
716               */
717               select @dbname = db_name()
718               raiserror 17756, "sp_bindrule", @dbname
719   
720               rollback transaction rs_logexec
721               return (1)
722           end
723   
724           commit transaction
725   
726           /*
727           ** If a new binding has occurred, display message 17357.
728           */
729           if (@new_binding = 1)
730           begin
731               /*
732               ** 17357, "The new rule has been bound to column(s) of the
733               **	   specified user datatype."
734               */
735               exec sp_getmessage 17357, @msg output
736               print @msg
737           end
738       end
739   
740       return (0)
741   
742   


exec sp_procxmode 'sp_bindrule', 'AnyMode'
go

Grant Execute on sp_bindrule to public
go
DEFECTS
 MCTR 4 Conditional Begin Tran or Commit Tran 353
 MCTR 4 Conditional Begin Tran or Commit Tran 409
 MCTR 4 Conditional Begin Tran or Commit Tran 511
 MCTR 4 Conditional Begin Tran or Commit Tran 724
 MEST 4 Empty String will be replaced by Single Space 545
 QCAS 4 Cartesian product with single row between tables sybsystemprocs..sysobjects o and [sybsystemprocs..syscolumns c], 2 tables with rc=1 202
 QCAS 4 Cartesian product with single row between tables sybsystemprocs..syscolumns and [sybsystemprocs..sysobjects], 3 tables with rc=1 256
 QCAS 4 Cartesian product with single row between tables sybsystemprocs..syscolumns and [sybsystemprocs..sysobjects], 3 tables with rc=1 300
 QCAS 4 Cartesian product with single row between tables sybsystemprocs..syscolumns and [sybsystemprocs..sysobjects], 3 tables with rc=1 318
 QCAS 4 Cartesian product with single row between tables sybsystemprocs..syscolumns and [sybsystemprocs..sysobjects], 3 tables with rc=1 330
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 209
 QTYP 4 Comparison type mismatch Comparison type mismatch: tinyint vs int 210
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 438
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 450
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 475
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 483
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 520
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 529
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 551
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 575
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 609
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 623
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 640
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 653
 CUNU 3 Cursor not updated: cursor should contain 'for read only' clause tab_cursor 675
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 133
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 135
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 149
 MAW1 3 Warning message on %name% sybsystemprocs..sysprocedures.id: Warning message on sysprocedures 157
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 180
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 182
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 204
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 207
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 223
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 239
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 257
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 259
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 303
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 305
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 315
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 322
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 324
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 333
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 335
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 372
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 547
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 567
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 572
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 572
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 606
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 606
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 637
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 637
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 675
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 677
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 677
 MGTP 3 Grant to public sybsystemprocs..sp_bindrule  
 MGTP 3 Grant to public sybsystemprocs..syscolumns  
 MGTP 3 Grant to public sybsystemprocs..sysconstraints  
 MGTP 3 Grant to public sybsystemprocs..sysobjects  
 MGTP 3 Grant to public sybsystemprocs..sysprocedures  
 MGTP 3 Grant to public sybsystemprocs..systypes  
 MNER 3 No Error Check should check @@error after update 300
 MNER 3 No Error Check should check @@error after update 318
 MNER 3 No Error Check should check @@error after update 330
 MNER 3 No Error Check should check @@error after update 369
 MNER 3 No Error Check should check return value of exec 414
 MNER 3 No Error Check should check @@error after update 515
 MNER 3 No Error Check should check @@error after update 524
 MNER 3 No Error Check should check return value of exec 535
 MNER 3 No Error Check should check @@error after update 600
 MNER 3 No Error Check should check @@error after update 618
 MNER 3 No Error Check should check @@error after update 631
 MNER 3 No Error Check should check @@error after update 648
 MNER 3 No Error Check should check return value of exec 735
 MUCO 3 Useless Code Useless Brackets 112
 MUCO 3 Useless Code Useless Brackets 118
 MUCO 3 Useless Code Useless Brackets 120
 MUCO 3 Useless Code Useless Brackets 126
 MUCO 3 Useless Code Useless Brackets 143
 MUCO 3 Useless Code Useless Brackets 166
 MUCO 3 Useless Code Useless Brackets 216
 MUCO 3 Useless Code Useless Brackets 232
 MUCO 3 Useless Code Useless Brackets 247
 MUCO 3 Useless Code Useless Brackets 277
 MUCO 3 Useless Code Useless Brackets 287
 MUCO 3 Useless Code Useless Brackets 295
 MUCO 3 Useless Code Useless Brackets 298
 MUCO 3 Useless Code Useless Brackets 355
 MUCO 3 Useless Code Useless Brackets 366
 MUCO 3 Useless Code Useless Brackets 382
 MUCO 3 Useless Code Useless Brackets 394
 MUCO 3 Useless Code Useless Brackets 406
 MUCO 3 Useless Code Useless Brackets 444
 MUCO 3 Useless Code Useless Brackets 462
 MUCO 3 Useless Code Useless Brackets 469
 MUCO 3 Useless Code Useless Brackets 492
 MUCO 3 Useless Code Useless Brackets 500
 MUCO 3 Useless Code Useless Brackets 513
 MUCO 3 Useless Code Useless Brackets 560
 MUCO 3 Useless Code Useless Brackets 584
 MUCO 3 Useless Code Useless Brackets 595
 MUCO 3 Useless Code Useless Brackets 598
 MUCO 3 Useless Code Useless Brackets 684
 MUCO 3 Useless Code Useless Brackets 688
 MUCO 3 Useless Code Useless Brackets 693
 MUCO 3 Useless Code Useless Brackets 709
 MUCO 3 Useless Code Useless Brackets 721
 MUCO 3 Useless Code Useless Brackets 729
 MUCO 3 Useless Code Useless Brackets 740
 MUOT 3 Updates outside transaction 330
 MUUF 3 Update or Delete with Useless From Clause 369
 MUUF 3 Update or Delete with Useless From Clause 515
 MUUF 3 Update or Delete with Useless From Clause 524
 QAFM 3 Var Assignment from potentially many rows 179
 QAFM 3 Var Assignment from potentially many rows 181
 QDIS 3 Check correct use of 'select distinct' 675
 QGWO 3 Group by/Distinct/Union without order by 675
 QISO 3 Set isolation level 85
 QNAJ 3 Not using ANSI Inner Join 203
 QNAJ 3 Not using ANSI Inner Join 256
 QNAJ 3 Not using ANSI Inner Join 302
 QNAJ 3 Not using ANSI Inner Join 312
 QNAJ 3 Not using ANSI Inner Join 321
 QNAJ 3 Not using ANSI Inner Join 332
 QNAJ 3 Not using ANSI Inner Join 548
 QNAJ 3 Not using ANSI Inner Join 571
 QNAJ 3 Not using ANSI Inner Join 605
 QNAJ 3 Not using ANSI Inner Join 620
 QNAJ 3 Not using ANSI Inner Join 636
 QNAJ 3 Not using ANSI Inner Join 650
 QNAJ 3 Not using ANSI Inner Join 676
 QNUA 3 Should use Alias: Column colid should use alias syscolumns 256
 QNUA 3 Should use Alias: Column status should use alias syscolumns 256
 QNUA 3 Should use Alias: Table sybsystemprocs..syscolumns 256
 QNUA 3 Should use Alias: Table sybsystemprocs..sysobjects 256
 QNUA 3 Should use Alias: Column uid should use alias sysobjects 260
 QNUA 3 Should use Alias: Table sybsystemprocs..sysobjects 302
 QNUA 3 Should use Alias: Column uid should use alias sysobjects 306
 QNUA 3 Should use Alias: Table sybsystemprocs..sysobjects 321
 QNUA 3 Should use Alias: Column uid should use alias sysobjects 325
 QNUA 3 Should use Alias: Table sybsystemprocs..sysobjects 332
 QNUA 3 Should use Alias: Column uid should use alias sysobjects 336
 QNUA 3 Should use Alias: Table sybsystemprocs..syscolumns 548
 QNUA 3 Should use Alias: Table sybsystemprocs..systypes 548
 QNUA 3 Should use Alias: Table sybsystemprocs..syscolumns 571
 QNUA 3 Should use Alias: Table sybsystemprocs..systypes 571
 QNUA 3 Should use Alias: Table sybsystemprocs..syscolumns 605
 QNUA 3 Should use Alias: Table sybsystemprocs..systypes 605
 QNUA 3 Should use Alias: Table sybsystemprocs..systypes 620
 QNUA 3 Should use Alias: Table sybsystemprocs..syscolumns 636
 QNUA 3 Should use Alias: Table sybsystemprocs..systypes 636
 QNUA 3 Should use Alias: Table sybsystemprocs..systypes 650
 QNUA 3 Should use Alias: Table sybsystemprocs..syscolumns 676
 QNUA 3 Should use Alias: Table sybsystemprocs..sysobjects 676
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysprocedures.csysprocedures unique clustered
(id, number, type, sequence)
Intersection: {id, sequence}
157
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
180
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
182
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
204
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
223
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
239
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
257
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
303
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
322
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
333
 QRPR 3 Repeated predicate c.name = @colname 206
 QSWV 3 Sarg with variable @tabname, Candidate Index: sysconstraints.csysconstraints clustered(tableid, colid) F 313
 QSWV 3 Sarg with variable @colid, Candidate Index: sysconstraints.csysconstraints clustered(tableid, colid) F 314
 VNRD 3 Variable is not read @dbcc_dbid 672
 CRDO 2 Read Only Cursor Marker (has a 'distinct' option) 675
 MSUB 2 Subquery Marker 133
 MSUB 2 Subquery Marker 156
 MSUB 2 Subquery Marker 202
 MSUB 2 Subquery Marker 222
 MSUB 2 Subquery Marker 238
 MSUB 2 Subquery Marker 312
 MSUB 2 Subquery Marker 435
 MSUB 2 Subquery Marker 447
 MSUC 2 Correlated Subquery Marker 570
 MSUC 2 Correlated Subquery Marker 604
 MSUC 2 Correlated Subquery Marker 635
 MTR1 2 Metrics: Comments Ratio Comments: 44% 39
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 71 = 88dec - 19exi + 2 39
 MTR3 2 Metrics: Query Complexity Complexity: 366 39
 PRED_QUERY_COLLECTION 2 {c=sybsystemprocs..sysconstraints, o=sybsystemprocs..sysobjects} 0 312
 PRED_QUERY_COLLECTION 2 {c=sybsystemprocs..syscolumns, t=sybsystemprocs..systypes} 0 547
 PRED_QUERY_COLLECTION 2 {c=sybsystemprocs..syscolumns, o=sybsystemprocs..sysobjects, t=sybsystemprocs..systypes} 0 570
 PRED_QUERY_COLLECTION 2 {c=sybsystemprocs..syscolumns, o=sybsystemprocs..sysobjects, t=sybsystemprocs..systypes} 0 604
 PRED_QUERY_COLLECTION 2 {c=sybsystemprocs..syscolumns, t=sybsystemprocs..systypes} 0 618
 PRED_QUERY_COLLECTION 2 {c=sybsystemprocs..syscolumns, o=sybsystemprocs..sysobjects, t=sybsystemprocs..systypes} 0 635
 PRED_QUERY_COLLECTION 2 {c=sybsystemprocs..syscolumns, t=sybsystemprocs..systypes} 0 648
 PRED_QUERY_COLLECTION 2 {c=sybsystemprocs..syscolumns, o=sybsystemprocs..sysobjects} 0 675

DATA PROPAGATION detailed
ColumnWritten To
@rulenamesyscolumns.domain   °.accessrule   systypes.domain   °.accessrule  

DEPENDENCIES
PROCS AND TABLES USED
calls proc sybsystemprocs..sp_getmessage  
   reads table master..syslanguages (1)  
   reads table sybsystemprocs..sysusermessages  
   calls proc sybsystemprocs..sp_validlang  
      reads table master..syslanguages (1)  
   reads table master..sysmessages (1)  
reads table sybsystemprocs..sysconstraints  
read_writes table sybsystemprocs..syscolumns  
reads table sybsystemprocs..sysprocedures  
read_writes table sybsystemprocs..systypes  
read_writes table sybsystemprocs..sysobjects