Skip to main content
added 1706 characters in body
Source Link
iorsa
  • 31
  • 4

// FINAL

I've tried workaround provided by @RolandoMySQLDBA and it helped after slightly modification.

Command

INSERT INTO some_new_table_name_here SELECT * FROM some_table_name_here; 

produced error:

ERROR 1906 (HY000): The value specified for generated column 'calcOne' in table 'some_table_name_here' has been ignored 

Since there are generated columns there, it's not possible to INSERT value into that column, so I had to change INSERT query to this:

INSERT INTO some_new_table_name_here (`id`, `title`, `description`, `price_actual`, `auction`, `square_meter_price`, `square_meter_price_analog`, `accuracy`, `accuracy_analog`, `total_area`) SELECT `id`, `title`, `description`, `price_actual`, `auction`, `square_meter_price`, `square_meter_price_analog`, `accuracy`, `accuracy_analog`, `total_area` FROM some_table_name_here; 

And afterwards command was fine too:

ANALYZE TABLE some_new_table_name_here; +-----------------------------+---------+----------+----------+ | Table | Op | Msg_type | Msg_text | +-----------------------------+---------+----------+----------+ | db.some_new_table_name_here | analyze | status | OK | +-----------------------------+---------+----------+----------+ 1 row in set (2.137 sec) 

I've also discovered one nice thing - after successfully duplicating table, renaming both of old and new of them and doing analyze, I tried to analyze and also optimize some_old_table_name_here table and it worked without errors!

IDK what was the problem. Maybe since the table previously was in use, it was not possible to alter it, while there are generated columns.

// FINAL

I've tried workaround provided by @RolandoMySQLDBA and it helped after slightly modification.

Command

INSERT INTO some_new_table_name_here SELECT * FROM some_table_name_here; 

produced error:

ERROR 1906 (HY000): The value specified for generated column 'calcOne' in table 'some_table_name_here' has been ignored 

Since there are generated columns there, it's not possible to INSERT value into that column, so I had to change INSERT query to this:

INSERT INTO some_new_table_name_here (`id`, `title`, `description`, `price_actual`, `auction`, `square_meter_price`, `square_meter_price_analog`, `accuracy`, `accuracy_analog`, `total_area`) SELECT `id`, `title`, `description`, `price_actual`, `auction`, `square_meter_price`, `square_meter_price_analog`, `accuracy`, `accuracy_analog`, `total_area` FROM some_table_name_here; 

And afterwards command was fine too:

ANALYZE TABLE some_new_table_name_here; +-----------------------------+---------+----------+----------+ | Table | Op | Msg_type | Msg_text | +-----------------------------+---------+----------+----------+ | db.some_new_table_name_here | analyze | status | OK | +-----------------------------+---------+----------+----------+ 1 row in set (2.137 sec) 

I've also discovered one nice thing - after successfully duplicating table, renaming both of old and new of them and doing analyze, I tried to analyze and also optimize some_old_table_name_here table and it worked without errors!

IDK what was the problem. Maybe since the table previously was in use, it was not possible to alter it, while there are generated columns.

Tweeted twitter.com/StackDBAs/status/1404181791343321095
Became Hot Network Question
few additions
Source Link
iorsa
  • 31
  • 4

// EDIT

When I added those virtual (generated) columns (on original mariadb server 10.3.27) I used this command/query:

ALTER TABLE some_table_name_here ADD COLUMN `sootn` float AS (IF(total_area=0, 0, IF(square_meter_price=0, 0, ROUND(((((price_actual-auction)/total_area/square_meter_price)-1)*100), 2)))) PERSISTENT; ALTER TABLE some_table_name_here ADD COLUMN `sootn_analog` float AS (IF(total_area=0, 0, IF(square_meter_price_analog=0, 0, ROUND(((((price_actual-auction)/total_area/square_meter_price_analog)-1)*100), 2)))) PERSISTENT; 

There were no such problems before. I used optimize table command in order to free space from unexisting/dropped indexes. I've upgraded mariadb 100% using this instructions: https://mariadb.com/kb/en/upgrading-from-mariadb-103-to-mariadb-104/

https://mariadb.com/kb/en/upgrading-from-mariadb-104-to-mariadb-105/

https://mariadb.com/docs/deploy/upgrade-community-server/

Is there any way how can I find where and why this problem occurs?

Is there any way how can I find where and why this problem occurs?

// EDIT

When I added those virtual (generated) columns (on original mariadb server 10.3.27) I used this command/query:

ALTER TABLE some_table_name_here ADD COLUMN `sootn` float AS (IF(total_area=0, 0, IF(square_meter_price=0, 0, ROUND(((((price_actual-auction)/total_area/square_meter_price)-1)*100), 2)))) PERSISTENT; ALTER TABLE some_table_name_here ADD COLUMN `sootn_analog` float AS (IF(total_area=0, 0, IF(square_meter_price_analog=0, 0, ROUND(((((price_actual-auction)/total_area/square_meter_price_analog)-1)*100), 2)))) PERSISTENT; 

There were no such problems before. I used optimize table command in order to free space from unexisting/dropped indexes. I've upgraded mariadb 100% using this instructions: https://mariadb.com/kb/en/upgrading-from-mariadb-103-to-mariadb-104/

https://mariadb.com/kb/en/upgrading-from-mariadb-104-to-mariadb-105/

https://mariadb.com/docs/deploy/upgrade-community-server/

Is there any way how can I find where and why this problem occurs?

added 235 characters in body; edited title
Source Link
iorsa
  • 31
  • 4

Can not drop virtual column (after mariadb upgrade),| ERROR 1054 (42S22): Unknown column in 'GENERATED ALWAYS'

1 column: calcOne float GENERATED ALWAYS AS (if(total_area = 0,0,if(square_meter_price = 0,0,round(((price - auction) / total_area / square_meter_price - 1) * 100,2)))) STORED

2 column: calcTwo float GENERATED ALWAYS AS (if(total_area = 0,0,if(square_meter_price_analog = 0,0,round(((price - auction) / total_area / square_meter_price_analog - 1) * 100,2)))) STORED

`calcOne` float GENERATED ALWAYS AS (if(`total_area` = 0,0,if(`square_meter_price` = 0,0,round(((`price_actual` - `auction`) / `total_area` / `square_meter_price` - 1) * 100,2)))) STORED `calcTwo` float GENERATED ALWAYS AS (if(`total_area` = 0,0,if(`square_meter_price_analog` = 0,0,round(((`price_actual` - `auction`) / `total_area` / `square_meter_price_analog` - 1) * 100,2)))) STORED 

Is there any way how can I find where and why this problem occurs?

For now I only see this way in fixing this problem:

  1. dump/export table
  2. drop it (if it's possible)
  3. create table structure
  4. fill it with data

Can not drop virtual column (after mariadb upgrade), ERROR 1054 (42S22): Unknown column in 'GENERATED ALWAYS'

1 column: calcOne float GENERATED ALWAYS AS (if(total_area = 0,0,if(square_meter_price = 0,0,round(((price - auction) / total_area / square_meter_price - 1) * 100,2)))) STORED

2 column: calcTwo float GENERATED ALWAYS AS (if(total_area = 0,0,if(square_meter_price_analog = 0,0,round(((price - auction) / total_area / square_meter_price_analog - 1) * 100,2)))) STORED

Can not drop virtual column | ERROR 1054 (42S22): Unknown column in 'GENERATED ALWAYS'

`calcOne` float GENERATED ALWAYS AS (if(`total_area` = 0,0,if(`square_meter_price` = 0,0,round(((`price_actual` - `auction`) / `total_area` / `square_meter_price` - 1) * 100,2)))) STORED `calcTwo` float GENERATED ALWAYS AS (if(`total_area` = 0,0,if(`square_meter_price_analog` = 0,0,round(((`price_actual` - `auction`) / `total_area` / `square_meter_price_analog` - 1) * 100,2)))) STORED 

Is there any way how can I find where and why this problem occurs?

For now I only see this way in fixing this problem:

  1. dump/export table
  2. drop it (if it's possible)
  3. create table structure
  4. fill it with data
more proper title
Source Link
iorsa
  • 31
  • 4
Loading
added 804 characters in body
Source Link
iorsa
  • 31
  • 4
Loading
edited tags
Link
RolandoMySQLDBA
  • 185.6k
  • 34
  • 327
  • 543
Loading
Source Link
iorsa
  • 31
  • 4
Loading