-
Notifications
You must be signed in to change notification settings - Fork 97
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 typmod value in case of nvarchar(max), varchar(max), varbinary(max) #2036
fix typmod value in case of nvarchar(max), varchar(max), varbinary(max) #2036
Conversation
Signed-off-by: Sandeep Kumawat <[email protected]>
Signed-off-by: Sandeep Kumawat <[email protected]>
Signed-off-by: Sandeep Kumawat <[email protected]>
Signed-off-by: Sandeep Kumawat <[email protected]>
Signed-off-by: Sandeep Kumawat <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We dont need tests to test these changes??
Looks like this is a common issue for varbinarytypmodin, bpchartypmodin and varchartypmodin but you have fixed only n/varchar |
1. Added test-cases 2. Changes value of atttypmod in parser for varchar, nvarchar 3. Changes value of atttypod in protocl for varbinary. Signed-off-by: Sandeep Kumawat <[email protected]>
Added test cases |
Yes, in tsql these three data-types support max as a scale. So these three have this issue.
In the latest commit I have made changes in parser for varchar(max), nvarchar(max). |
1. fixes crash in case of varchar(max), nvarchar(max), varbinary(max) when input value is very large. 2. Blocks the out of range value of scale in case char(), nchar(), varchar(), nvarchar(), binary(), varbinary() Signed-off-by: Sandeep Kumawat <[email protected]>
parse_datatype now uses oid to validated data-type instead of string. This will help in sys.varchar and varchar data-type to be treated as same Signed-off-by: Sandeep Kumawat <[email protected]>
Signed-off-by: Sandeep Kumawat <[email protected]>
Signed-off-by: Sandeep Kumawat <[email protected]>
Signed-off-by: Sandeep Kumawat <[email protected]>
Signed-off-by: Sandeep Kumawat <[email protected]>
Signed-off-by: Sandeep Kumawat <[email protected]>
Signed-off-by: Sandeep Kumawat <[email protected]>
Signed-off-by: Sandeep Kumawat <[email protected]>
Signed-off-by: Sandeep Kumawat <[email protected]>
2d52dc0
into
babelfish-for-postgresql:BABEL_3_X_DEV
…x) (babelfish-for-postgresql#2036) This PR fixes a crash in TdsSendTypeNVarchar for nvarchar(max) by resolving a bug in handling varchar(max) , nvarchar(max) and varbinary(max) and limits a maximum scale value for (var)char, (var)binary, and (n)(var)char types. To do that, we set a limit of 8000 for (var)char and (var)binary, and a limit of 4000 for (n)(var)char. Signed-off-by: Sandeep Kumawat [email protected] Issues Resolved BABEL-4547
…x) (babelfish-for-postgresql#2036) This PR fixes a crash in TdsSendTypeNVarchar for nvarchar(max) by resolving a bug in handling varchar(max) , nvarchar(max) and varbinary(max) and limits a maximum scale value for (var)char, (var)binary, and (n)(var)char types. To do that, we set a limit of 8000 for (var)char and (var)binary, and a limit of 4000 for (n)(var)char. Signed-off-by: Sandeep Kumawat [email protected] Issues Resolved BABEL-4547
…x) (babelfish-for-postgresql#2036) This PR fixes a crash in TdsSendTypeNVarchar for nvarchar(max) by resolving a bug in handling varchar(max) , nvarchar(max) and varbinary(max) and limits a maximum scale value for (var)char, (var)binary, and (n)(var)char types. To do that, we set a limit of 8000 for (var)char and (var)binary, and a limit of 4000 for (n)(var)char. Signed-off-by: Sandeep Kumawat [email protected] Issues Resolved BABEL-4547
…x) (babelfish-for-postgresql#2036) This PR fixes a crash in TdsSendTypeNVarchar for nvarchar(max) by resolving a bug in handling varchar(max) , nvarchar(max) and varbinary(max) and limits a maximum scale value for (var)char, (var)binary, and (n)(var)char types. To do that, we set a limit of 8000 for (var)char and (var)binary, and a limit of 4000 for (n)(var)char. Signed-off-by: Sandeep Kumawat [email protected] Issues Resolved BABEL-4547
…x) (babelfish-for-postgresql#2036) This PR fixes a crash in TdsSendTypeNVarchar for nvarchar(max) by resolving a bug in handling varchar(max) , nvarchar(max) and varbinary(max) and limits a maximum scale value for (var)char, (var)binary, and (n)(var)char types. To do that, we set a limit of 8000 for (var)char and (var)binary, and a limit of 4000 for (n)(var)char. Signed-off-by: Sandeep Kumawat [email protected] Issues Resolved BABEL-4547
…x) (babelfish-for-postgresql#2036) This PR fixes a crash in TdsSendTypeNVarchar for nvarchar(max) by resolving a bug in handling varchar(max) , nvarchar(max) and varbinary(max) and limits a maximum scale value for (var)char, (var)binary, and (n)(var)char types. To do that, we set a limit of 8000 for (var)char and (var)binary, and a limit of 4000 for (n)(var)char. Signed-off-by: Sandeep Kumawat [email protected] Issues Resolved BABEL-4547
…x) (babelfish-for-postgresql#2036) This PR fixes a crash in TdsSendTypeNVarchar for nvarchar(max) by resolving a bug in handling varchar(max) , nvarchar(max) and varbinary(max) and limits a maximum scale value for (var)char, (var)binary, and (n)(var)char types. To do that, we set a limit of 8000 for (var)char and (var)binary, and a limit of 4000 for (n)(var)char. Signed-off-by: Sandeep Kumawat [email protected] Issues Resolved BABEL-4547
…x) (babelfish-for-postgresql#2036) This PR fixes a crash in TdsSendTypeNVarchar for nvarchar(max) by resolving a bug in handling varchar(max) , nvarchar(max) and varbinary(max) and limits a maximum scale value for (var)char, (var)binary, and (n)(var)char types. To do that, we set a limit of 8000 for (var)char and (var)binary, and a limit of 4000 for (n)(var)char. Signed-off-by: Sandeep Kumawat [email protected] Issues Resolved BABEL-4547
…x) (babelfish-for-postgresql#2036) This PR fixes a crash in TdsSendTypeNVarchar for nvarchar(max) by resolving a bug in handling varchar(max) , nvarchar(max) and varbinary(max) and limits a maximum scale value for (var)char, (var)binary, and (n)(var)char types. To do that, we set a limit of 8000 for (var)char and (var)binary, and a limit of 4000 for (n)(var)char. Signed-off-by: Sandeep Kumawat [email protected] Issues Resolved BABEL-4547
…x) (#2036) This PR fixes a crash in TdsSendTypeNVarchar for nvarchar(max) by resolving a bug in handling varchar(max) , nvarchar(max) and varbinary(max) and limits a maximum scale value for (var)char, (var)binary, and (n)(var)char types. To do that, we set a limit of 8000 for (var)char and (var)binary, and a limit of 4000 for (n)(var)char. Signed-off-by: Sandeep Kumawat [email protected] Issues Resolved BABEL-4547
…x) (babelfish-for-postgresql#2036) This PR fixes a crash in TdsSendTypeNVarchar for nvarchar(max) by resolving a bug in handling varchar(max) , nvarchar(max) and varbinary(max) and limits a maximum scale value for (var)char, (var)binary, and (n)(var)char types. To do that, we set a limit of 8000 for (var)char and (var)binary, and a limit of 4000 for (n)(var)char. Signed-off-by: Sandeep Kumawat [email protected] Issues Resolved BABEL-4547
Description
Previously, there was an issue in handling
varchar(max)
,nvarchar(max)
andvarbinary(max)
in the code. Specifically, when dealing withatttypmod
with a value of -8000 (representingTSQLMaxTypmod
) in thePrepareRowDescription
function fornvarchar
andvarchar
, an incorrect value ofatttypmod
was being passed to theSetColMetadataForCharType
function. This resulted in setting an incorrectmaxSize
for the column metadata entry.Because of this if we assign a long string value to a nvarchar(max) variable with a length such that UTF16 output size is large it will throw a FATAL log
elog(FATAL, "UTF16 output of varchar/bpchar exceeds max length");
Additionally, This PR limits a maximum scale value for (var)char, (var)binary, and (n)(var)char types. To do that, we set a limit of 8000 for (var)char and (var)binary, and a limit of 4000 for (n)(var)char.
Signed-off-by: Sandeep Kumawat [email protected]
Issues Resolved
BABEL-4547
Check List
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.