Skip to content

Commit 2c0b95b

Browse files
committed
Merge branch 'odbc-3.1'
2 parents 520cb30 + 74d6447 commit 2c0b95b

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

driver/ma_statement.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3467,13 +3467,18 @@ SQLRETURN MADB_StmtDescribeCol(MADB_Stmt *Stmt, SQLUSMALLINT ColumnNumber, void
34673467
if (NullablePtr)
34683468
*NullablePtr= Record->Nullable;
34693469

3470-
if ((ColumnName || BufferLength) && Record->ColumnName)
3470+
if ((ColumnName || NameLengthPtr) && Record->ColumnName)
34713471
{
3472-
size_t Length= MADB_SetString(isWChar ? &Stmt->Connection->Charset : 0, ColumnName, ColumnName ? BufferLength : 0, Record->ColumnName, SQL_NTS, &Stmt->Error);
3472+
size_t Length= MADB_SetString(isWChar ? &Stmt->Connection->Charset : 0, ColumnName,
3473+
ColumnName ? BufferLength : 0, Record->ColumnName, SQL_NTS, &Stmt->Error);
34733474
if (NameLengthPtr)
3475+
{
34743476
*NameLengthPtr= (SQLSMALLINT)Length;
3475-
if (!BufferLength)
3476-
MADB_SetError(&Stmt->Error, MADB_ERR_01004, nullptr, 0);
3477+
}
3478+
if (ColumnName && !BufferLength)
3479+
{
3480+
MADB_SetError(&Stmt->Error, MADB_ERR_01004, NULL, 0);
3481+
}
34773482
}
34783483
return Stmt->Error.ReturnValue;
34793484
}

test/desc.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ ODBC_TEST(t_odbc216)
815815
return OK;
816816
}
817817

818-
/* */
818+
/* ODBC-211 SQLDescribeCol return precision=0 for field type decimal(1,0) */
819819
ODBC_TEST(t_odbc211)
820820
{
821821
SQLLEN Size= 0;
@@ -938,6 +938,26 @@ ODBC_TEST(t_odbc211)
938938
}
939939

940940

941+
/*
942+
ODBC-480 - SQLDescribeCol does not return column name length if if column name buf ptr
943+
and buffer lenght are not 0
944+
*/
945+
ODBC_TEST(t_odbc480)
946+
{
947+
SQLSMALLINT colNameLen;
948+
949+
CHECK_STMT_RC(Stmt, SQLExecDirect(Stmt,
950+
"SELECT 1 AS someColumnName1"
951+
, SQL_NTS));
952+
953+
CHECK_STMT_RC(Stmt, SQLDescribeCol(Stmt, 1, NULL, 0, &colNameLen,
954+
NULL, NULL, NULL, NULL));
955+
956+
is_num(colNameLen, sizeof("someColumnName1") - 1);
957+
958+
return OK;
959+
}
960+
941961
MA_ODBC_TESTS my_tests[]=
942962
{
943963
{t_desc_paramset,"t_desc_paramset"},
@@ -959,6 +979,7 @@ MA_ODBC_TESTS my_tests[]=
959979
{t_odbc213, "t_odbc213_param_type"},
960980
{t_odbc216, "t_odbc216_fixed_prec_scale"},
961981
{t_odbc211, "t_odbc211_zero_scale"},
982+
{t_odbc480, "t_odbc480_col_name_len"},
962983
{NULL, NULL}
963984
};
964985

0 commit comments

Comments
 (0)