Commit graph

34 commits

Author SHA1 Message Date
Habeas Codice
1a5a5c7edb PostgreSQL support initial commit
There were 11 main types of changes:
- UPDATE's and DELETE's sometimes had LIMIT 1 at the end of them. This is not only non-compliant but
it would certainly not do what whoever wrote it thought it would. It is likely this mistake was just
copied from Friendica. All of these instances, the LIMIT 1 was simply removed.
- Bitwise operations (and even some non-zero int checks) erroneously rely on MySQL implicit
integer-boolean conversion in the WHERE clauses. This is non-compliant (and bad programming practice
to boot). Proper explicit boolean conversions were added. New queries should use proper conventions.
- MySQL has a different operator for bitwise XOR than postgres. Rather than add yet another dba_
func, I converted them to "& ~" ("AND NOT") when turning off, and "|" ("OR") when turning on. There
were no true toggles (XOR). New queries should refrain from using XOR when not necessary.
- There are several fields which the schema has marked as NOT NULL, but the inserts don't specify
them. The reason this works is because mysql totally ignores the constraint and adds an empty text
default automatically. Again, non-compliant, obviously. In these cases a default of empty text was
added.
- Several statements rely on a non-standard MySQL feature
(http://dev.mysql.com/doc/refman/5.5/en/group-by-handling.html). These queries can all be rewritten
to be standards compliant. Interestingly enough, the newly rewritten standards compliant queries run
a zillion times faster, even on MySQL.
- A couple of function/operator name translations were needed (RAND/RANDOM, GROUP_CONCAT/STRING_AGG,
UTC_NOW, REGEXP/~, ^/#) -- assist functions added in the dba_
- INTERVALs: postgres requires quotes around the value, mysql requires that there are not quotes
around the value -- assist functions added in the dba_
- NULL_DATE's -- Postgres does not allow the invalid date '0000-00-00 00:00:00' (there is no such
thing as year 0 or month 0 or day 0). We use '0001-01-01 00:00:00' for postgres. Conversions are
handled in Zot/item packets automagically by quoting all dates with dbescdate().
- char(##) specifications in the schema creates fields with blank spaces that aren't trimmed in the
code. MySQL apparently treats char(##) as varchar(##), again, non-compliant. Since postgres works
better with text fields anyway, this ball of bugs was simply side-stepped by using 'text' datatype
for all text fields in the postgres schema. varchar was used in a couple of places where it actually
seemed appropriate (size constraint), but without rigorously vetting that all of the PHP code
actually validates data, new bugs might come out from under the rug.
- postgres doesn't store nul bytes and a few other non-printables in text fields, even when quoted.
bytea fields were used when storing binary data (photo.data, attach.data). A new dbescbin() function
was added to handle this transparently.
- postgres does not support LIMIT #,# syntax. All databases support LIMIT # OFFSET # syntax.
Statements were updated to be standard.

These changes require corresponding changes in the coding standards. Please review those before
adding any code going forward.

Still on my TODO list:
- remove quotes from non-reserved identifiers and make reserved identifiers use dba func for quoting
- Rewrite search queries for better results (both MySQL and Postgres)
2014-11-13 12:21:58 -08:00
friendica
79684e05cc fix import sql error 2014-10-13 21:24:06 -07:00
friendica
bca4d540e0 disable email notifications when bulk importing content. 2014-10-08 15:15:20 -07:00
friendica
d8c03526ed optionally include wall items (posts) in import/export 2014-09-25 20:21:23 -07:00
friendica
6a82ccecd0 when importing channels - use the new location notification message to tell your original site where it sits in terms of primary. 2014-09-16 05:14:06 -07:00
friendica
5f9c326ad7 channel export with items 2014-09-15 21:31:32 -07:00
friendica
bbc9e4427e honour service class restrictions for total_identities, total_channels ("friends") and total_feeds both when importing channels and subsequently when syncing clones. Limits are based on the local system - additional entries are silently dropped. 2014-09-15 17:17:00 -07:00
friendica
c6d07feff5 This is long overdue - use a symblic constant NULL_DATE instead of the easily mis-typed sequence '0000-00-00 00:00:00' 2014-09-08 20:35:15 -07:00
friendica
9196c9eef0 We really can't do this without a hubloc. I was hoping we could, but notifier is setup to take hublocs, not xchans. 2014-08-22 21:37:08 -07:00
friendica
d84f03d59b if photo import failed during channel import, reset the xchan_photo_date so it will automatically fix itself. 2014-06-04 01:37:50 -07:00
friendica
1a42580ad4 remove a couple of mysql reserved words from being used as table or row names. For this round we're getting 'group' and 'desc'. Warning: potentially destabilising as this touches a lot of code. 2013-12-22 18:37:39 -08:00
friendica
13feafce17 add poco and follow to default xchan creation 2013-12-04 18:30:14 -08:00
friendica
2c90a73695 change from refresh_all to a directory update - which does a refresh_all and also updates the directory. 2013-09-08 21:12:23 -07:00
friendica
a09829a1ee perform a refresh_all when an import has completed so that all your connections get a fresh update. 2013-09-08 21:05:39 -07:00
friendica
2e14dc242e if changing primary hub during an import operation - remove the old xchan and create a fresh xchan pointing at this instance. Also a minor edit to increase the default photo upload limit for new sites. There aren't many cameras left that will take photos < 800k in size. 2013-08-19 17:18:13 -07:00
friendica
d0951777c0 fix import from file 2013-08-15 19:21:22 -07:00
friendica
94dfe87a6b fix default channel setting after import 2013-07-18 21:35:28 -07:00
friendica
d76ec28f79 import requires a valid account 2013-06-08 16:41:57 -07:00
friendica
80be209bce Merge https://github.com/friendica/red into zpull 2013-06-08 16:30:50 -07:00
friendica
ee1ecd8ea2 remove uploaded import file once we're done with it. 2013-06-08 16:29:56 -07:00
Thomas Willingham
b263f11d77 Another missing include 2013-06-07 20:40:36 +01:00
friendica
f18a909eef set default channel to new import if a default channel wasn't already set 2013-06-05 19:35:04 -07:00
friendica
e65449ee11 missing include, plus change to new red api path for basic export 2013-06-05 19:15:44 -07:00
friendica
2493770af9 doh - would probably help to decode the data before trying to use it... 2013-06-05 18:40:10 -07:00
Zach Prezkuta
24d088d43b mysql 5.1 chokes on 'select * from group' since group is a keyword 2013-05-12 09:40:54 -06:00
friendica
72e83f69bc photo driver abstraction 2013-04-25 20:01:24 -07:00
friendica
1abce176ff add groups and personal configs to export/import 2013-02-21 21:18:36 -08:00
friendica
3ba267d0c0 unset auto increment keys on import 2013-02-19 22:55:34 -08:00
friendica
23718e5e28 that should be the last critical piece. Everything else is gravy. 2013-02-19 20:22:04 -08:00
friendica
ef360f0a5c dang - this is almost testable. Still have to figure out the best way to deal with the profile photo. Otherwise if you're really brave you could give it a go and see what happens. The worst that could happen is that it destroys the universe. Not a big deal. More likely you could end up with a bunch of imported things that have to be cleaned up. Less likely but entirely possible is that nothing useful will happen at all and it'll white screen. 2013-02-19 19:08:04 -08:00
friendica
24eac8c656 the heavy lifting is done for location migration aka channel import - now it's just connecting all the dots. Don't get impatient, there are a lot of dots. 2013-02-19 17:13:23 -08:00
friendica
9784536ff9 more groundwork for channel import 2013-02-14 17:39:16 -08:00
friendica
5cb970963b fill in the basic outline of what needs to happen on importation 2013-01-12 15:29:34 -08:00
friendica
303c24b261 skeleton for channel import 2013-01-12 15:20:58 -08:00