Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-10142 PL/SQL parser
  3. MDEV-14139

Anchored data types for variables

    XMLWordPrintable

Details

    • 10.2.2-3, 10.2.2-1, 10.2.2-2, 10.2.2-4, 10.1.18

    Description

      Previously we added anchored data type declarations for table columns, tables, cursors:

      DECLARE a TYPE OF t1.a;   -- table column
      DECLARE b ROW TYPE OF t1; -- table row
      DECLARE c ROW TYPE OF c1; -- cursor row
      

      Under terms of this tasks we'll add anchor references to other variables:

      DECLARE var1 INT;
      DECLARE var2 TYPE OF var1;
      

      The following features will be supported:

      • Nested anchor declarations (anchors to anchors)
      • Anchors to implicit ROW variables
      • Anchors to table and cursor ROW variables
      • Only local SP variables will be supported (SP parameters and SP return values are out of scope of this task)
      • Both TYPE OF (for sql_mode=default) and %TYPE (for sql_mode=ORACLE) will be supported

      Example: Scalar declarations

      DECLARE var1 INT;
      DECLARE var2 TYPE OF var1;
      DECLARE var3 TYPE OF var2;
      

      Example: Scalar declarations for sql_mode=ORACLE

      DECLARE
        var1 INT;
        var2 var1%TYPE;
        var3 var2%TYPE;
      

      Example: Implicit ROW variables

      DECLARE row1 ROW (a INT, b TEXT);
      DECLARE row2 TYPE OF row1;
      

      Example: Implicit ROW variables for sql_mode=ORACLE

      DECLARE
        row1 ROW (a INT, b TEXT);
        row2 row1%TYPE;
      

      Example: Table ROW variables

      DECLARE row1 ROW TYPE OF table1;
      DECLARE row2 TYPE OF row1;
      

      Example: Table ROW variables for sql_mode=ORACLE

      DECLARE
        row1 ROW TYPE OF table1;
        row2 row1%TYPE;
      

      Example: Cursor ROW variables

      DECLARE CURSOR cur1 AS SELECT 10 AS a, 'b' AS b;
      DECLARE row1 ROW TYPE OF cur1;
      DECLARE row2 TYPE OF row1;
      

      Example: Cursor ROW variables for sql_mode=ORACLE

      DECLARE
        CURSOR cur1 AS SELECT 10 AS a, 'b' AS b;
        row1 cur1%ROWTYPE;
        row2 row1%TYPE;
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.