[MDEV-20267] CREATE TABLE + SELECT behaves incoherently Created: 2019-08-06 Updated: 2020-05-29 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Create Table |
| Affects Version/s: | 10.1.20, 10.2.16, 10.3, 10.4 |
| Fix Version/s: | 10.5 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Guillermo Schulman | Assignee: | Sergei Golubchik |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | alias, create_table | ||
| Environment: |
Tested in ubuntu 16.04 (xenial) |
||
| Description |
|
Creating a table with a PK plus a SELECT statement leads to 2 different behaviors depending on the column matching names or not.
|
| Comments |
| Comment by Elena Stepanova [ 2019-08-06 ] | |||||||||||
|
What do you consider to be inconsistency? It seems quite logical.
Since `myField` doesn't have a default value (and you apparently run with one of strict sql modes), it fails. The second one is the same, only instead of naming the 2nd column `1`, you name it `myField2`. In the third case, you are doing
It is all legit, hence no complaints. | |||||||||||
| Comment by Guillermo Schulman [ 2019-08-06 ] | |||||||||||
|
You are right. I misunderstood the documentation and thought it just automatically links the first table column with the first recordset column, the second one with the second, etc as "INSERT INTO + SELECT" works, i.e., the order is the key to match regardless the column names/aliases. Now I see it doesn't, my bad. Anyway, I would like to highlight also this case:
It seems that the parser validates if there would be a column for the not nullable and no-default-value column before checking if there is any row in the results. A bit controversial, isn't it? | |||||||||||
| Comment by Elena Stepanova [ 2019-09-04 ] | |||||||||||
|
bar, do you consider the part from the last comment to be a bug? | |||||||||||
| Comment by Alexander Barkov [ 2020-05-29 ] | |||||||||||
|
I'm not sure. Reassigning to serg. |