From: Nando D. <na...@us...> - 2005-02-22 10:52:13
|
Update of /cvsroot/instantobjects/Source/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22476/Core Modified Files: InstantConsts.pas InstantPersistence.pas Log Message: dropped UsePreparedQuery feature, superseded by the statement cache Index: InstantConsts.pas =================================================================== RCS file: /cvsroot/instantobjects/Source/Core/InstantConsts.pas,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** InstantConsts.pas 16 Sep 2004 11:42:01 -0000 1.5 --- InstantConsts.pas 22 Feb 2005 10:50:59 -0000 1.6 *************** *** 153,159 **** SUnsupportedType = 'Unsupported type: %s'; SUpdateConflict = 'Object %s(''%s'') was updated by another session'; - SUnsupportedUsePreparedQuery = 'UsePreparedQueries option not supported by broker of type %s'; SUnsupportedGraphicStream = 'Unsupported graphic stream format'; SUnsupportedGraphicClass = 'Unsupported graphic class'; implementation --- 153,159 ---- SUnsupportedType = 'Unsupported type: %s'; SUpdateConflict = 'Object %s(''%s'') was updated by another session'; SUnsupportedGraphicStream = 'Unsupported graphic stream format'; SUnsupportedGraphicClass = 'Unsupported graphic class'; + SMissingImplementation = 'Method %s is not implemented in class %s'; implementation Index: InstantPersistence.pas =================================================================== RCS file: /cvsroot/instantobjects/Source/Core/InstantPersistence.pas,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** InstantPersistence.pas 22 Feb 2005 08:05:03 -0000 1.25 --- InstantPersistence.pas 22 Feb 2005 10:51:01 -0000 1.26 *************** *** 2141,2145 **** FGenerator: TInstantSQLGenerator; FResolverList: TObjectList; - FUsePreparedQuery: Boolean; function GetResolverList: TObjectList; function GetResolverCount: Integer; --- 2141,2144 ---- *************** *** 2151,2157 **** procedure InternalBuildDatabase(Scheme: TInstantScheme); override; property ResolverList: TObjectList read GetResolverList; - procedure PrepareQuery(DataSet : TDataSet); virtual; - function ExecuteQuery(DataSet : TDataSet) : integer; virtual; - procedure UnprepareQuery(DataSet : TDataSet); virtual; procedure AssignDataSetParams(DataSet : TDataSet; AParams: TParams); virtual; function CreateDataSet(const AStatement: string; AParams: TParams = nil): TDataSet; virtual; abstract; --- 2150,2153 ---- *************** *** 2167,2171 **** property ResolverCount: Integer read GetResolverCount; property Resolvers[Index: Integer]: TInstantSQLResolver read GetResolvers; - property UsePreparedQuery: Boolean read FUsePreparedQuery write FUsePreparedQuery; end; --- 2163,2166 ---- *************** *** 2179,2192 **** FUpdateSQL: string; FUpdateConcurrentSQL: string; - - FPreparedDataSet: TDataSet; - LastStatement: string; - LastConnector: TObject; FSelectExternalSQL: string; FSelectExternalPartSQL: string; FDeleteExternalSQL: string; FInsertExternalSQL: string; - function CreatePreparedQuery(const AStatement: string; AParams: TParams = nil): TDataSet; - procedure AddIntegerParam(Params: TParams; const ParamName: string; Value: Integer); procedure AddStringParam(Params: TParams; const ParamName, Value: string); --- 2174,2181 ---- *************** *** 2204,2208 **** function GetUpdateSQL: string; function GetBroker: TInstantSQLBroker; - function GetUsePreparedQuery: Boolean; function GetSelectExternalSQL: string; function GetSelectExternalPartSQL: string; --- 2193,2196 ---- *************** *** 2244,2248 **** public constructor Create(ABroker: TInstantSQLBroker; AMap: TInstantAttributeMap); - destructor Destroy; override; property Broker: TInstantSQLBroker read GetBroker; property DeleteConcurrentSQL: string read GetDeleteConcurrentSQL write FDeleteConcurrentSQL; --- 2232,2235 ---- *************** *** 2257,2261 **** property UpdateConcurrentSQL: string read GetUpdateConcurrentSQL write FUpdateConcurrentSQL; property UpdateSQL: string read GetUpdateSQL write FUpdateSQL; - property UsePreparedQuery: Boolean read GetUsePreparedQuery; end; --- 2244,2247 ---- *************** *** 12881,12886 **** procedure TInstantSQLBroker.AssignDataSetParams(DataSet: TDataSet; AParams: TParams); begin ! // must be implemented in derived broker ! raise EInstantError.CreateFmt(SUnsupportedUsePreparedQuery, [ClassName]); end; --- 12867,12871 ---- procedure TInstantSQLBroker.AssignDataSetParams(DataSet: TDataSet; AParams: TParams); begin ! raise EInstantError.CreateFmt(SMissingImplementation, ['AssignDataSetParams', ClassName]); end; *************** *** 12903,12912 **** end; - function TInstantSQLBroker.ExecuteQuery(DataSet: TDataSet): Integer; - begin - // must be implemented in derived broker - raise EInstantError.CreateFmt(SUnsupportedUsePreparedQuery, [ClassName]); - end; - function TInstantSQLBroker.FindResolver( AMap: TInstantAttributeMap): TInstantSQLResolver; --- 12888,12891 ---- *************** *** 12999,13007 **** end; - procedure TInstantSQLBroker.PrepareQuery(DataSet: TDataSet); - begin - //Prepare the query in derived Broker - end; - procedure TInstantSQLBroker.ReleaseDataSet(const ADataSet: TDataSet); begin --- 12978,12981 ---- *************** *** 13012,13020 **** end; - procedure TInstantSQLBroker.UnprepareQuery(DataSet: TDataSet); - begin - //Unprepare the query in derived Broker - end; - { TInstantSQLResolver } --- 12986,12989 ---- *************** *** 13285,13331 **** end; - function TInstantSQLResolver.CreatePreparedQuery(const AStatement: string; - AParams: TParams): TDataSet; - begin - if (FPreparedDataSet = nil) or (LastStatement <> AStatement) or (LastConnector <> Broker.Connector) then - begin - //First time or different statement/connector: create and prepare query - if Assigned(FPreparedDataSet) then - begin - FPreparedDataSet.Close; - Broker.UnprepareQuery(FPreparedDataSet); - FPreparedDataSet.Free; - FPreparedDataSet := nil; - end; - Result := Broker.CreateDataSet(AStatement,AParams); - try - FPreparedDataSet := Result; - LastStatement := AStatement; - LastConnector := Broker.Connector; - //Prepare the query for future uses - Broker.PrepareQuery(FPreparedDataSet); - except - Result.Free; - raise; - end; - end - else - begin - //Return the previous prepared query - if FPreparedDataSet.Active then - FPreparedDataSet.Close; - //Assign only new param values - Broker.AssignDataSetParams(FPreparedDataSet,AParams); - Result := FPreparedDataSet; - end; - end; - - destructor TInstantSQLResolver.Destroy; - begin - if Assigned(FPreparedDataSet) then - FPreparedDataSet.Free; - inherited; - end; - function TInstantSQLResolver.ExecuteStatement(const AStatement: string; AParams: TParams; Info: PInstantOperationInfo; --- 13254,13257 ---- *************** *** 13333,13337 **** var TransError: Exception; - DataSet : TDataSet; begin {$IFDEF IO_STATEMENT_LOGGING} --- 13259,13262 ---- *************** *** 13339,13350 **** {$ENDIF} try ! if not UsePreparedQuery then ! Result := Broker.Execute(AStatement, AParams) ! else ! begin ! DataSet := CreatePreparedQuery(AStatement, AParams); ! Result := Broker.ExecuteQuery(DataSet); ! end; ! Info.Success := Result = 1; Info.Conflict := not Info.Success or (ConflictAction = caIgnore); --- 13264,13268 ---- {$ENDIF} try ! Result := Broker.Execute(AStatement, AParams); Info.Success := Result = 1; Info.Conflict := not Info.Success or (ConflictAction = caIgnore); *************** *** 13438,13446 **** end; - function TInstantSQLResolver.GetUsePreparedQuery: Boolean; - begin - Result := Broker.UsePreparedQuery; - end; - procedure TInstantSQLResolver.InternalDisposeMap(AObject: TInstantObject; Map: TInstantAttributeMap; ConflictAction: TInstantConflictAction; --- 13356,13359 ---- *************** *** 13656,13664 **** try AddBaseParams(Params, AObject.ClassName, AObjectId); ! if not UsePreparedQuery then ! DataSet := Broker.AcquireDataSet(SelectSQL, Params) ! else ! DataSet := CreatePreparedQuery(SelectSQL, Params); ! try DataSet.Open; --- 13569,13573 ---- try AddBaseParams(Params, AObject.ClassName, AObjectId); ! DataSet := Broker.AcquireDataSet(SelectSQL, Params); try DataSet.Open; *************** *** 13673,13678 **** ResetAttributes; finally ! if not UsePreparedQuery then ! Broker.ReleaseDataSet(DataSet); end; finally --- 13582,13586 ---- ResetAttributes; finally ! Broker.ReleaseDataSet(DataSet); end; finally |