You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/05/30 02:28:56 UTC

[GitHub] [shardingsphere] sandynz opened a new issue, #18054: Question about logic table and schema name binding relation

sandynz opened a new issue, #18054:
URL: https://github.com/apache/shardingsphere/issues/18054

   ## Question
   
   Tested on master branch, proxy with PostgreSQL backend.
   
   ```
   postgres=> create database scaling_db;
   CREATE DATABASE
   postgres=> \c scaling_db
   psql (13.4, server 12.3-ShardingSphere-Proxy 5.1.2-SNAPSHOT)
   You are now connected to database "scaling_db" as user "root".
   scaling_db=> ADD RESOURCE ds_0 (
   scaling_db(>     URL="jdbc:postgresql://127.0.0.1:5432/scaling_ds_0",
   scaling_db(>     USER=postgres,
   scaling_db(>     PASSWORD=root,
   scaling_db(>     PROPERTIES("minPoolSize"=1,"maxPoolSize"=20,"idleTimeout"="60000")
   scaling_db(> ), ds_1 (
   scaling_db(>     URL="jdbc:postgresql://127.0.0.1:5432/scaling_ds_1",
   scaling_db(>     USER=postgres,
   scaling_db(>     PASSWORD=root,
   scaling_db(>     PROPERTIES("minPoolSize"=1,"maxPoolSize"=20,"idleTimeout"="60000")
   scaling_db(> );
   SUCCESS
   scaling_db=> CREATE SHARDING TABLE RULE t_order(
   scaling_db(> RESOURCES(ds_0,ds_1),
   scaling_db(> SHARDING_COLUMN=order_id,
   scaling_db(> TYPE(NAME=hash_mod,PROPERTIES("sharding-count"=4)),
   scaling_db(> KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=snowflake))
   scaling_db(> );
   SUCCESS
   scaling_db=> create schema schema1;
   CREATE SCHEMA
   scaling_db=> CREATE TABLE schema1.t_order (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
   CREATE TABLE
   scaling_db=> create schema schema2;
   CREATE SCHEMA
   scaling_db=> CREATE TABLE schema2.t_order (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
   CREATE TABLE
   scaling_db=> preview select * from schema1.t_order;
    data_source_name |                                actual_sql
   ------------------+---------------------------------------------------------------------------
    ds_0             | select * from schema1.t_order_0 UNION ALL select * from schema1.t_order_2
    ds_1             | select * from schema1.t_order_1 UNION ALL select * from schema1.t_order_3
   (2 rows)
   
   scaling_db=> preview select * from schema2.t_order;
    data_source_name |                                actual_sql
   ------------------+---------------------------------------------------------------------------
    ds_0             | select * from schema2.t_order_0 UNION ALL select * from schema2.t_order_2
    ds_1             | select * from schema2.t_order_1 UNION ALL select * from schema2.t_order_3
   (2 rows)
   ```
   `t_order` was created in `schema1` and `schema2`, and it seems there're 2 logic table of `t_order`, which are in `schema1` and `schema2`.
   
   And metadata in registry center:
   <img width="302" alt="图片" src="https://user-images.githubusercontent.com/42492540/170903954-ad96ac38-50dc-43ce-9826-3bed325a57fa.png">
   
   In PostgreSQL, one table belongs to only one schema. If there're `schema1.t_order` and `schema2.t_order`, then it means there're 2 tables.
   Seems it's different as PostgreSQL schema logic. Is it as expected?
   Currently, sharding rule already has databaseName, will sharding rule add schemaName for logic table?
   
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] sandynz closed issue #18054: Question about logic table and schema name binding relation

Posted by GitBox <gi...@apache.org>.
sandynz closed issue #18054: Question about logic table and schema name binding relation
URL: https://github.com/apache/shardingsphere/issues/18054


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] sandynz commented on issue #18054: Question about logic table and schema name binding relation

Posted by GitBox <gi...@apache.org>.
sandynz commented on issue #18054:
URL: https://github.com/apache/shardingsphere/issues/18054#issuecomment-1140665798

   Keynotes of discussion with @strongduanmu :
   
   1, logic table in sharding rule will not add schemaName for flexiblity.
   
   2, We could use search_path to determine same table name laying.
   ```
   scaling_db=> show search_path;
      search_path
   -----------------
    "$user", public
   (1 row)
   
   scaling_db=> set search_path to schema1,schema2,schema3;
   SET
   scaling_db=> show search_path;
           search_path
   ---------------------------
    schema1, schema2, schema3
   (1 row)
   ```
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org