Last active
June 18, 2018 23:27
-
-
Save rwestphal/457e9a763b8b24dfa367e239b7fc2979 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int nb_db_init(void) | |
{ | |
#ifdef HAVE_CONFIG_ROLLBACKS | |
int ret; | |
ret = db_execute( | |
" \ | |
BEGIN TRANSACTION; \ | |
CREATE TABLE IF NOT EXISTS TRANSACTIONS( \ | |
ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, \ | |
CLIENT CHAR(32) NOT NULL, \ | |
DATE datetime default current_timestamp,\ | |
COMMENT char(80) , \ | |
CONFIGURATION TEXT NOT NULL \ | |
); \ | |
CREATE TRIGGER IF NOT EXISTS delete_tail \ | |
AFTER INSERT ON TRANSACTIONS FOR EACH ROW \ | |
BEGIN \ | |
DELETE FROM TRANSACTIONS WHERE ID%%%u=NEW.ID%%%u AND ID!=NEW.ID;\ | |
END; \ | |
COMMIT;", | |
NB_DLFT_MAX_CONFIG_ROLLBACKS, NB_DLFT_MAX_CONFIG_ROLLBACKS); | |
if (ret != 0) | |
return NB_ERR; | |
#endif /* HAVE_CONFIG_ROLLBACKS */ | |
return NB_OK; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment