2018-01-24 14:28:48 +00:00
|
|
|
|
|
|
|
/*
|
2018-03-12 14:03:15 +00:00
|
|
|
* Odyssey.
|
2018-01-24 14:28:48 +00:00
|
|
|
*
|
2018-04-04 13:19:58 +00:00
|
|
|
* Scalable PostgreSQL connection pooler.
|
2020-04-02 11:00:56 +00:00
|
|
|
*/
|
2018-01-24 14:28:48 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2018-08-28 14:43:46 +00:00
|
|
|
#include <ctype.h>
|
2018-01-24 14:28:48 +00:00
|
|
|
#include <inttypes.h>
|
2018-08-28 14:43:46 +00:00
|
|
|
#include <assert.h>
|
2018-01-24 14:28:48 +00:00
|
|
|
|
|
|
|
#include <machinarium.h>
|
2018-08-28 14:43:46 +00:00
|
|
|
#include <kiwi.h>
|
|
|
|
#include <odyssey.h>
|
2018-01-24 14:28:48 +00:00
|
|
|
|
2020-04-02 11:00:56 +00:00
|
|
|
int
|
|
|
|
od_deploy(od_client_t *client, char *context)
|
2018-01-24 14:28:48 +00:00
|
|
|
{
|
2018-12-12 13:07:25 +00:00
|
|
|
od_instance_t *instance = client->global->instance;
|
2020-04-02 11:00:56 +00:00
|
|
|
od_server_t *server = client->server;
|
|
|
|
od_route_t *route = client->route;
|
2018-08-28 14:43:46 +00:00
|
|
|
|
2020-01-27 13:01:53 +00:00
|
|
|
if (route->id.physical_rep || route->id.logical_rep)
|
2019-04-13 10:26:47 +00:00
|
|
|
return 0;
|
|
|
|
|
2018-12-12 13:07:25 +00:00
|
|
|
/* compare and set options which are differs from server */
|
2020-04-02 11:00:56 +00:00
|
|
|
int query_count;
|
2018-12-13 11:18:20 +00:00
|
|
|
query_count = 0;
|
|
|
|
|
2018-02-05 13:39:20 +00:00
|
|
|
char query[512];
|
2020-04-02 11:00:56 +00:00
|
|
|
int query_size;
|
|
|
|
query_size =
|
|
|
|
kiwi_vars_cas(&client->vars, &server->vars, query, sizeof(query) - 1);
|
|
|
|
if (query_size > 0) {
|
2018-12-12 13:07:25 +00:00
|
|
|
query[query_size] = 0;
|
|
|
|
query_size++;
|
2018-12-13 11:18:20 +00:00
|
|
|
machine_msg_t *msg;
|
2019-01-23 15:43:52 +00:00
|
|
|
msg = kiwi_fe_write_query(NULL, query, query_size);
|
2018-08-28 14:43:46 +00:00
|
|
|
if (msg == NULL)
|
|
|
|
return -1;
|
2018-12-13 11:18:20 +00:00
|
|
|
int rc;
|
2019-01-23 15:43:52 +00:00
|
|
|
rc = od_write(&server->io, msg);
|
2018-02-05 13:39:20 +00:00
|
|
|
if (rc == -1)
|
|
|
|
return -1;
|
2018-12-12 13:07:25 +00:00
|
|
|
query_count++;
|
|
|
|
|
2020-04-02 11:00:56 +00:00
|
|
|
od_debug(
|
|
|
|
&instance->logger, context, client, server, "deploy: %s", query);
|
2018-02-05 13:39:20 +00:00
|
|
|
}
|
2018-08-28 14:43:46 +00:00
|
|
|
|
2018-02-05 13:39:20 +00:00
|
|
|
return query_count;
|
|
|
|
}
|