…source
The RDS PostgreSQL source concatenated schema-discovered
database.schema.table names into CREATE PUBLICATION without delimiting
them. PostgreSQL folds undelimited identifiers to lower case and rejects
characters such as hyphens, so any name requiring a delimited identifier
failed publication creation and aborted pipeline initialization.
Delimit each part of the name when building the statement. The names come
from JDBC metadata and already carry the true stored case, so quoting
them makes the lookup correct rather than merely legal. The generated
publication name is intentionally left undelimited so that create and
drop stay symmetric across an upgrade.
Signed-off-by: Ryan Gray <ryan@chipply.com>
Description
The RDS PostgreSQL source builds
CREATE PUBLICATION … FOR TABLE …by concatenating schema-discovereddatabase.schema.tablenames without delimiting them. PostgreSQL folds undelimited identifiers to lower case and rejects characters such as hyphens, so any name that requires a delimited identifier makes publication creation fail and aborts pipeline initialization:This change adds
quoteFullTableName/quoteIdentifierhelpers and delimits each part of the name when building the statement:Both forms above were run against PostgreSQL 17.10 to confirm the unquoted statements fail and the delimited one succeeds.
Delimiting is safe rather than merely tolerable here: the names originate from JDBC metadata (
TABLE_SCHEM/TABLE_NAME) viaPostgresSchemaManager.getTableNames, so they already carry the true stored case. For names that need no quoting the change is a semantic no-op, covered by a regression test.Three things this deliberately does not change:
CREATE PUBLICATIONandDROP PUBLICATION IF EXISTS. It is generated by Data Prepper and recorded in the pipeline state store; delimiting it would change how a publication created by an earlier version gets dropped after an upgrade — a mixed-case pipeline name would fold on create but not on drop, leaking the publication. Keeping both sides undelimited keeps create/drop symmetric.databasequalifier is kept. It is redundant — PostgreSQL only accepts a catalog qualifier equal to the current database — but dropping it is a separate behavior change and does not belong in a bug fix.MySqlSchemaManagerhas its own (backtick) quoting considerations; a separate concern.One pre-existing limitation is worth flagging but is out of scope: several methods in this class split a fully qualified name on
"\\.", which misparses identifiers containing a literal dot. Noted in the issue as a follow-up.Tests
Updated (the two existing assertions hard-coded the undelimited SQL):
test_createLogicalReplicationSlot_creates_slot_if_not_existstest_createLogicalReplicationSlot_skip_creation_if_slot_existsAdded:
test_createLogicalReplicationSlot_delimits_identifiers_that_require_quotingtest_quoteFullTableName_delimits_every_part_and_preserves_casetest_quoteFullTableName_when_name_needs_no_quoting_then_only_adds_delimiterstest_quoteIdentifier_escapes_embedded_double_quote"doubled to""test_deleteLogicalReplicationSlot_successis unchanged and still passes, which is what confirms the publication-name boundary described above.:data-prepper-plugins:rds-source:checkpasses locally (spotless, checkstyle, and the module's tests — 20/20).Issues Resolved
Resolves #7077
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.