statement.h

来自「postgresql-odbc,跨平台应用」· C头文件 代码 · 共 517 行 · 第 1/2 页

H
517
字号
/* File:			statement.h * * Description:		See "statement.c" * * Comments:		See "notice.txt" for copyright and license information. * */#ifndef __STATEMENT_H__#define __STATEMENT_H__#include "psqlodbc.h"#include <time.h>#include "pgtypes.h"#include "bind.h"#include "descriptor.h"#if defined (POSIX_MULTITHREAD_SUPPORT)#include <pthread.h>#endiftypedef enum{	STMT_ALLOCATED,				/* The statement handle is allocated, but								 * not used so far */	STMT_READY,					/* the statement is waiting to be executed */	STMT_PREMATURE,				/* ODBC states that it is legal to call								 * e.g. SQLDescribeCol before a call to								 * SQLExecute, but after SQLPrepare. To								 * get all the necessary information in								 * such a case, we simply execute the								 * query _before_ the actual call to								 * SQLExecute, so that statement is								 * considered to be "premature". */	STMT_FINISHED,				/* statement execution has finished */	STMT_EXECUTING				/* statement execution is still going on */} STMT_Status;/* *		ERROR status code * *		The code for warnings must be minus *		and  LOWEST_STMT_ERROR must be set to *		the least code number. *		The code for STMT_OK is 0 and error *		codes follow after it. */ 	enum {	LOWEST_STMT_ERROR		=		(-6)	/* minus values mean warning returns */	,STMT_ERROR_IN_ROW		=		(-6)	,STMT_OPTION_VALUE_CHANGED	=		(-5)	,STMT_ROW_VERSION_CHANGED	=		(-4)	,STMT_POS_BEFORE_RECORDSET	=		(-3)	,STMT_TRUNCATED			=		(-2)	,STMT_INFO_ONLY			=		(-1)				/* not an error message,				 * just a notification				 * to be returned by				 * SQLError				 */	,STMT_OK			=		0	,STMT_EXEC_ERROR	,STMT_STATUS_ERROR	,STMT_SEQUENCE_ERROR	,STMT_NO_MEMORY_ERROR	,STMT_COLNUM_ERROR	,STMT_NO_STMTSTRING	,STMT_ERROR_TAKEN_FROM_BACKEND	,STMT_INTERNAL_ERROR	,STMT_STILL_EXECUTING	,STMT_NOT_IMPLEMENTED_ERROR	,STMT_BAD_PARAMETER_NUMBER_ERROR	,STMT_OPTION_OUT_OF_RANGE_ERROR		,STMT_INVALID_COLUMN_NUMBER_ERROR	,STMT_RESTRICTED_DATA_TYPE_ERROR	,STMT_INVALID_CURSOR_STATE_ERROR	,STMT_CREATE_TABLE_ERROR	,STMT_NO_CURSOR_NAME	,STMT_INVALID_CURSOR_NAME	,STMT_INVALID_ARGUMENT_NO	,STMT_ROW_OUT_OF_RANGE	,STMT_OPERATION_CANCELLED	,STMT_INVALID_CURSOR_POSITION	,STMT_VALUE_OUT_OF_RANGE	,STMT_OPERATION_INVALID	,STMT_PROGRAM_TYPE_OUT_OF_RANGE	,STMT_BAD_ERROR	,STMT_INVALID_OPTION_IDENTIFIER	,STMT_RETURN_NULL_WITHOUT_INDICATOR	,STMT_INVALID_DESCRIPTOR_IDENTIFIER	,STMT_OPTION_NOT_FOR_THE_DRIVER	,STMT_FETCH_OUT_OF_RANGE	,STMT_COUNT_FIELD_INCORRECT	,STMT_INVALID_NULL_ARG};/* statement types */enum{	STMT_TYPE_UNKNOWN = -2	,STMT_TYPE_OTHER = -1	,STMT_TYPE_SELECT = 0	,STMT_TYPE_INSERT	,STMT_TYPE_UPDATE	,STMT_TYPE_DELETE	,STMT_TYPE_CREATE	,STMT_TYPE_ALTER	,STMT_TYPE_DROP	,STMT_TYPE_GRANT	,STMT_TYPE_REVOKE	,STMT_TYPE_PROCCALL	,STMT_TYPE_LOCK	,STMT_TYPE_TRANSACTION	,STMT_TYPE_CLOSE	,STMT_TYPE_FETCH	,STMT_TYPE_PREPARE	,STMT_TYPE_EXECUTE	,STMT_TYPE_DEALLOCATE	,STMT_TYPE_ANALYZE	,STMT_TYPE_NOTIFY	,STMT_TYPE_EXPLAIN	,STMT_TYPE_SET	,STMT_TYPE_RESET	,STMT_TYPE_DECLARE	,STMT_TYPE_MOVE	,STMT_TYPE_COPY	,STMT_TYPE_START	,STMT_TYPE_SPECIAL};#define STMT_UPDATE(stmt)	(stmt->statement_type > STMT_TYPE_SELECT)/*	Parsing status */enum{	STMT_PARSE_NONE = 0	,STMT_PARSE_COMPLETE	/* the driver parsed the statement */	,STMT_PARSE_INCOMPLETE	,STMT_PARSE_FATAL	,STMT_PARSE_MASK = 3L	,STMT_PARSED_OIDS = (1L << 2)	,STMT_FOUND_KEY = (1L << 3)	,STMT_HAS_ROW_DESCRIPTION = (1L << 4) /* already got the col info */	,STMT_REFLECTED_ROW_DESCRIPTION = (1L << 5)};/*	Result style */enum{	STMT_FETCH_NONE = 0,	STMT_FETCH_NORMAL,	STMT_FETCH_EXTENDED};#define	PG_NUM_NORMAL_KEYS	2typedef	RETCODE	(*NeedDataCallfunc)(RETCODE, void *);typedef	struct{	NeedDataCallfunc	func;	void			*data;}	NeedDataCallback;/********	Statement Handle	***********/struct StatementClass_{	ConnectionClass *hdbc;		/* pointer to ConnectionClass this								 * statement belongs to */	QResultClass *result;		/* result of the current statement */	QResultClass *curres;		/* the current result in the chain */	HSTMT FAR  *phstmt;	StatementOptions options;	StatementOptions options_orig;	/* attached descriptor handles */	ARDClass	*ard;	APDClass	*apd;	IRDClass	*ird;	IPDClass	*ipd;	/* implicit descriptor handles */	ARDClass	ardi;	IRDClass	irdi;	APDClass	apdi;	IPDClass	ipdi;	STMT_Status status;	char	   *__error_message;	int			__error_number;	PG_ErrorInfo	*pgerror;	SQLLEN		currTuple;	/* current absolute row number (GetData,						 * SetPos, SQLFetch) */	GetDataInfo	gdata_info;	SQLLEN		save_rowset_size;	/* saved rowset size in case of							 * change/FETCH_NEXT */	SQLLEN		rowset_start;	/* start of rowset (an absolute row								 * number) */	SQLSETPOSIROW	bind_row;	/* current offset for Multiple row/column						 * binding */	Int2		current_col;	/* current column for GetData -- used to						 * handle multiple calls */	SQLLEN		last_fetch_count;	/* number of rows retrieved in						 * last fetch/extended fetch */	int		lobj_fd;		/* fd of the current large object */	char	   *statement;		/* if non--null pointer to the SQL					 * statement that has been executed */	TABLE_INFO	**ti;	Int2		ntab;	Int2		num_key_fields;	Int2		statement_type; /* According to the defines above */	Int2		num_params;	Int2		data_at_exec; /* Number of params needing SQLPutData */	Int2		current_exec_param;	/* The current parameter for						 * SQLPutData */	PutDataInfo	pdata_info;	char		parse_status;	char		proc_return;	char		put_data;	/* Has SQLPutData been called ? */	char		catalog_result;	/* Is this a result of catalog function ? */	char		prepare;	/* is this a prepared statement ? */	char		prepared;	/* is this statement already					 * prepared at the server ? */	char		internal;	/* Is this statement being called							 * internally ? */	char		transition_status;	/* Transition status */	char		multi_statement; /* -1:unknown 0:single 1:multi */	char		rbonerr;	/* rollback on error */	char		discard_output_params;	 /* discard output parameters on parse stage */	char		cancel_info;	/* cancel information */	char		ref_CC_error;	/* refer to CC_error ? */	char		lock_CC_for_rb;	/* lock CC for statement rollback ? */	char		join_info;	/* have joins ? */	char		parse_method;	/* parse_statement is forced or ? */	pgNAME		cursor_name;	char		*plan_name;	char		*stmt_with_params;	/* statement after parameter							 * substitution */	Int4		stmt_size_limit; /* PG restriction */	SQLLEN		exec_start_row;	SQLLEN		exec_end_row;	SQLLEN		exec_current_row;	char		pre_executing;	/* This statement is prematurely executing */	char		inaccurate_result;	/* Current status is PREMATURE but						 * result is inaccurate */	unsigned char	miscinfo;	char		updatable;	SQLLEN		diag_row_count;	char		*load_statement; /* to (re)load updatable individual rows */	char		*execute_statement; /* to execute the prepared plans */	Int4		from_pos;		Int4		where_pos;	SQLLEN		last_fetch_count_include_ommitted;	time_t		stmt_time;	/* SQL_NEED_DATA Callback list */

⌨️ 快捷键说明

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