1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
# name: test/sql/logging/logging_buffer_size.test
# description:
# group: [logging]
require noforcestorage
# By default we flush the logger automatically at certain sensible moments (most importantly, on Query End)
# for this test we want to disable automatic flushing to test the buffer size param
statement ok
CALL enable_logging('QueryLog', storage_config={'buffer_size': 10, 'only_flush_on_full_buffer': true});
statement ok
SELECT 1 as a;
query I
SELECT count(*) FROM duckdb_logs
----
0
loop i 0 10
statement ok
SELECT 1 as a;
endloop
# We expect a single flush to have happened, e.g. 10 log entries
query I
SELECT count(*) FROM duckdb_logs
----
10
statement ok
CALL disable_logging()
statement ok
CALL truncate_duckdb_logs()
# Change logging to manualog log type
statement ok
CALL enable_logging('', level='trace', storage='memory', storage_config={'buffer_size': 3000, 'only_flush_on_full_buffer': true});
# Buffers aaaaalmost full
statement ok
SELECT write_log('hello from the connection log scope', level := 'error', scope := 'connection') from range(0,2999);
query I
SELECT count(*) FROM duckdb_logs()
----
0
# "it's only a wafer-thin mint"
statement ok
SELECT write_log('hello from the connection log scope', level := 'error', scope := 'connection');
# Buffer has expl.. been flushed
query I
SELECT count(*) FROM duckdb_logs() where type=''
----
3000
# Note that there are 2 logging contexts now, since we wrote the log entries across 2 queries with each their own logging context
query I
SELECT count(*) FROM duckdb_log_contexts()
----
2
# Try with some big buffers now
statement ok
CALL disable_logging()
statement ok
CALL truncate_duckdb_logs()
statement ok
CALL enable_logging(level='trace', storage='memory', storage_config={'buffer_size': 20*2048});
statement ok
SELECT write_log('hello from the connection log scope', level := 'error', scope := 'connection') from range(0,40*2048);
statement ok
FROM duckdb_logs()
statement ok
CALL enable_logging(level='trace', storage='file', storage_config={'buffer_size': 20*2048, 'path': '__TEST_DIR__/logging_buffer_size'});
statement ok
SELECT write_log('hello from the connection log scope', level := 'error', scope := 'connection') from range(0,40*2048);
# Try direct flushing
statement ok
CALL enable_logging(level='trace', storage='file', storage_config={'buffer_size': 0, 'path': '__TEST_DIR__/logging_buffer_size'});
statement ok
SELECT write_log('hello from the connection log scope', level := 'error', scope := 'connection') from range(0, 2048);
# Try weird buffer size
statement error
CALL enable_logging(level='trace', storage='file', storage_config={'buffer_size': -1, 'path': '__TEST_DIR__/logging_buffer_size'});
----
Invalid Input Error
|