MySQL ROLES_GRAPHML() Function

The MySQL ROLES_GRAPHML() function returns a string representing the GraphML document of the memory role subgraphs.

ROLES_GRAPHML() Syntax

Here is the syntax of the MySQL ROLES_GRAPHML() function:

ROLES_GRAPHML()

Parameters

The MySQL ROLES_GRAPHML() function does not require any parameters.

Return value

The ROLES_GRAPHML() function returns a utf8 string containing the GraphML document representing the memory role subgraphs.

The ROLES_GRAPHML() function requires ROLE_ADMIN permission, otherwise it just returns an empty <graphml> element.

ROLES_GRAPHML() Examples

First, log in to the MySQL server as the root user, and then run the following statement:

SELECT ROLES_GRAPHML();
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <key id="key0" for="edge" attr.name="color" attr.type="int" />
  <key id="key1" for="node" attr.name="name" attr.type="string" />
  <graph id="G" edgedefault="directed" parse.nodeids="canonical" parse.edgeids="canonical" parse.order="nodesfirst">
    <node id="n0">
      <data key="key1">`mysql.infoschema`@`localhost`</data>
    </node>
    <node id="n1">
      <data key="key1">`mysql.session`@`localhost`</data>
    </node>
    <node id="n2">
      <data key="key1">`mysql.sys`@`localhost`</data>
    </node>
    <node id="n3">
      <data key="key1">`root`@`localhost`</data>
    </node>
    <node id="n4">
      <data key="key1">`root`@`%`</data>
    </node>
    <node id="n5">
      <data key="key1">`testuser`@`%`</data>
    </node>
    <node id="n6">
      <data key="key1">`test_role1`@`%`</data>
    </node>
    <node id="n7">
      <data key="key1">`test_role2`@`%`</data>
    </node>
    <edge id="e0" source="n5" target="n6">
      <data key="key0">0</data>
    </edge>
    <edge id="e1" source="n5" target="n7">
      <data key="key0">0</data>
    </edge>
  </graph>
</graphml>

Here, for the sake of clarity, we only list the contents of the output xml document. Note that your values ​​may be different.

Then, log in to the MySQL server using the user testuser created in the CURRENT_ROLE() function section, and run the following statement:

SELECT ROLES_GRAPHML();
+---------------------------------------------------+
| ROLES_GRAPHML()                                   |
+---------------------------------------------------+
| <?xml version="1.0" encoding="UTF-8"?><graphml /> |
+---------------------------------------------------+

Here, the ROLES_GRAPHML() function outputs an empty element <graphml /> because the user testuser does not have ROLE_ADMIN permissions.