Subject ‘select view’ crashes a remote Firebird Server
Author kokok_kokok
I have attached a simple example where the combination of 2 `selects'
crashes a FB server, in local and remote mode:

SELECT * FROM HERD WHERE HTYPE=0 AND CODI='372'

SELECT * FROM FEMALE

Sources, binaries and database at:
http://www.fut.es/~xmarquez/LostConnection2.zip



HERD is a table and FEMALE is a view. The database does not use UDF
functions, it is SQL 100% code. The database is not corrupted. I only
use 2 TIBOQuery to execute the above sentences.

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.

It seems that FB has state memory because it crashes at the third
intent. I have noted that if you modify the FEMALE view, the problem
is minimized but it is even latent. For example if I delete any
field, everything workd ok. 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. Also, if you delete some fields of the view,
everything works ok. 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.


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
{
qryTest1->Open();
qryTest2->Open();
}
__finally
{
qryTest1->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");
}
//--------------------------------------------------------------------
-------

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 = 'Test'
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 qryTest1: TIBOQuery
Params = <>
DatabaseName = 'test.fdb'
IB_Connection = dbMainDatabase
RecordCountAccurate = False
Unidirectional = True
SQL.Strings = (
'SELECT * FROM HERD WHERE HTYPE=0 AND CODI=''372''')
FieldOptions = []
Left = 40
Top = 65534
end
object qryTest2: TIBOQuery
Params = <>
DatabaseName = 'test.fdb'
DefaultValues.Strings = (
'SELECT * FROM FEMALE')
IB_Connection = dbMainDatabase
RecordCountAccurate = False
Unidirectional = True
SQL.Strings = (
'SELECT * FROM FEMALE')
FieldOptions = []
Left = 80
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