Defining and Accessing Query Attributes •An application passes extra processing information with each query, for use by a plugin such as an audit plugin or query rewrite plugin. •Defining and Accessing Query Attributes •Prerequisites for Using Query Attributes •Query Attribute Loadable Functions 1920 As shown by the second  SELECT  statement, attributes defined prior to a given statement are available only to that statement and are cleared after the statement executes. To use an attribute value across This example defines two attributes named  n1  and  n2 . The first  SELECT  shows how to retrieve those attributes, and also demonstrates that retrieving a nonexistent attribute ( n3 ) returns  NULL . The second SELECT  shows that attributes do not persist across statements. The following examples use the  mysql  client  query_attributes  command to define attribute name/ value pairs, and the  mysql_query_attribute_string()  function to access attribute values by name. To access query attributes within SQL statements for which attributes have been defined, install the query_attributes  component as described in Prerequisites for Using Query Attributes. The component implements a  mysql_query_attribute_string()  loadable function that takes an attribute name argument and returns the attribute value as a string, or  NULL  if the attribute does not exist. See Query Attribute Loadable Functions. Query attribute names are transmitted using the character set indicated by the  character_set_client system variable. The  mysql  client has a  query_attributes  command that enables defining up to 32 pairs of attribute names and values. See Section 4.5.1.2, “mysql Client Commands” . Applications that use the MySQL C API define query attributes by calling the  mysql_bind_param() function. See mysql_bind_param(). Other MySQL connectors may also provide query-attribute support. See the documentation for individual connectors. Defining and Accessing Query Attributes MySQL supports these capabilities without the use of workarounds such as specially formatted comments included in query strings. The remainder of this section describes how to use query attribute support, including the prerequisites that must be satisfied. mysql>  query_attributes n1 v1 n2 v2; mysql>  SELECT mysql_query_attribute_string(’n1’) AS ’attr 1’, mysql_query_attribute_string(’n2’) AS ’attr 2’, mysql_query_attribute_string(’n3’) AS ’attr 3’; +--------+--------+--------+ | attr 1 | attr 2 | attr 3 | +--------+--------+--------+ | v1 | v2 | NULL | +--------+--------+--------+ mysql>  SELECT mysql_query_attribute_string(’n1’) AS ’attr 1’, mysql_query_attribute_string(’n2’) AS ’attr 2’; +--------+--------+ | attr 1 | attr 2 | +--------+--------+ | NULL | NULL | +--------+--------+