spqr icon indicating copy to clipboard operation
spqr copied to clipboard

Do not ignore schema of a table

Open Denchick opened this issue 11 months ago • 6 comments

When you are adding a new table, you can specify a schema. For example:

ALTER DISTRIBUTION ds1 ATTACH RELATION schema_name.table_name DISTRIBUTION KEY id;

In fact, during query/transaction routing, the schema is not taken into account. If there are tables with the same name but different schemas, they will be incorrectly routed. To fix this bug, you have to remember about search_path as well.

Denchick avatar Jan 29 '25 12:01 Denchick

"RELATION any_id DISTRIBUTION KEY distribution_key_argument_list opt_auto_increment opt_schema_name ... opt_schema_name: SCHEMA any_id { $$ = $2 } | /* EMPTY */ { $$ = "" } " schema sets in schema clause. May be it's not bug, but a language feature. Does we need setup schema by 2 ways?

"ALTER DISTRIBUTION ds1 ATTACH RELATION schema_name.table_name DISTRIBUTION KEY id;" equals "ALTER DISTRIBUTION ds1 ATTACH RELATION table_name DISTRIBUTION KEY id SCHEMA schema_name;"

is it right?

xelavopelk avatar Jun 03 '25 13:06 xelavopelk

Hi!

While both syntaxes are valid, the dot notation is more SQL-way, i think.

Deprecating the SCHEMA keyword version would simplify things and align with common practice. What do you think?

Denchick avatar Jun 20 '25 07:06 Denchick

Fixed in https://github.com/pg-sharding/spqr/pull/1298. @xelavopelk thank you for your contribution!

Denchick avatar Jul 02 '25 13:07 Denchick

No, #1298 was only the beginning of fixing problems.

Denchick avatar Jul 02 '25 14:07 Denchick

https://github.com/pg-sharding/spqr/pull/1326

Denchick avatar Jul 07 '25 08:07 Denchick

We paused https://github.com/pg-sharding/spqr/pull/1366 because the changes were becoming too dangerous for the existing installation. We had no intention of breaking backward compatibility.

Denchick avatar Aug 12 '25 09:08 Denchick