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 2020/12/01 09:52:35 UTC

[GitHub] [shardingsphere] tuohai666 opened a new issue #8445: Improve the SQL command types of PostgreSQL

tuohai666 opened a new issue #8445:
URL: https://github.com/apache/shardingsphere/issues/8445


   For ShardingSphere-Proxy's PostgreSQL protocol implement, we record the SQL command type for the CommandCompletePacket. In brief, users can get a readable prompt after execute an SQL:
   
   ![image](https://user-images.githubusercontent.com/24643893/100723393-abadc780-33fc-11eb-9e2a-4eb80f7c8a1a.png)
   
   Types that Proxy supports for now:
   
   ```
   SELECT
   INSERT
   UPDATE
   DELETE
   ```
   
   That's not enough, maybe we should implement the entire types according to:
   
   ```
   1.  PostgreSQL protocol.
   2. JDBC codes.
   3. PostgreSQL server codes.
   ```
   
   **Option 1**
   
   As the protocol doc: https://www.postgresql.org/docs/13/protocol-message-formats.html
   
   CommandComplete (B)
   Byte1('C')
   Identifies the message as a command-completed response.
   
   Int32
   Length of message contents in bytes, including self.
   
   ```
   CommandComplete (B)
   Byte1('C')
   Identifies the message as a command-completed response.
   
   Int32
   Length of message contents in bytes, including self.
   
   String
   The command tag. This is usually a single word that identifies which SQL command was completed.
   
   For an INSERT command, the tag is INSERT oid rows, where rows is the number of rows inserted. oid used to be the object ID of the inserted row if rows was 1 and the target table had OIDs, but OIDs system columns are not supported anymore; therefore oid is always 0.
   
   For a DELETE command, the tag is DELETE rows where rows is the number of rows deleted.
   
   For an UPDATE command, the tag is UPDATE rows where rows is the number of rows updated.
   
   For a SELECT or CREATE TABLE AS command, the tag is SELECT rows where rows is the number of rows retrieved.
   
   For a MOVE command, the tag is MOVE rows where rows is the number of rows the cursor's position has been changed by.
   
   For a FETCH command, the tag is FETCH rows where rows is the number of rows that have been retrieved from the cursor.
   
   For a COPY command, the tag is COPY rows where rows is the number of rows copied. (Note: the row count appears only in PostgreSQL 8.2 and later.)
   ```
   
   **Option 2**
   
   The **SqlCommandType** of pgjdbc: https://github.com/pgjdbc/pgjdbc
   
   ```
   public enum SqlCommandType {
   
     /**
      * Use BLANK for empty sql queries or when parsing the sql string is not
      * necessary.
      */
     BLANK,
     INSERT,
     UPDATE,
     DELETE,
     MOVE,
     SELECT,
     WITH;
   }
   ```
   
   **Option 3**
   
   Didn't get the codes yet.
   
   
   1 and 2 are not equivalent, which one should we choose? Does 3 necessary?


----------------------------------------------------------------
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.

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



[GitHub] [shardingsphere] tuohai666 commented on issue #8445: Improve the SQL command types of PostgreSQL

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


   @wenweibin Yes, Option 1 is reasonable. But the protocol maybe not complete. For example:
   
   ![123](https://user-images.githubusercontent.com/24643893/102061484-7b1f5200-3e2e-11eb-8036-ba8e9335032f.png)
   
   Other statements still have prompt(COMMIT, SET, etc.) except in protocol.
   
   Option 3 means find all the prompt statements from PostgreSQL server codes.
   
   
   So, should we adopt option 3 implementing all prompt statements?
   
   
   


----------------------------------------------------------------
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.

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



[GitHub] [shardingsphere] wenweibin commented on issue #8445: Improve the SQL command types of PostgreSQL

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


   > @wenweibin Yes, Option 1 is reasonable. But the protocol maybe not complete. For example:
   > 
   > ![123](https://user-images.githubusercontent.com/24643893/102061484-7b1f5200-3e2e-11eb-8036-ba8e9335032f.png)
   > 
   > Other statements still have prompt(COMMIT, SET, etc.) except in protocol.
   > 
   > Option 3 means find all the prompt statements from PostgreSQL server codes.
   > 
   > So, should we adopt option 3 implementing all prompt statements?
   
   If the protocol is incomplete, the option 3 may be a better one.


----------------------------------------------------------------
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.

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



[GitHub] [shardingsphere] wenweibin edited a comment on issue #8445: Improve the SQL command types of PostgreSQL

Posted by GitBox <gi...@apache.org>.
wenweibin edited a comment on issue #8445:
URL: https://github.com/apache/shardingsphere/issues/8445#issuecomment-739465947


   I think `option 1`  is more reasonable because we should follow the message protocol rather than the specific implementation such as PostgreSQL(Shardingproxy is also an implementation of PostgreSQL message protocol).
   
   Besides, what does `option 3`  mean?


----------------------------------------------------------------
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.

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



[GitHub] [shardingsphere] wenweibin commented on issue #8445: Improve the SQL command types of PostgreSQL

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


   I think the `option 1`  is more reasonable because we should follow the message protocol rather than the specific implementation such as PostgreSQL(Shardingproxy is also an implementation of PostgreSQL message protocol).
   
   Besides, what does `option 3`  mean?


----------------------------------------------------------------
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.

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



[GitHub] [shardingsphere] menghaoranss closed issue #8445: Improve the SQL command types of PostgreSQL

Posted by GitBox <gi...@apache.org>.
menghaoranss closed issue #8445:
URL: https://github.com/apache/shardingsphere/issues/8445


   


-- 
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.

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