NdbInterpretedCode ConstructorNdbInterpretedCode::add_reg()NdbInterpretedCode::add_val()NdbInterpretedCode::branch_col_and_mask_eq_mask()NdbInterpretedCode::branch_col_and_mask_eq_zero()NdbInterpretedCode::branch_col_and_mask_ne_mask()NdbInterpretedCode::branch_col_and_mask_ne_zero()NdbInterpretedCode::branch_col_eq()NdbInterpretedCode::branch_col_eq_null()NdbInterpretedCode::branch_col_ge()NdbInterpretedCode::branch_col_gt()NdbInterpretedCode::branch_col_le()NdbInterpretedCode::branch_col_like()NdbInterpretedCode::branch_col_lt()NdbInterpretedCode::branch_col_ne()NdbInterpretedCode::branch_col_ne_null()NdbInterpretedCode::branch_col_notlike()NdbInterpretedCode::branch_eq()NdbInterpretedCode::branch_eq_null()NdbInterpretedCode::branch_ge()NdbInterpretedCode::branch_gt()NdbInterpretedCode::branch_label()NdbInterpretedCode::branch_le()NdbInterpretedCode::branch_lt()NdbInterpretedCode::branch_ne()NdbInterpretedCode::branch_ne_null()NdbInterpretedCode::call_sub()NdbInterpretedCode::copy()NdbInterpretedCode::def_label()NdbInterpretedCode::def_sub()NdbInterpretedCode::finalise()NdbInterpretedCode::getNdbError()NdbInterpretedCode::getTable()NdbInterpretedCode::getWordsUsed()NdbInterpretedCode::interpret_exit_last_row()NdbInterpretedCode::interpret_exit_nok()NdbInterpretedCode::interpret_exit_ok()NdbInterpretedCode::load_const_null()NdbInterpretedCode::load_const_u16()NdbInterpretedCode::load_const_u32()NdbInterpretedCode::load_const_u64()NdbInterpretedCode::read_attr()NdbInterpretedCode::ret_sub()NdbInterpretedCode::sub_reg()NdbInterpretedCode::sub_val()NdbInterpretedCode::write_attr()
This section provides information about the public methods of the
NdbInterpretedCode class, grouped
together by function.
Description.
This is the
NdbInterpretedCode class
constuctor.
Signature.
NdbInterpretedCode
(
const NdbDictionary::Table* table = 0,
Uint32* buffer = 0,
Uint32 buffer_word_size = 0
)
Parameters.
The NdbInterpretedCode
constructor takes three parameters, as described here:
The table against which which
this program is to be be run. This parameter must be
supplied if the program is table-specific—that is, if
it reads from or writes to columns in a table.
A pointer to a buffer of 32-bit
words used to store the program.
buffer_word_size is the length of
the buffer passed in. If the program exceeds this length
then adding new instructions will fail with error
4518 Too many instructions
in interpreted program.
Alternatively, if no buffer is passed, a buffer will be dynamically allocated internally and extended to cope as instructions are added.
Return value.
An instance of
NdbInterpretedCode.
Description. This method sums the values stored in any two given registers and stores the result in a third register.
Signature.
int add_reg
(
Uint32 RegDest,
Uint32 RegSource1,
Uint32 RegSource2
)
Parameters.
This method takes three parameters. The first of these is the
register in which the result is to be stored
(RegDest). The second and third
parameters (RegSource1 and
RegSource2) are the registers whose
values are to be summed.
It is possible to re-use for storing the result one of the
registers whose values are summed; that is,
RegDest can be the same as
RegSource1 or
RegSource2.
Return value.
Returns 0 on success, -1
on failure.
Description.
This method adds a specified value to the value of a given
table column, and places the original and modified column
values in registers 6 and 7. It is equivalent to the following
series of NdbInterpretedCode
method calls, where attrId is the
table column' attribute ID and
aValue is the value to be added:
read_attr(6,attrId); load_const_u32(7,aValue); add_reg(7,6,7); write_attr(attrId, 7);
aValue can be a 32-bit or 64-bit
integer.
Signature.
This method can be invoked in either of two ways, depending on
whether aValue is 32-bit or 64-bit.
32-bit aValue:
int add_val
(
Uint32 attrId,
Uint32 aValue
)
64-bit aValue:
int add_val
(
Uint32 attrId,
Uint64 aValue
)
Parameters. A table column attribute ID and a 32-bit or 64-bit integer value to be added to this column value.
Return value.
Returns 0 on success, -1
on failure.
Description.
This method is used to compare a BIT column
value with a bitmask; if the column value
ANDed together with the bitmask is equal to
the bitmask, then execution jumps to a specified label
specified in the method call.
Signature.
int branch_col_and_mask_eq_mask
(
const void* mask,
Uint32 unused,
Uint32 attrId,
Uint32 Label
)
Parameters. This method can accept four parameters, of which three are actually used. These are described in the following list:
A pointer to a constant mask to
compare the column value to
A Uint32 value which is currently
unused.
The attrId of the column to be
compared.
A program Label to jump to if the
condition is true.
Return value.
This method returns 0 on success and
-1 on failure.
Description.
This method is used to compare a BIT column
value with a bitmask; if the column value
ANDed together with the bitmask is equal to
0, then execution jumps to a specified
label specified in the method call.
Signature.
int branch_col_and_mask_eq_zero
(
const void* mask,
Uint32 unused,
Uint32 attrId,
Uint32 Label
)
Parameters. This method can accept the following four parameters, of which three are actually used:
A pointer to a constant mask to
compare the column value to.
A Uint32 value which is currently
unused.
The attrId of the column to be
compared.
A program Label to jump to if the
condition is true.
Return value.
This method returns 0 on success and
-1 on failure.
Description.
This method is used to compare a BIT column
value with a bitmask; if the column value
ANDed together with the bitmask is not
equal to the bitmask, then execution jumps to a specified
label specified in the method call.
Signature.
int branch_col_and_mask_ne_mask
(
const void* mask,
Uint32 unused,
Uint32 attrId,
Uint32 Label
)
Parameters. This method accepts four parameters, of which three are actually used. These described in the following list:
A pointer to a constant mask to
compare the column value to.
A Uint32 value which is currently
unused.
The attrId of the column to be
compared.
A program Label to jump to if the
condition is true.
Return value.
This method returns 0 on success and
-1 on failure.
Description.
This method is used to compare a BIT column
value with a bitmask; if the column value
ANDed together with the bitmask is not
equal to 0, then execution jumps to a
specified label specified in the method call.
Signature.
int branch_col_and_mask_ne_zero
(
const void* mask,
Uint32 unused,
Uint32 attrId,
Uint32 Label
)
Parameters. This method accepts the following four parameters, of which three are actually used:
A pointer to a constant mask to
compare the column value to.
A Uint32 value which is currently
unused.
The attrId of the column to be
compared.
A program Label to jump to if the
condition is true.
Return value.
This method returns 0 on success and
-1 on failure.
Description. This method compares a table column value with an arbitrary constant and jumps to the specified program label if the values are equal.
Signature.
int branch_col_eq
(
const void* val,
Uint32 len,
Uint32 attrId,
Uint32 Label
)
Parameters. This method takes the following four parameters:
A constant value (val)
The length of the value (in bytes)
The attribute ID of the table column whose value is to be
compared with val
A Label (previously defined using
def_label()) to jump to if the compared
values are equal
Return value.
Returns 0 on success, -1
on failure.
Description.
This method tests the value of a table column and jumps to the
indicated program label if the column value is
NULL.
Signature.
int branch_col_eq_null
(
Uint32 attrId,
Uint32 Label
)
Parameters. This method requires the following two parameters:
The attribute ID of the table column
The program label to jump to if the column value is
NULL
Return value.
Returns 0 on success, -1
on failure.
Description. This method compares a table column value with an arbitrary constant and jumps to the specified program label if the constant is greater than or equal to the column value.
Signature.
int branch_col_ge
(
const void* val,
Uint32 len,
Uint32 attrId,
Uint32 Label
)
Parameters. This method takes the four parameters listed here:
A constant value (val)
The length of the value (in bytes)
The attribute ID of the table column whose value is to be
compared with val
A Label (previously defined using
def_label()) to jump to if the constant
value is greater than or equal to the column value
Return value.
Returns 0 on success, -1
on failure.
Description. This method compares a table column value with an arbitrary constant and jumps to the specified program label if the constant is greater than the column value.
Signature.
int branch_col_gt
(
const void* val,
Uint32 len,
Uint32 attrId,
Uint32 Label
)
Parameters. This method takes the following four parameters:
A constant value (val)
The length of the value (in bytes)
The attribute ID of the table column whose value is to be
compared with val
A Label (previously defined using
def_label()) to jump to if the constant
value is greater than the column value
Return value.
Returns 0 on success, -1
on failure.
Description. This method compares a table column value with an arbitrary constant and jumps to the specified program label if the constant is less than or equal to the column value.
Signature.
int branch_col_le
(
const void* val,
Uint32 len,
Uint32 attrId,
Uint32 Label
)
Parameters. This method takes the four parameters listed here:
A constant value (val)
The length of the value (in bytes)
The attribute ID of the table column whose value is to be
compared with val
A Label (previously defined using
def_label()) to jump to if the constant
value is less than or equal to the column value
Return value.
Returns 0 on success, -1
on failure.
Description. This method tests a table column value against a regular expression pattern and jumps to the indicated program label if they match.
Signature.
int branch_col_like
(
const void* val,
Uint32 len,
Uint32 attrId,
Uint32 Label
)
Parameters. This method takes four parameters, which are listed here:
A regular expression pattern
(val); see
Section 2.3.22.1.7, “Pattern-Based NdbInterpretedCode Branch Operations”,
for the syntax supported
Length of the pattern (in bytes)
The attribute ID for the table column being tested
The program label to jump to if the table column value matches the pattern
Return value.
0 on success, -1 on
failure
Description. This method compares a table column value with an arbitrary constant and jumps to the specified program label if the constant is less than the column value.
Signature.
int branch_col_lt
(
const void* val,
Uint32 len,
Uint32 attrId,
Uint32 Label
)
Parameters. This method takes the following four parameters:
A constant value (val)
The length of the value (in bytes)
The attribute ID of the table column whose value is to be
compared with val
A Label (previously defined using
def_label()) to jump to if the constant
value is less than the column value
Return value.
0 on success, -1 on
failure.
Description. This method compares a table column value with an arbitrary constant and jumps to the specified program label if the two values are not equal.
Signature.
int branch_col_ne
(
const void* val,
Uint32 len,
Uint32 attrId,
Uint32 Label
)
Parameters. This method takes the four parameters listed here:
A constant value (val)
The length of the value (in bytes)
The attribute ID of the table column whose value is to be
compared with val
A Label (previously defined using
def_label()) to jump to if the compared
values are unequal
Return value.
Returns 0 on success, -1
on failure.
Description.
This method tests the value of a table column and jumps to the
indicated program label if the column value is not
NULL.
Signature.
int branch_col_ne_null
(
Uint32 attrId,
Uint32 Label
)
Parameters. This method requires the following two parameters:
The attribute ID of the table column
The program label to jump to if the column value is not
NULL
Return value.
Returns 0 on success, -1
on failure.
Description.
This method is similar to branch_col_like()
in that it tests a table column value against a regular
expression pattern; however it jumps to the indicated program
label only if the pattern and the column value do
not match.
Signature.
int branch_col_notlike
(
const void* val,
Uint32 len,
Uint32 attrId,
Uint32 Label
)
Parameters. This method takes the following four parameters:
A regular expression pattern
(val); see
Section 2.3.22.1.7, “Pattern-Based NdbInterpretedCode Branch Operations”,
for the syntax supported
Length of the pattern (in bytes)
The attribute ID for the table column being tested
The program label to jump to if the table column value does not match the pattern
Return value.
Returns 0 on success, -1
on failure
Description. This method compares two register values; if they equal, then the interpreted program jumps to the specified label.
Signature.
int branch_eq
(
Uint32 RegLvalue,
Uint32 RegRvalue,
Uint32 Label
)
Parameters.
This method takes three parameters, the registers whose values
are to be compared—RegLvalue
and RegRvalue—and the program
Label to jump to if they are equal.
Label must have been defined
previously using def_label() (see
Section 2.3.22.2.29, “NdbInterpretedCode::def_label()”).
Return value.
0 on success, -1 on
failure.
Description.
This method compares a register value with
NULL; if the register value is null, then
the interpreted program jumps to the specified label.
Signature.
int branch_eq_null
(
Uint32 RegLvalue,
Uint32 Label
)
Parameters.
This method takes two parameters, the register whose value is
to be compared with NULL
(RegLvalue) and the program
Label to jump to if
RegLvalue is null.
Label must have been defined
previously using def_label() (see
Section 2.3.22.2.29, “NdbInterpretedCode::def_label()”).
Return value.
0 on success, -1 on
failure.
Description. This method compares two register values; if the first is greater than or equal to the second, the interpreted program jumps to the specified label.
Signature.
int branch_ge
(
Uint32 RegLvalue,
Uint32 RegRvalue,
Uint32 Label
)
Parameters.
This method takes three parameters, the registers whose values
are to be compared—RegLvalue
and RegRvalue—and the program
Label to jump to if
RegLvalue is greater than or equal
to RegRvalue.
Label must have been defined
previously using def_label() (see
Section 2.3.22.2.29, “NdbInterpretedCode::def_label()”).
Return value.
0 on success, -1 on
failure.
Description. This method compares two register values; if the first is greater than the second, the interpreted program jumps to the specified label.
Signature.
int branch_gt
(
Uint32 RegLvalue,
Uint32 RegRvalue,
Uint32 Label
)
Parameters.
This method takes three parameters, the registers whose values
are to be compared—RegLvalue
and RegRvalue—and the program
Label to jump to if
RegLvalue is greater than
RegRvalue.
Label must have been defined
previously using def_label() (see
Section 2.3.22.2.29, “NdbInterpretedCode::def_label()”).
Return value.
0 on success, -1 on
failure.
Description.
This method performs an unconditional jump to an interpreted
program label (see
Section 2.3.22.2.29, “NdbInterpretedCode::def_label()”).
Signature.
int branch_label
(
Uint32 Label
)
Parameters.
This method takes a single parameter, an interpreted program
Label defined using
def_label().
Return value.
0 on success, -1 on
failure.
Description. This method compares two register values; if the first is less than or equal to the second, the interpreted program jumps to the specified label.
Signature.
int branch_le
(
Uint32 RegLvalue,
Uint32 RegRvalue,
Uint32 Label
)
Parameters.
This method takes three parameters, the registers whose values
are to be compared—RegLvalue
and RegRvalue—and the program
Label to jump to if
RegLvalue is less than or equal to
RegRvalue.
Label must have been defined
previously using def_label() (see
Section 2.3.22.2.29, “NdbInterpretedCode::def_label()”).
Return value.
0 on success, -1 on
failure.
Description. This method compares two register values; if the first is less than the second, the interpreted program jumps to the specified label.
Signature.
int branch_lt
(
Uint32 RegLvalue,
Uint32 RegRvalue,
Uint32 Label
)
Parameters.
This method takes three parameters, the registers whose values
are to be compared—RegLvalue
and RegRvalue—and the program
Label to jump to if
RegLvalue is less than
RegRvalue.
Label must have been defined
previously using def_label() (see
Section 2.3.22.2.29, “NdbInterpretedCode::def_label()”).
Return value.
0 on success, -1 on
failure.
Description. This method compares two register values; if they are not equal, then the interpreted program jumps to the specified label.
Signature.
int branch_ne
(
Uint32 RegLvalue,
Uint32 RegRvalue,
Uint32 Label
)
Parameters.
This method takes three parameters, the registers whose values
are to be compared—RegLvalue
and RegRvalue—and the program
Label to jump they are not equal.
Label must have been defined
previously using def_label() (see
Section 2.3.22.2.29, “NdbInterpretedCode::def_label()”).
Return value.
0 on success, -1 on
failure.
Description.
This method compares a register value with
NULL; if the value is not null, then the
interpreted program jumps to the specified label.
Signature.
int branch_ne_null
(
Uint32 RegLvalue,
Uint32 Label
)
Parameters.
This method takes two parameters, the register whose value is
to be compared with NULL
(RegLvalue) and the program
Label to jump to if
RegLvalue is not null.
Label must have been defined
previously using def_label() (see
Section 2.3.22.2.29, “NdbInterpretedCode::def_label()”).
Return value.
0 on success, -1 on
failure.
Description. This method is used to call a subroutine.
Signature.
int call_sub
(
Uint32 SubroutineNumber
)
Parameters. This method takes a single parameter, the number identifying the subroutine to be called.
Return value.
Returns 0 on success, -1
on failure.
Description.
Makes a deep copy of an
NdbInterpretedCode object.
Signature.
int copy
(
const NdbInterpretedCode& src
)
Parameters. A reference to the copy.
Return value. 0 on success, or an error code.
Description. This method defines a label to be used as the target of one or more jumps in an interpreted program.
def_label() uses a 2-word buffer and requires
no space for request messages.
Signature.
int def_label
(
int LabelNum
)
Parameters.
This method takes a single parameter
LabelNum, whose value must be
unique among all values used for labels within the interpreted
program.
Return value.
0 on success; -1 on
failure.
Description.
This method is used to mark the start of a subroutine. See
Section 2.3.22.1.11, “Using Subroutines with NdbInterpretedCode”, for more
information.
Signature.
int def_sub
(
Uint32 SubroutineNumber
)
Parameters. A single parameter, a number used to identify the subroutine.
Return value.
Returns 0 on success, -1
otherwise.
Description.
This method prepares an interpreted program, including any
subroutines it might have, by resolving all branching
instructions and calls to subroutines. It must be called
before using the program, and can be invoked only once for any
given NdbInterpretedCode
object.
If no instructions have been defined, this method attempts to
insert a single
interpret_exit_ok()
method call prior to finalization.
Signature.
int finalise
(
void
)
Parameters. None.
Return value.
Returns 0 on success, -1
otherwise.
Description.
This method returns the most recent error associated with this
NdbInterpretedCode object.
Signature.
const class NdbError& getNdbError
(
void
) const
Parameters. None.
Return value.
A reference to an NdbError
object.
Description.
This method can be used to obtain a reference to the table for
which the NdbInterpretedCode
object was defined.
Signature.
const NdbDictionary::Table* getTable
(
void
) const
Parameters. None.
Return value.
A pointer to a Table object.
Returns NULL if no table object was
supplied when the
NdbInterpretedCode was
instantiated.
Description. This method returns the number of words from the buffer that have been used, whether the buffer is one that is user-supplied or the internally-provided buffer.
Signature.
Uint32 getWordsUsed
(
void
) const
Parameters. None.
Return value. The 32-bit number of words used from the buffer.
Description. For a scanning operation, invoking this method indicates that this row should be returned as part of the scan, and that no more rows in this fragment should be scanned. For other types of operations, the method causes the operation to be aborted.
Signature.
int interpret_exit_last_row
(
void
)
Parameters. None.
Return value.
Returns 0 if successful,
-1 otherwise.
Description. For scanning operations, this method is used to indicate that the current row should not be returned as part of the scan, and to cause the program should move on to the next row. It causes other types of operations to be aborted.
Signature.
int interpret_exit_nok
(
Uint32 ErrorCode = 626 // HA_ERR_KEY_NOT_FOUND
)
Parameters.
This method takes a single (optional) parameter
ErrorCode which . For a complete
listing of NDB error codes, see
Section 7.2.2, “NDB Error Codes and Messages”. If not supplied, defaults
to 626
(HA_ERR_KEY_NOT_FOUND/Tuple
did not exist. Applications should use error code
626 or another code in the range 6000 to 6999 inclusive.
Prior to MySQL Cluster NDB 7.0.38, MySQL Cluster NDB 7.1.27, and
MySQL Cluster NDB 7.2.1, ErrorCode
defaulted to NDB error code 899
(Rowid already allocated). This value is
still supported for backward compatibility. (Bug #16176006) For
any values other than those mentioned here, the behavior of this
method is undefined, and is subject to change at any time
without prior notice.
Return value.
Returns 0 on success, -1
on failure.
Description. For a scanning operation, this method indicates that the current row should be returned as part of the results of the scan and that the program should move on to the next row. For other operations, calling this method causes the interpreted program to exit.
Signature.
int interpret_exit_ok
(
void
)
Parameters. None.
Return value.
Returns 0 on success, -1
on failure.
Description.
This method is used to load a NULL value
into a register.
Signature.
int load_const_null
(
Uint32 RegDest
)
Parameters.
This method takes a single parameter, the register into which
to place the NULL.
Return value.
Returns 0 on success, -1
otherwise.
Description. This method loads a 16-bit value into the specified interpreter register.
Signature.
int load_const_u16
(
Uint32 RegDest,
Uint32 Constant
)
Parameters. This method takes the following two parameters:
RegDest: The register into which
the value should be loaded.
A Constant value to be loaded
Return value.
Returns 0 on success, -1
otherwise.
Description. This method loads a 32-bit value into the specified interpreter register.
Signature.
int load_const_u32
(
Uint32 RegDest,
Uint32 Constant
)
Parameters. This method takes the following two parameters:
RegDest: The register into which
the value should be loaded.
A Constant value to be loaded
Return value.
Returns 0 on success, -1
otherwise.
Description. This method loads a 64-bit value into the specified interpreter register.
Signature.
int load_const_u64
(
Uint32 RegDest,
Uint64 Constant
)
Parameters. This method takes the following two parameters:
RegDest: The register into which
the value should be loaded.
A Constant value to be loaded
Return value.
Returns 0 on success, -1
otherwise.
Description.
The read_attr() method is used to read a
table column value into a program register. The column may be
specified either by using its attribute ID or as a pointer to
a Column object.
Signature. This method can be called in either of two ways. The first of these is by referencing the column by its attribute ID, as shown here:
int read_attr
(
Uint32 RegDest,
Uint32 attrId
)
Alternatively, you can reference the column as a
Column object, as shown here:
int read_attr
(
Uint32 RegDest,
const NdbDictionary::Column* column
)
Parameters. This method takes two parameters, as described here:
The register to which the column value is to be copied
(RegDest).
Either of the following references to the table column whose value is to be copied:
The table column's attribute ID
(attrId)
A pointer to a
column—that is, a
pointer to an Column
object referencing the table column
Return value.
Returns 0 on success, and
-1 on failure.
Description. This method marks the end of the current subroutine.
Signature.
int ret_sub
(
void
)
Parameters. None.
Return value.
Returns 0 on success, -1
otherwise.
Description. This method gets the difference between the values stored in any two given registers and stores the result in a third register.
Signature.
int sub_reg
(
Uint32 RegDest,
Uint32 RegSource1,
Uint32 RegSource2
)
Parameters.
This method takes three parameters. The first of these is the
register in which the result is to be stored
(RegDest). The second and third
parameters (RegSource1and
RegSource2) are the registers whose
values are to be subtracted. In other words, the value of
register RegDest is calculated as
the value of the expression shown here:
(value in registerRegSource1) – (value in registerRegSource2)
It is possible to re-use one of the registers whose values are
subtracted for storing the result; that is,
RegDest can be the same as
RegSource1 or
RegSource2.
Return value.
0 on success; -1 on
failure.
Description.
This method subtracts a specified value from the value of a
given table column, and places the original and modified
column values in registers 6 and 7. It is equivalent to the
following series of
NdbInterpretedCode method
calls, where attrId is the table
column' attribute ID and
aValue is the value to be
subtracted:
read_attr(6,attrId); load_const_u32(7,aValue); sub_reg(7,6,7); write_attr(attrId, 7);
aValue can be a 32-bit or 64-bit
integer.
Signature.
This method can be invoked in either of two ways, depending on
whether aValue is 32-bit or 64-bit.
32-bit aValue:
int sub_val
(
Uint32 attrId,
Uint32 aValue
)
64-bit aValue:
int sub_val
(
Uint32 attrId,
Uint64 aValue
)
Parameters. A table column attribute ID and a 32-bit or 64-bit integer value to be subtracted from this column value.
Return value.
Returns 0 on success, -1
on failure.
Description.
This method is used to copy a register value to a table
column. The column may be specified either by using its
attribute ID or as a pointer to a
Column object.
Signature. This method can be invoked in either of two ways. The first of these is requires referencing the column by its attribute ID, as shown here:
int read_attr
(
Uint32 attrId,
Uint32 RegSource
)
You can also reference the column as a
Column object instead, like
this:
int read_attr
(
const NdbDictionary::Column* column,
Uint32 RegSource
)
Parameters. This method takes two parameters as follows:
A reference to the table column to which the register value is to be copied. This can be either of the following:
The table column's attribute ID
(attrId)
A pointer to a
column—that is, a
pointer to an Column
object referencing the table column
The register whose value is to be copied
(RegSource).
Return value.
Returns 0 on success; -1
on failure.
