Skip to content

Fixes 3962: Implementation of Returning#4206

Open
leonschenk wants to merge 10 commits intoh2database:masterfrom
leonschenk:feature/3962
Open

Fixes 3962: Implementation of Returning#4206
leonschenk wants to merge 10 commits intoh2database:masterfrom
leonschenk:feature/3962

Conversation

@leonschenk
Copy link

  • DeltaChangeCollector:
    -- Purpose is to collect changes from a DataChangeStatement
    -- Used for GeneratedKeys, DeltaTable (new/old/final table), Returning, setting LastIdentity

  • Returning
    -- Implementation to support Returning query using new DataChangeCollector

  • Postgresql server
    -- Newer versions are supported
    -- Implementations (noop) of the required postgresql queries for the newer versions.

@leonschenk leonschenk changed the title Fixes 3962 Fixes 3962: Implementation of Returning Mar 2, 2025
@leonschenk
Copy link
Author

#3962

@katzyn
Copy link
Contributor

katzyn commented Mar 2, 2025

Thank you for your contribution!

Unfortunately, it is too intrusive and contains random unrelated changes, including features, that we don't want to support on our side, such as non-standard operators. They create a lot of unnecessary complexity. H2 is not an emulator of other database systems and cannot have all their crazy features.

Actually it will be much better to write and contribute an implementation of standard data change delta tables to PostgreSQL. They are more powerful than RETURING from PostgreSQL.

If you can't do it for some reason, please implement only one feature per pull request and discuss what you add with community before writing an actual implementation.

For RETURNING clause it will be better to translate this syntax to SELECT … FROM FINAL TABLE (…) in the parser instead of messing with various parts of H2. You don't need to generate a new SQL here, you can simply construct a org.h2.command.query.Select with these expressions and a org.h2.table.DataChangeDeltaTable with original DML command. It should be relatively simple and it will not disturb code base of H2 too much for this compatibility-only feature. Of course, it must be restricted to PostgreSQL compatibility mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants