matrixone icon indicating copy to clipboard operation
matrixone copied to clipboard

[Feature Request]: Implement MySQL Encode()/Decode() function

Open charleschile opened this issue 1 year ago • 4 comments

User description

What type of PR is this?

  • [ ] API-change
  • [ ] BUG
  • [ ] Improvement
  • [ ] Documentation
  • [x] Feature
  • [ ] Test and CI
  • [ ] Code Refactoring

Which issue(s) this PR fixes:

issue #15027

What this PR does / why we need it:

implement Encode() and Decode() functions


PR Type

Enhancement, Tests


Description

  • Implemented Encode and Decode functions for string encryption and decryption.
  • Added helper structs and methods to support encoding and decoding logic.
  • Registered Encode and Decode functions in the built-in function list.
  • Added unit tests for Encode and Decode functions, covering various scenarios.
  • Added SQL test cases and expected results for Encode and Decode functions.

Changes walkthrough 📝

Relevant files
Enhancement
func_unary.go
Implement Encode and Decode functions for string encryption

pkg/sql/plan/function/func_unary.go

  • Added Encode and Decode functions for string encryption and
    decryption.
  • Introduced helper structs and methods for encoding and decoding logic.
  • Implemented encodeToBytes and decodeFromBytes helper functions.
  • +149/-0 
    list_builtIn.go
    Register Encode and Decode functions in built-in list       

    pkg/sql/plan/function/list_builtIn.go

  • Registered Encode and Decode functions in the built-in function list.
  • +42/-0   
    Tests
    func_unary_test.go
    Add unit tests for Encode and Decode functions                     

    pkg/sql/plan/function/func_unary_test.go

  • Added unit tests for Encode and Decode functions.
  • Introduced test cases for various encoding and decoding scenarios.
  • +167/-0 
    func_decode_encode.result
    Add expected results for Encode and Decode tests                 

    test/distributed/cases/function/func_decode_encode.result

    • Added expected results for Encode and Decode function tests.
    +33/-0   
    func_decode_encode.sql
    Add SQL test cases for Encode and Decode functions             

    test/distributed/cases/function/func_decode_encode.sql

    • Added SQL test cases for Encode and Decode functions.
    +11/-0   

    💡 PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    charleschile avatar Jul 02 '24 16:07 charleschile