Re: [fpc-devel]Some questions about tdataset and a small patch

2004-08-02 Thread Joost van der Sluis
Hi all,

i have some fixes/additions:

- With the patch in the attached dataset.inc.diff(2) tdataset now posts
changes before scrolling to another record (ie first, next etc.) like
Delphi does.

- In interbase.pp.diff(2) the ExecuteDirect method is added to TIBDatabase

And further i've implemented an BufferAllRecords property for
TDataset like i suggested earlier. I don't know if you guys like this
solution, but have a look at it. It works perfect with
interbase (tibquery doesn't work properly without it) but also with
tDbf. 

If BufferAllRecords is set to true, all fetched records will be kept in
memory. For tibquery this is the default.
(patch is in db.pp.diff, interbase.pp.diff, dataset.inc.diff)

Joost van der Sluis.

(reminder:)
> 3: Add a property to TDataset, which changes the behaviour of the buffers,
> so that they are 'infinitive'. All fetched records are kept in memory. The
> descendents that need this can set this property in their
> create-functions. Delphi has something like this, if you set the
> buffercount to -1.
> 
> I think i'm going to try to implement option three. But what do you all
> think about this issue?

Index: interbase.pp
===
RCS file: /FPC/CVS/fpc/fcl/db/interbase/interbase.pp,v
retrieving revision 1.13
diff -u -r1.13 interbase.pp
--- interbase.pp25 Jul 2004 11:32:40 -  1.13
+++ interbase.pp2 Aug 2004 22:20:43 -
@@ -1068,7 +1086,7 @@

 procedure TIBQuery.InternalFirst;
 begin
-  FCurrentRecord := -1;
+//  FCurrentRecord := -1;
 end;

 procedure TIBQuery.InternalGotoBookmark(ABookmark: Pointer);
@@ -1189,6 +1207,7 @@
 constructor TIBQuery.Create(AOwner : TComponent);
 begin
   inherited Create(AOwner);
+  setBufferAllRecords(true);
   FSQL := TStringList.Create;
   FCurrentRecord := -1;
   AllocSQLDA(10);
Index: interbase.pp
===
RCS file: /FPC/CVS/fpc/fcl/db/interbase/interbase.pp,v
retrieving revision 1.13
diff -u -r1.13 interbase.pp
--- interbase.pp25 Jul 2004 11:32:40 -  1.13
+++ interbase.pp2 Aug 2004 22:20:43 -
@@ -68,6 +68,7 @@
   public
 procedure StartTransaction; override;
 procedure EndTransaction; override;
+function ExecuteDirect(SQL : string) : integer;
 destructor Destroy; override;
 property Handle: Pointer read GetHandle;
   published
@@ -391,6 +392,23 @@
   raise EInterBaseError.Create('Cannot assign transaction while old transaction 
active!');
 end;
 
+function TIBDatabase.ExecuteDirect(SQL : string) : integer;
+
+var tr : pointer;
+
+begin
+  if FTransaction = nil then
+raise EDatabaseError.Create('TIBDatabase.ExecuteDirect: Transaction not set');
+
+// tr has to be zero to create a database
+{  if not FTransaction.Active then
+FTransaction.StartTransaction;}
+
+  tr := FTransaction.GetHandle;
+
+  result := isc_dsql_execute_immediate(@FStatus[0], @FIBDatabaseHandle, 
@tr,0,@SQL[1],1,nil);
+end;
+
 function TIBDatabase.GetHandle: pointer;
 begin
   Result := FIBDatabaseHandle;

Index: db.pp
===
RCS file: /FPC/CVS/fpc/fcl/db/db.pp,v
retrieving revision 1.19
diff -u -r1.19 db.pp
--- db.pp   25 Jul 2004 11:32:40 -  1.19
+++ db.pp   2 Aug 2004 22:25:31 -
@@ -827,6 +827,7 @@
 FRecordCount: Longint;
 FRecordSize: Word;
 FState : TDataSetState;
+FBufferAllRecords : Boolean;
 Procedure DoInsertAppend(DoAppend : Boolean);
 Procedure DoInternalOpen;
 Procedure DoInternalClose;
@@ -913,6 +914,7 @@
 procedure SetOnFilterRecord(const Value: TFilterRecordEvent); virtual;
 procedure SetRecNo(Value: Longint); virtual;
 procedure SetState(Value: TDataSetState);
+procedure SetBufferAllRecords(Value : Boolean);
 function SetTempState(const Value: TDataSetState): TDataSetState;
 function TempBuffer: PChar;
 procedure UpdateIndexDefs; virtual;
@@ -1020,6 +1022,7 @@
 property FilterOptions: TFilterOptions read FFilterOptions write FFilterOptions;
 property Active: Boolean read FActive write SetActive default False;
 property AutoCalcFields: Boolean read FAutoCalcFields write FAutoCalcFields;
+property BufferAllRecords : Boolean read FBufferAllRecords write 
SetBufferAllRecords;
 property BeforeOpen: TDataSetNotifyEvent read FBeforeOpen write FBeforeOpen;
 property AfterOpen: TDataSetNotifyEvent read FAfterOpen write FAfterOpen;
 property BeforeClose: TDataSetNotifyEvent read FBeforeClose write FBeforeClose;
Index: dataset.inc
===
RCS file: /FPC/CVS/fpc/fcl/db/dataset.inc,v
retrieving revision 1.15
diff -u -r1.15 dataset.inc
--- dataset.inc 25 Jul 2004 11:32:40 -  1.15
+++ dataset.inc 2 Aug 2004 22:28:29 -
@@ -523,11 +524,14 @@
   Writeln ('Getting next record. Internal RecordCount : ',FRecordCount);
 {$endif}
   Shifted:=FReco

[fpc-devel]Access violation with IndexName property of TDbf

2004-08-02 Thread Tony Maro
I'm not sure if this is a TDbf issue, or an FPC db issue, so I'm posting 
both places.  I'm using CVS of FPC from about 1 hour ago.

Basically, whatever I do, if I try to set the "IndexName" or 
"IndexFieldNames" property of the TDbf I get an access violation.

Here's a sample:
var
  MyDbf: TDbf;
begin
 MyDbf := TDbf.Create(nil);
 MyDbf.FilePath := 'data/';
 { we want to use Visual dBase VII compatible tables }
 MyDbf.TableLevel := 7;
 MyDbf.Exclusive := True;
 MyDbf.TableName := 'customers.dbf';
 With MyDbf.FieldDefs do begin
  Add('Id', ftAutoInc, 0, True);
  Add('Name', ftString, 80, True);
 End;
 MyDbf.CreateTable;
 MyDbf.Open;
 MyDbf.AddIndex('custid', 'Id', [ixPrimary, ixUnique]);
 MyDbf.AddIndex('custname.ndx','Name', [ixCaseInsensitive]);
 MyDbf.Close;
 MyDbf.Free;
 MessageDlg('Created.', mtInformation,[mbOk],0);
 MyDBF := TDBf.Create(nil);
 MyDBF.FilePath := 'data/';
 MyDBF.TableLevel := 25;
 MyDBF.TableName := 'customers.dbf';
 MyDBF.Open;
 MyDBF.OpenIndexFile('custname.ndx');
 MyDBF.IndexName := 'custname';
 //MyDBF.IndexFieldNames := 'Name';   // doesn't work either
 //MyDBF.IndexName := 'custid'; // doesn't work EITHER...
 MyDbf.Close;
end;
And the obligatory backtrace:
(gdb) run
Starting program: /home/tony/Projects/testcrash/project1
Program received signal SIGSEGV, Segmentation fault.
0x0806a29c in DBF_TDBF_$__GETRECORD$PCHAR$TGETMODE$BOOLEAN ()
(gdb) bt full
#0  0x0806a29c in DBF_TDBF_$__GETRECORD$PCHAR$TGETMODE$BOOLEAN ()
No symbol table info available.
#1  0x08070de8 in DB_TDATASET_$__RESYNC$TRESYNCMODE ()
No symbol table info available.
#2  0x0806b252 in DBF_TDBF_$__RESYNC$TRESYNCMODE ()
No symbol table info available.
#3  0x0806cf63 in DBF_TDBF_$__SETINDEXNAME$ANSISTRING ()
No symbol table info available.
#4  0x0816dd29 in TFORM1__BUTTON1CLICK (SENDER=0x40440ea8, this=0x4043eae8)
   at unit1.pas:59
   MYDBF = (TDBF *) 0x4057c014
#5  0x08102158 in TCONTROL__CLICK (this=0x40440ea8) at control.inc:1813
No locals.
#6  0x080d6b25 in TBUTTONCONTROL__CLICK (this=0x40440ea8)
   at buttoncontrol.inc:51
No locals.
#7  0x080ca201 in TCUSTOMBUTTON__CLICK (this=0x40440ea8) at buttons.inc:187
   FORM = (TCUSTOMFORM *) 0x0
#8  0x080ca220 in TCUSTOMBUTTON__WMDEFAULTCLICKED (MESSAGE=
 {MSG = 1031, WPARAM = -1073746528, LPARAM = 26, RESULT = 
1075674240, WPARA MLO = 60832, WPARAMHI = 49151, LPARAMLO = 26, LPARAMHI 
= 0, RESULTLO = 31872, RE SULTHI = 16413}, this=0x40440ea8) at 
buttons.inc:199
No locals.

___
fpc-devel maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel]gdb issue

2004-08-02 Thread Tomas Hajny
On Fri, 23 Jul 2004 19:34:16 +0300, Rimgaudas Laucius wrote

Hi

> i tried to view integer variable value in binary mode using gdb 
> (5.2.1, windows, fpc1010 ) command "p /t i". But it shows nothing. 
> Does anyone else come across this issue or i am doing something wrong?

You need to change all variable names to uppercase if using plain gdb (i.e.
"print /t I").

Tomas


___
fpc-devel maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel]Patch: Support for $LIBPREFIX, $LIBSUFFIX, and $EXTENSION compiler directives.

2004-08-02 Thread Christian Iversen
On Monday 02 August 2004 09:17, Michael Van Canneyt wrote:
> On Sun, 1 Aug 2004, Christian Iversen wrote:
> > The following patch is tested, although only on linux. It supports the
> > (at least for me :) long-awaited LIBPREFIX/SUFFIX support. It also cleans
> > up scanner.pas a bit, by renaming some "turbo_scannerdirectives" and
> > "directive_turbo" to "common_scannerdirectives" and "directive_common.
> >
> > This closes a number of bug reports, although my own one is the only one
> > I can find at the moment. (Can somebody do a fulltext search in the
> > bugreports?)
>
> Thank you.
>
> I have applied the patch, but I reverted back to the old turbo_ names.
> I assume Peter Vreman or Florian Klaempfl chose these names are for a
> reason.
>
> I closed the bug report.

I'm sorry, I completely forgot to say I talked to Florian on #fpc - he 
approved the new names. turbo_* was left over from some old code. 

-- 
Regards,
Christian Iversen

___
fpc-devel maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel]Patch: Support for $LIBPREFIX, $LIBSUFFIX, and $EXTENSION compiler directives.

2004-08-02 Thread Michael Van Canneyt


On Sun, 1 Aug 2004, Christian Iversen wrote:

>
> The following patch is tested, although only on linux. It supports the (at
> least for me :) long-awaited LIBPREFIX/SUFFIX support. It also cleans up
> scanner.pas a bit, by renaming some "turbo_scannerdirectives" and
> "directive_turbo" to "common_scannerdirectives" and "directive_common.
>
> This closes a number of bug reports, although my own one is the only one I can
> find at the moment. (Can somebody do a fulltext search in the bugreports?)

Thank you.

I have applied the patch, but I reverted back to the old turbo_ names.
I assume Peter Vreman or Florian Klaempfl chose these names are for a
reason.

I closed the bug report.

Michael.

___
fpc-devel maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-devel