Write the parallelizable UDR

To write a parallelizable C UDR, you must ensure that the UDR does not include any calls to the non-PDQ-threadsafe DataBlade API functions.

The following table lists non-PDQ-threadsafe DataBlade API functions.

Table 1. Non-PDQ-threadsafe DataBlade API functions
Category of non-PDQ-threadsafe function DataBlade API function
Statement processing:
  Statement execution

A parallelizable UDR cannot parse an SQL statement.

mi_exec(), mi_prepare()
Current-statement processing

No current statement exists in a parallelizable UDR. Therefore, these functions are not useful.

mi_binary_query(), mi_command_is_finished(), mi_get_result(), mi_get_row_desc_without_row(), mi_next_row(), mi_query_finish(), mi_query_interrupt(), mi_result_command_name(), mi_result_row_count(), mi_value(), mi_value_by_name()
Prepared statements

No prepared statement exists because you cannot prepare one in a parallelizable UDR. Therefore, these functions are not useful.

mi_close_statement(), mi_drop_prepared_statement(), mi_exec_prepared_statement(), mi_fetch_statement(), mi_get_statement_row_desc(), mi_open_prepared_statement(), mi_statement_command_name()

All input-parameter accessor functions: mi_parameter_* (see Table 1)

Transfer of data

Even though these type-transfer functions are PDQ-threadsafe, they are usually called within the send and receive support functions of an opaque type and are likely to be called during statement processing.

All type-transfer functions: mi_get_*, mi_put_* (see Conversion of opaque-type data with computer-specific data types)
Other mi_current_command_name()
Save-set handling All save-set functions: mi_save_set_* (see Table 1)
Complex-type (collections and row types) handling:
  Collection processing All collection functions: mi_collection_* (see Collections)
Row-type processing mi_get_row_desc(), mi_get_row_desc_from_type_desc(), mi_get_row_desc_without_row(), mi_get_statement_row_desc()

mi_row_create(), mi_row_free(), mi_row_desc_create(), mi_row_desc_free()

Complex-type processing Type-descriptor accessor functions if they access a complex type: mi_type_* (see Table 1)

Column functions if they access a complex type: mi_column_* (see Table 1)

Operating-system file access All file-access functions: mi_file_* (see Table 1)
Tracing:
  Even though the files listed here are not PDQ-threadsafe, you can include most statements that generate trace output in a parallelizable UDR. mi_tracefile_set(), mi_tracelevel_set() GL_DPRINTF
Miscellaneous mi_get_connection_option(), mi_get_database_info(), mi_get_session_connection(), mi_get_type_source_type()

A parallelizable C UDR cannot call (either explicitly or implicitly) any of the DataBlade API functions in Table 1. If you attempt to run a UDR that contains a non-PDQ-threadsafe function in parallel, the database server generates an error. If your UDR must call one of the functions in Table 1, it cannot be parallelizable.

Keep in mind the following considerations when you write a UDR to be parallelizable:
  • For a UDR that operates on an opaque type to be parallelizable, all support functions of the opaque type must be parallelizable.
  • A UDR that operates on complex data types cannot be parallelizable.
  • A UDR can be parallelizable whether it runs in the CPU VP or a user-defined VP.
  • A UDR that acts as a functional index cannot be parallelizable.
  • A UDR that is parallelizable cannot call a UDR that is not parallelizable (either explicitly or with the Fastpath interface).

Copyright© 2019 HCL Technologies Limited