Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-31431

support sql standard <explicit table> expressions

Details

    Attachments

      Issue Links

        Activity

          Johnston Rex Johnston added a comment - - edited

          Relevant excerpts from an SQL standard

          <simple table> ::= <query specification> | <table value constructor> | <explicit table>
          <explicit table> ::= TABLE <table or query name>

          5) The <explicit table>

          TABLE <table or query name>
          is equivalent to the <query specification>
          SELECT * FROM <table or query name>

          12) A <query expression> QE1 is insertable-into if it does not specify a <result offset clause> or a <fetch first clause> and the <query expression body> of QE1 is a <query primary> that is one of the following:

          b) An <explicit table> that identifies a table that is insertable-into.

          Without Feature F661, “Simple tables”, conforming SQL language shall not contain an <explicit table>.

          d) If VC i is an <explicit table>, then let T be the table identified by the <explicit table>.

          i) If the applicable privileges for A include DELETE on T, then a view component table privilege
          descriptor is created whose identified object is VC i , action is DELETE, grantor is the special
          grantor value “_SYSTEM”, and the grantee is A. The privilege is grantable if and only if the
          applicable privileges for A includes grantable DELETE privilege on T. The privilege descriptor
          is immediately dependent on the privilege descriptor whose identified object is T, action is
          DELETE, and grantee is A.

          ii) For each updatable column C of VC i , let CC be the counterpart to C in T. If the applicable
          privileges for A include UPDATE(CC) on T, then a view component column privilege
          descriptor VCCPD is created, as follows: the identified object is C, the action is UPDATE, the
          grantor is the special grantor value “_SYSTEM”, and the grantee is A. The privilege is grantable
          if and only if the applicable privilege for A includes grantable UPDATE(CC) privilege on T.
          The privilege descriptor is immediately dependent on the privilege descriptor whose identified
          object is CC, action is UPDATE, and grantee is A.

          iii) For each updatable column C of VC i , let CC be the counterpart to C in T. If the applicable
          privileges for A include INSERT(CC) on T, then a view component column privilege descriptor
          VCCPD is created, as follows: the identified object is C, the action is INSERT, the grantor is
          the special grantor value “_SYSTEM”, and the grantee is A. The privilege is grantable if and
          only if the applicable privilege for A includes grantable INSERT(CC) privilege on T. The
          privilege descriptor is immediately dependent on the privilege descriptor whose identified
          object is CC, action is INSERT, and grantee is A.

          Johnston Rex Johnston added a comment - - edited Relevant excerpts from an SQL standard <simple table> ::= <query specification> | <table value constructor> | <explicit table> <explicit table> ::= TABLE <table or query name> 5) The <explicit table> TABLE <table or query name> is equivalent to the <query specification> SELECT * FROM <table or query name> 12) A <query expression> QE1 is insertable-into if it does not specify a <result offset clause> or a <fetch first clause> and the <query expression body> of QE1 is a <query primary> that is one of the following: b) An <explicit table> that identifies a table that is insertable-into. Without Feature F661, “Simple tables”, conforming SQL language shall not contain an <explicit table>. d) If VC i is an <explicit table>, then let T be the table identified by the <explicit table>. i) If the applicable privileges for A include DELETE on T, then a view component table privilege descriptor is created whose identified object is VC i , action is DELETE, grantor is the special grantor value “_SYSTEM”, and the grantee is A. The privilege is grantable if and only if the applicable privileges for A includes grantable DELETE privilege on T. The privilege descriptor is immediately dependent on the privilege descriptor whose identified object is T, action is DELETE, and grantee is A. ii) For each updatable column C of VC i , let CC be the counterpart to C in T. If the applicable privileges for A include UPDATE(CC) on T, then a view component column privilege descriptor VCCPD is created, as follows: the identified object is C, the action is UPDATE, the grantor is the special grantor value “_SYSTEM”, and the grantee is A. The privilege is grantable if and only if the applicable privilege for A includes grantable UPDATE(CC) privilege on T. The privilege descriptor is immediately dependent on the privilege descriptor whose identified object is CC, action is UPDATE, and grantee is A. iii) For each updatable column C of VC i , let CC be the counterpart to C in T. If the applicable privileges for A include INSERT(CC) on T, then a view component column privilege descriptor VCCPD is created, as follows: the identified object is C, the action is INSERT, the grantor is the special grantor value “_SYSTEM”, and the grantee is A. The privilege is grantable if and only if the applicable privilege for A includes grantable INSERT(CC) privilege on T. The privilege descriptor is immediately dependent on the privilege descriptor whose identified object is CC, action is INSERT, and grantee is A.
          Johnston Rex Johnston added a comment -

          The "Explicit Table" DML command appears to have been been added in the SQL 2011 standard (please correct me if it was earlier).

          Databases that support this command include Postgres (since 8.4), MySQL (since 8.0.19) and Oracle (11gR2, though it isn't documented).

          As part of the SQL standard, it makes sense for us to implement this, as

          1) Being able to claim more SQL feature compliance is great for marketing (Feature F661, Tick)
          2) Minimize the amount of SQL that needs rewriting when porting to MariaDB from aforementioned databases.
          3) it can potentially minimize query length, speed parsing and increase clarity.

          Johnston Rex Johnston added a comment - The "Explicit Table" DML command appears to have been been added in the SQL 2011 standard (please correct me if it was earlier). Databases that support this command include Postgres (since 8.4), MySQL (since 8.0.19) and Oracle (11gR2, though it isn't documented). As part of the SQL standard, it makes sense for us to implement this, as 1) Being able to claim more SQL feature compliance is great for marketing (Feature F661, Tick) 2) Minimize the amount of SQL that needs rewriting when porting to MariaDB from aforementioned databases. 3) it can potentially minimize query length, speed parsing and increase clarity.
          greenman Ian Gilfillan added a comment -

          Happy to see better SQL standard support. I've added the sql2016 label - there's an sql2023 label for recent enhancements, and an sql2016 label which I've been using for anything in the SQL 2016 standard (regardless of when it was added).

          With 11.0 already stable, isn't this better suited to go into a later version?

          greenman Ian Gilfillan added a comment - Happy to see better SQL standard support. I've added the sql2016 label - there's an sql2023 label for recent enhancements, and an sql2016 label which I've been using for anything in the SQL 2016 standard (regardless of when it was added). With 11.0 already stable, isn't this better suited to go into a later version?
          Johnston Rex Johnston added a comment -

          Yes indeed, I'm currently working on something for 11.2, i'll close the 11.0 PR.

          Johnston Rex Johnston added a comment - Yes indeed, I'm currently working on something for 11.2, i'll close the 11.0 PR.

          People

            Johnston Rex Johnston
            Johnston Rex Johnston
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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