/* Every PostgreSQL table and index is stored as an array of pages of a fixed size (usually 8 kB, although a different page size can be selected when compiling the server)
if (attempt_exec("PRAGMA page_size = 4096;",
"Error setting PRAGMA page_size: %s\n")) {
return 1;
}*/
/* PostgreSQL has foreign keys enabled
if (attempt_exec("PRAGMA foreign_keys = ON;",
"Error setting PRAGMA foreign_keys: %s\n")) {
return 1;
}*/
// increase the DB by 1MB at a time -- supposed to help performance when populating
/*int chunkSize = 1024 * 1024;
if (sqlite3_file_control(m_db, NULL, SQLITE_FCNTL_CHUNK_SIZE, &chunkSize) != SQLITE_OK) {
("CREATE TABLE tsk_image_names (obj_id INTEGER NOT NULL, name TEXT NOT NULL, sequence INTEGER NOT NULL, FOREIGN KEY(obj_id) REFERENCES tsk_objects(obj_id));",
"Error creating tsk_image_names table: %s\n")
||
attempt_exec
("CREATE TABLE tsk_vs_info (obj_id INTEGER PRIMARY KEY, vs_type INTEGER NOT NULL, img_offset INTEGER NOT NULL, block_size INTEGER NOT NULL, FOREIGN KEY(obj_id) REFERENCES tsk_objects(obj_id));",
"Error creating tsk_vs_info table: %s\n")
||
attempt_exec
("CREATE TABLE tsk_fs_info (obj_id INTEGER PRIMARY KEY, img_offset INTEGER NOT NULL, fs_type INTEGER NOT NULL, block_size INTEGER NOT NULL, block_count INTEGER NOT NULL, root_inum INTEGER NOT NULL, first_inum INTEGER NOT NULL, last_inum INTEGER NOT NULL, display_name TEXT, FOREIGN KEY(obj_id) REFERENCES tsk_objects(obj_id));",
("CREATE TABLE tag_names (tag_name_id INTEGER PRIMARY KEY, display_name TEXT UNIQUE, description TEXT NOT NULL, color TEXT NOT NULL)",
"Error creating tag_names table: %s\n")
||
attempt_exec
("CREATE TABLE content_tags (tag_id INTEGER PRIMARY KEY, obj_id INTEGER NOT NULL, tag_name_id INTEGER NOT NULL, comment TEXT NOT NULL, begin_byte_offset INTEGER NOT NULL, end_byte_offset INTEGER NOT NULL, "
("CREATE TABLE blackboard_artifact_tags (tag_id INTEGER PRIMARY KEY, artifact_id INTEGER NOT NULL, tag_name_id INTEGER NOT NULL, comment TEXT NOT NULL, "
/* In PostgreSQL "desc" indicates "descending order" so I had to rename "desc TEXT" to "descr TEXT" */
attempt_exec
("CREATE TABLE tsk_vs_parts (obj_id INTEGER PRIMARY KEY, addr INTEGER NOT NULL, start INTEGER NOT NULL, length INTEGER NOT NULL, descr TEXT, flags INTEGER NOT NULL, FOREIGN KEY(obj_id) REFERENCES tsk_objects(obj_id));",
"Error creating tsk_vol_info table: %s\n")
||
attempt_exec
("CREATE TABLE reports (report_id INTEGER PRIMARY KEY, path TEXT NOT NULL, crtime INTEGER NOT NULL, src_module_name TEXT NOT NULL, report_name TEXT NOT NULL)",
"Error creating reports table: %s\n")){
return1;
}
if(m_blkMapFlag){
if(attempt_exec
("CREATE TABLE tsk_file_layout (obj_id INTEGER NOT NULL, byte_start INTEGER NOT NULL, byte_len INTEGER NOT NULL, sequence INTEGER NOT NULL, FOREIGN KEY(obj_id) REFERENCES tsk_objects(obj_id));",
"Error creating tsk_fs_blocks table: %s\n")){
return1;
}
}
if(createIndexes())
return1;
return0;
}
/**
* Create indexes for the columns that are not primary keys and that we query on.
* @returns 1 on error, 0 on success
*/
intTskDbPostgreSQL::createIndexes()
{
return
// tsk_objects index
attempt_exec("CREATE INDEX parObjId ON tsk_objects(par_obj_id);",
"Error creating tsk_objects index on par_obj_id: %s\n")||
// file layout index
attempt_exec("CREATE INDEX layout_objID ON tsk_file_layout(obj_id);",
"Error creating layout_objID index on tsk_file_layout: %s\n")||
// blackboard indexes
attempt_exec("CREATE INDEX artifact_objID ON blackboard_artifacts(obj_id);",
"Error creating artifact_objID index on blackboard_artifacts: %s\n")||
attempt_exec("CREATE INDEX artifact_typeID ON blackboard_artifacts(artifact_type_id);",
"Error creating artifact_objID index on blackboard_artifacts: %s\n")||
attempt_exec("CREATE INDEX attrsArtifactID ON blackboard_attributes(artifact_id);",
"Error creating artifact_id index on blackboard_attributes: %s\n");
/*attempt_exec("CREATE INDEX attribute_artifactTypeId ON blackboard_attributes(artifact_type_id);",
"Error creating artifact_type_id index on blackboard_attributes: %s\n");