Я сообщил об этой проблеме в центр качества Embarcadero, в соответствии с RSP-23958, и ошибка составлена из них. Кто-то по имени Дмитрий ответил, что проблема будет исправлена в обновлении 2 Delphi 10.3.
В RSP-23958 был прикреплен патч для исправления, который решает проблему, и вы можете использовать его, если у вас есть Dephi с исходным кодом Firedac, а Delphi 10.3 update 2 не выпущен.
Исправление ниже:
Index: runtime/data/firedac/FireDAC.Phys.PGWrapper.pas
===================================================================
--- runtime/data/firedac/FireDAC.Phys.PGWrapper.pas (revision 95224)
+++ runtime/data/firedac/FireDAC.Phys.PGWrapper.pas (revision 95225)
@@ -1109,7 +1109,9 @@
FDStrLike(sLCMessage, 'password authentication failed for user "%"') then
eKind := ekUserPwdInvalid
else if (Pos('connection refused', sLCMessage) <> 0) or
- (Pos('could not connect to server', sLCMessage) <> 0) then
+ (Pos('could not connect to server', sLCMessage) <> 0) or
+ (Pos('server closed the connection unexpectedly', sLCMessage) <> 0) or
+ (Pos('no connection to the server', sLCMessage) <> 0) then
eKind := ekServerGone
else
eKind := ekOther;
The text handling capabilities of MySQL aren't good enough for what you want. A stored function is an option, but will probably be slow. Your best bet to process the data within MySQL is to add a user defined function. If you're going to build a newer version of MySQL anyway, you could also add a native function.
The "correct" way is to process the data outside the DB since DBs are for storage, not processing, and any heavy processing might put too much of a load on the DBMS. Additionally, calculating the word count outside of MySQL makes it easier to change the definition of what counts as a word. How about storing the word count in the DB and updating it when a document is changed?
Example stored function:
DELIMITER $$
CREATE FUNCTION wordcount(str LONGTEXT)
RETURNS INT
DETERMINISTIC
SQL SECURITY INVOKER
NO SQL
BEGIN
DECLARE wordCnt, idx, maxIdx INT DEFAULT 0;
DECLARE currChar, prevChar BOOL DEFAULT 0;
SET maxIdx=char_length(str);
SET idx = 1;
WHILE idx <= maxIdx DO
SET currChar=SUBSTRING(str, idx, 1) RLIKE '[[:alnum:]]';
IF NOT prevChar AND currChar THEN
SET wordCnt=wordCnt+1;
END IF;
SET prevChar=currChar;
SET idx=idx+1;
END WHILE;
RETURN wordCnt;
END
$$
DELIMITER ;