-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the issue that PIVOT execution not return row affected line #2071
Fix the issue that PIVOT execution not return row affected line #2071
Conversation
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 <[email protected]>
@@ -5059,8 +5065,7 @@ exec_stmt_execsql(PLtsql_execstate *estate, | |||
/* If current plan constains a pivot operator, we remove the plan */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment does not match the code anymore. Please update comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
if (expr->plan && expr->plan->oneshot) | ||
{ | ||
SPI_freeplan(expr->plan); | ||
expr->plan = NULL; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code isn't pivot specific anymore so any generic expr->plan->oneshot
will go here. Has that been tested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Yes, it has passed all known cases
- As for the oneshot variable, is it specific in this case ? My understand is yes, since in PG execution whether oneshot is defined at spi_prepare stage, and it'll release in plan execution ends. But our usage is define at end of execution, and free plan at the begining of query before preparing. So they don't have overlap in this case.
@@ -738,6 +738,8 @@ PIVOT ( | |||
) AS pvt; | |||
SELECT TOP 10 * FROM pivot_insert_into ORDER by 1, 2; | |||
GO | |||
~~ROW COUNT: 197~~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't TOP 10
return only 10 rows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This row count is corresponding to the insert select, and it insert 197 lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one :
INSERT INTO pivot_insert_into
SELECT ManufactureID, EmployeeID, [2] AS STORE2, [3] AS STORE3, [4] AS STORE4, [5] AS STORE5, [6] AS STORE6
FROM
(
SELECT ManufactureID, EmployeeID, ItemID, StoreID
FROM StoreReceipt
)AS srctable
PIVOT (
COUNT (ItemID)
FOR StoreID IN ([2], [3], [4], [5], [6])
) AS pvt;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TOP 10 is another statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
369ea1b
into
babelfish-for-postgresql:BABEL_3_X_DEV
…lfish-for-postgresql#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 <[email protected]>
* PIVOT Bugs Fix (#2018) Previously, Babelfish PIVOT operator has many bugs and limitation. In this PR, we fixed the bugs and blocked some unsupported edge cases. Issues Resolved 1. fixed pivot used in function/procedure will cause server restart 2. fixed table/schema name used in 'FOR (colname)' will cause server restart 3. fixed view usage in pivot stmt produce empty result 4. NULL should be the aggregate result when no row is selected(except COUNT) 5. Error message for creating view on pivot, 6. Error message when use pivot in WITH CTE 7. Error message when use join with PIVOT stmt Task: BABEL-4567, BABEL-4568, BABEL-4569, BABEL-4576, BABEL-4558, BABEL-4559 Signed-off-by: Yanjie Xu <[email protected]> * 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 <[email protected]> --------- Signed-off-by: Yanjie Xu <[email protected]> Signed-off-by: Zhibai Song <[email protected]> Co-authored-by: Zhibai Song <[email protected]>
…lfish-for-postgresql#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 <[email protected]>
…lfish-for-postgresql#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 <[email protected]>
…lfish-for-postgresql#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 <[email protected]>
…lfish-for-postgresql#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 <[email protected]>
…lfish-for-postgresql#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 <[email protected]>
…lfish-for-postgresql#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 <[email protected]>
…lfish-for-postgresql#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 <[email protected]>
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 <[email protected]>
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
Description
This fix mainly fixed this problem :
the
will be missing on previous fix, it's due to too early release of the cached plan
Check List
By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.