Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 30 additions & 17 deletions src/dsql/parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -5452,7 +5452,7 @@ national_character_type
{
$$ = newNode<dsql_fld>();
$$->dtype = dtype_text;
$$->charLength = 1;
$$->charLength = DEFAULT_CHAR_LENGTH;
$$->flags |= FLD_national;
}
| national_character_keyword VARYING '(' pos_short_integer ')'
Expand All @@ -5462,6 +5462,13 @@ national_character_type
$$->charLength = (USHORT) $4;
$$->flags |= (FLD_national | FLD_has_len);
}
| national_character_keyword VARYING
{
$$ = newNode<dsql_fld>();
$$->dtype = dtype_varying;
$$->charLength = DEFAULT_VARCHAR_LENGTH;
$$->flags |= FLD_national;
}
;

%type <legacyField> binary_character_type
Expand All @@ -5481,8 +5488,8 @@ binary_character_type
{
$$ = newNode<dsql_fld>();
$$->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;
Expand All @@ -5499,6 +5506,17 @@ binary_character_type
$$->subType = fb_text_subtype_binary;
$$->flags |= (FLD_has_len | FLD_has_chset);
}
| varbinary_character_keyword
{
$$ = newNode<dsql_fld>();
$$->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 <legacyField> character_type
Expand All @@ -5514,7 +5532,7 @@ character_type
{
$$ = newNode<dsql_fld>();
$$->dtype = dtype_text;
$$->charLength = 1;
$$->charLength = DEFAULT_CHAR_LENGTH;
}
| varying_keyword '(' pos_short_integer ')'
{
Expand All @@ -5523,6 +5541,12 @@ character_type
$$->charLength = (USHORT) $3;
$$->flags |= FLD_has_len;
}
| varying_keyword
{
$$ = newNode<dsql_fld>();
$$->dtype = dtype_varying;
$$->charLength = DEFAULT_VARCHAR_LENGTH;
}
;

varying_keyword
Expand Down Expand Up @@ -5902,7 +5926,7 @@ set_bind

%type <legacyField> set_bind_from
set_bind_from
: bind_type
: non_array_type
| TIME ZONE
{
$$ = newNode<dsql_fld>();
Expand All @@ -5911,20 +5935,9 @@ set_bind_from
}
;

%type <legacyField> bind_type
bind_type
: non_array_type
| varying_keyword
{
$$ = newNode<dsql_fld>();
$$->dtype = dtype_varying;
$$->charLength = 0;
}
;

%type <legacyField> set_bind_to
set_bind_to
: bind_type
: non_array_type
{
$$ = $1;
}
Expand Down
8 changes: 8 additions & 0 deletions src/jrd/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <data type>, 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 <data type>, 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
Expand Down