-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL related fixes and updates #3980
Conversation
* Add missing 'mix' tables and indexes * Fix text vs varchar issues Various tests triggered this error: The data types text and varchar are incompatible in the equal to operator. Caused by incompatible 'text' columns in muc_online_room, muc_online_users, pubsub_node_option, and pubsub_node tables. * Fix definition of mqtt_pub table This table incorrectly included 'server_host' column in old schema, and had other inconsistencies.
'The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP, OFFSET or FOR XML is also specified.' Omit the ORDER BY clause from subquery if the SELECT is not constrained by TOP.
'server_host' column on 'route' table already exists in old schema and does not need adding for new schema migration.
For columns are already included in a compound index there is no benefit to having a separate index with a subset of the same columns in the same order, it just wastes space.
Support 'sql_ssl' option for MS SQL - set Encryption=required and Encrypt=yes in ODBC connection string to require SSL using default FreeTDS driver and Microsoft ODBC Driver for SQL Server repectively. Allow setting full ODBC connection string in 'sql_server' for MS SQL, allowing custom connection configuration beyond what is possible with just 'sql_odbc_driver' option.
This is consistent with other schemas, internally consistent with foreign keys, and allows for > 2B records in these tables.
2c08457
to
4f0e426
Compare
Great work, all those patches looks ok to me. |
@nosnilmot can you draft an upgrade docs PR with what this entails for existing installs? You need this for the next release anyway, 23.0x, but I'd like to keep up with ejabberd HEAD and I'm not brave enough to update past this PR as I don't know if "it wil magically work out" or break my schema. Albeit your next (unmerged) PR mentions "autoupgrades" which sound nice but might not yet be active/usable. |
Can I suggest you read the bit in the description of this PR after the words "The notes below can be used to apply these changes to existing databases." 😄 For the most part you don't strictly need to do anything, everything will just keep working (or, in the case of MS SQL, not working) in exactly the same way as before. If you want the benefits from this PR for an existing installation you need to make the DB schema changes documented.
Nope, no "autoupgrades" there, automated testing of schema upgrades (ie. GitHub workflow). |
Ah silly me, that flew above my head, indeed, will do. Thanks |
@nosnilmot: Good job! |
Various (mostly) SQL related fixes and updates
These changes may be more easily reviewed by commit, as each is self-contained. If preferred I can submit separately, although there is some ordering required.
Add missing tables, fix text vs varchar issues, fix definition of
mqtt_pub
table (refs Missing table definition for MSSQL: mqtt_pub #3097)server_host
column onroute
table already exists in old schema and does not need adding for new schema migration.For columns already included in a compound index there is no benefit to having a separate index with a subset of the same columns in the same order, it just wastes space. (refs Postgres schema updates #3860)
Add ability to indicate SSL is required using
sql_ssl
option, and allow custom ODBC connection string specification insql_server
(refs How to configure ejabberd to use SQL Server with integrated authentication? #3978)Most of the code was there, it just needed finishing up
The notes below can be used to apply these changes to existing databases.
Database Updates
PostgreSQL
Regular or New schema:
To convert columns to allow up to 2 billion rows in these tables. This conversion will require full table rebuilds, and will take a long time if tables already have lots of rows. Optional: this is not necessary if the tables are never likely to grow large.
PostgreSQL or SQLite
Regular schema:
New schema:
Add index that might be missing
PostgreSQL:
SQLite:
MySQL
Regular schema:
New schema:
Add index that might be missing:
MS SQL
MS SQL schema was missing some tables added in earlier versions of ejabberd:
MS SQL also had some incompatible column types:
... and
mqtt_pub
table was incorrectly defined in old schema:... and
sr_group
index/PK was inconsistent with other DBs: