From 26b30efd0cf93478be68218090435f995809e546 Mon Sep 17 00:00:00 2001 From: Hiroshi Inoue Date: Mon, 18 May 2020 19:53:48 +0900 Subject: Improve execution of parameterized SQL statements with arrays of parameters by sending chunks of SQL statements. If SQL_ATTR_CURSOR_TYPE of an statement is SQL_CURSOR_FORWARD_ONLY, SQL_ATTR_CONCURRENCY is SQL_CONCUR_READ_ONLY and extended protocol isn't used, the batch execution of the statement is possible. A new option Batch Size was introduced for such cases. Batch Size: Split an array (of parameters) into chunks of Batch Size to execute statements. The last chunk may contain less than Batch Size elements. Setting 1 to this option forces the current one by one execution. Also turn off use_server_side_prepare option temporarily when batch executuion is possible. --- statement.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'statement.h') diff --git a/statement.h b/statement.h index 5abeca8..02f7ad5 100644 --- a/statement.h +++ b/statement.h @@ -12,6 +12,7 @@ #include "psqlodbc.h" #include +#include "pqexpbuffer.h" #include "pgtypes.h" #include "bind.h" #include "descriptor.h" @@ -167,6 +168,12 @@ enum STMT_FETCH_NORMAL, STMT_FETCH_EXTENDED }; +/* Type of the 3rd parameter of Exec_with_parameters_resolved() */ +typedef enum { + DIRECT_EXEC, + DEFFERED_EXEC, + LAST_EXEC +} EXEC_TYPE; #define PG_NUM_NORMAL_KEYS 2 @@ -271,6 +278,7 @@ struct StatementClass_ po_ind_t join_info; /* have joins ? */ po_ind_t parse_method; /* parse_statement is forced or ? */ po_ind_t curr_param_result; /* current param result is set ? */ + po_ind_t has_notice; /* exec result contains notice messages ? */ pgNAME cursor_name; char *plan_name; @@ -291,6 +299,12 @@ struct StatementClass_ SQLLEN last_fetch_count_include_ommitted; time_t stmt_time; struct tm localtime; + // for batch execution + signed char use_server_side_prepare; + int batch_size; + EXEC_TYPE exec_type; + int count_of_deffered; + PQExpBufferData stmt_deffered; /* SQL_NEED_DATA Callback list */ StatementClass *execute_delegate; StatementClass *execute_parent; -- cgit v1.2.3