diff --git a/src/dsql/parse.y b/src/dsql/parse.y index 8fcbd7ec57a..364be68de06 100644 --- a/src/dsql/parse.y +++ b/src/dsql/parse.y @@ -5452,7 +5452,7 @@ national_character_type { $$ = newNode(); $$->dtype = dtype_text; - $$->charLength = 1; + $$->charLength = DEFAULT_CHAR_LENGTH; $$->flags |= FLD_national; } | national_character_keyword VARYING '(' pos_short_integer ')' @@ -5462,6 +5462,13 @@ national_character_type $$->charLength = (USHORT) $4; $$->flags |= (FLD_national | FLD_has_len); } + | national_character_keyword VARYING + { + $$ = newNode(); + $$->dtype = dtype_varying; + $$->charLength = DEFAULT_VARCHAR_LENGTH; + $$->flags |= FLD_national; + } ; %type binary_character_type @@ -5481,8 +5488,8 @@ binary_character_type { $$ = newNode(); $$->dtype = dtype_text; - $$->charLength = 1; - $$->length = 1; + $$->charLength = DEFAULT_BINARY_LENGTH; + $$->length = DEFAULT_BINARY_LENGTH; $$->textType = ttype_binary; $$->charSetId = CS_BINARY; $$->subType = fb_text_subtype_binary; @@ -5499,6 +5506,17 @@ binary_character_type $$->subType = fb_text_subtype_binary; $$->flags |= (FLD_has_len | FLD_has_chset); } + | varbinary_character_keyword + { + $$ = newNode(); + $$->dtype = dtype_varying; + $$->charLength = DEFAULT_VARBINARY_LENGTH; + $$->length = DEFAULT_VARBINARY_LENGTH + sizeof(USHORT); + $$->textType = ttype_binary; + $$->charSetId = CS_BINARY; + $$->subType = fb_text_subtype_binary; + $$->flags |= FLD_has_chset; + } ; %type character_type @@ -5514,7 +5532,7 @@ character_type { $$ = newNode(); $$->dtype = dtype_text; - $$->charLength = 1; + $$->charLength = DEFAULT_CHAR_LENGTH; } | varying_keyword '(' pos_short_integer ')' { @@ -5523,6 +5541,12 @@ character_type $$->charLength = (USHORT) $3; $$->flags |= FLD_has_len; } + | varying_keyword + { + $$ = newNode(); + $$->dtype = dtype_varying; + $$->charLength = DEFAULT_VARCHAR_LENGTH; + } ; varying_keyword @@ -5902,7 +5926,7 @@ set_bind %type set_bind_from set_bind_from - : bind_type + : non_array_type | TIME ZONE { $$ = newNode(); @@ -5911,20 +5935,9 @@ set_bind_from } ; -%type bind_type -bind_type - : non_array_type - | varying_keyword - { - $$ = newNode(); - $$->dtype = dtype_varying; - $$->charLength = 0; - } - ; - %type set_bind_to set_bind_to - : bind_type + : non_array_type { $$ = $1; } diff --git a/src/jrd/constants.h b/src/jrd/constants.h index b173267e3e7..36b6f2ea041 100644 --- a/src/jrd/constants.h +++ b/src/jrd/constants.h @@ -220,6 +220,14 @@ inline constexpr size_t DEFAULT_TIME_PRECISION = 0; // Should be 6 as per SQL spec inline constexpr size_t DEFAULT_TIMESTAMP_PRECISION = 3; +// SQL spec requires an implementation-specific default (6.1 , syntax rules 6 (VARBINARY) and 7 (VARCHAR)) +inline constexpr size_t DEFAULT_VARCHAR_LENGTH = 255; +inline constexpr size_t DEFAULT_VARBINARY_LENGTH = 255; + +// SQL spec requires a default length of 1 (6.1 , syntax rule 5) +inline constexpr size_t DEFAULT_CHAR_LENGTH = 1; +inline constexpr size_t DEFAULT_BINARY_LENGTH = 1; + inline constexpr size_t MAX_ARRAY_DIMENSIONS = 16; inline constexpr size_t MAX_SORT_ITEMS = 255; // ORDER BY f1,...,f255