Search Postgresql Archives

Re: How to fix set-valued function called in context that cannot accept a set in earlier versions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello, Andrus

I tested this reproduce case.

8.3.9   return exception
8.3.10 return exception
8.4.0   Crash Server!!
8.4.1   OK
8.4.2   OK
8.4.3   OK

Just for your information,
8.4.0's clash made this call stack(I analyzed core file)

#0 DirectFunctionCall1 (func=0x8095a70 <hashoid>, arg1=16421) at fmgr.c:1012
1012            result = (*func) (&fcinfo);
(gdb) where
#0 DirectFunctionCall1 (func=0x8095a70 <hashoid>, arg1=16421) at fmgr.c:1012
#1  0x082c9eab in CatalogCacheComputeHashValue (cache=0xa091058,
    nkeys=<value optimized out>, cur_skey=0xbeca1298) at catcache.c:207
#2 0x082cad19 in SearchCatCache (cache=0xa091058, v1=16421, v2=0, v3=0, v4=0)
    at catcache.c:1137
#3 0x082df1cf in fmgr_info_cxt_security (functionId=16421, finfo=0xbeca144c,
    mcxt=<value optimized out>, ignore_security=0 '\0') at fmgr.c:209
#4 0x082df881 in fmgr_info (functionId=16421, finfo=0xbeca144c) at fmgr.c:156 #5 0x082df282 in fmgr_info_cxt_security (functionId=43373, finfo=0xb56c6320,
    mcxt=<value optimized out>, ignore_security=1 '\001') at fmgr.c:406
#6  0x082e0520 in fmgr_security_definer (fcinfo=0xa0e2f34) at fmgr.c:898
#7  0x082e041c in fmgr_security_definer (fcinfo=0xa0e2f34) at fmgr.c:961
#8  0x082e041c in fmgr_security_definer (fcinfo=0xa0e2f34) at fmgr.c:961

I usually see this call stack in version 8.4.0 and I guess this error does not occur in 8.4.1

Thank you.

(2010/04/05 20:14), Andrus wrote:
In 8.3 code below causes exception

ERROR:  set-valued function called in context that cannot accept a set
CONTEXT:  PL/pgSQL function "wordwrap" line 21 at RETURN NEXT

How to fix this so that wordwrap works in any PostgreSql 8.x version or at least in
8.3 and 8.4 ?

Andrus

CREATE OR REPLACE FUNCTION wordwrap(line text, linelen integer)
RETURNS SETOF text as $$
DECLARE
 words text[] := string_to_array(line,' ');
 i integer;
 res text:='';

BEGIN
 if trim(line)='' then
   return next '';
   return;
   end if;
for i IN 1 .. array_upper(words,1) LOOP
  if length(res)+length(words[i]) > linelen THEN
    return next res;
    res := '';
    END IF ;
  if res<>'' then
    res := res || ' ';
    end if;
  res := res || words[i];
  end loop;
return next res;
END
$$ LANGUAGE plpgsql;

select wordwrap('fdgdf',10)



--
================================================
Kenichiro Tanaka
K.K.Ashisuto
http://www.ashisuto.co.jp/english/index.html
================================================


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux