added: QueryResult stack to PostgreSQLConnector
this allowes us to call query() recursively (from after_select() callback) git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1085 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -50,6 +50,15 @@ public:
|
||||
PostgreSQLConnector();
|
||||
virtual ~PostgreSQLConnector();
|
||||
|
||||
void clear_all_query_results();
|
||||
void clear_last_query_result();
|
||||
|
||||
// give me a better names
|
||||
virtual size_t last_select_size(); // was: last_select_size
|
||||
virtual ExecStatusType last_query_status();
|
||||
virtual bool is_last_result(ExecStatusType t); // was: is_last_result
|
||||
|
||||
|
||||
void set_log_queries(bool log_queries);
|
||||
|
||||
bool query(const PT::TextStream & stream);
|
||||
@@ -64,15 +73,12 @@ public:
|
||||
bool query_update(const PT::TextStream & stream);
|
||||
bool query_insert(const PT::TextStream & stream);
|
||||
|
||||
// give me a better name
|
||||
virtual size_t last_select_size();
|
||||
|
||||
// give me a better name
|
||||
virtual void set_current_row_at_beginning();
|
||||
virtual void advance_current_row();
|
||||
|
||||
|
||||
bool is_last_result(ExecStatusType t);
|
||||
|
||||
/*
|
||||
* get column index from the last query (select)
|
||||
@@ -93,40 +99,61 @@ public:
|
||||
int get_value_length(int row, int col);
|
||||
|
||||
|
||||
void clear_result();
|
||||
|
||||
void set_conn_param(const std::wstring & database, const std::wstring & user, const std::wstring & pass);
|
||||
void connect();
|
||||
void wait_for_connection();
|
||||
void close();
|
||||
bool assert_connection(bool put_log = true, bool throw_if_no_connection = true);
|
||||
//bool assert_connection(bool put_log = true, bool throw_if_no_connection = true);
|
||||
bool assert_connection(bool put_log = true);
|
||||
void set_db_parameters();
|
||||
void log_connection_socket();
|
||||
|
||||
//PGconn * GetPgConn();
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
PGconn * pg_conn;
|
||||
PGresult * last_result; // can be null
|
||||
size_t last_result_rows; // how many rows in the last result query
|
||||
ExecStatusType last_status;
|
||||
// PGresult * last_result; // can be null
|
||||
// size_t last_result_rows; // how many rows in the last result query
|
||||
// ExecStatusType last_status;
|
||||
bool log_queries;
|
||||
PT::TextStream stream;
|
||||
std::string query_str;
|
||||
size_t cur_row;
|
||||
std::string temp_column_name;
|
||||
|
||||
std::wstring db_database;
|
||||
std::wstring db_user;
|
||||
std::wstring db_pass;
|
||||
|
||||
struct QueryResult
|
||||
{
|
||||
PGresult * result; // can be null
|
||||
size_t result_rows; // how many rows in the result query
|
||||
ExecStatusType status;
|
||||
size_t cur_row; // used for reading
|
||||
|
||||
QueryResult()
|
||||
{
|
||||
result = nullptr;
|
||||
result_rows = 0;
|
||||
status = PGRES_EMPTY_QUERY;
|
||||
cur_row = 0;
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<QueryResult> query_results;
|
||||
|
||||
|
||||
void allocate_default_expression();
|
||||
|
||||
void overwrite(PT::TextStream & stream);
|
||||
virtual const char * get_field_string_value(const char * column_name);
|
||||
virtual const char * get_field_string_value(const wchar_t * field_name);
|
||||
|
||||
|
||||
const char * query_last_sequence(const wchar_t * sequence_table_name);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user