Skip to content
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

Missing table definition for MSSQL: mqtt_pub #3097

Closed
petertirrell opened this issue Nov 26, 2019 · 10 comments
Closed

Missing table definition for MSSQL: mqtt_pub #3097

petertirrell opened this issue Nov 26, 2019 · 10 comments
Labels
Component:MQTT Database:MSSQL Microsoft SQL server To reconsider Interesting feature, but nobody offered to implement on the short term.

Comments

@petertirrell
Copy link

Environment

  • ejabberd version: 19.09.1
  • Erlang version: erl +V
  • OS: Linux (Debian)
  • Installed from: official deb/rpm

Configuration (only if needed): grep -Ev '^$|^\s*#' ejabberd.yml

loglevel: 4
...

Errors from error.log/crash.log

No errors

Bug description

I am trying to set up ejabberd against an MSSQL backend and I ran into the same issue as bug #2843 regarding the missing mqtt_pub table. It looks like the table definition for that table has not been added to the mssql.sql scipt at https://github.com/processone/ejabberd/tree/master/sql .

I moved on locally by porting the MySQL script (sort of?) to MSSQL and adding the table to get past the error, but I'm not fully confident in my porting skills.

I could spend some time in making sure I have the type conversions correct and make a PR, but it looks like in the source there are two different MySQL table definitions for that table: mysql.new.sql and mysql.sql. Which is the correct schema for the mqtt_pub table that should be added to the MSSQL script?

Thanks,

@zinid
Copy link
Contributor

zinid commented Nov 27, 2019

I moved on locally by porting the MySQL script (sort of?) to MSSQL and adding the table to get past the error, but I'm not fully confident in my porting skills.

So we're. And currently we have no running MSSQL to check against. We also cannot test ejabberd against MSSQL in Travis, so things are quite complicated.

@zinid zinid added the Database:MSSQL Microsoft SQL server label Jan 3, 2020
@badlop
Copy link
Member

badlop commented Apr 29, 2021

it looks like in the source there are two different MySQL table definitions for that table: mysql.new.sql and mysql.sql. Which is the correct schema for the mqtt_pub table that should be added to the MSSQL script?

Yes, those are the "default" and the "new" schemas, see https://docs.ejabberd.im/admin/configuration/database-ldap/#default-and-new-schemas

Looking at mssql.sql, it seems to be based on the default schema, that is mysql.sql.

Did you look at this, are you interested at all, or otherwise this issue can be closed?

@petertirrell
Copy link
Author

Hi, and thanks for the reply! Honestly, once I got our install up and running I haven't really looked into this that much more. Feel free to close the issue. I still have my original solution - taking what I guess was the default schema based on mysql and using getting the missing mssql table set up based on that.

Thanks again,

@badlop badlop closed this as completed Apr 30, 2021
@wahur666
Copy link

The missing tables still not part of the mssql, an update would be useful.

@badlop badlop added Component:MQTT To reconsider Interesting feature, but nobody offered to implement on the short term. labels May 12, 2021
@badlop
Copy link
Member

badlop commented May 12, 2021

@wahur666 : If @petertirrell shares here his definition of the missing tables, and you can try them, and you confirm they work too for you... they could be included in ejabberd.

@petertirrell
Copy link
Author

@wahur666 @badlop , here's what I have for the MSSQL schema for mqtt_pub. I believe that was the only table that was missing that I had to create. Creating it got rid of the original error I was running into (complaining that the table wasn't found), but we're not actually using any mqtt functionality for our ejabberd installation.

USE [ejabberd]
GO

/****** Object:  Table [dbo].[mqtt_pub]    Script Date: 5/12/2021 11:08:29 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[mqtt_pub](
	[username] [varchar](191) NOT NULL,
	[server_host] [varchar](191) NOT NULL,
	[resource] [varchar](191) NOT NULL,
	[topic] [varchar](191) NOT NULL,
	[qos] [tinyint] NOT NULL,
	[payload] [varbinary](max) NOT NULL,
	[payload_format] [tinyint] NOT NULL,
	[content_type] [text] NOT NULL,
	[response_topic] [text] NOT NULL,
	[correlation_data] [varbinary](max) NOT NULL,
	[user_properties] [varbinary](max) NOT NULL,
	[expiry] [int] NOT NULL,
 CONSTRAINT [i_mqtt_topic_server] PRIMARY KEY CLUSTERED 
(
	[topic] ASC,
	[server_host] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

@wahur666
Copy link

wahur666 commented May 13, 2021

@badlop @petertirrell I can confirm, that the code works, thank you :) Is there a way to reinitialize the database, because switching from Mnesia, there is literally nothing in it.
kép

@badlop
Copy link
Member

badlop commented May 13, 2021

You have two things to check:
A) The account you provide to login in webadmin... does it have admin rights in ejabberd.yml ?
B) https://docs.ejabberd.im/developer/ejabberd-api/admin-api/#export2sql

@wahur666
Copy link

@badlop It was the first one, thank you for the help :)

@badlop badlop added this to the ejabberd 21.xx milestone Jun 14, 2021
@badlop
Copy link
Member

badlop commented Jun 14, 2021

Thanks! I've committed them to ejabberd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component:MQTT Database:MSSQL Microsoft SQL server To reconsider Interesting feature, but nobody offered to implement on the short term.
Projects
None yet
Development

No branches or pull requests

4 participants