btree: failed to add item to

Поиск
Список
Период
Сортировка
Искать

btree: failed to add item to

От:
"Adam Walczykiewicz" <archiver@db.geocrawler.com>
Дата:
This message was sent from Geocrawler.com by "Adam Walczykiewicz" 
Be sure to reply to that address.

Hi!

I've tried to create function in plpgsql in 
postgresql 6.5 (on Linux Suse 6.2).
: i file.pl
In response I got on the screen an error message :
"gReadData()-- backend closed the channel 
unexpectadly..."
I was back in shell.
In /var/lib/pgsql/pgserver.log I saw :
FATAL1 : btree: failed to add item to the page
The next thing I did was to cut some last 3 lines 
(those beginning with substr(...))
And I run again
: i file.pl
In response I got again on the screen an error 
message :
"gReadData()-- backend closed the channel 
unexpectadly..."
I was back in shell.
In /var/lib/pgsql/pgserver.log I saw :
FATAL1 : my bits moved right off to the end of 
the world!
After all of it I cut some more lines (I thougt 
that the function was
to long to write it down in pg_proc).
And execute once again:
: i file.pl
and it works.
Next I add some more lines and start again to 
create this function and
it failed again with the same effects. 


Why it hapenned?? What can I do to solve that 
problem.
Thanks for any help!!!!
Regards
Adam Walczykiewicz 
(adam.walczykiewicz@multiuser.com.pl) 

(file.pl)
drop function insklient(text);
create function insklient(text) returns text as '
declare
kl_wa klient.wa%TYPE;
kl_typk klient.typk%TYPE;
kl_czas_od_ob klient.czas_od_ob%TYPE;
kl_plec klient.plec%TYPE;
kl_nazwisko klient.nazwisko%TYPE;
kl_imie klient.imie%TYPE;
kl_imied klient.imied%TYPE;
kl_pesel klient.pesel%TYPE;
kl_nip klient.nip%TYPE;
kl_i_ojca klient.i_ojca%TYPE;
kl_nazwisko_r klient.nazwisko_r%TYPE;
kl_data_ur klient.data_ur%TYPE;
kl_tel_dom klient.tel_dom%TYPE;
kl_kod_p klient.kod_p%TYPE;
kl_miasto klient.miasto%TYPE;
kl_ulica klient.ulica%TYPE;
kl_kr_tel klient.kr_tel%TYPE;
kl_kr_kod_p klient.kr_kod_p%TYPE;
kl_kr_miasto klient.kr_miasto%TYPE;
kl_kr_ulica klient.kr_ulica%TYPE;
kl_tel_pr klient.tel_pr%TYPE;
kl_nzprac klient.nzprac%TYPE;
kl_zp_kod klient.zp_kod_p%TYPE;
kl_zp_miasto klient.zp_miasto%TYPE;
kl_zp_ulica klient.zp_ulica%TYPE;
kl_uwagi1 klient.uwagi1%TYPE;
kl_uwagi2 klient.uwagi2%TYPE;
str text;
kl_serial int4;
begin--str := $1;kl_wa := substr(str,1,textpos(str,'','')-
1);str := substr(str,textpos(str,'','')+1);kl_typk := substr(str,1,textpos
(str,'','')-1);str := substr(str,textpos(str,'','')+1);kl_czas_od_ob := substr(str,1,textpos
(str,'','')-1);str := substr(str,textpos(str,'','')+1);kl_plec := substr(str,1,textpos
(str,'','')-1);str := substr(str,textpos(str,'','')+1);kl_nazwisko := substr(str,1,textpos
(str,'','')-1);str := substr(str,textpos(str,'','')+1);kl_imie := substr(str,1,textpos
(str,'','')-1);str := substr(str,textpos(str,'','')+1);kl_imied := substr(str,1,textpos
(str,'','')-1);str := substr(str,textpos(str,'','')+1);kl_pesel := substr(str,1,textpos
(str,'','')-1);str := substr(str,textpos(str,'','')+1);kl_nip := substr(str,1,textpos(str,'','')-
1);str := substr(str,textpos(str,'','')+1);kl_i_ojca := substr(str,1,textpos
(str,'','')-1);str := substr(str,textpos(str,'','')+1);kl_nazwisko_r := substr(str,1,textpos
(str,'','')-1);str := substr(str,textpos(str,'','')+1);kl_data_ur := substr(str,1,textpos
(str,'','')-1);str := substr(str,textpos(str,'','')+1);kl_tel_dom := substr(str,1,textpos
(str,'','')-1);str := substr(str,textpos(str,'','')+1);kl_kod_p := substr(str,1,textpos
(str,'','')-1);str := substr(str,textpos(str,'','')+1);kl_miasto := substr(str,1,textpos
(str,'','')-1);str := substr(str,textpos(str,'','')+1);kl_ulica := substr(str,1,textpos
(str,'','')-1);str := substr(str,textpos(str,'','')+1);kl_kr_tel := substr(str,1,textpos
(str,'','')-1);str := substr(str,textpos(str,'','')-1);str := substr(str,textpos(str,'','')-1);kl_kr_miasto := substr(str,1,texpos
(str,'','')-1);str := substr(str,textpos(str,'','')-1);kl_kr_ulica := substr(str,1,textpos
(str,'','')-1);kl_tel_pr := substr(str,1,textpos
(str,'','')-1);return ''rrrr'';
end;
' language 'plpgsql';

After executing that file (so similar to file.1 
but shorter) the function
was created without any errors. I did it again  
and it works.
(file2.pl)
-- wywolanie select ia('W^45^34');
drop function insdokument(text);
CREATE FUNCTION insdokument(text) RETURNS int4 
AS '
DECLARE
dok_wa dokument.wa%TYPE;
dok_nrk dokument.nrk%TYPE;
dok_rodzaj dokument.rodzaj%TYPE;
dok_seria dokument.seria%TYPE;
dok_numer dokument.numer%TYPE;
dok_uwagi1 dokument.uwagi1%TYPE;
dok_uwagi2 dokument.uwagi2%TYPE;
str text;
dok_serial int4;
beginstr := $1;dok_wa := substr(str,1,textpos(str,''^'')-
1); str := substr(str,textpos(str,''^'')+1);dok_nrk := substr(str,1,textpos
(str,''^'')-1);str := substr(str,textpos(str,''^'')+1);dok_rodzaj := substr(str,1,textpos
(str,''^'')-1);str := substr(str,textpos(str,''^'')+1);dok_seria := substr(str,1,textpos
(str,''^'')-1);str := substr(str,textpos(str,''^'')+1);dok_numer := substr(str,1,textpos
(str,''^'')-1);str := substr(str,textpos(str,''^'')+1);dok_uwagi1 := substr(str,1,textpos
(str,''^'')-1);str := substr(str,textpos(str,''^'')+1);dok_uwagi2 := substr(str,1,textpos
(str,''^'')-1);str := substr(str,textpos(str,''^'')+1);insert into dokument
(wa,nrk,rodzaj,seria,numer,uwagi1,uwagi2) values
(dok_wa,dok_nrk,dok_rodzaj,dok_seria,dok_numer,dok
_uwagi1,dok_uwagi2);select last_value into dok_serial from 
dokument_nr_seq;return dok_serial;
end;
' language 'plpgsql';



Geocrawler.com - The Knowledge Archive

Re: [HACKERS] btree: failed to add item to

От:
Jan Wieck <wieck@debis.com>
Дата:
Adam Walczykiewicz wrote:

> Hi!
>
> I've tried to create function in plpgsql in
>  [...]
> FATAL1 : my bits moved right off to the end of
> the world!
> After all of it I cut some more lines (I thougt
> that the function was
> to long to write it down in pg_proc).
> And execute once again:
> : i file.pl
> and it works.
    Surely you ran into the pg_proc_prosrc_index problem with it.
    This is fixed in the CURRENT tree. I've placed the patch against v6.5.2 onto the FTP server now.    Grab it from

         ftp://ftp.postgresql.org/pub/patches/v6.5/


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#========================================= wieck@debis.com (Jan Wieck) #




Re: [HACKERS] btree: failed to add item to

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Adam, I think you are running into the same problem with overly large
procedure definitions that's been discussed here recently.  In 6.5.*
it's not safe to create a procedure def that's more than 2700 bytes.
Workaround: split your code into smaller functions.

7.0 will be better...
		regards, tom lane

FAQ