| Bug #44966 | SQLColAttribute SQL_DESC_NULLABLE incorrect info for column | ||
|---|---|---|---|
| Submitted: | 19 May 2009 20:52 | Modified: | 10 Jul 2012 9:28 |
| Reporter: | Farid Zidan (Candidate Quality Contributor) | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / ODBC | Severity: | S2 (Serious) |
| Version: | 5.01.05.00 | OS: | Windows (XP SP3) |
| Assigned to: | Lawrenty Novitsky | CPU Architecture: | Any |
[23 Dec 2009 12:49]
Tonci Grgin
Duplicate of verified report Bug#49655.
[23 Dec 2009 15:29]
Farid Zidan
Just a clarification. In the test case table (how to repeat section) there are two TIMESTAMP columns both are defined as not to allow null. The driver is returning incorrect SQL_DESC_NULLABLE info for only the timestamp column that is defined as having a default.
[23 Dec 2009 16:28]
Tonci Grgin
Thanks for explanation, will revisit after vacation.
[25 Jan 2010 15:55]
Tonci Grgin
Verified just as Farid described: For Column2 SQLColAttribute: In: StatementHandle = 0x00775B78, ColumnNumber = 2, FieldIdentifier = SQL_DESC_NULLABLE=1008, CharacterAttributePtr = 0x04110020, BufferLength = 600, StringLengthPtr = 0x001B1B28, NumericAttributePtr = 0x001B6FF8, fFieldIndentifier Type = SQL_C_SLONG=-16 Return: SQL_SUCCESS=0 Out: *CharacterAttributePtr = <unmodified>, *StringLengthPtr = <unmodified>, *NumericAttributePtr = 1 For Column3 SQLColAttribute: In: StatementHandle = 0x00775B78, ColumnNumber = 3, FieldIdentifier = SQL_DESC_NULLABLE=1008, CharacterAttributePtr = 0x04110020, BufferLength = 600, StringLengthPtr = 0x001B1B28, NumericAttributePtr = 0x001B6FF8, fFieldIndentifier Type = SQL_C_SLONG=-16 Return: SQL_SUCCESS=0 Out: *CharacterAttributePtr = <unmodified>, *StringLengthPtr = <unmodified>, *NumericAttributePtr = 0
[25 Jan 2010 15:57]
Tonci Grgin
To be checked with Bug#49655.
[10 Jul 2012 9:22]
Hemant Dangi
--------------------------------------------------------------------------
REFINED PROBLEM DESCRIPTION
===========================
For auto-increment and timestamp field with auto-update/auto-set, we can
insert
NULL. So this make them SQL_NULLABLE field.
where,
SQL_NULLABLE: The column allows NULL values.
(http://msdn.microsoft.com/en-us/library/windows/desktop/ms716289(v=vs.85).asp
x)
And same is used in code implementation. For auto-increment and
timestamp_flag (auto-update
and auto-initialize Timestamp ) columns SQL_NULLABLE is present.
if ((field->flags & NOT_NULL_FLAG) &&
!(field->flags & TIMESTAMP_FLAG) &&
!(field->flags & AUTO_INCREMENT_FLAG))
irrec->nullable= SQL_NO_NULLS;
else
irrec->nullable= SQL_NULLABLE;
If a field has TIMESTAMP_FLAG set, it's an auto-updating timestamp
field, and NULL can be stored to it (although it gets turned into
something else).
--------------------------------------------------------------------------
[10 Jul 2012 9:23]
Hemant Dangi
Closing as SQL_NULLABLE implementation in myodbc is consistent with MSDN definition of SQL_NULLABLE on http://msdn.microsoft.com/en-us/library/windows/desktop/ms716289(v=vs.85).aspx

Description: MySQL 5.0.67 community MySQL ODBC 5.1 Driver 5.01.05.00 SQLColAttribute returns incorrect info SQL_NULLABLE (1) for column that has a default whereas column does not allow null. MySQL ODBC driver 3.51.21.00 returns the correct info. SQLLEN nDescNullable = SQL_NULLABLE_UNKNOWN; rc = SQLColAttribute( hstmt, nCol, SQL_DESC_NULLABLE, NULL, 0, NULL, &nDescNullable ); How to repeat: create table test_null( col1 int not null, ctrl_ins_dtm timestamp not null default current_timestamp, ctrl_upd_dtm timestamp not null, primary key (col1) ); execute SQLColAttribute SQL_DESC_NULLABLE on select * from the table, driver returns incorrect null info for column ctrl_ins_dtm (2nd column in the resultset) I am guessing that the column having a default is somehow a factor since 1st and 3rd columns nullable info is returned correctly.