Source
int zbx_db_prepare_multiple_query(const char *query, const char *field_name, zbx_vector_uint64_t *ids, char **sql,
/*
** Copyright (C) 2001-2024 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
static zbx_dbconn_t *dbconn;
static int db_autoincrement;
void zbx_db_init_autoincrement_options(void)
{
db_autoincrement = 1;
}
/******************************************************************************
* *
* Purpose: connect to the database *
* *
* Parameters: flag - ZBX_DB_CONNECT_ONCE (try once and return the result), *
* ZBX_DB_CONNECT_EXIT (exit on failure) or *
* ZBX_DB_CONNECT_NORMAL (retry until connected) *
* *
* Return value: ZBX_DB_OK - successfully connected *
* ZBX_DB_DOWN - database is down *
* ZBX_DB_FAIL - failed to connect *
* *
******************************************************************************/
int zbx_db_connect(int flag)
{
if (NULL != dbconn)
THIS_SHOULD_NEVER_HAPPEN;
dbconn = zbx_dbconn_create();
zbx_dbconn_set_connect_options(dbconn, flag);
zbx_dbconn_set_autoincrement(dbconn, db_autoincrement);
return zbx_dbconn_open(dbconn);
}
/******************************************************************************
* *
* Purpose: close database connection *
* *
******************************************************************************/
void zbx_db_close(void)
{
if (NULL == dbconn)
{