Re: SQL:2011 application time

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: Paul Jungwirth <pj@illuminatedcomputing.com>
Cc: jian he <jian.universality@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-12-04T11:15:40Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Rename gist stratnum support function

  2. Remove support for temporal RESTRICT foreign keys

  3. Cache NO ACTION foreign keys separately from RESTRICT foreign keys

  4. Fix NO ACTION temporal foreign keys when the referenced endpoints change

  5. Improve whitespace in without_overlaps test

  6. Tests for logical replication with temporal keys

  7. Support for GiST in get_equal_strategy_number()

  8. Make the conditions in IsIndexUsableForReplicaIdentityFull() more explicit

  9. Replace get_equal_strategy_number_for_am() by get_equal_strategy_number()

  10. Improve internal logical replication error for missing equality strategy

  11. Simplify IsIndexUsableForReplicaIdentityFull()

  12. Fix ALTER TABLE / REPLICA IDENTITY for temporal tables

  13. doc: Update pg_constraint.conexclop docs for WITHOUT OVERLAPS

  14. doc: Add PERIOD to ALTER TABLE reference docs

  15. doc: Add WITHOUT OVERLAPS to ALTER TABLE reference docs

  16. Add temporal FOREIGN KEY contraints

  17. Add temporal PRIMARY KEY and UNIQUE constraints

  18. Add stratnum GiST support function

  19. Avoid crashing when a JIT-inlined backend function throws an error.

  20. Revert temporal primary keys and foreign keys

  21. Fix ON CONFLICT DO NOTHING/UPDATE for temporal indexes

  22. Add test for REPLICA IDENTITY with a temporal key

  23. Use half-open interval notation in without_overlaps tests

  24. Use daterange and YMD in without_overlaps tests instead of tsrange.

  25. Rename pg_constraint.conwithoutoverlaps to conperiod

  26. Fix comment on gist_stratnum_btree

  27. Add missing TAP test name

  28. Improve error handling of HMAC computations

  29. Rename functions to avoid future conflicts

Attachments

On 26.11.24 13:18, Peter Eisentraut wrote:
> I think this is the right idea, but after digging around a bit more, I 
> think more could/should be done.
> 
> After these changes, the difference between 
> get_equal_strategy_number_for_am() and get_equal_strategy_number() is 
> kind of pointless.  We should really just use 
> get_equal_strategy_number() for all purposes.
> 
> But then you have the problem that IsIndexUsableForReplicaIdentityFull() 
> doesn't have the opclass IDs available in the IndexInfo structure.  You 
> appear to have worked around that by writing
> 
> +   if (get_equal_strategy_number_for_am(indexInfo->ii_Am, InvalidOid) 
> == InvalidStrategy)
> 
> which I suppose will have the same ultimate result as before that patch, 
> but it seems kind of incomplete.
> 
> I figure this could all be simpler if 
> IsIndexUsableForReplicaIdentityFull() used the index relcache entry 
> directly instead of going the detour through IndexInfo.  Then we have 
> all the information available, and this should ultimately all work 
> properly for suitable GiST indexes as well.
> 
> I have attached three patches that show how that could be done.  (This 
> would work in conjunction with your new tests.  (Although now we could 
> also test GiST with replica identity full?))
> 
> The comment block for IsIndexUsableForReplicaIdentityFull() makes a 
> bunch of claims that are not all explicitly supported by the code.  The 
> code doesn't actually check the AM, this is all only done indirectly via 
> other checks.  The second point (about tuples_equal()) appears to be 
> slightly wrong, because while you need an equals operator from the type 
> cache, that shouldn't prevent you from also using a different index AM 
> than btree or hash for the replica identity index.  And the stuff about 
> amgettuple, if that is important, why is it only checked for assert builds?

I did some more work on this approach, with the attached patches 
resulting.  This is essentially what I'm describing above, which in turn 
is a variation of your patch 
v45-0001-Fix-logical-replication-for-temporal-tables.patch, with your 
tests added at the end.

I also did some more work on IsIndexUsableForReplicaIdentityFull() to 
make the various claims in the comments reflected by actual code.  With 
all of this, it can now also use gist indexes on the subscriber side in 
cases of REPLICA IDENTITY FULL.  This isn't immediately visible in the 
tests, but you can see that the tests are using it internally by adding 
debugging elogs or something like that.

Altogether, I think this fixes the original problem of temporal keys not 
being handled properly in logical replication subscribers, and it makes 
things less hardcoded around btree and hash in general.

Please review.