Hi!

I've got a small patch here that removes the LOCK IN EXCLUSIVE MODE if
sql_dont_try_update is enabled -- if we're only using INSERT statements to
put the data in the database, we don't need to lock the table, the databsae
is smart enough to do the right thing, and this also means that pmpgplay
will finish faster, because it's not waiting for the lock to release.
diff --exclude debian -ruN pmacct-0.9.6.orig/pgsql_plugin.c 
pmacct-0.9.6/pgsql_plugin.c
--- pmacct-0.9.6.orig/pgsql_plugin.c    2005-12-19 22:36:12.000000000 +1100
+++ pmacct-0.9.6/pgsql_plugin.c 2006-03-07 12:54:27.000000000 +1100
@@ -480,7 +480,11 @@
   strncat(insert_clause, ")", SPACELEFT(insert_clause));
 
   /* "LOCK ..." stuff */
+  if (config.sql_dont_try_update) {
+         snprintf(lock_clause, sizeof(lock_clause), "BEGIN;");
+  } else {
   snprintf(lock_clause, sizeof(lock_clause), "BEGIN; LOCK %s IN EXCLUSIVE 
MODE;", config.sql_table);
+  }
 
   /* "UPDATE ... SET ..." stuff */
   snprintf(update_clause, sizeof(update_clause), "UPDATE %s ", 
config.sql_table);
diff --exclude debian -ruN pmacct-0.9.6.orig/pmpgplay.c pmacct-0.9.6/pmpgplay.c
--- pmacct-0.9.6.orig/pmpgplay.c        2005-11-12 02:39:26.000000000 +1100
+++ pmacct-0.9.6/pmpgplay.c     2006-03-07 12:52:11.000000000 +1100
@@ -810,7 +810,11 @@
   strncat(insert_clause, ")", SPACELEFT(insert_clause));
 
   /* "LOCK ..." stuff */
+  if (sql_dont_try_update) {
+         snprintf(lock_clause, sizeof(lock_clause), "BEGIN;");
+  } else { 
   snprintf(lock_clause, sizeof(lock_clause), "BEGIN; LOCK %s IN EXCLUSIVE 
MODE;", sql_table);
+  }
 
   /* "UPDATE ... SET ..." stuff */
   snprintf(update_clause, sizeof(update_clause), "UPDATE %s ", sql_table);

Reply via email to