Commit Graph

141 Commits

Author SHA1 Message Date
Geert Janssens
239ee6797a Fix crash when cancelling a Save As... overwrite action
This was discovered while trying to fix bug 796792. However that bug itself
is totally unrelated.
2018-08-08 15:47:09 +02:00
John Ralls
43af50bd8a Bug 796759 - --add-price-quotes <sql file> leaves a lock on the file.
First, save isn't necessary if the book is dirty, so don't... but that
means that the book has to be marked dirty after a session swap. No more
laziness.

Second, regardless of the outcome of inner_main_add_price_quotes the
session must be destroyed to remove the lock.

A couple of cleanups in QofSessionImpl::save as well: Rewrote the
descriptive comment to reflect how it really works when the backend has
gotten disconnected and removed the superfluous qof_book_set_backend
with the backend that we'd *just gotten from the book*.
2018-07-14 17:09:22 -07:00
John Ralls
de927d535d Fix test-backend-dbi for Postgress and MySQL.
Pass MySQL database exists errors and skip creating the database
if it exists.
2018-07-13 16:34:42 -07:00
John Ralls
756f444ac3 Update bug tracker URL
Change all instances of bugzilla.gnome.org to bugs.gnucash.org, reflecting
our migration to a self-hosted bug tracker.

Inform the Translation Project Coordinator at release that this affects
translatable strings and that all message catalogs have been updated.
2018-07-13 09:49:33 -07:00
Geert Janssens
9d5712ef09 Use same 'force' logic sequence for sqlite and other dbs 2018-07-06 22:32:01 +02:00
Geert Janssens
875781847a Bug 796724 - Can't overwrite gnucash DB on MariaDB 2018-07-06 22:30:15 +02:00
Geert Janssens
9ab06bc9b3 Bug 789594 - Unable to overwrite sqlite3 database file 2018-07-05 22:41:56 +02:00
Geert Janssens
240c4bd2cf Whitespace cosmetics 2018-07-05 22:41:56 +02:00
John Ralls
f7ed46a35b Bug 796248 - Editing Scheduled Transaction, take 2.
In addition to not begining to edit already-loaded transactions,
don't try to load splits that are already loaded. It shouldn't
be possible to load a transaction without also loading its splits.
2018-06-26 15:04:23 -07:00
John Ralls
4e04f6e51d Don't warn about an invalid date if it's just an empty column. 2018-06-26 15:00:51 -07:00
John Ralls
1e6627c4c5 [DBI Backend] Init and finalize the backend in setup and teardown.
Xcode 9's clang creates a separate dbi_instance for each test and so
each one needs to be initialized during its setup and finalized at
teardown.
2018-06-23 17:35:42 -07:00
Geert Janssens
a438a59513 Bug 795944 - Cannot store change to Business Suppliers data
The underlying problem was that the vendor object remained in infant state
That confused the backend code so it used an sql INSERT statement instead
of an UPDATE statement to write back the changes. As the object already
existed in the db this would fail.
The fix is to ensure the object doesn't remain in infant state during
sql loading. See the bug report for a more detailed explanation.
2018-06-23 13:15:46 +02:00
John Ralls
f144a8deb7 Revert "Bug 796248 - Editing Scheduled Transaction"
This reverts commit ffe6044cd6.
It breaks loading splits on transactions that have already
been loaded.
2018-06-22 10:14:21 -07:00
John Ralls
696277bbf6 New clang error enforces virtual destructors. 2018-06-22 09:09:33 -07:00
John Ralls
ffe6044cd6 Bug 796248 - Editing Scheduled Transaction
An extra XaccTransBeginEdit, never committed, for transactions that
the backend tried to load when they were already there. That made
the register think that something else had it open.
2018-06-12 15:49:28 -07:00
John Ralls
c8861d4666 Bug 795276 - Invalid date on price stops file from being parsed.
Instead of reporting an error and declining to load the file (XML)
or failing to enter a value (SQL) when a bad date is found in the
database, use a 0 time stamp (1970-01-01 00:00:00 UTC). Adds a warning
in SQL backends; there was one already in XML.
2018-06-12 14:56:27 -07:00
John Ralls
333a14c0fd Fix ubuntu build failure.
%$^%$ C++11 initializer list behavior.
2018-06-02 17:57:42 -07:00
John Ralls
3b3074c28d Bug 796117 - Connecting 3.1 to an existing mysql db drops all data
Provide a backup recovery function that instead of dropping primaries
and restoring backups merges the primaries and backups. This should
handle a worst-case safe-save failure where the backup tables don't
have a complete set of rows for some reason.
2018-06-02 16:21:49 -07:00
John Ralls
f8045b2735 A wee bit of C++ style. 2018-06-02 16:21:05 -07:00
John Ralls
537fd995a3 Ensure full precision of doubles is saved to SQL.
std::iostream's operator<<(double) uses only 6 digits of precision
by default. We want 12 digits when saving.
2018-06-02 16:20:36 -07:00
John Ralls
9db60ca63c Make float database operations more consistent.
We don't use floats in GnuCash, we use doubles (and those as little as
possible), but dbd-sqlite3 is broken in that it stores only floats.
Simply casting floats to doubles introduces bogus additional digits
that can cause round-trip tests to fail. Instead convert floats to
doubles by multiplying by 10E6, rounding, then dividing by 10E6.
2018-06-02 16:16:41 -07:00
John Ralls
3e052e8dac [DBI Backend] Rework backup-table management.
Removes a public function, GncDbiSqlConnection::table_manage_backup that
should have been private in the first place.

Better encapsulates table renames and drops with private functions and
handles cases where there exist some primary tables and some backup tables.
2018-06-01 14:50:41 -07:00
John Ralls
e23769f078 [DBI Backend] If there's a set error value use that to set the backend error. 2018-06-01 14:13:11 -07:00
John Ralls
f504e39d78 Correct the type of error variables.
C++ doesn't like interchanging enums and ints.
2018-06-01 14:13:11 -07:00
John Ralls
464fdeeb26 [DBI Backend] Remove unused TableOpTypes. 2018-06-01 14:13:10 -07:00
John Ralls
243bf8afce Bug 796369 - Notes lost or perhaps just not displaying when using...
SQLite backend.

Release Note: This bug caused data loss if you saved your SQLite3
database to a different file or database.

The problem is that in SQLite3 (though not in MySQL or PgSQL) the
subquery ((SELECT DISTINCT guid FROM transactions)) (note the double
parentheses) returns only the first guid in the subquery's results.

Some transactions are loaded by special queries and those queries are
also used to retrieve the transaction's slots so they weren't affected.
2018-05-25 12:58:39 -07:00
gnucash-dev
8b3a874418 Fix typo 2018-05-04 10:04:52 -07:00
Geert Janssens
a9f35ed7ae Lowercase cmake commands
A huge bikeshed fest but it distracted me enough to do it anyway.
2018-05-03 23:18:15 +02:00
Geert Janssens
b761b5a0dc Bug 795377 - Reads and saves Gnucash 2.6.19 XML file, then can't reread it, due to bad date in old file
This commit contains another round of cleanups in the
timespec to time64 conversion. There were a number of
false assumptions that time64 = 0 would be a bad date
in the xml parser. This commit corrects enough of them to
eliminate the bug. Further cleanup is probably advised but
can be done at a later stage.
2018-04-28 12:19:28 +02:00
Geert Janssens
c71204628d Bug 795031 - 3.0 Crashes on loading when opening 2.6.19 file 2018-04-26 23:06:36 +02:00
John Ralls
cad6bb4272 Bug 792105 - Startup takes several minutes, take two.
First, remove the unnecessary locale push & pop on <CT_TIME64>load.

Second, the registry accesses were caused by using g_win32_get_locale
to convert the Microsoft locale strings to POSIX ones. We don't care
what kind of string we get as long as we can pass it back to setlocale,
so remove that.

Third, gnc_push/pop_locale were used only in backend/dbi in a
very limited way and did much more than was necessary, so
convert them to C++ inlines in gnc-backend-dbi.hpp that does
only what we need them to.
2018-04-17 16:32:45 -07:00
John Ralls
39aecb7610 Bug 794936 - 3.0 does not open previously saved sqlite3 files...
properly - corrupted business data

Turned out to be a pointer/value mismatch between <CT_NUMERIC>load()
and most of the setter functions, so the address was getting set
as the value.
2018-04-17 16:32:44 -07:00
Geert Janssens
3138229cf6 A few whitespace fixups 2018-04-17 23:04:21 +02:00
Geert Janssens
06db9bcf2b Fix crash when loading sql book with posted transactions
This crash started to appear as of commit 80dbb9940b because the sequence
of split loading has changed as a result of the query optimizations.
Invoice transactions get loaded before the general transaction loading happens.
However because of this, when an invoice transaction was encountered again
during general transaction loading, it was (correctly) not created again
AND (incorrectly) not opened for subsequent editing. This caused
an assert to fail when the splits for this transaction are loaded
shortly afterwards. The solution is simply to ensure all transactions
are opened for editing during the general transaction loading call.
2018-04-17 23:04:21 +02:00
Geert Janssens
80dbb9940b Fix a couple of warnings introduced by commit 01420adb99
In addition make the code really use an inner join if no additional conditions are set
which gives better performance on at least postgresql
2018-04-17 19:45:39 +02:00
John Ralls
4ba77f7b09 Remove another gnc_pop_locale(). 2018-04-14 13:11:23 -07:00
John Ralls
a04fd573ef Bug 792105 - Startup takes several minutes
set/get_locale are apparently very expensive on Mingw64, and setting
the C locale for extracting a string is unnecessary.

Unfortunately the released version of libdbi still uses strtod so
setting the C locale *is* still necessary for retrieving floats
and doubles and for passing queries.

Thanks to Mkubat for the diagnosis.
2018-04-14 12:38:04 -07:00
John Ralls
01420adb99 Bug 772776 - VERY large queries (over 11000 fields in IN clause) slow...
down GnuCash

Replace with joins or subqueries. Affords a 20% speedup on Windows.
2018-04-14 10:18:01 -07:00
John Ralls
e90a662a20 Use subquery instead of instancevec GncSqlTransBackend::load_all. 2018-04-14 10:18:01 -07:00
John Ralls
b739661171 Remove functions marked G_UNUSED.
More noise reduction.
2018-04-14 10:18:01 -07:00
John Ralls
9b64357427 Remove LOAD_TRANSACTIONS_AS_NEEDED from SQL backend.
We're not ready for that and until we are it's just noise.
2018-04-14 10:18:01 -07:00
John Ralls
e4d0ad9dda Reduce use of gnc_sql_slots_load_for_instancevec. 2018-04-14 10:18:01 -07:00
Bill Nottingham
434dd9520c Adjust catch syntax to avoid GCC8 warnings. 2018-04-03 22:02:44 -04:00
Geert Janssens
7271ce3dee Add feature kvp frame to the dbi test file 2018-03-30 19:02:57 +02:00
Geert Janssens
152277274f Fix slot loading in sql backend
Be smarter about what is path and key for each slot.
Instead of assuming a slash is always a path separator (first attempt
on unstable) or never a separator (second attempt),
track the parent path while loading kvp slots from the db
and deduce the slot's name by substracting this parent path.
2018-03-30 19:02:57 +02:00
John Ralls
8fe2cb6fa8 Fix date corruption in SQL load.
Four date elements were affected: GncEntry::date, GncEntry::date_entered,
GncInvoice::opened, and GncInvoice::posted. The problem arose during the
cleansing of Timespec from the reports; the setter functions for those
elements were converted to time64 but no provision was made to the SQL
backend to pass them time64 instead of Timespec*.

This commit adds a new column type, CT_TIME64, and changes the column
types for those elements to CT_TIME64.
2018-03-16 16:47:11 -07:00
John Ralls
e5561bd7ab Fix lost Bayesian matches in SQL backend.
The import-map-bayes uses a three-part key that uses the same delimiter
as a path and the SQL backend was throwing away everything except the
account guid.

Added more slot types including import-map-bayes ones to the test xml
file to help debug this and to catch it in the future.

Also don't pass std::string.c_str() to a std::vector<std::string>
constructor, just pass the string.
2018-03-16 13:59:04 -07:00
John Ralls
74d94650ed Avoid crash when committing a date outside of the valid range
Insert a NULL in its place.
2018-03-15 16:28:01 -07:00
John Ralls
a4399ee732 Bug 792157 - Cannot create account with different currency
Restore force-insert logic that had gotten lost in the C++ conversion.
2018-02-20 17:32:22 -08:00
John Ralls
78705dc8be Bug 792833 - User specifies source of 'num' field'; either...
transaction number or split action (requires at least GnuCash 2.5.0)

Strip leading delimiters from KVP keys when reading them from the
database. Leading delimiters are incorrectly included in databases
created with GnuCash 2.6.x.
2018-02-20 12:02:38 -08:00
Geert Janssens
00396db560 Remove the .in extension from test-real-data.sh and stop configuring it for autotools
We have dropped support for autotools and cmake invokes this script using /bin/bash <script>
So the exact shebang value is not relevant any more
2018-01-26 18:26:06 +01:00
Geert Janssens
0f4a72b49f Remove unused file 2018-01-26 18:26:06 +01:00
John Ralls
74ddb671e4 Merge Chris Lam's and Aaron Laws's branch 'time64-ftw' into unstable. 2018-01-20 12:40:32 -08:00
John Ralls
6ffb77de20 Merge branch Rob Gowin's 'bye_bye_autotools' into unstable. 2018-01-18 12:02:56 -08:00
John Ralls
8900b19da3 Bug 790845 - 2.7.3: massive test failures on some architectures (reopened).
Fix some test failures caused by erroneous size assumptions.
2018-01-14 16:31:22 -08:00
Rob Gowin
54ac7f23e0 Remove Autotools 2018-01-13 12:52:57 -06:00
lmat
1f050fd1e5 Transaction members Timespec->time64 2018-01-08 13:01:29 +11:00
lmat
9a86dd222b gncInvoice uses time64 2018-01-08 13:01:29 +11:00
lmat
598cb6d861 gncEntry members timespec->time64 2018-01-08 13:01:29 +11:00
lmat
5dd12119b7 Converted timespec_to_dom_tree to time64 2018-01-08 13:01:29 +11:00
lmat
f77369bb96 Removing timspec from some xml parsing
And several other sprawling references that are connected in one
way or another.
2018-01-08 13:01:29 +11:00
John Ralls
c0fd3b3165 Remove all references to the now-defunct Yahoo! quote retrieval
And make Alphavantage the default.
2018-01-02 10:43:49 -08:00
John Ralls
bbd2df6a3b Bug 791848 - GC 2.6.x does not handle ISO dates introduced with GC 2.7.
Set a feature to prevent versions older that 2.6.20 from loading a
database from which they cannot read the dates. Ideally we would do this
only if the database is written to, but the current persistence design
includes committing back to the database during the load so the net
effect is that the flag would be set anyway.
2017-12-26 15:18:43 -08:00
John Ralls
91727525b9 Enforce -Werror on C++ files and fix resulting errors. 2017-12-26 15:18:43 -08:00
lmat
5636afc4a2 Kvp no longer parses entries looking for delimiters 2017-12-21 07:39:32 -05:00
lmat
34e0d6cfa0 kvp frame to template and correcting failure macro
The template avoids the need to cast to and from void*, and adds flexibility to
the targeted function's signature.

test-stuff.h defines a macro, "failure" which is used as an identifier
in the standard IO library, so I moved any inclusion of test-stuff.h to
the last include position so that "failure" wouldn't be defined before
the IO library was included.
2017-12-21 07:39:32 -05:00
John Ralls
0026b10851 Merge branch 'maint' into unstable 2017-12-17 13:00:00 -08:00
John Ralls
1c8c53a861 Remove (unused because of an error) parse-to-tm string timespec construction. 2017-12-12 21:02:11 -08:00
John Ralls
5204100d53 Use GNUInstallDirs in CMake Builds
Provides correct file layout when building distribution tarballs.
Fixes Bugs 790840 and 790841.
2017-11-28 14:25:35 -08:00
John Ralls
13657ee1bb Merge branch 'maint' into unstable 2017-11-25 15:35:24 -08:00
John Ralls
d8c2f52447 Correct quoting for SQL backends.
Only string values should be quoted in queries; in particular NULL
isn't a string value and must not be quoted.
Note that this is a less than perfect solution because it doesn't use
the Database's quoting function and so doesn't escape quotes, linefeeds,
or carriage returns inside the string. That's because the SQL generating
logic is independent of the connection class and can't easily get to it.
2017-11-25 14:46:31 -08:00
John Ralls
9c4635e393 Bug 784623 - GNUCash does not work with sql backend.
Wherin the problem is that MySQL's TIMESTAMP has a date range of
1970-01-01 00:00:01 to 2038-01-19 03:14:07 and is unable to handle
time_t of 0. MySQL's TIMESTAMP also assumes that input is in the server's
timezone and adjusts it to UTC. GnuCash has already done that conversion.
2017-11-23 11:41:09 -08:00
John Ralls
937f8c5083 Set GncSqlObjectBackend::m_version to the appropriate TABLE_VERSION.
For each subclass, getting rid of GNC_SQL_OBJECT_BACKEND_VERSION which
was a bit misguided.

Also remove the bogus test the skipped loading a table if its version
didn't match GNC_SQL_OBJECT_BACKEND_VERSION which was even more misguided.
2017-11-21 18:15:37 -08:00
John Ralls
9444c1e300 Fix bad string construction in adjust_sql_options. 2017-11-19 17:32:12 -08:00
John Ralls
61316648b8 Bug 789608 - Compilation problems when linking libraries.
Fix using a preproc macro in a different file from where it was declared
and more-strict template resolution of error_handler<> by gcc-7.x.
2017-11-09 13:47:08 -08:00
John Ralls
1895ae280c Merge branch 'maint' into unstable 2017-11-09 13:45:45 -08:00
John Ralls
04642fc42a [SQL] Check return of string_to_guid, bail if false. 2017-10-27 09:46:47 -07:00
John Ralls
d17c24b770 Bug 789298 - Prompt for file history update leads to crash during startup. 2017-10-27 09:46:47 -07:00
Geert Janssens
1238b9d8cd Prevent gcc from searching config.h in the current directory
This will avoid a ninja-build from picking up a config.h generated by the autotools build
(in the root build directory). Picking up the wrong config.h may lead to all kinds of
subtle issues if the autotools run was done with different options than the cmake run.
2017-10-26 14:05:17 +02:00
John Ralls
91a2ee4525 [MacOS] Change CMake installed names to absolute paths from @rpath/...
gtk-mac-bundler can't access the executable's rpath list so it can't
follow dependencies if they're not in $install_dir/lib from @rpath.
Autotools always sets absolute path install names so this should have no
adverse affects on other Mac builds.
2017-10-15 13:22:29 -07:00
lmat
a9cc488cbf Should return std::string
This is only used in C++, so there is no need to g_strdup in here. Also,
this fixes a memory leak in KvpFrameImpl.
2017-08-29 14:12:25 -04:00
John Ralls
1e0a9a0ef8 Parse date strings into a struct tm and construct GDateTime with that.
Instead of using the more generic string constructor. The struct tm
constructor is several times faster and this change speeds up
transaction loading by 2x.
2017-08-20 21:28:09 +02:00
John Ralls
c6a72cc596 Revert "Fix mac looking in wrong directory for libgncmod-backend-dbi.dylib."
This reverts commit 6a359f86a0.
2017-08-19 20:25:04 +02:00
John Ralls
7e7d42847c Fix load string KVP memory error. 2017-08-19 17:15:49 +02:00
John Ralls
6a359f86a0 Fix mac looking in wrong directory for libgncmod-backend-dbi.dylib. 2017-08-19 17:15:49 +02:00
Geert Janssens
f943ba61ae Rename directory for code from external projects
'lib' is also being used by the cmake build, so there was a
theoretical risk for file conflicts. The new name is 'borrowed'.
2017-08-17 15:25:49 +02:00
John Ralls
e9ac71c0f9 Fix time-string format in backend for GncDateTime(std::string).
Also provide a simple test of that ctor.
2017-08-16 23:17:07 +02:00
John Ralls
43df1ccc3a Fix the most serious backend memory leaks. 2017-08-16 23:17:07 +02:00
Geert Janssens
0c6da2f001 Cleanup some more obscure references to no longer existing 'src' directory 2017-08-11 22:44:50 +02:00
Geert Janssens
afecab330a Move accounts, checks and pixmaps into a data directory
At the same time move the art directory into contrib to unclutter the top level
2017-08-11 22:42:15 +02:00
Geert Janssens
83d14e1c1c Restructure the src directory
It is split into
- /libgnucash (for the non-gui bits)
- /gnucash (for the gui)
- /common (misc source files used by both)
- /bindings (currently only holds python bindings)

This is the first step in restructuring the code. It will need much
more fine tuning later on.
2017-08-10 18:45:00 +02:00