DatabaseProcApplicationCreatedLinks
sybsystemprocssp_ddlgen_db_print_alterdb  31 Aug 14Defects Dependencies

1     
2     /*
3     ** sp_ddlgen_db_print_alterdb
4     **
5     **	Print the ALTER DATABASE clause, with the given parameters. The caller
6     ** 	has already decided that there is a change in disk pieces that needs
7     **	a new ALTER DATABASE to be issued.
8     **	This procedure is called to print the start of a new ALTER DATABASE SQL
9     **	block. It will first terminate a previously generated ALTER DATABASE 
10    **	block with any required WITH OVERRIDE clause, and then will start a 
11    **	fresh SQL command.
12    **
13    ** Parameters:
14    **	@dbname		- Name of db for which DDL is being generated.
15    **	@archivedb	- Boolean; whether it's an archive db.
16    **	@alterdb_sql	- SQL for 'ALTER DATABASE'
17    **	@segment	- Segment's characteristics
18    **	@durability	- DURABILITY setting of db
19    **	@dmllogging	- DML_LOGGING setting of db
20    **	@with_override	- Boolean; whether WITH OVERRIDE should be generated.
21    **	@with_dur_and_dmllog
22    **			- Boolean; whether WITH DURABILITY AND DML_LOGGING
23    **			  should be generated.
24    **	@with_dcomp_and_IRL
25    **			- Boolean; whether WITH COMPRESSION, LOB_COMPRESSION AND
26    **			  INROW_LOB_LENGTH should be generated.
27    **	@data_compression	- data compression setting of db
28    **	@lob_compression	- lob compression setting of db
29    **	@inrow_lob_length	- inrow lob length of db
30    **	@prefix		- Prefix string, for formatting.
31    **
32    ** Returns:	0, always.
33    {
34    */
35    create procedure sp_ddlgen_db_print_alterdb(
36        @dbname varchar(30)
37        , @archivedb tinyint
38        , @alterdb_sql varchar(15)
39        , @segment varchar(12)
40        , @durability varchar(13)
41        , @dmllogging varchar(9)
42        , @data_compression varchar(4)
43        , @lob_compression int
44        , @inrow_lob_length int
45        , @trace int
46        , @reason varchar(30)
47        , @with_override tinyint output
48        , @with_dur_and_dmllog tinyint output
49        , @with_dcomp_and_IRL tinyint output
50        , @prefix varchar(10) output
51    ) as
52        begin -- {
53            declare @newline char(1)
54                , @tabchar char(1)
55                , @comment char(3)
56                , @retval int
57                , @indent varchar(10)
58    
59            select @newline = char(10)
60                , @tabchar = char(9)
61                , @comment = "-- "
62                , @indent = space(@@nestlevel * 2)
63    
64    
65            exec @retval = sp_ddlgen_db_print_with_clause @with_override
66                , @with_dur_and_dmllog
67                , @with_dcomp_and_IRL
68                , @durability
69                , @dmllogging
70                , @data_compression
71                , @lob_compression
72                , @inrow_lob_length
73                , @archivedb
74    
75            if (@trace = 2)
76            begin
77                print " "
78                print "%1!---- Trace sp_ddlgen_db_print_alterdb ----", @indent
79                print "%1!Generate '%2! %3!' because %4!. @archivedb=%5! @segment='%6!'"
80                    , @indent
81                    , @alterdb_sql, @dbname, @reason
82                    , @archivedb, @segment
83                print "@with_override=%1! @with_dur_and_dmllog=%2! @with_dcomp_and_IRL=%3!"
84                    , @with_override, @with_dur_and_dmllog, @with_dcomp_and_IRL
85                print "%1!---- End Trace sp_ddlgen_db_print_alterdb ----"
86                    , @indent
87                print " "
88            end
89    
90            -- print: ALTER DATABASE 
91            print "%1! %2!", @alterdb_sql, @dbname
92    
93            -- We are restarting a newblock of disk pieces that
94            -- will be investigated. Reset 'prev' variables,
95            -- and other variables.
96            --
97            select @with_override = 0
98                , @with_dur_and_dmllog = 0
99                , @with_dcomp_and_IRL = 0
100   
101           select @prefix = @tabchar + case @segment when "log only"
102                   then "LOG ON "
103                   else "    ON "
104               end
105           return 0
106       end -- }
107   

DEFECTS
 MNER 3 No Error Check should check return value of exec 65
 MUCO 3 Useless Code Useless Brackets in create proc 35
 MUCO 3 Useless Code Useless Begin-End Pair 52
 MUCO 3 Useless Code Useless Brackets 75
 VNRD 3 Variable is not read @newline 59
 VNRD 3 Variable is not read @comment 61
 VNRD 3 Variable is not read @retval 65
 MTR1 2 Metrics: Comments Ratio Comments: 44% 35
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 2 = 1dec - 1exi + 2 35
 MTR3 2 Metrics: Query Complexity Complexity: 16 35

DEPENDENCIES
PROCS AND TABLES USED
calls proc sybsystemprocs..sp_ddlgen_db_print_with_clause  

CALLERS
called by proc sybsystemprocs..sp_ddlgen_database