PL/SQL parser (MDEV-10142)

[MDEV-13415] Wrap the code in sp.cc into a class Sp_handler Created: 2017-07-31  Updated: 2018-08-31  Resolved: 2017-07-31

Status: Closed
Project: MariaDB Server
Component/s: Stored routines
Affects Version/s: 10.3
Fix Version/s: 10.3.1

Type: Technical task Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: refactoring

Issue Links:
Blocks
blocks MDEV-10591 Oracle-style packages Closed
Sprint: 10.2.2-3, 10.2.2-1, 10.2.2-2, 10.2.2-4, 10.1.18

 Description   

The code in sp.sp, sp_head.cc, sql_acl.cc, sql_lex.cc, sql_show.cc, sql_yacc*.yy uses a lot of conditions on the routine type, e.g.

  if (type == TYPE_ENUM_FUNCTION)
    do_func;
  else
    do_proc;

Oracle style packages (MDEV-10591) will introduce new SP object types: TYPE_ENUM_PACKAGE_SPEC and TYPE_ENUM_PACKAGE_BODY.
The conditional type-related code will get more complex.

Under terms of this code we'll create a new class Sp_handler with a number of virtual methods, to simplify handling of SP objects of different types and therefore simplify adding packages.

We'll add the be the top level abstract class Sp_handler with this approximate set of virtual methods:

class Sp_handler
{
public:
  virtual const char *show_create_routine_col1_caption() const;
  virtual const char *show_create_routine_col3_caption() const;
  virtual stored_procedure_type type() const;
  virtual LEX_CSTRING type_lex_cstring() const;
  virtual LEX_CSTRING empty_body_lex_cstring() const;
  virtual MDL_key::enum_mdl_namespace get_mdl_type() const;
  virtual sp_cache **get_cache(THD *) const;  
  virtual HASH *priv_hash() const;
  virtual ulong recursion_depth(THD *thd) const;
  virtual void recursion_level_error(THD *thd, const sp_head *sp) const;
};

and will add instantiable sub-classes for certain SP object types:

Sp_handler
  Sp_handler_procedure
  Sp_handler_trigger
  Sp_handler_function

MDEV-10591 will later add Sp_handler_package_spec and Sp_handler_package_body sub-classes.


Generated at Thu Feb 08 08:05:25 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.