test_output_all_v4.txt

text/plain

Filename: test_output_all_v4.txt
Type: text/plain
Part: 0
Message: Re: [PATCH] Add NESTED_STATEMENTS option to EXPLAIN
============================================================================
NESTED_STATEMENTS Feature - Comprehensive Test Suite
============================================================================

This test suite demonstrates:
  1. Validation (NESTED_STATEMENTS requires ANALYZE)
  2. Simple PL/pgSQL function (all level 1)
  3. PERFORM pattern (creates deeper nesting levels)
  4. Expression assignment pattern (stays at same level)
  5. Comparison: PERFORM vs expression assignment
  6. SQL function nesting (true SQL nesting)
  7. Three-level chain with PERFORM
  8. Recursive function (increasing levels)
  9. Exception handling blocks
  10. No nested statements (plain query)
  11. Trigger-fired nested statements
  12. Combined with VERBOSE and BUFFERS options
  13. Statement numbering = completion order (triggers demo)
  14. BEGIN/ROLLBACK safety pattern
  15. Error during EXPLAIN does not crash (Bug 1 fix)
  16. Nested EXPLAIN does not crash (Bug 2 fix)
  17. Memory context cleanup (Bug 3 fix)
  18. Memory context does not grow across repeated calls
  19. Stress test - 50 nested statements
  20. Execution Time per nested statement (SUMMARY default)
  21. SUMMARY OFF hides timing, percentages, and summary section
  22. Structured output - JSON format
  23. Structured output - XML format
  24. Structured output - YAML format
  25. SHOW_NESTED - limit displayed plans
  26. SHOW_NESTED 0 - summary only
  27. SHOW_NESTED validation (requires NESTED_STATEMENTS)
  28. Nested Statements Summary with percentages
  29. Statement timeout — hooks cleaned up
  30. Dynamic SQL — query text captured correctly
  31. Infinite recursion — graceful error
  32. auto_explain compatibility
  33. Deep nesting (20 levels)
  34. All EXPLAIN options combined with SHOW_NESTED
  35. Performance — zero overhead when disabled
  36. Interpreting Total Nested Time percentage
  37. Multiple triggers on separate tables
  38. Direct DML with triggers (BEFORE + AFTER, cascading)
  39. BEFORE and AFTER triggers in function context
  40. Query Identifier integration (pg_stat_statements)
  41. Level-1 only counting (no double-counting with deep nesting)
-- ============================================================================
psql:comprehensive_nested_statements_test_v4.sql:61: NOTICE:  table "products" does not exist, skipping
DROP TABLE
CREATE TABLE
INSERT 0 3
============================================================================
TEST 1: Validation - NESTED_STATEMENTS requires ANALYZE
============================================================================

Expected: ERROR message

psql:comprehensive_nested_statements_test_v4.sql:78: ERROR:  EXPLAIN option NESTED_STATEMENTS requires ANALYZE

============================================================================
TEST 2: Simple PL/pgSQL Function - All Statements at Level 1
============================================================================

Purpose: SQL statements in a single function all execute at level 1
         because they run sequentially in the same executor context.

CREATE FUNCTION
Expected: All 4 statements at level 1

                            QUERY PLAN                             
-------------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=144 read=42
 Planning Time: 0.031 ms
 Execution Time: 19.137 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM products
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on products (actual rows=3.00 loops=1)
           Buffers: shared hit=1
   Execution Time: 0.017 ms (17.6%)
 
   Nested Statement #2 (level 1):
   Query Text: INSERT INTO products VALUES (10, 'Temp', 1, 'Temp')
   Insert on products (actual rows=0.00 loops=1)
     Buffers: shared hit=1
     ->  Result (actual rows=1.00 loops=1)
   Execution Time: 0.022 ms (23.3%)
 
   Nested Statement #3 (level 1):
   Query Text: UPDATE products SET price = price + 1 WHERE id = 1
   Update on products (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on products (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 3
           Buffers: shared hit=1
   Execution Time: 0.050 ms (53.3%)
 
   Nested Statement #4 (level 1):
   Query Text: DELETE FROM products WHERE id = 10
   Delete on products (actual rows=0.00 loops=1)
     Buffers: shared hit=2
     ->  Seq Scan on products (actual rows=1.00 loops=1)
           Filter: (id = 10)
           Rows Removed by Filter: 3
           Buffers: shared hit=1
   Execution Time: 0.005 ms (5.8%)
 
 Nested Statements Summary:
   Total: 4 statements, max depth 1
   Total Execution Time: 19.137 ms
   Total Nested Time: 0.094 ms (0.5% of total time)
   Slowest Statement: #3 (0.050 ms, 53.3%)
(47 rows)


============================================================================
TEST 3: PERFORM Pattern - Creates Deeper Nesting Levels
============================================================================

Purpose: PERFORM func() creates a new executor call (SELECT func()),
         so statements inside the called function run at a deeper level.

How it works internally:
  PERFORM func() → executes "SELECT func()" → ExecutorRun increments level
  → func() body runs its SQL at the elevated level

CREATE FUNCTION
CREATE FUNCTION
Expected:
  Statement #1 (level 1): SELECT COUNT in outer_perform
  Statement #2 (level 2): UPDATE in inner_perform
  Statement #3 (level 2): INSERT in inner_perform
  Statement #4 (level 2): DELETE in inner_perform
  Statement #5 (level 1): SELECT inner_perform() [the PERFORM call]
  Statement #6 (level 1): UPDATE in outer_perform

                             QUERY PLAN                              
---------------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=58 read=1
 Planning Time: 0.016 ms
 Execution Time: 0.361 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM products
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on products (actual rows=3.00 loops=1)
           Buffers: shared hit=1
   Execution Time: 0.013 ms (8.4%)
 
   Nested Statement #2 (level 2):
   Query Text: UPDATE products SET price = price + 1 WHERE id = 2
   Update on products (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on products (actual rows=1.00 loops=1)
           Filter: (id = 2)
           Rows Removed by Filter: 2
           Buffers: shared hit=1
   Execution Time: 0.013 ms
 
   Nested Statement #3 (level 2):
   Query Text: INSERT INTO products VALUES (20, 'Inner', 50, 'Test')
   Insert on products (actual rows=0.00 loops=1)
     Buffers: shared hit=1
     ->  Result (actual rows=1.00 loops=1)
   Execution Time: 0.003 ms
 
   Nested Statement #4 (level 2):
   Query Text: DELETE FROM products WHERE id = 20
   Delete on products (actual rows=0.00 loops=1)
     Buffers: shared hit=2
     ->  Seq Scan on products (actual rows=1.00 loops=1)
           Filter: (id = 20)
           Rows Removed by Filter: 3
           Buffers: shared hit=1
   Execution Time: 0.005 ms
 
   Nested Statement #5 (level 1):
   Query Text: SELECT inner_perform()
   Result (actual rows=1.00 loops=1)
     Buffers: shared hit=6
   Execution Time: 0.138 ms (87.6%)
 
   Nested Statement #6 (level 1):
   Query Text: UPDATE products SET price = price - 1 WHERE id = 2
   Update on products (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on products (actual rows=1.00 loops=1)
           Filter: (id = 2)
           Rows Removed by Filter: 2
           Buffers: shared hit=1
   Execution Time: 0.006 ms (4.0%)
 
 Nested Statements Summary:
   Total: 6 statements, max depth 2
   Total Execution Time: 0.361 ms
   Total Nested Time: 0.157 ms (43.5% of total time)
   Slowest Statement: #5 (0.138 ms, 87.6%)
(63 rows)


============================================================================
TEST 4: Expression Assignment (result := func()) - Same Level
============================================================================

Purpose: result := func() evaluates the function as an expression via
         ExecEvalFunc WITHOUT creating a new executor call. Statements
         inside the called function run at the SAME level as the caller.

How it works internally:
  result := func() → ExecEvalFunc(func) → NO new ExecutorRun
  → func() body runs its SQL at the SAME level as caller

CREATE FUNCTION
CREATE FUNCTION
Expected: ALL statements at level 1 (no deeper nesting)
  Statement #1 (level 1): SELECT COUNT in outer_expr
  Statement #2 (level 1): SELECT SUM in inner_expr  ← same level!
  Statement #3 (level 1): UPDATE in inner_expr      ← same level!
  Statement #4 (level 1): DELETE in outer_expr

                            QUERY PLAN                            
------------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=191 read=9
 Planning Time: 0.011 ms
 Execution Time: 1.287 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM products
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on products (actual rows=3.00 loops=1)
           Buffers: shared hit=1
   Execution Time: 0.007 ms (17.8%)
 
   Nested Statement #2 (level 1):
   Query Text: SELECT SUM(price)            FROM products
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on products (actual rows=3.00 loops=1)
           Buffers: shared hit=1
   Execution Time: 0.014 ms (37.4%)
 
   Nested Statement #3 (level 1):
   Query Text: UPDATE products SET price = price + 1 WHERE id = 3
   Update on products (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on products (actual rows=1.00 loops=1)
           Filter: (id = 3)
           Rows Removed by Filter: 2
           Buffers: shared hit=1
   Execution Time: 0.015 ms (38.1%)
 
   Nested Statement #4 (level 1):
   Query Text: DELETE FROM products WHERE price > 9999
   Delete on products (actual rows=0.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on products (actual rows=0.00 loops=1)
           Filter: (price > '9999'::numeric)
           Rows Removed by Filter: 3
           Buffers: shared hit=1
   Execution Time: 0.003 ms (6.7%)
 
 Nested Statements Summary:
   Total: 4 statements, max depth 1
   Total Execution Time: 1.287 ms
   Total Nested Time: 0.038 ms (3.0% of total time)
   Slowest Statement: #3 (0.015 ms, 38.1%)
(48 rows)


============================================================================
TEST 5: PERFORM vs Expression Assignment - Side by Side
============================================================================

Purpose: Same inner function called two different ways to show the
         nesting level difference.

CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
--- Via PERFORM (expect level 2 for inner SELECT): ---

                                     QUERY PLAN                                      
-------------------------------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=25 read=2
 Planning Time: 0.004 ms
 Execution Time: 0.259 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 2):
   Query Text: SELECT COUNT(*)          FROM products WHERE category = 'Electronics'
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on products (actual rows=2.00 loops=1)
           Filter: (category = 'Electronics'::text)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
   Execution Time: 0.008 ms
 
   Nested Statement #2 (level 1):
   Query Text: SELECT shared_inner()
   Result (actual rows=1.00 loops=1)
     Buffers: shared hit=19 read=2
   Execution Time: 0.236 ms (100.0%)
 
 Nested Statements Summary:
   Total: 2 statements, max depth 2
   Total Execution Time: 0.259 ms
   Total Nested Time: 0.236 ms (91.2% of total time)
   Slowest Statement: #2 (0.236 ms, 100.0%)
(28 rows)


--- Via expression assignment (expect level 1 for inner SELECT): ---

                                     QUERY PLAN                                      
-------------------------------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=1
 Planning Time: 0.003 ms
 Execution Time: 0.026 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM products WHERE category = 'Electronics'
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on products (actual rows=2.00 loops=1)
           Filter: (category = 'Electronics'::text)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
   Execution Time: 0.004 ms (100.0%)
 
 Nested Statements Summary:
   Total: 1 statements, max depth 1
   Total Execution Time: 0.026 ms
   Total Nested Time: 0.004 ms (15.2% of total time)
   Slowest Statement: #1 (0.004 ms, 100.0%)
(22 rows)


Notice: Same function, different nesting levels depending on call pattern.

============================================================================
TEST 6: SQL Functions - True SQL Execution Nesting
============================================================================

Purpose: SQL functions execute DURING the parent query, creating true
         SQL nesting where inner functions complete before outer.

psql:comprehensive_nested_statements_test_v4.sql:270: NOTICE:  table "t1" does not exist, skipping
psql:comprehensive_nested_statements_test_v4.sql:270: NOTICE:  table "t2" does not exist, skipping
psql:comprehensive_nested_statements_test_v4.sql:270: NOTICE:  table "t3" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
INSERT 0 1
INSERT 0 1
INSERT 0 1
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
Expected: Deepest-first execution order (3→2→1)
  Statement #1 (level 3): SELECT from t3 (sql_level3)
  Statement #2 (level 2): SELECT from t2 (sql_level2)
  Statement #3 (level 1): SELECT from t1 (plpgsql_sql_caller)

                                    QUERY PLAN                                     
-----------------------------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=30
 
 Nested Plans:
 
   Nested Statement #1 (level 3):
   Query Text: 
     SELECT data FROM t3 WHERE id = 1;
 
   Seq Scan on t3 (actual rows=1.00 loops=1)
     Filter: (id = 1)
     Buffers: shared hit=1
 
   Nested Statement #2 (level 2):
   Query Text: 
     SELECT data || '+' || sql_level3() FROM t2 WHERE id = 1;
 
   Seq Scan on t2 (actual rows=1.00 loops=1)
     Filter: (id = 1)
     Buffers: shared hit=8
 
   Nested Statement #3 (level 1):
   Query Text: SELECT data || '+' || sql_level2()             FROM t1 WHERE id = 1
   Seq Scan on t1 (actual rows=1.00 loops=1)
     Filter: (id = 1)
     Buffers: shared hit=15
(26 rows)


============================================================================
TEST 7: Three-Level PL/pgSQL Chain (via PERFORM)
============================================================================

Purpose: Each PERFORM adds one executor level

CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
Expected:
  Statement #1 (level 1): SELECT COUNT(*) FROM products
  Statement #2 (level 2): SELECT COUNT(*) WHERE id = 1
  Statement #3 (level 3): SELECT COUNT(*) WHERE category = Books
  Statement #4 (level 2): SELECT chain_level3()
  Statement #5 (level 1): SELECT chain_level2()

                              QUERY PLAN                              
----------------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=18
 Planning Time: 0.009 ms
 Execution Time: 0.202 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*) FROM products
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on products (actual rows=3.00 loops=1)
           Buffers: shared hit=1
   Execution Time: 0.007 ms (6.0%)
 
   Nested Statement #2 (level 2):
   Query Text: SELECT COUNT(*) FROM products WHERE id = 1
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on products (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 2
           Buffers: shared hit=1
   Execution Time: 0.004 ms
 
   Nested Statement #3 (level 3):
   Query Text: SELECT COUNT(*) FROM products WHERE category = 'Books'
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on products (actual rows=1.00 loops=1)
           Filter: (category = 'Books'::text)
           Rows Removed by Filter: 2
           Buffers: shared hit=1
   Execution Time: 0.005 ms
 
   Nested Statement #4 (level 2):
   Query Text: SELECT chain_level3()
   Result (actual rows=1.00 loops=1)
     Buffers: shared hit=1
   Execution Time: 0.040 ms
 
   Nested Statement #5 (level 1):
   Query Text: SELECT chain_level2()
   Result (actual rows=1.00 loops=1)
     Buffers: shared hit=8
   Execution Time: 0.104 ms (94.0%)
 
 Nested Statements Summary:
   Total: 5 statements, max depth 3
   Total Execution Time: 0.202 ms
   Total Nested Time: 0.111 ms (54.8% of total time)
   Slowest Statement: #5 (0.104 ms, 94.0%)
(52 rows)


============================================================================
TEST 8: Recursive Function - Increasing Nesting Levels
============================================================================

Purpose: Recursive PERFORM calls increase the nesting level each time

psql:comprehensive_nested_statements_test_v4.sql:358: NOTICE:  table "counter_log" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE FUNCTION
Expected:
  Statement #1 (level 1): INSERT with n=3
  Statement #2 (level 2): INSERT with n=2
  Statement #3 (level 3): INSERT with n=1
  + PERFORM calls at levels 2 and 1

                        QUERY PLAN                        
----------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=39 read=2 dirtied=1 written=1
 Planning Time: 0.024 ms
 Execution Time: 1.382 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: INSERT INTO counter_log VALUES (n, n * 10)
   Insert on counter_log (actual rows=0.00 loops=1)
     Buffers: shared dirtied=1 written=1
     ->  Result (actual rows=1.00 loops=1)
   Execution Time: 1.020 ms (95.8%)
 
   Nested Statement #2 (level 2):
   Query Text: INSERT INTO counter_log VALUES (n, n * 10)
   Insert on counter_log (actual rows=0.00 loops=1)
     Buffers: shared hit=1
     ->  Result (actual rows=1.00 loops=1)
   Execution Time: 0.003 ms
 
   Nested Statement #3 (level 3):
   Query Text: INSERT INTO counter_log VALUES (n, n * 10)
   Insert on counter_log (actual rows=0.00 loops=1)
     Buffers: shared hit=1
     ->  Result (actual rows=1.00 loops=1)
   Execution Time: 0.001 ms
 
   Nested Statement #4 (level 2):
   Query Text: SELECT recursive_func(n - 1)
   Result (actual rows=1.00 loops=1)
     Buffers: shared hit=1
   Execution Time: 0.013 ms
 
   Nested Statement #5 (level 1):
   Query Text: SELECT recursive_func(n - 1)
   Result (actual rows=1.00 loops=1)
     Buffers: shared hit=2
   Execution Time: 0.045 ms (4.2%)
 
 Nested Statements Summary:
   Total: 5 statements, max depth 3
   Total Execution Time: 1.382 ms
   Total Nested Time: 1.065 ms (77.1% of total time)
   Slowest Statement: #1 (1.020 ms, 95.8%)
(45 rows)


============================================================================
TEST 9: Exception Handling - Statements in BEGIN/EXCEPTION Blocks
============================================================================

Purpose: Verify statements in exception handlers are captured

psql:comprehensive_nested_statements_test_v4.sql:392: NOTICE:  table "safe_table" does not exist, skipping
DROP TABLE
CREATE TABLE
INSERT 0 1
CREATE FUNCTION
Expected:
  - UPDATE (level 1): initial update
  - UPDATE (level 1): recovery in exception handler
  - The failed INSERT is rolled back and may not appear

                                    QUERY PLAN                                     
-----------------------------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=23
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: UPDATE safe_table SET data = 'updated' WHERE id = 1
   Update on safe_table (actual rows=0.00 loops=1)
     Buffers: shared hit=4
     ->  Index Scan using safe_table_pkey on safe_table (actual rows=1.00 loops=1)
           Index Cond: (id = 1)
           Index Searches: 1
           Buffers: shared hit=2
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE safe_table SET data = 'recovered' WHERE id = 1
   Update on safe_table (actual rows=0.00 loops=1)
     Buffers: shared hit=4
     ->  Index Scan using safe_table_pkey on safe_table (actual rows=1.00 loops=1)
           Index Cond: (id = 1)
           Index Searches: 1
           Buffers: shared hit=2
(22 rows)


============================================================================
TEST 10: No Nested Statements - Plain Query
============================================================================

Purpose: When no nested statements execute, no "Nested Plans:" section

Expected: Normal EXPLAIN output, no Nested Plans section

                   QUERY PLAN                    
-------------------------------------------------
 Seq Scan on products (actual rows=1.00 loops=1)
   Filter: (id = 1)
   Rows Removed by Filter: 2
   Buffers: shared hit=1
(4 rows)


============================================================================
TEST 11: Trigger-Fired Nested Statements
============================================================================

Purpose: Triggers fire DURING the triggering statement, creating
         deeper nesting. Trigger-fired statements are automatically
         detected and annotated with "(trigger)" in the header.
         Their time is tracked separately in the summary.

What this tests:
  - Trigger detection via nested_in_finish flag
  - "(trigger)" annotation on trigger-fired statements
  - Trigger statements show no percentage (time included in parent)
  - Deeper-level direct statements show no percentage (time included in level-1 parent)
  - Summary shows "N direct, M trigger-fired" breakdown
  - Total Trigger Time shown separately with % of nested time
  - Completion order: trigger finishes before parent

psql:comprehensive_nested_statements_test_v4.sql:459: NOTICE:  table "orders" does not exist, skipping
DROP TABLE
psql:comprehensive_nested_statements_test_v4.sql:460: NOTICE:  table "audit_log" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE TABLE
CREATE FUNCTION
CREATE TRIGGER
CREATE FUNCTION
Expected:
  #1 (level 2, trigger): INSERT INTO audit_log — trigger from INSERT
  #2 (level 1): INSERT INTO orders — the triggering statement
  #3 (level 2, trigger): INSERT INTO audit_log — trigger from UPDATE
  #4 (level 1): UPDATE orders — the triggering statement

Summary should show: (2 direct, 2 trigger-fired)
Total Trigger Time shows % of nested time

                                         QUERY PLAN                                          
---------------------------------------------------------------------------------------------
 Result (actual time=2.033..2.033 rows=1.00 loops=1)
   Buffers: shared hit=68 read=1 dirtied=4 written=3
 Planning Time: 0.015 ms
 Execution Time: 2.039 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 2, trigger):
   Query Text: INSERT INTO audit_log (order_id, action)
     VALUES (NEW.id, TG_OP || ': ' || NEW.status)
   Insert on audit_log (actual time=0.477..0.478 rows=0.00 loops=1)
     Buffers: shared dirtied=1 written=1
     ->  Result (actual time=0.029..0.029 rows=1.00 loops=1)
   Execution Time: 0.478 ms
 
   Nested Statement #2 (level 1):
   Query Text: INSERT INTO orders VALUES (p_id, 99.99, 'new')
   Insert on orders (actual time=0.969..0.969 rows=0.00 loops=1)
     Buffers: shared hit=14 read=1 dirtied=3 written=2
     ->  Result (actual time=0.001..0.001 rows=1.00 loops=1)
   Trigger order_audit_trigger: time=0.705 calls=1
   Execution Time: 1.675 ms (94.0%)
 
   Nested Statement #3 (level 2, trigger):
   Query Text: INSERT INTO audit_log (order_id, action)
     VALUES (NEW.id, TG_OP || ': ' || NEW.status)
   Insert on audit_log (actual time=0.005..0.005 rows=0.00 loops=1)
     Buffers: shared hit=1
     ->  Result (actual time=0.002..0.002 rows=1.00 loops=1)
   Execution Time: 0.005 ms
 
   Nested Statement #4 (level 1):
   Query Text: UPDATE orders SET status = 'processed' WHERE id = p_id
   Update on orders (actual time=0.057..0.058 rows=0.00 loops=1)
     Buffers: shared hit=5
     ->  Index Scan using orders_pkey on orders (actual time=0.005..0.006 rows=1.00 loops=1)
           Index Cond: (id = 1)
           Index Searches: 1
           Buffers: shared hit=2
   Trigger order_audit_trigger: time=0.049 calls=1
   Execution Time: 0.107 ms (6.0%)
 
 Nested Statements Summary:
   Total: 4 statements (2 direct, 2 trigger-fired), max depth 2
   Total Execution Time: 2.039 ms
   Total Nested Time: 1.782 ms (87.4% of total time)
   Slowest Statement: #2 (1.675 ms, 94.0%)
(47 rows)


============================================================================
TEST 12: NESTED_STATEMENTS with VERBOSE and BUFFERS
============================================================================

Purpose: VERBOSE and BUFFERS options are inherited by nested plans

CREATE FUNCTION
Expected: Schema-qualified names (public.products) and Output columns

                                             QUERY PLAN                                              
-----------------------------------------------------------------------------------------------------
 Result  (cost=0.00..0.26 rows=1 width=4) (actual rows=1.00 loops=1)
   Output: verbose_func()
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM products
   Aggregate  (cost=17.88..17.89 rows=1 width=8) (actual rows=1.00 loops=1)
     Output: count(*)
     Buffers: shared hit=1
     ->  Seq Scan on public.products  (cost=0.00..16.30 rows=630 width=0) (actual rows=3.00 loops=1)
           Output: id, name, price, category
           Buffers: shared hit=1
(14 rows)


============================================================================
TEST 13: Statement Numbering Shows Completion Order
============================================================================

Purpose: Statement #N reflects when a statement FINISHES (ExecutorEnd),
         not when it starts. This is most visible with triggers:

  Timeline for INSERT with an AFTER trigger:
    1. Parent INSERT starts executing
    2. Trigger fires → trigger INSERT starts → trigger INSERT FINISHES → gets #1
    3. Parent INSERT FINISHES → gets #2

  The trigger statement finishes INSIDE the parent, so it gets a lower number.

psql:comprehensive_nested_statements_test_v4.sql:542: NOTICE:  table "demo_orders" does not exist, skipping
DROP TABLE
psql:comprehensive_nested_statements_test_v4.sql:543: NOTICE:  table "demo_log" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE TABLE
CREATE FUNCTION
CREATE TRIGGER
CREATE FUNCTION
Expected numbering (completion order):
  #1 (level 2, trigger): INSERT INTO demo_log  ← trigger finishes first
  #2 (level 1): INSERT INTO demo_orders (Widget) ← parent finishes second
  #3 (level 2, trigger): INSERT INTO demo_log  ← second trigger finishes
  #4 (level 1): INSERT INTO demo_orders (Gadget) ← second parent finishes

                                QUERY PLAN                                
--------------------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=36 dirtied=2 written=2
 
 Nested Plans:
 
   Nested Statement #1 (level 2, trigger):
   Query Text: INSERT INTO demo_log VALUES ('order placed: ' || NEW.item)
   Insert on demo_log (actual rows=0.00 loops=1)
     Buffers: shared dirtied=1 written=1
     ->  Result (actual rows=1.00 loops=1)
 
   Nested Statement #2 (level 1):
   Query Text: INSERT INTO demo_orders VALUES (1, 'Widget')
   Insert on demo_orders (actual rows=0.00 loops=1)
     Buffers: shared dirtied=1 written=1
     ->  Result (actual rows=1.00 loops=1)
   Trigger demo_after_insert: calls=1
 
   Nested Statement #3 (level 2, trigger):
   Query Text: INSERT INTO demo_log VALUES ('order placed: ' || NEW.item)
   Insert on demo_log (actual rows=0.00 loops=1)
     Buffers: shared hit=1
     ->  Result (actual rows=1.00 loops=1)
 
   Nested Statement #4 (level 1):
   Query Text: INSERT INTO demo_orders VALUES (2, 'Gadget')
   Insert on demo_orders (actual rows=0.00 loops=1)
     Buffers: shared hit=1
     ->  Result (actual rows=1.00 loops=1)
   Trigger demo_after_insert: calls=1
(30 rows)


Key takeaway: Lower statement number = finished earlier.
Triggers finish inside their parent, so they always get lower numbers.

============================================================================
TEST 14: BEGIN/ROLLBACK - Safe Analysis of Data-Modifying Functions
============================================================================

Purpose: Demonstrate the recommended pattern for safely analyzing
         functions that modify data without persisting changes.

Pattern:
  BEGIN;
  EXPLAIN (ANALYZE, NESTED_STATEMENTS) SELECT my_function();
  ROLLBACK;

The function executes (so we get real plans with actual rows),
but ROLLBACK undoes all changes.

psql:comprehensive_nested_statements_test_v4.sql:599: NOTICE:  table "safe_orders" does not exist, skipping
DROP TABLE
CREATE TABLE
INSERT 0 2
CREATE FUNCTION
--- Before: ---
 id |  item  | status  
----+--------+---------
  1 | Widget | pending
  2 | Gadget | pending
(2 rows)


--- EXPLAIN inside BEGIN/ROLLBACK: ---
BEGIN
                                     QUERY PLAN                                      
-------------------------------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=11
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: UPDATE safe_orders SET status = 'processing' WHERE status = 'pending'
   Update on safe_orders (actual rows=0.00 loops=1)
     Buffers: shared hit=5
     ->  Seq Scan on safe_orders (actual rows=2.00 loops=1)
           Filter: (status = 'pending'::text)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: INSERT INTO safe_orders VALUES (3, 'Bonus', 'new')
   Insert on safe_orders (actual rows=0.00 loops=1)
     Buffers: shared hit=1
     ->  Result (actual rows=1.00 loops=1)
 
   Nested Statement #3 (level 1):
   Query Text: DELETE FROM safe_orders WHERE item = 'Gadget'
   Delete on safe_orders (actual rows=0.00 loops=1)
     Buffers: shared hit=2
     ->  Seq Scan on safe_orders (actual rows=1.00 loops=1)
           Filter: (item = 'Gadget'::text)
           Rows Removed by Filter: 2
           Buffers: shared hit=1
(27 rows)

ROLLBACK

--- After ROLLBACK (data unchanged): ---
 id |  item  | status  
----+--------+---------
  1 | Widget | pending
  2 | Gadget | pending
(2 rows)


Result: We got full execution plans with actual row counts,
        but the data is unchanged after ROLLBACK.

============================================================================
TEST 15: Error During EXPLAIN Does Not Crash Server
============================================================================

Purpose: If EXPLAIN errors (e.g., division by zero), hooks must be
         cleaned up so subsequent queries do not crash the backend.

CREATE FUNCTION
psql:comprehensive_nested_statements_test_v4.sql:654: ERROR:  division by zero
CONTEXT:  SQL statement "SELECT 1/x"
PL/pgSQL function divz_plpgsql(integer) line 4 at SQL statement
After error - next query (should not crash):
 post_error_test 
-----------------
               1
(1 row)

After error - EXPLAIN NESTED_STATEMENTS again:
            QUERY PLAN             
-----------------------------------
 Result (actual rows=1.00 loops=1)
 Planning Time: 0.002 ms
 Execution Time: 0.002 ms
(3 rows)

TEST 15: Server survived the error — hooks cleaned up correctly

============================================================================
TEST 16: Nested EXPLAIN Does Not Crash Server
============================================================================

Purpose: A function that internally runs EXPLAIN (NESTED_STATEMENTS)
         should not corrupt the outer EXPLAIN state (reentrancy guard).

CREATE FUNCTION
                         QUERY PLAN                          
-------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: EXPLAIN (ANALYZE, NESTED_STATEMENTS) SELECT 1
   Result (actual rows=1.00 loops=1)
(7 rows)

TEST 16: Server survived nested EXPLAIN — reentrancy guard works

============================================================================
TEST 17: Memory Context Properly Freed After EXPLAIN
============================================================================

Purpose: The dedicated memory context for nested plans should not
         persist after EXPLAIN completes (no memory leak).

            QUERY PLAN             
-----------------------------------
 Result (actual rows=1.00 loops=1)
(1 row)

            QUERY PLAN             
-----------------------------------
 Result (actual rows=1.00 loops=1)
(1 row)

            QUERY PLAN             
-----------------------------------
 Result (actual rows=1.00 loops=1)
(1 row)

Memory contexts named "Nested EXPLAIN plans" (should be 0 rows):
 name 
------
(0 rows)

TEST 17: 0 rows above = memory context freed after EXPLAIN

============================================================================
TEST 18: Memory Context Does Not Grow Across Repeated Calls
============================================================================

Purpose: Run EXPLAIN NESTED_STATEMENTS 20 times and verify no memory
         context persists or accumulates between calls.

CREATE TABLE
INSERT 0 2
CREATE FUNCTION
                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=16
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

                           QUERY PLAN                            
-----------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM mem_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mem_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE mem_test SET val = val || 'x' WHERE id = 1
   Update on mem_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on mem_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

After 20 runs - "Nested EXPLAIN plans" contexts (should be 0 rows):
 name 
------
(0 rows)

TEST 18: 0 rows above = no memory accumulation after 20 runs

============================================================================
TEST 19: Stress Test - Function With 50 Nested Statements
============================================================================

Purpose: Verify the feature handles many nested statements without
         crashing or corrupting memory.

psql:comprehensive_nested_statements_test_v4.sql:766: NOTICE:  table "stress_table" does not exist, skipping
DROP TABLE
CREATE TABLE
INSERT 0 100
CREATE FUNCTION
                               QUERY PLAN                               
------------------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=59
 Planning Time: 0.005 ms
 Execution Time: 1.472 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 1
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.011 ms (3.9%)
 
   Nested Statement #2 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 2
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 2)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.006 ms (2.2%)
 
   Nested Statement #3 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 3
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 3)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.006 ms (2.0%)
 
   Nested Statement #4 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 4
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 4)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.006 ms (2.0%)
 
   Nested Statement #5 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 5
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 5)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.006 ms (2.1%)
 
   Nested Statement #6 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 6
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 6)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.006 ms (1.9%)
 
   Nested Statement #7 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 7
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 7)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #8 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 8
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 8)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.8%)
 
   Nested Statement #9 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 9
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 9)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.006 ms (1.9%)
 
   Nested Statement #10 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 10
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 10)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.006 ms (1.9%)
 
   Nested Statement #11 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 11
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 11)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #12 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 12
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 12)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #13 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 13
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 13)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #14 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 14
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 14)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.006 ms (2.0%)
 
   Nested Statement #15 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 15
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 15)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.8%)
 
   Nested Statement #16 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 16
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 16)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #17 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 17
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 17)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.8%)
 
   Nested Statement #18 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 18
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 18)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #19 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 19
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 19)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.006 ms (2.0%)
 
   Nested Statement #20 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 20
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 20)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #21 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 21
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 21)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #22 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 22
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 22)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.8%)
 
   Nested Statement #23 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 23
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 23)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.006 ms (1.9%)
 
   Nested Statement #24 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 24
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 24)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.8%)
 
   Nested Statement #25 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 25
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 25)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #26 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 26
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 26)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #27 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 27
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 27)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.8%)
 
   Nested Statement #28 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 28
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 28)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.006 ms (1.9%)
 
   Nested Statement #29 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 29
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 29)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #30 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 30
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 30)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #31 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 31
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 31)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #32 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 32
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 32)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.006 ms (1.9%)
 
   Nested Statement #33 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 33
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 33)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #34 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 34
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 34)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.8%)
 
   Nested Statement #35 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 35
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 35)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #36 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 36
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 36)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #37 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 37
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 37)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #38 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 38
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 38)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #39 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 39
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 39)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #40 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 40
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 40)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.8%)
 
   Nested Statement #41 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 41
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 41)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.8%)
 
   Nested Statement #42 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 42
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 42)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #43 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 43
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 43)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.012 ms (4.0%)
 
   Nested Statement #44 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 44
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 44)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.007 ms (2.5%)
 
   Nested Statement #45 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 45
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 45)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.006 ms (2.0%)
 
   Nested Statement #46 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 46
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 46)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.006 ms (2.0%)
 
   Nested Statement #47 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 47
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 47)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.006 ms (2.0%)
 
   Nested Statement #48 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 48
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 48)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
   Nested Statement #49 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 49
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 49)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.006 ms (2.0%)
 
   Nested Statement #50 (level 1):
   Query Text: SELECT COUNT(*)          FROM stress_table WHERE id = 50
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on stress_table (actual rows=1.00 loops=1)
           Filter: (id = 50)
           Rows Removed by Filter: 99
           Buffers: shared hit=1
   Execution Time: 0.005 ms (1.9%)
 
 Nested Statements Summary:
   Total: 50 statements, max depth 1
   Total Execution Time: 1.472 ms
   Total Nested Time: 0.287 ms (19.5% of total time)
   Slowest Statement: #43 (0.012 ms, 4.0%)
(512 rows)


Server healthy after stress:
 server_healthy 
----------------
              1
(1 row)

No memory leak after stress:
 name 
------
(0 rows)

TEST 19: 50 nested statements captured, server healthy, no leak

============================================================================
TEST 20: Execution Time Per Nested Statement
============================================================================

Purpose: Each nested statement shows its Execution Time when SUMMARY
         is enabled (default with ANALYZE). Uses query_instr->total.

psql:comprehensive_nested_statements_test_v4.sql:848: NOTICE:  table "et_test" does not exist, skipping
DROP TABLE
CREATE TABLE
INSERT 0 2
CREATE FUNCTION
Expected: Each nested statement shows "Execution Time: X.XXX ms"

                                QUERY PLAN                                
--------------------------------------------------------------------------
 Result (actual time=0.130..0.130 rows=1.00 loops=1)
   Buffers: shared hit=16
 Planning Time: 0.007 ms
 Execution Time: 0.134 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM et_test
   Aggregate (actual time=0.006..0.006 rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on et_test (actual time=0.004..0.004 rows=2.00 loops=1)
           Buffers: shared hit=1
   Execution Time: 0.006 ms (43.0%)
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE et_test SET val = 'updated' WHERE id = 1
   Update on et_test (actual time=0.008..0.008 rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on et_test (actual time=0.003..0.003 rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
   Execution Time: 0.009 ms (57.0%)
 
 Nested Statements Summary:
   Total: 2 statements, max depth 1
   Total Execution Time: 0.134 ms
   Total Nested Time: 0.015 ms (11.3% of total time)
   Slowest Statement: #2 (0.009 ms, 57.0%)
(30 rows)


============================================================================
TEST 21: Summary and Percentages Hidden with SUMMARY OFF
============================================================================

Purpose: When SUMMARY OFF is specified, the following are all hidden:
  - Per-statement Execution Time and percentage
  - Nested Statements Summary section (total, max depth, slowest)
  - Main query Planning Time and Execution Time
  This is consistent with how the main query hides its timing info.

Expected: No Execution Time, no percentages, no Summary section

                          QUERY PLAN                           
---------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=4
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM et_test
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on et_test (actual rows=2.00 loops=1)
           Buffers: shared hit=1
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE et_test SET val = 'updated' WHERE id = 1
   Update on et_test (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on et_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
(20 rows)

DROP FUNCTION
DROP TABLE

============================================================================
TEST 22: Structured Output - JSON Format
============================================================================

Purpose: Nested plans are output as proper structured JSON with
         Node Type, Plans array, costs, timing, and execution time.

psql:comprehensive_nested_statements_test_v4.sql:900: NOTICE:  table "json_t" does not exist, skipping
DROP TABLE
CREATE TABLE
INSERT 0 2
CREATE FUNCTION
                         QUERY PLAN                         
------------------------------------------------------------
 [                                                         +
   {                                                       +
     "Plan": {                                             +
       "Node Type": "Result",                              +
       "Parallel Aware": false,                            +
       "Async Capable": false,                             +
       "Startup Cost": 0.00,                               +
       "Total Cost": 0.26,                                 +
       "Plan Rows": 1,                                     +
       "Plan Width": 4,                                    +
       "Actual Startup Time": 0.155,                       +
       "Actual Total Time": 0.155,                         +
       "Actual Rows": 1.00,                                +
       "Actual Loops": 1,                                  +
       "Disabled": false,                                  +
       "Shared Hit Blocks": 16,                            +
       "Shared Read Blocks": 0,                            +
       "Shared Dirtied Blocks": 0,                         +
       "Shared Written Blocks": 0,                         +
       "Local Hit Blocks": 0,                              +
       "Local Read Blocks": 0,                             +
       "Local Dirtied Blocks": 0,                          +
       "Local Written Blocks": 0,                          +
       "Temp Read Blocks": 0,                              +
       "Temp Written Blocks": 0                            +
     },                                                    +
     "Planning": {                                         +
       "Shared Hit Blocks": 0,                             +
       "Shared Read Blocks": 0,                            +
       "Shared Dirtied Blocks": 0,                         +
       "Shared Written Blocks": 0,                         +
       "Local Hit Blocks": 0,                              +
       "Local Read Blocks": 0,                             +
       "Local Dirtied Blocks": 0,                          +
       "Local Written Blocks": 0,                          +
       "Temp Read Blocks": 0,                              +
       "Temp Written Blocks": 0                            +
     },                                                    +
     "Planning Time": 0.008,                               +
     "Triggers": [                                         +
     ],                                                    +
     "Execution Time": 0.159                               +
   }                                                       +
 ]                                                         +
                                                           +
 Nested Plans:                                             +
                                                           +
 Nested Statement #1 (level 1):                            +
 Query Text: SELECT COUNT(*)          FROM json_t          +
 [                                                         +
   {                                                       +
     "Plan": {                                             +
       "Node Type": "Aggregate",                           +
       "Strategy": "Plain",                                +
       "Partial Mode": "Simple",                           +
       "Parallel Aware": false,                            +
       "Async Capable": false,                             +
       "Startup Cost": 25.88,                              +
       "Total Cost": 25.89,                                +
       "Plan Rows": 1,                                     +
       "Plan Width": 8,                                    +
       "Actual Startup Time": 0.006,                       +
       "Actual Total Time": 0.006,                         +
       "Actual Rows": 1.00,                                +
       "Actual Loops": 1,                                  +
       "Disabled": false,                                  +
       "Shared Hit Blocks": 1,                             +
       "Shared Read Blocks": 0,                            +
       "Shared Dirtied Blocks": 0,                         +
       "Shared Written Blocks": 0,                         +
       "Local Hit Blocks": 0,                              +
       "Local Read Blocks": 0,                             +
       "Local Dirtied Blocks": 0,                          +
       "Local Written Blocks": 0,                          +
       "Temp Read Blocks": 0,                              +
       "Temp Written Blocks": 0,                           +
       "Plans": [                                          +
         {                                                 +
           "Node Type": "Seq Scan",                        +
           "Parent Relationship": "Outer",                 +
           "Parallel Aware": false,                        +
           "Async Capable": false,                         +
           "Relation Name": "json_t",                      +
           "Alias": "json_t",                              +
           "Startup Cost": 0.00,                           +
           "Total Cost": 22.70,                            +
           "Plan Rows": 1270,                              +
           "Plan Width": 0,                                +
           "Actual Startup Time": 0.004,                   +
           "Actual Total Time": 0.004,                     +
           "Actual Rows": 2.00,                            +
           "Actual Loops": 1,                              +
           "Disabled": false,                              +
           "Shared Hit Blocks": 1,                         +
           "Shared Read Blocks": 0,                        +
           "Shared Dirtied Blocks": 0,                     +
           "Shared Written Blocks": 0,                     +
           "Local Hit Blocks": 0,                          +
           "Local Read Blocks": 0,                         +
           "Local Dirtied Blocks": 0,                      +
           "Local Written Blocks": 0,                      +
           "Temp Read Blocks": 0,                          +
           "Temp Written Blocks": 0                        +
         }                                                 +
       ]                                                   +
     },                                                    +
     "Triggers": [                                         +
     ],                                                    +
     "Execution Time": 0.007                               +
   }                                                       +
 ]                                                         +
                                                           +
 Nested Statement #2 (level 1):                            +
 Query Text: UPDATE json_t SET val = 'updated' WHERE id = 1+
 [                                                         +
   {                                                       +
     "Plan": {                                             +
       "Node Type": "ModifyTable",                         +
       "Operation": "Update",                              +
       "Parallel Aware": false,                            +
       "Async Capable": false,                             +
       "Relation Name": "json_t",                          +
       "Alias": "json_t",                                  +
       "Startup Cost": 0.00,                               +
       "Total Cost": 25.88,                                +
       "Plan Rows": 0,                                     +
       "Plan Width": 0,                                    +
       "Actual Startup Time": 0.009,                       +
       "Actual Total Time": 0.009,                         +
       "Actual Rows": 0.00,                                +
       "Actual Loops": 1,                                  +
       "Disabled": false,                                  +
       "Shared Hit Blocks": 3,                             +
       "Shared Read Blocks": 0,                            +
       "Shared Dirtied Blocks": 0,                         +
       "Shared Written Blocks": 0,                         +
       "Local Hit Blocks": 0,                              +
       "Local Read Blocks": 0,                             +
       "Local Dirtied Blocks": 0,                          +
       "Local Written Blocks": 0,                          +
       "Temp Read Blocks": 0,                              +
       "Temp Written Blocks": 0,                           +
       "Plans": [                                          +
         {                                                 +
           "Node Type": "Seq Scan",                        +
           "Parent Relationship": "Outer",                 +
           "Parallel Aware": false,                        +
           "Async Capable": false,                         +
           "Relation Name": "json_t",                      +
           "Alias": "json_t",                              +
           "Startup Cost": 0.00,                           +
           "Total Cost": 25.88,                            +
           "Plan Rows": 6,                                 +
           "Plan Width": 38,                               +
           "Actual Startup Time": 0.003,                   +
           "Actual Total Time": 0.003,                     +
           "Actual Rows": 1.00,                            +
           "Actual Loops": 1,                              +
           "Disabled": false,                              +
           "Filter": "(id = 1)",                           +
           "Rows Removed by Filter": 1,                    +
           "Shared Hit Blocks": 1,                         +
           "Shared Read Blocks": 0,                        +
           "Shared Dirtied Blocks": 0,                     +
           "Shared Written Blocks": 0,                     +
           "Local Hit Blocks": 0,                          +
           "Local Read Blocks": 0,                         +
           "Local Dirtied Blocks": 0,                      +
           "Local Written Blocks": 0,                      +
           "Temp Read Blocks": 0,                          +
           "Temp Written Blocks": 0                        +
         }                                                 +
       ]                                                   +
     },                                                    +
     "Triggers": [                                         +
     ],                                                    +
     "Execution Time": 0.009                               +
   }                                                       +
 ]                                                         +
                                                           +
 Nested Statements Summary:                                +
   Total: 2 statements, max depth 1                        +
   Total Execution Time: 0.159 ms                          +
   Total Nested Time: 0.016 ms (9.8% of total time)        +
   Slowest Statement: #2 (0.009 ms, 57.4%)                 +
 
(1 row)

DROP FUNCTION
DROP TABLE

============================================================================
TEST 23: Structured Output - XML Format
============================================================================

Purpose: Nested plans are output as proper XML with Node-Type,
         Plans elements, costs, timing, and execution time.

psql:comprehensive_nested_statements_test_v4.sql:929: NOTICE:  table "xml_t" does not exist, skipping
DROP TABLE
CREATE TABLE
INSERT 0 2
CREATE FUNCTION
                          QUERY PLAN                          
--------------------------------------------------------------
 <explain xmlns="http://www.postgresql.org/2009/explain">    +
   <Query>                                                   +
     <Plan>                                                  +
       <Node-Type>Result</Node-Type>                         +
       <Parallel-Aware>false</Parallel-Aware>                +
       <Async-Capable>false</Async-Capable>                  +
       <Startup-Cost>0.00</Startup-Cost>                     +
       <Total-Cost>0.26</Total-Cost>                         +
       <Plan-Rows>1</Plan-Rows>                              +
       <Plan-Width>4</Plan-Width>                            +
       <Actual-Startup-Time>0.199</Actual-Startup-Time>      +
       <Actual-Total-Time>0.199</Actual-Total-Time>          +
       <Actual-Rows>1.00</Actual-Rows>                       +
       <Actual-Loops>1</Actual-Loops>                        +
       <Disabled>false</Disabled>                            +
       <Shared-Hit-Blocks>16</Shared-Hit-Blocks>             +
       <Shared-Read-Blocks>0</Shared-Read-Blocks>            +
       <Shared-Dirtied-Blocks>0</Shared-Dirtied-Blocks>      +
       <Shared-Written-Blocks>0</Shared-Written-Blocks>      +
       <Local-Hit-Blocks>0</Local-Hit-Blocks>                +
       <Local-Read-Blocks>0</Local-Read-Blocks>              +
       <Local-Dirtied-Blocks>0</Local-Dirtied-Blocks>        +
       <Local-Written-Blocks>0</Local-Written-Blocks>        +
       <Temp-Read-Blocks>0</Temp-Read-Blocks>                +
       <Temp-Written-Blocks>0</Temp-Written-Blocks>          +
     </Plan>                                                 +
     <Planning>                                              +
       <Shared-Hit-Blocks>0</Shared-Hit-Blocks>              +
       <Shared-Read-Blocks>0</Shared-Read-Blocks>            +
       <Shared-Dirtied-Blocks>0</Shared-Dirtied-Blocks>      +
       <Shared-Written-Blocks>0</Shared-Written-Blocks>      +
       <Local-Hit-Blocks>0</Local-Hit-Blocks>                +
       <Local-Read-Blocks>0</Local-Read-Blocks>              +
       <Local-Dirtied-Blocks>0</Local-Dirtied-Blocks>        +
       <Local-Written-Blocks>0</Local-Written-Blocks>        +
       <Temp-Read-Blocks>0</Temp-Read-Blocks>                +
       <Temp-Written-Blocks>0</Temp-Written-Blocks>          +
     </Planning>                                             +
     <Planning-Time>0.008</Planning-Time>                    +
     <Triggers>                                              +
     </Triggers>                                             +
     <Execution-Time>0.203</Execution-Time>                  +
   </Query>                                                  +
 </explain>                                                  +
                                                             +
 Nested Plans:                                               +
                                                             +
 Nested Statement #1 (level 1):                              +
 Query Text: SELECT COUNT(*)          FROM xml_t             +
 <explain xmlns="http://www.postgresql.org/2009/explain">    +
   <Query>                                                   +
     <Plan>                                                  +
       <Node-Type>Aggregate</Node-Type>                      +
       <Strategy>Plain</Strategy>                            +
       <Partial-Mode>Simple</Partial-Mode>                   +
       <Parallel-Aware>false</Parallel-Aware>                +
       <Async-Capable>false</Async-Capable>                  +
       <Startup-Cost>25.88</Startup-Cost>                    +
       <Total-Cost>25.89</Total-Cost>                        +
       <Plan-Rows>1</Plan-Rows>                              +
       <Plan-Width>8</Plan-Width>                            +
       <Actual-Startup-Time>0.006</Actual-Startup-Time>      +
       <Actual-Total-Time>0.007</Actual-Total-Time>          +
       <Actual-Rows>1.00</Actual-Rows>                       +
       <Actual-Loops>1</Actual-Loops>                        +
       <Disabled>false</Disabled>                            +
       <Shared-Hit-Blocks>1</Shared-Hit-Blocks>              +
       <Shared-Read-Blocks>0</Shared-Read-Blocks>            +
       <Shared-Dirtied-Blocks>0</Shared-Dirtied-Blocks>      +
       <Shared-Written-Blocks>0</Shared-Written-Blocks>      +
       <Local-Hit-Blocks>0</Local-Hit-Blocks>                +
       <Local-Read-Blocks>0</Local-Read-Blocks>              +
       <Local-Dirtied-Blocks>0</Local-Dirtied-Blocks>        +
       <Local-Written-Blocks>0</Local-Written-Blocks>        +
       <Temp-Read-Blocks>0</Temp-Read-Blocks>                +
       <Temp-Written-Blocks>0</Temp-Written-Blocks>          +
       <Plans>                                               +
         <Plan>                                              +
           <Node-Type>Seq Scan</Node-Type>                   +
           <Parent-Relationship>Outer</Parent-Relationship>  +
           <Parallel-Aware>false</Parallel-Aware>            +
           <Async-Capable>false</Async-Capable>              +
           <Relation-Name>xml_t</Relation-Name>              +
           <Alias>xml_t</Alias>                              +
           <Startup-Cost>0.00</Startup-Cost>                 +
           <Total-Cost>22.70</Total-Cost>                    +
           <Plan-Rows>1270</Plan-Rows>                       +
           <Plan-Width>0</Plan-Width>                        +
           <Actual-Startup-Time>0.004</Actual-Startup-Time>  +
           <Actual-Total-Time>0.004</Actual-Total-Time>      +
           <Actual-Rows>2.00</Actual-Rows>                   +
           <Actual-Loops>1</Actual-Loops>                    +
           <Disabled>false</Disabled>                        +
           <Shared-Hit-Blocks>1</Shared-Hit-Blocks>          +
           <Shared-Read-Blocks>0</Shared-Read-Blocks>        +
           <Shared-Dirtied-Blocks>0</Shared-Dirtied-Blocks>  +
           <Shared-Written-Blocks>0</Shared-Written-Blocks>  +
           <Local-Hit-Blocks>0</Local-Hit-Blocks>            +
           <Local-Read-Blocks>0</Local-Read-Blocks>          +
           <Local-Dirtied-Blocks>0</Local-Dirtied-Blocks>    +
           <Local-Written-Blocks>0</Local-Written-Blocks>    +
           <Temp-Read-Blocks>0</Temp-Read-Blocks>            +
           <Temp-Written-Blocks>0</Temp-Written-Blocks>      +
         </Plan>                                             +
       </Plans>                                              +
     </Plan>                                                 +
     <Triggers>                                              +
     </Triggers>                                             +
     <Execution-Time>0.007</Execution-Time>                  +
   </Query>                                                  +
 </explain>                                                  +
                                                             +
 Nested Statement #2 (level 1):                              +
 Query Text: UPDATE xml_t SET val = 'updated' WHERE id = 1   +
 <explain xmlns="http://www.postgresql.org/2009/explain">    +
   <Query>                                                   +
     <Plan>                                                  +
       <Node-Type>ModifyTable</Node-Type>                    +
       <Operation>Update</Operation>                         +
       <Parallel-Aware>false</Parallel-Aware>                +
       <Async-Capable>false</Async-Capable>                  +
       <Relation-Name>xml_t</Relation-Name>                  +
       <Alias>xml_t</Alias>                                  +
       <Startup-Cost>0.00</Startup-Cost>                     +
       <Total-Cost>25.88</Total-Cost>                        +
       <Plan-Rows>0</Plan-Rows>                              +
       <Plan-Width>0</Plan-Width>                            +
       <Actual-Startup-Time>0.008</Actual-Startup-Time>      +
       <Actual-Total-Time>0.008</Actual-Total-Time>          +
       <Actual-Rows>0.00</Actual-Rows>                       +
       <Actual-Loops>1</Actual-Loops>                        +
       <Disabled>false</Disabled>                            +
       <Shared-Hit-Blocks>3</Shared-Hit-Blocks>              +
       <Shared-Read-Blocks>0</Shared-Read-Blocks>            +
       <Shared-Dirtied-Blocks>0</Shared-Dirtied-Blocks>      +
       <Shared-Written-Blocks>0</Shared-Written-Blocks>      +
       <Local-Hit-Blocks>0</Local-Hit-Blocks>                +
       <Local-Read-Blocks>0</Local-Read-Blocks>              +
       <Local-Dirtied-Blocks>0</Local-Dirtied-Blocks>        +
       <Local-Written-Blocks>0</Local-Written-Blocks>        +
       <Temp-Read-Blocks>0</Temp-Read-Blocks>                +
       <Temp-Written-Blocks>0</Temp-Written-Blocks>          +
       <Plans>                                               +
         <Plan>                                              +
           <Node-Type>Seq Scan</Node-Type>                   +
           <Parent-Relationship>Outer</Parent-Relationship>  +
           <Parallel-Aware>false</Parallel-Aware>            +
           <Async-Capable>false</Async-Capable>              +
           <Relation-Name>xml_t</Relation-Name>              +
           <Alias>xml_t</Alias>                              +
           <Startup-Cost>0.00</Startup-Cost>                 +
           <Total-Cost>25.88</Total-Cost>                    +
           <Plan-Rows>6</Plan-Rows>                          +
           <Plan-Width>38</Plan-Width>                       +
           <Actual-Startup-Time>0.003</Actual-Startup-Time>  +
           <Actual-Total-Time>0.003</Actual-Total-Time>      +
           <Actual-Rows>1.00</Actual-Rows>                   +
           <Actual-Loops>1</Actual-Loops>                    +
           <Disabled>false</Disabled>                        +
           <Filter>(id = 1)</Filter>                         +
           <Rows-Removed-by-Filter>1</Rows-Removed-by-Filter>+
           <Shared-Hit-Blocks>1</Shared-Hit-Blocks>          +
           <Shared-Read-Blocks>0</Shared-Read-Blocks>        +
           <Shared-Dirtied-Blocks>0</Shared-Dirtied-Blocks>  +
           <Shared-Written-Blocks>0</Shared-Written-Blocks>  +
           <Local-Hit-Blocks>0</Local-Hit-Blocks>            +
           <Local-Read-Blocks>0</Local-Read-Blocks>          +
           <Local-Dirtied-Blocks>0</Local-Dirtied-Blocks>    +
           <Local-Written-Blocks>0</Local-Written-Blocks>    +
           <Temp-Read-Blocks>0</Temp-Read-Blocks>            +
           <Temp-Written-Blocks>0</Temp-Written-Blocks>      +
         </Plan>                                             +
       </Plans>                                              +
     </Plan>                                                 +
     <Triggers>                                              +
     </Triggers>                                             +
     <Execution-Time>0.009</Execution-Time>                  +
   </Query>                                                  +
 </explain>                                                  +
                                                             +
 Nested Statements Summary:                                  +
   Total: 2 statements, max depth 1                          +
   Total Execution Time: 0.203 ms                            +
   Total Nested Time: 0.016 ms (7.8% of total time)          +
   Slowest Statement: #2 (0.009 ms, 54.2%)                   +
 
(1 row)

DROP FUNCTION
DROP TABLE

============================================================================
TEST 24: Structured Output - YAML Format
============================================================================

Purpose: Nested plans are output as proper YAML with Node Type,
         Plans list, costs, timing, and execution time.

psql:comprehensive_nested_statements_test_v4.sql:958: NOTICE:  table "yaml_t" does not exist, skipping
DROP TABLE
CREATE TABLE
INSERT 0 2
CREATE FUNCTION
                         QUERY PLAN                         
------------------------------------------------------------
 - Plan:                                                   +
     Node Type: "Result"                                   +
     Parallel Aware: false                                 +
     Async Capable: false                                  +
     Startup Cost: 0.00                                    +
     Total Cost: 0.26                                      +
     Plan Rows: 1                                          +
     Plan Width: 4                                         +
     Actual Startup Time: 0.166                            +
     Actual Total Time: 0.166                              +
     Actual Rows: 1.00                                     +
     Actual Loops: 1                                       +
     Disabled: false                                       +
     Shared Hit Blocks: 16                                 +
     Shared Read Blocks: 0                                 +
     Shared Dirtied Blocks: 0                              +
     Shared Written Blocks: 0                              +
     Local Hit Blocks: 0                                   +
     Local Read Blocks: 0                                  +
     Local Dirtied Blocks: 0                               +
     Local Written Blocks: 0                               +
     Temp Read Blocks: 0                                   +
     Temp Written Blocks: 0                                +
   Planning:                                               +
     Shared Hit Blocks: 0                                  +
     Shared Read Blocks: 0                                 +
     Shared Dirtied Blocks: 0                              +
     Shared Written Blocks: 0                              +
     Local Hit Blocks: 0                                   +
     Local Read Blocks: 0                                  +
     Local Dirtied Blocks: 0                               +
     Local Written Blocks: 0                               +
     Temp Read Blocks: 0                                   +
     Temp Written Blocks: 0                                +
   Planning Time: 0.009                                    +
   Triggers:                                               +
   Execution Time: 0.171                                   +
                                                           +
 Nested Plans:                                             +
                                                           +
 Nested Statement #1 (level 1):                            +
 Query Text: SELECT COUNT(*)          FROM yaml_t          +
 - Plan:                                                   +
     Node Type: "Aggregate"                                +
     Strategy: "Plain"                                     +
     Partial Mode: "Simple"                                +
     Parallel Aware: false                                 +
     Async Capable: false                                  +
     Startup Cost: 25.88                                   +
     Total Cost: 25.89                                     +
     Plan Rows: 1                                          +
     Plan Width: 8                                         +
     Actual Startup Time: 0.006                            +
     Actual Total Time: 0.006                              +
     Actual Rows: 1.00                                     +
     Actual Loops: 1                                       +
     Disabled: false                                       +
     Shared Hit Blocks: 1                                  +
     Shared Read Blocks: 0                                 +
     Shared Dirtied Blocks: 0                              +
     Shared Written Blocks: 0                              +
     Local Hit Blocks: 0                                   +
     Local Read Blocks: 0                                  +
     Local Dirtied Blocks: 0                               +
     Local Written Blocks: 0                               +
     Temp Read Blocks: 0                                   +
     Temp Written Blocks: 0                                +
     Plans:                                                +
       - Node Type: "Seq Scan"                             +
         Parent Relationship: "Outer"                      +
         Parallel Aware: false                             +
         Async Capable: false                              +
         Relation Name: "yaml_t"                           +
         Alias: "yaml_t"                                   +
         Startup Cost: 0.00                                +
         Total Cost: 22.70                                 +
         Plan Rows: 1270                                   +
         Plan Width: 0                                     +
         Actual Startup Time: 0.004                        +
         Actual Total Time: 0.005                          +
         Actual Rows: 2.00                                 +
         Actual Loops: 1                                   +
         Disabled: false                                   +
         Shared Hit Blocks: 1                              +
         Shared Read Blocks: 0                             +
         Shared Dirtied Blocks: 0                          +
         Shared Written Blocks: 0                          +
         Local Hit Blocks: 0                               +
         Local Read Blocks: 0                              +
         Local Dirtied Blocks: 0                           +
         Local Written Blocks: 0                           +
         Temp Read Blocks: 0                               +
         Temp Written Blocks: 0                            +
   Triggers:                                               +
   Execution Time: 0.007                                   +
                                                           +
 Nested Statement #2 (level 1):                            +
 Query Text: UPDATE yaml_t SET val = 'updated' WHERE id = 1+
 - Plan:                                                   +
     Node Type: "ModifyTable"                              +
     Operation: "Update"                                   +
     Parallel Aware: false                                 +
     Async Capable: false                                  +
     Relation Name: "yaml_t"                               +
     Alias: "yaml_t"                                       +
     Startup Cost: 0.00                                    +
     Total Cost: 25.88                                     +
     Plan Rows: 0                                          +
     Plan Width: 0                                         +
     Actual Startup Time: 0.009                            +
     Actual Total Time: 0.009                              +
     Actual Rows: 0.00                                     +
     Actual Loops: 1                                       +
     Disabled: false                                       +
     Shared Hit Blocks: 3                                  +
     Shared Read Blocks: 0                                 +
     Shared Dirtied Blocks: 0                              +
     Shared Written Blocks: 0                              +
     Local Hit Blocks: 0                                   +
     Local Read Blocks: 0                                  +
     Local Dirtied Blocks: 0                               +
     Local Written Blocks: 0                               +
     Temp Read Blocks: 0                                   +
     Temp Written Blocks: 0                                +
     Plans:                                                +
       - Node Type: "Seq Scan"                             +
         Parent Relationship: "Outer"                      +
         Parallel Aware: false                             +
         Async Capable: false                              +
         Relation Name: "yaml_t"                           +
         Alias: "yaml_t"                                   +
         Startup Cost: 0.00                                +
         Total Cost: 25.88                                 +
         Plan Rows: 6                                      +
         Plan Width: 38                                    +
         Actual Startup Time: 0.003                        +
         Actual Total Time: 0.003                          +
         Actual Rows: 1.00                                 +
         Actual Loops: 1                                   +
         Disabled: false                                   +
         Filter: "(id = 1)"                                +
         Rows Removed by Filter: 1                         +
         Shared Hit Blocks: 1                              +
         Shared Read Blocks: 0                             +
         Shared Dirtied Blocks: 0                          +
         Shared Written Blocks: 0                          +
         Local Hit Blocks: 0                               +
         Local Read Blocks: 0                              +
         Local Dirtied Blocks: 0                           +
         Local Written Blocks: 0                           +
         Temp Read Blocks: 0                               +
         Temp Written Blocks: 0                            +
   Triggers:                                               +
   Execution Time: 0.009                                   +
                                                           +
 Nested Statements Summary:                                +
   Total: 2 statements, max depth 1                        +
   Total Execution Time: 0.171 ms                          +
   Total Nested Time: 0.016 ms (9.6% of total time)        +
   Slowest Statement: #2 (0.009 ms, 57.2%)                 +
 
(1 row)

DROP FUNCTION
DROP TABLE

============================================================================
TEST 25: SHOW_NESTED - Limit Displayed Plans
============================================================================

Purpose: SHOW_NESTED N controls how many nested plans are displayed.
         All statements are still captured internally for the summary,
         but only the first N plans are shown in the output.

What this tests:
  - A function with 5 nested statements
  - SHOW_NESTED 2 shows only first 2 plans
  - Header shows "(showing 2 of 5)"
  - Summary still reflects all 5 statements

psql:comprehensive_nested_statements_test_v4.sql:994: NOTICE:  table "sn_test" does not exist, skipping
DROP TABLE
CREATE TABLE
INSERT 0 10
CREATE FUNCTION
                            QUERY PLAN                            
------------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=14
 Planning Time: 0.011 ms
 Execution Time: 0.197 ms
 
 Nested Plans (showing 2 of 5):
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM sn_test WHERE id = 1
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on sn_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 9
           Buffers: shared hit=1
   Execution Time: 0.008 ms (42.5%)
 
   Nested Statement #2 (level 1):
   Query Text: SELECT COUNT(*)          FROM sn_test WHERE id = 2
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on sn_test (actual rows=1.00 loops=1)
           Filter: (id = 2)
           Rows Removed by Filter: 9
           Buffers: shared hit=1
   Execution Time: 0.003 ms (18.1%)
 
 Nested Statements Summary:
   Total: 5 statements, max depth 1
   Total Execution Time: 0.197 ms
   Total Nested Time: 0.019 ms (9.7% of total time)
   Slowest Statement: #1 (0.008 ms, 42.5%)
(32 rows)


============================================================================
TEST 26: SHOW_NESTED 0 - Summary Only (No Plans Displayed)
============================================================================

Purpose: SHOW_NESTED 0 means "capture all but display none".
         Only the summary is shown — useful for getting a quick
         overview of a complex function without pages of plan output.

What this tests:
  - No individual plans are displayed
  - Header shows "(showing 0 of 5)"
  - Summary shows total count, max depth, timing, and slowest
  - User can then re-run with a higher SHOW_NESTED to see details

                     QUERY PLAN                      
-----------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=5
 Planning Time: 0.005 ms
 Execution Time: 0.040 ms
 
 Nested Plans (showing 0 of 5):
 
 Nested Statements Summary:
   Total: 5 statements, max depth 1
   Total Execution Time: 0.040 ms
   Total Nested Time: 0.013 ms (33.9% of total time)
   Slowest Statement: #1 (0.005 ms, 38.0%)
(12 rows)


============================================================================
TEST 27: SHOW_NESTED Validation
============================================================================

Purpose: SHOW_NESTED requires NESTED_STATEMENTS to be enabled.
         Using it alone should produce a clear error message.

psql:comprehensive_nested_statements_test_v4.sql:1047: ERROR:  EXPLAIN option SHOW_NESTED requires NESTED_STATEMENTS

============================================================================
TEST 28: Nested Statements Summary with Percentages
============================================================================

Purpose: The summary shows statistics about all nested statements:
  - Total count and max nesting depth
  - Total Nested Time with % of main Execution Time
  - Slowest statement with % of nested total

Per-statement Execution Time shows % of nested total for level-1
statements only. Deeper levels show absolute time (their time is
already included in their level-1 parent).

Percentage bases:
  - Per-statement %: statement_time / total_nested_time (level 1 only)
  - Summary Total %: total_nested_time / main_execution_time
  - Slowest %: slowest_time / total_nested_time (level 1 only)

                            QUERY PLAN                            
------------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=5
 Planning Time: 0.004 ms
 Execution Time: 0.060 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM sn_test WHERE id = 1
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on sn_test (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 9
           Buffers: shared hit=1
   Execution Time: 0.006 ms (39.0%)
 
   Nested Statement #2 (level 1):
   Query Text: SELECT COUNT(*)          FROM sn_test WHERE id = 2
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on sn_test (actual rows=1.00 loops=1)
           Filter: (id = 2)
           Rows Removed by Filter: 9
           Buffers: shared hit=1
   Execution Time: 0.003 ms (18.9%)
 
   Nested Statement #3 (level 1):
   Query Text: SELECT COUNT(*)          FROM sn_test WHERE id = 3
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on sn_test (actual rows=1.00 loops=1)
           Filter: (id = 3)
           Rows Removed by Filter: 9
           Buffers: shared hit=1
   Execution Time: 0.002 ms (15.3%)
 
   Nested Statement #4 (level 1):
   Query Text: SELECT COUNT(*)          FROM sn_test WHERE id = 4
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on sn_test (actual rows=1.00 loops=1)
           Filter: (id = 4)
           Rows Removed by Filter: 9
           Buffers: shared hit=1
   Execution Time: 0.002 ms (13.4%)
 
   Nested Statement #5 (level 1):
   Query Text: SELECT COUNT(*)          FROM sn_test WHERE id = 5
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on sn_test (actual rows=1.00 loops=1)
           Filter: (id = 5)
           Rows Removed by Filter: 9
           Buffers: shared hit=1
   Execution Time: 0.002 ms (13.4%)
 
 Nested Statements Summary:
   Total: 5 statements, max depth 1
   Total Execution Time: 0.060 ms
   Total Nested Time: 0.015 ms (25.0% of total time)
   Slowest Statement: #1 (0.006 ms, 39.0%)
(62 rows)

DROP FUNCTION
DROP TABLE

============================================================================
TEST 29: Statement Timeout — Hooks Cleaned Up After Timeout
============================================================================

Purpose: A function with multiple statements times out mid-execution.
         The first statement was captured internally but the timeout
         aborts the entire EXPLAIN before output is produced.
         PG_FINALLY cleanup frees the partial data correctly.
         After the error, the server continues working normally.

CREATE FUNCTION
CREATE FUNCTION
SET
psql:comprehensive_nested_statements_test_v4.sql:1108: ERROR:  canceling statement due to statement timeout
CONTEXT:  SQL statement "SELECT pg_sleep(5)"
PL/pgSQL function timeout_inner() line 3 at PERFORM
SQL statement "SELECT timeout_inner()"
PL/pgSQL function timeout_outer() line 5 at PERFORM
RESET
After timeout - server still works:
 post_timeout_ok 
-----------------
               1
(1 row)


DROP FUNCTION
DROP FUNCTION
============================================================================
TEST 30: Dynamic SQL — Query Text Captured Correctly
============================================================================

Purpose: When a function uses EXECUTE (dynamic SQL), the Query Text
         field shows the actual executed SQL string, not the PL/pgSQL
         expression that built it.

psql:comprehensive_nested_statements_test_v4.sql:1130: NOTICE:  table "dyn_t" does not exist, skipping
DROP TABLE
CREATE TABLE
INSERT 0 2
CREATE FUNCTION
                          QUERY PLAN                           
---------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=20 read=2
 Planning Time: 0.011 ms
 Execution Time: 0.258 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*) FROM dyn_t
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on dyn_t (actual rows=2.00 loops=1)
           Buffers: shared hit=1
   Execution Time: 0.008 ms (43.0%)
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE dyn_t SET val = 'dynamic' WHERE id = '1'
   Update on dyn_t (actual rows=0.00 loops=1)
     Buffers: shared hit=3
     ->  Seq Scan on dyn_t (actual rows=1.00 loops=1)
           Filter: (id = 1)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
   Execution Time: 0.010 ms (57.0%)
 
 Nested Statements Summary:
   Total: 2 statements, max depth 1
   Total Execution Time: 0.258 ms
   Total Nested Time: 0.018 ms (6.8% of total time)
   Slowest Statement: #2 (0.010 ms, 57.0%)
(30 rows)

DROP FUNCTION
DROP TABLE

============================================================================
TEST 31: Infinite Recursion — Graceful Error and Cleanup
============================================================================

Purpose: A function that calls itself infinitely triggers
         "stack depth limit exceeded". After this error, the server
         must not crash and hooks must be cleaned up.

How PostgreSQL prevents infinite recursion:
  - Every function call adds a "frame" to the OS call stack
  - PostgreSQL has a GUC: max_stack_depth (default 2MB)
  - The function check_stack_depth() is called before each PL/pgSQL
    function entry to check if the stack is getting too large
  - When the stack exceeds max_stack_depth, PostgreSQL throws:
    ERROR: stack depth limit exceeded
  - This happens after roughly 100-200 nested calls

What this tests for NESTED_STATEMENTS:
  - The error fires while our hooks are installed
  - Some nested plans may have been partially captured in memory
  - PG_TRY/PG_FINALLY must clean up: remove hooks, free memory
  - After the error, the next query must work normally

CREATE FUNCTION
psql:comprehensive_nested_statements_test_v4.sql:1182: ERROR:  stack depth limit exceeded
HINT:  Increase the configuration parameter "max_stack_depth" (currently 2048kB), after ensuring the platform's stack depth limit is adequate.
CONTEXT:  SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
SQL statement "SELECT inf_func()"
PL/pgSQL function inf_func() line 3 at PERFORM
After recursion error - server still works:
 post_recursion_ok 
-------------------
                 1
(1 row)


DROP FUNCTION
============================================================================
TEST 32: auto_explain Compatibility — Hooks Coexist
============================================================================

Purpose: auto_explain uses the same executor hooks we use.
         Both must coexist without crashes or duplicate output.
         Hook chaining (prev_hook saved/restored) must work.

psql:comprehensive_nested_statements_test_v4.sql:1202: NOTICE:  table "ae_t" does not exist, skipping
DROP TABLE
CREATE TABLE
INSERT 0 1
CREATE FUNCTION
LOAD
SET
SET
SET
                     QUERY PLAN                      
-----------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=8
 Planning Time: 0.016 ms
 Execution Time: 0.845 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM ae_t
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on ae_t (actual rows=1.00 loops=1)
           Buffers: shared hit=1
   Execution Time: 0.011 ms (100.0%)
 
 Nested Statements Summary:
   Total: 1 statements, max depth 1
   Total Execution Time: 0.845 ms
   Total Nested Time: 0.011 ms (1.3% of total time)
   Slowest Statement: #1 (0.011 ms, 100.0%)
(20 rows)

RESET
RESET
RESET
DROP FUNCTION
DROP TABLE

============================================================================
TEST 33: Deep Nesting — 20 Levels Without Crash
============================================================================

Purpose: Verify deep function call chains do not crash or corrupt
         memory. Uses 20 levels (100 would hit stack limit).

CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
            QUERY PLAN             
-----------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=60
 Planning Time: 0.011 ms
 Execution Time: 0.165 ms
(4 rows)

DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION

============================================================================
TEST 34: All EXPLAIN Options Combined with SHOW_NESTED
============================================================================

Purpose: Every option together — NESTED_STATEMENTS, VERBOSE, BUFFERS,
         WAL, SETTINGS, SHOW_NESTED 3. Verifies no conflicts.

psql:comprehensive_nested_statements_test_v4.sql:1273: NOTICE:  table "combo_t" does not exist, skipping
DROP TABLE
CREATE TABLE
INSERT 0 3
CREATE FUNCTION
                                                      QUERY PLAN                                                       
-----------------------------------------------------------------------------------------------------------------------
 Result  (cost=0.00..0.26 rows=1 width=4) (actual time=1.103..1.103 rows=1.00 loops=1)
   Output: combo_f()
   Buffers: shared hit=22
   WAL: records=2 bytes=132
 Planning Time: 0.007 ms
 Execution Time: 1.106 ms
 
 Nested Plans (showing 3 of 5):
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM combo_t
   Aggregate  (cost=25.88..25.89 rows=1 width=8) (actual time=0.006..0.006 rows=1.00 loops=1)
     Output: count(*)
     Buffers: shared hit=1
     ->  Seq Scan on public.combo_t  (cost=0.00..22.70 rows=1270 width=0) (actual time=0.004..0.004 rows=3.00 loops=1)
           Output: id, val
           Buffers: shared hit=1
   Execution Time: 0.007 ms (20.5%)
 
   Nested Statement #2 (level 1):
   Query Text: UPDATE combo_t SET val = 'x' WHERE id = 1
   Update on public.combo_t  (cost=0.00..25.88 rows=0 width=0) (actual time=0.013..0.013 rows=0.00 loops=1)
     Buffers: shared hit=3
     WAL: records=1 bytes=69
     ->  Seq Scan on public.combo_t  (cost=0.00..25.88 rows=6 width=38) (actual time=0.004..0.004 rows=1.00 loops=1)
           Output: 'x'::text, ctid
           Filter: (combo_t.id = 1)
           Rows Removed by Filter: 2
           Buffers: shared hit=1
   Execution Time: 0.013 ms (38.5%)
 
   Nested Statement #3 (level 1):
   Query Text: DELETE FROM combo_t WHERE id = 99
   Delete on public.combo_t  (cost=0.00..25.88 rows=0 width=0) (actual time=0.005..0.006 rows=0.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on public.combo_t  (cost=0.00..25.88 rows=6 width=6) (actual time=0.005..0.005 rows=0.00 loops=1)
           Output: ctid
           Filter: (combo_t.id = 99)
           Rows Removed by Filter: 3
           Buffers: shared hit=1
   Execution Time: 0.006 ms (17.3%)
 
 Nested Statements Summary:
   Total: 5 statements, max depth 1
   Total Execution Time: 1.106 ms
   Total Nested Time: 0.034 ms (3.0% of total time)
   Slowest Statement: #2 (0.013 ms, 38.5%)
(47 rows)

DROP FUNCTION
DROP TABLE

============================================================================
TEST 35: Performance — Zero Overhead When Feature Disabled
============================================================================

Purpose: When NESTED_STATEMENTS is not used, there should be zero
         overhead. Hooks are only installed during EXPLAIN with
         NESTED_STATEMENTS — regular queries are unaffected.

psql:comprehensive_nested_statements_test_v4.sql:1307: NOTICE:  table "perf_t" does not exist, skipping
DROP TABLE
CREATE TABLE
INSERT 0 1000
CREATE FUNCTION
Timing is on.
Without NESTED_STATEMENTS (baseline):
                  QUERY PLAN                  
----------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=15 dirtied=1 written=1
(2 rows)

Time: 0.750 ms

With NESTED_STATEMENTS:
                        QUERY PLAN                        
----------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=6
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM perf_t
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=6
     ->  Seq Scan on perf_t (actual rows=1000.00 loops=1)
           Buffers: shared hit=6
(11 rows)

Time: 1.569 ms
Timing is off.
DROP FUNCTION
DROP TABLE

============================================================================
TEST 36: Interpreting Total Nested Time Percentage
============================================================================

Purpose: Demonstrate how the "Total Nested Time (X% of total time)"
         helps users decide WHERE to optimize.

The percentage answers: "How much of my function execution time
                         is spent in SQL vs PL/pgSQL overhead?"

Interpretation guide:
  High % (80-100%): Most time is in SQL queries.
    → Action: Optimize the SQL (add indexes, rewrite queries)
  Low % (0-20%): SQL is fast, PL/pgSQL overhead dominates.
    → Action: Reduce function complexity (fewer loops, less logic)
  Medium % (20-80%): Mixed — both SQL and overhead contribute.
    → Action: Look at per-statement % to find the slow query

--- Function A: SQL-heavy (big scan, minimal PL/pgSQL logic) ---

psql:comprehensive_nested_statements_test_v4.sql:1355: NOTICE:  table "big_table" does not exist, skipping
DROP TABLE
CREATE TABLE
INSERT 0 10000
CREATE FUNCTION
                                    QUERY PLAN                                     
-----------------------------------------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=78 dirtied=1 written=1
 Planning Time: 0.016 ms
 Execution Time: 1.186 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT SUM(val)             FROM big_table WHERE category = 'cat_5'
   Aggregate (actual rows=1.00 loops=1)
     Buffers: shared hit=64 dirtied=1 written=1
     ->  Seq Scan on big_table (actual rows=1000.00 loops=1)
           Filter: (category = 'cat_5'::text)
           Rows Removed by Filter: 9000
           Buffers: shared hit=64 dirtied=1 written=1
   Execution Time: 1.072 ms (100.0%)
 
 Nested Statements Summary:
   Total: 1 statements, max depth 1
   Total Execution Time: 1.186 ms
   Total Nested Time: 1.072 ms (90.4% of total time)
   Slowest Statement: #1 (1.072 ms, 100.0%)
(22 rows)


--- Function B: Overhead-heavy (trivial SQL, lots of PL/pgSQL work) ---

CREATE FUNCTION
                     QUERY PLAN                     
----------------------------------------------------
 Result (actual rows=1.00 loops=1)
   Buffers: shared hit=9
 Planning Time: 0.004 ms
 Execution Time: 0.067 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT 1
   Result (actual rows=1.00 loops=1)
   Execution Time: 0.001 ms (100.0%)
 
 Nested Statements Summary:
   Total: 1 statements, max depth 1
   Total Execution Time: 0.067 ms
   Total Nested Time: 0.001 ms (1.2% of total time)
   Slowest Statement: #1 (0.001 ms, 100.0%)
(17 rows)


Compare the "Total Nested Time (X% of total time)" between the two:
  - sql_heavy_func: high % → SQL is the bottleneck
  - overhead_heavy_func: low % → PL/pgSQL overhead is the bottleneck

DROP FUNCTION
DROP FUNCTION
DROP TABLE

============================================================================
TEST 37: Multiple Triggers on Separate Tables
============================================================================

Purpose: Verify trigger detection works correctly when a function
         touches multiple tables, each with its own trigger.

What this tests:
  - Triggers on different tables are all detected
  - Total Trigger Time accumulates across all trigger-fired statements
  - Summary correctly counts all trigger-fired vs direct statements
  - Per-statement percentages only apply to level-1 direct statements

psql:comprehensive_nested_statements_test_v4.sql:1420: NOTICE:  table "mt_orders" does not exist, skipping
DROP TABLE
psql:comprehensive_nested_statements_test_v4.sql:1421: NOTICE:  table "mt_inventory" does not exist, skipping
DROP TABLE
psql:comprehensive_nested_statements_test_v4.sql:1422: NOTICE:  table "mt_audit" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
INSERT 0 2
CREATE FUNCTION
CREATE TRIGGER
CREATE FUNCTION
CREATE TRIGGER
CREATE FUNCTION
Expected:
  #1 (level 2, trigger): INSERT INTO mt_audit — from orders trigger
  #2 (level 1): INSERT INTO mt_orders — direct
  #3 (level 2, trigger): INSERT INTO mt_audit — from inventory trigger
  #4 (level 1): UPDATE mt_inventory — direct
  #5 (level 1): SELECT COUNT(*) — direct

Summary: 5 statements (3 direct, 2 trigger-fired)
Total Trigger Time accumulates both trigger statements

                                        QUERY PLAN                                         
-------------------------------------------------------------------------------------------
 Result (actual time=2.131..2.132 rows=1.00 loops=1)
   Buffers: shared hit=87 dirtied=2 written=2
 Planning Time: 0.010 ms
 Execution Time: 2.137 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 2, trigger):
   Query Text: INSERT INTO mt_audit VALUES ('order: ' || NEW.item || ' x' || NEW.qty)
   Insert on mt_audit (actual time=0.405..0.405 rows=0.00 loops=1)
     Buffers: shared dirtied=1 written=1
     ->  Result (actual time=0.000..0.000 rows=1.00 loops=1)
   Execution Time: 0.405 ms
 
   Nested Statement #2 (level 1):
   Query Text: INSERT INTO mt_orders VALUES (1, p_item, p_qty)
   Insert on mt_orders (actual time=0.430..0.430 rows=0.00 loops=1)
     Buffers: shared dirtied=1 written=1
     ->  Result (actual time=0.001..0.001 rows=1.00 loops=1)
   Trigger mt_orders_audit: time=0.561 calls=1
   Execution Time: 0.993 ms (85.9%)
 
   Nested Statement #3 (level 2, trigger):
   Query Text: INSERT INTO mt_audit VALUES ('stock: ' || NEW.item || ' now ' || NEW.stock)
   Insert on mt_audit (actual time=0.003..0.003 rows=0.00 loops=1)
     Buffers: shared hit=1
     ->  Result (actual time=0.000..0.000 rows=1.00 loops=1)
   Execution Time: 0.004 ms
 
   Nested Statement #4 (level 1):
   Query Text: UPDATE mt_inventory SET stock = stock - p_qty WHERE item = p_item
   Update on mt_inventory (actual time=0.020..0.020 rows=0.00 loops=1)
     Buffers: shared hit=4
     ->  Seq Scan on mt_inventory (actual time=0.009..0.009 rows=1.00 loops=1)
           Filter: (item = 'widget'::text)
           Rows Removed by Filter: 1
           Buffers: shared hit=1
   Trigger mt_inventory_audit: time=0.137 calls=1
   Execution Time: 0.158 ms (13.6%)
 
   Nested Statement #5 (level 1):
   Query Text: SELECT COUNT(*) FROM mt_audit
   Aggregate (actual time=0.004..0.005 rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on mt_audit (actual time=0.002..0.003 rows=2.00 loops=1)
           Buffers: shared hit=1
   Execution Time: 0.005 ms (0.4%)
 
 Nested Statements Summary:
   Total: 5 statements (3 direct, 2 trigger-fired), max depth 2
   Total Execution Time: 2.137 ms
   Total Nested Time: 1.155 ms (54.1% of total time)
   Slowest Statement: #2 (0.993 ms, 85.9%)
(53 rows)

DROP FUNCTION
DROP TRIGGER
DROP FUNCTION
DROP TRIGGER
DROP FUNCTION
DROP TABLE

============================================================================
TEST 38: Direct DML with Triggers (No Function Wrapper)
============================================================================

Purpose: NESTED_STATEMENTS is not just for functions — it reveals
         trigger activity on any DML statement. This helps DBAs
         understand why an INSERT/UPDATE/DELETE is slow when triggers
         are involved, without needing to wrap anything in a function.

What this tests:
  - Direct UPDATE with BEFORE trigger (validation + logging)
  - Direct UPDATE with AFTER trigger (audit logging)
  - Cascading triggers (trigger inserts into table with its own trigger)
  - Both BEFORE and AFTER triggers detected via GetMyTriggerDepth()

psql:comprehensive_nested_statements_test_v4.sql:1503: NOTICE:  table "emp" does not exist, skipping
DROP TABLE
psql:comprehensive_nested_statements_test_v4.sql:1504: NOTICE:  table "emp_audit" does not exist, skipping
DROP TABLE
psql:comprehensive_nested_statements_test_v4.sql:1505: NOTICE:  table "notifications" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
INSERT 0 3
CREATE FUNCTION
CREATE TRIGGER
CREATE FUNCTION
CREATE TRIGGER
CREATE FUNCTION
CREATE TRIGGER
--- Part A: Accepted UPDATE (BEFORE passes, AFTER fires) ---
Expected: All statements annotated as (trigger)
  - AFTER trigger on emp_audit fires cascading trigger on notifications

                                            QUERY PLAN                                             
---------------------------------------------------------------------------------------------------
 Update on emp (actual time=0.079..0.079 rows=0.00 loops=1)
   Buffers: shared hit=12
   ->  Index Scan using emp_pkey on emp (actual time=0.006..0.006 rows=1.00 loops=1)
         Index Cond: (id = 1)
         Index Searches: 1
         Buffers: shared hit=2
 Planning:
   Buffers: shared hit=4
 Planning Time: 0.425 ms
 Trigger emp_audit_trigger: time=0.912 calls=1
 Trigger emp_validate: time=0.058 calls=1
 Execution Time: 1.015 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 2, trigger):
   Query Text: INSERT INTO notifications VALUES ('audit: ' || NEW.action || ' emp ' || NEW.emp_id)
   Insert on notifications (actual time=0.319..0.319 rows=0.00 loops=1)
     Buffers: shared dirtied=1 written=1
     ->  Result (actual time=0.000..0.000 rows=1.00 loops=1)
   Execution Time: 0.319 ms
 
   Nested Statement #2 (level 1, trigger):
   Query Text: INSERT INTO emp_audit VALUES (NEW.id, 'ACCEPTED', OLD.salary, NEW.salary)
   Insert on emp_audit (actual time=0.370..0.370 rows=0.00 loops=1)
     Buffers: shared dirtied=1 written=1
     ->  Result (actual time=0.001..0.001 rows=1.00 loops=1)
   Trigger audit_notify_trigger: time=0.468 calls=1
   Execution Time: 0.839 ms
 
 Nested Statements Summary:
   Total: 2 statements (0 direct, 2 trigger-fired), max depth 2
   Total Execution Time: 1.015 ms
   Total Trigger Time: 0.839 ms
(34 rows)


--- Part B: Rejected UPDATE (BEFORE trigger rejects, logs, no AFTER) ---
Expected: BEFORE trigger INSERT into emp_audit detected as (trigger)
  - Cascading notification trigger also fires
  - No AFTER trigger (update was rejected by BEFORE returning NULL)

                                            QUERY PLAN                                             
---------------------------------------------------------------------------------------------------
 Update on emp (actual time=0.099..0.099 rows=0.00 loops=1)
   Buffers: shared hit=7
   ->  Index Scan using emp_pkey on emp (actual time=0.005..0.005 rows=1.00 loops=1)
         Index Cond: (id = 2)
         Index Searches: 1
         Buffers: shared hit=2
 Planning Time: 0.022 ms
 Trigger emp_validate: time=0.088 calls=1
 Execution Time: 0.107 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 2, trigger):
   Query Text: INSERT INTO notifications VALUES ('audit: ' || NEW.action || ' emp ' || NEW.emp_id)
   Insert on notifications (actual time=0.002..0.002 rows=0.00 loops=1)
     Buffers: shared hit=1
     ->  Result (actual time=0.000..0.000 rows=1.00 loops=1)
   Execution Time: 0.002 ms
 
   Nested Statement #2 (level 1, trigger):
   Query Text: INSERT INTO emp_audit VALUES (NEW.id, 'REJECTED', OLD.salary, NEW.salary)
   Insert on emp_audit (actual time=0.004..0.004 rows=0.00 loops=1)
     Buffers: shared hit=1
     ->  Result (actual time=0.000..0.001 rows=1.00 loops=1)
   Trigger audit_notify_trigger: time=0.041 calls=1
   Execution Time: 0.045 ms
 
 Nested Statements Summary:
   Total: 2 statements (0 direct, 2 trigger-fired), max depth 2
   Total Execution Time: 0.107 ms
   Total Trigger Time: 0.045 ms
(31 rows)

DROP TABLE
DROP TABLE
DROP TABLE
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION

============================================================================
TEST 39: BEFORE and AFTER Triggers in Function Context
============================================================================

Purpose: Verify trigger detection works correctly when DML with
         BEFORE and AFTER triggers is executed inside a function.
         Both trigger types should be annotated, and direct function
         statements should NOT be annotated.

What this tests:
  - Function executes INSERT (fires BEFORE + AFTER triggers)
  - Function also executes a plain SELECT (not a trigger)
  - Trigger statements: annotated with (trigger), no percentage
  - Direct level-1 statements: show percentage, no (trigger) annotation
  - Summary correctly separates direct vs trigger-fired counts

psql:comprehensive_nested_statements_test_v4.sql:1596: NOTICE:  table "t39_data" does not exist, skipping
DROP TABLE
psql:comprehensive_nested_statements_test_v4.sql:1597: NOTICE:  table "t39_log" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE TABLE
CREATE FUNCTION
CREATE TRIGGER
CREATE FUNCTION
CREATE TRIGGER
CREATE FUNCTION
Expected:
  - BEFORE trigger INSERTs: (trigger) annotation
  - AFTER trigger INSERTs: (trigger) annotation
  - INSERT INTO t39_data: direct (level 1)
  - SELECT COUNT(*): direct (level 1) with percentage
  - Summary: mix of direct and trigger-fired

                                        QUERY PLAN                                        
------------------------------------------------------------------------------------------
 Result (actual time=1.978..1.978 rows=1.00 loops=1)
   Buffers: shared hit=65 read=1 dirtied=4 written=3
 Planning Time: 0.017 ms
 Execution Time: 1.986 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 2, trigger):
   Query Text: INSERT INTO t39_log VALUES ('before: setting timestamp for id=' || NEW.id)
   Insert on t39_log (actual time=0.449..0.450 rows=0.00 loops=1)
     Buffers: shared dirtied=1 written=1
     ->  Result (actual time=0.000..0.000 rows=1.00 loops=1)
   Execution Time: 0.450 ms
 
   Nested Statement #2 (level 2, trigger):
   Query Text: INSERT INTO t39_log VALUES ('after: row inserted id=' || NEW.id)
   Insert on t39_log (actual time=0.003..0.003 rows=0.00 loops=1)
     Buffers: shared hit=1
     ->  Result (actual time=0.000..0.000 rows=1.00 loops=1)
   Execution Time: 0.003 ms
 
   Nested Statement #3 (level 1):
   Query Text: INSERT INTO t39_data VALUES (1, 'hello', NULL)
   Insert on t39_data (actual time=1.634..1.634 rows=0.00 loops=1)
     Buffers: shared hit=35 read=1 dirtied=4 written=3
     ->  Result (actual time=0.001..0.001 rows=1.00 loops=1)
   Trigger t39_after: time=0.105 calls=1
   Trigger t39_before: time=0.577 calls=1
   Execution Time: 1.741 ms (96.2%)
 
   Nested Statement #4 (level 2, trigger):
   Query Text: INSERT INTO t39_log VALUES ('before: setting timestamp for id=' || NEW.id)
   Insert on t39_log (actual time=0.002..0.002 rows=0.00 loops=1)
     Buffers: shared hit=1
     ->  Result (actual time=0.000..0.000 rows=1.00 loops=1)
   Execution Time: 0.002 ms
 
   Nested Statement #5 (level 2, trigger):
   Query Text: INSERT INTO t39_log VALUES ('after: row inserted id=' || NEW.id)
   Insert on t39_log (actual time=0.001..0.001 rows=0.00 loops=1)
     Buffers: shared hit=1
     ->  Result (actual time=0.000..0.000 rows=1.00 loops=1)
   Execution Time: 0.002 ms
 
   Nested Statement #6 (level 1):
   Query Text: INSERT INTO t39_data VALUES (2, 'world', NULL)
   Insert on t39_data (actual time=0.038..0.038 rows=0.00 loops=1)
     Buffers: shared hit=4
     ->  Result (actual time=0.000..0.000 rows=1.00 loops=1)
   Trigger t39_after: time=0.023 calls=1
   Trigger t39_before: time=0.032 calls=1
   Execution Time: 0.061 ms (3.4%)
 
   Nested Statement #7 (level 1):
   Query Text: SELECT COUNT(*)          FROM t39_log
   Aggregate (actual time=0.007..0.007 rows=1.00 loops=1)
     Buffers: shared hit=1
     ->  Seq Scan on t39_log (actual time=0.005..0.005 rows=4.00 loops=1)
           Buffers: shared hit=1
   Execution Time: 0.008 ms (0.4%)
 
 Nested Statements Summary:
   Total: 7 statements (3 direct, 4 trigger-fired), max depth 2
   Total Execution Time: 1.986 ms
   Total Nested Time: 1.809 ms (91.1% of total time)
   Slowest Statement: #3 (1.741 ms, 96.2%)
(66 rows)

DROP TABLE
DROP TABLE
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION

============================================================================
TEST 40: Query Identifier Integration (pg_stat_statements)
============================================================================

Purpose: When VERBOSE and compute_query_id are enabled, each nested
         statement shows its Query Identifier. This allows users to
         correlate nested plans with pg_stat_statements entries.

What this tests:
  - Each nested statement shows Query Identifier with VERBOSE
  - Repeated queries share the same Query Identifier
  - Trigger-fired statements have their own Query Identifier
  - Users can look up any nested query in pg_stat_statements

SET
psql:comprehensive_nested_statements_test_v4.sql:1675: NOTICE:  table "qid_orders" does not exist, skipping
DROP TABLE
psql:comprehensive_nested_statements_test_v4.sql:1676: NOTICE:  table "qid_audit" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE TABLE
INSERT 0 2
CREATE FUNCTION
CREATE TRIGGER
CREATE FUNCTION
CREATE FUNCTION
Expected: Each nested statement shows Query Identifier.
Repeated queries (UPDATE, trigger INSERT, PERFORM) share the same ID.

                                                 QUERY PLAN                                                 
------------------------------------------------------------------------------------------------------------
 Result (actual time=2.507..2.507 rows=1.00 loops=1)
   Output: qid_process_orders()
   Buffers: shared hit=135 dirtied=1 written=1
 Query Identifier: -7380725256259468906
 Planning Time: 0.014 ms
 Execution Time: 2.514 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT COUNT(*)          FROM qid_orders
   Aggregate (actual time=0.013..0.013 rows=1.00 loops=1)
     Output: count(*)
     Buffers: shared hit=1
     ->  Seq Scan on public.qid_orders (actual time=0.010..0.010 rows=2.00 loops=1)
           Output: id, item, total
           Buffers: shared hit=1
   Query Identifier: 213668903401070912
   Execution Time: 0.014 ms (1.0%)
 
   Nested Statement #2 (level 3, trigger):
   Query Text: INSERT INTO qid_audit VALUES (NEW.id, TG_OP)
   Insert on public.qid_audit (actual time=0.900..0.900 rows=0.00 loops=1)
     Buffers: shared dirtied=1 written=1
     ->  Result (actual time=0.001..0.001 rows=1.00 loops=1)
           Output: 1, 'UPDATE'::text
   Query Identifier: 461021655627114973
   Execution Time: 0.900 ms
 
   Nested Statement #3 (level 2):
   Query Text: UPDATE qid_orders SET total = total * (1 - p_pct/100) WHERE id = p_id
   Update on public.qid_orders (actual time=0.021..0.021 rows=0.00 loops=1)
     Buffers: shared hit=5
     ->  Index Scan using qid_orders_pkey on public.qid_orders (actual time=0.005..0.005 rows=1.00 loops=1)
           Output: (total * 0.90000000000000000000), ctid
           Index Cond: (qid_orders.id = 1)
           Index Searches: 1
           Buffers: shared hit=2
   Query Identifier: -4236462531438235649
   Trigger qid_audit_trig: time=0.996 calls=1
   Execution Time: 1.018 ms
 
   Nested Statement #4 (level 1):
   Query Text: SELECT qid_apply_discount(1, 10)
   Result (actual time=1.211..1.211 rows=1.00 loops=1)
     Output: qid_apply_discount(1, '10'::numeric)
     Buffers: shared hit=96 dirtied=1 written=1
   Query Identifier: -8778528588607211830
   Execution Time: 1.212 ms (84.8%)
 
   Nested Statement #5 (level 3, trigger):
   Query Text: INSERT INTO qid_audit VALUES (NEW.id, TG_OP)
   Insert on public.qid_audit (actual time=0.003..0.003 rows=0.00 loops=1)
     Buffers: shared hit=1
     ->  Result (actual time=0.000..0.000 rows=1.00 loops=1)
           Output: 2, 'UPDATE'::text
   Query Identifier: 461021655627114973
   Execution Time: 0.004 ms
 
   Nested Statement #6 (level 2):
   Query Text: UPDATE qid_orders SET total = total * (1 - p_pct/100) WHERE id = p_id
   Update on public.qid_orders (actual time=0.039..0.039 rows=0.00 loops=1)
     Buffers: shared hit=5
     ->  Index Scan using qid_orders_pkey on public.qid_orders (actual time=0.013..0.014 rows=1.00 loops=1)
           Output: (total * 0.80000000000000000000), ctid
           Index Cond: (qid_orders.id = 2)
           Index Searches: 1
           Buffers: shared hit=2
   Query Identifier: -4236462531438235649
   Trigger qid_audit_trig: time=0.071 calls=1
   Execution Time: 0.111 ms
 
   Nested Statement #7 (level 1):
   Query Text: SELECT qid_apply_discount(2, 20)
   Result (actual time=0.202..0.202 rows=1.00 loops=1)
     Output: qid_apply_discount(2, '20'::numeric)
     Buffers: shared hit=8
   Query Identifier: -8778528588607211830
   Execution Time: 0.203 ms (14.2%)
 
 Nested Statements Summary:
   Total: 7 statements (5 direct, 2 trigger-fired), max depth 3
   Total Execution Time: 2.514 ms
   Total Nested Time: 1.429 ms (56.8% of total time)
   Slowest Statement: #4 (1.212 ms, 84.8%)
(85 rows)

RESET
DROP TABLE
DROP TABLE
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION

============================================================================
TEST 41: Level-1 Only Counting — No Double-Counting
============================================================================

Purpose: Demonstrate that Total Nested Time sums only level-1 statements.
         Deeper levels show absolute time but are NOT added to the total,
         because their time is already included in their level-1 parent.

Setup: 3-level PERFORM chain, each level does pg_sleep(0.01) = ~10ms.
  - Level 1: own sleep (10ms) + PERFORM level2 (~20ms) = ~30ms
  - Level 2: own sleep (10ms) + PERFORM level3 (~10ms) = ~20ms
  - Level 3: own sleep (10ms) = ~10ms

Key indicators:
  - Level-1 statements show percentage
  - Level-2 and level-3 statements show time only (no %)
  - Total Nested Time ≤ Total Execution Time (always)

CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
                       QUERY PLAN                        
---------------------------------------------------------
 Result (actual time=33.464..33.464 rows=1.00 loops=1)
   Buffers: shared hit=18
 Planning Time: 0.016 ms
 Execution Time: 33.471 ms
 
 Nested Plans:
 
   Nested Statement #1 (level 1):
   Query Text: SELECT pg_sleep(0.01)
   Result (actual time=11.031..11.032 rows=1.00 loops=1)
   Execution Time: 11.048 ms (33.2%)
 
   Nested Statement #2 (level 2):
   Query Text: SELECT pg_sleep(0.01)
   Result (actual time=11.020..11.020 rows=1.00 loops=1)
   Execution Time: 11.025 ms
 
   Nested Statement #3 (level 3):
   Query Text: SELECT pg_sleep(0.01)
   Result (actual time=11.011..11.012 rows=1.00 loops=1)
   Execution Time: 11.015 ms
 
   Nested Statement #4 (level 2):
   Query Text: SELECT dc_level3()
   Result (actual time=11.063..11.063 rows=1.00 loops=1)
   Execution Time: 11.063 ms
 
   Nested Statement #5 (level 1):
   Query Text: SELECT dc_level2()
   Result (actual time=22.250..22.250 rows=1.00 loops=1)
     Buffers: shared hit=6
   Execution Time: 22.251 ms (66.8%)
 
 Nested Statements Summary:
   Total: 5 statements, max depth 3
   Total Execution Time: 33.471 ms
   Total Nested Time: 33.299 ms (99.5% of total time)
   Slowest Statement: #5 (22.251 ms, 66.8%)
(38 rows)

DROP FUNCTION
DROP FUNCTION
DROP FUNCTION

DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP TRIGGER
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP TRIGGER
DROP FUNCTION
DROP TABLE
DROP TABLE
DROP TABLE
DROP TABLE
DROP TABLE
DROP TABLE
DROP TABLE
DROP TABLE
DROP TABLE
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP FUNCTION
DROP TABLE
DROP TABLE
============================================================================
Test Suite Complete — 41 tests
============================================================================