SEPURI-SAI-KRISHNA commented on issue #12601:
URL: https://github.com/apache/seatunnel/issues/12601#issuecomment-5982709033

   @dybyte already pointed at `TypeRegistry` L85 as the origin of the bare type 
name, so this just follows that thread further, for the question @SEZ9 and 
@DanielLeens both raised about whether the namespace can reach the sink at all.
   
   Short version: it is available, but dropped in three separate places, so 
recovering it is a registry change rather than a DDL-quoting change.
   
   All in 
`connector-cdc-postgres/.../io/debezium/connector/postgresql/TypeRegistry.java` 
on `dev`:
   
   **1. The query already joins `pg_namespace`, it just never selects it.** 
`SQL_TYPES` (L84-91) is already `JOIN pg_catalog.pg_namespace n ON 
(t.typnamespace = n.oid)`, with `n.nspname` used only in `WHERE n.nspname != 
'pg_toast'`. So the namespace is one selected column away.
   
   **2. The cache cannot hold two same-named types.** `addType` (L151) is 
`nameToType.put(type.getName(), type)`, keyed on the bare `t.typname`. Two 
types with the same name in different schemas collide and the later load wins.
   
   **3. The name lookup throws away a schema it is handed.** `get(String name)` 
(L196-215):
   
   ```java
   String[] parts = name.split("\\.");
   if (parts.length > 1) {
       name = parts[1];
   }
   PostgresType r = nameToType.get(name);
   ```
   
   So a caller that already knows `inv.mood` loses `inv` before the lookup.
   
   One more, independent of #12606. `SQL_NAME_LOOKUP` is `SQL_TYPES + " AND 
t.typname = ?"`, no namespace predicate and no `ORDER BY`, and `loadType` 
(L370-379) returns the first row and discards the rest, so with a name in 
several schemas the winner is whatever the plan returns. The sibling query at 
L397 treats that case deliberately, using `SELECT DISTINCT ON (typname) ... 
ORDER BY typname, sp.r, pg_type.oid` and a comment about types existing in 
multiple schemas.
   
   Checked against the compiled class rather than only the source, since this 
class also ships in the `debezium-connector-postgres` jar: I built the module 
and read the strings out of `target/classes`. The compiled query has the join 
and no `nspname` in its select list. This copy was also re-synced during the 
Debezium 1.9.8 bump in #6740.
   
   So carrying the namespace through is reachable, but it touches the cache 
keying and the name lookup, not only the generated DDL. I have not run this 
against a live Postgres, so the multi-schema collision is read from the code 
rather than reproduced. Happy to open a separate issue for it.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to