FreeBSD/contrib/subversion/subversion/libsvn_subr/sqlite.c
/* APR cleanup function used to close the database when its pool is destroyed.
   DATA should be the svn_sqlite__db_t handle for the database. */
APR cleanup function used to close the database when its pool is destroyed.
DATA should be the svn_sqlite__db_t handle for the database.
APR cleanup function used to close the database when its pool is destroyed . DATA should be the svn_sqlite__db_t handle for the database .
static apr_status_t
close_apr(void *data)
{
  svn_sqlite__db_t *db = data;
  svn_error_t *err = SVN_NO_ERROR;
  apr_status_t result;
  int i;
  if (db->db3 == NULL)
    return APR_SUCCESS;
  if (db->prepared_stmts)
    {
      for (i = 0; i < db->nbr_statements + STMT_INTERNAL_LAST; i++)
        {
          if (db->prepared_stmts[i])
            {
              if (i < db->nbr_statements
                  && db->prepared_stmts[i]->needs_reset)
                {
#ifdef SVN_DEBUG
                  const char *stmt_text = db->statement_strings[i];
                  SVN_UNUSED(stmt_text);
                  SVN_ERR_MALFUNCTION_NO_RETURN();
#else
                  err = svn_error_compose_create(err,
                            svn_sqlite__reset(db->prepared_stmts[i]));
#endif
                }
              err = svn_error_compose_create(
                        svn_sqlite__finalize(db->prepared_stmts[i]), err);
            }
        }
    }
  result = sqlite3_close(db->db3);
  if (err)
    {
      result = err->apr_err;
      svn_error_clear(err);
      return result;
    }
  if (result != SQLITE_OK)
    return SQLITE_ERROR_CODE(result); 
  db->db3 = NULL;
  return APR_SUCCESS;
}
static apr_status_t close_apr ( void * data ) { svn_sqlite__db_t * db = data ; svn_error_t * err = SVN_NO_ERROR ; apr_status_t result ; int i ; if ( db -> db3 == NULL ) return APR_SUCCESS ; if ( db -> prepared_stmts ) { for ( i = 0 ; i < db -> nbr_statements + STMT_INTERNAL_LAST ; i ++ ) { if ( db -> prepared_stmts [ i ] ) { if ( i < db -> nbr_statements && db -> prepared_stmts [ i ] -> needs_reset ) { #ifdef SVN_DEBUG const char * stmt_text = db -> statement_strings [ i ] ; SVN_UNUSED ( stmt_text ) ; SVN_ERR_MALFUNCTION_NO_RETURN ( ) ; #else err = svn_error_compose_create ( err , svn_sqlite__reset ( db -> prepared_stmts [ i ] ) ) ; #endif } err = svn_error_compose_create ( svn_sqlite__finalize ( db -> prepared_stmts [ i ] ) , err ) ; } } } result = sqlite3_close ( db -> db3 ) ; if ( err ) { result = err -> apr_err ; svn_error_clear ( err ) ; return result ; } if ( result != SQLITE_OK ) return SQLITE_ERROR_CODE ( result ) ; db -> db3 = NULL ; return APR_SUCCESS ; }
APR cleanup function used to close the database when its pool is destroyed.
APR cleanup function used to close the database when its pool is destroyed .
/* Check to see if we've already closed this database. */ /* Finalize any prepared statements. */ /* If there's a pre-existing error, return it. */ /* ### lossy */