-- Generate queries with wal write
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000001-0000000000000001-01'*/ INSERT INTO pg_tracing_test VALUES(generate_series(1, 10), 'aaa');
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000002-0000000000000002-01'*/ UPDATE pg_tracing_test SET b = 'bbb' WHERE a = 7;
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000003-0000000000000003-01'*/ DELETE FROM pg_tracing_test WHERE a = 9;
-- Check WAL is generated for the above statements
SELECT trace_id, span_type, span_operation,
       wal_records > 0 as wal_records,
       wal_bytes > 0 as wal_bytes
FROM peek_ordered_spans;
             trace_id             |     span_type     |                         span_operation                          | wal_records | wal_bytes 
----------------------------------+-------------------+-----------------------------------------------------------------+-------------+-----------
 00000000000000000000000000000001 | Insert query      | INSERT INTO pg_tracing_test VALUES(generate_series($1, $2), $3) | t           | t
 00000000000000000000000000000001 | Planner           | Planner                                                         | f           | f
 00000000000000000000000000000001 | ExecutorRun       | ExecutorRun                                                     |             | 
 00000000000000000000000000000001 | Insert            | Insert on pg_tracing_test                                       | t           | t
 00000000000000000000000000000001 | ProjectSet        | ProjectSet                                                      | f           | f
 00000000000000000000000000000001 | Result            | Result                                                          | f           | f
 00000000000000000000000000000001 | TransactionCommit | TransactionCommit                                               |             | 
 00000000000000000000000000000002 | Update query      | UPDATE pg_tracing_test SET b = $1 WHERE a = $2                  | t           | t
 00000000000000000000000000000002 | Planner           | Planner                                                         | f           | f
 00000000000000000000000000000002 | ExecutorRun       | ExecutorRun                                                     |             | 
 00000000000000000000000000000002 | Update            | Update on pg_tracing_test                                       | t           | t
 00000000000000000000000000000002 | IndexScan         | IndexScan using pg_tracing_index_a on pg_tracing_test           | f           | f
 00000000000000000000000000000002 | TransactionCommit | TransactionCommit                                               |             | 
 00000000000000000000000000000003 | Delete query      | DELETE FROM pg_tracing_test WHERE a = $1                        | t           | t
 00000000000000000000000000000003 | Planner           | Planner                                                         | f           | f
 00000000000000000000000000000003 | ExecutorRun       | ExecutorRun                                                     |             | 
 00000000000000000000000000000003 | Delete            | Delete on pg_tracing_test                                       | t           | t
 00000000000000000000000000000003 | IndexScan         | IndexScan using pg_tracing_index_a on pg_tracing_test           | t           | t
 00000000000000000000000000000003 | TransactionCommit | TransactionCommit                                               |             | 
(19 rows)

CALL clean_spans();
-- Cleanup
CALL clean_spans();