Permalink
Browse files

Added function to reset the buffer/file stats (so that the logging st…

…arts from the beginning).
  • Loading branch information...
1 parent 908542e commit a5ff7c9388bc2fb41a053496f978424ad95bc776 @tvondra committed Nov 27, 2011
Showing with 23 additions and 1 deletion.
  1. +6 −1 sql/query_recorder--1.0.0.sql
  2. +17 −0 src/record.c
@@ -2,4 +2,9 @@
CREATE OR REPLACE FUNCTION query_recorder_flush()
RETURNS void
AS 'MODULE_PATHNAME', 'query_buffer_flush'
- LANGUAGE C IMMUTABLE;
+ LANGUAGE C IMMUTABLE;
+
+CREATE OR REPLACE FUNCTION query_recorder_reset()
+ RETURNS void
+ AS 'MODULE_PATHNAME', 'query_buffer_reset'
+ LANGUAGE C IMMUTABLE;
View
@@ -108,7 +108,10 @@ static bool collect;
PG_FUNCTION_INFO_V1(query_buffer_flush);
+PG_FUNCTION_INFO_V1(query_buffer_reset);
+
Datum query_buffer_flush(PG_FUNCTION_ARGS);
+Datum query_buffer_reset(PG_FUNCTION_ARGS);
/*
* Module load callback
@@ -793,3 +796,17 @@ query_buffer_flush(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+Datum
+query_buffer_reset(PG_FUNCTION_ARGS)
+{
+ LWLockAcquire(query_buffer->lock, LW_EXCLUSIVE);
+ LWLockAcquire(log_file->lock, LW_EXCLUSIVE);
+ query_buffer->next = 0;
+ log_file->file_number = 0;
+ log_file->file_bytes = 0;
+ LWLockRelease(log_file->lock);
+ LWLockRelease(query_buffer->lock);
+
+ PG_RETURN_VOID();
+}

0 comments on commit a5ff7c9

Please sign in to comment.