Commit graph

137 commits

Author SHA1 Message Date
38bdde1167 Add access tokens to the db, with relevant code
Tokens are similar to sessions in that they stand in for users, but the
protocol handlers will manage them; Fever login hashes are the
originating use case for them. These must never expire, for example,
and we need to specify their values.

This commit also performs a bit of database clean-up
2019-03-09 16:23:56 -05:00
ff0c9a3a55 Add functionality for interacting with subscription tags 2019-03-06 22:15:41 -05:00
ed22090e49 Work around various SQLite-related problems
- WAL mode was not getting set properly
- Queries using the PDO driver could fail because PDO sucks
2019-03-04 11:05:46 -05:00
21fdd66d37 Work around limit to SQL parameter placeholders for IN() clauses
Improves #150

LIKE-based matches also need to be similarly conservative
2019-03-01 22:36:25 -05:00
6857e8ec1b Merge branch 'search' 2019-03-01 12:26:08 -05:00
837f3c6dd6 Simplify SQL type handling
This is done in anticipation of dealing with SQL types in
places other than statements
2019-03-01 12:17:33 -05:00
570a9b171c Revert fulltext detection in driver 2019-02-22 18:49:57 -05:00
ad8057a40b Driver changes to support basic text searching 2019-02-22 11:13:13 -05:00
908e1fa310 API documentation for database driver interface 2019-02-21 15:43:19 -05:00
b55d0b374f API documentation for database driver interface 2019-02-21 15:10:32 -05:00
500851f161 Style fixes 2019-01-23 16:34:54 -05:00
8ea1df920a Unify SQL timeouts
- Exec and lock timeouts now apply to MySQL
- Lock timeout now applies to PostgreSQL
- SQLite now uses a generic lock timeout setting which applies to all
2019-01-23 16:31:54 -05:00
05aadfe7c7 Use correct SQLite chema change procedure; version bump 2019-01-21 10:40:39 -05:00
5cd84c4ab4 Validate configuration parameters on import, and other changes
- Each parameter is checked for type and normalized
- Interval strings are converted to DateInterval objects
- Timeouts can be specified as interval strings
- Most intervals can be null to signify infinity
- Driver classes are checked that they implement the correct interface
- Short driver names may be used, and are used by default
- Helpful errors messages are printed in case of erroneous configuration

Exporting is currently broken; this will be fixed in an upcoming commit
2019-01-20 22:40:49 -05:00
4670dfc849 Handle connection errors 2019-01-15 10:51:55 -05:00
e92bda5373 Various changes:
- Fix handling of binary data and long strings
- Simplify handling of socket connections
- Fix coverage
2019-01-15 08:58:11 -05:00
5d61ab0a57 Fixes for MySQL native interface
Three test failures remain, but these are minor and will be resolved
soon. Handling of binary data is also broken, but given that this works
fine with the PDO driver, there is presumably some correct method.
2019-01-13 23:17:19 -05:00
81acba90dc Use strict equality when comparing strings 2019-01-11 10:38:06 -05:00
c4a41255b0 Experimental native MySQL driver
No testing has been performed yet, but changes are extensive enough to
warrant a commit. Of particular note:

- SQL states are enumerated in a separate trait to reduce duplication
- PDOStatement is now an abstract class to avoid duplication of
engine-specific error handling
- Error handling has been cleaned up somewhat
2019-01-10 19:01:32 -05:00
206cca35a9 Test tweaks 2018-12-21 17:51:49 -05:00
5a133b795a Correctly munge MySQL queries 2018-12-21 17:37:22 -05:00
f0d30c2eee Make munging of queries a generic feature 2018-12-21 12:35:10 -05:00
24df564045 Mostly successful MySQL database function tests
Two failures remain, at least one requiring query munging.
2018-12-21 10:14:26 -05:00
393b4e95ad Adjustments for MySQL 8
The prototype had been tested against MariaDB
2018-12-20 20:50:56 -05:00
4ef36643a4 Proof-of-concept PDO MySQL driver
- Configuration options were added
- Non-transactional locking was added to the savepoint handlers
- Tests were adjusted for MySQL's reserved words
2018-12-20 18:06:28 -05:00
50f92625ef Use PosgreSQL's existing general Unicode collation
All collations appear to be case-insensitive
2018-12-14 09:18:56 -05:00
2bebdd44cf Implementation of native PostgreSQL interface
Changes to the Database class were required to avoid outputting booleans
2018-12-13 19:47:51 -05:00
161f5f08f6 Proactively support SQLite 3.25 2018-12-12 12:21:28 -05:00
28f803dd28 Handle PostgreSQL connection errors 2018-12-12 11:15:07 -05:00
0f48ce6f37 Use a Unicode collation for SQLite 2018-12-11 14:14:32 -05:00
35d46d2913 Use persistent connections with PostgreSQL 2018-12-10 12:28:43 -05:00
0513b606c2 Merge master 2018-12-07 19:21:44 -05:00
089f666de6 Fix PDO insert ID errors in PHP 7.1 2018-12-06 17:46:00 -05:00
cf896121b2 Style fixes 2018-12-05 17:28:11 -05:00
15301cd7dc Fix cleanup tests in PostgreSQL 2018-12-05 11:05:01 -05:00
258be1d54e Fix most PostgreSQL test failures
Reasons for failures included an unhandled error code, erroneous sorting
assumptions, and a broken computation of the next insert ID in tests

Five failures remain.
2018-12-05 09:05:43 -05:00
8fc31cfc40 Rewrite various queries to work in PostgreSQL
This involved changes to the driver interface as well as the database
schemata. The most significantly altered queries were for article
selection and marking, which relied upon unusual features of SQLite.
Overall query efficiency should not be adversely affected (it may have
even imprved) in the common case, while very rare cases (not presently
triggered by any REST handlers) require more queries.

One notable benefit of these changes is that functions which query
articles can now have complete control over which columns are returned.
This has not, however, been implemented yet: symbolic column groups are
still used for now.

Note that PostgreSQL still fails many tests, but the test suite runs to
completion. Note also that one line of the Database class is not
covered; later changes will eventually make it easier to cover the line
in question.
2018-12-04 20:41:21 -05:00
527ecee393 Code coverage fixes 2018-11-29 13:56:15 -05:00
4a1c23ba45 Munge PostgreSQL queries instead of adding explicit casts
PDO does not adequately inform PostgreSQL of a parameter's type, so type
casts are required. Rather than adding these to each query manually, the
queries are instead processed to add type hints automatically.

Unfortunately the queries are processed rather naively; question-mark
characters in string constants, identifiers, regex patterns, or geometry
operators will break things spectacularly.
2018-11-29 13:45:37 -05:00
8dfedd30ef Test PostgreSQL schema upgrade
This was in fact buggy due to the schema version check causing an error
2018-11-28 10:46:23 -05:00
93af381436 Test setting of schema name 2018-11-27 17:39:39 -05:00
1414f8979c Fix savepoint handling and locking in PostgreSQL driver 2018-11-27 17:16:00 -05:00
736a8c9d0c Improved timeout handling for both SQlite and PostgreSQL 2018-11-22 13:30:13 -05:00
c0c4810662 Nominally complete PostgreSQL driver
Connection error handling as well as uprade error handling still need
to be implemented.
2018-11-21 11:06:12 -05:00
84b4cb7465 Enable PostgreSQL statement testing
Tests involving binary data are skipped for now
2018-11-20 16:32:18 -05:00
d52af6db5a PostgreSQL fixes
Errors were not correctly throwing exceptions

For the sake of SQLite compatibility booleans should be bound as
integers in PDO
2018-11-20 15:48:03 -05:00
b5733b070c Clean up statement tests
PostgreSQL tests are suppressed for now, but most pass.
2018-11-20 15:45:20 -05:00
e30d82fbaa Correct signature 2018-11-16 21:35:05 -05:00
edfae438fa Refine pg connection strings 2018-11-16 21:20:54 -05:00
796315c00c Basic stub of PDO-base PostgreSQL driver 2018-11-10 00:02:38 -05:00