Subject Example to shutdown a remote Firebird Server
Author kokok_kokok
Problem:
------------
A simple program can shutdown the Firebird server placed in a remote
PC.

I have put several messages in this forum about this problem without
results, probably because this problem is hard to reproduce. Now, I
have isolated it and in this example, the problem always arises.
The thing is that some combination of `selects' shutdown the FB
server, showing `Lost Connection' message, and of course, all FB
clients lose their connections, in remote and local mode.

I have noted that if you modify the view FEMALE, the problem is
minimized but it is even latent. Also, the "cast" operator in the
view can mimize the frequency of the problem in an important way, but
it is only question of time. In few words: I have no idea about the
reason.


Environment:
----------
Firebird version 1.5
IBObjects 4.2 Ie
Builder C++6
OS: This problem appear in Windows XP Professional, XP Home and
Windows 2000. I do not know in W98.
Hardware: Several computers

It happens in remote connections via TCP/IP and also in local mode.

Example:
-----------
I have upload the source, binaries and database example at:
http://www.fut.es/~xmarquez/LostConnection.zip


Steps to reproduce the problem:
-------------------------------------

1-Enter the database parameters (try in local mode and remote mode)
2-Click `Connect'
3-Click `Test'
4-Click `Test'
5-Click `Test'

Only at the third click in `Test' button, the lost connection message
appear.

---------

Another way to reproduce it is:

1-Delete the query "select * from female" from the CPP code
2-Compile and Execute
3-Click `Connect' and `Test'
4-Now, from IBConsole or any SQL client, execute "select * from
female" stantement
5-Return to the program and click "Test" several times. The FB server
will be shutdown. Note that if you do not execute "select * from
female", everything works ok.


-----
firebird.log file:

NETVISTA (Client) Fri May 28 13:27:34 2004
C:\Archivos de programa\Firebird\Firebird_1_5
\bin\fbserver.exe: terminated abnormally (4294967295)
------------

CPP code:
-----------

void __fastcall TForm1::btnTestClick(TObject *Sender)
{
try
{
cdsTest->FetchParams();
cdsTest->Params->ParamByName("hType")->Value =0;
cdsTest->Params->ParamByName("Codi")->AsString ="372";
cdsTest->Open();

qryTest2->SQL->Text="select * from female";
qryTest2->Open();
}
__finally
{
cdsTest->Close();
qryTest2->Close();
}
}
//--------------------------------------------------------------------
-------

void __fastcall TForm1::btnButtonClick(TObject *Sender)
{
dbMainDatabase->Protocol=cbLocal->Checked? cpLocal: cpTCP_IP;
dbMainDatabase->Server=edServer->Text;
dbMainDatabase->Path=edDatabase->Text;

dbMainDatabase->Connected=true;
ShowMessage("Connection OK");
}
//--------------------------------------------------------------------
-------


DFM file:

object Form1: TForm1
Left = 323
Top = 174
Width = 327
Height = 204
Caption = 'v'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 24
Top = 64
Width = 31
Height = 13
Caption = 'Server'
end
object Label2: TLabel
Left = 24
Top = 96
Width = 46
Height = 13
Caption = 'Database'
end
object btnTest: TButton
Left = 168
Top = 136
Width = 75
Height = 25
Caption = 'Test'
TabOrder = 0
OnClick = btnTestClick
end
object btnButton: TButton
Left = 80
Top = 136
Width = 75
Height = 25
Caption = 'Connect'
TabOrder = 1
OnClick = btnButtonClick
end
object edServer: TEdit
Left = 88
Top = 56
Width = 217
Height = 21
TabOrder = 2
Text = 'localhost'
end
object edDatabase: TEdit
Left = 88
Top = 88
Width = 217
Height = 21
TabOrder = 3
Text = 'test.fdb'
end
object cbLocal: TCheckBox
Left = 88
Top = 32
Width = 137
Height = 17
Caption = 'Protocol cpLocal'
Checked = True
State = cbChecked
TabOrder = 4
end
object qryPrvHerd: TIBOQuery
Params = <
item
DataType = ftSmallint
Name = 'HTYPE'
ParamType = ptInput
end
item
DataType = ftString
Name = 'CODI'
ParamType = ptInput
end>
DatabaseName = 'test.fdb'
IB_Connection = dbMainDatabase
RecordCountAccurate = False
RequestLive = True
SQL.Strings = (
'SELECT * FROM HERD WHERE HTYPE=:HTYPE AND CODI=:CODI')
FieldOptions = []
Left = 72
Top = 65534
end
object prvHerd: TDataSetProvider
DataSet = qryPrvHerd
Constraints = True
Left = 104
end
object cdsTest: TClientDataSet
Aggregates = <>
Params = <>
ProviderName = 'prvHerd'
Left = 136
Top = 65528
end
object qryTest2: TIBOQuery
Params = <
item
DataType = ftSmallint
Name = 'HTYPE'
ParamType = ptInput
end
item
DataType = ftString
Name = 'CODI'
ParamType = ptInput
end>
DatabaseName = 'test.fdb'
IB_Connection = dbMainDatabase
RecordCountAccurate = False
RequestLive = True
SQL.Strings = (
'SELECT * FROM HERD WHERE HTYPE=:HTYPE AND CODI=:CODI')
FieldOptions = []
Left = 40
Top = 65534
end
object dbMainDatabase: TIBODatabase
SQLDialect = 3
Params.Strings = (
'PAGE SIZE=4096'
'PATH=test.fdb'
'SQL DIALECT=3'
'USER NAME=SYSDBA')
AutoCommit = False
Left = 8
SavedPassword = '.JuMbLe.01.432B0639073E0E4B49'
end
end