babelfish_extensions icon indicating copy to clipboard operation
babelfish_extensions copied to clipboard

[DO NOT MERGE] Added wrapper function for TRIM, LTRIM, RTRIM, LEFT and RIGHT

Open rohit01010 opened this issue 1 year ago • 0 comments

Description

Currently, for string functions TRIM, LTRIM, RTRIM, LEFT and RIGHT underlying Postgres function is being used which leads to incorrect output behaviour. This PR will fix this issue by adding wrapper functions for these string functions.

Changes included in this PR are as follows:-

  • Added wrapper functions for TRIM, LTRIM, RTRIM, LEFT and RIGHT.
  • Added hook func_select_candidate_for_special_hook for selecting best candidate among list of functions definitions based on return type for string functions which are in special function list.
  • Updated definition of function pltsql_report_proc_not_found_error to include input_typeids of function.
  • Added PG_CATALOG namespace before TRIM, LTRIM, RTRIM, LEFT or RIGHT function invocations in some of the system functions as with these wrapper definitions of TRIM, LTRIM, RTRIM, LEFT and RIGHT functions in sys namespace, any function invocation of TRIM, LTRIM, RTRIM, LEFT or RIGHT function without namespace, by default it will call the function in sys namespace.
  • Added new test files and updated existing test files expected output as the output behaviour of these functions will change with this fix.
  • In case of Inline Table Valued Function(ITVF), made changes such that if the return type of body is different than return type stored for during creation of ITVF, an implicit cast will occur and return type of body will be casted to return type stored.
  • fixed composite actions to avoid replacing partial word for test files present in schedule file of upgrades.

Engine PR: https://github.com/babelfish-for-postgresql/postgresql_modified_for_babelfish/pull/344

Authored-by: Rohit Bhagat [email protected] Signed-off-by: Rohit Bhagat [email protected]

Issues Resolved

BABEL-4489

Test Scenarios Covered

  • Use case based - YES

  • Boundary conditions - YES

  • Arbitrary inputs - NA

  • Negative test cases - YES

  • Minor version upgrade tests - YES

  • Major version upgrade tests - YES

  • Performance tests - NA

  • Tooling impact - NA

  • Client tests - YES

Check List

  • [x] Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

rohit01010 avatar Apr 15 '24 08:04 rohit01010