[MDEV-19679] CREATE SERVER needs tweaks for compatibility with CONNECT engine Created: 2019-06-03  Updated: 2019-09-20  Resolved: 2019-09-20

Status: Closed
Project: MariaDB Server
Component/s: Admin statements
Fix Version/s: 10.2.28, 10.3.19, 10.4.9

Type: Task Priority: Major
Reporter: Robert Dyas Assignee: Anel Husakovic
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-726 LP:1002807 - CREATE SERVER still not ... Closed

 Description   

The CREATE SERVER command needs to be tweaked to provide better compatibility with CONNECT engine. It can be accomplished as follows:

#1
Extend the length of the mysql.servers.Host column to 2048 chars (to support CONNECT engine's use of this column for the host connection URL which can easily run to 500 or even 1,000+ chars with certain sets of connection properties)

#2
Extend the length of the mysql.servers.Owner column to 512 chars (to support CONNECT engine's use of this column for storing multiple additional connection options)

#3
Fix the forced lower casing of the host column - right now create server forces the host data to lower case, which is incorrect when storing a host connection URL for connect engine that may contain case sensitive parameters such as passwords and security tokens.

This issue is related to MDEV-13136 which solved part of the problem but requires the above fixes to work properly.



 Comments   
Comment by Robert Dyas [ 2019-06-06 ]

Can we get this assigned and worked on? Important for our use cases.

Comment by Robert Dyas [ 2019-06-16 ]

Hi,

Would it be possible to get this assigned? It is likely a pretty small task.

Comment by Robert Dyas [ 2019-06-17 ]

We reported this for 10.3 not 10.2 ... don't know if that matters or not.

Comment by Sergei Golubchik [ 2019-06-17 ]

Shouldn't. CONNECT is the same, and SERVER code, I'm pretty sure, is too.

Comment by Anel Husakovic [ 2019-06-18 ]

Hi,
there is a patch for first two tasks. I applied it only to servers table.
Regarding above, serg according to your patches for changing username field MDEV-5275 and MDEV-4332 , you applied change to all system tables. Do I need the same here?
Regarding the third task :

Fix the forced lower casing of the host column

I don't get that situation in mysql client.
Please see bellow:

MariaDB [mysql]> show create table servers\G
*************************** 1. row ***************************
       Table: servers
Create Table: CREATE TABLE `servers` (
  `Server_name` char(64) NOT NULL DEFAULT '',
  `Host` varchar(2048) NOT NULL DEFAULT '',
  `Db` char(64) NOT NULL DEFAULT '',
  `Username` char(80) NOT NULL DEFAULT '',
  `Password` char(64) NOT NULL DEFAULT '',
  `Port` int(4) NOT NULL DEFAULT 0,
  `Socket` char(64) NOT NULL DEFAULT '',
  `Wrapper` char(64) NOT NULL DEFAULT '',
  `Owner` varchar(512) NOT NULL DEFAULT '',
  PRIMARY KEY (`Server_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='MySQL Foreign Servers table'
 
 
MariaDB [mysql]> INSERT INTO servers VALUES ('t1','localhost','test','root','', 0,'','mysql','root'), ('t2','LOCALHOST','test','root','', 0,'','mysql','root');
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0
MariaDB [mysql]> select * from servers;
+-------------+-----------+------+----------+----------+------+--------+---------+-------+
| Server_name | Host      | Db   | Username | Password | Port | Socket | Wrapper | Owner |
+-------------+-----------+------+----------+----------+------+--------+---------+-------+
| t1          | localhost | test | root     |          |    0 |        | mysql   | root  |
| t2          | LOCALHOST | test | root     |          |    0 |        | mysql   | root  |
+-------------+-----------+------+----------+----------+------+--------+---------+-------+
 

Comment by Robert Dyas [ 2019-06-26 ]

RE "Fix the forced lower casing of the host column" and the above comment "I don't get that situation in mysql client."
Don't use INSERT or UPDATE on the table itself, use the CREATE SERVER or CREATE OR REPLACE SERVER syntax and the host is forced lower case.

I hope that helps.

Comment by Anel Husakovic [ 2019-06-27 ]

Hi rdyas,
I updated the patch with commit 50adbd72d7, hope now is ok.

MariaDB [test]> CREATE OR REPLACE SERVER s31  FOREIGN DATA WRAPPER mysql  OPTIONS (USER 'Remote', HOST 'Hello_World()', DATABASE 'test'); 
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [test]> select * from mysql.servers;
+-------------+---------------+------+----------+----------+------+--------+---------+-------+
| Server_name | Host          | Db   | Username | Password | Port | Socket | Wrapper | Owner |
+-------------+---------------+------+----------+----------+------+--------+---------+-------+
| s31         | Hello_World() | test | Remote   |          | 3306 |        | mysql   |       |
+-------------+---------------+------+----------+----------+------+--------+---------+-------+
1 row in set (0.00 sec)

Comment by Robert Dyas [ 2019-06-27 ]

Looks ok to me... I'll test when the next release is out 10.3.17 I think, right?

Comment by Sergei Golubchik [ 2019-08-23 ]

anel, please check why this lowercasing was added, and if it was a bug fix, see whether you did not re-introduce the old bug.

Comment by Anel Husakovic [ 2019-09-02 ]

Hi serg,
MDEV-726 CREATE SERVER still not converting hostnames to lower case — introduced the patch (and test case) related to system tables that have to have lower case host name (since Mysql 5.1.53 there was inconsistency in grant statementsmysql patch; host_to_lowercase())
From my point of view having the reverted patch of MDEV-726, if above is not related to standard and if we need to have it, will not have impact on grant statements.

Comment by Robert Dyas [ 2019-09-14 ]

Any additional info on this?

Comment by Sergei Golubchik [ 2019-09-17 ]

hholzgra, what was the point in MDEV-726? Can there be grants on host names in CREATE SERVER?
Why should CREATE SERVER follow GRANT rules?

Comment by Hartmut Holzgraefe [ 2019-09-17 ]

I'm trying to remember ... I was probably thinking along the lines of "DNS host names are case insensitive, so they should be stored in that way over here, too".

There might have been a support issue related to this, but back then we didn't have a support issue filed in Jira yet, and Eventum search does not turn anything up either.

As far as I can tell back then in 2012 this was only used by FEDERATED and FEDERATEDX, so the assumption that the `host` column only stores IP addresses or DNS seemed to make sense at that point.

Comment by Sergei Golubchik [ 2019-09-19 ]

ok to push

Comment by Anel Husakovic [ 2019-09-20 ]

Pushed with 1ad79c818780aafe.

Generated at Thu Feb 08 08:53:32 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.