Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CBRD-24371] In alter synonym, comments can be changed without a for clause, and empty string comments become NULL. #3694

Merged
merged 2 commits into from
Jul 6, 2022

Conversation

youngjinj
Copy link
Contributor

@youngjinj youngjinj commented Jun 30, 2022

http://jira.cubrid.org/browse/CBRD-24371

In alter synonym, comments can be changed without a for clause, and empty string comments become NULL.

  1. In AS-IS, only the comment could not be changed when the ALTER SYNONYM statement was executed.
csql> create synonym s1 for t1;
csql> alter synonym s1 comment 'Change comment without for clause.';

ERROR: Invalid alter synonym.
  ALTER [PRIVATE] SYNONYM [<user_name>.]<synonym_name> FOR [<user_name>.]<target_name> [COMMENT 'comment_string']

In To-BE

  1. When executing the ALTER SYNONYM statement, only the comment can be changed without using the for clause.
/* AS-IS */
ALTER [PRIVATE] SYNONYM [<user_name>.]<synonym_name> FOR [<user_name>.]<target_name> [COMMENT 'comment_string']

/* TO-BE */
ALTER [PRIVATE] SYNONYM [<schema_name>.]<synonym_name> {FOR [<schema_name>.]<target_name> [COMMENT 'comment_string'] | COMMENT 'comment_string'}
  1. In the ALTER SYNONYM statement, if there is no for clause and no comments are changed, an error should occur.
    • MSGCAT_SYNTAX_SYNONYM_ALTER_NO_OPTION
csql> create synonym s2 for t2;
csql> alter synonym s2;
    
ERROR: No options specified for ALTER SYNONYM.
  1. If the comment of synonym is changed to an empty string, it becomes NULL.

    3.1. CREATE SYNONYM with empty string as comment.

    csql> create synonym s3 for t3 comment '';
    csql> select * from db_synonym where synonym_name = 's3';
    
    /* AS-IS */
      synonym_name  synonym_owner_name  is_public_synonym  target_name  target_owner_name  comment
    ================================================================================================
      's3'          'PUBLIC'            'NO'               't3'         'PUBLIC'           ''
    
    /* TO-BE */
      synonym_name  synonym_owner_name  is_public_synonym  target_name  target_owner_name  comment
    ================================================================================================
      's3'          'PUBLIC'            'NO'               't3'         'PUBLIC'           NULL
    

    3.2. ALTER SYNONYM with empty string as comment.

    csql> create synonym s4 for t4 comment 'dummy comment.';
    csql> select * from db_synonym where synonym_name = 's4';
    
      synonym_name  synonym_owner_name  is_public_synonym  target_name  target_owner_name  comment
    =========================================================================================================
      's4'          'PUBLIC'            'NO'               't4'         'PUBLIC'           'Dummy comment.'
    
    csql> alter synonym s4 for t4 comment '';
    csql> select * from db_synonym where synonym_name = 's4';
    
    /* AS-IS */
      synonym_name  synonym_owner_name  is_public_synonym  target_name  target_owner_name  comment
    =========================================================================================================
      's4'          'PUBLIC'            'NO'               't4'         'PUBLIC'           ''
    
    /* TO-BE */
      synonym_name  synonym_owner_name  is_public_synonym  target_name  target_owner_name  comment
    =========================================================================================================
      's4'          'PUBLIC'            'NO'               't4'         'PUBLIC'           NULL
    

@youngjinj youngjinj self-assigned this Jun 30, 2022
@youngjinj youngjinj changed the title [CBRD-24371] Allows only comments to be changed in alter synonym. [CBRD-24371] In alter synonym, comments can be changed without a for clause, and empty string comments become null. Jun 30, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jun 30, 2022

Codecov Report

Merging #3694 (20f105a) into develop (aa38779) will decrease coverage by 1.88%.
The diff coverage is 0.88%.

@@             Coverage Diff             @@
##           develop    #3694      +/-   ##
===========================================
- Coverage    50.91%   49.02%   -1.89%     
===========================================
  Files          515      515              
  Lines       398190   398213      +23     
===========================================
- Hits        202726   195232    -7494     
- Misses      195464   202981    +7517     
Impacted Files Coverage Δ
src/parser/parse_tree_cl.c 66.41% <0.00%> (-3.04%) ⬇️
src/parser/semantic_check.c 63.52% <0.00%> (-4.66%) ⬇️
src/query/execute_statement.c 52.56% <0.00%> (-3.90%) ⬇️
src/parser/parser_support.c 60.51% <2.32%> (-3.32%) ⬇️
src/method/method_def.hpp 0.00% <0.00%> (-100.00%) ⬇️
src/method/method_def.cpp 18.18% <0.00%> (-68.69%) ⬇️
src/method/method_connection_pool.cpp 6.12% <0.00%> (-59.19%) ⬇️
src/query/query_hash_scan.c 7.43% <0.00%> (-51.60%) ⬇️
src/method/method_struct_invoke.cpp 34.44% <0.00%> (-33.34%) ⬇️
src/object/object_printer.cpp 48.58% <0.00%> (-25.06%) ⬇️
... and 126 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa38779...20f105a. Read the comment docs.

@youngjinj youngjinj marked this pull request as ready for review June 30, 2022 09:55
@youngjinj youngjinj changed the title [CBRD-24371] In alter synonym, comments can be changed without a for clause, and empty string comments become null. [CBRD-24371] In alter synonym, comments can be changed without a for clause, and empty string comments become NULL. Jun 30, 2022
@youngjinj youngjinj merged commit e351dd3 into CUBRID:develop Jul 6, 2022
youngjinj added a commit to youngjinj/cubrid that referenced this pull request Oct 12, 2022
…clause, and empty string comments become NULL. (CUBRID#3694)

http://jira.cubrid.org/browse/CBRD-24371

### In alter synonym, comments can be changed without a for clause, and empty string comments become NULL.
1. When executing the ALTER SYNONYM statement, only the comment can be changed without using the for clause.
2. In the ALTER SYNONYM statement, if there is no for clause and no comments are changed, an error should occur.
    - MSGCAT_SYNTAX_SYNONYM_ALTER_NO_OPTION
3. If the comment of synonym is changed to an empty string, it becomes NULL.
youngjinj added a commit that referenced this pull request Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants