src/pEpEngine.c
changeset 1602 904da6719597
parent 1574 12b7a45140d3
child 1603 f954f77387f1
     1.1 --- a/src/pEpEngine.c	Tue Feb 21 23:08:01 2017 +0100
     1.2 +++ b/src/pEpEngine.c	Wed Feb 22 19:26:45 2017 +0100
     1.3 @@ -160,14 +160,16 @@
     1.4  static const char *sql_sequence_value1 = 
     1.5      "insert or replace into sequences (name, value, own) "
     1.6      "values (?1, "
     1.7 -    "(select coalesce((select value + 1 from sequences "
     1.8 -    "where name = ?1), 1 )), ?2) ; ";
     1.9 +    "       (select coalesce((select value + 1 from sequences "
    1.10 +    "           where name = ?1), 1 )), "
    1.11 +    "       (select coalesce((select own or ?2 from sequences "
    1.12 +    "           where name = ?1), ?2))) ; ";
    1.13  
    1.14  static const char *sql_sequence_value2 = 
    1.15      "select value, own from sequences where name = ?1 ;";
    1.16  
    1.17  static const char *sql_sequence_value3 = 
    1.18 -    "update sequences set value = ?2, own = ?3 where name = ?1 ;";
    1.19 +    "update sequences set value = ?2, own = (select own or ?3 from sequences where name = ?1) where name = ?1 ;";
    1.20          
    1.21  // Revocation tracking
    1.22  static const char *sql_set_revoked =