1
- create language plpgsql ;
1
+ CREATE LANGUAGE plpgsql ;
2
2
3
3
-- Engler's names of bugs
4
- create table bug_categories (
5
- standardized_name VarChar (256 ) not null ,
6
- standardized_name_id integer NOT NULL ,
4
+ CREATE TABLE bug_categories (
5
+ standardized_name VarChar (256 ),
6
+ standardized_name_id integer ,
7
7
8
- primary key (standardized_name),
9
- unique (standardized_name_id)
8
+ PRIMARY KEY (standardized_name, standardized_name_id)
10
9
);
11
10
12
11
-- binding of the errors between us and Engler's ones
13
- create table error_names (
14
- report_error_name VarChar (256 ) primary key ,
15
- standardized_name VarChar (256 ) not null -- references standardized_names
12
+ CREATE TABLE error_names (
13
+ report_error_name VarChar (256 ) PRIMARY KEY ,
14
+ standardized_name VarChar (256 ) NOT NULL REFERENCES bug_categories
16
15
);
17
16
18
17
-- binding of the notes between us and Engler's ones
19
- create table note_names (
20
- standardized_name VarChar (256 ) not null , -- references standardized_names ,
21
- note_error_name VarChar (256 ) not null -- Can not be a primary key. Notes sharing.
18
+ CREATE TABLE note_names (
19
+ note_error_name VarChar (256 ) PRIMARY KEY ,
20
+ standardized_name VarChar (256 ) NOT NULL REFERENCES bug_categories
22
21
);
23
22
24
23
--
25
24
-- Name: dir_names; List of directories to study
26
25
--
27
26
CREATE TABLE study_dirnames (
28
- study_dirname text primary key ,
29
- study_dirname_id int NOT NULL
27
+ study_dirname text PRIMARY KEY ,
28
+ study_dirname_id int NOT NULL
30
29
);
31
30
32
31
-- versions are used to compute the age of a file and to filter versions
33
- create table versions (
34
- version_name VarChar (256 ) primary key , -- '2.6.33' for example
32
+ CREATE TABLE versions (
33
+ version_name VarChar (256 ) PRIMARY KEY , -- '2.6.33' for example
35
34
commit_id VarChar (256 ) , -- revision name
36
- main integer not null , -- 2
37
- major integer not null , -- 6
35
+ main integer NOT NULL , -- 2
36
+ major integer NOT NULL , -- 6
38
37
minor integer , -- 33
39
- release_date date not null , -- used to compute the age of a file
38
+ release_date date NOT NULL , -- used to compute the age of a file
40
39
locc bigint DEFAULT 0 NOT NULL ,-- # of C-code lines
41
40
42
41
unique (commit_id),
@@ -46,20 +45,20 @@ create table versions (
46
45
COMMENT ON COLUMN versions.commit_id IS ' Revision name in the source code manager' ;
47
46
48
47
-- Describe of a file
49
- create table file_names (
50
- file_name VarChar (256 ) primary key ,
51
- family_name VarChar (256 ) not null , -- first part of the directory
52
- type_name VarChar (256 ) not null , -- second part
53
- impl_name VarChar (256 ) not null , -- third part
54
- other_name VarChar (256 ) not null , -- other parts
55
- study_dirname VarChar (256 ) not null -- the study dir name
48
+ CREATE TABLE file_names (
49
+ file_name VarChar (256 ) PRIMARY KEY ,
50
+ family_name VarChar (256 ) NOT NULL , -- first part of the directory
51
+ type_name VarChar (256 ) NOT NULL , -- second part
52
+ impl_name VarChar (256 ) NOT NULL , -- third part
53
+ other_name VarChar (256 ) NOT NULL , -- other parts
54
+ study_dirname VarChar (256 ) NOT NULL -- the study dir name
56
55
);
57
56
58
57
-- describe a file with version
59
- create table files (
60
- file_id serial primary key ,
61
- file_name VarChar (256 ) not null references file_names,
62
- version_name VarChar (256 ) not null references versions,
58
+ CREATE TABLE files (
59
+ file_id serial PRIMARY KEY ,
60
+ file_name VarChar (256 ) NOT NULL REFERENCES file_names,
61
+ version_name VarChar (256 ) NOT NULL REFERENCES versions,
63
62
file_size int ,
64
63
nb_mods int ,
65
64
def_compiled boolean DEFAULT false NOT NULL ,
@@ -81,24 +80,23 @@ create table files (
81
80
-- );
82
81
83
82
-- describe a note
84
- create table notes (
85
- note_id serial primary key ,
86
- file_id int not null references files,
87
- data_source VarChar (256 ) not null , -- for update
88
- note_error_name VarChar (256 ) not null ,
89
- line_no int not null ,
90
- column_start int not null ,
91
- column_end int not null ,
83
+ CREATE TABLE notes (
84
+ note_id serial PRIMARY KEY ,
85
+ file_id int NOT NULL REFERENCES files,
86
+ data_source VarChar (256 ) NOT NULL , -- for update
87
+ note_error_name VarChar (256 ) NOT NULL ,
88
+ line_no int NOT NULL ,
89
+ column_start int NOT NULL ,
90
+ column_end int NOT NULL ,
92
91
text_link VarChar (256 ) , -- text hyperlink
93
92
94
- unique (file_id, note_error_name, line_no, column_start)
93
+ UNIQUE (file_id, note_error_name, line_no, column_start, column_end )
95
94
);
95
+ CREATE UNIQUE INDEX note_idx ON notes (file_id, note_error_name, line_no, column_start, column_end);
96
96
97
- create table authors (
98
- author_id serial primary key ,
99
- author_name VarChar (256 ) not null ,
100
-
101
- unique (author_name)
97
+ CREATE TABLE authors (
98
+ author_id serial PRIMARY KEY ,
99
+ author_name VarChar (256 ) UNIQUE NOT NULL
102
100
);
103
101
104
102
-- create table tmp_bug_authors (
@@ -107,45 +105,46 @@ unique (author_name)
107
105
-- commit_id VarChar(64) not null
108
106
-- );
109
107
110
- create table history (
111
- commit_id VarChar (64 ) primary key ,
112
- author_id int not null references authors,
113
- author_date date not null ,
114
- committer_id int not null references authors(author_id),
115
- committer_date date not null ,
116
- version_name VarChar (256 ) references versions ON UPDATE CASCADE ON DELETE SET NULL ,
108
+ CREATE TABLE history (
109
+ commit_id VarChar (64 ) PRIMARY KEY ,
110
+ author_id int NOT NULL REFERENCES authors,
111
+ author_date date NOT NULL ,
112
+ committer_id int NOT NULL REFERENCES authors(author_id),
113
+ committer_date date NOT NULL ,
114
+ version_name VarChar (256 ) REFERENCES versions ON UPDATE CASCADE ON DELETE SET NULL ,
117
115
author_expertise real ,
118
116
committer_expertise real
119
117
);
120
118
121
119
-- TODO: Add a reference (fkey) to the versions table once the history table is created.
122
120
123
- create sequence correlation_idx ;
121
+ CREATE SEQUENCE correlation_idx ;
124
122
125
123
-- describe a set of correlated reports
126
- create table correlations (
127
- correlation_id int primary key ,
128
- report_error_name VarChar (256 ) not null ,
129
- status VarChar (256 ) not null ,
124
+ CREATE TABLE correlations (
125
+ correlation_id int PRIMARY KEY ,
126
+ report_error_name VarChar (256 ) NOT NULL ,
127
+ status VarChar (256 ) NOT NULL ,
130
128
reason_phrase VarChar (256 ), -- annotation
131
- data_source VarChar (256 ) not null ,
129
+ data_source VarChar (256 ) NOT NULL ,
132
130
birth_commit_number VarChar (64 ), -- hash of the commit that introduces the bug
133
131
death_commit_number VarChar (64 ), -- hash of the commit that removes the bug
134
132
patch_status VarChar (128 ) -- status of the fix.
135
133
);
136
134
137
135
-- describe one report
138
- create table reports (
139
- report_id serial primary key ,
140
- correlation_id int not null references correlations on delete cascade ,
141
- file_id int not null references files on delete cascade ,
142
- line_no int not null ,
143
- column_start int not null ,
144
- column_end int not null ,
136
+ CREATE TABLE reports (
137
+ report_id serial PRIMARY KEY ,
138
+ correlation_id int NOT NULL REFERENCES correlations ON DELETE CASCADE ,
139
+ file_id int NOT NULL REFERENCES files ON DELETE CASCADE ,
140
+ line_no int NOT NULL ,
141
+ column_start int NOT NULL ,
142
+ column_end int NOT NULL ,
145
143
text_link VarChar (256 ) , -- text hyperlink
146
144
147
- unique (report_id, file_id, line_no, column_start)
145
+ UNIQUE (report_id, file_id, line_no, column_start, column_end )
148
146
);
147
+ CREATE UNIQUE INDEX reports_idx ON reports (correlation_id, file_id, line_no, column_start, column_end);
149
148
150
149
-- describe a position of a note
151
150
-- create table report_annotations (
@@ -157,13 +156,13 @@ create table reports (
157
156
-- );
158
157
159
158
-- describe a function
160
- create table functions (
161
- function_id serial primary key ,
162
- file_id int not null references files on delete cascade ,
163
- function_name VarChar (256 ) not null ,
164
- start int not null ,
165
- finish int not null ,
166
-
167
- unique (file_id, start),
168
- unique (file_id, finish)
159
+ CREATE TABLE functions (
160
+ function_id serial PRIMARY KEY ,
161
+ file_id int NOT NULL REFERENCES files ON DELETE CASCADE ,
162
+ function_name VarChar (256 ) NOT NULL ,
163
+ start int NOT NULL ,
164
+ finish int NOT NULL ,
165
+
166
+ UNIQUE (file_id, start),
167
+ UNIQUE (file_id, finish)
169
168
);
0 commit comments