Source
/*
** Zabbix
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
typedef struct
{
zbx_uint64_t autoreg_hostid;
zbx_uint64_t hostid;
char *host;
char *ip;
char *dns;
char *host_metadata;
int now;
unsigned short port;
unsigned short flag;
unsigned int connection_type;
}
zbx_autoreg_host_t;
extern char ZBX_PG_ESCAPE_BACKSLASH;
static int connection_failure;
extern unsigned char program_type;
void DBclose(void)
{
zbx_db_close();
}
int zbx_tsdb_table_has_compressed_chunks(const char *table_names)
{
DB_RESULT result;
int ret;
if (1 == ZBX_DB_TSDB_V1) {
result = DBselect("select null from timescaledb_information.compressed_chunk_stats where hypertable_name in (%s) and "
"compression_status='Compressed'", table_names);
}
else
{
result = DBselect("select null from timescaledb_information.chunks where hypertable_name in (%s) and "
"is_compressed='t'", table_names);
}
if (NULL != DBfetch(result))
ret = SUCCEED;
else
ret = FAIL;
DBfree_result(result);
return ret;
}
void zbx_tsdb_update_dbversion_info(struct zbx_db_version_info_t *db_version_info)
{
const char *history_tables, *trends_tables;
history_tables = (1 == ZBX_DB_TSDB_V1 ? ZBX_TSDB1_HISTORY_TABLES : ZBX_TSDB2_HISTORY_TABLES);
trends_tables = (1 == ZBX_DB_TSDB_V1 ? ZBX_TSDB1_TRENDS_TABLES : ZBX_TSDB2_TRENDS_TABLES);
db_version_info->history_compressed_chunks = (SUCCEED ==
zbx_tsdb_table_has_compressed_chunks(history_tables)) ? 1 : 0;