ENGINE-463 - delete person ENGINE-463
authorKrista Bennett <krista@pep-project.org>
Tue, 02 Oct 2018 13:26:19 +0200
branchENGINE-463
changeset 2965a15e73c2a4e8
parent 2964 4f22b5bc7b9a
child 2966 29f67097eaf0
ENGINE-463 - delete person
src/pEpEngine.c
src/pEp_internal.h
     1.1 --- a/src/pEpEngine.c	Tue Oct 02 13:22:12 2018 +0200
     1.2 +++ b/src/pEpEngine.c	Tue Oct 02 13:26:19 2018 +0200
     1.3 @@ -151,7 +151,11 @@
     1.4      "       device_group = "
     1.5      "           (select device_group from person where id = ?1)"
     1.6      "   where id = ?1 ;";
     1.7 -    
     1.8 +
     1.9 +// Will cascade.
    1.10 +static const char *sql_delete_person = 
    1.11 +     "delete from person where id = ?1 ;";
    1.12 +
    1.13  static const char *sql_set_as_pep_user =
    1.14      "update person set is_pep_user = 1 "
    1.15      "   where id = ?1 ; ";
    1.16 @@ -1120,6 +1124,10 @@
    1.17              (int)strlen(sql_update_person), &_session->update_person, NULL);
    1.18      assert(int_result == SQLITE_OK);
    1.19  
    1.20 +    int_result = sqlite3_prepare_v2(_session->db, sql_delete_person,
    1.21 +            (int)strlen(sql_delete_person), &_session->delete_person, NULL);
    1.22 +    assert(int_result == SQLITE_OK);
    1.23 +
    1.24      int_result = sqlite3_prepare_v2(_session->db, sql_exists_person,
    1.25              (int)strlen(sql_exists_person), &_session->exists_person, NULL);
    1.26      assert(int_result == SQLITE_OK);
    1.27 @@ -1392,6 +1400,8 @@
    1.28                  sqlite3_finalize(session->remove_fpr_as_default);            
    1.29              if (session->set_person)
    1.30                  sqlite3_finalize(session->set_person);
    1.31 +            if (session->delete_person)
    1.32 +                sqlite3_finalize(session->delete_person);                
    1.33              if (session->set_as_pep_user)
    1.34                  sqlite3_finalize(session->set_as_pep_user);
    1.35              if (session->is_pep_user)
     2.1 --- a/src/pEp_internal.h	Tue Oct 02 13:22:12 2018 +0200
     2.2 +++ b/src/pEp_internal.h	Tue Oct 02 13:26:19 2018 +0200
     2.3 @@ -138,6 +138,7 @@
     2.4      sqlite3_stmt *remove_fpr_as_default;
     2.5      sqlite3_stmt *set_person;
     2.6      sqlite3_stmt *update_person;
     2.7 +    sqlite3_stmt *delete_person;
     2.8      sqlite3_stmt *exists_person;    
     2.9      sqlite3_stmt *set_as_pep_user;
    2.10      sqlite3_stmt *is_pep_user;