View Issue Details

IDProjectCategoryView StatusLast Update
0033918FPCDatabasepublic2018-08-15 19:09
ReporterOndrej PokornyAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product VersionProduct Build 
Target Version3.2.0Fixed in Version3.1.1 
Summary0033918: Make the getters and setters of TParam virtual
DescriptionTField setters and getters are virtual and so I can override them. I cannot override TParam setters and getters.

The attached patch makes the getters and setters virtual.
TagsNo tags attached.
Fixed in Revision39321
FPCOldBugId
FPCTarget
Attached Files
  • TParam-virtual-01.patch (4,426 bytes)
    Index: packages/fcl-db/src/base/db.pas
    ===================================================================
    --- packages/fcl-db/src/base/db.pas	(revision 39317)
    +++ packages/fcl-db/src/base/db.pas	(working copy)
    @@ -1190,47 +1190,47 @@
       protected
         Procedure AssignParam(Param: TParam);
         Procedure AssignTo(Dest: TPersistent); override;
    -    Function GetAsBoolean: Boolean;
    -    Function GetAsBytes: TBytes;
    -    Function GetAsCurrency: Currency;
    -    Function GetAsDateTime: TDateTime;
    -    Function GetAsFloat: Double;
    -    Function GetAsInteger: Longint;
    -    Function GetAsLargeInt: LargeInt;
    -    Function GetAsMemo: string;
    -    Function GetAsString: string;
    -    Function GetAsAnsiString: AnsiString;
    -    Function GetAsUnicodeString: UnicodeString;
    -    Function GetAsUTF8String: UTF8String;
    -    Function GetAsWideString: WideString;
    -    Function GetAsVariant: Variant;
    -    Function GetAsFMTBCD: TBCD;
    +    Function GetAsBoolean: Boolean; virtual;
    +    Function GetAsBytes: TBytes; virtual;
    +    Function GetAsCurrency: Currency; virtual;
    +    Function GetAsDateTime: TDateTime; virtual;
    +    Function GetAsFloat: Double; virtual;
    +    Function GetAsInteger: Longint; virtual;
    +    Function GetAsLargeInt: LargeInt; virtual;
    +    Function GetAsMemo: string; virtual;
    +    Function GetAsString: string; virtual;
    +    Function GetAsAnsiString: AnsiString; virtual;
    +    Function GetAsUnicodeString: UnicodeString; virtual;
    +    Function GetAsUTF8String: UTF8String; virtual;
    +    Function GetAsWideString: WideString; virtual;
    +    Function GetAsVariant: Variant; virtual;
    +    Function GetAsFMTBCD: TBCD; virtual;
         Function GetDisplayName: string; override;
         Function GetIsNull: Boolean;
         Function IsEqual(AValue: TParam): Boolean;
    -    Procedure SetAsBCD(const AValue: Currency);
    -    Procedure SetAsBlob(const AValue: TBlobData);
    -    Procedure SetAsBoolean(AValue: Boolean);
    -    Procedure SetAsBytes(const AValue: TBytes);
    -    Procedure SetAsCurrency(const AValue: Currency);
    -    Procedure SetAsDate(const AValue: TDateTime);
    -    Procedure SetAsDateTime(const AValue: TDateTime);
    -    Procedure SetAsFloat(const AValue: Double);
    -    Procedure SetAsInteger(AValue: Longint);
    -    Procedure SetAsLargeInt(AValue: LargeInt);
    -    Procedure SetAsMemo(const AValue: string);
    -    Procedure SetAsSmallInt(AValue: LongInt);
    -    Procedure SetAsString(const AValue: string);
    -    Procedure SetAsAnsiString(const AValue: AnsiString);
    -    Procedure SetAsUTF8String(const AValue: UTF8String);
    -    Procedure SetAsUnicodeString(const AValue: UnicodeString);
    -    Procedure SetAsWideString(const AValue: WideString);
    -    Procedure SetAsTime(const AValue: TDateTime);
    -    Procedure SetAsVariant(const AValue: Variant);
    -    Procedure SetAsWord(AValue: LongInt);
    -    Procedure SetAsFMTBCD(const AValue: TBCD);
    +    Procedure SetAsBCD(const AValue: Currency); virtual;
    +    Procedure SetAsBlob(const AValue: TBlobData); virtual;
    +    Procedure SetAsBoolean(AValue: Boolean); virtual;
    +    Procedure SetAsBytes(const AValue: TBytes); virtual;
    +    Procedure SetAsCurrency(const AValue: Currency); virtual;
    +    Procedure SetAsDate(const AValue: TDateTime); virtual;
    +    Procedure SetAsDateTime(const AValue: TDateTime); virtual;
    +    Procedure SetAsFloat(const AValue: Double); virtual;
    +    Procedure SetAsInteger(AValue: Longint); virtual;
    +    Procedure SetAsLargeInt(AValue: LargeInt); virtual;
    +    Procedure SetAsMemo(const AValue: string); virtual;
    +    Procedure SetAsSmallInt(AValue: LongInt); virtual;
    +    Procedure SetAsString(const AValue: string); virtual;
    +    Procedure SetAsAnsiString(const AValue: AnsiString); virtual;
    +    Procedure SetAsUTF8String(const AValue: UTF8String); virtual;
    +    Procedure SetAsUnicodeString(const AValue: UnicodeString); virtual;
    +    Procedure SetAsWideString(const AValue: WideString); virtual;
    +    Procedure SetAsTime(const AValue: TDateTime); virtual;
    +    Procedure SetAsVariant(const AValue: Variant); virtual;
    +    Procedure SetAsWord(AValue: LongInt); virtual;
    +    Procedure SetAsFMTBCD(const AValue: TBCD); virtual;
         Procedure SetDataType(AValue: TFieldType);
    -    Procedure SetText(const AValue: string);
    +    Procedure SetText(const AValue: string); virtual;
       public
         constructor Create(ACollection: TCollection); overload; override;
         constructor Create(AParams: TParams; AParamType: TParamType); reintroduce; overload;
    
    TParam-virtual-01.patch (4,426 bytes)

Activities

Ondrej Pokorny

2018-06-27 19:24

developer  

TParam-virtual-01.patch (4,426 bytes)
Index: packages/fcl-db/src/base/db.pas
===================================================================
--- packages/fcl-db/src/base/db.pas	(revision 39317)
+++ packages/fcl-db/src/base/db.pas	(working copy)
@@ -1190,47 +1190,47 @@
   protected
     Procedure AssignParam(Param: TParam);
     Procedure AssignTo(Dest: TPersistent); override;
-    Function GetAsBoolean: Boolean;
-    Function GetAsBytes: TBytes;
-    Function GetAsCurrency: Currency;
-    Function GetAsDateTime: TDateTime;
-    Function GetAsFloat: Double;
-    Function GetAsInteger: Longint;
-    Function GetAsLargeInt: LargeInt;
-    Function GetAsMemo: string;
-    Function GetAsString: string;
-    Function GetAsAnsiString: AnsiString;
-    Function GetAsUnicodeString: UnicodeString;
-    Function GetAsUTF8String: UTF8String;
-    Function GetAsWideString: WideString;
-    Function GetAsVariant: Variant;
-    Function GetAsFMTBCD: TBCD;
+    Function GetAsBoolean: Boolean; virtual;
+    Function GetAsBytes: TBytes; virtual;
+    Function GetAsCurrency: Currency; virtual;
+    Function GetAsDateTime: TDateTime; virtual;
+    Function GetAsFloat: Double; virtual;
+    Function GetAsInteger: Longint; virtual;
+    Function GetAsLargeInt: LargeInt; virtual;
+    Function GetAsMemo: string; virtual;
+    Function GetAsString: string; virtual;
+    Function GetAsAnsiString: AnsiString; virtual;
+    Function GetAsUnicodeString: UnicodeString; virtual;
+    Function GetAsUTF8String: UTF8String; virtual;
+    Function GetAsWideString: WideString; virtual;
+    Function GetAsVariant: Variant; virtual;
+    Function GetAsFMTBCD: TBCD; virtual;
     Function GetDisplayName: string; override;
     Function GetIsNull: Boolean;
     Function IsEqual(AValue: TParam): Boolean;
-    Procedure SetAsBCD(const AValue: Currency);
-    Procedure SetAsBlob(const AValue: TBlobData);
-    Procedure SetAsBoolean(AValue: Boolean);
-    Procedure SetAsBytes(const AValue: TBytes);
-    Procedure SetAsCurrency(const AValue: Currency);
-    Procedure SetAsDate(const AValue: TDateTime);
-    Procedure SetAsDateTime(const AValue: TDateTime);
-    Procedure SetAsFloat(const AValue: Double);
-    Procedure SetAsInteger(AValue: Longint);
-    Procedure SetAsLargeInt(AValue: LargeInt);
-    Procedure SetAsMemo(const AValue: string);
-    Procedure SetAsSmallInt(AValue: LongInt);
-    Procedure SetAsString(const AValue: string);
-    Procedure SetAsAnsiString(const AValue: AnsiString);
-    Procedure SetAsUTF8String(const AValue: UTF8String);
-    Procedure SetAsUnicodeString(const AValue: UnicodeString);
-    Procedure SetAsWideString(const AValue: WideString);
-    Procedure SetAsTime(const AValue: TDateTime);
-    Procedure SetAsVariant(const AValue: Variant);
-    Procedure SetAsWord(AValue: LongInt);
-    Procedure SetAsFMTBCD(const AValue: TBCD);
+    Procedure SetAsBCD(const AValue: Currency); virtual;
+    Procedure SetAsBlob(const AValue: TBlobData); virtual;
+    Procedure SetAsBoolean(AValue: Boolean); virtual;
+    Procedure SetAsBytes(const AValue: TBytes); virtual;
+    Procedure SetAsCurrency(const AValue: Currency); virtual;
+    Procedure SetAsDate(const AValue: TDateTime); virtual;
+    Procedure SetAsDateTime(const AValue: TDateTime); virtual;
+    Procedure SetAsFloat(const AValue: Double); virtual;
+    Procedure SetAsInteger(AValue: Longint); virtual;
+    Procedure SetAsLargeInt(AValue: LargeInt); virtual;
+    Procedure SetAsMemo(const AValue: string); virtual;
+    Procedure SetAsSmallInt(AValue: LongInt); virtual;
+    Procedure SetAsString(const AValue: string); virtual;
+    Procedure SetAsAnsiString(const AValue: AnsiString); virtual;
+    Procedure SetAsUTF8String(const AValue: UTF8String); virtual;
+    Procedure SetAsUnicodeString(const AValue: UnicodeString); virtual;
+    Procedure SetAsWideString(const AValue: WideString); virtual;
+    Procedure SetAsTime(const AValue: TDateTime); virtual;
+    Procedure SetAsVariant(const AValue: Variant); virtual;
+    Procedure SetAsWord(AValue: LongInt); virtual;
+    Procedure SetAsFMTBCD(const AValue: TBCD); virtual;
     Procedure SetDataType(AValue: TFieldType);
-    Procedure SetText(const AValue: string);
+    Procedure SetText(const AValue: string); virtual;
   public
     constructor Create(ACollection: TCollection); overload; override;
     constructor Create(AParams: TParams; AParamType: TParamType); reintroduce; overload;
TParam-virtual-01.patch (4,426 bytes)

Ondrej Pokorny

2018-06-27 20:51

developer   ~0109085

This one is not really needed, I found a better way. Sorry for the noise.

Michael Van Canneyt

2018-06-28 10:13

administrator   ~0109095

Applied, thank you !

Luiz Americo

2018-07-24 02:05

developer   ~0109643

Given that original poster pointed that this patch is not necessary anymore, should it be reverted?

Calling virtual methods are slightly slower than normal ones

Michael Van Canneyt

2018-07-24 08:37

administrator   ~0109647

Ondrej, you opinion ?

Ondrej Pokorny

2018-07-25 17:15

developer   ~0109672

> Ondrej, you opinion ?

Still the same: This one is not really needed, I found a better way. Sorry for the noise.

Michael Van Canneyt

2018-07-28 11:49

administrator   ~0109719

Undid patch in rev. 39515.

Ondrej Pokorny

2018-08-15 19:09

developer   ~0110062

Thank you!

Issue History

Date Modified Username Field Change
2018-06-27 19:24 Ondrej Pokorny New Issue
2018-06-27 19:24 Ondrej Pokorny File Added: TParam-virtual-01.patch
2018-06-27 20:51 Ondrej Pokorny Note Added: 0109085
2018-06-27 21:38 Michael Van Canneyt Assigned To => Michael Van Canneyt
2018-06-27 21:38 Michael Van Canneyt Status new => assigned
2018-06-28 10:13 Michael Van Canneyt Fixed in Revision => 39321
2018-06-28 10:13 Michael Van Canneyt Note Added: 0109095
2018-06-28 10:13 Michael Van Canneyt Status assigned => resolved
2018-06-28 10:13 Michael Van Canneyt Fixed in Version => 3.1.1
2018-06-28 10:13 Michael Van Canneyt Resolution open => fixed
2018-06-28 10:13 Michael Van Canneyt Target Version => 3.2.0
2018-07-24 02:05 Luiz Americo Note Added: 0109643
2018-07-24 02:05 Luiz Americo Status resolved => feedback
2018-07-24 02:05 Luiz Americo Resolution fixed => reopened
2018-07-24 08:37 Michael Van Canneyt Note Added: 0109647
2018-07-25 17:15 Ondrej Pokorny Note Added: 0109672
2018-07-25 17:15 Ondrej Pokorny Status feedback => assigned
2018-07-28 11:49 Michael Van Canneyt Note Added: 0109719
2018-07-28 11:49 Michael Van Canneyt Status assigned => resolved
2018-07-28 11:49 Michael Van Canneyt Resolution reopened => fixed
2018-08-15 19:09 Ondrej Pokorny Note Added: 0110062
2018-08-15 19:09 Ondrej Pokorny Status resolved => closed