Skip to content

SQLColAttribute and SQLDescribeCol return incorrect precision/scale for DECIMAL/NUMERIC types #171

@kevinjamesus86

Description

@kevinjamesus86

DuckDB's ODBC driver incorrectly reports precision and scale information for DECIMAL/NUMERIC columns when using SQLColAttribute and SQLDescribeCol functions.

Current Behavior

SQLColAttribute issues:

SQLDescribeCol issues:

Examples

Column Declaration SQLColAttribute Returns(Precision/Scale) SQLDescribeCol Returns(ColumnSize/DecimalDigits) Expected Values(Precision/Scale)
DECIMAL(5,2) 38/38 7/2 5/2
DECIMAL(8,4) 38/38 12/4 8/4
DECIMAL(10,9) 38/38 19/9 10/9
DECIMAL(30,9) 38/38 39/9 30/9
DECIMAL(38,0) 38/38 38/0 38/0
DECIMAL(38,37) 38/38 75/37 38/37
NUMERIC(5,2) 38/38 7/2 5/2
NUMERIC(8,4) 38/38 12/4 8/4

Takeaway

  • SQLColAttribute always returns 38 for both precision and scale
  • SQLDescribeCol returns precision + scale for ColumnSize (e.g., 5+2=7 for DECIMAL(5,2))

Expected Behavior

  • SQLColAttribute with SQL_DESC_PRECISION: Should return the actual precision (e.g., 5 for DECIMAL(5,2))
  • SQLColAttribute with SQL_DESC_SCALE: Should return the actual scale (e.g., 2 for DECIMAL(5,2))
  • SQLDescribeCol ColumnSize: Should return only the precision (e.g., 5 for DECIMAL(5,2))
  • SQLDescribeCol DecimalDigits: Should return the scale (currently working correctly)

Fork + possible fix n' tests

main...thedatamates:duckdb-odbc:kg/decimals-info

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions