Commit Graph

17924 Commits

Author SHA1 Message Date
John Ralls
d1b406d8db Allow PRId64 & PRIu64 to work on MingGW in gnc-backend-dbi.cpp. 2016-11-07 12:47:34 -08:00
John Ralls
472b585feb Interim merge of c++-backend to expose C++ interface. 2016-10-29 13:16:29 -07:00
John Ralls
b8024fa9ea Fix review comment errors. 2016-10-29 12:40:57 -07:00
John Ralls
00880cd8f5 Fix another initializer list error. 2016-10-29 12:05:47 -07:00
John Ralls
70c803d6aa Fix unsigned-signed comparison mismatch. 2016-10-28 13:03:56 -07:00
John Ralls
afb57d0e7b Initialize a variable to appease travis-ci. 2016-10-28 12:31:49 -07:00
John Ralls
0bc35eb3e2 Fix two C++11 initializer list errors. 2016-10-28 11:38:29 -07:00
John Ralls
10ff71b29a Fix passing std::string to PWARN. 2016-10-28 10:33:54 -07:00
John Ralls
0baff455a2 Bug 769115 - db name isn't escaped well
More like at all, but it's supposed to be quoted rather than
escaped.
dbi_conn_quote_string() doesn't work well for database names,
so we do it directly. libdbi is also inconsistent about needing
quotes: They're required by mysql in SQL commands, and libdbi
requires them for internal commands that it turns into SQL
(e.g. db_conn_get_table_list) but not others (e.g dbi_conn_set_option).
2016-10-28 10:33:54 -07:00
John Ralls
7ff6e51a72 Use GncDbiProvider::get_table_list instead of calling out to libdbi.
GncDbiProvider can figure out the dbname for itself so change the
function signature to replace dbname with a particular table to
search for. Pass an empty string ("" works) to get the full list.
2016-10-28 10:33:54 -07:00
John Ralls
02d173d2e7 Replace g_str functions in dbi_library_test with std::stringstream. 2016-10-28 10:33:54 -07:00
John Ralls
451f3ffe4d DBI: Convert all of the gchar to char, remove a few gratuitous g_funcs.
Except where we're explicitly using other GLib functions.
2016-10-28 10:33:54 -07:00
John Ralls
5065bce45c Combine Postgres and MySql gnc_dbi_session_begin into a single template. 2016-10-28 10:33:53 -07:00
John Ralls
c141711425 Move creation of the provider to GncDbiSqlConnection's constructor.
Making GncDbiProviderImpl private to GncDbiSqlConnection.
2016-10-28 10:33:53 -07:00
John Ralls
5d38c7a729 Make conn_setup and the error handler functions templates on DbType. 2016-10-28 10:33:53 -07:00
John Ralls
314a5e10c2 Make gnc_lock_database a GncDbiSqlConnection member function.
Called from the constructor, so effective RAII with unlock_database called
from the destructor.
2016-10-28 10:33:53 -07:00
John Ralls
00e0a6e8b6 Change parameter of save_may_clobber_data from QofBackend to dbi_conn.
It actually needs the dbi_conn and that's known to its caller. Plus,
the backend's conn parameter hasn't actually been set so it was somewhat
coincidental that it worked.
2016-10-28 10:33:53 -07:00
John Ralls
fc47b63265 Templatize the session_begin functions and new_backend().
Thus removing the need for specializations of
QofDbiBackendProvider::create_backend().
2016-10-28 10:33:53 -07:00
John Ralls
61beed5686 Make sure that all of the GncDbiProviderImpl functions are in the right file.
Also merge create_table_ddl back into the only function that used it.
2016-10-28 10:33:53 -07:00
John Ralls
31c73a141e Extract functions conn_setup and create_database. 2016-10-28 10:33:53 -07:00
John Ralls
37d4257336 Extract-function conn_test_dbi_library.
Renaming the previous so-named function dbi_library_test.
2016-10-28 10:33:53 -07:00
John Ralls
5074bd590f Don't leak the quoted string returned from dbi_conn_quote_string_copy. 2016-10-28 10:33:53 -07:00
John Ralls
b38be9fe20 Get rid of gotos.
By replacing all of the char*s on the heap to std::strings, mostly in
a new UriString struct. Also lets us simplify the call to
set_standard_connection_options.
2016-10-28 10:33:53 -07:00
John Ralls
d8556ca7b5 Reformat adjust_sql_options a bit to reduce nesting. 2016-10-28 10:33:52 -07:00
John Ralls
431b704c92 Abstract setting database string-value options to function set_options. 2016-10-28 10:33:52 -07:00
John Ralls
ccc1cc49ab Separate DBI classes into their own files. 2016-10-28 10:33:52 -07:00
John Ralls
c2082bea99 Convert upgrade_table to member, remove some convenience functions.
To wit, gnc_sql_execute_select_sql, gnc_sql_execute_nonselect_sql,
gnc_sql_create_temp_table, and gnc_sql_create_select_statement.
2016-10-28 10:33:52 -07:00
John Ralls
54acef27c2 Remove a bunch of free functions already implemented as GncSqlBackend members. 2016-10-28 10:33:52 -07:00
John Ralls
a303ae688a Remove some GList and GSList uses from tests. 2016-10-28 10:33:52 -07:00
John Ralls
4b62deee42 Rework gnc_sql_append_guid_list_to_sql to eliminate GString and GList.
Which in turn forced rework of its users since the GString and GList were
passed-in parameters.
2016-10-28 10:33:52 -07:00
John Ralls
cb464da599 Replace GHashTable in GncSqlConnection with a std::vector. 2016-10-28 10:33:52 -07:00
John Ralls
885470b3e7 Replace std::vector<std::string> with StrVec. 2016-10-28 10:33:52 -07:00
John Ralls
d1fd223f9f Make conn_table_operation and add_columns_ddl members of GncDbiSqlConnection.
So they don't need to be friends.
2016-10-28 10:33:51 -07:00
John Ralls
6f67e2dd1a Convert GncSqlBackend and GncDbiBackend into a class hierarchy.
This is a rather complex change, because it also begins to separate the
responsibilities of the backends and GncSqlConnection.
2016-10-28 10:33:51 -07:00
John Ralls
d106346316 Minimally document GncDbiResult. 2016-10-28 10:33:51 -07:00
John Ralls
97b6e3a6c6 Pass ownership of the dbi_conn to GncDbiSqlConnection. 2016-10-28 10:33:51 -07:00
John Ralls
e0d5cc5b0b New function GncSqlConnection::dberror().
GncDbiSqlResult::dberror() just calls it instead of retrieving the dbi_conn
to call dbi_conn_error() itself.
2016-10-28 10:33:51 -07:00
John Ralls
583c951adc Use the right include delineators, it's not in the current source dir. 2016-10-28 10:33:51 -07:00
John Ralls
5823bf0d9a Move GncDbiSqlConnection into a separate file.
The declaration stays in gnc-backend-dbi.h because the dependencies are
still a little too tangled to be able to separate it.
2016-10-28 10:33:51 -07:00
John Ralls
ccbfb69cf1 Delete unused or duplicated member variables from GncSqlBackend & GncDbiBackend. 2016-10-28 10:33:51 -07:00
John Ralls
c0a193c593 Remove unused/never implemented QofBackend functions.
Note that the QofQuery functions that sort-of used them are ifdefed out
instead of deleted to serve as place-holders since we'll be bringing
back backend querying later.
2016-10-28 10:33:51 -07:00
John Ralls
eed4a012c3 Remove no-longer-needed gnc_table_slist_free. 2016-10-28 10:33:51 -07:00
John Ralls
1f52839271 Templatize QofDbiBackendProvider. 2016-10-28 10:33:50 -07:00
John Ralls
3894a2e8b7 Convert struct provider_functions_t into virtual class GncDbiProvider.
Implementation templated as template <DbType> GncDbiProviderImpl.
Converted GSLists to std::vectors and GStrings to std::strings.
2016-10-28 10:33:50 -07:00
John Ralls
faf59964e4 Rename gnc-backend-dbi-priv.h to gnc-backend-dbi.hpp.
Also remove "#ifdef __cplusplus" from both gnc-backend-dbi.hpp and
gnc-backend-dbi.h, these files are always C++.
2016-10-28 10:33:50 -07:00
John Ralls
7fe404808a Delete some no-longer (or in some cases never) used functions. 2016-10-28 10:33:50 -07:00
John Ralls
cfa3ab24f6 Convert GncSqlConnection to a C++ class. 2016-10-28 10:33:50 -07:00
John Ralls
12e763884e Use a std::unique_ptr for GncSqlStatement for better memory management. 2016-10-28 10:33:50 -07:00
John Ralls
64c1fda6ec gnc-backend-dbi.cpp: NULL -> nullptr. 2016-10-28 10:33:50 -07:00
John Ralls
92f2f2765e Replace the ptr-to-func GncSqlObjectBackend struct with a class hierarchy.
Can't template them because we need to iterate on the collection when loading.
2016-10-28 10:33:50 -07:00