DatabaseProcApplicationCreatedLinks
sybsystemprocssp_ddlgen_db_print_alterdb  14 déc. 14Defects Propagation 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    **	@with_dek_name
28    **			- Boolean; whether WITH Database Encryption Key
29    **			  should be generated.
30    **	@data_compression	- data compression setting of db
31    **	@lob_compression	- lob compression setting of db
32    **	@inrow_lob_length	- inrow lob length of db
33    **	@dek_name		- the name of database encryption key
34    **	@prefix		- Prefix string, for formatting.
35    **
36    ** Returns:	0, always.
37    {
38    */
39    create or replace procedure sp_ddlgen_db_print_alterdb(
40        @dbname varchar(30)
41        , @archivedb tinyint
42        , @alterdb_sql varchar(15)
43        , @segment varchar(12)
44        , @durability varchar(13)
45        , @dmllogging varchar(9)
46        , @data_compression varchar(4)
47        , @lob_compression int
48        , @inrow_lob_length int
49        , @dek_name varchar(255)
50        , @trace int
51        , @reason varchar(30)
52        , @with_override tinyint output
53        , @with_dur_and_dmllog tinyint output
54        , @with_dcomp_and_IRL tinyint output
55        , @with_dek_name tinyint output
56        , @prefix varchar(10) output
57    ) as
58        begin -- {
59            declare @newline char(1)
60                , @tabchar char(1)
61                , @comment char(3)
62                , @retval int
63                , @indent varchar(10)
64    
65            select @newline = char(10)
66                , @tabchar = char(9)
67                , @comment = "-- "
68                , @indent = space(@@nestlevel * 2)
69    
70    
71            exec @retval = sp_ddlgen_db_print_with_clause @with_override
72                , @with_dur_and_dmllog
73                , @with_dcomp_and_IRL
74                , @with_dek_name
75                , @durability
76                , @dmllogging
77                , @data_compression
78                , @lob_compression
79                , @inrow_lob_length
80                , @dek_name
81                , @archivedb
82    
83            if (@trace = 2)
84            begin
85                print " "
86                print "%1!---- Trace sp_ddlgen_db_print_alterdb ----", @indent
87                print "%1!Generate '%2! %3!' because %4!. @archivedb=%5! @segment='%6!'"
88                    , @indent
89                    , @alterdb_sql, @dbname, @reason
90                    , @archivedb, @segment
91                print "@with_override=%1! @with_dur_and_dmllog=%2! @with_dcomp_and_IRL=%3! @with_dek_name=%4!"
92                    , @with_override, @with_dur_and_dmllog, @with_dcomp_and_IRL, @with_dek_name
93                print "%1!---- End Trace sp_ddlgen_db_print_alterdb ----"
94                    , @indent
95                print " "
96            end
97    
98            -- print: ALTER DATABASE 
99            print "%1! %2!", @alterdb_sql, @dbname
100   
101           -- We are restarting a newblock of disk pieces that
102           -- will be investigated. Reset 'prev' variables,
103           -- and other variables.
104           --
105           select @with_override = 0
106               , @with_dur_and_dmllog = 0
107               , @with_dcomp_and_IRL = 0
108               , @with_dek_name = 0
109   
110   
111           select @prefix = @tabchar + case @segment when "log only"
112                   then "LOG ON "
113                   else "    ON "
114               end
115           return 0
116       end -- }
117   

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

DEPENDENCIES
PROCS AND TABLES USED
calls proc sybsystemprocs..sp_ddlgen_db_print_with_clause  

CALLERS
called by proc sybsystemprocs..sp_ddlgen_database