![]() |
smax-postgres v0.9
PostgreSQL / TimescaleDB logger for SMA-X
|
Macros | |
| #define | __XCHANGE_INTERNAL_API__ |
| Use internal definitions. | |
| #define | _GNU_SOURCE |
| C source code standard. | |
| #define | COL_NAME_STEM "c" |
| prefix for array data columns | |
| #define | DEFAULT_STRING_LEN 16 |
| (bytes) default initial size for variable-length strings | |
| #define | FIX_SCALAR_DIMS 0 |
| Whether singled-element 1D data should be stored as scalars. | |
| #define | MASTER_TABLE "titles" |
| table name in which to store variable name -> id pairings | |
| #define | META_NAME_PATTERN TABLE_NAME_PATTERN "_meta" |
| pattern for metadata table names | |
| #define | META_SERIAL_ID "serial" |
| column name/id for metadata serial numbers | |
| #define | META_SHAPE_LEN X_MAX_STRING_DIMS |
| Maximum number of dimensions to store. | |
| #define | META_UNIT_LEN 32 |
| Maximum size for sotring physical units. | |
| #define | MIN_CMD_SIZE 16384 |
| (bytes) Initial size of the command buffer | |
| #define | POSTGRES 1 |
| Use PostgreSQL data types from sql-types.h. | |
| #define | SQL_COL_NAME_LEN 32 |
| (bytes) Maximum length for column names | |
| #define | SQL_SEP ", " |
| List separator. | |
| #define | SQL_TABLE_NAME_LEN 32 |
| (bytes) Maximum length for table names | |
| #define | SQL_TYPE_LEN 64 |
| (bytes) Maximum length of SQL data type names | |
| #define | TABLE_NAME_PATTERN "var_%06d" |
| pattern for tables names that store data for variables | |
| #define | VARNAME_ID "name" |
| column name/id for variable names | |
Functions | |
| int | deleteVars (const char *pattern) |
| int | insertQueue (Variable *u) |
| int | setupDB (const char *owner, const char *passwd) |
| void * | SQLThread () |
SQL backend module for smaxLogger. It supports most common SQL flavors. The specific SQL flavor to use can be selected via an appropriate compiler constant.
| int deleteVars | ( | const char * | pattern | ) |
Deletes variables and metadata from the SQL DB, and removes them from the master table also.
| pattern | Glob variable name pattern |
References MASTER_TABLE.
| int insertQueue | ( | Variable * | u | ) |
Add the variable to the queue for database insertion.
| u | Pointer to the variable data structure |
References ERROR_RETURN, Variable::next, and SUCCESS_RETURN.
| int setupDB | ( | const char * | owner, |
| const char * | passwd | ||
| ) |
Sets up (bootstraps) a clean new database
| owner | User that will own the database (it must have privileges for creating the database) |
| passwd | Password for oqner |
References IDLE_STATE.
| void * SQLThread | ( | ) |
The main processing thread, which pulls values from the queue and inserts them into the database asynchronously. It is started up by initialize();
References CONNECT_RETRY_ATTEMPTS, destroyVariable(), ERROR_EXIT, IDLE_STATE, META_NAME_PATTERN, Variable::next, SQL_TABLE_NAME_LEN, SUCCESS_RETURN, and TRUE.