From 0042f51ce5ec437b875980a6c31ff0a5cdbe5bbb Mon Sep 17 00:00:00 2001 From: Zhibai Song Date: Mon, 27 Nov 2023 20:04:29 -0800 Subject: [PATCH] Fix the issue that PIVOT execution not return row affected line (#2071) Previous our implement of PIVOT has a issue that it didn't return the row affected line as result, this fix has fixed the bug. Task: BABEL-284 Signed-off-by: Zhibai Song --- contrib/babelfishpg_tsql/src/pl_exec.c | 5 ++--- test/JDBC/expected/pivot-vu-verify.out | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/contrib/babelfishpg_tsql/src/pl_exec.c b/contrib/babelfishpg_tsql/src/pl_exec.c index da7ba1b5e1..28d4a7890e 100644 --- a/contrib/babelfishpg_tsql/src/pl_exec.c +++ b/contrib/babelfishpg_tsql/src/pl_exec.c @@ -5062,11 +5062,10 @@ exec_stmt_execsql(PLtsql_execstate *estate, /* If query affects IDENTITY_INSERT relation then update sequence */ pltsql_update_identity_insert_sequence(expr); - /* If current plan constains a pivot operator, we remove the plan */ + /* If current plan constains a pivot operator, we set it as execute oneshot */ if (is_pivot) { - SPI_freeplan(expr->plan); - expr->plan = NULL; + expr->plan->oneshot = true; } /* Expect SPI_tuptable to be NULL else complain */ diff --git a/test/JDBC/expected/pivot-vu-verify.out b/test/JDBC/expected/pivot-vu-verify.out index 1e9abd20dd..2618174b21 100644 --- a/test/JDBC/expected/pivot-vu-verify.out +++ b/test/JDBC/expected/pivot-vu-verify.out @@ -738,6 +738,8 @@ PIVOT ( ) AS pvt; SELECT TOP 10 * FROM pivot_insert_into ORDER by 1, 2; GO +~~ROW COUNT: 197~~ + ~~START~~ int#!#int#!#int#!#int#!#int#!#int#!#int 1200#!#200#!#0#!#0#!#0#!#0#!#0