2013年1月16日星期三

Solved!! Illegal mix of collations for operation 'concat'

今天解決這個了MySQL Error,錯誤出現在Stored Routines (Stored Procedure)當中的Concat function。

因為我公司那個MySQL DB Schema設計十分差,Database / Table /Column的collation都有不同。
所以原因已經說得很明,估都不用估肯定是collation的原因。

但我公司的Production環境是MySQL 5.0版本,並沒有這個錯誤出現。
而我今天下載XAMPP最新版本,是MySQL 5.5版本,把5.0的DB migrate至5.5就得知這個問題。

上網找了很久很久,十個解決方法,有九個都不外乎說在my.ini加入以下設定:
[client]
default-character-set = utf8
[mysqld]
skip-character-set-client-handshake
init_connect="SET collation_connection = utf8_general_ci"
init_connect="SET NAMES utf8"
collation-server=utf8_general_ci 
#collation-server=utf8_unicode_ci
character-set-server=utf8
[mysql]
default-character-set=utf8

不知道其他人怎樣,但對我來說,都是解決不到,同樣的錯誤出現。
最後找到的方法是直接在Concat語法中設定String的Collate。
用法如下 : (省略了很多沒關係的)
DECLARE Usage DOUBLE; #Variable
DECLARE ins_query VARCHAR(500); #Dynamic SQL
#MemberID  & MemberID are [IN] Parameters.

SET ins_query = CONCAT(
     CONVERT('Select @Usage:=Count(*) from Sales Where ' USING UTF8) , 
     CONVERT(CASE MemberID WHEN '' THEN '' ELSE CONCAT('MemberId="',MemberID,'" AND ') END USING UTF8), 
     ' CompanyId = ' , CompanyID , ';');

SELECT ins_query;
set @ins_query=ins_query;
PREPARE ins_query from @ins_query;
EXECUTE ins_query;

沒錯,就是那句USING UTF8了,把各個String都做一次設定就可以了。
如果還是不行,試試執行下列的Query,看看collation_server是不是跟其他的一致。
show variables like '%coll%'

2013年1月8日星期二

建立Windows Git Server 失敗記

本來現在來說,如非工作上要求,實在沒有理由不用網絡上的Git服務,而自架Git Server。
不過本著學習理由,今天花了半天去自建,最後結果可說是半失敗,得出來的Git Server是可Clone,不可Push。

2013年1月4日星期五

GSmartControl - 觀看RAID HDD的SMART狀態

我現在的電腦都用了接近4年,硬碟是用ICH9R建的RAID-1,近期硬碟開始很吵,所以想看看SMART有沒有什麼異樣。

其實這類HDD的Health Monitor軟件都很多,但不是每隻都支援RAID的子集HDD。

所以就找來一個免費軟件叫GSmartControl,可以從RAID集合中,獨立觀看個別HDD的情況。
這軟件同樣是我最愛不用安裝的Unzip & Run軟件。

官方的介紹:
  • automatically reports and highlights any anomalies;
  • allows enabling/disabling SMART;
  • allows enabling/disabling Automatic Offline Data Collection - a short self-check that the drive will perform automatically every four hours with no impact on performance;
  • supports configuration of global and per-drive options for smartctl;
  • performs SMART self-tests;
  • displays drive identity information, capabilities, attributes, and self-test/error logs;
  • can read in smartctl output from a saved file, interpreting it as a read-only virtual device;
  • works on most smartctl-supported operating systems;
  • has extensive help information.



Microsoft Ajax CDN Down Time

早在10月時我自己都經歷過一次 - Microsoft Ajax CDN NO Response。

日前國外有人發現Microsoft的CDN再次出現死機情況。

Microsoft's Ajax CDN tumbles worldwide
Twitter : Dammit! http://ajax.aspnetcdn.com is down, @Microsoft any ideas when it will come back up?

現在的CDN都是寄存一些比較核心的JS,一旦有什麼問題,就導致其他Self-Host的JavaScript都不能工作。
其實自從上次"災難"後,我現在認為不要太過依賴CDN,特別是公司裡頭的Web程式,
那怕是因為CDN,或Firewall還是其他因素導致程式出現Error,
始終End User只看結果,只要見到Javascript Error就會認為是程式問題,多冤枉呢。