Unquoted SQL identifiers in `spec.streams` publication sync and connection pooler lookup

オープン
#3,256 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go, kubernetes, postgresql
領域
backend, databases

調査の方向性

Start with the publication sync in pkg/cluster/streams.go and SQL templates and pooler lookup in pkg/cluster/database.go; compare their identifier handling with role quoting in pkg/util/users/users.go. Check how pg_publication_tables represents identifiers and review existing tests around publication sync and pooler lookup. Done means mixed-case, hyphenated, and reserved-word names work correctly and unchanged publications are not altered on every sync.

索引モデルが issue の本文から書いたものです。

説明

When syncing publications for spec.streams, pkg/cluster/streams.go#L116-L124 formats schemaName and tableName without double quotes (fmt.Sprintf("%s.%s", schemaName, tableName)) and interpolates that list directly into CREATE PUBLICATION and ALTER PUBLICATION at pkg/cluster/database.go#L54-L55:

createPublicationSQL = `CREATE PUBLICATION "%s" FOR TABLE %s WITH (publish = 'insert, update');`
alterPublicationSQL  = `ALTER PUBLICATION "%s" SET TABLE %s;`

Even though the CRD schema (pkg/apis/acid.zalan.do/v1/crds.go#L533) allows uppercase letters and hyphens in spec.streams[].tables keys, PostgreSQL folds unquoted mixed-case identifiers (such as public.Orders) to lowercase public.orders (ERROR: relation "public.orders" does not exist) and rejects hyphenated or reserved-word table names (such as public.order-events or public.user) with SQLSTATE 42601. Putting literal quotes in the manifest key does not work either because pkg/cluster/database.go#L49-L53 reads unquoted pt.schemaname || '.' || pt.tablename from pg_publication_tables, so currentTables != tableList never matches and re-runs ALTER PUBLICATION on every sync.

Similarly, in the same file at pkg/cluster/database.go#L76-L95, connectionPoolerLookup substitutes {{.pooler_schema}} and {{.pooler_user}} without double quotes (whereas pkg/util/users/users.go#L148 and pkg/cluster/database.go#L70-L74 quote role names), causing PostgreSQL to fold mixed-case pooler role/schema names to lowercase (ERROR: role "..." does not exist) or fail with a syntax error on hyphenated names.

主要言語
Go
スター
5.3k
フォーク
1.1k
平均マージ
3日 17時間
マージ済み PR(30日)
11

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

zalando/postgres-operator のほかの issue

zalando/postgres-operator の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。