WL#14242: TABLE ACCESS SERVICE

Affects: Server-8.0   —   Status: Complete

Summary:
========

Provide a service to access a given table.

This is helpful for components that needs to access configuration data
stored in SQL tables.

Details:
========

Provide, as a service, the following functionality:

Database session:
- create / destroy a session
- commit or rollback changes done in a session

For a session:
- adding all the tables involved
- open and lock tables
- perform table DML
- commit or rollback the session

For table DML:
- Full table scan, similar to a rnd_init / rnd_next / rnd_end loop.
- Full index scan, similar to an index_init / index_first / index_next / index_end loop
- Index fetch, similar to an index_init / inded_read_map / index_next_same / index_end loop
- Insert row
- Update row
- Delete row

Restrictions:
=============

Only base tables can be accessed (i.e., no views).

There are no privilege checks (i.e., no authorization).
This task provides an API set (services) to be used from other components.
There is no change visible externally in the server behavior.

Requirements listed here concerns the API capabilities of the service exposed.

Functional requirements:
========================

F-1 Transactions

The services exposed allows the caller to perform a database transaction,
that may contain multiple tables.

F-2 Metadata locks

The services exposed allows the caller to explicitly lock the tables
used in the transaction in either READ or WRITE mode.

F-3 Full table scan

The services exposed allows the caller to perform a table scan.
The caller controls how many records to read, and can interrupt the scan.

F-4 Full index scan

The services exposed allows the caller to perform an index scan.
The caller controls how many records to read, and can interrupt the scan.

F-5 Index fetch

The services exposed allows the caller to perform an index fetch.
The fetch can be done using a full key, or a partial key prefix in case of multi-parts indexes.
The caller controls how many records to read, and can interrupt the scan.

F-6 INSERT

The services exposed allows the caller to add a new row in a table.

F-7 UPDATE

The services exposed allows the caller to update an existing row in a table.

F-8 DELETE

The services exposed allows the caller to delete an existing row in a table.

F-9 Data types

The following columns data types are supported by a dedicated service,
manipulating values with the proper type (i.e, int for an integer)

F-9.1 INTEGER columns are supported

F-9.2 VARCHAR columns are supported

All other data types are supported by a generic service,
where values are read and written as strings.

F-9.3 Other columns are supported as 'ANY'

Full details available in:
- file include/mysql/components/services/table_access_service.h
- file include/mysql/components/services/bits/table_access_bits.h
- file include/mysql/components/services/mysql_string.h

"Table access" consist of several related services,
that together can be used to perform DML on tables from a component.

Individual services are:

BEGIN_SERVICE_DEFINITION(table_access_factory_v1)
create_table_access_v1_t create;
destroy_table_access_v1_t destroy;
END_SERVICE_DEFINITION(table_access_factory_v1)

BEGIN_SERVICE_DEFINITION(table_access_v1)
add_table_v1_t add;
begin_v1_t begin;
commit_v1_t commit;
rollback_v1_t rollback;
get_table_v1_t get;
check_table_fields_v1_t check;
END_SERVICE_DEFINITION(table_access_v1)

BEGIN_SERVICE_DEFINITION(table_access_index_v1)
index_init_v1_t init;
index_read_map_v1_t read_map;
index_first_v1_t first;
index_next_v1_t next;
index_next_same_v1_t next_same;
index_end_v1_t end;
END_SERVICE_DEFINITION(table_access_index_v1)

BEGIN_SERVICE_DEFINITION(table_access_scan_v1)
rnd_init_v1_t init;
rnd_next_v1_t next;
rnd_end_v1_t end;
END_SERVICE_DEFINITION(table_access_scan_v1)

BEGIN_SERVICE_DEFINITION(table_access_update_v1)
write_row_v1_t insert;
update_row_v1_t update;
delete_row_v1_t delete_row;
END_SERVICE_DEFINITION(table_access_update_v1)

BEGIN_SERVICE_DEFINITION(field_access_nullability_v1)
set_field_null_v1_t set;
is_field_null_v1_t get;
END_SERVICE_DEFINITION(field_access_nullability_v1)

BEGIN_SERVICE_DEFINITION(field_integer_access_v1)
set_field_integer_value_v1_t set;
get_field_integer_value_v1_t get;
END_SERVICE_DEFINITION(field_integer_access_v1)

BEGIN_SERVICE_DEFINITION(field_varchar_access_v1)
set_field_varchar_value_v1_t set;
get_field_varchar_value_v1_t get;
END_SERVICE_DEFINITION(field_varchar_access_v1)

BEGIN_SERVICE_DEFINITION(field_any_access_v1)
set_field_any_value_v1_t set;
get_field_any_value_v1_t get;
END_SERVICE_DEFINITION(field_any_access_v1)

In addition, new services for mysql_h_string are provided:

BEGIN_SERVICE_DEFINITION(mysql_charset_v1)
get_charset_utf8mb4_v1_t get_utf8mb4;
END_SERVICE_DEFINITION(mysql_charset_v1)

BEGIN_SERVICE_DEFINITION(mysql_string_converter_v2)
convert_from_buffer_v2_t convert_from_buffer;
convert_to_buffer_v2_t convert_to_buffer;
END_SERVICE_DEFINITION(mysql_string_converter_v2)

BEGIN_SERVICE_DEFINITION(mysql_string_reset_v1)
mysql_string_reset_v1_t reset;
END_SERVICE_DEFINITION(mysql_string_reset_v1)

BEGIN_SERVICE_DEFINITION(mysql_string_append_v1)
mysql_string_append_v1_t append;
END_SERVICE_DEFINITION(mysql_string_append_v1)

BEGIN_SERVICE_DEFINITION(mysql_string_compare_v1)
mysql_string_compare_v1_t compare;
END_SERVICE_DEFINITION(mysql_string_compare_v1)

BEGIN_SERVICE_DEFINITION(mysql_string_get_data_v1)
mysql_string_get_data_v1_t get_data;
END_SERVICE_DEFINITION(mysql_string_get_data_v1)