Exemplo n.º 1
0
RETCODE SQL_API SQLGetDiagRec ( SQLSMALLINT     pHandleType,
                                SQLHANDLE       pHandle,
                                SQLSMALLINT     pRecNum,
                                SQLCHAR*        pSqlstate,
                                SQLINTEGER*     pNativeErrorPtr,
                                SQLCHAR*        pMsgTxtPtr,
                                SQLSMALLINT     pMsgTxtSize,
                                SQLSMALLINT*    pMsgTxtSizePtr ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetDiagRec called, HandleType: %d, RecNum: %d, BufLen: %d", pHandleType,
                              pRecNum, pMsgTxtSize ) );
    pODBCDiag    diag;
    pODBCDiagRow diagrow;
    __CHK_HANDLE ( pHandle, pHandleType, SQL_ERROR );
    diag = _SQLGetDiagHandle ( pHandleType, pHandle );
    
    if ( !diag ) { return SQL_ERROR; }
    
    // now get the desired diag row
    if ( ( diagrow = _SQLGetDiagRowX ( diag, pRecNum ) ) == NULL )
    { return SQL_NO_DATA; }
    
    // sql-state
    if ( pSqlstate )
    { strcpy ( ( char* ) pSqlstate, diagrow->State ); }
    
    // native error code
    if ( pNativeErrorPtr )
    { ( *pNativeErrorPtr ) = diagrow->NativeErrorCode; }
    
    // msg
    _SQLCopyCharData ( diag, pMsgTxtPtr, pMsgTxtSize, pMsgTxtSizePtr, 16, diagrow->Msg, -1 );
    // debug
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetDiagRec msg: %s", pMsgTxtPtr ? ( StrPtr ) pMsgTxtPtr : "(unknown)" ) );
    return ( pMsgTxtSizePtr && ( *pMsgTxtSizePtr ) > pMsgTxtSize ) ? SQL_SUCCESS_WITH_INFO : SQL_SUCCESS;
}
Exemplo n.º 2
0
/*
     Kylin uses rest request for query executing, SQLPrepare does not do anything meaningful
*/
RETCODE SQL_API SQLPrepareW ( SQLHSTMT    pStmt,
                              SQLWCHAR*    pStmtText,
                              SQLINTEGER  pTextLength ) {
    wchar_t*      s;
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLPrepareW called on: %d", pStmt ) );
    __CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
    _SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
    
    // precaution
    if ( pStmtText == NULL || ( pTextLength <= 0 && pTextLength != SQL_NTS ) ) {
        __ODBCPOPMSG ( _ODBCPopMsg ( "SQLPrepare - bad params" ) );
        _SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "SQLPrepare", "01000", -1, "SQLPrepare - bad params" );
        return SQL_ERROR;
    }
    
    // MANAGE STMT CONTENT
    
    // convert to full request, with zero termination ( as well as params - later )
    if ( ProcessStmtForParams ( ( pODBCStmt ) pStmt, pStmtText, pTextLength, s ) == BAD )
    { return SQL_ERROR; }
    
    // release existing stmt contents
    SQLFreeStmt ( pStmt, SQL_CLOSE );
    // replace with new stmt string
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The query being prepared is :" ) );
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, s ) );
    ( ( pODBCStmt ) pStmt )->Stmt = s;
    ( ( pODBCStmt ) pStmt )->StmtLen = pTextLength;
    // MARK as prepared
    // set the flag
    ( ( pODBCStmt ) pStmt )->Prepared = 1;
    return SQL_SUCCESS;
}
Exemplo n.º 3
0
RETCODE SQL_API SQLExecDirectW ( SQLHSTMT    pStmt,
                                 SQLWCHAR*    pStmtText,
                                 SQLINTEGER  pTextLength ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLExecDirectW called on: %d", pStmt ) );
    wchar_t*      s;
    __CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
    _SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
    
    // precaution
    if ( pStmtText == NULL || ( pTextLength <= 0 && pTextLength != SQL_NTS ) ) {
        __ODBCPOPMSG ( _ODBCPopMsg ( "SQLExecDirect - bad params" ) );
        _SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "SQLExecDirectW", "01000", -1, "bad params" );
        return SQL_ERROR;
    }
    
    // convert to full request, with zero termination ( as well as params - later )
    if ( ProcessStmtForParams ( ( pODBCStmt ) pStmt, ( wchar_t* ) pStmtText, pTextLength, s ) == BAD )
    { return SQL_ERROR; }
    
    // release existing stmt contents
    SQLFreeStmt ( pStmt, SQL_CLOSE );
    // replace with new stmt string
    ( ( pODBCStmt ) pStmt )->Stmt = s;
    ( ( pODBCStmt ) pStmt )->StmtLen = pTextLength;
    // mark it as prepared
    ( ( pODBCStmt ) pStmt )->Prepared = 1;
    // execute
    RETCODE code = SQLExecute ( pStmt );
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLExecDirectW exited on with %d", code ) );
    return code;
}
Exemplo n.º 4
0
RETCODE SQL_API SQLRowCount ( HSTMT pStmt, SQLLEN* pDataPtr ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLRowCount called" ) );
    __CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
    // free diags
    _SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
    *pDataPtr = ( ( pODBCStmt ) pStmt )->RowCount;
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLRowCount returned: %d", *pDataPtr ) );
    return SQL_SUCCESS;
}
Exemplo n.º 5
0
RETCODE SQL_API SQLColAttributeW ( SQLHSTMT        pStmt,
                                   SQLUSMALLINT    pColNum,
                                   SQLUSMALLINT    pFldID,
                                   SQLPOINTER      pDataPtr,
                                   SQLSMALLINT     pDataSize,
                                   SQLSMALLINT*    pDataSizePtr,
                                   SQLPOINTER      pNumValuePtr ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLColAttributeW called, ColNum: %d, FldID: %d", pColNum, pFldID ) );
    RETCODE code =  _SQLColAttribute_basic ( pStmt, pColNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, pNumValuePtr,
                                             false );
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "the return code is %d", code ) );
    return code;
}
Exemplo n.º 6
0
RETCODE SQL_API SQLFetchScroll ( SQLHSTMT        pStatementHandle,
                                 SQLSMALLINT     pFetchOrientation,
                                 SQLINTEGER      pFetchOffset ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLFetchScroll called" ) );
    __ODBCPOPMSG ( _ODBCPopMsg ( "SQLFetchScroll not implemented" ) );
    return SQL_ERROR;
}
Exemplo n.º 7
0
RETCODE SQL_API SQLPrepare ( SQLHSTMT    pStmt,
                             SQLCHAR*    pStmtText,
                             SQLINTEGER  pTextLength ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLPrepare called" ) );
    __ODBCPOPMSG ( _ODBCPopMsg ( "SQLPrepare not implemented, use SQLPrepareW" ) );
    return SQL_ERROR;
}
Exemplo n.º 8
0
eGoodBad _SQLPutDiagRow ( SQLSMALLINT pHandleType, SQLHANDLE pHandle, StrPtr pFunc, StrPtr pState,
                          Long pNativeErrorCode, Long pRow, Long pCol, StrPtr pMsgArgs, ... ) {
    // note
    // this implementation of function takes take row/col as param
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "_SQLPutDiagRow called" ) );
    va_list             args;
    pODBCDiag        diag;
    pODBCDiagRow     r;
    __CHK_HANDLE ( pHandle, pHandleType, BAD );
    diag = _SQLGetDiagHandle ( pHandleType, pHandle );
    
    if ( !diag )
    { return BAD; }
    
    // get va_args
    va_start ( args, pMsgArgs );
    r = _SQLPutDiagRow ( diag, pFunc, pState, pNativeErrorCode, pMsgArgs, args );
    va_end ( args );
    
    if ( r ) {
        r->Row = pRow;
        r->Col = pCol;
        return GOOD;
    }
    
    return BAD;
}
Exemplo n.º 9
0
RETCODE SQL_API SQLPutData ( SQLHSTMT       pStmt,
                             SQLPOINTER     pDataPtr,
                             SQLINTEGER     pDataSize ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLPutData called" ) );
    __ODBCPOPMSG ( _ODBCPopMsg ( "SQLPutData not implemented" ) );
    return SQL_ERROR;
}
Exemplo n.º 10
0
RETCODE SQL_API SQLEndTran ( SQLSMALLINT     pHandleType,
                             SQLHANDLE       pHandle,
                             SQLSMALLINT     pCompletionType ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLEndTran called" ) );
    __ODBCPOPMSG ( _ODBCPopMsg ( "SQLEndTran not implemented" ) );
    return SQL_ERROR;
}
Exemplo n.º 11
0
RETCODE SQL_API SQLExtendedFetch ( SQLHSTMT        pStmt,
                                   SQLUSMALLINT    pFetchOrientation,
                                   SQLINTEGER      pFetchOffset,
                                   SQLUINTEGER*    pRowCountPtr,
                                   SQLUSMALLINT*   pRowStatusArray ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG,
                              "SQLExtendedFetch called, Stmt: %d, FO: %d, Offset: %d, Rcount: %d, RowStatus: %d", pStmt, pFetchOrientation,
                              pFetchOffset, pRowCountPtr, pRowStatusArray ) );
    __ODBCPOPMSG ( _ODBCPopMsg ( "SQLExtendedFetch is not implemented   " ) );
    return SQL_ERROR;
    Long n;
    __CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
    // free diags
    _SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
    
    // only fetch next supported
    if ( pFetchOrientation != SQL_FETCH_NEXT ) {
        __ODBCPOPMSG ( _ODBCPopMsg ( "SQLExtendedFetch option not supported, FetchOrientation: %d", pFetchOrientation ) );
        return SQL_ERROR;
    }
    
    // check if number of rows explicitly specified
    if ( pFetchOffset <= 0 )
    { n = ( ( pODBCStmt ) pStmt )->ARD.RowArraySize; }
    
    // use default rowset size as a fallback
    if ( n <= 0 )
    { n = 1; }
    
    return _SQLFetch ( ( pODBCStmt ) pStmt, pFetchOrientation, n, pRowCountPtr, pRowStatusArray );
}
Exemplo n.º 12
0
RETCODE SQL_API SQLCancel ( HSTMT pStmt ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_INFO, "SQLCancel called" ) );
    //if ( pStmt )
    //    // clear all previous diag info
    //{ _SQLFreeDiag ( & ( ( ( pODBCStmt ) pStmt )->Diag ) ); }
    return SQL_SUCCESS;
}
Exemplo n.º 13
0
RETCODE SQL_API SQLGetEnvAttr ( SQLHENV pEnv,
                                SQLINTEGER pAttr,
                                SQLPOINTER pDataPtr,
                                SQLINTEGER pDataSize,
                                SQLINTEGER* pDataSizePtr )
{
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetEnvAttr called" ) );
    __CHK_HANDLE ( pEnv, SQL_HANDLE_ENV, SQL_ERROR );
    _SQLFreeDiag ( _DIAGENV ( pEnv ) );

    switch ( pAttr )
    {
        case SQL_ATTR_ODBC_VERSION :
            * ( ( ULong* ) pDataPtr ) = ( ( pODBCEnv ) pEnv ) -> AttrODBCVersion;
            break;

        case SQL_ATTR_CONNECTION_POOLING :
            * ( ( ULong* ) pDataPtr ) = ( ( pODBCEnv ) pEnv ) -> AttrConnPooling;
            break;

        case SQL_ATTR_CP_MATCH :
            * ( ( ULong* ) pDataPtr ) = ( ( pODBCEnv ) pEnv ) -> AttrCPMatch;
            break;

        case SQL_ATTR_OUTPUT_NTS :
            * ( ( ULong* ) pDataPtr ) = ( ( pODBCEnv ) pEnv ) -> AttrOutputNTS;
            break;

        default :
            return SQL_ERROR; // unknown attribute
    }

    return SQL_SUCCESS;
}
Exemplo n.º 14
0
Word _SQLCopyDateTimeData ( pODBCDiag pDiag, void* pTgtDataPtr, Word pTgtDataType, CStrPtr pSrcData,
                            Word pSrcDataType )
{
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "_SQLCopyDateTimeData called, with the src : %s", pSrcData ) );
    // note
    // source data is received as character string
    // source data type is also recd. but is not being checked right now
    // this can be used to detrmine if the conversion is possible at all
    bool isnull;
    // check if source data is NULL
    isnull = ( !pSrcData || _stricmp ( pSrcData, "NULL" ) == 0 ) ? TRUE : 0;

    // check if target is there
    if ( pTgtDataPtr )
    {
        // check the data size
        switch ( pTgtDataType )
        {
            case SQL_C_TYPE_DATE : // 91
            case SQL_C_DATE :

                // ???? check src type
                if ( !isnull )
                {
                    memset ( pTgtDataPtr, 0, sizeof ( struct tagDATE_STRUCT) );
                    GetDateFromString ( pSrcData, ( struct tagDATE_STRUCT* ) pTgtDataPtr );
                }

                break;

            case SQL_C_TYPE_TIME : // 92
            case SQL_C_TIME :
                //not suppporting Time
                return 1;

            case SQL_C_TYPE_TIMESTAMP : // 93
            case SQL_C_TIMESTAMP :

                // ???? check src type
                if ( !isnull )
                {
                    memset ( pTgtDataPtr, 0, sizeof ( struct tagTIMESTAMP_STRUCT) );
                    GetTimestampFromString ( pSrcData, ( struct tagTIMESTAMP_STRUCT* ) pTgtDataPtr );
                }

                break;

            default :
                return 1; // data type not understood
        }

        return 0; // successful, at least data type recognized
    }

    else
    {
        return -1;
    } // should not typically happen
}
Exemplo n.º 15
0
RETCODE SQL_API SQLExecDirect ( SQLHSTMT    pStmt,
                                SQLCHAR*    pStmtText,
                                SQLINTEGER  pTextLength ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLExecDirect called, strlen is %d, pTextLength is %d",
                              strlen ( ( char* ) pStmtText ), pTextLength ) );
    unique_ptr<wchar_t[]> pStmtTextW ( char2wchar ( ( char* ) pStmtText ) );
    return SQLExecDirectW ( pStmt, ( SQLWCHAR* ) pStmtTextW.get(), pTextLength );
}
Exemplo n.º 16
0
RETCODE SQL_API SQLSetCursorName ( SQLHSTMT    pStmt,
                                   SQLCHAR*    pDataPtr,
                                   SQLSMALLINT pDataSize ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetCursorName called" ) );
    __CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
    _SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
    return SQL_SUCCESS;
}
Exemplo n.º 17
0
RETCODE SQL_API SQLSetPos ( SQLHSTMT        pStmt,
                            SQLUSMALLINT    pRowNumber,
                            SQLUSMALLINT    pOperation,
                            SQLUSMALLINT    pLockType ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLSetPos called" ) );
    __ODBCPOPMSG ( _ODBCPopMsg ( "SQLSetPos not implemented" ) );
    return SQL_ERROR;
}
Exemplo n.º 18
0
RETCODE SQL_API SQLGetStmtAttrW ( SQLHSTMT    pStmt,
                                  SQLINTEGER  pAttr,
                                  SQLPOINTER  pDataPtr,
                                  SQLINTEGER  pDataSize,
                                  SQLINTEGER* pDataSizePtr ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetStmtAttrW, Attr: %d, DataPtr: %d, DataSize: %d", pAttr, pDataPtr,
                              pDataSize ) );
    return SQLGetStmtAttr ( pStmt, pAttr, pDataPtr, pDataSize, pDataSizePtr );
}
Exemplo n.º 19
0
RETCODE   TryFetchMetadata ( pODBCConn pgConn ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "start loading metadata..." ) );
    
    try {
        pgConn->meta = std::move ( restGetMeta ( pgConn->Server, pgConn->ServerPort, pgConn->UserName, pgConn->Password,
                                                 pgConn->Project ) );
    }
    
    catch ( const exception& e ) {
        __ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR, "The REST request failed to get metadata" ) );
        __ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR, e.what() ) );
        _SQLPutDiagRow ( SQL_HANDLE_DBC, pgConn, "SQLDriverConnect", "HY000", 1045, "Access denied. (using password: NO)" );
        return SQL_ERROR;
    }
    
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "End loading metadata" ) );
    return SQL_SUCCESS;
}
Exemplo n.º 20
0
// --------------------------------------------------------------------
// to set attributes specific to a connection
// --------------------------------------------------------------------
RETCODE SQL_API SQLSetConnectAttrW ( SQLHDBC            hdbc,
                                     SQLINTEGER         fAttribute,
                                     SQLPOINTER         rgbValue,
                                     SQLINTEGER         cbValue ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLSetConnectAttrW, Attr: %d, DataPtr: %d, DataSize: %d", fAttribute,
                              rgbValue, cbValue ) );
    RETCODE code = SQLSetConnectAttr ( hdbc, fAttribute, rgbValue, cbValue );
    return code;
}
Exemplo n.º 21
0
pODBCDiagRow _SQLPutDiagRow ( pODBCDiag pDiag, StrPtr pFunc, StrPtr pState, Long pNativeErrorCode,
                              StrPtr pMsgArgs, va_list pArgs ) {
    Char                s[4096];                        // arbitary and maximum length of message
    pODBCDiagRow     l;
    pODBCDiagRow     r;
    
    // first set the value of source function, assuming less than 64
    if ( pFunc )
    { strcpy ( pDiag->Func, pFunc ); }
    
    // create message template
    strcpy ( s, "[Kylin][ODBC 1.0(w) Driver]" );
    
    // check if there is some message
    if ( pMsgArgs )
    { vsprintf ( s + strlen ( s ), pMsgArgs, pArgs ); }
    
    else
    { strcat ( s, "(unknown)" ); }
    
    // allocate a new row
    r = new ODBCDiagRow;
    // reset
    memset ( r, 0, sizeof ( ODBCDiagRow ) );
    
    // set the values for state and native error code
    if ( pState )       { strncpy ( r->State, pState, SQL_SQLSTATE_SIZE ); }
    
    r->NativeErrorCode = pNativeErrorCode;
    // allocate space for message
    r->Msg = new Char[strlen ( s ) + 1];
    strcpy ( r->Msg, s );
    // set the default row and col values
    r->Row = SQL_ROW_NUMBER_UNKNOWN;
    r->Col = SQL_COLUMN_NUMBER_UNKNOWN;
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "DiagMsg: %s", s ) );
    
    // ATTACH TO LIST
    
    // check for any existing rows
    if ( pDiag->DiagRows ) {
        // iterate to last row
        for ( l = pDiag->DiagRows; l->Next != NULL; l = l->Next );
        
        // attach
        l->Next = r;            // next of last row
        r->Prev = l;            // last row becomes the prev row of this row
    }
    
    else {
        // make it the first row
        pDiag->DiagRows = r;
    }
    
    return r;
}
Exemplo n.º 22
0
RETCODE SQL_API SQLColAttribute ( SQLHSTMT        pStmt,
                                  SQLUSMALLINT    pColNum,
                                  SQLUSMALLINT    pFldID,
                                  SQLPOINTER      pDataPtr,
                                  SQLSMALLINT     pDataSize,
                                  SQLSMALLINT*    pDataSizePtr,
                                  SQLLEN*      pNumValuePtr ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLColAttributeW called, ColNum: %d, FldID: %d", pColNum, pFldID ) );
    return _SQLColAttribute_basic ( pStmt, pColNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, pNumValuePtr, true );
}
Exemplo n.º 23
0
RETCODE SQL_API SQLNativeSql ( SQLHDBC         pConn,
                               SQLCHAR*        pInStmtText,
                               SQLINTEGER      pInStmtTextLen,
                               SQLCHAR*        pOutStmtText,
                               SQLINTEGER      pOutStmtTextLen,
                               SQLINTEGER*     pOutStmtTextLenPtr ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLNativeSql called" ) );
    __ODBCPOPMSG ( _ODBCPopMsg ( "SQLNativeSql not implemented" ) );
    return SQL_ERROR;
}
Exemplo n.º 24
0
RETCODE SQL_API SQLGetData ( SQLHSTMT        pStmt,
                             SQLUSMALLINT    pColNum,
                             SQLSMALLINT     pgtType,
                             SQLPOINTER      pDataPtr,
                             SQLINTEGER      pDataSize,
                             SQLINTEGER*     pDataSizePtr ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetData called" ) );
    __ODBCPOPMSG ( _ODBCPopMsg ( "SQLGetData not implemented" ) );
    return SQL_ERROR;
}
Exemplo n.º 25
0
// -----------------------------------------------------------------------
// to get param descriptions for a specified bound param
// -----------------------------------------------------------------------
RETCODE SQL_API SQLDescribeParam(SQLHSTMT        pStmt,
    SQLUSMALLINT    pParamNum,
    SQLSMALLINT*    pDataTypePtr,
    SQLUINTEGER*    pParamSizePtr,
    SQLSMALLINT*    pDecimalDigitsPtr,
    SQLSMALLINT*    pNullablePtr) {
    __ODBCLOG(_ODBCLogMsg(LogLevel_DEBUG, "SQLDescribeParam called"));
    __ODBCPOPMSG(_ODBCPopMsg("SQLDescribeParam not implemented"));
    return SQL_ERROR;
}
Exemplo n.º 26
0
RETCODE SQL_API SQLBrowseConnect ( SQLHDBC         pConn,
                                   SQLCHAR*        InConnectionString,
                                   SQLSMALLINT     StringLength1,
                                   SQLCHAR*        OutConnectionString,
                                   SQLSMALLINT     BufferLength,
                                   SQLSMALLINT*    StringLength2Ptr ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLBrowseConnect called" ) );
    __ODBCPOPMSG ( _ODBCPopMsg ( "SQLBrowseConnect - not implemented, use SQLDriverConnect" ) );
    return SQL_ERROR;
}
Exemplo n.º 27
0
RETCODE   TryAuthenticate ( pODBCConn pgConn ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Start authenticating.." ) );
    
    try {
        bool authenticated = restAuthenticate ( pgConn->Server, pgConn->ServerPort, pgConn->UserName, pgConn->Password );
        
        if ( !authenticated )
        { throw exception ( "Username/Password incorrect." ); }
    }
    
    catch ( const exception& e ) {
        __ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR, "The REST request failed to authenticate." ) );
        __ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR, e.what() ) );
        _SQLPutDiagRow ( SQL_HANDLE_DBC, pgConn, "SQLDriverConnect", "HY000", 1045, "Access denied. (using password: NO)" );
        return SQL_ERROR;
    }
    
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "End authenticating" ) );
    return SQL_SUCCESS;
}
Exemplo n.º 28
0
// -----------------------------------------------------------------------
// to get the number of parameters in a statement
// -----------------------------------------------------------------------
RETCODE SQL_API SQLNumParams(SQLHSTMT pStmt, SQLSMALLINT* pParamCountPtr) {
    // since the concept of parameters has not been implemented
    // this function returns zero in the number of params to
    // make sure that the calle does not proceed forward on this issue
    __ODBCLOG(_ODBCLogMsg(LogLevel_DEBUG, "SQLNumParams called"));

    if (pParamCountPtr) {
        *pParamCountPtr = 0;
    }

    return SQL_SUCCESS;
}
Exemplo n.º 29
0
RETCODE SQL_API _SQLExecStmtFromReq ( pODBCStmt pStmt, bool pPrepared ) {
    ////// this part should not be required if already prepared
    // release existing stmt contents
    //SQLFreeStmt ( pStmt, SQL_CLOSE );
    //////
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_INFO, "================================================================" ) );
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_INFO, "start exec the query: " ) );
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_INFO, pStmt->Stmt ) );
    std::unique_ptr<SQLResponse> p;
    
    try {
        p = restQuery ( pStmt->Stmt, pStmt->Conn->Server, pStmt->Conn->ServerPort, pStmt->Conn->UserName, pStmt->Conn->Password,
                        pStmt->Conn->Project );
        __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The REST request succeed" ) );
    }
    
    catch ( const exception& e ) {
        std::stringstream ss;
        ss << "The REST query request failed, the error message is: " << e.what();
        std::string s = ss.str();
        __ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR, s.c_str() ) );
        _SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "_SQLExecStmtFromReq", "01000", -1, ( char* ) s.c_str() );
        return SQL_ERROR;
    }
    
    // feed stmt structure with response, stmt will take charge of deleting it
    if ( p == NULL ||  p->isException == true || PutRespToStmt ( ( pODBCStmt ) pStmt, std::move ( p ) ) != GOOD ) {
        return SQL_ERROR;
    }
    
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_INFO, "Successfully done executing the query" ) );
    return SQL_SUCCESS;
}
Exemplo n.º 30
0
RETCODE SQL_API SQLNumResultCols ( SQLHSTMT pStmt, SQLSMALLINT*  pColCountPtr ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLNumResultCols called" ) );
    SQLResponse* rowdesc;
    __CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
    // free diags
    _SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
    // caller safe
    * ( ( SQLSMALLINT* ) pColCountPtr ) = 0;
    // get the row desciptor
    rowdesc = ( ( pODBCStmt ) pStmt )->IRD.RowDesc.get();
    
    if ( rowdesc == NULL ) {
        _SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "SQLNumResultCols", "01000", -1, "no resultset or IRD" );
        return SQL_ERROR;
    }
    
    // count the number of columns
    * ( ( SQLSMALLINT* ) pColCountPtr ) = ( SQLSMALLINT ) ( rowdesc->columnMetas.size() );
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLNumResultCols called returned: %d",
                              * ( ( SQLSMALLINT* ) pColCountPtr ) ) );
    return SQL_SUCCESS;
}