Skip to content

Commit

Permalink
Fixed CORE-5404 - Inconsistent column/line references when PSQL defin…
Browse files Browse the repository at this point in the history
…itions return errors.
  • Loading branch information
asfernandes committed Nov 22, 2016
1 parent 18dabe3 commit 0cf8d88
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
24 changes: 13 additions & 11 deletions src/dsql/Parser.cpp
Expand Up @@ -437,7 +437,7 @@ int Parser::yylexAux()
check_bound(p, string);

if (p > string + maxByteLength || p > string + maxCharLength)
yyabandon(-104, isc_dyn_name_longer);
yyabandon(yyposn, -104, isc_dyn_name_longer);

*p = 0;

Expand Down Expand Up @@ -519,27 +519,27 @@ int Parser::yylexAux()
{
if (buffer != string)
gds__free (buffer);
yyabandon (-104, isc_invalid_string_constant);
yyabandon(yyposn, -104, isc_invalid_string_constant);
}
else if (client_dialect >= SQL_DIALECT_V6)
{
if (p - buffer >= MAX_TOKEN_LEN)
{
if (buffer != string)
gds__free (buffer);
yyabandon(-104, isc_token_too_long);
yyabandon(yyposn, -104, isc_token_too_long);
}
else if (p > &buffer[MAX_SQL_IDENTIFIER_LEN])
{
if (buffer != string)
gds__free (buffer);
yyabandon(-104, isc_dyn_name_longer);
yyabandon(yyposn, -104, isc_dyn_name_longer);
}
else if (p - buffer == 0)
{
if (buffer != string)
gds__free (buffer);
yyabandon(-104, isc_dyn_zero_len_id);
yyabandon(yyposn, -104, isc_dyn_zero_len_id);
}

Attachment* const attachment = tdbb->getAttachment();
Expand All @@ -548,7 +548,7 @@ int Parser::yylexAux()
name.length(), (const UCHAR*) name.c_str(), true);

if (name.length() > maxByteLength || charLength > maxCharLength)
yyabandon(-104, isc_dyn_name_longer);
yyabandon(yyposn, -104, isc_dyn_name_longer);

yylval.metaNamePtr = FB_NEW_POOL(pool) MetaName(pool, name);

Expand Down Expand Up @@ -1103,7 +1103,7 @@ int Parser::yylexAux()
*p = 0;

if (p > &string[maxByteLength] || p > &string[maxCharLength])
yyabandon(-104, isc_dyn_name_longer);
yyabandon(yyposn, -104, isc_dyn_name_longer);

const MetaName str(string, p - string);
const Keyword* const keyVer = keywordsMap->get(str);
Expand Down Expand Up @@ -1206,7 +1206,7 @@ void Parser::yyerrorIncompleteCmd()
void Parser::check_bound(const char* const to, const char* const string)
{
if ((to - string) >= Parser::MAX_TOKEN_LEN)
yyabandon(-104, isc_token_too_long);
yyabandon(yyposn, -104, isc_token_too_long); //// FIXME:
}

void Parser::check_copy_incr(char*& to, const char ch, const char* const string)
Expand All @@ -1216,7 +1216,7 @@ void Parser::check_copy_incr(char*& to, const char ch, const char* const string)
}


void Parser::yyabandon(SLONG sql_code, ISC_STATUS error_symbol)
void Parser::yyabandon(const Position& position, SLONG sql_code, ISC_STATUS error_symbol)
{
/**************************************
*
Expand All @@ -1229,6 +1229,8 @@ void Parser::yyabandon(SLONG sql_code, ISC_STATUS error_symbol)
*
**************************************/

ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(sql_code) <<
Arg::Gds(error_symbol));
ERRD_post(
Arg::Gds(isc_sqlerr) << Arg::Num(sql_code) << Arg::Gds(error_symbol) <<
Arg::Gds(isc_dsql_line_col_error) <<
Arg::Num(position.firstLine) << Arg::Num(position.firstColumn));
}
2 changes: 1 addition & 1 deletion src/dsql/Parser.h
Expand Up @@ -234,7 +234,7 @@ class Parser : public Firebird::PermanentStorage
void check_bound(const char* const to, const char* const string);
void check_copy_incr(char*& to, const char ch, const char* const string);

void yyabandon(SLONG, ISC_STATUS);
void yyabandon(const Position& position, SLONG, ISC_STATUS);

Firebird::MetaName optName(Firebird::MetaName* name)
{
Expand Down
16 changes: 8 additions & 8 deletions src/dsql/parse.y
Expand Up @@ -4435,7 +4435,7 @@ non_charset_simple_type
$$->length = sizeof(GDS_TIMESTAMP);
}
else if (client_dialect == SQL_DIALECT_V6_TRANSITION)
yyabandon(-104, isc_transitional_date);
yyabandon(YYPOSNARG(1), -104, isc_transitional_date);
else
{
$$->dtype = dtype_sql_date;
Expand Down Expand Up @@ -4647,7 +4647,7 @@ prec_scale
$$ = newNode<dsql_fld>();

if ($2 < 1 || $2 > 18)
yyabandon(-842, isc_precision_err); // Precision must be between 1 and 18.
yyabandon(YYPOSNARG(2), -842, isc_precision_err); // Precision must be between 1 and 18.

if ($2 > 9)
{
Expand Down Expand Up @@ -4697,10 +4697,10 @@ prec_scale
$$ = newNode<dsql_fld>();

if ($2 < 1 || $2 > 18)
yyabandon (-842, isc_precision_err); // Precision should be between 1 and 18
yyabandon(YYPOSNARG(2), -842, isc_precision_err); // Precision should be between 1 and 18

if ($4 > $2 || $4 < 0)
yyabandon (-842, isc_scale_nogt); // Scale must be between 0 and precision
yyabandon(YYPOSNARG(4), -842, isc_scale_nogt); // Scale must be between 0 and precision

if ($2 > 9)
{
Expand Down Expand Up @@ -6991,7 +6991,7 @@ nonneg_short_integer
: NUMBER
{
if ($1 > SHRT_POS_MAX)
yyabandon(-842, isc_expec_short); // Short integer expected
yyabandon(YYPOSNARG(1), -842, isc_expec_short); // Short integer expected

$$ = $1;
}
Expand All @@ -7002,7 +7002,7 @@ neg_short_integer
: NUMBER
{
if ($1 > SHRT_NEG_MAX)
yyabandon(-842, isc_expec_short); // Short integer expected
yyabandon(YYPOSNARG(1), -842, isc_expec_short); // Short integer expected

$$ = $1;
}
Expand All @@ -7013,7 +7013,7 @@ pos_short_integer
: nonneg_short_integer
{
if ($1 == 0)
yyabandon(-842, isc_expec_positive); // Positive number expected
yyabandon(YYPOSNARG(1), -842, isc_expec_positive); // Positive number expected

$$ = $1;
}
Expand All @@ -7024,7 +7024,7 @@ unsigned_short_integer
: NUMBER
{
if ($1 > SHRT_UNSIGNED_MAX)
yyabandon(-842, isc_expec_ushort); // Unsigned short integer expected
yyabandon(YYPOSNARG(1), -842, isc_expec_ushort); // Unsigned short integer expected

$$ = $1;
}
Expand Down

0 comments on commit 0cf8d88

Please sign in to comment.