The BDT blade is designed to allow for the storage and manipulation of binary encoded strings. It supports two new datatypes, andallows for logical operations like AND, OR, XOR and NOT to be usedagainst these datatypes.
Like any official datablade, it is registered/installed by the use ofthe blademgr function.
After registering it to your database you now have two additional UDT's
- binaryvar- UDT which stores binary string of up to 255 characters
- binary18- UDT which stores a fixed 18 byte binary string. If the value insertedinto this UDT is less tha 18 bytes, the field is right paddedwith zeroes.
But inserting the Following will not generate an error:
Currently the above datatypes can be manipulated by the followingfunctions:
- bit_and() -performs a logical AND on two BDT datatypes or one BDT datatype and astring constant.
- bit_complement() - performs a logical NOT on a single BDT datatype.
- bit_or()- performs a logical OR on two BDT datatypes or one BDTdatatype and a string constant.
- bit_xor()-performs a logical XOR on two BDT datatypes or one BDT datatype and astring constant.
Also the following aggregates support the BDT datatypes:
- COUNT DISTINCT()
The BDT Blade supports b-tree indices for both single column andcomposite indices.
So now that we have the details, let create an example. We will createa table in the stores_demo database called bdt_example, and insert somerows.
CREATE TABLE bdt_example (bin_id serial, bin_val binary18) ;
INSERT into bdt_example values (0, '102039847137');
INSERT into bdt_example values (0, '0xFE');
INSERT into bdt_example values(0, '49424d434f52504f524154494f4e32303036');
So let's run :
SELECT DISTINCT (bin_val) FROM bin_val;
As you can see the values for the binary18 which were inserted that hadless than 18 bytes had zeroes padded on the end.
So let's see what the complement of the data would be:
SELECT bit_complement(bin_val) from bdt_example;
Again you can see where the logical not was run against these threevalues.
The BDT datablade also has some additional diagnostic type functions.They are:
- BDTRelease() - This function tells you what version of theBDT datablade you are using.
- BDTTrace(filename)- This function specifies the location of the debug/trace file for theBDT datablade.
- LENGTH(column)- This function specifies the length, in bytes, of the BDT columnspecified.
- OCTECT_LENGTH (column)- This function specifies the length, in bytes, of the BDT columnspecified.
One additional addendum. The BDT is fully supported for use in ER.
Additional information on the Binary Datablade can be found in TheBuilt-In DataBlade Modules User's Guide