mariadb/sql/sp_rcontext.h
unknown 76b037dc42 Made stored FUNCTION invokation work almost always. Still buggy and unstable, and
various known problems, but good enough for a checkpoint commit.


mysql-test/r/sp.result:
  New tests for invoking simple FUNCTIONs.
mysql-test/t/sp.test:
  New tests for invoking simple FUNCTIONs.
sql/item_func.cc:
  New Item_func_sp for stored FUNCTIONs.
sql/item_func.h:
  New Item_func_sp for stored FUNCTIONs.
sql/sp.cc:
  Close mysql.proc table earlier so recursive find_function calls work.
  Added temporary sp_function_exists() function for checking without parsing.
sql/sp.h:
  Added temporary sp_function_exists() function for checking without parsing.
sql/sp_head.cc:
  New code for executing a FUNCTION. (And reworked some of the old code in the process.)
sql/sp_head.h:
  New code for executing a FUNCTION.
sql/sp_rcontext.h:
  Added result slot for FUNCTIONs.
sql/sql_lex.cc:
  Added check for stored FUNCTION, analogous to UDFs.
sql/sql_parse.cc:
  sp_head::execute was renamed into execute_procedure.
sql/sql_yacc.yy:
  Added parsing of stored FUNCTION invocation and code generation for RETURN statement.
2003-02-26 19:22:29 +01:00

95 lines
1.9 KiB
C++

/* -*- C++ -*- */
/* Copyright (C) 2002 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef _SP_RCONTEXT_H_
#define _SP_RCONTEXT_H_
class sp_rcontext : public Sql_alloc
{
sp_rcontext(const sp_rcontext &); /* Prevent use of these */
void operator=(sp_rcontext &);
public:
sp_rcontext(uint size)
: m_count(0), m_size(size), m_result(NULL)
{
m_frame = (Item **)sql_alloc(size * sizeof(Item*));
m_outs = (int *)sql_alloc(size * sizeof(int));
}
~sp_rcontext()
{
// Not needed?
//sql_element_free(m_frame);
}
inline void
push_item(Item *i)
{
if (m_count < m_size)
m_frame[m_count++] = i;
}
inline void
set_item(uint idx, Item *i)
{
if (idx < m_count)
m_frame[idx] = i;
}
inline Item *
get_item(uint idx)
{
return m_frame[idx];
}
inline void
set_oindex(uint idx, int oidx)
{
m_outs[idx] = oidx;
}
inline int
get_oindex(uint idx)
{
return m_outs[idx];
}
inline void
set_result(Item *it)
{
m_result= it;
}
inline Item *
get_result()
{
return m_result;
}
private:
uint m_count;
uint m_size;
Item **m_frame;
int *m_outs;
Item *m_result; // For FUNCTIONs
}; // class sp_rcontext : public Sql_alloc
#endif /* _SP_RCONTEXT_H_ */