[MDEV-30294] Cannot insert NULL value into a AUTO_INCREMENT column in a CONNECTed MariaDB table Created: 2022-12-23 Updated: 2023-11-28 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - Connect |
| Affects Version/s: | 10.3, 10.4, 10.9.3, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11 |
| Fix Version/s: | 10.4, 10.5, 10.6, 10.11 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Gisbert W. Selke | Assignee: | Andrew Hutchings |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows 10 |
||
| Description |
|
I have a CONNECT to a MariaDB server table which contains an AUTO_INCREMENT column. Trying to insert a NULL value into this column always fails, while acording to the specifications I would expect it to use the next auto_incremented value. Minimal example using a locally installed MariaDB 10.9.3 server: (Problem came up originally when CONNECTing from a MariaDB 10.6.10 server to a MySQL 5.7 server – same effect.)¶
Since directly inserting into the underlying table (t0) works OK, it seems that the CONNECT engine is over-eager in checking the NOT NULL condition that is implied by the primary key. Unfortunately, this makes the AUTO_INCREMENT feature unusable in the CONNECT engine. |
| Comments |
| Comment by Elena Stepanova [ 2023-01-22 ] | ||||||||||
|
The reason for this is that upon table discovery the auto-increment property gets ignored, while non-null property remains. It is easy to see if you add show create table to the test case:
And the reason for that is that Connect engine doesn't support auto-increment. It can be seen if instead of table discovery we try to create an identical table explicitly:
Maybe to avoid confusion, the automatic discovery should either fail or at least produce a warning about losing auto-increment. | ||||||||||
| Comment by Gisbert W. Selke [ 2023-01-23 ] | ||||||||||
|
It would certainly help if, for the time being, the documentation stated that automatic discovery will fail if the target table has an auto_increment field, and also taht, under the given circumstances, automatic discovery should probably fail rather than pretend everything is fine. Maybe, however, the CONNECT mechanism is currently trying to be too clever for its own good. Arguably, the CONNECT engine shouldn't bother to check any such restraints, because the engine for the underlying table on the remote host will do so anyway. And that engine knows perfectly well what it can and cannot do. Why duplicate the effort, check the constraints twice, and get inconsistent results? To illustrate, assume this manual setup:
Note that in this case the definition of t1_conn is more lenient than that of the underlying table, in not requiring NOT NULL for column id. Trying to
will produce Side note: ; |