Subject | Re: FB 1.5 closes connection if 'when-case' does not have cast |
---|---|
Author | kokok_kokok |
Post date | 2004-05-24T13:24:23Z |
The complete DDL is:
/* View: FEMALE, Owner: SYSDBA */
CREATE VIEW "FEMALE" (
"BIRTHDATE",
"BIRTHINGS",
"COMMENT",
"CURLOC1",
"CURLOC2",
"CURLOC3",
"CURPARITY",
"CURPREWEANEDS",
"DAM",
"ENTRYDATE",
"GENETICS",
"ID",
"IID_FEMALE",
"ISACTIVE",
"LACTATIONSTATUS",
"LFABORTIONS",
"LFAVGLIVEBORN",
"LFAVGSTILLBORN",
"LFAVGTOTALBORN",
"LFLIVEBORN",
"LFMUMMIES",
"LFNETADDED",
"LFPREWEANEDDEATHS",
"LFSERVICES",
"LFSTILLBORN",
"LFTOTALBORN",
"LOCATION",
"MORPHSCORE",
"NAME",
"REGISTERID",
"REMOVEDATE",
"REMOVEREASON",
"REMOVETYPE",
"REPROSTATUS",
"SERV1AGE",
"SIRE",
"TOBEREMOVED",
"USERFIELDA1",
"USERFIELDA2"
) AS
select
h.DtNaixement,
h.Parts,
h.Comentari,
CurLoc1,
CurLoc2,
CurLoc3,
coalesce(parts,0)+coalesce(iniparity,0),
CurPreWeaneds,
h.Mare,
h.DtEntrada,
h.Genetics,
h.codi,
h.herd_id,
case when dtbaixa is null then 0 else 1 end,
h.lacstatus,
f.lfAbortions,
f.lfliveBorn*1.00 / nullif(h.parts,0),
f.lfStillBorn*1.00 / nullif(h.parts,0),
(f.lfliveBorn+f.lfstillborn+f.lfmummies)*1.00 / nullif(h.parts,0),
f.lfLiveborn,
f.lfMummies,
f.lfnetadded,
f.LFPREWEANEDDEATHS,
f.lfServices,
f.lfStillborn,
f.lfliveBorn+f.lfstillborn+f.lfmummies,
h.ubicacio,
h.PMorfo,
h.Name,
h.Registre,
h.DtBaixa,
h.CausaBaixa,
h.TipusBaixa,
h.reproStatus,
h.DtRepro-h.DtNaixement,
h.Pare,
case when peticiorepos is null then 0 else 1 end,
h.UserFieldA0,
h.UserFieldA1 from herd h inner join herd_females f on
h.herd_id=f.herd_id where h.htype=0
;
-------------------
There 2 cases:
case when dtbaixa is null then 0 else 1 end,
case when peticiorepos is null then 0 else 1 end
---
dtbaixa is date field
peticiorepos is D_BOOLEAN
CREATE DOMAIN "D_BOOLEAN" AS CHAR(1)
default 'F'
CHECK (value='T' or value='F' );
I have noted that it is not necessary to cast "dtbaixa" field. On
other hand, "peticiorepos" needs to be cast because in another
case "connection lost" appear:
"case when peticiorepos is null then cast(0 as smallint) else cast(1
as smallint) end"
"select * from female" does not fail always, depends on previous
tasks. Also it fails sometimes yes, sometimes no. There is not a
pattern that fails always, but there are several patterns where it
fails frequently. For example, if I print out some reports, it fails
about 60%. If the program execute several sentences like INSERT or
UPDATE and then I do "select * from female", the connecion lost
appears always.
As I said, I have tested in local and remote mode and several
computers, and under Windows 2000 and XP.
When I cast the value to smallint, everything works ok.
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
/* View: FEMALE, Owner: SYSDBA */
CREATE VIEW "FEMALE" (
"BIRTHDATE",
"BIRTHINGS",
"COMMENT",
"CURLOC1",
"CURLOC2",
"CURLOC3",
"CURPARITY",
"CURPREWEANEDS",
"DAM",
"ENTRYDATE",
"GENETICS",
"ID",
"IID_FEMALE",
"ISACTIVE",
"LACTATIONSTATUS",
"LFABORTIONS",
"LFAVGLIVEBORN",
"LFAVGSTILLBORN",
"LFAVGTOTALBORN",
"LFLIVEBORN",
"LFMUMMIES",
"LFNETADDED",
"LFPREWEANEDDEATHS",
"LFSERVICES",
"LFSTILLBORN",
"LFTOTALBORN",
"LOCATION",
"MORPHSCORE",
"NAME",
"REGISTERID",
"REMOVEDATE",
"REMOVEREASON",
"REMOVETYPE",
"REPROSTATUS",
"SERV1AGE",
"SIRE",
"TOBEREMOVED",
"USERFIELDA1",
"USERFIELDA2"
) AS
select
h.DtNaixement,
h.Parts,
h.Comentari,
CurLoc1,
CurLoc2,
CurLoc3,
coalesce(parts,0)+coalesce(iniparity,0),
CurPreWeaneds,
h.Mare,
h.DtEntrada,
h.Genetics,
h.codi,
h.herd_id,
case when dtbaixa is null then 0 else 1 end,
h.lacstatus,
f.lfAbortions,
f.lfliveBorn*1.00 / nullif(h.parts,0),
f.lfStillBorn*1.00 / nullif(h.parts,0),
(f.lfliveBorn+f.lfstillborn+f.lfmummies)*1.00 / nullif(h.parts,0),
f.lfLiveborn,
f.lfMummies,
f.lfnetadded,
f.LFPREWEANEDDEATHS,
f.lfServices,
f.lfStillborn,
f.lfliveBorn+f.lfstillborn+f.lfmummies,
h.ubicacio,
h.PMorfo,
h.Name,
h.Registre,
h.DtBaixa,
h.CausaBaixa,
h.TipusBaixa,
h.reproStatus,
h.DtRepro-h.DtNaixement,
h.Pare,
case when peticiorepos is null then 0 else 1 end,
h.UserFieldA0,
h.UserFieldA1 from herd h inner join herd_females f on
h.herd_id=f.herd_id where h.htype=0
;
-------------------
There 2 cases:
case when dtbaixa is null then 0 else 1 end,
case when peticiorepos is null then 0 else 1 end
---
dtbaixa is date field
peticiorepos is D_BOOLEAN
CREATE DOMAIN "D_BOOLEAN" AS CHAR(1)
default 'F'
CHECK (value='T' or value='F' );
I have noted that it is not necessary to cast "dtbaixa" field. On
other hand, "peticiorepos" needs to be cast because in another
case "connection lost" appear:
"case when peticiorepos is null then cast(0 as smallint) else cast(1
as smallint) end"
"select * from female" does not fail always, depends on previous
tasks. Also it fails sometimes yes, sometimes no. There is not a
pattern that fails always, but there are several patterns where it
fails frequently. For example, if I print out some reports, it fails
about 60%. If the program execute several sentences like INSERT or
UPDATE and then I do "select * from female", the connecion lost
appears always.
As I said, I have tested in local and remote mode and several
computers, and under Windows 2000 and XP.
When I cast the value to smallint, everything works ok.
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
> At 11:38 AM 24/05/2004 +0000, you wrote:in
>
> >FB 1.5 server closes the connection to the database when I
> >execute "select * from view1" from my program or from IBConsole.
> >
> >This view has several fields, the problematic field is:
> >
> >"case when field1 is null then 0 else 1 end"
> >
> >
> >"field1" is a smallint field from a table. If I have this sentence
> >the view script, FB crashes generating a "Connection lost" error:please
> >
> >"fbserver.exe: terminated abnormally (4294967295)"
> >
> >
> >I can fix this problem only casting the above sentence in the view:
> >
> >"case when field1 is null then cast(0 as smallint) else cast(1 as
> >smallint) end"
> >
> >Now, "select * from view1" works ok and the connection is not lost.
> >
> >
> >My question is why this happens?
> >
> >I have tried this with several computers, remote and local
> >connection, I do not use UDF functions, IBOConsole and other
> >clients,... but the problem appears in all cases.
>
> If anything, it should fail on the CREATE VIEW statement. Can you
> post the full DDL for the view declaration?
>
> /heLen