summaryrefslogtreecommitdiffstats
path: root/scripts/aurblup/aurblup.c
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2011-02-10 09:04:01 +0100
committerLukas Fleischer <archlinux@cryptocrack.de>2011-02-11 14:43:23 +0100
commita64cd12feb1a4cf7bfa6174696cf6cb271ba0602 (patch)
treed3ef6736971e44a1272040f56a6fa48f654c4f90 /scripts/aurblup/aurblup.c
parent13bcc269ff8a4410bd6d24ee51e7c24f5cb55a98 (diff)
downloadaur-a64cd12feb1a4cf7bfa6174696cf6cb271ba0602.tar.gz
aur-a64cd12feb1a4cf7bfa6174696cf6cb271ba0602.tar.xz
Add support for MySQL transactions to aurblup.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'scripts/aurblup/aurblup.c')
-rw-r--r--scripts/aurblup/aurblup.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/scripts/aurblup/aurblup.c b/scripts/aurblup/aurblup.c
index 005fc8ee..b9628ebe 100644
--- a/scripts/aurblup/aurblup.c
+++ b/scripts/aurblup/aurblup.c
@@ -66,11 +66,22 @@ blacklist_sync(alpm_list_t *pkgs)
{
alpm_list_t *r, *p;
+#if MYSQL_USE_TRANSACTIONS
+ if (mysql_autocommit(c, 0))
+ mysql_die("failed to turn MySQL autocommit off: %s\n");
+
+ if (mysql_query(c, "START TRANSACTION;"))
+ mysql_die("failed to start MySQL transaction: %s\n");
+
+ if (mysql_query(c, "TRUNCATE TABLE PackageBlacklist;"))
+ mysql_die("failed to truncate MySQL table: %s\n");
+#else
if (mysql_query(c, "LOCK TABLES PackageBlacklist WRITE;"))
mysql_die("failed to lock MySQL table: %s\n");
if (mysql_query(c, "DELETE FROM PackageBlacklist;"))
mysql_die("failed to clear MySQL table: %s\n");
+#endif
for (r = pkgs; r; r = alpm_list_next(r)) {
pmpkg_t *pkg = alpm_list_getdata(r);
@@ -86,8 +97,13 @@ blacklist_sync(alpm_list_t *pkgs)
}
}
+#if MYSQL_USE_TRANSACTIONS
+ if (mysql_query(c, "COMMIT;"))
+ mysql_die("failed to commit MySQL transaction: %s\n");
+#else
if (mysql_query(c, "UNLOCK TABLES;"))
mysql_die("failed to unlock MySQL tables: %s\n");
+#endif
}
alpm_list_t *