src/Pure/Thy/sessions.scala
changeset 65699 9f74d9aa0bdf
parent 65698 38139b2067cf
child 65740 83388f09e9ab
equal deleted inserted replaced
65698:38139b2067cf 65699:9f74d9aa0bdf
   762 
   762 
   763     /* SQL database content */
   763     /* SQL database content */
   764 
   764 
   765     def read_bytes(db: SQL.Database, name: String, column: SQL.Column): Bytes =
   765     def read_bytes(db: SQL.Database, name: String, column: SQL.Column): Bytes =
   766       db.using_statement(Session_Info.table.select(List(column),
   766       db.using_statement(Session_Info.table.select(List(column),
   767         Session_Info.session_name.sql_where_equal(name)))(stmt =>
   767         Session_Info.session_name.where_equal(name)))(stmt =>
   768       {
   768       {
   769         val rs = stmt.executeQuery
   769         val rs = stmt.executeQuery
   770         if (!rs.next) Bytes.empty else db.bytes(rs, column)
   770         if (!rs.next) Bytes.empty else db.bytes(rs, column)
   771       })
   771       })
   772 
   772 
   820       build: Build.Session_Info)
   820       build: Build.Session_Info)
   821     {
   821     {
   822       db.transaction {
   822       db.transaction {
   823         db.create_table(Session_Info.table)
   823         db.create_table(Session_Info.table)
   824         db.using_statement(
   824         db.using_statement(
   825           Session_Info.table.delete(Session_Info.session_name.sql_where_equal(name)))(_.execute)
   825           Session_Info.table.delete(Session_Info.session_name.where_equal(name)))(_.execute)
   826         db.using_statement(Session_Info.table.insert())(stmt =>
   826         db.using_statement(Session_Info.table.insert())(stmt =>
   827         {
   827         {
   828           db.set_string(stmt, 1, name)
   828           db.set_string(stmt, 1, name)
   829           db.set_bytes(stmt, 2, encode_properties(build_log.session_timing))
   829           db.set_bytes(stmt, 2, encode_properties(build_log.session_timing))
   830           db.set_bytes(stmt, 3, compress_properties(build_log.command_timings))
   830           db.set_bytes(stmt, 3, compress_properties(build_log.command_timings))
   863         task_statistics = if (task_statistics) read_task_statistics(db, name) else Nil)
   863         task_statistics = if (task_statistics) read_task_statistics(db, name) else Nil)
   864     }
   864     }
   865 
   865 
   866     def read_build(db: SQL.Database, name: String): Option[Build.Session_Info] =
   866     def read_build(db: SQL.Database, name: String): Option[Build.Session_Info] =
   867       db.using_statement(Session_Info.table.select(Session_Info.build_columns,
   867       db.using_statement(Session_Info.table.select(Session_Info.build_columns,
   868         Session_Info.session_name.sql_where_equal(name)))(stmt =>
   868         Session_Info.session_name.where_equal(name)))(stmt =>
   869       {
   869       {
   870         val rs = stmt.executeQuery
   870         val rs = stmt.executeQuery
   871         if (!rs.next) None
   871         if (!rs.next) None
   872         else {
   872         else {
   873           Some(
   873           Some(