1 Star 0 Fork 53

huangjiajun/openGauss-connector-odbc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
odbcapi.c 39.31 KB
一键复制 编辑 原始数据 按行查看 历史
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535
/*-------
* Module: odbcapi.c
*
* Description: This module contains routines related to
* preparing and executing an SQL statement.
*
* Classes: n/a
*
* API functions: SQLAllocConnect, SQLAllocEnv, SQLAllocStmt,
SQLBindCol, SQLCancel, SQLColumns, SQLConnect,
SQLDataSources, SQLDescribeCol, SQLDisconnect,
SQLError, SQLExecDirect, SQLExecute, SQLFetch,
SQLFreeConnect, SQLFreeEnv, SQLFreeStmt,
SQLGetConnectOption, SQLGetCursorName, SQLGetData,
SQLGetFunctions, SQLGetInfo, SQLGetStmtOption,
SQLGetTypeInfo, SQLNumResultCols, SQLParamData,
SQLPrepare, SQLPutData, SQLRowCount,
SQLSetConnectOption, SQLSetCursorName, SQLSetParam,
SQLSetStmtOption, SQLSpecialColumns, SQLStatistics,
SQLTables, SQLTransact, SQLColAttributes,
SQLColumnPrivileges, SQLDescribeParam, SQLExtendedFetch,
SQLForeignKeys, SQLMoreResults, SQLNativeSql,
SQLNumParams, SQLParamOptions, SQLPrimaryKeys,
SQLProcedureColumns, SQLProcedures, SQLSetPos,
SQLTablePrivileges, SQLBindParameter
*-------
*/
#include "psqlodbc.h"
#include <stdio.h>
#include <string.h>
#include "misc.h"
#include "pgapifunc.h"
#include "environ.h"
#include "connection.h"
#include "statement.h"
#include "qresult.h"
#include "loadlib.h"
BOOL SC_connection_lost_check(StatementClass *stmt, const char *funcname)
{
ConnectionClass *conn = SC_get_conn(stmt);
char message[64];
if (NULL != conn->pqconn)
return FALSE;
SC_clear_error(stmt);
SPRINTF_FIXED(message, "%s unable due to the connection lost", funcname);
SC_set_error(stmt, STMT_COMMUNICATION_ERROR, message, funcname);
return TRUE;
}
RETCODE SQL_API
SQLBindCol(HSTMT StatementHandle,
SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
PTR TargetValue, SQLLEN BufferLength,
SQLLEN *StrLen_or_Ind)
{
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
MYLOG(0, "Entering\n");
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
ret = PGAPI_BindCol(StatementHandle, ColumnNumber,
TargetType, TargetValue, BufferLength, StrLen_or_Ind);
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
RETCODE SQL_API
SQLCancel(HSTMT StatementHandle)
{
MYLOG(0, "Entering\n");
/* Not that neither ENTER_STMT_CS nor StartRollbackState is called */
/* SC_clear_error((StatementClass *) StatementHandle); maybe this neither */
if (SC_connection_lost_check((StatementClass *) StatementHandle, __FUNCTION__))
return SQL_ERROR;
return PGAPI_Cancel(StatementHandle);
}
static BOOL theResultIsEmpty(const StatementClass *stmt)
{
QResultClass *res = SC_get_Result(stmt);
if (NULL == res)
return FALSE;
return (0 == QR_get_num_total_tuples(res));
}
#ifndef UNICODE_SUPPORTXX
RETCODE SQL_API
SQLColumns(HSTMT StatementHandle,
SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
SQLCHAR *TableName, SQLSMALLINT NameLength3,
SQLCHAR *ColumnName, SQLSMALLINT NameLength4)
{
CSTR func = "SQLColumns";
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
SQLCHAR *ctName = CatalogName, *scName = SchemaName,
*tbName = TableName, *clName = ColumnName;
ConnInfo *ci = &(SC_get_conn(stmt)->connInfo);
UWORD flag = PODBC_SEARCH_PUBLIC_SCHEMA;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
if (stmt->options.metadata_id)
flag |= PODBC_NOT_SEARCH_PATTERN;
if (atoi(ci->show_oid_column))
flag |= PODBC_SHOW_OID_COLUMN;
if (atoi(ci->row_versioning))
flag |= PODBC_ROW_VERSIONING;
if (SC_opencheck(stmt, func))
ret = SQL_ERROR;
else
ret = PGAPI_Columns(StatementHandle, ctName, NameLength1,
scName, NameLength2, tbName, NameLength3,
clName, NameLength4, flag, 0, 0);
if (SQL_SUCCESS == ret && theResultIsEmpty(stmt))
{
BOOL ifallupper = TRUE, reexec = FALSE;
SQLCHAR *newCt = NULL, *newSc = NULL, *newTb = NULL, *newCl = NULL;
ConnectionClass *conn = SC_get_conn(stmt);
if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
ifallupper = FALSE;
if (newCt = make_lstring_ifneeded(conn, CatalogName, NameLength1, ifallupper), NULL != newCt)
{
ctName = newCt;
reexec = TRUE;
}
if (newSc = make_lstring_ifneeded(conn, SchemaName, NameLength2, ifallupper), NULL != newSc)
{
scName = newSc;
reexec = TRUE;
}
if (newTb = make_lstring_ifneeded(conn, TableName, NameLength3, ifallupper), NULL != newTb)
{
tbName = newTb;
reexec = TRUE;
}
if (newCl = make_lstring_ifneeded(conn, ColumnName, NameLength4, ifallupper), NULL != newCl)
{
clName = newCl;
reexec = TRUE;
}
if (reexec)
{
ret = PGAPI_Columns(StatementHandle, ctName, NameLength1,
scName, NameLength2, tbName, NameLength3,
clName, NameLength4, flag, 0, 0);
if (newCt)
free(newCt);
if (newSc)
free(newSc);
if (newTb)
free(newTb);
if (newCl)
free(newCl);
}
}
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
RETCODE SQL_API
SQLConnect(HDBC ConnectionHandle,
SQLCHAR *ServerName, SQLSMALLINT NameLength1,
SQLCHAR *UserName, SQLSMALLINT NameLength2,
SQLCHAR *Authentication, SQLSMALLINT NameLength3)
{
RETCODE ret;
ConnectionClass *conn = (ConnectionClass *) ConnectionHandle;
MYLOG(0, "Entering\n");
CC_examine_global_transaction(conn);
ENTER_CONN_CS(conn);
CC_clear_error(conn);
ret = PGAPI_Connect(ConnectionHandle, ServerName, NameLength1,
UserName, NameLength2, Authentication, NameLength3);
LEAVE_CONN_CS(conn);
return ret;
}
RETCODE SQL_API
SQLDriverConnect(HDBC hdbc,
HWND hwnd,
SQLCHAR * szConnStrIn,
SQLSMALLINT cbConnStrIn,
SQLCHAR * szConnStrOut,
SQLSMALLINT cbConnStrOutMax,
SQLSMALLINT * pcbConnStrOut,
SQLUSMALLINT fDriverCompletion)
{
RETCODE ret;
ConnectionClass *conn = (ConnectionClass *) hdbc;
MYLOG(0, "Entering\n");
CC_examine_global_transaction(conn);
ENTER_CONN_CS(conn);
CC_clear_error(conn);
ret = PGAPI_DriverConnect(hdbc, hwnd, szConnStrIn, cbConnStrIn,
szConnStrOut, cbConnStrOutMax, pcbConnStrOut, fDriverCompletion);
LEAVE_CONN_CS(conn);
return ret;
}
RETCODE SQL_API
SQLBrowseConnect(HDBC hdbc,
SQLCHAR *szConnStrIn,
SQLSMALLINT cbConnStrIn,
SQLCHAR *szConnStrOut,
SQLSMALLINT cbConnStrOutMax,
SQLSMALLINT *pcbConnStrOut)
{
RETCODE ret;
ConnectionClass *conn = (ConnectionClass *) hdbc;
MYLOG(0, "Entering\n");
CC_examine_global_transaction(conn);
ENTER_CONN_CS(conn);
CC_clear_error(conn);
ret = PGAPI_BrowseConnect(hdbc, szConnStrIn, cbConnStrIn,
szConnStrOut, cbConnStrOutMax, pcbConnStrOut);
LEAVE_CONN_CS(conn);
return ret;
}
RETCODE SQL_API
SQLDataSources(HENV EnvironmentHandle,
SQLUSMALLINT Direction, SQLCHAR *ServerName,
SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
SQLCHAR *Description, SQLSMALLINT BufferLength2,
SQLSMALLINT *NameLength2)
{
MYLOG(0, "Entering\n");
/*
* return PGAPI_DataSources(EnvironmentHandle, Direction, ServerName,
* BufferLength1, NameLength1, Description, BufferLength2,
* NameLength2);
*/
return SQL_ERROR;
}
RETCODE SQL_API
SQLDescribeCol(HSTMT StatementHandle,
SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName,
SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
SQLSMALLINT *DataType, SQLULEN *ColumnSize,
SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
{
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
ret = PGAPI_DescribeCol(StatementHandle, ColumnNumber,
ColumnName, BufferLength, NameLength,
DataType, ColumnSize, DecimalDigits, Nullable);
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
#endif /* UNICODE_SUPPORTXX */
RETCODE SQL_API
SQLDisconnect(HDBC ConnectionHandle)
{
RETCODE ret;
ConnectionClass *conn = (ConnectionClass *) ConnectionHandle;
MYLOG(0, "Entering for %p\n", ConnectionHandle);
#ifdef _HANDLE_ENLIST_IN_DTC_
if (CC_is_in_global_trans(conn))
CALL_DtcOnDisconnect(conn);
#endif /* _HANDLE_ENLIST_IN_DTC_ */
ENTER_CONN_CS(conn);
CC_clear_error(conn);
ret = PGAPI_Disconnect(ConnectionHandle);
LEAVE_CONN_CS(conn);
return ret;
}
#ifndef UNICODE_SUPPORTXX
RETCODE SQL_API
SQLExecDirect(HSTMT StatementHandle,
SQLCHAR *StatementText, SQLINTEGER TextLength)
{
CSTR func = "SQLExecDirect";
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
UWORD flag = 0;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
flag |= PODBC_WITH_HOLD;
if (SC_opencheck(stmt, func))
ret = SQL_ERROR;
else
{
StartRollbackState(stmt);
ret = PGAPI_ExecDirect(StatementHandle, StatementText, TextLength, flag);
ret = DiscardStatementSvp(stmt, ret, FALSE);
}
LEAVE_STMT_CS(stmt);
return ret;
}
#endif /* UNICODE_SUPPORTXX */
RETCODE SQL_API
SQLExecute(HSTMT StatementHandle)
{
CSTR func = "SQLExecute";
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
UWORD flag = 0;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
flag |= PODBC_WITH_HOLD;
if (SC_opencheck(stmt, func))
ret = SQL_ERROR;
else
{
StartRollbackState(stmt);
stmt->exec_current_row = -1;
ret = PGAPI_Execute(StatementHandle, flag);
ret = DiscardStatementSvp(stmt, ret, FALSE);
}
LEAVE_STMT_CS(stmt);
return ret;
}
RETCODE SQL_API
SQLFetch(HSTMT StatementHandle)
{
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
IRDFields *irdopts = SC_get_IRDF(stmt);
ARDFields *ardopts = SC_get_ARDF(stmt);
SQLUSMALLINT *rowStatusArray = irdopts->rowStatusArray;
SQLULEN *pcRow = irdopts->rowsFetched;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
ret = PGAPI_ExtendedFetch(StatementHandle, SQL_FETCH_NEXT, 0,
pcRow, rowStatusArray, 0, ardopts->size_of_rowset);
stmt->transition_status = STMT_TRANSITION_FETCH_SCROLL;
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
RETCODE SQL_API
SQLFreeStmt(HSTMT StatementHandle,
SQLUSMALLINT Option)
{
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
ConnectionClass *conn = NULL;
MYLOG(0, "Entering\n");
if (stmt)
{
if (Option == SQL_DROP)
{
conn = stmt->hdbc;
if (conn)
ENTER_CONN_CS(conn);
}
else
ENTER_STMT_CS(stmt);
}
ret = PGAPI_FreeStmt(StatementHandle, Option);
if (stmt)
{
if (Option == SQL_DROP)
{
if (conn)
LEAVE_CONN_CS(conn);
}
else
LEAVE_STMT_CS(stmt);
}
return ret;
}
#ifndef UNICODE_SUPPORTXX
RETCODE SQL_API
SQLGetCursorName(HSTMT StatementHandle,
SQLCHAR *CursorName, SQLSMALLINT BufferLength,
SQLSMALLINT *NameLength)
{
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
MYLOG(0, "Entering\n");
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
ret = PGAPI_GetCursorName(StatementHandle, CursorName, BufferLength,
NameLength);
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
#endif /* UNICODE_SUPPORTXX */
RETCODE SQL_API
SQLGetData(HSTMT StatementHandle,
SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
PTR TargetValue, SQLLEN BufferLength,
SQLLEN *StrLen_or_Ind)
{
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
ret = PGAPI_GetData(StatementHandle, ColumnNumber, TargetType,
TargetValue, BufferLength, StrLen_or_Ind);
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
RETCODE SQL_API
SQLGetFunctions(HDBC ConnectionHandle,
SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported)
{
RETCODE ret;
ConnectionClass *conn = (ConnectionClass *) ConnectionHandle;
MYLOG(0, "Entering\n");
CC_examine_global_transaction(conn);
ENTER_CONN_CS(conn);
CC_clear_error(conn);
if (FunctionId == SQL_API_ODBC3_ALL_FUNCTIONS)
ret = PGAPI_GetFunctions30(ConnectionHandle, FunctionId, Supported);
else
ret = PGAPI_GetFunctions(ConnectionHandle, FunctionId, Supported);
LEAVE_CONN_CS(conn);
return ret;
}
#ifndef UNICODE_SUPPORTXX
RETCODE SQL_API
SQLGetInfo(HDBC ConnectionHandle,
SQLUSMALLINT InfoType, PTR InfoValue,
SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
{
RETCODE ret;
ConnectionClass *conn = (ConnectionClass *) ConnectionHandle;
CC_examine_global_transaction(conn);
ENTER_CONN_CS(conn);
CC_clear_error(conn);
MYLOG(0, "Entering\n");
if ((ret = PGAPI_GetInfo(ConnectionHandle, InfoType, InfoValue,
BufferLength, StringLength)) == SQL_ERROR)
CC_log_error("SQLGetInfo(30)", "", conn);
LEAVE_CONN_CS(conn);
return ret;
}
RETCODE SQL_API
SQLGetTypeInfo(HSTMT StatementHandle,
SQLSMALLINT DataType)
{
CSTR func = "SQLGetTypeInfo";
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check((StatementClass *) StatementHandle, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
if (SC_opencheck(stmt, func))
ret = SQL_ERROR;
else
{
StartRollbackState(stmt);
ret = PGAPI_GetTypeInfo(StatementHandle, DataType);
ret = DiscardStatementSvp(stmt, ret, FALSE);
}
LEAVE_STMT_CS(stmt);
return ret;
}
#endif /* UNICODE_SUPPORTXX */
RETCODE SQL_API
SQLNumResultCols(HSTMT StatementHandle,
SQLSMALLINT *ColumnCount)
{
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
ret = PGAPI_NumResultCols(StatementHandle, ColumnCount);
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
RETCODE SQL_API
SQLParamData(HSTMT StatementHandle,
PTR *Value)
{
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
ret = PGAPI_ParamData(StatementHandle, Value);
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
#ifndef UNICODE_SUPPORTXX
RETCODE SQL_API
SQLPrepare(HSTMT StatementHandle,
SQLCHAR *StatementText, SQLINTEGER TextLength)
{
CSTR func = "SQLPrepare";
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
if (SC_opencheck(stmt, func))
ret = SQL_ERROR;
else
{
StartRollbackState(stmt);
ret = PGAPI_Prepare(StatementHandle, StatementText, TextLength);
ret = DiscardStatementSvp(stmt, ret, FALSE);
}
LEAVE_STMT_CS(stmt);
return ret;
}
#endif /* UNICODE_SUPPORTXX */
RETCODE SQL_API
SQLPutData(HSTMT StatementHandle,
PTR Data, SQLLEN StrLen_or_Ind)
{
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
ret = PGAPI_PutData(StatementHandle, Data, StrLen_or_Ind);
ret = DiscardStatementSvp(stmt, ret, TRUE);
LEAVE_STMT_CS(stmt);
return ret;
}
RETCODE SQL_API
SQLRowCount(HSTMT StatementHandle,
SQLLEN *RowCount)
{
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
ret = PGAPI_RowCount(StatementHandle, RowCount);
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
#ifndef UNICODE_SUPPORTXX
RETCODE SQL_API
SQLSetCursorName(HSTMT StatementHandle,
SQLCHAR *CursorName, SQLSMALLINT NameLength)
{
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
MYLOG(0, "Entering\n");
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
ret = PGAPI_SetCursorName(StatementHandle, CursorName, NameLength);
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
#endif /* UNICODE_SUPPORTXX */
RETCODE SQL_API
SQLSetParam(HSTMT StatementHandle,
SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
SQLSMALLINT ParameterType, SQLULEN LengthPrecision,
SQLSMALLINT ParameterScale, PTR ParameterValue,
SQLLEN *StrLen_or_Ind)
{
MYLOG(0, "Entering\n");
SC_clear_error((StatementClass *) StatementHandle);
/*
* return PGAPI_SetParam(StatementHandle, ParameterNumber, ValueType,
* ParameterType, LengthPrecision, ParameterScale, ParameterValue,
* StrLen_or_Ind);
*/
return SQL_ERROR;
}
#ifndef UNICODE_SUPPORTXX
RETCODE SQL_API
SQLSpecialColumns(HSTMT StatementHandle,
SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName,
SQLSMALLINT NameLength1, SQLCHAR *SchemaName,
SQLSMALLINT NameLength2, SQLCHAR *TableName,
SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
SQLUSMALLINT Nullable)
{
CSTR func = "SQLSpecialColumns";
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
SQLCHAR *ctName = CatalogName, *scName = SchemaName, *tbName = TableName;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
if (SC_opencheck(stmt, func))
ret = SQL_ERROR;
else
ret = PGAPI_SpecialColumns(StatementHandle, IdentifierType, ctName,
NameLength1, scName, NameLength2, tbName, NameLength3,
Scope, Nullable);
if (SQL_SUCCESS == ret && theResultIsEmpty(stmt))
{
BOOL ifallupper = TRUE, reexec = FALSE;
SQLCHAR *newCt =NULL, *newSc = NULL, *newTb = NULL;
ConnectionClass *conn = SC_get_conn(stmt);
if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
ifallupper = FALSE;
if (newCt = make_lstring_ifneeded(conn, CatalogName, NameLength1, ifallupper), NULL != newCt)
{
ctName = newCt;
reexec = TRUE;
}
if (newSc = make_lstring_ifneeded(conn, SchemaName, NameLength2, ifallupper), NULL != newSc)
{
scName = newSc;
reexec = TRUE;
}
if (newTb = make_lstring_ifneeded(conn, TableName, NameLength3, ifallupper), NULL != newTb)
{
tbName = newTb;
reexec = TRUE;
}
if (reexec)
{
ret = PGAPI_SpecialColumns(StatementHandle, IdentifierType, ctName,
NameLength1, scName, NameLength2, tbName, NameLength3,
Scope, Nullable);
if (newCt)
free(newCt);
if (newSc)
free(newSc);
if (newTb)
free(newTb);
}
}
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
RETCODE SQL_API
SQLStatistics(HSTMT StatementHandle,
SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
SQLCHAR *TableName, SQLSMALLINT NameLength3,
SQLUSMALLINT Unique, SQLUSMALLINT Reserved)
{
CSTR func = "SQLStatistics";
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
SQLCHAR *ctName = CatalogName, *scName = SchemaName, *tbName = TableName;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
if (SC_opencheck(stmt, func))
ret = SQL_ERROR;
else
ret = PGAPI_Statistics(StatementHandle, ctName, NameLength1,
scName, NameLength2, tbName, NameLength3,
Unique, Reserved);
if (SQL_SUCCESS == ret && theResultIsEmpty(stmt))
{
BOOL ifallupper = TRUE, reexec = FALSE;
SQLCHAR *newCt =NULL, *newSc = NULL, *newTb = NULL;
ConnectionClass *conn = SC_get_conn(stmt);
if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
ifallupper = FALSE;
if (newCt = make_lstring_ifneeded(conn, CatalogName, NameLength1, ifallupper), NULL != newCt)
{
ctName = newCt;
reexec = TRUE;
}
if (newSc = make_lstring_ifneeded(conn, SchemaName, NameLength2, ifallupper), NULL != newSc)
{
scName = newSc;
reexec = TRUE;
}
if (newTb = make_lstring_ifneeded(conn, TableName, NameLength3, ifallupper), NULL != newTb)
{
tbName = newTb;
reexec = TRUE;
}
if (reexec)
{
ret = PGAPI_Statistics(StatementHandle, ctName, NameLength1,
scName, NameLength2, tbName, NameLength3,
Unique, Reserved);
if (newCt)
free(newCt);
if (newSc)
free(newSc);
if (newTb)
free(newTb);
}
}
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
RETCODE SQL_API
SQLTables(HSTMT StatementHandle,
SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
SQLCHAR *TableName, SQLSMALLINT NameLength3,
SQLCHAR *TableType, SQLSMALLINT NameLength4)
{
CSTR func = "SQLTables";
RETCODE ret;
StatementClass *stmt = (StatementClass *) StatementHandle;
SQLCHAR *ctName = CatalogName, *scName = SchemaName, *tbName = TableName;
UWORD flag = 0;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
if (stmt->options.metadata_id)
flag |= PODBC_NOT_SEARCH_PATTERN;
if (SC_opencheck(stmt, func))
ret = SQL_ERROR;
else
ret = PGAPI_Tables(StatementHandle, ctName, NameLength1,
scName, NameLength2, tbName, NameLength3,
TableType, NameLength4, flag);
if (SQL_SUCCESS == ret && theResultIsEmpty(stmt))
{
BOOL ifallupper = TRUE, reexec = FALSE;
SQLCHAR *newCt =NULL, *newSc = NULL, *newTb = NULL;
ConnectionClass *conn = SC_get_conn(stmt);
if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
ifallupper = FALSE;
if (newCt = make_lstring_ifneeded(conn, CatalogName, NameLength1, ifallupper), NULL != newCt)
{
ctName = newCt;
reexec = TRUE;
}
if (newSc = make_lstring_ifneeded(conn, SchemaName, NameLength2, ifallupper), NULL != newSc)
{
scName = newSc;
reexec = TRUE;
}
if (newTb = make_lstring_ifneeded(conn, TableName, NameLength3, ifallupper), NULL != newTb)
{
tbName = newTb;
reexec = TRUE;
}
if (reexec)
{
ret = PGAPI_Tables(StatementHandle, ctName, NameLength1,
scName, NameLength2, tbName, NameLength3,
TableType, NameLength4, flag);
if (newCt)
free(newCt);
if (newSc)
free(newSc);
if (newTb)
free(newTb);
}
}
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
RETCODE SQL_API
SQLColumnPrivileges(HSTMT hstmt,
SQLCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLCHAR *szTableName,
SQLSMALLINT cbTableName,
SQLCHAR *szColumnName,
SQLSMALLINT cbColumnName)
{
CSTR func = "SQLColumnPrivileges";
RETCODE ret;
StatementClass *stmt = (StatementClass *) hstmt;
SQLCHAR *ctName = szCatalogName, *scName = szSchemaName,
*tbName = szTableName, *clName = szColumnName;
UWORD flag = 0;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
if (stmt->options.metadata_id)
flag |= PODBC_NOT_SEARCH_PATTERN;
if (SC_opencheck(stmt, func))
ret = SQL_ERROR;
else
ret = PGAPI_ColumnPrivileges(hstmt, ctName, cbCatalogName,
scName, cbSchemaName, tbName, cbTableName,
clName, cbColumnName, flag);
if (SQL_SUCCESS == ret && theResultIsEmpty(stmt))
{
BOOL ifallupper = TRUE, reexec = FALSE;
SQLCHAR *newCt = NULL, *newSc = NULL, *newTb = NULL, *newCl = NULL;
ConnectionClass *conn = SC_get_conn(stmt);
if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
ifallupper = FALSE;
if (newCt = make_lstring_ifneeded(conn, szCatalogName, cbCatalogName, ifallupper), NULL != newCt)
{
ctName = newCt;
reexec = TRUE;
}
if (newSc = make_lstring_ifneeded(conn, szSchemaName, cbSchemaName, ifallupper), NULL != newSc)
{
scName = newSc;
reexec = TRUE;
}
if (newTb = make_lstring_ifneeded(conn, szTableName, cbTableName, ifallupper), NULL != newTb)
{
tbName = newTb;
reexec = TRUE;
}
if (newCl = make_lstring_ifneeded(conn, szColumnName, cbColumnName, ifallupper), NULL != newCl)
{
clName = newCl;
reexec = TRUE;
}
if (reexec)
{
ret = PGAPI_ColumnPrivileges(hstmt, ctName, cbCatalogName,
scName, cbSchemaName, tbName, cbTableName,
clName, cbColumnName, flag);
if (newCt)
free(newCt);
if (newSc)
free(newSc);
if (newTb)
free(newTb);
if (newCl)
free(newCl);
}
}
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
#endif /* UNICODE_SUPPORTXX */
RETCODE SQL_API
SQLDescribeParam(HSTMT hstmt,
SQLUSMALLINT ipar,
SQLSMALLINT *pfSqlType,
SQLULEN *pcbParamDef,
SQLSMALLINT *pibScale,
SQLSMALLINT *pfNullable)
{
RETCODE ret;
StatementClass *stmt = (StatementClass *) hstmt;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
ret = PGAPI_DescribeParam(hstmt, ipar, pfSqlType, pcbParamDef,
pibScale, pfNullable);
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
RETCODE SQL_API
SQLExtendedFetch(HSTMT hstmt,
SQLUSMALLINT fFetchType,
SQLLEN irow,
#if defined(WITH_UNIXODBC) && (SIZEOF_LONG_INT != 8)
SQLROWSETSIZE *pcrow,
#else
SQLULEN *pcrow,
#endif /* WITH_UNIXODBC */
SQLUSMALLINT *rgfRowStatus)
{
RETCODE ret;
StatementClass *stmt = (StatementClass *) hstmt;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
#ifdef WITH_UNIXODBC
{
SQLULEN retrieved;
ret = PGAPI_ExtendedFetch(hstmt, fFetchType, irow, &retrieved, rgfRowStatus, 0, SC_get_ARDF(stmt)->size_of_rowset_odbc2);
if (pcrow)
*pcrow = retrieved;
}
#else
ret = PGAPI_ExtendedFetch(hstmt, fFetchType, irow, pcrow, rgfRowStatus, 0, SC_get_ARDF(stmt)->size_of_rowset_odbc2);
#endif /* WITH_UNIXODBC */
stmt->transition_status = STMT_TRANSITION_EXTENDED_FETCH;
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
#ifndef UNICODE_SUPPORTXX
RETCODE SQL_API
SQLForeignKeys(HSTMT hstmt,
SQLCHAR *szPkCatalogName,
SQLSMALLINT cbPkCatalogName,
SQLCHAR *szPkSchemaName,
SQLSMALLINT cbPkSchemaName,
SQLCHAR *szPkTableName,
SQLSMALLINT cbPkTableName,
SQLCHAR *szFkCatalogName,
SQLSMALLINT cbFkCatalogName,
SQLCHAR *szFkSchemaName,
SQLSMALLINT cbFkSchemaName,
SQLCHAR *szFkTableName,
SQLSMALLINT cbFkTableName)
{
CSTR func = "SQLForeignKeys";
RETCODE ret;
StatementClass *stmt = (StatementClass *) hstmt;
SQLCHAR *pkctName = szPkCatalogName, *pkscName = szPkSchemaName,
*pktbName = szPkTableName, *fkctName = szFkCatalogName,
*fkscName = szFkSchemaName, *fktbName = szFkTableName;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
if (SC_opencheck(stmt, func))
ret = SQL_ERROR;
else
ret = PGAPI_ForeignKeys(hstmt, pkctName, cbPkCatalogName,
pkscName, cbPkSchemaName, pktbName, cbPkTableName,
fkctName, cbFkCatalogName, fkscName, cbFkSchemaName,
fktbName, cbFkTableName);
if (SQL_SUCCESS == ret && theResultIsEmpty(stmt))
{
BOOL ifallupper = TRUE, reexec = FALSE;
SQLCHAR *newPkct = NULL, *newPksc = NULL, *newPktb = NULL,
*newFkct = NULL, *newFksc = NULL, *newFktb = NULL;
ConnectionClass *conn = SC_get_conn(stmt);
if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
ifallupper = FALSE;
if (newPkct = make_lstring_ifneeded(conn, szPkCatalogName, cbPkCatalogName, ifallupper), NULL != newPkct)
{
pkctName = newPkct;
reexec = TRUE;
}
if (newPksc = make_lstring_ifneeded(conn, szPkSchemaName, cbPkSchemaName, ifallupper), NULL != newPksc)
{
pkscName = newPksc;
reexec = TRUE;
}
if (newPktb = make_lstring_ifneeded(conn, szPkTableName, cbPkTableName, ifallupper), NULL != newPktb)
{
pktbName = newPktb;
reexec = TRUE;
}
if (newFkct = make_lstring_ifneeded(conn, szFkCatalogName, cbFkCatalogName, ifallupper), NULL != newFkct)
{
fkctName = newFkct;
reexec = TRUE;
}
if (newFksc = make_lstring_ifneeded(conn, szFkSchemaName, cbFkSchemaName, ifallupper), NULL != newFksc)
{
fkscName = newFksc;
reexec = TRUE;
}
if (newFktb = make_lstring_ifneeded(conn, szFkTableName, cbFkTableName, ifallupper), NULL != newFktb)
{
fktbName = newFktb;
reexec = TRUE;
}
if (reexec)
{
ret = PGAPI_ForeignKeys(hstmt, pkctName, cbPkCatalogName,
pkscName, cbPkSchemaName, pktbName, cbPkTableName,
fkctName, cbFkCatalogName, fkscName, cbFkSchemaName,
fktbName, cbFkTableName);
if (newPkct)
free(newPkct);
if (newPksc)
free(newPksc);
if (newPktb)
free(newPktb);
if (newFkct)
free(newFkct);
if (newFksc)
free(newFksc);
if (newFktb)
free(newFktb);
}
}
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
#endif /* UNICODE_SUPPORTXX */
RETCODE SQL_API
SQLMoreResults(HSTMT hstmt)
{
RETCODE ret;
StatementClass *stmt = (StatementClass *) hstmt;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
ret = PGAPI_MoreResults(hstmt);
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
#ifndef UNICODE_SUPPORTXX
RETCODE SQL_API
SQLNativeSql(HDBC hdbc,
SQLCHAR *szSqlStrIn,
SQLINTEGER cbSqlStrIn,
SQLCHAR *szSqlStr,
SQLINTEGER cbSqlStrMax,
SQLINTEGER *pcbSqlStr)
{
RETCODE ret;
ConnectionClass *conn = (ConnectionClass *) hdbc;
MYLOG(0, "Entering\n");
CC_examine_global_transaction(conn);
ENTER_CONN_CS(conn);
CC_clear_error(conn);
ret = PGAPI_NativeSql(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr,
cbSqlStrMax, pcbSqlStr);
LEAVE_CONN_CS(conn);
return ret;
}
#endif /* UNICODE_SUPPORTXX */
RETCODE SQL_API
SQLNumParams(HSTMT hstmt,
SQLSMALLINT *pcpar)
{
RETCODE ret;
StatementClass *stmt = (StatementClass *) hstmt;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
ret = PGAPI_NumParams(hstmt, pcpar);
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
#ifndef UNICODE_SUPPORTXX
RETCODE SQL_API
SQLPrimaryKeys(HSTMT hstmt,
SQLCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLCHAR *szTableName,
SQLSMALLINT cbTableName)
{
CSTR func = "SQLPrimaryKeys";
RETCODE ret;
StatementClass *stmt = (StatementClass *) hstmt;
SQLCHAR *ctName = szCatalogName, *scName = szSchemaName,
*tbName = szTableName;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
if (SC_opencheck(stmt, func))
ret = SQL_ERROR;
else
ret = PGAPI_PrimaryKeys(hstmt, ctName, cbCatalogName,
scName, cbSchemaName, tbName, cbTableName, 0);
if (SQL_SUCCESS == ret && theResultIsEmpty(stmt))
{
BOOL ifallupper = TRUE, reexec = FALSE;
SQLCHAR *newCt = NULL, *newSc = NULL, *newTb = NULL;
ConnectionClass *conn = SC_get_conn(stmt);
if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
ifallupper = FALSE;
if (newCt = make_lstring_ifneeded(conn, szCatalogName, cbCatalogName, ifallupper), NULL != newCt)
{
ctName = newCt;
reexec = TRUE;
}
if (newSc = make_lstring_ifneeded(conn, szSchemaName, cbSchemaName, ifallupper), NULL != newSc)
{
scName = newSc;
reexec = TRUE;
}
if (newTb = make_lstring_ifneeded(conn, szTableName, cbTableName, ifallupper), NULL != newTb)
{
tbName = newTb;
reexec = TRUE;
}
if (reexec)
{
ret = PGAPI_PrimaryKeys(hstmt, ctName, cbCatalogName,
scName, cbSchemaName, tbName, cbTableName, 0);
if (newCt)
free(newCt);
if (newSc)
free(newSc);
if (newTb)
free(newTb);
}
}
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
RETCODE SQL_API
SQLProcedureColumns(HSTMT hstmt,
SQLCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLCHAR *szProcName,
SQLSMALLINT cbProcName,
SQLCHAR *szColumnName,
SQLSMALLINT cbColumnName)
{
CSTR func = "SQLProcedureColumns";
RETCODE ret;
StatementClass *stmt = (StatementClass *) hstmt;
SQLCHAR *ctName = szCatalogName, *scName = szSchemaName,
*prName = szProcName, *clName = szColumnName;
UWORD flag = 0;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
if (stmt->options.metadata_id)
flag |= PODBC_NOT_SEARCH_PATTERN;
if (SC_opencheck(stmt, func))
ret = SQL_ERROR;
else
ret = PGAPI_ProcedureColumns(hstmt, ctName, cbCatalogName,
scName, cbSchemaName, prName, cbProcName,
clName, cbColumnName, flag);
if (SQL_SUCCESS == ret && theResultIsEmpty(stmt))
{
BOOL ifallupper = TRUE, reexec = FALSE;
SQLCHAR *newCt = NULL, *newSc = NULL, *newPr = NULL, *newCl = NULL;
ConnectionClass *conn = SC_get_conn(stmt);
if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
ifallupper = FALSE;
if (newCt = make_lstring_ifneeded(conn, szCatalogName, cbCatalogName, ifallupper), NULL != newCt)
{
ctName = newCt;
reexec = TRUE;
}
if (newSc = make_lstring_ifneeded(conn, szSchemaName, cbSchemaName, ifallupper), NULL != newSc)
{
scName = newSc;
reexec = TRUE;
}
if (newPr = make_lstring_ifneeded(conn, szProcName, cbProcName, ifallupper), NULL != newPr)
{
prName = newPr;
reexec = TRUE;
}
if (newCl = make_lstring_ifneeded(conn, szColumnName, cbColumnName, ifallupper), NULL != newCl)
{
clName = newCl;
reexec = TRUE;
}
if (reexec)
{
ret = PGAPI_ProcedureColumns(hstmt, ctName, cbCatalogName,
scName, cbSchemaName, prName, cbProcName,
clName, cbColumnName, flag);
if (newCt)
free(newCt);
if (newSc)
free(newSc);
if (newPr)
free(newPr);
if (newCl)
free(newCl);
}
}
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
RETCODE SQL_API
SQLProcedures(HSTMT hstmt,
SQLCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLCHAR *szProcName,
SQLSMALLINT cbProcName)
{
CSTR func = "SQLProcedures";
RETCODE ret;
StatementClass *stmt = (StatementClass *) hstmt;
SQLCHAR *ctName = szCatalogName, *scName = szSchemaName,
*prName = szProcName;
UWORD flag = 0;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
if (stmt->options.metadata_id)
flag |= PODBC_NOT_SEARCH_PATTERN;
if (SC_opencheck(stmt, func))
ret = SQL_ERROR;
else
ret = PGAPI_Procedures(hstmt, ctName, cbCatalogName,
scName, cbSchemaName, prName,
cbProcName, flag);
if (SQL_SUCCESS == ret && theResultIsEmpty(stmt))
{
BOOL ifallupper = TRUE, reexec = FALSE;
SQLCHAR *newCt = NULL, *newSc = NULL, *newPr = NULL;
ConnectionClass *conn = SC_get_conn(stmt);
if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
ifallupper = FALSE;
if (newCt = make_lstring_ifneeded(conn, szCatalogName, cbCatalogName, ifallupper), NULL != newCt)
{
ctName = newCt;
reexec = TRUE;
}
if (newSc = make_lstring_ifneeded(conn, szSchemaName, cbSchemaName, ifallupper), NULL != newSc)
{
scName = newSc;
reexec = TRUE;
}
if (newPr = make_lstring_ifneeded(conn, szProcName, cbProcName, ifallupper), NULL != newPr)
{
prName = newPr;
reexec = TRUE;
}
if (reexec)
{
ret = PGAPI_Procedures(hstmt, ctName, cbCatalogName,
scName, cbSchemaName, prName, cbProcName, flag);
if (newCt)
free(newCt);
if (newSc)
free(newSc);
if (newPr)
free(newPr);
}
}
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
#endif /* UNICODE_SUPPORTXX */
RETCODE SQL_API
SQLSetPos(HSTMT hstmt,
SQLSETPOSIROW irow,
SQLUSMALLINT fOption,
SQLUSMALLINT fLock)
{
RETCODE ret;
StatementClass *stmt = (StatementClass *) hstmt;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
ret = PGAPI_SetPos(hstmt, irow, fOption, fLock);
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
#ifndef UNICODE_SUPPORTXX
RETCODE SQL_API
SQLTablePrivileges(HSTMT hstmt,
SQLCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLCHAR *szTableName,
SQLSMALLINT cbTableName)
{
CSTR func = "SQLTablePrivileges";
RETCODE ret;
StatementClass *stmt = (StatementClass *) hstmt;
SQLCHAR *ctName = szCatalogName, *scName = szSchemaName,
*tbName = szTableName;
UWORD flag = 0;
MYLOG(0, "Entering\n");
if (SC_connection_lost_check(stmt, __FUNCTION__))
return SQL_ERROR;
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
if (stmt->options.metadata_id)
flag |= PODBC_NOT_SEARCH_PATTERN;
if (SC_opencheck(stmt, func))
ret = SQL_ERROR;
else
ret = PGAPI_TablePrivileges(hstmt, ctName, cbCatalogName,
scName, cbSchemaName, tbName, cbTableName, flag);
if (SQL_SUCCESS == ret && theResultIsEmpty(stmt))
{
BOOL ifallupper = TRUE, reexec = FALSE;
SQLCHAR *newCt = NULL, *newSc = NULL, *newTb = NULL;
ConnectionClass *conn = SC_get_conn(stmt);
if (SC_is_lower_case(stmt, conn)) /* case-insensitive identifier */
ifallupper = FALSE;
if (newCt = make_lstring_ifneeded(conn, szCatalogName, cbCatalogName, ifallupper), NULL != newCt)
{
ctName = newCt;
reexec = TRUE;
}
if (newSc = make_lstring_ifneeded(conn, szSchemaName, cbSchemaName, ifallupper), NULL != newSc)
{
scName = newSc;
reexec = TRUE;
}
if (newTb = make_lstring_ifneeded(conn, szTableName, cbTableName, ifallupper), NULL != newTb)
{
tbName = newTb;
reexec = TRUE;
}
if (reexec)
{
ret = PGAPI_TablePrivileges(hstmt, ctName, cbCatalogName,
scName, cbSchemaName, tbName, cbTableName, 0);
if (newCt)
free(newCt);
if (newSc)
free(newSc);
if (newTb)
free(newTb);
}
}
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
#endif /* UNICODE_SUPPORTXX */
RETCODE SQL_API
SQLBindParameter(HSTMT hstmt,
SQLUSMALLINT ipar,
SQLSMALLINT fParamType,
SQLSMALLINT fCType,
SQLSMALLINT fSqlType,
SQLULEN cbColDef,
SQLSMALLINT ibScale,
PTR rgbValue,
SQLLEN cbValueMax,
SQLLEN *pcbValue)
{
RETCODE ret;
StatementClass *stmt = (StatementClass *) hstmt;
MYLOG(0, "Entering\n");
ENTER_STMT_CS(stmt);
SC_clear_error(stmt);
StartRollbackState(stmt);
ret = PGAPI_BindParameter(hstmt, ipar, fParamType, fCType,
fSqlType, cbColDef, ibScale, rgbValue, cbValueMax,
pcbValue);
ret = DiscardStatementSvp(stmt, ret, FALSE);
LEAVE_STMT_CS(stmt);
return ret;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/b_127/openGauss-connector-odbc.git
git@gitee.com:b_127/openGauss-connector-odbc.git
b_127
openGauss-connector-odbc
openGauss-connector-odbc
master

搜索帮助