Skip to content

pgbk: specify the schema name in wal2json's add-tables#32197

Merged
espadolini merged 2 commits intomasterfrom
espadolini/pgbk-addtables-schema
Sep 20, 2023
Merged

pgbk: specify the schema name in wal2json's add-tables#32197
espadolini merged 2 commits intomasterfrom
espadolini/pgbk-addtables-schema

Conversation

@espadolini
Copy link
Copy Markdown
Contributor

@espadolini espadolini commented Sep 20, 2023

We currently run queries on the kv table with no schema qualifier, which means that we will end up using the first existing schema in the database's search_path, both when creating or updating the tables, and when using them. This can be used by database administrators to have Teleport use a schema that's not the default public schema, but the wal2json change feed was working under the assumption that the schema was always public, leading to a confusing scenario where no error is signaled, but the change feed pulls no events because it's looking for changes in public.kv when the actual table is some_other_schema.kv.

With this PR we read the schema name for the (unqualified) kv table when we open the change feed connection, and pass it to add-tables later. The string quoting strategy for the wal2json option (prepending a backslash to every character) was inspired by https://github.com/supabase/walrus/blob/aa36cf9ac8667573bc109fd62d4a57f267131b42/sql/walrus--0.1.sql#L125 .

changelog: fix: the PostgreSQL backend now handles default database schemas other than public

@espadolini espadolini added this pull request to the merge queue Sep 20, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 20, 2023
@espadolini espadolini added this pull request to the merge queue Sep 20, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 20, 2023
@espadolini espadolini added this pull request to the merge queue Sep 20, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 20, 2023
@espadolini espadolini added this pull request to the merge queue Sep 20, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 20, 2023
@espadolini espadolini added this pull request to the merge queue Sep 20, 2023
Merged via the queue into master with commit 97a8526 Sep 20, 2023
@espadolini espadolini deleted the espadolini/pgbk-addtables-schema branch September 20, 2023 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants