コード例 #1
0
ファイル: fncontrol.c プロジェクト: bschurig/ps2avrU
void enterFrameForFnControl(void){
    if(isReleaseAll()){
        applyLock(&_isLockKey);
        applyLock(&_isLockWin);
    }
    if(isReleaseAllPrev() && _isReadyQuickMacro){
        _isReadyQuickMacro = false;
        if(_quickMacroIndex < 255) {
            startQuickMacro(_quickMacroIndex);
            _quickMacroIndex = 255;
        }
    }
}
コード例 #2
0
RETCODE SQL_API SQLGetStmtOption(
    SQLHSTMT     hstmt,
    UWORD        fOption,
    SQLPOINTER   pvParamParameter)
{
    RETCODE rc, traceRet = 1;
    pSTMT pstmt = (pSTMT)hstmt;
    
    ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLGetStmtOption(hstmt, fOption,
        pvParamParameter), traceRet);

    if (pstmt->hdr.driverHandle)
    {
        resetErrorBuff(pstmt, SQL_HANDLE_STMT);

        rc = IIGetStmtOption(
            pstmt->hdr.driverHandle,
            fOption,
            pvParamParameter);

        applyLock(SQL_HANDLE_STMT, pstmt);
        if (rc != SQL_SUCCESS)
        {
            pstmt->hdr.driverError = TRUE;
            pstmt->errHdr.rc = rc;
        }
        releaseLock(SQL_HANDLE_STMT, pstmt);
    }
    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #3
0
SQLRETURN  SQL_API SQLGetStmtAttr (
    SQLHSTMT     StatementHandle,
    SQLINTEGER   Attribute,
    SQLPOINTER   ValuePtr,
    SQLINTEGER   BufferLength,
    SQLINTEGER  *pStringLength)
{
    RETCODE rc, traceRet = 1;
    pSTMT pstmt = (pSTMT)StatementHandle;

    ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLGetStmtAttr(StatementHandle,
        Attribute, ValuePtr, BufferLength, pStringLength), traceRet);

    if (pstmt->hdr.driverHandle)
    {
        resetErrorBuff(pstmt, SQL_HANDLE_STMT);
        rc = IIGetStmtAttr (
            pstmt->hdr.driverHandle,
            Attribute,
            ValuePtr,
            BufferLength,
            pStringLength);

        applyLock(SQL_HANDLE_STMT, pstmt);
        if (rc != SQL_SUCCESS)
        {
            pstmt->hdr.driverError = TRUE;
            pstmt->errHdr.rc = rc;
        }
        releaseLock(SQL_HANDLE_STMT, pstmt);
    }
    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #4
0
SQLRETURN SQL_API SQLParamOptions(
    SQLHSTMT     hstmt,
    UDWORD       crow,
    UDWORD     * pirow)
{
    RETCODE rc, traceRet = 1;
    pSTMT pstmt = (pSTMT)hstmt;

    ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLParamOptions (hstmt, crow, pirow),
        traceRet);

    if (validHandle(hstmt, SQL_HANDLE_STMT) != SQL_SUCCESS)
    {
        ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, SQL_INVALID_HANDLE));
        return SQL_INVALID_HANDLE;
    }

    resetErrorBuff(hstmt, SQL_HANDLE_STMT);

    rc =  IIParamOptions(
        pstmt->hdr.driverHandle,
        crow,
        pirow);

    applyLock(SQL_HANDLE_STMT, pstmt);
    if (rc != SQL_SUCCESS)
    {
        pstmt->hdr.driverError = TRUE;
        pstmt->errHdr.rc = rc;
    }
    releaseLock(SQL_HANDLE_STMT, pstmt);

    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #5
0
RETCODE SQL_API SQLGetConnectOption(
    SQLHDBC    hdbc,
    UWORD      fOption,
    SQLPOINTER pvParam)
{
    RETCODE rc, traceRet = 1;
    pDBC pdbc = (pDBC)hdbc;

    ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLGetConnectOption(hdbc, fOption,
       pvParam), traceRet);

    if (!pdbc)
    {
        ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, SQL_INVALID_HANDLE));
        return SQL_INVALID_HANDLE;
    }

    resetErrorBuff(hdbc, SQL_HANDLE_DBC);

    rc = IIGetConnectOption(
        pdbc->hdr.driverHandle,
        fOption,
        pvParam);

    applyLock(SQL_HANDLE_DBC, pdbc);
    if (rc != SQL_SUCCESS)
    {
        pdbc->hdr.driverError = TRUE;
        pdbc->errHdr.rc = rc;
    }
    releaseLock(SQL_HANDLE_DBC, pdbc);

    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #6
0
SQLRETURN SQL_API SQLPrepare(
    SQLHSTMT      hstmt,
    UCHAR       * szSqlStr,
    SDWORD        cbSqlStr)
{
    RETCODE rc, traceRet = 1;
    pSTMT pstmt = (pSTMT)hstmt;
    pDBC pdbc;

    ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLPrepare(hstmt, szSqlStr, 
         cbSqlStr), traceRet);

    if (validHandle((SQLHANDLE)pstmt, SQL_HANDLE_STMT) != SQL_SUCCESS)
    {
        ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, SQL_INVALID_HANDLE));
        return SQL_INVALID_HANDLE;
    }

    resetErrorBuff((SQLHANDLE)pstmt, SQL_HANDLE_STMT);
    pdbc = pstmt->pdbc;
 
	if (!szSqlStr)
    {
        insertErrorMsg((SQLHANDLE)pstmt, SQL_HANDLE_STMT, SQL_HY009,
            SQL_ERROR, NULL, 0);
        ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, SQL_ERROR));
        return SQL_ERROR;
    }

    rc = IIPrepare( pstmt->hdr.driverHandle,
        szSqlStr,
        cbSqlStr);

    applyLock(SQL_HANDLE_STMT, pstmt);
    if (rc != SQL_SUCCESS)
    {
        pstmt->hdr.driverError = TRUE;
        pstmt->errHdr.rc = rc;
    }

    if (SQL_SUCCEEDED(rc))
    {
       if (!pdbc->autocommit)
            pdbc->hdr.state = C6;
       if (pstmt->hdr.state == S1)
            if (pstmt->select || pstmt->execproc)
                pstmt->hdr.state = S3;
            else
                pstmt->hdr.state = S2;
    }
    else
        pstmt->hdr.state = S1;
    releaseLock(SQL_HANDLE_STMT, pstmt);

    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #7
0
RETCODE SQL_API SQLSetConnectOption(
    SQLHDBC    hdbc,
    UWORD      fOption,
    SQLUINTEGER vParam)
{
    RETCODE rc, traceRet = 1;
    pDBC pdbc = (pDBC)hdbc;
    IISETCONNECTOPTION_PARAM *iiSetConnectOptionParam;

    ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLSetConnectOption(hdbc,
        fOption, vParam), traceRet);

    if (!hdbc)
    {
        ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, SQL_INVALID_HANDLE));
        return SQL_INVALID_HANDLE;
    }
    /*
    **  If the driver isn't loaded yet, set a placeholder to do this 
    **  later.
    */
    if ( !IISetConnectOption )
    {
        iiSetConnectOptionParam = 
            (IISETCONNECTOPTION_PARAM *)MEreqmem(0, 
            sizeof(IISETCONNECTOPTION_PARAM), TRUE, NULL);
        QUinsert((QUEUE *)iiSetConnectOptionParam, &pdbc->setConnectOption_q);
        iiSetConnectOptionParam->ConnectionHandle = hdbc;
        iiSetConnectOptionParam->Option = fOption;
        iiSetConnectOptionParam->Value = vParam;
        pdbc->setConnectOption_count++;
        ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, SQL_SUCCESS));
        return SQL_SUCCESS;
    }
    else
    {
        resetErrorBuff(pdbc, SQL_HANDLE_DBC);

        rc = IISetConnectOption(
            pdbc->hdr.driverHandle,
            fOption,
            vParam);

        applyLock(SQL_HANDLE_DBC, pdbc);
        if (rc != SQL_SUCCESS)
        {
            pdbc->hdr.driverError = TRUE;
            pdbc->errHdr.rc = rc;
        }
        else if (fOption == SQL_ATTR_AUTOCOMMIT)
            pdbc->autocommit = TRUE;
        releaseLock(SQL_HANDLE_DBC, pdbc);
    }

    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #8
0
RETCODE SQL_API SQLSetStmtAttr(
    SQLHSTMT   hstmt,
    SQLINTEGER fOption,
    SQLPOINTER ValuePtr,
    SQLINTEGER StringLength)
{
    RETCODE rc, traceRet = 1;
    pSTMT pstmt = (pSTMT)hstmt;
    
    ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLSetStmtAttr(hstmt, fOption,
        ValuePtr, StringLength), traceRet);

    if (validHandle(pstmt, SQL_HANDLE_STMT) != SQL_SUCCESS)
    {
        ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, SQL_INVALID_HANDLE));
        return SQL_INVALID_HANDLE;
    }
    else
        resetErrorBuff(hstmt, SQL_HANDLE_STMT);

    switch (fOption)
    {
    case SQL_ATTR_USE_BOOKMARKS: 
    case SQL_ATTR_CONCURRENCY: 
    case SQL_ATTR_CURSOR_TYPE:
    case SQL_ATTR_SIMULATE_CURSOR: 
        if (pstmt->hdr.state >= S3)
        {
            rc = SQL_ERROR;
            {
                ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
                return rc;
            }
        }
        break;
    }
     
    rc = IISetStmtAttr(
        pstmt->hdr.driverHandle,
        fOption,
        ValuePtr,
        StringLength);

    applyLock(SQL_HANDLE_STMT, pstmt);
    if (rc != SQL_SUCCESS)
    {
        pstmt->hdr.driverError = TRUE;
        pstmt->errHdr.rc = rc;
    }
    releaseLock(SQL_HANDLE_STMT, pstmt);

    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #9
0
SQLRETURN SQL_API SQLNativeSql(
    SQLHDBC     hdbc,
    SQLCHAR   * InStatementText,
    SQLINTEGER  TextLength1,
    SQLCHAR   * OutStatementText,
    SQLINTEGER  BufferLength,
    SQLINTEGER* pcbValue)
{
    RETCODE rc, traceRet = 1;
    pDBC pdbc = (pDBC)hdbc;

    ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLNativeSql(hdbc, InStatementText,
        TextLength1, OutStatementText, BufferLength, pcbValue), traceRet);

    if (!BufferLength)
        BufferLength = SQL_MAX_MESSAGE_LENGTH;

    if (validHandle(hdbc, SQL_HANDLE_DBC) != SQL_SUCCESS)
    {
        ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, SQL_INVALID_HANDLE));
        return SQL_INVALID_HANDLE;
    }

    resetErrorBuff(hdbc, SQL_HANDLE_DBC);

    rc =  IINativeSql(
        pdbc->hdr.driverHandle,
        InStatementText,
        TextLength1,
        OutStatementText,
        BufferLength,
        pcbValue);

    applyLock(SQL_HANDLE_DBC, pdbc);
    if (rc != SQL_SUCCESS)
    {
        pdbc->hdr.driverError = TRUE;
        pdbc->errHdr.rc = rc;
    }
    releaseLock(SQL_HANDLE_DBC, pdbc);

    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #10
0
SQLRETURN SQL_API SQLBindParameter(
    SQLHSTMT      hstmt,        /* StatementHandle  */
    UWORD         ipar,         /* ParameterNumber  */
    SWORD         fParamType,   /* InputOutputType  */
    SWORD         fCType,       /* ValueType        */
    SWORD         fSqlType,     /* ParameterType    */
    SQLUINTEGER   cbColDef,     /* ColumnSize       */
    SWORD         ibScale,      /* DecimalDigits    */
    SQLPOINTER    rgbValue,     /* ParameterValuePtr*/
    SQLINTEGER    cbValueMax,   /* BufferLength     */
    SQLINTEGER   *pcbValue)    /* StrLen_or_IndPtr */
{
    RETCODE rc, traceRet = 1;
    pSTMT pstmt = (pSTMT)hstmt;

    ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLBindParameter(hstmt, ipar, 
        fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue,
        cbValueMax, pcbValue), traceRet);

    rc =  IIBindParameter(
        pstmt->hdr.driverHandle,
        ipar,        
        fParamType, 
        fCType,    
        fSqlType, 
        cbColDef,
        ibScale,
        rgbValue,     
        cbValueMax,  
        pcbValue);

    applyLock(SQL_HANDLE_STMT, pstmt);
    if (rc != SQL_SUCCESS)
    {
        pstmt->hdr.driverError = TRUE;
        pstmt->errHdr.rc = rc;
    }
    releaseLock(SQL_HANDLE_STMT, pstmt);

    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #11
0
SQLRETURN  SQL_API SQLBindParam(
    SQLHSTMT StatementHandle,
    SQLUSMALLINT ParameterNumber,
    SQLSMALLINT ValueType,
    SQLSMALLINT ParameterType, 
    SQLUINTEGER LengthPrecision,
    SQLSMALLINT ParameterScale, 
    SQLPOINTER ParameterValue,
    SQLINTEGER *StrLen_or_Ind)
{
    RETCODE rc, traceRet = 1;
    pSTMT pstmt = (pSTMT)StatementHandle;

    ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLBindParam(StatementHandle,
        ParameterNumber, ValueType, ParameterType, LengthPrecision,
        ParameterScale, ParameterValue, StrLen_or_Ind), traceRet);

    rc =  IIBindParameter(
        pstmt->hdr.driverHandle,
        ParameterNumber,
        SQL_PARAM_OUTPUT,
        ValueType,
        ParameterType,
        LengthPrecision,
        ParameterScale,
        ParameterValue,
        0,
        StrLen_or_Ind);

    applyLock(SQL_HANDLE_STMT, pstmt);
    if (rc != SQL_SUCCESS)
    {
        pstmt->hdr.driverError = TRUE;
        pstmt->errHdr.rc = rc;
    }

    releaseLock(SQL_HANDLE_STMT, pstmt);
    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #12
0
SQLRETURN SQL_API SQLSetCursorName(
    SQLHSTMT      hstmt,
    UCHAR       * szCursorParameter,
    SWORD         cbCursor)
{   
    RETCODE rc, traceRet = 1;
    pSTMT pstmt = (pSTMT)hstmt;

    ODBC_TRACE_ENTRY(ODBC_TR_TRACE,  IITraceSQLSetCursorName(hstmt, 
         szCursorParameter, cbCursor), traceRet);

    if (validHandle(hstmt, SQL_HANDLE_STMT) != SQL_SUCCESS)
    {
        ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, SQL_INVALID_HANDLE));
        return SQL_INVALID_HANDLE;
    }

    resetErrorBuff(hstmt, SQL_HANDLE_STMT);

    rc =  IISetCursorName(
        pstmt->hdr.driverHandle,
        szCursorParameter,
        cbCursor);

    applyLock(SQL_HANDLE_STMT, pstmt);
    if (rc != SQL_SUCCESS)
    {
        pstmt->hdr.driverError = TRUE;
        pstmt->errHdr.rc = rc;
    }
    else if (SQL_SUCCEEDED(rc))
    {
        pstmt->prepared = TRUE;
    }
    releaseLock(SQL_HANDLE_STMT, pstmt);
    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #13
0
/*
** Name: 	SQLCloseCursor - Close a cursor.
** 
** Description: 
**              SQLCloseCursor closes a cursor that has been opened on a 
**              statement and discards pending results.
**
** Inputs:
**              StatementHandle.
**
** Outputs: 
**              None.
**
** Returns: 
**              SQL_SUCCESS
**              SQL_SUCCESS_WITH_INFO
**              SQL_ERROR
**              SQL_INVALID_HANDLE
**
** Exceptions: 
**       
**              N/A 
** 
** Side Effects: 
** 
**              None.
**
** History: 
**    14-jun-04 (loera01)
**      Created.
*/ 
SQLRETURN  SQL_API SQLCloseCursor (
    SQLHSTMT StatementHandle)
{
    RETCODE rc, traceRet = 1;
    pSTMT pstmt = (pSTMT)StatementHandle;

    ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLCloseCursor(StatementHandle), 
         traceRet);

    if (validHandle((SQLHANDLE)pstmt, SQL_HANDLE_STMT) != SQL_SUCCESS)
    {
        ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, SQL_INVALID_HANDLE));
        return SQL_INVALID_HANDLE;
    }

    resetErrorBuff((SQLHANDLE)pstmt, SQL_HANDLE_STMT);

    rc =  IICloseCursor(
        pstmt->hdr.driverHandle);

    applyLock(SQL_HANDLE_STMT, pstmt);
    if (rc != SQL_SUCCESS)
    {
        pstmt->hdr.driverError = TRUE;
        pstmt->errHdr.rc = rc;
    }
    else if (SQL_SUCCEEDED(rc))
    {
        if (pstmt->prepared)
            pstmt->hdr.state = S3;
        else
            pstmt->hdr.state = S1;
    }

    releaseLock(SQL_HANDLE_STMT, pstmt);
    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #14
0
RETCODE SQL_API SQLSetStmtOption(
    SQLHSTMT hstmt,
    SQLUSMALLINT fOption,
    SQLUINTEGER  vParam)
{
    RETCODE rc, traceRet = 1;
    pSTMT pstmt = (pSTMT)hstmt;
    
    ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLSetStmtOption( hstmt, fOption,
        vParam), traceRet);

    if (validHandle(pstmt, SQL_HANDLE_STMT) != SQL_SUCCESS)
    {
        ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, SQL_INVALID_HANDLE));
        return SQL_INVALID_HANDLE;
    }
    else
    {
        resetErrorBuff(hstmt, SQL_HANDLE_STMT);

        rc = IISetStmtOption(
            pstmt->hdr.driverHandle,
            fOption,
            vParam);

        applyLock(SQL_HANDLE_STMT, pstmt);
        if (rc != SQL_SUCCESS)
        {
            pstmt->hdr.driverError = TRUE;
            pstmt->errHdr.rc = rc;
        }
        releaseLock(SQL_HANDLE_STMT, pstmt);
    }
    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #15
0
SQLRETURN SQL_API SQLAllocStmt(
    SQLHDBC     hdbc,
    SQLHSTMT  * phstmt)
{
    pSTMT pstmt;
    pDBC pdbc = (pDBC)hdbc;
    RETCODE rc, traceRet = 1;

    ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLAllocStmt(hdbc, phstmt), traceRet);
    rc = IIodbc_allocStmt(pdbc, (pSTMT *)phstmt); 

    if (rc == SQL_SUCCESS)
    {
        pstmt = (pSTMT) *phstmt;

        rc = IIAllocStmt(
            pdbc->hdr.driverHandle,
            &pstmt->hdr.driverHandle);


        applyLock(SQL_HANDLE_STMT, pstmt);
        if (rc != SQL_SUCCESS)
        {
            pdbc->hdr.driverError = TRUE;
            pdbc->errHdr.rc = rc;
	}
        else
        {
            pstmt->hdr.state = S1;
            pdbc->hdr.state = C5;
        }
        releaseLock(SQL_HANDLE_STMT, pstmt);
    }
    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #16
0
RETCODE SQL_API SQLGetConnectAttr(
    SQLHDBC     hdbc,
    SQLINTEGER  fOption,
    SQLPOINTER  pvParamParameter,
    SQLINTEGER  BufferLength,
    SQLINTEGER *pStringLength)
{
    RETCODE rc = SQL_SUCCESS, traceRet = 1;
    pDBC pdbc = (pDBC)hdbc;
    SQLUINTEGER *pvParam = (SQLUINTEGER *)pvParamParameter;
    SQLINTEGER   StringLength = sizeof(SQLUINTEGER); 

    ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLGetConnectAttr(hdbc,
         fOption, pvParamParameter, BufferLength, pStringLength), traceRet);

    if (!hdbc)
    {
        rc = SQL_INVALID_HANDLE;
        goto exit_routine;
    }
    
    if ( !pdbc->hdr.driverHandle )
    {
        if (fOption == SQL_ATTR_LOGIN_TIMEOUT)
        {
            *pvParam = 15;
            *pStringLength = StringLength;
            rc = SQL_SUCCESS;
            goto exit_routine;
        }
    }
    else if (fOption == SQL_ATTR_CONNECTION_DEAD)
    {
        if (pdbc->hdr.state < C4)
            *pvParam = SQL_CD_TRUE;
        else
            *pvParam = SQL_CD_FALSE;
        rc =  SQL_SUCCESS;
        goto exit_routine;
    }
    else
    {
        resetErrorBuff(pdbc, SQL_HANDLE_DBC);
        rc = IIGetConnectAttr(
            pdbc->hdr.driverHandle,
            fOption,
            pvParamParameter,
            BufferLength,
            pStringLength);
    }

    applyLock(SQL_HANDLE_DBC, pdbc);
    if (rc != SQL_SUCCESS)
    {
        pdbc->hdr.driverError = TRUE;
        pdbc->errHdr.rc = rc;
    }
    releaseLock(SQL_HANDLE_DBC, pdbc);

exit_routine:
    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #17
0
SQLRETURN  SQL_API SQLGetEnvAttr (
    SQLHENV     EnvironmentHandle,
    SQLINTEGER  Attribute,
    SQLPOINTER  ValuePtr,
    SQLINTEGER  BufferLength,
    SQLINTEGER *pStringLength)
{
    RETCODE rc = SQL_SUCCESS, traceRet = 1;
    i4 *pi4 = (i4 *)ValuePtr;
    pENV penv = (pENV)EnvironmentHandle;

    ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLGetEnvAttr(EnvironmentHandle,
         Attribute, ValuePtr, BufferLength, pStringLength), traceRet);

    if (!EnvironmentHandle)
    {
        ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, SQL_INVALID_HANDLE));
        rc = SQL_INVALID_HANDLE;
        goto routine_exit;
    }
    if ( !IIGetEnvAttr )
    {
        /*
        ** Without a loaded driver, we can only report on the attributes
        ** supported in the driver manager.  Pooling attributes are only
        ** reported in the driver manager anyway.
        */
        if (Attribute == SQL_ATTR_ODBC_VERSION)
        {
            if (penv->envAttrValue)
                *pi4 = (i4)(SCALARP)penv->envAttrValue;
            else
                *pi4 = (i4)SQL_OV_ODBC2;
        }
        else if (Attribute == SQL_ATTR_CONNECTION_POOLING)
        {
            if (penv->pooling == DRIVER_POOL)
                *pi4 = (i4)SQL_CP_ONE_PER_DRIVER;
            else if (penv->pooling == HENV_POOL)
                *pi4 = (i4)SQL_CP_ONE_PER_HENV;
            else
                *pi4 = (i4)SQL_CP_OFF;
        }
        else if (Attribute == SQL_ATTR_CP_MATCH)
        {
            if (penv->relaxed_match)
                *pi4 = (i4)SQL_CP_RELAXED_MATCH;
            else
                *pi4 = (i4)SQL_CP_STRICT_MATCH;
        }
        goto routine_exit;
    } /* if ( !IIGetEnvAttr ) */
    
    if (Attribute == SQL_ATTR_CONNECTION_POOLING)
    {
        rc = SQL_SUCCESS;
        if (penv->pooling == DRIVER_POOL)
            *pi4 = (i4)SQL_CP_ONE_PER_DRIVER;
        else if (penv->pooling == HENV_POOL)
            *pi4 = (i4)SQL_CP_ONE_PER_HENV;
        else
            *pi4 = (i4)SQL_CP_OFF;
        goto routine_exit;
    }
    else if (Attribute == SQL_ATTR_CP_MATCH)
    {
        if (penv->relaxed_match)
            *pi4 = (i4)SQL_CP_RELAXED_MATCH;
        else
            *pi4 = (i4)SQL_CP_STRICT_MATCH;
        goto routine_exit;
    }
    else if (Attribute == SQL_ATTR_OUTPUT_NTS)
    {
        *pi4 = (i4)SQL_TRUE;
        goto routine_exit;
    }

    resetErrorBuff(penv, SQL_HANDLE_ENV);

    rc = IIGetEnvAttr (
        penv->hdr.driverHandle,
        Attribute,
        ValuePtr,
        BufferLength,
        pStringLength);

    if (rc != SQL_SUCCESS)
    {
        applyLock(SQL_HANDLE_ENV, penv);
        penv->hdr.driverError = TRUE;
        penv->errHdr.rc = rc;
        releaseLock(SQL_HANDLE_ENV, penv);
    }
 
    /*
    ** Assume ODBC version 2 if the driver returns an unspecified response.
    */
    if (Attribute == SQL_ATTR_ODBC_VERSION && 
        (*(i4 *)ValuePtr !=  SQL_OV_ODBC2 && *(i4 *)ValuePtr != SQL_OV_ODBC3))
        *pi4 = (i4)SQL_OV_ODBC2;

routine_exit:
    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #18
0
/*
** Name: 	SQLFreeStmt - Free a statement handle
** 
** Description: 
**              SQLFreeStmt stops processing associated with a specific 
**              statement, closes any open cursors associated with the 
**              statement, discards pending results, or, optionally, frees 
**              all resources associated with the statement handle.
**
** Inputs:
**              hstmt - Statement handle.
**              fOption - Operation to be performed.
**
** Outputs: 
**              None.
**
** Returns: 
**              SQL_SUCCESS
**              SQL_SUCCESS_WITH_INFO
**              SQL_ERROR
**              SQL_INVALID_HANDLE
**
** Exceptions: 
**       
**              N/A 
** 
** Side Effects: 
** 
**              None.
**
** History: 
**    14-jun-04 (loera01)
**      Created.
*/ 
SQLRETURN SQL_API SQLFreeStmt(
    SQLHSTMT hstmt,
    UWORD   fOption)
{
    RETCODE rc, traceRet = 1;
    pSTMT pstmt = (pSTMT)hstmt;
    pDBC pdbc = pstmt->pdbc;

    ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLFreeStmt(hstmt, fOption), traceRet);

    if (validHandle(hstmt, SQL_HANDLE_STMT) != SQL_SUCCESS)
    {
        rc = SQL_INVALID_HANDLE;
        goto exit_routine;
    }

    resetErrorBuff(hstmt, SQL_HANDLE_STMT);

    if (fOption == SQL_DROP)
    {
        rc = IIFreeHandle(
            SQL_HANDLE_STMT,
            pstmt->hdr.driverHandle);
    }
    else
        rc = IIFreeStmt(
            pstmt->hdr.driverHandle,
            fOption);

    applyLock(SQL_HANDLE_STMT, pstmt);
    if (rc != SQL_SUCCESS)
    {
        pstmt->hdr.driverError = TRUE;
        pstmt->errHdr.rc = rc;
        goto exit_routine;
    }
    if (pstmt->hdr.state >= S4 &&
        pstmt->hdr.state <= S7)
    if (pstmt->prepared)
        pstmt->hdr.state = S2;
    else
        pstmt->hdr.state = S1;
    releaseLock(SQL_HANDLE_STMT, pstmt);

    if (fOption == SQL_DROP)
    {
        if (!IIodbc_freeHandle(SQL_HANDLE_STMT, (void *)pstmt))
            rc = SQL_INVALID_HANDLE;
        else
        {
            applyLock(SQL_HANDLE_DBC, pdbc);
            if (!pdbc->stmt_count && pdbc->hdr.state != C6)
                pdbc->hdr.state = C4;
            releaseLock(SQL_HANDLE_DBC, pdbc);
            rc = SQL_SUCCESS;
        } 
    }

exit_routine:
    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #19
0
void IIodbc_timeOutThread()
{
    QUEUE *q, *p, *pq;
    pENV penv;
    pDBC pdbc;
    RETCODE rc;
    SYSTIME expire_time;
    TM_STAMP stamp;
    char stampStr[TM_SIZE_STAMP];

    ODBC_EXEC_TRACE(ODBC_EX_TRACE)
        ("IIodbc_timeOutThread() with timeout %d\n", IIodbc_cb.timeout);
    while(TRUE)
    {
        /*
        ** Search the pool every thirty seconds and check for expired
        ** connections.  Force disconnect and free from the pool
        ** if the connection handle has passed the expiration time.  
        ** Note that the CLI and driver connection handles are not
        ** freed.  
        */
        PCsleep(30000);
        TMget_stamp(&stamp);
        TMstamp_str(&stamp, stampStr);
        ODBC_EXEC_TRACE(ODBC_EX_TRACE)
            ("IIodbc_timeOutThread woke up at %s\n", stampStr);
        TMnow(&expire_time);
        
        if (IIodbc_cb.pooling == DRIVER_POOL)
        {
            applyLock(SQL_HANDLE_IIODBC_CB, NULL);
            for (q = IIodbc_cb.pool_q.q_prev; q!= &IIodbc_cb.pool_q;
                q = p)
            {
                ODBC_EXEC_TRACE(ODBC_EX_TRACE)
                    ("IIodbc_timeOutThread: driver pool count is %d\n", 
                    IIodbc_cb.pool_count);
                p = q->q_prev;
                pdbc = (pDBC)((pPOOL)q)->pdbc;
                ODBC_EXEC_TRACE(ODBC_EX_TRACE)
                    ("IIodbc_timeOutThread: found conn handle %p with time diff %d\n",pdbc,
                    expire_time.TM_secs - pdbc->expire_time.TM_secs);
                if (expire_time.TM_secs - pdbc->expire_time.TM_secs > 
                    IIodbc_cb.timeout)
                {
                    /*
                    **  Note that the connection handle is not freed, only
                    **  removed from the pool. 
                    */
                    ODBC_EXEC_TRACE(ODBC_EX_TRACE)
                        ("IIodbc_timeOutThread: EXPIRED.  pdbc time is %d vs %d\n",
                        pdbc->expire_time.TM_secs, expire_time.TM_secs);
                    rc = IIDisconnect(pdbc->hdr.driverHandle);
                    QUremove(q);
                    MEfree((PTR)q);
                    IIodbc_cb.pool_count -= 1;
                    ODBC_EXEC_TRACE(ODBC_EX_TRACE)
                        ("new pool count is %d\n",IIodbc_cb.pool_count);
                    applyLock(SQL_HANDLE_DBC, pdbc);
                    pdbc->hdr.state = C2;
                    releaseLock(SQL_HANDLE_DBC, pdbc);
                }
            }
            releaseLock(SQL_HANDLE_IIODBC_CB, NULL);
        }
        else
        {
            for (q = IIodbc_cb.env_q.q_prev; q!= &IIodbc_cb.env_q;
                q = q->q_prev)
            {
                penv = (pENV)q;
                TRdisplay("Found env handle %p\n",penv);
                applyLock(SQL_HANDLE_ENV, penv);
                for (pq = penv->pool_q.q_prev; pq != &penv->pool_q;
                    pq = p)
                {
                    ODBC_EXEC_TRACE(ODBC_EX_TRACE)
                        ("Env pool count is %d\n",penv->pool_count);
                    p = q->q_prev;
                    pdbc = (pDBC)((pPOOL)pq)->pdbc;
                    ODBC_EXEC_TRACE(ODBC_EX_TRACE)
                        ("IIodbc_TimeOutThread: Found conn handle %p with time diff %d\n",pdbc,
                        expire_time.TM_secs - pdbc->expire_time.TM_secs);
                    if (expire_time.TM_secs - pdbc->expire_time.TM_secs
                        > 1)
                    {
                        ODBC_EXEC_TRACE(ODBC_EX_TRACE)
                            ("IIodbc_timeOutThread: EXPIRED.  pdbc time is %d vs %d\n",
                            pdbc->expire_time.TM_secs,   
                            expire_time.TM_secs);
                        rc = IIDisconnect(pdbc->hdr.driverHandle);
                        QUremove(q);
                        MEfree((PTR)q);
                        penv->pool_count -= 1;
                        ODBC_EXEC_TRACE(ODBC_EX_TRACE)
                            ("IIodbc_timeOutThread: new pool count is %d\n",
                            penv->pool_count);
                    }
                }
                releaseLock(SQL_HANDLE_ENV, penv);
            } /* for (q = IIodbc_cb.env_q.q_prev; q!= &IIodbc_cb.env_q;
                q = q->q_prev) */
        } /* if (IIodbc_cb.pooling == DRIVER_POOL) */
    } /* while (TRUE) */
}
コード例 #20
0
SQLRETURN  SQL_API SQLSetEnvAttr (
    SQLHENV    EnvironmentHandle,
    SQLINTEGER Attribute,
    SQLPOINTER ValuePtr,
    SQLINTEGER StringLength)
{
    RETCODE rc, traceRet = 1;
    pENV penv = (pENV)EnvironmentHandle;
    IISETENVATTR_PARAM *iiSetEnvAttrParam;
    i4 value = (i4)(SCALARP)ValuePtr;

    if (block_init)
        ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLSetEnvAttr(EnvironmentHandle,
            Attribute, ValuePtr, StringLength), traceRet);

    /*
    ** Connection pooling is set in the CLI before any drivers are loaded.
    */
    if (!EnvironmentHandle)
    {
        if (Attribute != SQL_ATTR_CONNECTION_POOLING)
        {
            rc = SQL_INVALID_HANDLE;
            goto exit_routine;
        }
        if (!block_init)
        {
            /*
            ** Initialize the CLI control block if connection pooling is 
            ** specified.
            */
            if (value == SQL_CP_ONE_PER_DRIVER || value == SQL_CP_ONE_PER_HENV)
            {
                IIodbc_initControlBlock();
                if (IIodbc_cb.timeout != -1)
                    IIodbc_createPoolThread();
                block_init = TRUE;
            }
        }
        
        if (value == SQL_CP_ONE_PER_DRIVER)
        {
            ODBC_EXEC_TRACE(ODBC_TR_TRACE)
                ("SQLSetEnvAttr: driver pool initialized\n");
            IIodbc_cb.pooling = DRIVER_POOL;
            QUinit(&IIodbc_cb.pool_q);
        }
        else if (value == SQL_CP_ONE_PER_HENV)
        {
            IIodbc_cb.pooling = HENV_POOL;
        }
        else if (value != SQL_CP_OFF)
        {
            /* 
            ** If the pooling arguments are invalid, only SQL_INVALID_HANDLE 
            ** can be returned because no environment handle exists.
            */
            rc = SQL_INVALID_HANDLE;
            goto exit_routine;
        } /* if (!initPool) */
        rc = SQL_SUCCESS;
        goto exit_routine;
    } /* if (!EnvironmentHandle) */
    
    
    if (Attribute == SQL_ATTR_CP_MATCH && value == SQL_CP_RELAXED_MATCH)
        penv->relaxed_match = TRUE;
    else
        penv->relaxed_match = FALSE;

    /*
    **  If the driver isn't loaded yet, set a placeholder to do this 
    **  later.
    */
    if ( !IISetEnvAttr )
    {
        if (Attribute == SQL_ATTR_ODBC_VERSION)
            penv->envAttrValue = ValuePtr;
        iiSetEnvAttrParam = 
        (IISETENVATTR_PARAM *)MEreqmem(0, sizeof(IISETENVATTR_PARAM), 
            TRUE, NULL);
        penv->setEnvAttr_count++;
        iiSetEnvAttrParam->Attribute = Attribute;
        iiSetEnvAttrParam->EnvironmentHandle = EnvironmentHandle;
        iiSetEnvAttrParam->ValuePtr = ValuePtr;
        iiSetEnvAttrParam->StringLength = StringLength;
        QUinsert((QUEUE *)iiSetEnvAttrParam, &penv->setEnvAttr_q);
        rc = SQL_SUCCESS;
        goto exit_routine;
    }

    if (penv->hdr.state < E2)
    {
        resetErrorBuff(penv, SQL_HANDLE_ENV);

        rc = IISetEnvAttr (
            penv->hdr.driverHandle,
            Attribute,
            ValuePtr,
            StringLength);
    }
    else
        rc = SQL_ERROR;

    applyLock(SQL_HANDLE_ENV, penv);
    if (rc != SQL_SUCCESS)
    {
        penv->hdr.driverError = TRUE;
        penv->errHdr.rc = rc;
    }
    releaseLock(SQL_HANDLE_ENV, penv);
    
exit_routine:
    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}
コード例 #21
0
RETCODE SQL_API SQLSetConnectAttr(
    SQLHDBC     hdbc,
    SQLINTEGER  fOption,
    SQLPOINTER  pValue,
    SQLINTEGER  StringLength)
{
    RETCODE rc, traceRet = 1;
    pDBC pdbc = (pDBC)hdbc;
    IISETCONNECTATTR_PARAM *iiSetConnectAttrParam;
    
    ODBC_TRACE_ENTRY(ODBC_TR_TRACE, IITraceSQLSetConnectAttr(hdbc, fOption,
       pValue, StringLength), traceRet);
    
    if (!hdbc)
    {
        ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, SQL_INVALID_HANDLE));
        return SQL_INVALID_HANDLE;
    }

    /*
    **  If the driver isn't loaded yet, set a placeholder to do this 
    **  later.
    */
    if (!IISetConnectAttr)
    {
        iiSetConnectAttrParam = 
            (IISETCONNECTATTR_PARAM *)MEreqmem(0, 
            sizeof(IISETCONNECTATTR_PARAM), TRUE, NULL);
        QUinsert((QUEUE *)iiSetConnectAttrParam, &pdbc->setConnectAttr_q);
        iiSetConnectAttrParam->ConnectionHandle = hdbc;
        iiSetConnectAttrParam->Attribute = fOption;
        iiSetConnectAttrParam->Value = pValue;
        iiSetConnectAttrParam->StringLength = StringLength;
        pdbc->setConnectAttr_count++;
        ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, SQL_SUCCESS));
        return SQL_SUCCESS;
    }
    else
    {
        resetErrorBuff( pdbc, SQL_HANDLE_DBC );
        rc = IISetConnectAttr(
            pdbc->hdr.driverHandle,
            fOption,
            pValue,
            StringLength);

        applyLock(SQL_HANDLE_DBC, pdbc);
        if (rc != SQL_SUCCESS)
        {
            pdbc->errHdr.rc = rc;
            pdbc->hdr.driverError = TRUE;
        }
        else if (fOption == SQL_ATTR_AUTOCOMMIT && StringLength == SQL_IS_INTEGER)
        {
            if (((ULONG)pValue) == SQL_AUTOCOMMIT_OFF)
                pdbc->autocommit = FALSE;
            else if (((ULONG)pValue) == SQL_AUTOCOMMIT_ON)
                pdbc->autocommit = TRUE;
        }
        releaseLock(SQL_HANDLE_DBC, pdbc);
    }
    ODBC_TRACE(ODBC_TR_TRACE, IITraceReturn(traceRet, rc));
    return rc;
}