TCRDB(3)
TCRDB(3) β Tokyo Tyrant π
okay bestie, this is the remote database API, and it's giving very serious Tokyo Cabinet + Tokyo Tyrant server energy. Every function, argument, default, error code, and caveat is here β no cap. π«Ά
πΈ NAME πΈ
tcrdb β the remote database API. π
β¨ DESCRIPTION β¨
Remote database is a set of interfaces to use an abstract database of Tokyo Cabinet, mediated by a server of Tokyo Tyrant.
To use the remote database API, include tcrdb.h and related standard header files. Usually, write the following description near the front of a source file.
#include <tcrdb.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
Objects whose type is pointer to TCRDB are used to handle remote databases. A remote database object is created with the function tcrdbnew and is deleted with the function tcrdbdel. To avoid memory leak, it is important to delete every object when it is no longer in use. π please don't leak, bestie.
Before operations to store or retrieve records, it is necessary to connect the remote database object to the server. The function tcrdbopen is used to open a database connection and the function tcrdbclose is used to close the connection. π
π DESCRIPTION π
now the function-by-function tea β β same section name, more slay.
π§° the function squad
π©· tcrdberrmsg
Use tcrdberrmsg to get the message string corresponding to an error code.
const char *tcrdberrmsg(int ecode);
ecode specifies the error code. The return value is the message string of the error code.
π©· tcrdbnew
Use tcrdbnew to create a remote database object.
TCRDB *tcrdbnew(void);
The return value is the new remote database object.
π©· tcrdbdel
Use tcrdbdel to delete a remote database object.
void tcrdbdel(TCRDB *rdb);
rdb specifies the remote database object.
π©· tcrdbecode
Use tcrdbecode to get the last happened error code of a remote database object.
int tcrdbecode(TCRDB *rdb);
rdb specifies the remote database object. The return value is the last happened error code. The following error code is defined:
TTESUCCESSfor successTTEINVALIDfor invalid operationTTENOHOSTfor host not foundTTEREFUSEDfor connection refusedTTESENDfor send errorTTERECVfor recv errorTTEKEEPfor existing recordTTENORECfor no record foundTTEMISCfor miscellaneous error
π©· tcrdbtune
Use tcrdbtune to set the tuning parameters of a hash database object.
bool tcrdbtune(TCRDB *rdb, double timeout, int opts);
rdb specifies the remote database object. timeout specifies the timeout of each query in seconds. If it is not more than 0, the timeout is not specified. opts specifies options by bitwise-or: RDBTRECON specifies that the connection is recovered automatically when it is disconnected. If successful, the return value is true, else, it is false.
β οΈ Note that the tuning parameters should be set before the database is opened. fr fr, do it early.
π©· tcrdbopen
Use tcrdbopen to open a remote database.
bool tcrdbopen(TCRDB *rdb, const char *host, int port);
rdb specifies the remote database object. host specifies the name or the address of the server. port specifies the port number. If it is not more than 0, UNIX domain socket is used and the path of the socket file is specified by the host parameter. If successful, the return value is true, else, it is false.
π©· tcrdbopen2
Use tcrdbopen2 to open a remote database with a simple server expression.
bool tcrdbopen2(TCRDB *rdb, const char *expr);
rdb specifies the remote database object. expr specifies the simple server expression. It is composed of two substrings separated by ":". The former field specifies the name or the address of the server. The latter field specifies the port number. If the latter field is omitted, the default port number is specified. If successful, the return value is true, else, it is false.
π©· tcrdbclose
Use tcrdbclose to close a remote database object.
bool tcrdbclose(TCRDB *rdb);
rdb specifies the remote database object. If successful, the return value is true, else, it is false.
π©· tcrdbput
Use tcrdbput to store a record into a remote database object.
bool tcrdbput(TCRDB *rdb, const void *kbuf, int ksiz, const void *vbuf, int vsiz);
rdb specifies the remote database object. kbuf specifies the pointer to the region of the key. ksiz specifies the size of the region of the key. vbuf specifies the pointer to the region of the value. vsiz specifies the size of the region of the value. If successful, the return value is true, else, it is false. If a record with the same key exists in the database, it is overwritten.
π©· tcrdbput2
Use tcrdbput2 to store a string record into a remote object.
bool tcrdbput2(TCRDB *rdb, const char *kstr, const char *vstr);
rdb specifies the remote database object. kstr specifies the string of the key. vstr specifies the string of the value. If successful, the return value is true, else, it is false. If a record with the same key exists in the database, it is overwritten.
π©· tcrdbputkeep
Use tcrdbputkeep to store a new record into a remote database object.
bool tcrdbputkeep(TCRDB *rdb, const void *kbuf, int ksiz, const void *vbuf, int vsiz);
rdb specifies the remote database object. kbuf specifies the pointer to the region of the key. ksiz specifies the size of the region of the key. vbuf specifies the pointer to the region of the value. vsiz specifies the size of the region of the value. If successful, the return value is true, else, it is false. If a record with the same key exists in the database, this function has no effect. π it simply refuses to touch it.
π©· tcrdbputkeep2
Use tcrdbputkeep2 to store a new string record into a remote database object.
bool tcrdbputkeep2(TCRDB *rdb, const char *kstr, const char *vstr);
rdb specifies the remote database object. kstr specifies the string of the key. vstr specifies the string of the value. If successful, the return value is true, else, it is false. If a record with the same key exists in the database, this function has no effect.
π©· tcrdbputcat
Use tcrdbputcat to concatenate a value at the end of the existing record in a remote database object.
bool tcrdbputcat(TCRDB *rdb, const void *kbuf, int ksiz, const void *vbuf, int vsiz);
rdb specifies the remote database object. kbuf specifies the pointer to the region of the key. ksiz specifies the size of the region of the key. vbuf specifies the pointer to the region of the value. vsiz specifies the size of the region of the value. If successful, the return value is true, else, it is false. If there is no corresponding record, a new record is created.
π©· tcrdbputcat2
Use tcrdbputcat2 to concatenate a string value at the end of the existing record in a remote database object.
bool tcrdbputcat2(TCRDB *rdb, const char *kstr, const char *vstr);
rdb specifies the remote database object. kstr specifies the string of the key. vstr specifies the string of the value. If successful, the return value is true, else, it is false. If there is no corresponding record, a new record is created.
π©· tcrdbputshl
Use tcrdbputshl to concatenate a value at the end of the existing record and shift it to the left.
bool tcrdbputshl(TCRDB *rdb, const void *kbuf, int ksiz, const void *vbuf, int vsiz, int width);
rdb specifies the remote database object. kbuf specifies the pointer to the region of the key. ksiz specifies the size of the region of the key. vbuf specifies the pointer to the region of the value. vsiz specifies the size of the region of the value. width specifies the width of the record. If successful, the return value is true, else, it is false. If there is no corresponding record, a new record is created. π shifting left, iconic behavior.
π©· tcrdbputshl2
Use tcrdbputshl2 to concatenate a string value at the end of the existing record and shift it to the left.
bool tcrdbputshl2(TCRDB *rdb, const char *kstr, const char *vstr, int width);
rdb specifies the remote database object. kstr specifies the string of the key. vstr specifies the string of the value. width specifies the width of the record. If successful, the return value is true, else, it is false. If there is no corresponding record, a new record is created.
π©· tcrdbputnr
Use tcrdbputnr to store a record into a remote database object without response from the server.
bool tcrdbputnr(TCRDB *rdb, const void *kbuf, int ksiz, const void *vbuf, int vsiz);
rdb specifies the remote database object. kbuf specifies the pointer to the region of the key. ksiz specifies the size of the region of the key. vbuf specifies the pointer to the region of the value. vsiz specifies the size of the region of the value. If successful, the return value is true, else, it is false. If a record with the same key exists in the database, it is overwritten. π₯ no response from the server, just vibes and a write.
okay so next up is the put-with-no-response situation π
tcrdbputnr2 is the "fire and forget" bestie of the family β you use it to stash a string record into a remote object without waiting for a response from the server π«Ά
bool tcrdbputnr2(TCRDB *rdb, const char *kstr, const char *vstr);
rdbβ the remote database object, obvs.kstrβ the string of the key.vstrβ the string of the value.
If it works, the return value is true; if not, it's false. And if a record with the same key is already chilling in the database, it gets overwritten β no cap, it's gone π«‘
tcrdbout is the delete button for a record of a remote database object. bye bestie π
bool tcrdbout(TCRDB *rdb, const void *kbuf, int ksiz);
rdbβ the remote database object.kbufβ the pointer to the region of the key.ksizβ the size of the region of the key.
Successful? true. Not successful? false. That's the whole vibe check β¨
tcrdbout2 does the exact same delete, but the string-key version β much more your speed if you're not out here juggling buffers π
bool tcrdbout2(TCRDB *rdb, const char *kstr);
rdbβ the remote database object.kstrβ the string of the key.
true if it slayed, false if it flopped π
πΈ the getting-it-back era
tcrdbget is how you retrieve a record out of a remote database object π₯
void *tcrdbget(TCRDB *rdb, const void *kbuf, int ksiz, int *sp);
rdbβ the remote database object.kbufβ the pointer to the region of the key.ksizβ the size of the region of the key.spβ the pointer to the variable where the size of the region of the return value gets assigned.
If it's a success, the return value is the pointer to the region of the value of the corresponding record. NULL comes back if no record corresponds π
β¨ cute detail: because an additional zero code is appended at the end of the region of the return value, you can literally treat the return value as a character string.
And because the region of the return value is allocated with the malloc call, it should be released with the free call when it is no longer in use. yes bestie, that means you. free it. π§
tcrdbget2 is the string-flavored get β same energy, way less pointer admin π
char *tcrdbget2(TCRDB *rdb, const char *kstr);
rdbβ the remote database object.kstrβ the string of the key.
Success = the string of the value of the corresponding record. NULL = no record corresponds, tragic π
Because the region of the return value is allocated with the malloc call, it should be released with the free call when it is no longer in use β same rule, icon behavior only π
tcrdbget3 is the group-chat version: it retrieves records plural, all at once π
bool tcrdbget3(TCRDB *rdb, TCMAP *recs);
rdbβ the remote database object.recsβ a map object containing the retrieval keys. as a result of this function, keys existing in the database have the corresponding values, and keys not existing in the database are removed π³ (yes, it edits your map, that's the whole bit)
Return value is true if successful, else false π
π¦ size check era
tcrdbvsiz β how big is the value of a record in a remote database object? this function knows π
int tcrdbvsiz(TCRDB *rdb, const void *kbuf, int ksiz);
rdbβ the remote database object.kbufβ the pointer to the region of the key.ksizβ the size of the region of the key.
If successful, the return value is the size of the value of the corresponding record. else, it is -1 π
tcrdbvsiz2 β same size situation, but for a string record β¨
int tcrdbvsiz2(TCRDB *rdb, const char *kstr);
rdbβ the remote database object.kstrβ the string of the key.
Successful β the size of the value of the corresponding record. otherwise β -1 π
π iterator hours
tcrdbiterinit initializes the iterator of a remote database object β think of it as resetting the little cursor back to the start π
bool tcrdbiterinit(TCRDB *rdb);
rdbβ the remote database object.
true if successful, else false. and like β what's the iterator even for? it's used in order to access the key of every record stored in a database. iconique β¨
tcrdbiternext is the "gimme the next key" call on that iterator πββοΈ
void *tcrdbiternext(TCRDB *rdb, int *sp);
rdbβ the remote database object.spβ the pointer to the variable into which the size of the region of the return value is assigned.
Success = pointer to the region of the next key. otherwise = NULL. and NULL is also what you get when no record is to be get out of the iterator β i.e. you've reached the end, congrats π
because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string.
because the region of the return value is allocated with the malloc call, it should be released with the free call when it is no longer in use. (are we sensing a theme? we are. free it.) π
β οΈ real talk though: the iterator can be updated by multiple connections, and then it is not assured that every record is traversed. so like, don't @ me if you skip one π
tcrdbiternext2 β the next key, but as a string, because we're not doing buffer math today π
char *tcrdbiternext2(TCRDB *rdb);
rdbβ the remote database object.
Success = the string of the next key, else NULL. NULL also happens when no record is to be get out of the iterator, so don't panic π«Ά
Because the region of the return value is allocated with the malloc call, it should be released with the free call when it is no longer in use.
same warning, same energy: the iterator can be updated by multiple connections and then it is not assured that every record is traversed. fr fr πΈ
π forward matching keys
tcrdbfwmkeys fetches forward matching keys in a remote database object β basically "gimme everything that starts with this prefix" π«
TCLIST *tcrdbfwmkeys(TCRDB *rdb, const void *pbuf, int psiz, int max);
rdbβ the remote database object.pbufβ the pointer to the region of the prefix.psizβ the size of the region of the prefix.maxβ the maximum number of keys to be fetched. if it is negative, no limit is specified π€―
The return value is a list object of the corresponding keys. key detail: this function does never fail. it returns an empty list even if no key corresponds. no drama, just an empty list π
Because the object of the return value is created with the function tclistnew, it should be deleted with the function tclistdel when it is no longer in use β¨
tcrdbfwmkeys2 β same forward matching era, but the prefix is a string π
TCLIST *tcrdbfwmkeys2(TCRDB *rdb, const char *pstr, int max);
rdbβ the remote database object.pstrβ the string of the prefix.maxβ the maximum number of keys to be fetched. if it is negative, no limit is specified.
Return value = a list object of the corresponding keys. again: this function does never fail. empty list even if no key corresponds. it simply doesn't miss π
Because the object of the return value is created with the function tclistnew, it should be deleted with the function tclistdel when it is no longer in use π₯
π number-crunching besties
tcrdbaddint adds an integer to a record in a remote database object β
int tcrdbaddint(TCRDB *rdb, const void *kbuf, int ksiz, int num);
rdbβ the remote database object.kbufβ the pointer to the region of the key.ksizβ the size of the region of the key.numβ the additional value.
Success = the summation value. else = INT_MIN π and here's the little mechanic: if the corresponding record exists, the value is treated as an integer and is added to. if no record corresponds, a new record of the additional value is stored π«Ά
tcrdbadddouble is the same bit but with a real number π
double tcrdbadddouble(TCRDB *rdb, const void *kbuf, int ksiz, double num);
rdbβ the remote database object.kbufβ the pointer to the region of the key.ksizβ the size of the region of the key.numβ the additional value.
Success = the summation value, else = Not-a-Number π If the corresponding record exists, the value is treated as a real number and is added to. if no record corresponds, a new record of the additional value is stored. same rules, floatier vibes β
tcrdbext is used in order to call a function of the script language extension β
Because an extra zero code gets tacked onto the end of the return-value region, you can literally treat the return value as a character string β so convenient π. And because that region is allocated with the malloc call, bestie please release it with the free call the moment you're done with it, ok? Don't leave it hanging π
The function tcrdbext2 is used in order to call a function of the script language extension with string parameters.
char *tcrdbext2(TCRDB *rdb, const char *name, int opts, const char *kstr, const char *vstr);
rdbspecifies the remote database object.namespecifies the function name.optsspecifies options by bitwise-or:RDBXOLCKRECfor record locking,RDBXOLCKGLBfor global locking.kstrspecifies the string of the key.vstrspecifies the string of the value.
If it works out, the return value is the string of the value of the response β¨. NULL is returned on failure, sad but true.
Because the region of the return value is allocated with the malloc call, it should be released with the free call when it is no longer in use π
The function tcrdbsync is used in order to synchronize updated contents of a remote database object with the file and the device.
bool tcrdbsync(TCRDB *rdb);
rdbspecifies the remote database object.
If successful, the return value is true, else, it is false π«Ά
The function tcrdboptimize is used in order to optimize the storage of a remove database object.
bool tcrdboptimize(TCRDB *rdb, const char *params);
rdbspecifies the remote database object.paramsspecifies the string of the tuning parameters. If it isNULL, it is not used.
If successful, the return value is true, else, it is false πΈ
The function tcrdbvanish is used in order to remove all records of a remote database object.
bool tcrdbvanish(TCRDB *rdb);
rdbspecifies the remote database object.
If successful, the return value is true, else, it is false π (yes, all the records. gone. periodt.)
The function tcrdbcopy is used in order to copy the database file of a remote database object.
bool tcrdbcopy(TCRDB *rdb, const char *path);
rdbspecifies the remote database object.pathspecifies the path of the destination file. If it begins with@, the trailing substring is executed as a command line π
If successful, the return value is true, else, it is false. False is returned if the executed command returns non-zero code.
The database file is assured to be kept synchronized and not modified while the copying or executing operation is in progress π. So yeah, this function is genuinely useful to create a backup file of the database file β iconic behaviour honestly.
The function tcrdbrestore is used in order to restore the database file of a remote database object from the update log.
bool tcrdbrestore(TCRDB *rdb, const char *path, uint64_t ts, int opts);
rdbspecifies the remote database object.pathspecifies the path of the update log directory.optsspecifies options by bitwise-or:RDBROCHKCONfor consistency checking.tsspecifies the beginning time stamp in microseconds.
If successful, the return value is true, else, it is false π
The function tcrdbsetmst is used in order to set the replication master of a remote database object.
bool tcrdbsetmst(TCRDB *rdb, const char *host, int port, uint64_t ts, int opts);
rdbspecifies the remote database object.hostspecifies the name or the address of the server. If it isNULL, replication of the database is disabled π«portspecifies the port number.tsspecifies the beginning timestamp in microseconds.optsspecifies options by bitwise-or:RDBROCHKCONfor consistency checking.
If successful, the return value is true, else, it is false β¨
The function tcrdbsetmst2 is used in order to set the replication master of a remote database object with a simple server expression.
bool tcrdbsetmst2(TCRDB *rdb, const char *expr, uint64_t ts, int opts);
rdbspecifies the remote database object.exprspecifies the simple server expression. It is composed of two substrings separated by":". The former field specifies the name or the address of the server. The latter field specifies the port number. If the latter field is omitted, the default port number is specified πtsspecifies the beginning timestamp in microseconds.optsspecifies options by bitwise-or:RDBROCHKCONfor consistency checking.
If successful, the return value is true, else, it is false π¦
The function tcrdbrnum is used in order to get the number of records of a remote database object.
uint64_t tcrdbrnum(TCRDB *rdb);
rdbspecifies the remote database object.
The return value is the number of records or 0 if the object does not connect to any database server π
The function tcrdbsize is used in order to get the size of the database of a remote database object.
uint64_t tcrdbsize(TCRDB *rdb);
rdbspecifies the remote database object.
The return value is the size of the database or 0 if the object does not connect to any database server π
The function tcrdbstat is used in order to get the status string of the database of a remote database object.
char *tcrdbstat(TCRDB *rdb);
rdbspecifies the remote database object.
The return value is the status message of the database or NULL if the object does not connect to any database server. The message format is TSV π. The first field of each line means the parameter name and the second field means the value β iykyk.
Because the region of the return value is allocated with the malloc call, it should be released with the free call when it is no longer in use π§
The function tcrdbmisc is used in order to call a versatile function for miscellaneous operations of a remote database object.
TCLIST *tcrdbmisc(TCRDB *rdb, const char *name, int opts, const TCLIST *args);
rdbspecifies the remote database object.namespecifies the name of the function. All databases support"put","out","get","putlist","outlist", and"getlist"β¨"put"is to store a record. It receives a key and a value, and returns an empty list."out"is to remove a record. It receives a key, and returns an empty list."get"is to retrieve a record. It receives a key, and returns a list of the values."putlist"is to store records. It receives keys and values one after the other, and returns an empty list."outlist"is to remove records. It receives keys, and returns an empty list."getlist"is to retrieve records. It receives keys, and returns keys and values of corresponding records one after the other π₯
optsspecifies options by bitwise-or:RDBMONOULOGfor omission of the update log.argsspecifies a list object containing arguments.
If successful, the return value is a list object of the result. NULL is returned on failure π
Because the object of the return value is created with the function tclistnew, it should be deleted with the function tclistdel when it is no longer in use β don't forget, bestie π
π TABLE EXTENSION π
The function tcrdbtblput is used in order to store a record into a remote database object.
bool tcrdbtblput(TCRDB *rdb, const void *pkbuf, int pksiz, TCMAP *cols);
rdbspecifies the remote database object.pkbufspecifies the pointer to the region of the primary key.pksizspecifies the size of the region of the primary key.colsspecifies a map object containing columns.
If successful, the return value is true, else, it is false π
If a record with the same key exists in the database, it is overwritten β no warning, it just goes π
The function tcrdbtblputkeep is used in order to store a new record into a remote database object.
tcrdbtblputkeep is the table-put that's like, βnew key only, bestie.β If a record with the same key already exists in the database, this function has no effect β it literally just minds its business.
bool tcrdbtblputkeep(TCRDB *rdb, const void *pkbuf, int pksiz,
TCMAP *cols);
rdbβ the remote database object.pkbufβ pointer to the region of the primary key.pksizβ size of the region of the primary key.colsβ a map object containing columns.- If successful, the return value is
true; else, it isfalse.
tcrdbtblputcat is used in order to concatenate columns of the existing record in a remote database object. If thereβs no corresponding record, a new record is created β so itβs giving βmerge or make it happen.β π«Ά
bool tcrdbtblputcat(TCRDB *rdb, const void *pkbuf, int pksiz,
TCMAP *cols);
rdbβ the remote database object.pkbufβ pointer to the region of the primary key.pksizβ size of the region of the primary key.colsβ a map object containing columns.- If successful, the return value is
true; else, it isfalse.
tcrdbtblout is used in order to remove a record of a remote database object. Bye-bye, record. π
bool tcrdbtblout(TCRDB *rdb, const void *pkbuf, int pksiz);
rdbβ the remote database object.pkbufβ pointer to the region of the primary key.pksizβ size of the region of the primary key.- If successful, the return value is
true; else, it isfalse.
tcrdbtblget is used in order to retrieve a record in a remote database object. Itβs the βcome through, columnsβ function. β¨
TCMAP *tcrdbtblget(TCRDB *rdb, const void *pkbuf, int pksiz);
rdbβ the remote database object.pkbufβ pointer to the region of the primary key.pksizβ size of the region of the primary key.- If successful, the return value is a map object of the columns of the corresponding record.
NULLis returned if no record corresponds. - Because the object of the return value is created with the function
tcmapnew, it should be deleted with the functiontcmapdelwhen it is no longer in use.
Bestie, donβt forget the tcmapdel β thatβs your cleanup era. π
tcrdbtblsetindex is used in order to set a column index to a remote database object. If the name of an existing index is specified, the index is rebuilt. An empty string means the primary key.
bool tcrdbtblsetindex(TCRDB *rdb, const char *name, int type);
rdbβ the remote database object.nameβ the name of a column. If the name of an existing index is specified, the index is rebuilt. An empty string means the primary key.typeβ the index type:RDBITLEXICALβ lexical stringRDBITDECIMALβ decimal stringRDBITTOKENβ token inverted indexRDBITQGRAMβ q-gram inverted indexRDBITOPTβ the index is optimizedRDBITVOIDβ the index is removedRDBITKEEPβ if added by bitwise-or and the index exists, this function merely returns failure
- If successful, the return value is
true; else, it isfalse.
tcrdbtblgenuid is used in order to generate a unique ID number of a remote database object. Fresh ID, no duplicates, main character energy. π
int64_t tcrdbtblgenuid(TCRDB *rdb);
rdbβ the remote database object.- The return value is the new unique ID number or
-1on failure.
tcrdbqrynew is used in order to create a query object.
RDBQRY *tcrdbqrynew(TCRDB *rdb);
rdbβ the remote database object.- The return value is the new query object.
tcrdbqrydel is used in order to delete a query object. Clean up your query, bestie.
void tcrdbqrydel(RDBQRY *qry);
qryβ the query object.
tcrdbqryaddcond is used in order to add a narrowing condition to a query object. Itβs the βbe more specificβ button, and honestly? Obsessed.
void tcrdbqryaddcond(RDBQRY *qry, const char *name, int op, const
char *expr);
qryβ the query object.nameβ the name of a column. An empty string means the primary key.opβ an operation type:RDBQCSTREQβ string which is equal to the expressionRDBQCSTRINCβ string which is included in the expressionRDBQCSTRBWβ string which begins with the expressionRDBQCSTREWβ string which ends with the expressionRDBQCSTRANDβ string which includes all tokens in the expressionRDBQCSTRORβ string which includes at least one token in the expressionRDBQCSTROREQβ string which is equal to at least one token in the expressionRDBQCSTRRXβ string which matches regular expressions of the expressionRDBQCNUMEQβ number which is equal to the expressionRDBQCNUMGTβ number which is greater than the expressionRDBQCNUMGEβ number which is greater than or equal to the expressionRDBQCNUMLTβ number which is less than the expressionRDBQCNUMLEβ number which is less than or equal to the expressionRDBQCNUMBTβ number which is between two tokens of the expressionRDBQCNUMOREQβ number which is equal to at least one token in the expressionRDBQCFTSPHβ full-text search with the phrase of the expressionRDBQCFTSANDβ full-text search with all tokens in the expressionRDBQCFTSORβ full-text search with at least one token in the expressionRDBQCFTSEXβ full-text search with the compound expression- All operations can be flagged by bitwise-or:
RDBQCNEGATEfor negation,RDBQCNOIDXfor using no index.
exprβ specifies an operand exression.
tcrdbqrysetorder is used in order to set the order of a query object. Sorting? We love a sorted result. π
void tcrdbqrysetorder(RDBQRY *qry, const char *name, int type);
qryβ the query object.nameβ the name of a column. An empty string means the primary key.typeβ the order type:RDBQOSTRASCβ string ascendingRDBQOSTRDESCβ string descendingRDBQONUMASCβ number ascendingRDBQONUMDESCβ number descending
tcrdbqrysetlimit is used in order to set the limit number of records of the result of a query object. Boundaries, but make it cute. π¦
void tcrdbqrysetlimit(RDBQRY *qry, int max, int skip);
qryβ the query object.maxβ the maximum number of records of the result. If it is negative, no limit is specified.skipβ the number of skipped records of the result. If it is not more than0, no record is skipped.
tcrdbqrysearch is used in order to execute the search of a query object.
TCLIST *tcrdbqrysearch(RDBQRY *qry);
qryβ the query object.- The return value is a list object of the primary keys of the corresponding records.
- This function does never fail. It returns an empty list even if no record corresponds.
- Because the object of the return value is created with the function
tclistnew, it should be deleted with the functiontclistdelwhen it is no longer in use.
Empty list still ate, okay? Itβs valid. π
tcrdbqrysearchout is used in order to remove each record corresponding to a query object.
bool tcrdbqrysearchout(RDBQRY *qry);
qryβ the query object of the database.- If successful, the return value is
true; else, it isfalse.
tcrdbqrysearchget is used in order to get records corresponding to the search of a query object.
TCLIST *tcrdbqrysearchget(RDBQRY *qry);
qryβ the query object.- The return value is a list object of zero separated columns of the corresponding records.
- This function does never fail. It returns an empty list even if no record corresponds.
- Each element of the list can be treated with the function
tcrdbqryrescols. - Because the object of the return value is created with the function
tclistnew, it should be deleted with the functiontclistdelwhen it is no longer in use.
tcrdbqryrescols is used in order to get columns of a record in a search result.
TCMAP *tcrdbqryrescols(TCLIST *res, int index);
resβ a list of zero separated columns of the search result.indexβ the index of an element of the search result.- The return value is a map object containing columns.
- Because the object of the return value is created with the function
tcmapnew, it should be deleted with the functiontcmapdelwhen it is no longer in use.
tcrdbqrysearchcount is used in order to get the count of corresponding records of a query object.
int tcrdbqrysearchcount(RDBQRY *qry);
qryβ the query object.- The return value is the count of corresponding records or
0on failure.
tcrdbqryhint is used in order to get the hint string of a query object.
const char *tcrdbqryhint(RDBQRY *qry);
qryβ the query object.- The return value is the hint string.
- This function should be called after the query execution by
tcrdbqrysearchand so on. - The region of the return value is overwritten when this function is called again.
Read it, enjoy it, donβt hold onto the pointer forever β it gets overwritten. π
tcrdbmetasearch is used in order to retrieve records with multiple query objects and get the set of the result.
okay so tcrdbmetasearch is the group-chat organizer of query objects β it takes a whole array and does set math on them π
TCLIST *tcrdbmetasearch(RDBQRY **qrys, int num, int type);
qrysβ an array of the query objects, bestie. Like, all of them.numβ how many elements are in that array.typeβ the set operation vibe:RDBMSUNIONfor the union set,RDBMSISECTfor the intersection set,RDBMSDIFFfor the difference set. Pick your fighter β¨
The return value is a list object of the primary keys of the corresponding records. This function does never fail β no cap. It returns an empty list even if no record corresponds, so donβt panic if itβs giving nothing. If the first query object has the order setting, the result array is sorted by the order. And because the object of the return value is created with the function tclistnew, it should be deleted with the function tclistdel when it is no longer in use. Clean up after yourself, queen π
The function tcrdbparasearch is used in order to search records for multiple servers in parallel β parallel bestie behavior, highkey iconic π¦
TCLIST *tcrdbparasearch(RDBQRY **qrys, int num);
qrysβ an array of the query objects.numβ the number of elements of the array.
The return value is a list object of zero separated columns of the corresponding records. This function does never fail. It returns an empty list even if no record corresponds. Each element of the list can be treated with the function tcrdbqryrescols. And because the object of the return value is created with the function tclistnew, it should be deleted with the function tclistdel when it is no longer in use. Same cleanup rule, same main character energy π«Ά
π SEE ALSO π
Thatβs the whole TCRDB(3) page, bestie β footer vibes say 2010-08-05, and we are officially out π
β¨π
π¦ where this page comes from
- nixos 26.05: tokyotyrant 1.1.41
- nixpkgs unstable: tokyotyrant 1.1.41
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms