MycatピットERROR 1064(HY 000)

3304 ワード

MycatピットERROR 1064(HY 000)
問題の再現
生産環境で新しく構築されたmycat、照会エラー:
mysql> select distinct o.* from
    ->         ( select goods_id offer_id, name offer_name, sn offer_code,simple_name,mktPrice,price,state,
    ->         thumbnail,type_id offer_type, marketing_begin_time,marketing_end_time,
    ->         t.tax
    ->         from  prod_goods t
    ->         where 1 = 1
    ->        and t.marketing_begin_time <= sysdate() 
    ->        and  t.marketing_end_time > sysdate())o
    -> ;
ERROR 1064 (HY000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*
LIMIT 100000000' at line 6

mysqlに直接接続し、mycatを行かないとクエリは正常に結果を返すことができます.
ソリューション
myctはselect distinct *をサポートしていません.*を特定のcolumn名に置き換えます.
mysql> select distinct offer_id,offer_name,offer_code,simple_name,mktPrice,price,state,thumbnail,offer_type,marketing_begin_time,marketing_end_time,tax from
    ->         ( select goods_id offer_id, name offer_name, sn offer_code,simple_name,mktPrice,price,state,
    ->         thumbnail,type_id offer_type, marketing_begin_time,marketing_end_time,
    ->         t.tax
    ->         from  prod_goods t
    ->         where 1 = 1
    ->        and t.marketing_begin_time <= sysdate() 
    ->        and  t.marketing_end_time > sysdate())o
    -> ;
+---------------------+-------------------------------+------------+-------------------------------+----------+-------+-------+-----------+------------+----------------------+---------------------+------+
| offer_id            | offer_name                    | offer_code | simple_name                   | mktPrice | price | state | thumbnail | offer_type | marketing_begin_time | marketing_end_time  | tax  |
+---------------------+-------------------------------+------------+-------------------------------+----------+-------+-------+-----------+------------+----------------------+---------------------+------+
| 1162487289697533953 | a                     | 12344      | a                    |    10000 |     1 | C     | NULL      | 6          | 2019-08-17 06:12:22  | 2019-09-16 06:12:22 | NULL |
| 1162487833723928578 | b                     | NULL       | b                    |        0 |     0 | C     | NULL      | 8          | 2019-08-17 06:14:42  | 2019-09-16 06:14:42 | NULL |
| 1162488027156840449 | c                     | NULL       | c                    |        0 |     0 | C     | NULL      | 6          | 2019-08-17 06:15:28  | 2019-09-16 06:15:28 | NULL |
| 1162488158606327810 | d                     | NULL       | d                    |        0 |     0 | C     | NULL      | 6          | 2019-08-17 06:15:59  | 2019-09-16 06:15:59 | NULL |
| 1162488323824156674 | e                     | NULL       | e                    |        0 |     0 | C     | NULL      | 6          | 2019-08-17 06:16:38  | 2019-09-16 06:16:38 | NULL |
+---------------------+-------------------------------+------------+-------------------------------+----------+-------+-------+-----------+------------+----------------------+---------------------+------+
5 rows in set (0.00 sec)

スクリプトが正常に実行されました