-
Notifications
You must be signed in to change notification settings - Fork 49
Description
For all VARCHAR
types: Regardless of whether you define a length for the VARCHAR column, the getPrecision() method will always return a hardcoded value of 0.
Within the DuckDBResultSetMetaData.java file, the getPrecision(int column) method in the DuckDB JDBC driver does not return the defined length of a VARCHAR
variable. Instead, for VARCHAR types, the getPrecision() method returns a hardcoded value of 0.
This means that even if you define a VARCHAR with a specific length in your DuckDB table, the JDBC driver will not report this length to the client application.
When compared to PostgreSQL implementation, the PostgreSQL JDBC driver provides a more nuanced and informative implementation of getPrecision() compared to the DuckDB driver. Here's how it behaves:
-
For
VARCHAR(n)
: When you define a column as VARCHAR with a specific length (e.g., VARCHAR(100)), the getPrecision() method will return that defined length (100 in this case). -
For
VARCHAR
(without a length) andTEXT
: PostgreSQL treats VARCHAR without a length specifier as equivalent to the TEXT data type, both of which can store strings of virtually unlimited length. In this scenario, the PostgreSQL JDBC driver will typically return a very large value, often Integer.MAX_VALUE (2,147,483,647), to signify that there is no predefined limit.