In current code, varchar datatype with no length is only allowed for the
construct:
convert(<expr>, varchar)
It is changed to true in the following parser production:
| TOK_CONVERT '(' value_expression ','
{empty_charlen_specifier_allowed =TRUE;} data_type ')'
In other cases it is not allowed.
Should be ok to change the global to true. But make sure that all cases where
varchar is used, are covered.
They include column definition, CAST specification, CALL statements procedure
declarations.
Default size is set in parser variable DEFAULT_STRING_SIZE of 1. This is based
on ANSI rule:
6.1.4) If <length> is omitted, then a <length> of 1 (one) is implicit.
If this is to be made different than 1, then it is better to add a cqd to
control it.
anoop
-----Original Message-----
From: Zhu, Wen-Jun <[email protected]>
Sent: Monday, April 23, 2018 1:07 AM
To: [email protected]
Subject: about the length for varchar
Hi,
I find that there is a setting that controls whether the length is needed for
varchar in file sqlparser.y:
298 //This global is introduced to allow empty character length specifier
299 //(e.g. varchar) in VARCHAR for ODBC.
300 THREAD_P NABoolean empty_charlen_specifier_allowed = FALSE;
As I can see, it was always FALSE. What is it for?
In Oracle, sometimes the varchar can be supplied without length, like
Xxx varchar,
To make this compatible with Oracle in these situations,
I'd like to set ` empty_charlen_specifier_allowed ` to TRUE.
But it would allow empty length for every situation, which (maybe) breaks
previous usages.
And another issue, its default length is 1, which is too short. Can I make it
larger?
If I make another rule for these situations, it takes a lot effects, including
all kinds of character types.
But I only care about the length of the varchar type. Is there some suggestion?
Regards,
Wenjun Zhu