Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of SQLSetDescRec & SQLGetDescRec functions #23

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions descriptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,8 @@ static const struct
{ DESC_OPTION_NOT_FOR_THE_DRIVER, "HYC00", "HYC00" },
{ DESC_FETCH_OUT_OF_RANGE, "HY106", "S1106" },
{ DESC_COUNT_FIELD_INCORRECT, "07002", "07002" },
{ DESC_STATEMENT_NOT_PREPARED, "HY007", "S1010" },
{ DESC_STRING_DATA_TRUNCATED, "01004", "01004"}
};

static PG_ErrorInfo *DC_create_errorinfo(const DescriptorClass *self)
Expand Down
2 changes: 2 additions & 0 deletions descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,7 @@ enum {
,DESC_OPTION_NOT_FOR_THE_DRIVER
,DESC_FETCH_OUT_OF_RANGE
,DESC_COUNT_FIELD_INCORRECT
,DESC_STATEMENT_NOT_PREPARED
,DESC_STRING_DATA_TRUNCATED
};
#endif /* __DESCRIPTOR_H__ */
4 changes: 2 additions & 2 deletions info.c
Original file line number Diff line number Diff line change
Expand Up @@ -1565,18 +1565,18 @@ PGAPI_GetFunctions(HDBC hdbc,
case SQL_API_SQLFREEHANDLE: /* 1006 */
case SQL_API_SQLGETCONNECTATTR: /* 1007 */
case SQL_API_SQLGETDESCFIELD: /* 1008 */
case SQL_API_SQLGETDESCREC: /* 1009 */
case SQL_API_SQLGETDIAGFIELD: /* 1010 */
case SQL_API_SQLGETDIAGREC: /* 1011 */
case SQL_API_SQLGETENVATTR: /* 1012 */
case SQL_API_SQLGETSTMTATTR: /* 1014 */
case SQL_API_SQLSETCONNECTATTR: /* 1016 */
case SQL_API_SQLSETDESCFIELD: /* 1017 */
case SQL_API_SQLSETDESCREC: /* 1018 */
case SQL_API_SQLSETENVATTR: /* 1019 */
case SQL_API_SQLSETSTMTATTR: /* 1020 */
*pfExists = TRUE;
break;
case SQL_API_SQLGETDESCREC: /* 1009 */
case SQL_API_SQLSETDESCREC: /* 1018 */
case SQL_API_SQLCOPYDESC: /* 1004 */
*pfExists = FALSE;
break;
Expand Down
32 changes: 18 additions & 14 deletions odbcapi30.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,14 @@ SQLGetDescRec(SQLHDESC DescriptorHandle,
SQLLEN *Length, SQLSMALLINT *Precision,
SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
{
MYLOG(0, "Entering\n");
MYLOG(0, "Error not implemented\n");
return SQL_ERROR;
RETCODE ret;

MYLOG(0, "Entering h=%p rec=%d name=%p blen=%d\n", DescriptorHandle, RecNumber, Name, BufferLength);
MYLOG(0, "str=%p type=%p sub=%p len=%p prec=%p scale=%p null=%p\n", StringLength, Type, SubType, Length, Precision, Scale, Nullable);
ret = PGAPI_GetDescRec(DescriptorHandle, RecNumber, Name, BufferLength,
StringLength, Type, SubType, Length, Precision,
Scale, Nullable);
return ret;
}

/* new function */
Expand Down Expand Up @@ -459,9 +464,14 @@ SQLSetDescRec(SQLHDESC DescriptorHandle,
PTR Data, SQLLEN *StringLength,
SQLLEN *Indicator)
{
MYLOG(0, "Entering\n");
MYLOG(0, "Error not implemented\n");
return SQL_ERROR;
RETCODE ret;

MYLOG(0, "Entering h=%p rec=%d type=%d sub=%d len=" FORMAT_LEN " prec=%d scale=%d data=%p\n", DescriptorHandle, RecNumber, Type, SubType, Length, Precision, Scale, Data);
MYLOG(0, "str=%p ind=%p\n", StringLength, Indicator);
ret = PGAPI_SetDescRec(DescriptorHandle, RecNumber, Type,
SubType, Length, Precision, Scale, Data,
StringLength, Indicator);
return ret;
}
#endif /* UNICODE_SUPPORTXX */

Expand Down Expand Up @@ -646,20 +656,14 @@ MYLOG(DETAIL_LOG_LEVEL, "lie=%d\n", ci->drivers.lie);
SQL_FUNC_ESET(pfExists, SQL_API_SQLFREEHANDLE); /* 1006 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCONNECTATTR); /* 1007 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCFIELD); /* 1008 */
if (ci->drivers.lie)
{
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCREC); /* 1009 not implemented yet */
}
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCREC); /* 1009 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGFIELD); /* 1010 minimal implementation */
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGREC); /* 1011 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETENVATTR); /* 1012 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETSTMTATTR); /* 1014 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCONNECTATTR); /* 1016 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCFIELD); /* 1017 */
if (ci->drivers.lie)
{
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCREC); /* 1018 not implemented yet */
}
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCREC); /* 1018 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETENVATTR); /* 1019 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSTMTATTR); /* 1020 */
SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCHSCROLL); /* 1021 */
Expand Down
61 changes: 55 additions & 6 deletions odbcapi30w.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,37 @@ SQLGetDescRecW(SQLHDESC DescriptorHandle,
SQLLEN *Length, SQLSMALLINT *Precision,
SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
{
MYLOG(0, "Entering\n");
MYLOG(0, "Error not implemented\n");
return SQL_ERROR;
RETCODE ret;
char *NameA = NULL;
SQLSMALLINT nlen;

MYLOG(0, "Entering h=%p rec=%d name=%p blen=%d\n", DescriptorHandle, RecNumber, Name, BufferLength);
MYLOG(0, "str=%p type=%p sub=%p len=%p prec=%p scale=%p null=%p\n", StringLength, Type, SubType, Length, Precision, Scale, Nullable);

if (BufferLength > 0)
NameA = malloc(BufferLength);

ret = PGAPI_GetDescRec(DescriptorHandle, RecNumber, (SQLCHAR *) NameA, BufferLength,
&nlen, Type, SubType, Length, Precision,
Scale, Nullable);
if (SQL_SUCCEEDED(ret))
{
if (NameA && nlen <= BufferLength)
{
SQLULEN ulen = utf8_to_ucs2_lf(NameA, nlen, FALSE, Name, BufferLength, TRUE);
if (ulen == (SQLULEN) -1)
nlen = (SQLSMALLINT) locale_to_sqlwchar((SQLWCHAR *) Name, NameA, BufferLength, FALSE);
else
nlen = (SQLSMALLINT) ulen;
if (nlen >= BufferLength)
ret = SQL_SUCCESS_WITH_INFO;
}
if (StringLength)
*StringLength = nlen;
}
if (NameA)
free(NameA);
return ret;
}

/* new function */
Expand All @@ -440,7 +468,28 @@ SQLSetDescRecW(SQLHDESC DescriptorHandle,
PTR Data, SQLLEN *StringLength,
SQLLEN *Indicator)
{
MYLOG(0, "Entering\n");
MYLOG(0, "Error not implemented\n");
return SQL_ERROR;
RETCODE ret;
SQLLEN vallen;
char *uval = NULL;
BOOL val_alloced = FALSE;

MYLOG(0, "Entering h=%p rec=%d type=%d sub=%d len=" FORMAT_LEN " prec=%d scale=%d data=%p\n", DescriptorHandle, RecNumber, Type, SubType, Length, Precision, Scale, Data);
MYLOG(0, "str=%p ind=%p\n", StringLength, Indicator);

if (Length > 0 || SQL_NTS == Length)
{
uval = ucs2_to_utf8(Data, Length > 0 ? Length / WCLEN : Length, &vallen, FALSE);
val_alloced = TRUE;
}
if (!val_alloced)
{
uval = Data;
vallen = Length;
}
ret = PGAPI_SetDescRec(DescriptorHandle, RecNumber, Type,
SubType, Length, Precision, Scale, uval,
&vallen, Indicator);
if (val_alloced)
free(uval);
return ret;
}
Loading