⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 odbcapi.c

📁 postgresql-odbc,跨平台应用
💻 C
📖 第 1 页 / 共 3 页
字号:
		CC_log_error("SQLGetInfo(30)", "", conn);#else	mylog("[%s]", func);	if (ret = PGAPI_GetInfo(ConnectionHandle, InfoType, InfoValue,			BufferLength, StringLength), SQL_ERROR == ret)		CC_log_error(func, "", conn);#endifcleanup:	LEAVE_CONN_CS(conn);	return ret;}#if (ODBCVER < 0x0300)RETCODE		SQL_APISQLGetStmtOption(HSTMT StatementHandle,				 SQLUSMALLINT Option, PTR Value){	CSTR	func = "SQLGetStmtOption";	RETCODE	ret;	StatementClass *stmt = (StatementClass *) StatementHandle;	mylog("[%s]", func);	ENTER_STMT_CS(stmt);	SC_clear_error(stmt);	StartRollbackState(stmt);	ret = PGAPI_GetStmtOption(StatementHandle, Option, Value, NULL, 64);	ret = DiscardRollbackState(stmt, ret, FALSE);	LEAVE_STMT_CS(stmt);	return ret;}#endif /* ODBCVER */RETCODE		SQL_APISQLGetTypeInfo(HSTMT StatementHandle,			   SQLSMALLINT DataType){	CSTR func = "SQLGetTypeInfo";	RETCODE	ret;	StatementClass *stmt = (StatementClass *) StatementHandle;	mylog("[%s]", func);	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;}RETCODE		SQL_APISQLNumResultCols(HSTMT StatementHandle,				 SQLSMALLINT *ColumnCount){	RETCODE	ret;	StatementClass *stmt = (StatementClass *) StatementHandle;	mylog("[SQLNumResultCols]");	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_APISQLParamData(HSTMT StatementHandle,			 PTR *Value){	RETCODE	ret;	StatementClass *stmt = (StatementClass *) StatementHandle;	mylog("[SQLParamData]");	ENTER_STMT_CS(stmt);	SC_clear_error(stmt);	ret = PGAPI_ParamData(StatementHandle, Value);	ret = DiscardStatementSvp(stmt, ret, FALSE);	LEAVE_STMT_CS(stmt);	return ret;}RETCODE		SQL_APISQLPrepare(HSTMT StatementHandle,		   SQLCHAR *StatementText, SQLINTEGER TextLength){	RETCODE	ret;	StatementClass *stmt = (StatementClass *) StatementHandle;	mylog("[SQLPrepare]");	ENTER_STMT_CS(stmt);	SC_clear_error(stmt);	StartRollbackState(stmt);	ret = PGAPI_Prepare(StatementHandle, StatementText, TextLength);	ret = DiscardStatementSvp(stmt, ret, FALSE);	LEAVE_STMT_CS(stmt);	return ret;}RETCODE		SQL_APISQLPutData(HSTMT StatementHandle,		   PTR Data, SQLLEN StrLen_or_Ind){	RETCODE	ret;	StatementClass *stmt = (StatementClass *) StatementHandle;	mylog("[SQLPutData]");	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_APISQLRowCount(HSTMT StatementHandle,			SQLLEN *RowCount){	RETCODE	ret;	StatementClass *stmt = (StatementClass *) StatementHandle;	mylog("[SQLRowCount]");	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;}#if (ODBCVER < 0x0300)RETCODE		SQL_APISQLSetConnectOption(HDBC ConnectionHandle,					SQLUSMALLINT Option, SQLULEN Value){	RETCODE	ret;	ConnectionClass *conn = (ConnectionClass *) ConnectionHandle;	mylog("[SQLSetConnectionOption]");	ENTER_CONN_CS(conn);	CC_clear_error(conn);	ret = PGAPI_SetConnectOption(ConnectionHandle, Option, Value);	LEAVE_CONN_CS(conn);	return ret;}#endif /* ODBCVER */RETCODE		SQL_APISQLSetCursorName(HSTMT StatementHandle,				 SQLCHAR *CursorName, SQLSMALLINT NameLength){	RETCODE	ret;	StatementClass *stmt = (StatementClass *) StatementHandle;	mylog("[SQLSetCursorName]");	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;}RETCODE		SQL_APISQLSetParam(HSTMT StatementHandle,			SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,			SQLSMALLINT ParameterType, SQLULEN LengthPrecision,			SQLSMALLINT ParameterScale, PTR ParameterValue,			SQLLEN *StrLen_or_Ind){	mylog("[SQLSetParam]");	SC_clear_error((StatementClass *) StatementHandle);	/*	 * return PGAPI_SetParam(StatementHandle, ParameterNumber, ValueType,	 * ParameterType, LengthPrecision, ParameterScale, ParameterValue,	 * StrLen_or_Ind);	 */	return SQL_ERROR;}#if (ODBCVER < 0x0300)RETCODE		SQL_APISQLSetStmtOption(HSTMT StatementHandle,				 SQLUSMALLINT Option, SQLULEN Value){	RETCODE	ret;	StatementClass *stmt = (StatementClass *) StatementHandle;	mylog("[SQLSetStmtOption]");	ENTER_STMT_CS(stmt);	SC_clear_error(stmt);	StartRollbackState(stmt);	ret = PGAPI_SetStmtOption(StatementHandle, Option, Value);	ret = DiscardStatementSvp(stmt, ret, FALSE);	LEAVE_STMT_CS(stmt);	return ret;}#endif /* ODBCVER */RETCODE		SQL_APISQLSpecialColumns(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("[%s]", func);	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 && 0 == QR_get_num_total_tuples(SC_get_Result(stmt))) 	{		BOOL	ifallupper = TRUE, reexec = FALSE;		char *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_APISQLStatistics(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("[%s]", func);	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 && 0 == QR_get_num_total_tuples(SC_get_Result(stmt))) 	{		BOOL	ifallupper = TRUE, reexec = FALSE;		char *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_APISQLTables(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("[%s]", func);	ENTER_STMT_CS(stmt);	SC_clear_error(stmt);	StartRollbackState(stmt);#if (ODBCVER >= 0x0300)	if (stmt->options.metadata_id)		flag |= PODBC_NOT_SEARCH_PATTERN;#endif	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 && 0 == QR_get_num_total_tuples(SC_get_Result(stmt))) 	{		BOOL	ifallupper = TRUE, reexec = FALSE;		char *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;}#if (ODBCVER < 0x0300)RETCODE		SQL_APISQLTransact(HENV EnvironmentHandle,			HDBC ConnectionHandle, SQLUSMALLINT CompletionType){	RETCODE	ret;	mylog("[SQLTransact]");	if (NULL != EnvironmentHandle)		ENTER_ENV_CS((EnvironmentClass *) EnvironmentHandle);	else		ENTER_CONN_CS((ConnectionClass *) ConnectionHandle);	ret = PGAPI_Transact(EnvironmentHandle, ConnectionHandle, CompletionType);	if (NULL != EnvironmentHandle)		LEAVE_ENV_CS((EnvironmentClass *) EnvironmentHandle);	else		LEAVE_CONN_CS((ConnectionClass *) ConnectionHandle);	return ret;}RETCODE		SQL_APISQLColAttributes(				 HSTMT hstmt,				 SQLUSMALLINT icol,				 SQLUSMALLINT fDescType,				 PTR rgbDesc,				 SQLSMALLINT cbDescMax,				 SQLSMALLINT *pcbDesc,				 SQLLEN *pfDesc){	RETCODE	ret;	StatementClass *stmt = (StatementClass *) hstmt;	mylog("[SQLColAttributes]");	ENTER_STMT_CS(stmt);	SC_clear_error(stmt);	StartRollbackState(stmt);	ret = PGAPI_ColAttributes(hstmt, icol, fDescType, rgbDesc,							   cbDescMax, pcbDesc, pfDesc);	ret = DiscardStatementSvp(stmt, ret, FALSE);	LEAVE_STMT_CS(stmt);	return ret;}#endif /* ODBCVER */RETCODE		SQL_APISQLColumnPrivileges(					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("[%s]", func);	ENTER_STMT_CS(stmt);	SC_clear_error(stmt);	StartRollbackState(stmt);#if (ODBCVER >= 0x0300)	if (stmt->options.metadata_id)		flag |= PODBC_NOT_SEARCH_PATTERN;#endif	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 && 0 == QR_get_num_total_tuples(SC_get_Result(stmt))) 	{		BOOL	ifallupper = TRUE, reexec = FALSE;		char *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;}RETCODE		SQL_APISQLDescribeParam(				 HSTMT hstmt,				 SQLUSMALLINT ipar,				 SQLSMALLINT *pfSqlType,				 SQLULEN *pcbParamDef,				 SQLSMALLINT *pibScale,				 SQLSMALLINT *pfNullable){	RETCODE	ret;	StatementClass *stmt = (StatementClass *) hstmt;	mylog("[SQLDescribeParam]");	ENTER_STMT_CS(stmt);	SC_clear_error(stmt);	StartRollbackState(stmt);	ret = PGAPI_DescribeParam(hstmt, ipar, pfSqlType, pcbParamDef,							   pibScale, pfNullable);	ret = DiscardStatementSvp(stmt, ret, FALSE);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -