All pages
Powered by GitBook
1 of 5

Loading...

Loading...

Loading...

Loading...

Loading...

Spider Functions

Explore Spider functions in MariaDB Server. Learn about the specialized functions that enhance data access and manipulation across sharded and distributed databases using the Spider storage engine.

SPIDER_COPY_TABLES

Learn how to use this function to copy table data from one Spider link ID to another, useful for migrating data or rebalancing shards without stopping the service.

Syntax

SPIDER_COPY_TABLES(spider_table_name, 
  source_link_id, destination_link_id_list [,parameters])

Description

A UDF installed with the Spider Storage Engine, this function copies table data from source_link_id to destination_link_id_list. The service does not need to be stopped in order to copy.

If the Spider table is partitioned, the name must be of the format table_name#P#partition_name. The partition name can be viewed in the mysql.spider_tables table, for example:

Returns 1 if the data was copied successfully, or 0 if copying the data failed.

This page is licensed: CC BY-SA / Gnu FDL

SPIDER_BG_DIRECT_SQL

This UDF allows you to execute SQL statements on remote data nodes in the background, enabling concurrent processing and non-blocking operations.

Syntax

Description

Executes the given SQL statement in the background on the remote server, as defined in the parameters listing. If the query returns a result-set, it sttores the results in the given temporary table. When the given SQL statement executes successfully, this function returns the number of called UDF's. It returns 0 when the given SQL statement fails.

This function is a installed with the storage engine.

Examples

Parameters

error_rw_mode

  • Description: Returns empty results on network error.

    • 0 : Return error on getting network error.

    • 1: Return 0 records on getting network error.

See also

This page is licensed: CC BY-SA / Gnu FDL

SPIDER_FLUSH_TABLE_MON_CACHE

Use this UDF to refresh the cache used by Spider's monitoring threads, ensuring that the status of remote tables and connections is up to date.

Syntax

SPIDER_FLUSH_TABLE_MON_CACHE()

Description

A UDF installed with the Spider Storage Engine, this function is used for refreshing monitoring server information. It returns a value of 1.

Examples

This page is licensed: CC BY-SA / Gnu FDL

SPIDER_BG_DIRECT_SQL('sql', 'tmp_table_list', 'parameters')
Default Table Value: 0
  • DSN Parameter Name: erwm

  • UDF
    Spider
    SPIDER_DIRECT_SQL
    SELECT table_name FROM mysql.spider_tables;
    +-------------+
    | table_name  |
    +-------------+
    | spt_a#P#pt1 |
    | spt_a#P#pt2 |
    | spt_a#P#pt3 |
    +-------------+
    SELECT SPIDER_FLUSH_TABLE_MON_CACHE();
    +--------------------------------+
    | SPIDER_FLUSH_TABLE_MON_CACHE() |
    +--------------------------------+
    |                              1 |
    +--------------------------------+

    SPIDER_DIRECT_SQL

    This function executes an SQL string directly on a specified remote backend server, allowing for maintenance tasks or queries that bypass local parsing.

    Syntax

    SPIDER_DIRECT_SQL('sql', 'tmp_table_list', 'parameters')

    Description

    A UDF installed with the Spider Storage Engine, this function is used to execute the SQL string sql on the remote server, as defined in parameters. If any resultsets are returned, they are stored in the tmp_table_list.

    The function returns 1 if the SQL executes successfully, or 0 if it fails.

    Examples

    See also

    This page is licensed: CC BY-SA / Gnu FDL

    SELECT SPIDER_BG_DIRECT_SQL('SELECT * FROM example_table',  '', 
       'srv "node1", port "8607"') AS "Direct Query";
    +--------------+
    | Direct Query | 
    +--------------+
    |            1 |
    +--------------+
    SPIDER_BG_DIRECT_SQL
    SELECT SPIDER_DIRECT_SQL('SELECT * FROM s', '', 'srv "node1", port "8607"');
    +----------------------------------------------------------------------+
    | SPIDER_DIRECT_SQL('SELECT * FROM s', '', 'srv "node1", port "8607"') |
    +----------------------------------------------------------------------+
    |                                                                    1 |
    +----------------------------------------------------------------------+