Index of /code/PostgreSQL/y_octet_t

[ICO]NameLast modifiedSizeDescription

[DIR]Parent Directory  -  
[   ]LICENSE18-Jan-2007 21:47 1.4K 
[   ]Makefile06-Mar-2008 10:51 2.2K 
[TXT]README.html22-Jan-2007 15:54 2.8K 
[TXT]y_octet_t.c22-Jan-2007 15:48 8.0K 
[TXT]y_octet_t.h22-Jan-2007 15:48 1.2K 
[   ]y_octet_t.sql22-Jan-2007 15:48 3.8K 

README for y_mhash

y_octet_t

Fixed length octet string types. (I use the term 'octet' instead of 'byte' because although we typically associate the term 'byte' with eight bits, there is no definition of byte that requires this). The purpose of this type is to reduce the overhead associated with storing fixed length binary data in a variable length type like bytea. For example, a UUID (aka GUID) type can be stored in exactly 16 octets.

So far this code contains one type: y_octet_16, for storing sixteen character octet strings. This type includes operators and operator classes required to maintain btree and hash indexes. This type accepts 32 character case-insensitive hexadecimal strings as input. Whitespace, colons (:), and dashes (-) are ignored. Any other character renders the input invalid. A y_octet_16 function (and corresponding CAST) is provided to convert values of type text to type y_octet_16.

The Makefile implements the standard PostgreSQL PGXS build infrastructure. Run 'make' and 'make install' with appropriate permissions to build and install y_octet_t.so. Execute the SQL calls in y_octet_t.sql to instantiate the type within your database.

Examples:

% CREATE TABLE octets ( octet_string y_octet_16 );
CREATE TABLE

% CREATE UNIQUE INDEX osidx ON octets( octet_string );
CREATE INDEX

% INSERT INTO octets VALUES ( 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' );
INSERT 0 1

% INSERT INTO octets VALUES ( ' 0123456789 abcdef-01:23:45:67:89:ABCDEF ' );
INSERT 0 1

% INSERT INTO octets VALUES ( encode( y_uuid_generate_random(), 'hex' )::y_octet_16 );
INSERT 0 1

% SELECT * FROM octets;
           octet_string           
----------------------------------
 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 0123456789abcdef0123456789abcdef
(2 rows)
(Uses y_uuid for last INSERT example)

Please send comments and suggestions to 'ron dot peterson at yellowbank dot com'.

TODO: More testing. Implement LIKE operator. Implement other common string sizes.


More Yellowbank Code.


Last modified: Mon Jan 22 15:54:26 EST 2007