Skip to content

Imprecise Data Type false positive #55

Description

@pcnate

The Imprecise Data Type thrown when the value of a string contains the word real. The regular expression should probably check for these data types being used outside of a string or value.

-------------------------------------------------
SQL Statement at line 409: exec @returnvalue = api.adddatasetattribute @datasetidentifier =
@datasetidentifier ,@attributetype = '' ,@name = 'realtimereload' ,@value = 0
,@returnreason = @returnreason output ,@mysqlerrline = @mysqlerrline output
,@mysqlerrnbr = @mysqlerrnbr output ,@mysqlerrsp = @mysqlerrsp output;
[Data/Import.sql]: (MEDIUM RISK) (PHYSICAL_DATABASE_DESIGN ANTI-PATTERN) Imprecise Data Type
[Matching Expression: real at line 409]

sqlcheck/src/list.cpp

Lines 352 to 383 in 391ae84

// PHYSICAL DATABASE DESIGN
void CheckFloat(Configuration& state,
const std::string& sql_statement,
bool& print_statement){
std::regex pattern("(float)|(real)|(double precision)|(0\\.000[0-9]*)");
std::string title = "Imprecise Data Type";
PatternType pattern_type = PatternType::PATTERN_TYPE_PHYSICAL_DATABASE_DESIGN;
auto message =
"● Use precise data types: "
"Virtually any use of FLOAT, REAL, or DOUBLE PRECISION data types is suspect. "
"Most applications that use floating-point numbers don't require the range of "
"values supported by IEEE 754 formats. The cumulative impact of inexact "
"floating-point numbers is severe when calculating aggregates. "
"Instead of FLOAT or its siblings, use the NUMERIC or DECIMAL SQL data types "
"for fixed-precision fractional numbers. These data types store numeric values "
"exactly, up to the precision you specify in the column definition. "
"Do not use FLOAT if you can avoid it.";
CheckPattern(state,
sql_statement,
print_statement,
pattern,
RISK_LEVEL_MEDIUM,
pattern_type,
title,
message,
true);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions