Fix a possible crash when building POI sql