mksqlite  2.5
A MATLAB interface to SQLite
Functions
sql_builtin_functions.hpp File Reference

SQL builtin functions, automatically attached to each database. More...

#include "typed_blobs.hpp"
#include "number_compressor.hpp"
#include "serialize.hpp"
#include "deelx/deelx.h"
#include "md5/md5.h"
+ Include dependency graph for sql_builtin_functions.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void pow_func (sqlite3_context *ctx, int argc, sqlite3_value **argv)
 Power function implementation. More...
 
void lg_func (sqlite3_context *ctx, int argc, sqlite3_value **argv)
 Logarithm function to base 10 implementation. More...
 
void ln_func (sqlite3_context *ctx, int argc, sqlite3_value **argv)
 Natural logarithm function implementation. More...
 
void exp_func (sqlite3_context *ctx, int argc, sqlite3_value **argv)
 Exponential function implementation. More...
 
void regex_func (sqlite3_context *ctx, int argc, sqlite3_value **argv)
 Regular expression function implementation. More...
 
void BDC_ratio_func (sqlite3_context *ctx, int argc, sqlite3_value **argv)
 BDCRatio function implementation. More...
 
void BDC_pack_time_func (sqlite3_context *ctx, int argc, sqlite3_value **argv)
 BDCPackTime function implementation. More...
 
void BDC_unpack_time_func (sqlite3_context *ctx, int argc, sqlite3_value **argv)
 BDCUnpackTime function implementation. More...
 
void MD5_func (sqlite3_context *ctx, int argc, sqlite3_value **argv)
 MD5 hashing implementation. More...
 
int blob_pack (const mxArray *pcItem, bool bStreamable, void **ppBlob, size_t *pBlob_size, double *pdProcess_time, double *pdRatio, const char *compressor, int level)
 create a compressed typed blob from a Matlab item (deep copy) More...
 
int blob_unpack (const void *pBlob, size_t blob_size, bool bStreamable, mxArray **ppItem, double *pdProcess_time, double *pdRatio)
 uncompress a typed blob and return as MATLAB array More...
 
void blob_free (void **ppBlob)
 Free memory allocated for a BLOB.
 

Detailed Description

SQL builtin functions, automatically attached to each database.

Additional functions in SQL statements (MD5, regex, pow, and packing ratio/time)

See also
http://undocumentedmatlab.com/blog/serializing-deserializing-matlab-data
Authors
Martin Kortmann mail@.nosp@m.kort.nosp@m.mann..nosp@m.de, Andreas Martin andim.nosp@m.arti.nosp@m.n@use.nosp@m.rs.s.nosp@m.ource.nosp@m.forg.nosp@m.e.net
Version
2.5
Date
2008-2017
Precondition
Warning
Bug:

Definition in file sql_builtin_functions.hpp.

Function Documentation

◆ BDC_pack_time_func()

void BDC_pack_time_func ( sqlite3_context *  ctx,
int  argc,
sqlite3_value **  argv 
)

BDCPackTime function implementation.

BDCPackTime(value) calculates the compression time on a blob, where value is argv[0]

Parameters
[in]ctxSQL context parameter
[in]argcArgument count
[in]argvSQL argument values

Definition at line 553 of file sql_builtin_functions.hpp.

References blob_pack(), blob_unpack(), can_serialize(), and utils_destroy_array().

Referenced by SQLstackitem::attachBuiltinFunctions().

+ Here is the caller graph for this function:

◆ BDC_ratio_func()

void BDC_ratio_func ( sqlite3_context *  ctx,
int  argc,
sqlite3_value **  argv 
)

BDCRatio function implementation.

BDCRatio(value) calculates the compression ratio for a blob, where value is argv[0]

Parameters
[in]ctxSQL context parameter
[in]argcArgument count
[in]argvSQL argument values

Definition at line 497 of file sql_builtin_functions.hpp.

References blob_unpack(), can_serialize(), and utils_destroy_array().

Referenced by SQLstackitem::attachBuiltinFunctions().

+ Here is the caller graph for this function:

◆ BDC_unpack_time_func()

void BDC_unpack_time_func ( sqlite3_context *  ctx,
int  argc,
sqlite3_value **  argv 
)

BDCUnpackTime function implementation.

BDCUnpackTime(value) calculates the uncompression time on a blob, where value is argv[0]

Parameters
[in]ctxSQL context parameter
[in]argcArgument count
[in]argvSQL argument values

Definition at line 619 of file sql_builtin_functions.hpp.

References blob_unpack(), can_serialize(), and utils_destroy_array().

Referenced by SQLstackitem::attachBuiltinFunctions().

+ Here is the caller graph for this function:

◆ blob_pack()

int blob_pack ( const mxArray *  pcItem,
bool  bStreamable,
void **  ppBlob,
size_t *  pBlob_size,
double *  pdProcess_time,
double *  pdRatio,
const char *  compressor,
int  level 
)

create a compressed typed blob from a Matlab item (deep copy)

Parameters
[in]pcItemMATLAB array to compress
[in]bStreamableif true, streaming preprocess is intended
[out]ppBlobCreated BLOB, allocated by sqlite3_malloc
[out]pBlob_sizeSize of BLOB in bytes
[out]pdProcess_timeProcessing time in seconds
[out]pdRatioRealized compression ratio
[in]compressorname of compressor to use (optional). Default is global setting g_compression_type
[in]levelcompression level (optional). Default is global setting g_compression_level
Todo:
MSG_ERRSERIALIZE
Todo:
Do byteswapping here if big endian?
Todo:
Do byteswapping here if big endian?

Definition at line 699 of file sql_builtin_functions.hpp.

References ValueMex::Complexity(), serialize(), Err::set(), and ValueMex::TC_COMPLEX.

Referenced by BDC_pack_time_func().

+ Here is the caller graph for this function:

◆ blob_unpack()

int blob_unpack ( const void *  pBlob,
size_t  blob_size,
bool  bStreamable,
mxArray **  ppItem,
double *  pdProcess_time,
double *  pdRatio 
)

uncompress a typed blob and return as MATLAB array

Parameters
[out]pBlobBLOB to decompress
[out]blob_sizeSize of BLOB in bytes
[in]bStreamableif true, streaming preprocess is intended
[in]ppItemMATLAB array to compress
[out]pdProcess_timeProcessing time in seconds
[out]pdRatioRealized compression ratio
Todo:
warning, error or automatic conversion..?
Todo:
Do byteswapping here if needed, depend on endian?

Definition at line 899 of file sql_builtin_functions.hpp.

References getLocaleMsg().

Referenced by BDC_pack_time_func(), BDC_ratio_func(), BDC_unpack_time_func(), and MD5_func().

+ Here is the caller graph for this function:

◆ exp_func()

void exp_func ( sqlite3_context *  ctx,
int  argc,
sqlite3_value **  argv 
)

Exponential function implementation.

Computes the equation result = exp( value )
where value is argv[0]

Parameters
[in]ctxSQL context parameter
[in]argcArgument count
[in]argvSQL argument values

Definition at line 200 of file sql_builtin_functions.hpp.

Referenced by SQLstackitem::attachBuiltinFunctions().

+ Here is the caller graph for this function:

◆ lg_func()

void lg_func ( sqlite3_context *  ctx,
int  argc,
sqlite3_value **  argv 
)

Logarithm function to base 10 implementation.

Computes the equation result = log10( value )
where value is argv[0]

Parameters
[in]ctxSQL context parameter
[in]argcArgument count
[in]argvSQL argument values

Definition at line 124 of file sql_builtin_functions.hpp.

Referenced by SQLstackitem::attachBuiltinFunctions().

+ Here is the caller graph for this function:

◆ ln_func()

void ln_func ( sqlite3_context *  ctx,
int  argc,
sqlite3_value **  argv 
)

Natural logarithm function implementation.

Computes the equation result = ln( value )
where value is argv[0]

Parameters
[in]ctxSQL context parameter
[in]argcArgument count
[in]argvSQL argument values

Definition at line 162 of file sql_builtin_functions.hpp.

Referenced by SQLstackitem::attachBuiltinFunctions().

+ Here is the caller graph for this function:

◆ MD5_func()

void MD5_func ( sqlite3_context *  ctx,
int  argc,
sqlite3_value **  argv 
)

MD5 hashing implementation.

md5(value) calculates the md5 hash (RSA), where value is argv[0]

Parameters
[in]ctxSQL context parameter
[in]argcArgument count
[in]argvSQL argument values

Definition at line 357 of file sql_builtin_functions.hpp.

References blob_unpack(), can_serialize(), g_convertUTF8, TypedBLOBHeaderBase::getDataSize(), HC_NOTES, MEM_ALLOC, TBH_endian, utils_destroy_array(), utils_free_ptr(), and utils_strnewdup().

Referenced by SQLstackitem::attachBuiltinFunctions().

+ Here is the caller graph for this function:

◆ pow_func()

void pow_func ( sqlite3_context *  ctx,
int  argc,
sqlite3_value **  argv 
)

Power function implementation.

Computes the equation result = pow( base, exponent )
where base is argv[0] and exponent is argv[1]

Parameters
[in]ctxSQL context parameter
[in]argcArgument count
[in]argvSQL argument values

Definition at line 74 of file sql_builtin_functions.hpp.

Referenced by SQLstackitem::attachBuiltinFunctions().

+ Here is the caller graph for this function:

◆ regex_func()

void regex_func ( sqlite3_context *  ctx,
int  argc,
sqlite3_value **  argv 
)

Regular expression function implementation.

Regular expression function ( with replace option, then argc > 2 )
regex(str,pattern) returns the matching substring of str, which matches against pattern, where str is argv[0] and pattern is argv[1].

If 3 arguments passed regex(str,pattern,replacement) the substring will be modified regarding replacement parameter before returned.

Parameters
[in]ctxSQL context parameter
[in]argcArgument count
[in]argvSQL argument values

Definition at line 242 of file sql_builtin_functions.hpp.

References g_convertUTF8, HC_NOTES, MEM_ALLOC, utils_free_ptr(), utils_latin2utf(), and utils_strnewdup().

Referenced by SQLstackitem::attachBuiltinFunctions().

+ Here is the caller graph for this function: