Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 314109 Details for
Bug 458708
SQLGetDiagRec() segfaults on end of diagnostic data
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
C program exhibiting the bug described
TestCase.c (text/x-csrc), 2.25 KB, created by
Patrick Monnerat
on 2008-08-12 15:50:19 UTC
(
hide
)
Description:
C program exhibiting the bug described
Filename:
MIME Type:
Creator:
Patrick Monnerat
Created:
2008-08-12 15:50:19 UTC
Size:
2.25 KB
patch
obsolete
>#include <stdio.h> >#include <sqlext.h> > >#define DSN "<put your DSN name here>" >#define USER "<put the authentication user name here>" >#define PASSWORD "<put the authentication password here>" >#define TABLE "<put the table name here>" >#define FIELD "<put the name of a char field in table here>" > >void SqShowDiagRecs(SQLSMALLINT hndType, SQLHANDLE hnd) >{ > SQLCHAR SqState[6]; > SQLINTEGER nativeError; > SQLCHAR messageText[81]; > SQLSMALLINT bufferLength; > SQLSMALLINT textLength; > SQLRETURN SqReturn; > SQLSMALLINT recNumber; > > bufferLength = sizeof messageText; > > for (recNumber = 1;; recNumber++) { > SqReturn = SQLGetDiagRec(hndType, hnd, recNumber, SqState, &nativeError, messageText, bufferLength, &textLength); > if (SqReturn == SQL_SUCCESS || SqReturn == SQL_SUCCESS_WITH_INFO) { > printf ("(%d) %s (%ld) %s\n", recNumber, SqState, nativeError, messageText); > } > else break; > } >} > >int main() >{ > SQLHANDLE SqEnv; > SQLHANDLE SqDbc; > SQLHANDLE SqStmt; > SQLRETURN SqReturn; > SQLCHAR colName[17]; > SQLSMALLINT colNameAvl; > SQLSMALLINT colType; > SQLULEN colSize; > SQLSMALLINT colDecd; > SQLSMALLINT colNull; > > char name[21]; // name is shorter than the corresponding data base field > > SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &SqEnv); > SQLSetEnvAttr(SqEnv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)(SQL_OV_ODBC3), 0); > SQLAllocHandle(SQL_HANDLE_DBC, SqEnv, &SqDbc); > SQLConnect(SqDbc, (SQLCHAR *) DSN, SQL_NTS, > (SQLCHAR *) USER, SQL_NTS, (SQLCHAR *) PASSWORD, SQL_NTS); > > SQLAllocHandle(SQL_HANDLE_STMT, SqDbc, &SqStmt); > SQLPrepare(SqStmt, > (SQLCHAR *) "select " FIELD " from " TABLE, SQL_NTS); > SQLExecute(SqStmt); > SQLDescribeCol(SqStmt, 1, colName, sizeof colName - 1, > &colNameAvl, &colType, &colSize, &colDecd, &colNull); > SQLBindCol(SqStmt, 1, SQL_C_CHAR, (SQLPOINTER) name, > (colSize < sizeof name? colSize: sizeof name) - 1, (SQLLEN *) NULL); > > for (;;) { > SqReturn = SQLFetch(SqStmt); > if (SqReturn == SQL_SUCCESS || SqReturn == SQL_SUCCESS_WITH_INFO) { > if (SqReturn == SQL_SUCCESS_WITH_INFO) { > SqShowDiagRecs(SQL_HANDLE_STMT, SqStmt); > } > printf ("Name: %s\n", name); > } > else break; > } > > SQLFreeHandle(SQL_HANDLE_STMT, SqStmt); > SQLDisconnect(SqDbc); > SQLFreeHandle(SQL_HANDLE_DBC, SqDbc); > SQLFreeHandle(SQL_HANDLE_ENV, SqEnv); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 458708
: 314109