|
@@ -246,6 +246,7 @@ function TConnectionName.StrToStatementType(s : string) : TStatementType;
|
|
|
begin
|
|
|
S:=Lowercase(s);
|
|
|
if s = 'show' then exit(stSelect);
|
|
|
+ if s = 'call' then exit(stExecProcedure);
|
|
|
result := inherited StrToStatementType(s);
|
|
|
end;
|
|
|
|
|
@@ -297,7 +298,7 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
- HMySQL:=mysql_real_connect(HMySQL,PChar(H),PChar(U),Pchar(P),Nil,APort,Nil,0);
|
|
|
+ HMySQL:=mysql_real_connect(HMySQL,PChar(H),PChar(U),Pchar(P),Nil,APort,Nil,CLIENT_MULTI_RESULTS); //CLIENT_MULTI_RESULTS is required by CALL SQL statement(executes stored procedure), that produces result sets
|
|
|
If (HMySQL=Nil) then
|
|
|
MySQlError(Nil,SErrServerConnectFailed,Self);
|
|
|
|
|
@@ -476,7 +477,7 @@ begin
|
|
|
FStatement:=Buf;
|
|
|
if assigned(AParams) and (AParams.count > 0) then
|
|
|
FStatement := AParams.ParseSQL(FStatement,false,sqEscapeSlash in ConnOptions, sqEscapeRepeat in ConnOptions,psSimulated,paramBinding,ParamReplaceString);
|
|
|
- if FStatementType=stSelect then
|
|
|
+ if FStatementType in [stSelect,stExecProcedure] then
|
|
|
FNeedData:=True;
|
|
|
end
|
|
|
end;
|
|
@@ -493,7 +494,7 @@ Var
|
|
|
|
|
|
begin
|
|
|
C:=Cursor as TCursorName;
|
|
|
- if c.FStatementType=stSelect then
|
|
|
+ if c.FStatementType in [stSelect,stExecProcedure] then
|
|
|
c.FNeedData:=False;
|
|
|
If (C.FRes<>Nil) then
|
|
|
begin
|
|
@@ -511,6 +512,7 @@ Var
|
|
|
C : TCursorName;
|
|
|
i : integer;
|
|
|
ParamNames,ParamValues : array of string;
|
|
|
+ Res: PMYSQL_RES;
|
|
|
|
|
|
begin
|
|
|
C:=Cursor as TCursorName;
|
|
@@ -535,7 +537,14 @@ begin
|
|
|
C.RowsAffected := mysql_affected_rows(FMYSQL);
|
|
|
C.LastInsertID := mysql_insert_id(FMYSQL);
|
|
|
if C.FNeedData then
|
|
|
- C.FRes:=mysql_store_result(FMySQL);
|
|
|
+ repeat
|
|
|
+ Res:=mysql_store_result(FMySQL); //returns a null pointer if the statement didn't return a result set
|
|
|
+ if Res<>nil then
|
|
|
+ begin
|
|
|
+ mysql_free_result(C.FRes);
|
|
|
+ C.FRes:=Res;
|
|
|
+ end;
|
|
|
+ until mysql_next_result(FMySQL)<>0;
|
|
|
end;
|
|
|
end;
|
|
|
end;
|
|
@@ -569,13 +578,10 @@ begin
|
|
|
ADecimals:=AField^.decimals;
|
|
|
if (ADecimals < 5) and (ASize-2-ADecimals < 15) then //ASize is display size i.e. with sign and decimal point
|
|
|
NewType := ftBCD
|
|
|
- else
|
|
|
- begin
|
|
|
- if (ADecimals = 0) and (ASize < 20) then
|
|
|
- NewType := ftLargeInt
|
|
|
- else
|
|
|
- NewType := ftFmtBCD;
|
|
|
- end;
|
|
|
+ else if (ADecimals = 0) and (ASize < 20) then
|
|
|
+ NewType := ftLargeInt
|
|
|
+ else
|
|
|
+ NewType := ftFmtBCD;
|
|
|
NewSize := ADecimals;
|
|
|
end;
|
|
|
FIELD_TYPE_FLOAT, FIELD_TYPE_DOUBLE:
|