-
Notifications
You must be signed in to change notification settings - Fork 40
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
Initial RETURNING
implementation
#107
base: master
Are you sure you want to change the base?
Conversation
expected/17.0/extra/returning.out
Outdated
|
||
--Testcase 49: | ||
INSERT INTO "type_DATE"(col) VALUES ('2021.02.23') RETURNING col; | ||
ERROR: Failed to execute remote SQL |
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.
Could you add comment for the failed test cases below? What is your test purpose?
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.
Reverted to standard behaviour for testing data transfer of different data types. Please check again.
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.
--Testcase 47:
SELECT * FROM "type_DATE";
col
------------
2021-02-23
2021-03-08
9999-12-30
(3 rows)
--Testcase 49:
INSERT INTO "type_DATE"(col) VALUES ('2021/03/08') RETURNING col;
col
------------
2021-03-08
(1 row)
--Testcase 54:
SELECT * FROM "type_DATE";
col
------------
2021-02-23
2021-03-08
9999-12-30
2021-04-23
2021-03-09
9999-12-29
(6 rows)
Do you know why the duplicated value "2021-03-08" was not inserted?
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.
Do you know why the duplicated value "2021-03-08" was not inserted?
This seems doNothing
problem, but I did doNothing
check across our FDW and haven't found wrong logic.
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.
@lamdn1409 , I think there is some problem inside of sqliteIterateForeignScan
, because postgresIterateForeignScan
contains other very simple algorithm.
Also sqlite_make_tuple_from_result_row
sometimes have values
and nulls
not after palloc
, but always after palloc
in postgres_fdw
's make_tuple_from_result_row
. Also our SQLite FDW doesn't contain fetch_more_data
.
Hence I cannot compare SQLite FDW code with Postgres FDW example and possible optimal code structure for fetching RETURNING
data. Could you please share your thought about possible sqliteIterateForeignScan
changes for RETURNING
support?
SELECT * FROM type_JSON; | ||
--Testcase 62 | ||
DELETE FROM type_JSON RETURNING *; | ||
|
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.
According to the specification https://www.sqlite.org/lang_returning.html, could you please add more test cases regarding RETURNING to verify the following points?
INSERT/DELETE/UPDATE combine RETURNING
- RETURNING expr
- RETURNING expr1, expr2,...
- RETURNING expr AS column-alias
- RETURNING expr1 AS column-alias1, expr2 AS column-alias2,...
- The RETURNING clause does not report any additional database changes caused by foreign key constraints or triggers.
- The output order for the RETURNING rows is arbitrary and is not necessarily related to the order in which the rows were processed internally.
- 07 items of Limitations And Caveats
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.
Will TC 60 ..100 enough?
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.
Remain some points we need to verify, however, please fix all bugs of the current test. I checked the test output, some tests work not correctly.
For example, the test below returns 0 row.
--Testcase 07:
UPDATE "type_STRING" SET col = '_' || substr(col, 2) RETURNING *;
col
-----
(0 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.
@lamdn1409 , could you please diagnose if here is sqlite_store_returning_result
problems? Please refer https://github.com/mkgrgis/sqlite_fdw/blob/69a2e7221ca0f0ed9b297c00835a1352b0c4562d/sqlite_fdw.c#L5420
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.
Resolved after 2385a8e , but there are other problems with RETURNING
not for UPDATE
. Please verify if we can resolve this discussion.
Could you add description about the feature to README.md file? |
bms_make_singleton(0 - FirstLowInvalidHeapAttributeNumber); | ||
} | ||
|
||
if (withCheckOptionList != NIL) |
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.
Could you add test case to cover this condition?
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.
Is this about view after tested table https://www.postgresql.org/docs/17/sql-createview.html + https://www.postgresql.jp/document/16/html/fdw-callbacks.html#FDW-CALLBACKS-UPDATE ? Will this https://neon.tech/postgresql/postgresql-views/postgresql-views-with-check-option relevant TCs?
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, your understanding is correct.
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.
Please verify 45db11c. TCs was added to extra/insert
tests, because previously regressed functions belongs only to INSERT
support and only restored in this PR.
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.
Please don't modify the existing tests in extra/, these tests were ported from the core test (src/test/regress) of PostgreSQL. We keep them in sync with the core test for maintainability.
I checked some tests you added, there is no RETURNING clause.
Could you add test cases that satisfy the condition "col1 > 20", including RETURNING clause?
Please make sure the test cover added code.
+--Testcase 16:
+create view inserttest01_view_wco as
+select * from inserttest01 where col1 > 20
+with check option;
+--Testcase 17:
+create view inserttest01_view as
+select * from inserttest01 where col1 > 20;
+--Testcase 18: ok
+insert into inserttest01_view values(10, 50, 'uuuuu');
+--Testcase 19: no!
+insert into inserttest01_view_wco values(10, 50, 'uuuuu');
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.
@lamdn1409 , should similar TCs be placed only at returning
test in 2 TCs with and without RETURNING
?
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.
Moved to extra/returning
and reverted in 3cb5ceb , please confirm @lamdn1409.
@mkgrgis Thanks for your contribution. I'm happy to work with you to support this feature. I have some review comments, could you please check them? |
Hello, @lamdn1409 ! Thanks for interesting review! Because this was mechanical edit by |
@lamdn1409, could you please help me to do a resume about code problem? |
Yes, no problems. Now there is short sentence after 04a9ef8 |
Look like there is something in |
@lamdn1409 , look like there is some problems with regressed and deleted |
@mkgrgis INSERT/DELETE/UPDATE ... RETURNING will be pushed down, so Direct Modification mechanism is activated , please check the routine PlanDirectModify, RETURNING clause should be deparsed at this step. |
Thanks, @lamdn1409 ! I am seeing some unchanged code, not unified with |
@lamdn1409 , I have carefully read |
I have a comment #107 (comment) |
@lamdn1409 , now we have only problem for lower versions of PostgreSQL which is in not successfully tests. Some Here is log around of error
|
@lamdn1409 , please check first review comments again. I think most of them should be resolved. |
@mkgrgis I think there are differences about RETURNING implementation among postgres_fdw's versions. We often use the macro PG_VERSION_NUM to distinguish code of different versions. |
@mkgrgis OK. I'm checking them now. Then I'm gonna start 2nd review. |
Thanks for 2nd review, @lamdn1409! Let's summarise current problems:
Anything other? |
SQL
RETURNING
have been introduced in SQLite 3.35.0.I haven't noticed any special behaviour for
RETURNING
in SQLite not mapped to PostgreSQLRETURNING
behaviour.This PR made as mechanical edition according
postgres_fdw
code structures including naming conventions. This was enough for full ISO:SQLINSERT ... RETURNING
andUPDATE ... RETURNING
implementation. In case ofDELETE ... RETURNING
there are some problems and warning message was implemented.Implemented after #56