Re: functions returning records

Поиск
Список
Период
Сортировка
От Jan Wieck
Тема Re: functions returning records
Дата
Msg-id 200106281240.f5SCeTG21354@jupiter.us.greatbridge.com
обсуждение исходный текст
Ответ на Re: functions returning records  (Jan Wieck <JanWieck@Yahoo.com>)
Ответы Re: functions returning records  (Alex Pilosov <alex@pilosoft.com>)
Список pgsql-hackers
Jan Wieck wrote:
> Alex Pilosov wrote:
> > On Wed, 27 Jun 2001, Jan Wieck wrote:
> >
> > > Alex Pilosov wrote:
> > > > On Thu, 28 Jun 2001, Hannu Krosing wrote:
> > > > >
> > > > > How hard would it be to turn this around and implement RETURN AND
> > > > > CONTINUE
> > > > > for at least PL/PGSQL, and possibly C/Perl/Python ... ?
> > > > Cannot talk about plpgsql, but for c this would be probably implemented
> > > > with setjmp and with perl with goto. Probably not very complex.
> > >
> > >     Don't  think  so.  When  the function returns, the call stack
> > >     get's destroyed. Jumping back to there - er - the  core  dump
> > >     is not even useful any more. Or did I miss something?
> >
> > Well, it shouldn't return, but instead save the location and longjmp to
> > SPI_RESUME_jmp location. On a next call, instead of a function call, it
> > should longjmp back to saved location. I have to admit its more complex
> > than I originally thought, but probably doable.
>
>     OK, let's screw it up some more:
>
>         SELECT F.a, B.b FROM foo() F, bar() B
>             WHERE F.a = B.a;
>
>     This should normally result in a merge join, so you might get
>     away with longjmp's. But you get the idea.
   On  a  third  thought, you don't get anywhere with longjmp's.   You have a  call  stack,  do  a  setjmp()  saving
the stack   pointer. Then you call the function, do another setjmp() here   and do the longjmp() to #1. This  restores
the saved  stack   pointer,  so at the very first time you do any other function   call (lib calls included), you
corruptthe stack frame at the   current  stack  pointer  position.  If you later jump back to   setjmp() #2 location,
you'llnot be able to return.
 
   You can only drop stack frames safely,  you  can't  add  them   back, they aren't saved.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Barry Lind
Дата:
Сообщение: Re: Instrumenting and Logging in JDBC
Следующее
От: fche@redhat.com (Frank Ch. Eigler)
Дата:
Сообщение: Re: functions returning records