Skip to content
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

PgValue variant bypassing QValue for more efficient & correct PG<>PG mirroring #1565

Merged
merged 16 commits into from
Apr 12, 2024

Conversation

serprex
Copy link
Contributor

@serprex serprex commented Apr 2, 2024

Currently enabled by passing system = 'PG' in CREATE MIRROR command

@serprex serprex marked this pull request as draft April 2, 2024 23:56
@serprex
Copy link
Contributor Author

serprex commented Apr 2, 2024

Schema setup/changes needs to be corrected for PG<>PG & pulling in extra info like collation etc would be nice

@serprex
Copy link
Contributor Author

serprex commented Apr 4, 2024

Problem: table schema deltas don't care about numeric precision/scale

@serprex
Copy link
Contributor Author

serprex commented Apr 4, 2024

Problem: TypeModifier only used for numeric; should be used for all types such as varchar

@serprex serprex mentioned this pull request Apr 9, 2024
@serprex serprex changed the title Implement PgWal variant bypassing QValue for more efficient & correct PG<>PG mirroring PgValue variant bypassing QValue for more efficient & correct PG<>PG mirroring Apr 9, 2024
serprex added a commit that referenced this pull request Apr 9, 2024
From working on #1565
@iskakaushik
Copy link
Contributor

can you share some examples where text representation of QValue differs from PGValue?

@serprex
Copy link
Contributor Author

serprex commented Apr 9, 2024

can you share some examples where text representation of QValue differs from PGValue?

This the wrong question, we could map everything to QValueInvalid, but that won't work for schema changes / creating correct matching tables

That said, NaN/inf/-inf for doubles & numerics

Similarly, we map json/jsonb both to QValueJSON, not preserving their difference

Arrays are a whole thing

@serprex serprex force-pushed the pgvalue branch 9 times, most recently from 230638e to 182b242 Compare April 10, 2024 22:05
@serprex
Copy link
Contributor Author

serprex commented Apr 11, 2024

Thoughts/listing things which can be done as followup:

  1. types have typmod_in/typmod_out which can be used to properly propagate to destination, need to transmit string instead of raw integer value (hack: only propagate integer value for text types)
  2. not null & other constraints/indexes, complicates schema changes since not sure what to do about ingesting after a column drop if column is not null, similarly constraints may be violated by deleted columns, so constraints would have to ignore soft deleted columns
  3. process type messages in replication stream, adding to custom type map
  4. support types without binary serialization (aclitem, seg) which doesn't work with pgx CopyFrom in initial copy. Also think there's issues with custom enums. Need some fallback method
  5. TRUNCATE
  6. scripting will get all columns as text, transforms will be responsible for preserving valid text representation
  7. collations in table schema
  8. should propagate typmod in schema changes

@serprex serprex force-pushed the pgvalue branch 2 times, most recently from 92e7aa6 to b65fbc9 Compare April 11, 2024 14:16
@serprex serprex marked this pull request as ready for review April 11, 2024 14:41
@serprex serprex force-pushed the pgvalue branch 2 times, most recently from 102f116 to e35ba7d Compare April 11, 2024 17:39
@serprex serprex requested a review from heavycrystal April 11, 2024 18:13
@serprex serprex merged commit 9697aa9 into main Apr 12, 2024
13 checks passed
@serprex serprex deleted the pgvalue branch April 12, 2024 12:34
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.

3 participants