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

Fix valgrind warnings related to varcharvarbinary function #2161

Conversation

basasairohan
Copy link
Contributor

@basasairohan basasairohan commented Dec 20, 2023

Description

Currently, we have defined the following cast functions which call varcharvarbinary C function with only 1 argument. But, in varcharvarbinary function, we are reading two arguments which might lead to memory related issues.

  1. sys.binarysysvarchar
  2. sys.binaryvarchar
  3. sys.rowversionsysvarchar
  4. sys.rowversionvarchar

This change modifies the above casts to have 3 arguments, one for input, one for typmod (integer) and the other for specifying isExplicit (boolean)

Issues Resolved

BABEL-4475
Signed-off-by: Sai Rohan Basa [email protected]

Test Scenarios Covered

  • Use case based - Tests related to above cast functions have already been written in babel_datatype.sql and BABEL-ROWVERSION.sql

  • Boundary conditions - N/A

  • Arbitrary inputs - N/A

  • Negative test cases - N/A

  • Minor version upgrade tests - N/A

  • Major version upgrade tests - N/A

  • Performance tests - N/A

  • Tooling impact - N/A

  • Client tests - N/A

Check List

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

@basasairohan basasairohan marked this pull request as ready for review December 25, 2023 12:02
Comment on lines 99 to +100
CREATE CAST (sys.BBF_BINARY AS sys.VARCHAR)
WITH FUNCTION sys.binarysysvarchar (sys.BBF_BINARY) AS ASSIGNMENT;
WITH FUNCTION sys.binarysysvarchar (sys.BBF_BINARY, integer, boolean) AS ASSIGNMENT;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets have some test cases which uses these cast in prepare script and then we try to upgrade it,

Prepare:

create view some_view as select cast(cast(some_value as binary) as varchar)

verify --

extract the view definition, SELECT pg_catalog.pg_get_viewdef(oid, true) FROM pg_class WHERE relname = 'some_view';

@basasairohan basasairohan deleted the babel-4475 branch January 10, 2024 08:44
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.

2 participants