Skip to content

Commit

Permalink
Added function to reset the buffer/file stats (so that the logging st…
Browse files Browse the repository at this point in the history
…arts from the beginning).
  • Loading branch information
tvondra committed Nov 27, 2011
1 parent 908542e commit a5ff7c9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sql/query_recorder--1.0.0.sql
Expand Up @@ -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;
17 changes: 17 additions & 0 deletions src/record.c
Expand Up @@ -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
Expand Down Expand Up @@ -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.