diff options
author | Tatsuo Ishii | 2025-07-17 10:15:48 +0000 |
---|---|---|
committer | Tatsuo Ishii | 2025-07-17 10:15:48 +0000 |
commit | 468573ad3d19bee5634e362d17df357298d4b51a (patch) | |
tree | d6aa49c09c4f85420005d3db60a7070b846e17c0 | |
parent | 22552cffcc4106af3d9f759b96412a69d94ad237 (diff) |
Run pgindent.
148 files changed, 4880 insertions, 4446 deletions
diff --git a/src/auth/auth-scram.c b/src/auth/auth-scram.c index 3a0aa71c8..334e28f33 100644 --- a/src/auth/auth-scram.c +++ b/src/auth/auth-scram.c @@ -212,8 +212,8 @@ static char *build_client_first_message(fe_scram_state *state); static char *build_client_final_message(fe_scram_state *state); static bool verify_server_signature(fe_scram_state *state); static void calculate_client_proof(fe_scram_state *state, - const char *client_final_message_without_proof, - uint8 *result); + const char *client_final_message_without_proof, + uint8 *result); static void read_client_first_message(scram_state *state, char *input); static void read_client_final_message(scram_state *state, char *input); @@ -222,9 +222,9 @@ static char *build_server_final_message(scram_state *state); static bool verify_client_proof(scram_state *state); static bool verify_final_nonce(scram_state *state); static bool parse_scram_verifier(const char *verifier, int *iterations, - char **salt, uint8 *stored_key, uint8 *server_key); + char **salt, uint8 *stored_key, uint8 *server_key); static void mock_scram_verifier(const char *username, int *iterations, - char **salt, uint8 *stored_key, uint8 *server_key); + char **salt, uint8 *stored_key, uint8 *server_key); static bool is_scram_printable(char *p); static char *sanitize_char(char c); static char *GetMockAuthenticationNonce(void); @@ -1138,7 +1138,7 @@ build_server_final_message(scram_state *state) char *server_signature_base64; int siglen; scram_HMAC_ctx ctx; - char *res; + char *res; /* calculate ServerSignature */ scram_HMAC_init(&ctx, state->ServerKey, SCRAM_KEY_LEN); diff --git a/src/auth/pool_auth.c b/src/auth/pool_auth.c index 198d8c99e..8c17db4a7 100644 --- a/src/auth/pool_auth.c +++ b/src/auth/pool_auth.c @@ -58,36 +58,36 @@ #define MAX_SASL_PAYLOAD_LEN 1024 -static void pool_send_backend_key_data(POOL_CONNECTION * frontend, int pid, +static void pool_send_backend_key_data(POOL_CONNECTION *frontend, int pid, char *key, int32 keylen, int protoMajor); -static int do_clear_text_password(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, int reauth, int protoMajor); -static void pool_send_auth_fail(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp); -static int do_md5(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, int reauth, int protoMajor, - char *storedPassword, PasswordType passwordType); -static void send_md5auth_request(POOL_CONNECTION * frontend, int protoMajor, char *salt); -static int read_password_packet(POOL_CONNECTION * frontend, int protoMajor, char *password, int *pwdSize); -static int send_password_packet(POOL_CONNECTION * backend, int protoMajor, char *password); -static int send_auth_ok(POOL_CONNECTION * frontend, int protoMajor); -static void sendAuthRequest(POOL_CONNECTION * frontend, int protoMajor, int32 auth_req_type, char *extradata, int extralen); - -static int pg_SASL_continue(POOL_CONNECTION * backend, char *payload, int payloadlen, void *sasl_state, bool final); -static void *pg_SASL_init(POOL_CONNECTION * backend, char *payload, int payloadlen, char *username, char *storedPassword); -static bool do_SCRAM(POOL_CONNECTION * frontend, POOL_CONNECTION * backend, int protoMajor, int message_length, - char *username, char *storedPassword, PasswordType passwordType); -static void authenticate_frontend_md5(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, int reauth, int protoMajor); -static void authenticate_frontend_cert(POOL_CONNECTION * frontend); -static void authenticate_frontend_SCRAM(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, int reauth); -static void authenticate_frontend_clear_text(POOL_CONNECTION * frontend); -static bool get_auth_password(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, int reauth, - char **password, PasswordType *passwordType); -static void ProcessNegotiateProtocol(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp); +static int do_clear_text_password(POOL_CONNECTION *backend, POOL_CONNECTION *frontend, int reauth, int protoMajor); +static void pool_send_auth_fail(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp); +static int do_md5(POOL_CONNECTION *backend, POOL_CONNECTION *frontend, int reauth, int protoMajor, + char *storedPassword, PasswordType passwordType); +static void send_md5auth_request(POOL_CONNECTION *frontend, int protoMajor, char *salt); +static int read_password_packet(POOL_CONNECTION *frontend, int protoMajor, char *password, int *pwdSize); +static int send_password_packet(POOL_CONNECTION *backend, int protoMajor, char *password); +static int send_auth_ok(POOL_CONNECTION *frontend, int protoMajor); +static void sendAuthRequest(POOL_CONNECTION *frontend, int protoMajor, int32 auth_req_type, char *extradata, int extralen); + +static int pg_SASL_continue(POOL_CONNECTION *backend, char *payload, int payloadlen, void *sasl_state, bool final); +static void *pg_SASL_init(POOL_CONNECTION *backend, char *payload, int payloadlen, char *username, char *storedPassword); +static bool do_SCRAM(POOL_CONNECTION *frontend, POOL_CONNECTION *backend, int protoMajor, int message_length, + char *username, char *storedPassword, PasswordType passwordType); +static void authenticate_frontend_md5(POOL_CONNECTION *backend, POOL_CONNECTION *frontend, int reauth, int protoMajor); +static void authenticate_frontend_cert(POOL_CONNECTION *frontend); +static void authenticate_frontend_SCRAM(POOL_CONNECTION *backend, POOL_CONNECTION *frontend, int reauth); +static void authenticate_frontend_clear_text(POOL_CONNECTION *frontend); +static bool get_auth_password(POOL_CONNECTION *backend, POOL_CONNECTION *frontend, int reauth, + char **password, PasswordType *passwordType); +static void ProcessNegotiateProtocol(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp); /* * Do authentication. Assuming the only caller is * make_persistent_db_connection(). */ void -connection_do_auth(POOL_CONNECTION_POOL_SLOT * cp, char *password) +connection_do_auth(POOL_CONNECTION_POOL_SLOT *cp, char *password) { char kind; int length; @@ -243,8 +243,8 @@ connection_do_auth(POOL_CONNECTION_POOL_SLOT * cp, char *password) switch (kind) { - char *p; - int32 keylen; + char *p; + int32 keylen; case 'K': /* backend key data */ keydata_done = true; @@ -259,7 +259,7 @@ connection_do_auth(POOL_CONNECTION_POOL_SLOT * cp, char *password) { ereport(ERROR, (errmsg("failed to authenticate"), - errdetail("invalid backend key data length. received %d bytes exceeding %d", + errdetail("invalid backend key data length. received %d bytes exceeding %d", ntohl(length), MAX_CANCELKEY_LENGTH))); } @@ -332,7 +332,7 @@ connection_do_auth(POOL_CONNECTION_POOL_SLOT * cp, char *password) * 0. */ int -pool_do_auth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) +pool_do_auth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp) { signed char kind; int pid; @@ -342,9 +342,9 @@ pool_do_auth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) int i; int message_length = 0; StartupPacket *sp; - int32 keylen; /* cancel key length */ - char cancel_key[MAX_CANCELKEY_LENGTH]; - char *p; + int32 keylen; /* cancel key length */ + char cancel_key[MAX_CANCELKEY_LENGTH]; + char *p; protoMajor = MAIN_CONNECTION(cp)->sp->major; @@ -484,9 +484,8 @@ read_kind: &password, &passwordType) == false) { /* - * We do not have any password, we can still get the password - * from client using plain text authentication if it is - * allowed by user + * We do not have any password, we can still get the password from + * client using plain text authentication if it is allowed by user */ if (frontend->pool_hba == NULL && pool_config->allow_clear_text_frontend_auth) { @@ -741,7 +740,7 @@ read_kind: } } else - keylen = 4; + keylen = 4; elog(DEBUG1, "cancel key length: %d", keylen); @@ -821,11 +820,11 @@ read_kind: * throws ereport. */ int -pool_do_reauth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) +pool_do_reauth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp) { int protoMajor; int msglen; - POOL_CONNECTION_POOL_SLOT *sp; + POOL_CONNECTION_POOL_SLOT *sp; protoMajor = MAJOR(cp); @@ -900,7 +899,7 @@ pool_do_reauth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) * send authentication failure message text to frontend */ static void -pool_send_auth_fail(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) +pool_send_auth_fail(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp) { int messagelen; char *errmessage; @@ -925,7 +924,7 @@ pool_send_auth_fail(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) * Send backend key data to frontend. */ static void -pool_send_backend_key_data(POOL_CONNECTION * frontend, int pid, +pool_send_backend_key_data(POOL_CONNECTION *frontend, int pid, char *key, int32 keylen, int protoMajor) { char kind; @@ -946,7 +945,7 @@ pool_send_backend_key_data(POOL_CONNECTION * frontend, int pid, } static void -authenticate_frontend_clear_text(POOL_CONNECTION * frontend) +authenticate_frontend_clear_text(POOL_CONNECTION *frontend) { static int size; char password[MAX_PASSWORD_SIZE]; @@ -1033,7 +1032,7 @@ authenticate_frontend_clear_text(POOL_CONNECTION * frontend) * perform clear text password authentication */ static int -do_clear_text_password(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, int reauth, int protoMajor) +do_clear_text_password(POOL_CONNECTION *backend, POOL_CONNECTION *frontend, int reauth, int protoMajor) { static int size; char *pwd = NULL; @@ -1066,17 +1065,16 @@ do_clear_text_password(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, in else if (!rtn || frontend->pwd_size == 0) { /* - * We do not have any password, we can still get the password - * from client using plain text authentication if it is - * allowed by user + * We do not have any password, we can still get the password from + * client using plain text authentication if it is allowed by user */ if (frontend->pool_hba == NULL || frontend->pool_hba->auth_method == uaPassword || - pool_config->allow_clear_text_frontend_auth ) + pool_config->allow_clear_text_frontend_auth) { ereport(DEBUG1, - (errmsg("using clear text authentication with frontend"), + (errmsg("using clear text authentication with frontend"), errdetail("backend is using password authentication"))); authenticate_frontend_clear_text(frontend); @@ -1086,8 +1084,8 @@ do_clear_text_password(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, in { ereport(FATAL, (return_code(2), - errmsg("clear text password authentication failed"), - errdetail("unable to get the password for user: \"%s\"", frontend->username))); + errmsg("clear text password authentication failed"), + errdetail("unable to get the password for user: \"%s\"", frontend->username))); } } } @@ -1157,7 +1155,7 @@ do_clear_text_password(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, in * password in the pool_passwd file. */ static void -authenticate_frontend_SCRAM(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, int reauth) +authenticate_frontend_SCRAM(POOL_CONNECTION *backend, POOL_CONNECTION *frontend, int reauth) { void *scram_opaq; char *output = NULL; @@ -1172,7 +1170,7 @@ authenticate_frontend_SCRAM(POOL_CONNECTION * backend, POOL_CONNECTION * fronten PasswordType storedPasswordType = PASSWORD_TYPE_UNKNOWN; char *storedPassword = NULL; - if (get_auth_password(backend, frontend, reauth,&storedPassword, &storedPasswordType) == false) + if (get_auth_password(backend, frontend, reauth, &storedPassword, &storedPasswordType) == false) { ereport(FATAL, (return_code(2), @@ -1341,7 +1339,7 @@ authenticate_frontend_SCRAM(POOL_CONNECTION * backend, POOL_CONNECTION * fronten * Authenticate frontend using pool_hba.conf */ void -authenticate_frontend(POOL_CONNECTION * frontend) +authenticate_frontend(POOL_CONNECTION *frontend) { switch (frontend->pool_hba->auth_method) { @@ -1379,7 +1377,7 @@ authenticate_frontend(POOL_CONNECTION * frontend) #ifdef USE_SSL static void -authenticate_frontend_cert(POOL_CONNECTION * frontend) +authenticate_frontend_cert(POOL_CONNECTION *frontend) { if (frontend->client_cert_loaded == true && frontend->cert_cn) { @@ -1406,7 +1404,7 @@ authenticate_frontend_cert(POOL_CONNECTION * frontend) } #else static void -authenticate_frontend_cert(POOL_CONNECTION * frontend) +authenticate_frontend_cert(POOL_CONNECTION *frontend) { ereport(ERROR, (errmsg("CERT authentication failed"), @@ -1415,7 +1413,7 @@ authenticate_frontend_cert(POOL_CONNECTION * frontend) #endif static void -authenticate_frontend_md5(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, int reauth, int protoMajor) +authenticate_frontend_md5(POOL_CONNECTION *backend, POOL_CONNECTION *frontend, int reauth, int protoMajor) { char salt[4]; static int size; @@ -1427,7 +1425,7 @@ authenticate_frontend_md5(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, PasswordType storedPasswordType = PASSWORD_TYPE_UNKNOWN; char *storedPassword = NULL; - if (get_auth_password(backend, frontend, reauth,&storedPassword, &storedPasswordType) == false) + if (get_auth_password(backend, frontend, reauth, &storedPassword, &storedPasswordType) == false) { ereport(FATAL, (return_code(2), @@ -1503,7 +1501,7 @@ authenticate_frontend_md5(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, * it. */ static bool -get_auth_password(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, int reauth, +get_auth_password(POOL_CONNECTION *backend, POOL_CONNECTION *frontend, int reauth, char **password, PasswordType *passwordType) { /* First preference is to use the pool_passwd file */ @@ -1552,7 +1550,7 @@ get_auth_password(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, int rea * perform MD5 authentication */ static int -do_md5(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, int reauth, int protoMajor, +do_md5(POOL_CONNECTION *backend, POOL_CONNECTION *frontend, int reauth, int protoMajor, char *storedPassword, PasswordType passwordType) { char salt[4]; @@ -1669,7 +1667,7 @@ do_md5(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, int reauth, int pr * Send an authentication request packet to the frontend. */ static void -sendAuthRequest(POOL_CONNECTION * frontend, int protoMajor, int32 auth_req_type, char *extradata, int extralen) +sendAuthRequest(POOL_CONNECTION *frontend, int protoMajor, int32 auth_req_type, char *extradata, int extralen) { int kind = htonl(auth_req_type); @@ -1692,7 +1690,7 @@ sendAuthRequest(POOL_CONNECTION * frontend, int protoMajor, int32 auth_req_type, * Send md5 authentication request packet to frontend */ static void -send_md5auth_request(POOL_CONNECTION * frontend, int protoMajor, char *salt) +send_md5auth_request(POOL_CONNECTION *frontend, int protoMajor, char *salt) { sendAuthRequest(frontend, protoMajor, AUTH_REQ_MD5, salt, 4); } @@ -1702,7 +1700,7 @@ send_md5auth_request(POOL_CONNECTION * frontend, int protoMajor, char *salt) * Read password packet from frontend */ static int -read_password_packet(POOL_CONNECTION * frontend, int protoMajor, char *password, int *pwdSize) +read_password_packet(POOL_CONNECTION *frontend, int protoMajor, char *password, int *pwdSize) { int size; @@ -1755,7 +1753,7 @@ read_password_packet(POOL_CONNECTION * frontend, int protoMajor, char *password, * "password" must be null-terminated. */ static int -send_password_packet(POOL_CONNECTION * backend, int protoMajor, char *password) +send_password_packet(POOL_CONNECTION *backend, int protoMajor, char *password) { int size; int len; @@ -1811,7 +1809,7 @@ send_password_packet(POOL_CONNECTION * backend, int protoMajor, char *password) * Send auth ok to frontend */ static int -send_auth_ok(POOL_CONNECTION * frontend, int protoMajor) +send_auth_ok(POOL_CONNECTION *frontend, int protoMajor) { int msglen; @@ -1850,7 +1848,7 @@ pool_random_salt(char *md5Salt) } static bool -do_SCRAM(POOL_CONNECTION * frontend, POOL_CONNECTION * backend, int protoMajor, int message_length, +do_SCRAM(POOL_CONNECTION *frontend, POOL_CONNECTION *backend, int protoMajor, int message_length, char *username, char *storedPassword, PasswordType passwordType) { /* read the packet first */ @@ -1979,7 +1977,7 @@ do_SCRAM(POOL_CONNECTION * frontend, POOL_CONNECTION * backend, int protoMajor, } static void * -pg_SASL_init(POOL_CONNECTION * backend, char *payload, int payloadlen, char *username, char *storedPassword) +pg_SASL_init(POOL_CONNECTION *backend, char *payload, int payloadlen, char *username, char *storedPassword) { char *initialresponse = NULL; int initialresponselen; @@ -2082,7 +2080,7 @@ pg_SASL_init(POOL_CONNECTION * backend, char *payload, int payloadlen, char *use * the protocol. */ static int -pg_SASL_continue(POOL_CONNECTION * backend, char *payload, int payloadlen, void *sasl_state, bool final) +pg_SASL_continue(POOL_CONNECTION *backend, char *payload, int payloadlen, void *sasl_state, bool final) { char *output; int outputlen; @@ -2141,21 +2139,21 @@ pg_SASL_continue(POOL_CONNECTION * backend, char *payload, int payloadlen, void static void ProcessNegotiateProtocol(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp) { - int32 len; - int32 savelen; - int32 protoMajor; - int32 protoMinor; - int32 protov; - bool forwardMsg = false; - int i; + int32 len; + int32 savelen; + int32 protoMajor; + int32 protoMinor; + int32 protov; + bool forwardMsg = false; + int i; elog(DEBUG1, "Forwarding NegotiateProtocol message to frontend"); pool_write(frontend, "v", 1); /* forward message kind */ - savelen = len = pool_read_int(cp); /* message length including self */ + savelen = len = pool_read_int(cp); /* message length including self */ pool_write(frontend, &len, 4); /* forward message length */ - len = ntohl(len) - 4; /* length of rest of the message */ - protov = pool_read_int(cp); /* read protocol version */ - protoMajor = PG_PROTOCOL_MAJOR(ntohl(protov)); /* protocol major version */ + len = ntohl(len) - 4; /* length of rest of the message */ + protov = pool_read_int(cp); /* read protocol version */ + protoMajor = PG_PROTOCOL_MAJOR(ntohl(protov)); /* protocol major version */ protoMinor = PG_PROTOCOL_MINOR(ntohl(protov)); /* protocol minor version */ pool_write(frontend, &protov, 4); /* forward protocol version */ elog(DEBUG1, "protocol verion offered: major: %d minor: %d", protoMajor, protoMinor); @@ -2164,15 +2162,16 @@ ProcessNegotiateProtocol(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp) { if (VALID_BACKEND(i)) { - POOL_CONNECTION_POOL_SLOT *sp; - char *p; - char *np; - Size nplen; + POOL_CONNECTION_POOL_SLOT *sp; + char *p; + char *np; + Size nplen; p = pool_read2(CONNECTION(cp, i), len); if (!forwardMsg) { - pool_write_and_flush(frontend, p, len); /* forward rest of message */ + pool_write_and_flush(frontend, p, len); /* forward rest of + * message */ forwardMsg = true; } /* save negatiate protocol version */ @@ -2181,10 +2180,10 @@ ProcessNegotiateProtocol(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp) sp->negotiated_minor = protoMinor; /* save negatiate protocol message */ - nplen = 1 + /* message kind */ + nplen = 1 + /* message kind */ sizeof(savelen) + /* message length */ sizeof(protov) + /* protocol version */ - len; /* rest of message */ + len; /* rest of message */ /* allocate message area */ sp->negotiateProtocolMsg = MemoryContextAlloc(TopMemoryContext, nplen); np = sp->negotiateProtocolMsg; diff --git a/src/auth/pool_hba.c b/src/auth/pool_hba.c index 202195b43..8daf74a97 100644 --- a/src/auth/pool_hba.c +++ b/src/auth/pool_hba.c @@ -109,37 +109,37 @@ static HbaToken *copy_hba_token(HbaToken *in); static HbaToken *make_hba_token(const char *token, bool quoted); static bool parse_hba_auth_opt(char *name, char *val, HbaLine *hbaline, - int elevel, char **err_msg); + int elevel, char **err_msg); static MemoryContext tokenize_file(const char *filename, FILE *file, - List **tok_lines, int elevel); -static void sendAuthRequest(POOL_CONNECTION * frontend, AuthRequest areq); -static void auth_failed(POOL_CONNECTION * frontend); -static bool hba_getauthmethod(POOL_CONNECTION * frontend); -static bool check_hba(POOL_CONNECTION * frontend); + List **tok_lines, int elevel); +static void sendAuthRequest(POOL_CONNECTION *frontend, AuthRequest areq); +static void auth_failed(POOL_CONNECTION *frontend); +static bool hba_getauthmethod(POOL_CONNECTION *frontend); +static bool check_hba(POOL_CONNECTION *frontend); static bool check_user(char *user, List *tokens); static bool check_db(const char *dbname, const char *user, List *tokens); static List *tokenize_inc_file(List *tokens, - const char *outer_filename, - const char *inc_filename, - int elevel, - char **err_msg); + const char *outer_filename, + const char *inc_filename, + int elevel, + char **err_msg); static bool - check_hostname(POOL_CONNECTION * frontend, const char *hostname); + check_hostname(POOL_CONNECTION *frontend, const char *hostname); static bool check_ip(SockAddr *raddr, struct sockaddr *addr, struct sockaddr *mask); static bool check_same_host_or_net(SockAddr *raddr, IPCompareMethod method); static void check_network_callback(struct sockaddr *addr, struct sockaddr *netmask, - void *cb_data); + void *cb_data); static HbaLine *parse_hba_line(TokenizedLine *tok_line, int elevel); static bool pg_isblank(const char c); static bool next_token(char **lineptr, char *buf, int bufsz, - bool *initial_quote, bool *terminating_comma, - int elevel, char **err_msg); + bool *initial_quote, bool *terminating_comma, + int elevel, char **err_msg); static List *next_field_expand(const char *filename, char **lineptr, - int elevel, char **err_msg); + int elevel, char **err_msg); #ifdef NOT_USED static POOL_STATUS CheckUserExist(char *username); #endif @@ -154,7 +154,7 @@ static POOL_STATUS CheckUserExist(char *username); #define PGPOOL_PAM_SERVICE "pgpool" /* Service name passed to PAM */ -static POOL_STATUS CheckPAMAuth(POOL_CONNECTION * frontend, char *user, char *password); +static POOL_STATUS CheckPAMAuth(POOL_CONNECTION *frontend, char *user, char *password); static int pam_passwd_conv_proc(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr); static struct pam_conv pam_passwd_conv = { @@ -163,7 +163,7 @@ static struct pam_conv pam_passwd_conv = { }; static char *pam_passwd = NULL; /* Workaround for Solaris 2.6 brokenness */ -static POOL_CONNECTION * pam_frontend_kludge; /* Workaround for passing +static POOL_CONNECTION *pam_frontend_kludge; /* Workaround for passing * POOL_CONNECTION *frontend * into pam_passwd_conv_proc */ #endif /* USE_PAM */ @@ -189,7 +189,7 @@ static POOL_STATUS CheckLDAPAuth(POOL_CONNECTION *frontend); * so declare a prototype here in "#if defined(USE_PAM or USE_LDAP)" to avoid * compilation warning. */ -static char *recv_password_packet(POOL_CONNECTION * frontend); +static char *recv_password_packet(POOL_CONNECTION *frontend); #endif /* USE_PAM or USE_LDAP */ /* @@ -761,6 +761,7 @@ parse_hba_line(TokenizedLine *tok_line, int elevel) } #ifdef USE_LDAP + /* * Check if the selected authentication method has any mandatory arguments * that are not set. @@ -1166,7 +1167,7 @@ parse_hba_auth_opt(char *name, char *val, HbaLine *hbaline, * do frontend <-> pgpool authentication based on pool_hba.conf */ void -ClientAuthentication(POOL_CONNECTION * frontend) +ClientAuthentication(POOL_CONNECTION *frontend) { POOL_STATUS status = POOL_END; MemoryContext oldContext; @@ -1182,10 +1183,9 @@ ClientAuthentication(POOL_CONNECTION * frontend) /* * Get the password for the user if it is stored in the pool_password - * file - * authentication process is called in the temporary memory - * context, but password mappings has to live till the life time - * of frontend connection, so call the pool_get_user_credentials in + * file authentication process is called in the temporary memory + * context, but password mappings has to live till the life time of + * frontend connection, so call the pool_get_user_credentials in * ProcessLoopContext memory context */ oldContext = MemoryContextSwitchTo(ProcessLoopContext); @@ -1215,7 +1215,7 @@ ClientAuthentication(POOL_CONNECTION * frontend) #ifdef USE_SSL ereport(FATAL, - (return_code(2), + (return_code(2), errmsg("client authentication failed"), errdetail("no pool_hba.conf entry for host \"%s\", user \"%s\", database \"%s\", %s", hostinfo, frontend->username, frontend->database, @@ -1323,7 +1323,7 @@ ClientAuthentication(POOL_CONNECTION * frontend) static void -sendAuthRequest(POOL_CONNECTION * frontend, AuthRequest areq) +sendAuthRequest(POOL_CONNECTION *frontend, AuthRequest areq) { int wsize; /* number of bytes to write */ int areq_nbo; /* areq in network byte order */ @@ -1371,7 +1371,7 @@ sendAuthRequest(POOL_CONNECTION * frontend, AuthRequest areq) * Returns NULL if couldn't get password, else palloc'd string. */ static char * -recv_password_packet(POOL_CONNECTION * frontend) +recv_password_packet(POOL_CONNECTION *frontend) { int rsize; char *passwd; @@ -1421,7 +1421,7 @@ recv_password_packet(POOL_CONNECTION * frontend) * Tell the user the authentication failed. */ static void -auth_failed(POOL_CONNECTION * frontend) +auth_failed(POOL_CONNECTION *frontend) { int messagelen; char *errmessage; @@ -1521,7 +1521,7 @@ auth_failed(POOL_CONNECTION * frontend) * we return true and method = uaReject. */ static bool -hba_getauthmethod(POOL_CONNECTION * frontend) +hba_getauthmethod(POOL_CONNECTION *frontend) { if (check_hba(frontend)) return true; @@ -1535,7 +1535,7 @@ hba_getauthmethod(POOL_CONNECTION * frontend) * request. */ static bool -check_hba(POOL_CONNECTION * frontend) +check_hba(POOL_CONNECTION *frontend) { ListCell *line; HbaLine *hba; @@ -1672,7 +1672,7 @@ hostname_match(const char *pattern, const char *actual_hostname) * Check to see if a connecting IP matches a given host name. */ static bool -check_hostname(POOL_CONNECTION * frontend, const char *hostname) +check_hostname(POOL_CONNECTION *frontend, const char *hostname) { struct addrinfo *gai_result, *gai; @@ -2363,7 +2363,8 @@ pam_passwd_conv_proc(int num_msg, const struct pam_message **msg, /* * Check authentication against PAM. */ -static POOL_STATUS CheckPAMAuth(POOL_CONNECTION * frontend, char *user, char *password) +static POOL_STATUS +CheckPAMAuth(POOL_CONNECTION *frontend, char *user, char *password) { int retval; pam_handle_t *pamh = NULL; @@ -2379,8 +2380,8 @@ static POOL_STATUS CheckPAMAuth(POOL_CONNECTION * frontend, char *user, char *pa * later used inside the PAM conversation to pass the password to the * authentication module. */ - pam_passwd_conv.appdata_ptr = (char *) password; /* from password above, - * not allocated */ + pam_passwd_conv.appdata_ptr = (char *) password; /* from password above, + * not allocated */ /* Optionally, one can set the service name in pool_hba.conf */ if (frontend->pool_hba->pamservice && frontend->pool_hba->pamservice[0] != '\0') @@ -2673,7 +2674,8 @@ FormatSearchFilter(const char *pattern, const char *user_name) /* * Check authentication against LDAP. */ -static POOL_STATUS CheckLDAPAuth(POOL_CONNECTION * frontend) +static POOL_STATUS +CheckLDAPAuth(POOL_CONNECTION *frontend) { char *passwd; LDAP *ldap; @@ -2722,7 +2724,7 @@ static POOL_STATUS CheckLDAPAuth(POOL_CONNECTION * frontend) passwd = recv_password_packet(frontend); if (passwd == NULL) - return -2; /* client wouldn't send password */ + return -2; /* client wouldn't send password */ if (InitializeLDAPConnection(frontend, &ldap) == -1) { @@ -2925,7 +2927,8 @@ static POOL_STATUS CheckLDAPAuth(POOL_CONNECTION * frontend) #endif /* USE_LDAP */ #ifdef NOT_USED -static POOL_STATUS CheckUserExist(char *username) +static POOL_STATUS +CheckUserExist(char *username) { char *passwd; diff --git a/src/auth/pool_passwd.c b/src/auth/pool_passwd.c index 41bd38f07..91b0efd00 100644 --- a/src/auth/pool_passwd.c +++ b/src/auth/pool_passwd.c @@ -58,7 +58,8 @@ pool_init_pool_passwd(char *pool_passwd_filename, POOL_PASSWD_MODE mode) if (pool_passwd_filename == NULL) { - saved_passwd_filename[0] = '\0'; /* indicate pool_passwd is disabled */ + saved_passwd_filename[0] = '\0'; /* indicate pool_passwd is + * disabled */ return; } @@ -102,10 +103,10 @@ pool_create_passwdent(char *username, char *passwd) { #define LINE_LEN \ MAX_USER_NAME_LEN + 1 + MAX_POOL_PASSWD_LEN + 2 - char linebuf[LINE_LEN]; - char *writebuf = NULL; - int len; - bool updated = false; + char linebuf[LINE_LEN]; + char *writebuf = NULL; + int len; + bool updated = false; if (!passwd_fd) ereport(ERROR, @@ -124,8 +125,8 @@ pool_create_passwdent(char *username, char *passwd) while (!feof(passwd_fd) && !ferror(passwd_fd)) { - char *t = linebuf; - int len; + char *t = linebuf; + int len; if (fgets(linebuf, sizeof(linebuf), passwd_fd) == NULL) break; @@ -162,7 +163,7 @@ pool_create_passwdent(char *username, char *passwd) strcat(writebuf, linebuf); } - if(!writebuf) + if (!writebuf) return 0; fclose(passwd_fd); @@ -203,7 +204,7 @@ pool_get_passwd(char *username) { if (strlen(saved_passwd_filename)) ereport(ERROR, - (errmsg("unable to get password, password file descriptor is NULL"))); + (errmsg("unable to get password, password file descriptor is NULL"))); else return NULL; } @@ -355,7 +356,7 @@ pool_get_user_credentials(char *username) { if (strlen(saved_passwd_filename)) ereport(WARNING, - (errmsg("unable to get password, password file descriptor is NULL"))); + (errmsg("unable to get password, password file descriptor is NULL"))); return NULL; } @@ -416,7 +417,7 @@ pool_get_user_credentials(char *username) } void -delete_passwordMapping(PasswordMapping * pwdMapping) +delete_passwordMapping(PasswordMapping *pwdMapping) { if (!pwdMapping) return; @@ -476,8 +477,8 @@ get_pgpool_config_user_password(char *username, char *password_in_config) PasswordMapping *password_mapping = NULL; /* - * if the password specified in config is empty string or NULL look for the - * password in pool_passwd file + * if the password specified in config is empty string or NULL look for + * the password in pool_passwd file */ if (password_in_config == NULL || strlen(password_in_config) == 0) { @@ -525,7 +526,7 @@ get_pgpool_config_user_password(char *username, char *password_in_config) /* convert the TEXT prefixed password to plain text password */ passwordType = PASSWORD_TYPE_PLAINTEXT; if (password) - password = (char*)(password + strlen(PASSWORD_TEXT_PREFIX)); + password = (char *) (password + strlen(PASSWORD_TEXT_PREFIX)); } if (password && strlen(password) && (passwordType != PASSWORD_TYPE_PLAINTEXT && @@ -634,11 +635,11 @@ read_pool_key(char *key_file_path) return NULL; /* - * To prevent file-swapping due to file race conditions, - * we open the key file before checking it by stat(). + * To prevent file-swapping due to file race conditions, we open the key + * file before checking it by stat(). */ /* If password file cannot be opened, ignore it. */ - if ( (fp = fopen(key_file_path, "r")) == NULL) + if ((fp = fopen(key_file_path, "r")) == NULL) return NULL; if (fstat(fileno(fp), &stat_buf) != 0) @@ -707,12 +708,13 @@ check_password_type_is_not_md5(char *username, char *password_in_config) PasswordType passwordType = PASSWORD_TYPE_UNKNOWN; /* - * if the password specified in config is empty string or NULL look for the - * password in pool_passwd file + * if the password specified in config is empty string or NULL look for + * the password in pool_passwd file */ if (password_in_config == NULL || strlen(password_in_config) == 0) { PasswordMapping *password_mapping = NULL; + password_mapping = pool_get_user_credentials(username); if (password_mapping == NULL) { @@ -726,7 +728,7 @@ check_password_type_is_not_md5(char *username, char *password_in_config) passwordType = get_password_type(password_in_config); } - /* if the password type is MD5 hash return -1*/ + /* if the password type is MD5 hash return -1 */ if (passwordType == PASSWORD_TYPE_MD5) { return -1; diff --git a/src/config/pool_config_variables.c b/src/config/pool_config_variables.c index 83ce0c2bf..31f42caa9 100644 --- a/src/config/pool_config_variables.c +++ b/src/config/pool_config_variables.c @@ -85,22 +85,22 @@ static bool config_post_processor(ConfigContext context, int elevel); static void sort_config_vars(void); static bool setConfigOptionArrayVarWithConfigDefault(struct config_generic *record, const char *name, - const char *value, ConfigContext context, int elevel); + const char *value, ConfigContext context, int elevel); static bool setConfigOption(const char *name, const char *value, - ConfigContext context, GucSource source, int elevel); + ConfigContext context, GucSource source, int elevel); static bool setConfigOptionVar(struct config_generic *record, const char *name, int index_val, - const char *value, ConfigContext context, GucSource source, int elevel); + const char *value, ConfigContext context, GucSource source, int elevel); static bool get_index_in_var_name(struct config_generic *record, - const char *name, int *index, int elevel); + const char *name, int *index, int elevel); static bool MakeUserRedirectListRegex(char *newval, int elevel); static bool MakeDBRedirectListRegex(char *newval, int elevel); static bool MakeAppRedirectListRegex(char *newval, int elevel); static bool MakeDMLAdaptiveObjectRelationList(char *newval, int elevel); -static char* getParsedToken(char *token, DBObjectTypes *object_type); +static char *getParsedToken(char *token, DBObjectTypes *object_type); static bool check_redirect_node_spec(char *node_spec); static char **get_list_from_string(const char *str, const char *delimi, int *n); @@ -180,7 +180,7 @@ static bool convert_to_base_unit(double value, const char *unit, #ifndef POOL_PRIVATE static void convert_int_from_base_unit(int64 base_value, int base_unit, - int64 *value, const char **unit); + int64 *value, const char **unit); /* These functions are used to provide Hints for enum type config parameters and @@ -194,12 +194,12 @@ static const char *config_enum_lookup_by_value(struct config_enum *record, int v static char *ShowOption(struct config_generic *record, int index, int elevel); static char *config_enum_get_options(struct config_enum *record, const char *prefix, - const char *suffix, const char *separator); -static void send_row_description_for_detail_view(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend); -static int send_grouped_type_variable_to_frontend(struct config_grouped_array_var *grouped_record, - POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend); -static int send_array_type_variable_to_frontend(struct config_generic *record, - POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend); + const char *suffix, const char *separator); +static void send_row_description_for_detail_view(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); +static int send_grouped_type_variable_to_frontend(struct config_grouped_array_var *grouped_record, + POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); +static int send_array_type_variable_to_frontend(struct config_generic *record, + POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); #endif @@ -300,17 +300,20 @@ static const struct config_enum_entry relcache_query_target_options[] = { }; static const struct config_enum_entry check_temp_table_options[] = { - {"catalog", CHECK_TEMP_CATALOG, false}, /* search system catalogs */ - {"trace", CHECK_TEMP_TRACE, false}, /* tracing temp tables */ - {"none", CHECK_TEMP_NONE, false}, /* do not check temp tables */ - {"on", CHECK_TEMP_ON, false}, /* same as CHECK_TEMP_CATALOG. Just for backward compatibility. */ - {"off", CHECK_TEMP_OFF, false}, /* same as CHECK_TEMP_NONE. Just for backward compatibility. */ + {"catalog", CHECK_TEMP_CATALOG, false}, /* search system catalogs */ + {"trace", CHECK_TEMP_TRACE, false}, /* tracing temp tables */ + {"none", CHECK_TEMP_NONE, false}, /* do not check temp tables */ + {"on", CHECK_TEMP_ON, false}, /* same as CHECK_TEMP_CATALOG. Just for + * backward compatibility. */ + {"off", CHECK_TEMP_OFF, false}, /* same as CHECK_TEMP_NONE. Just for + * backward compatibility. */ {NULL, 0, false} }; static const struct config_enum_entry log_backend_messages_options[] = { - {"none", BGMSG_NONE, false}, /* turn off logging */ - {"terse", BGMSG_TERSE, false}, /* terse logging (repeated messages are collapsed into count */ + {"none", BGMSG_NONE, false}, /* turn off logging */ + {"terse", BGMSG_TERSE, false}, /* terse logging (repeated messages are + * collapsed into count */ {"verbose", BGMSG_VERBOSE, false}, /* always log each message */ {NULL, 0, false} }; @@ -810,8 +813,8 @@ static struct config_bool ConfigureNamesBool[] = { {"health_check_test", CFGCXT_INIT, HEALTH_CHECK_CONFIG, - "If on, enable health check testing.", - CONFIG_VAR_TYPE_BOOL, false, 0 + "If on, enable health check testing.", + CONFIG_VAR_TYPE_BOOL, false, 0 }, &g_pool_config.health_check_test, false, @@ -1825,7 +1828,7 @@ static struct config_string_array ConfigureNamesStringArray[] = CONFIG_VAR_TYPE_STRING_ARRAY, true, VAR_PART_OF_GROUP, MAX_NUM_BACKENDS }, NULL, - "", /* for ALWAYS_PRIMARY */ + "", /* for ALWAYS_PRIMARY */ EMPTY_CONFIG_STRING, BackendFlagsAssignFunc, NULL, BackendFlagsShowFunc, BackendSlotEmptyCheckFunc }, @@ -2285,7 +2288,7 @@ static struct config_int ConfigureNamesInt[] = CONFIG_VAR_TYPE_INT, false, GUC_UNIT_MIN }, &g_pool_config.log_rotation_age, - 1440,/*1 day*/ + 1440, /* 1 day */ 0, INT_MAX, NULL, NULL, NULL }, @@ -2296,7 +2299,7 @@ static struct config_int ConfigureNamesInt[] = }, &g_pool_config.log_rotation_size, 10 * 1024, - 0, INT_MAX/1024, + 0, INT_MAX / 1024, NULL, NULL, NULL }, { @@ -3106,7 +3109,7 @@ get_list_from_string(const char *str, const char *delimi, int *n) for (token = strtok(temp_string, delimi); token != NULL; token = strtok(NULL, delimi)) { - int i; + int i; /* skip leading whitespace */ while (isspace(*token)) @@ -3114,7 +3117,8 @@ get_list_from_string(const char *str, const char *delimi, int *n) /* skip trailing whitespace */ i = strlen(token) - 1; - while (i >= 0 && isspace(token[i])) { + while (i >= 0 && isspace(token[i])) + { token[i] = '\0'; i--; } @@ -3186,7 +3190,8 @@ get_list_from_string_regex_delim(const char *input, const char *delimi, int *n) } else if (*str_temp == *delimi) { - char *output = (char *) palloc(j + 1); + char *output = (char *) palloc(j + 1); + StrNCpy(output, buf, j + 1); /* replace escape character of "'" */ @@ -3642,7 +3647,7 @@ setConfigOptionVar(struct config_generic *record, const char *name, int index_va if (value != NULL) { - int64 newval64; + int64 newval64; const char *hintmsg; if (!parse_int(value, &newval64, @@ -3654,7 +3659,7 @@ setConfigOptionVar(struct config_generic *record, const char *name, int index_va hintmsg ? errhint("%s", _(hintmsg)) : 0)); return false; } - newval = (int)newval64; + newval = (int) newval64; } else if (source == PGC_S_DEFAULT) { @@ -3752,7 +3757,7 @@ setConfigOptionVar(struct config_generic *record, const char *name, int index_va if (value != NULL) { - int64 newval64; + int64 newval64; const char *hintmsg; if (!parse_int(value, &newval64, @@ -3764,7 +3769,7 @@ setConfigOptionVar(struct config_generic *record, const char *name, int index_va hintmsg ? errhint("%s", _(hintmsg)) : 0)); return false; } - newval = (int)newval64; + newval = (int) newval64; } else if (source == PGC_S_DEFAULT) { @@ -4551,7 +4556,7 @@ BackendFlagsShowFunc(int index) if (*buffer == '\0') snprintf(buffer, sizeof(buffer), "ALWAYS_PRIMARY"); else - snprintf(buffer+strlen(buffer), sizeof(buffer), "|ALWAYS_PRIMARY"); + snprintf(buffer + strlen(buffer), sizeof(buffer), "|ALWAYS_PRIMARY"); } return buffer; } @@ -4577,7 +4582,7 @@ WdSlotEmptyCheckFunc(int index) static bool WdIFSlotEmptyCheckFunc(int index) { - return (g_pool_config.hb_ifs[index].dest_port == 0); + return (g_pool_config.hb_ifs[index].dest_port == 0); } static const char * @@ -4809,6 +4814,7 @@ FailOverOnBackendErrorAssignMessage(ConfigContext scontext, bool newval, int ele g_pool_config.failover_on_backend_error = newval; return true; } + /* * Throws warning for if someone uses the removed delegate_IP * configuration parameter and set the value to delegate_ip @@ -4823,6 +4829,7 @@ DelegateIPAssignMessage(ConfigContext scontext, char *newval, int elevel) g_pool_config.delegate_ip = newval; return true; } + /* * Check DB node spec. node spec should be either "primary", "standby" or * numeric DB node id. @@ -4864,9 +4871,9 @@ check_redirect_node_spec(char *node_spec) static bool config_post_processor(ConfigContext context, int elevel) { - double total_weight = 0.0; + double total_weight = 0.0; sig_atomic_t local_num_backends = 0; - int i; + int i; /* read from pgpool_node_id */ SetPgpoolNodeId(elevel); @@ -4987,9 +4994,9 @@ config_post_processor(ConfigContext context, int elevel) /* * Quarantine state in native replication mode is dangerous and it can - * potentially cause data inconsistency. - * So as per the discussions, we agreed on disallowing setting - * failover_when_quorum_exists in native replication mode + * potentially cause data inconsistency. So as per the discussions, we + * agreed on disallowing setting failover_when_quorum_exists in native + * replication mode */ if (pool_config->failover_when_quorum_exists && pool_config->replication_mode) @@ -5001,8 +5008,8 @@ config_post_processor(ConfigContext context, int elevel) } /* - * Verify the minimum and maximum number of spare children configuration when - * dynamic process management is enabled + * Verify the minimum and maximum number of spare children configuration + * when dynamic process management is enabled */ if (g_pool_config.process_management == PM_DYNAMIC) @@ -5011,14 +5018,14 @@ config_post_processor(ConfigContext context, int elevel) { ereport(elevel, (errmsg("invalid configuration, max_spare_children:%d must be greater than min_spare_children:%d", - pool_config->max_spare_children,pool_config->min_spare_children))); + pool_config->max_spare_children, pool_config->min_spare_children))); return false; } if (pool_config->num_init_children < pool_config->max_spare_children) { ereport(elevel, (errmsg("invalid configuration, max_spare_children:%d can't be greater than num_init_children:%d", - pool_config->max_spare_children,pool_config->num_init_children))); + pool_config->max_spare_children, pool_config->num_init_children))); return false; } } @@ -5028,9 +5035,9 @@ config_post_processor(ConfigContext context, int elevel) static bool MakeDMLAdaptiveObjectRelationList(char *newval, int elevel) { - int i; - int elements_count = 0; - char **rawList = get_list_from_string(newval, ",", &elements_count); + int i; + int elements_count = 0; + char **rawList = get_list_from_string(newval, ",", &elements_count); if (rawList == NULL || elements_count == 0) { @@ -5041,21 +5048,21 @@ MakeDMLAdaptiveObjectRelationList(char *newval, int elevel) for (i = 0; i < elements_count; i++) { - char *kvstr = rawList[i]; - char *left_token = strtok(kvstr, ":"); - char *right_token = strtok(NULL, ":"); + char *kvstr = rawList[i]; + char *left_token = strtok(kvstr, ":"); + char *right_token = strtok(NULL, ":"); DBObjectTypes object_type; ereport(DEBUG5, (errmsg("dml_adaptive_init"), - errdetail("%s -- left_token[%s] right_token[%s]", kvstr, left_token, right_token))); + errdetail("%s -- left_token[%s] right_token[%s]", kvstr, left_token, right_token))); pool_config->parsed_dml_adaptive_object_relationship_list[i].left_token.name = - getParsedToken(left_token, &object_type); + getParsedToken(left_token, &object_type); pool_config->parsed_dml_adaptive_object_relationship_list[i].left_token.object_type = object_type; pool_config->parsed_dml_adaptive_object_relationship_list[i].right_token.name = - getParsedToken(right_token,&object_type); + getParsedToken(right_token, &object_type); pool_config->parsed_dml_adaptive_object_relationship_list[i].right_token.object_type = object_type; pfree(kvstr); } @@ -5075,10 +5082,11 @@ MakeDMLAdaptiveObjectRelationList(char *newval, int elevel) * We also remove the trailing spaces from the function type token * and return the palloc'd copy of token in new_token */ -static char* +static char * getParsedToken(char *token, DBObjectTypes *object_type) { - int len; + int len; + *object_type = OBJECT_TYPE_UNKNOWN; if (!token) @@ -5087,18 +5095,19 @@ getParsedToken(char *token, DBObjectTypes *object_type) len = strlen(token); if (len > strlen("*()")) { - int namelen = len - 2; + int namelen = len - 2; + /* check if token ends with () */ - if (strcmp(token + namelen,"()") == 0) + if (strcmp(token + namelen, "()") == 0) { /* - * Remove the Parentheses from end of - * token name + * Remove the Parentheses from end of token name */ - char *new_token; - int new_len = strlen(token) - 2; + char *new_token; + int new_len = strlen(token) - 2; + new_token = palloc(new_len + 1); - strncpy(new_token,token,new_len); + strncpy(new_token, token, new_len); new_token[new_len] = '\0'; *object_type = OBJECT_TYPE_FUNCTION; return new_token; @@ -5241,16 +5250,16 @@ static bool SetPgpoolNodeId(int elevel) { char pgpool_node_id_file[POOLMAXPATHLEN + 1]; - FILE *fd; - int length; - int i; + FILE *fd; + int length; + int i; if (g_pool_config.use_watchdog) { snprintf(pgpool_node_id_file, sizeof(pgpool_node_id_file), "%s/%s", config_file_dir, NODE_ID_FILE_NAME); #define MAXLINE 10 - char readbuf[MAXLINE]; + char readbuf[MAXLINE]; fd = fopen(pgpool_node_id_file, "r"); if (!fd) @@ -5326,12 +5335,13 @@ SetPgpoolNodeId(int elevel) static bool SetHBDestIfFunc(int elevel) { - int idx = 0; - char **addrs; - char **if_names; - int i, j, - n_addr, - n_if_name; + int idx = 0; + char **addrs; + char **if_names; + int i, + j, + n_addr, + n_if_name; g_pool_config.num_hb_dest_if = 0; @@ -5342,10 +5352,10 @@ SetHBDestIfFunc(int elevel) /* * g_pool_config.hb_ifs is the information for sending/receiving heartbeat - * for all nodes specified in pgpool.conf. - * If it is local pgpool node information, set dest_port to g_pool_config.wd_heartbeat_port - * and ignore addr and if_name. - * g_pool_config.hb_dest_if is the heartbeat destination information. + * for all nodes specified in pgpool.conf. If it is local pgpool node + * information, set dest_port to g_pool_config.wd_heartbeat_port and + * ignore addr and if_name. g_pool_config.hb_dest_if is the heartbeat + * destination information. */ for (i = 0; i < WD_MAX_IF_NUM; i++) { @@ -5358,7 +5368,7 @@ SetHBDestIfFunc(int elevel) continue; } - WdHbIf *hbNodeInfo = &g_pool_config.hb_ifs[i]; + WdHbIf *hbNodeInfo = &g_pool_config.hb_ifs[i]; addrs = get_list_from_string(hbNodeInfo->addr, ";", &n_addr); if_names = get_list_from_string(hbNodeInfo->if_name, ";", &n_if_name); @@ -5383,7 +5393,7 @@ SetHBDestIfFunc(int elevel) { strlcpy(g_pool_config.hb_dest_if[idx].addr, addrs[j], WD_MAX_HOST_NAMELEN - 1); g_pool_config.hb_dest_if[idx].dest_port = hbNodeInfo->dest_port; - if (n_if_name > j ) + if (n_if_name > j) { strlcpy(g_pool_config.hb_dest_if[idx].if_name, if_names[j], WD_MAX_IF_NAME_LEN - 1); pfree(if_names[j]); @@ -5537,6 +5547,7 @@ parse_int(const char *value, int64 *result, int flags, const char **hintmsg, int *result = (int64) val; return true; } + /* * Convert a value from one of the human-friendly units ("kB", "min" etc.) * to the given base unit. 'value' and 'unit' are the input value and unit @@ -5935,7 +5946,7 @@ value_slot_for_config_record_is_empty(struct config_generic *record, int index) } bool -set_config_option_for_session(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, const char *name, const char *value) +set_config_option_for_session(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, const char *name, const char *value) { bool ret; MemoryContext oldCxt = MemoryContextSwitchTo(TopMemoryContext); @@ -5950,7 +5961,7 @@ set_config_option_for_session(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * } bool -reset_all_variables(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend) +reset_all_variables(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend) { int i; int elevel = (frontend == NULL) ? FATAL : FRONTEND_ONLY_ERROR; @@ -6019,7 +6030,7 @@ reset_all_variables(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend) * Handle "pgpool show all" command. */ bool -report_all_variables(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend) +report_all_variables(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend) { int i; int num_rows = 0; @@ -6077,7 +6088,7 @@ report_all_variables(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend) * Handle "pgpool show" command. */ bool -report_config_variable(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, const char *var_name) +report_config_variable(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, const char *var_name) { int index = 0; char *value; @@ -6151,7 +6162,7 @@ report_config_variable(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backen } static int -send_array_type_variable_to_frontend(struct config_generic *record, POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend) +send_array_type_variable_to_frontend(struct config_generic *record, POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend) { if (record->dynamic_array_var) { @@ -6192,7 +6203,7 @@ send_array_type_variable_to_frontend(struct config_generic *record, POOL_CONNECT } static int -send_grouped_type_variable_to_frontend(struct config_grouped_array_var *grouped_record, POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend) +send_grouped_type_variable_to_frontend(struct config_grouped_array_var *grouped_record, POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend) { int k, index; @@ -6243,7 +6254,7 @@ send_grouped_type_variable_to_frontend(struct config_grouped_array_var *grouped_ } static void -send_row_description_for_detail_view(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend) +send_row_description_for_detail_view(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend) { static char *field_names[] = {"item", "value", "description"}; diff --git a/src/context/pool_process_context.c b/src/context/pool_process_context.c index 00a04ff8d..da2913b6d 100644 --- a/src/context/pool_process_context.c +++ b/src/context/pool_process_context.c @@ -30,7 +30,7 @@ #include "pool_config.h" /* remove me afterwards */ static POOL_PROCESS_CONTEXT process_context_d; -static POOL_PROCESS_CONTEXT * process_context; +static POOL_PROCESS_CONTEXT *process_context; /* * Initialize per process context @@ -108,7 +108,7 @@ pool_increment_local_session_id(void) size_t pool_coninfo_size(void) { - size_t size; + size_t size; size = pool_config->num_init_children * pool_config->max_pool * @@ -264,13 +264,13 @@ pool_coninfo_backend_pid(int backend_pid, int *backend_node_id) * This flag is used to handle pg_terminate_backend() */ void -pool_set_connection_will_be_terminated(ConnectionInfo * connInfo) +pool_set_connection_will_be_terminated(ConnectionInfo *connInfo) { connInfo->swallow_termination = 1; } void -pool_unset_connection_will_be_terminated(ConnectionInfo * connInfo) +pool_unset_connection_will_be_terminated(ConnectionInfo *connInfo) { connInfo->swallow_termination = 0; } diff --git a/src/context/pool_query_context.c b/src/context/pool_query_context.c index d398bee6d..a4800d94b 100644 --- a/src/context/pool_query_context.c +++ b/src/context/pool_query_context.c @@ -48,7 +48,7 @@ typedef enum POOL_STANDBY, POOL_EITHER, POOL_BOTH -} POOL_DEST; +} POOL_DEST; #define CHECK_QUERY_CONTEXT_IS_VALID \ do { \ @@ -58,9 +58,9 @@ typedef enum } while (0) static POOL_DEST send_to_where(Node *node); -static void where_to_send_deallocate(POOL_QUERY_CONTEXT * query_context, Node *node); -static void where_to_send_main_replica(POOL_QUERY_CONTEXT * query_context, char *query, Node *node); -static void where_to_send_native_replication(POOL_QUERY_CONTEXT * query_context, char *query, Node *node); +static void where_to_send_deallocate(POOL_QUERY_CONTEXT *query_context, Node *node); +static void where_to_send_main_replica(POOL_QUERY_CONTEXT *query_context, char *query, Node *node); +static void where_to_send_native_replication(POOL_QUERY_CONTEXT *query_context, char *query, Node *node); static char *remove_read_write(int len, const char *contents, int *rewritten_len); static void set_virtual_main_node(POOL_QUERY_CONTEXT *query_context); @@ -70,8 +70,8 @@ static bool is_in_list(char *name, List *list); static bool is_select_object_in_temp_write_list(Node *node, void *context); static bool add_object_into_temp_write_list(Node *node, void *context); static void dml_adaptive(Node *node, char *query); -static char* get_associated_object_from_dml_adaptive_relations - (char *left_token, DBObjectTypes object_type); +static char *get_associated_object_from_dml_adaptive_relations + (char *left_token, DBObjectTypes object_type); /* * Create and initialize per query session context @@ -98,7 +98,7 @@ pool_init_query_context(void) * Destroy query context */ void -pool_query_context_destroy(POOL_QUERY_CONTEXT * query_context) +pool_query_context_destroy(POOL_QUERY_CONTEXT *query_context) { POOL_SESSION_CONTEXT *session_context; @@ -130,7 +130,7 @@ pool_query_context_destroy(POOL_QUERY_CONTEXT * query_context) * Perform shallow copy of given query context. Used in parse_before_bind. */ POOL_QUERY_CONTEXT * -pool_query_context_shallow_copy(POOL_QUERY_CONTEXT * query_context) +pool_query_context_shallow_copy(POOL_QUERY_CONTEXT *query_context) { POOL_QUERY_CONTEXT *qc; MemoryContext memory_context; @@ -146,7 +146,7 @@ pool_query_context_shallow_copy(POOL_QUERY_CONTEXT * query_context) * Start query */ void -pool_start_query(POOL_QUERY_CONTEXT * query_context, char *query, int len, Node *node) +pool_start_query(POOL_QUERY_CONTEXT *query_context, char *query, int len, Node *node) { POOL_SESSION_CONTEXT *session_context; @@ -180,7 +180,7 @@ pool_start_query(POOL_QUERY_CONTEXT * query_context, char *query, int len, Node * Specify DB node to send query */ void -pool_set_node_to_be_sent(POOL_QUERY_CONTEXT * query_context, int node_id) +pool_set_node_to_be_sent(POOL_QUERY_CONTEXT *query_context, int node_id) { CHECK_QUERY_CONTEXT_IS_VALID; @@ -198,7 +198,7 @@ pool_set_node_to_be_sent(POOL_QUERY_CONTEXT * query_context, int node_id) * Unspecified DB node to send query */ void -pool_unset_node_to_be_sent(POOL_QUERY_CONTEXT * query_context, int node_id) +pool_unset_node_to_be_sent(POOL_QUERY_CONTEXT *query_context, int node_id) { CHECK_QUERY_CONTEXT_IS_VALID; @@ -216,7 +216,7 @@ pool_unset_node_to_be_sent(POOL_QUERY_CONTEXT * query_context, int node_id) * Clear DB node map */ void -pool_clear_node_to_be_sent(POOL_QUERY_CONTEXT * query_context) +pool_clear_node_to_be_sent(POOL_QUERY_CONTEXT *query_context) { CHECK_QUERY_CONTEXT_IS_VALID; @@ -228,7 +228,7 @@ pool_clear_node_to_be_sent(POOL_QUERY_CONTEXT * query_context) * Set all DB node map entry */ void -pool_setall_node_to_be_sent(POOL_QUERY_CONTEXT * query_context) +pool_setall_node_to_be_sent(POOL_QUERY_CONTEXT *query_context) { int i; POOL_SESSION_CONTEXT *sc; @@ -245,8 +245,9 @@ pool_setall_node_to_be_sent(POOL_QUERY_CONTEXT * query_context) if (SL_MODE) { /* - * If load balance mode is disabled, only send to the primary node. - * If primary node does not exist, send to the main node. + * If load balance mode is disabled, only send to the primary + * node. If primary node does not exist, send to the main + * node. */ if (!pool_config->load_balance_mode) { @@ -259,6 +260,7 @@ pool_setall_node_to_be_sent(POOL_QUERY_CONTEXT * query_context) continue; } else + /* * If the node is not primary node nor load balance node, * there's no point to send query except statement level @@ -266,7 +268,7 @@ pool_setall_node_to_be_sent(POOL_QUERY_CONTEXT * query_context) */ if (!pool_config->statement_level_load_balance && i != PRIMARY_NODE_ID && i != sc->load_balance_node_id) - continue; + continue; } query_context->where_to_send[i] = true; } @@ -278,7 +280,7 @@ pool_setall_node_to_be_sent(POOL_QUERY_CONTEXT * query_context) * Return true if multiple nodes are targets */ bool -pool_multi_node_to_be_sent(POOL_QUERY_CONTEXT * query_context) +pool_multi_node_to_be_sent(POOL_QUERY_CONTEXT *query_context) { int i; int cnt = 0; @@ -305,7 +307,7 @@ pool_multi_node_to_be_sent(POOL_QUERY_CONTEXT * query_context) * Return if the DB node is needed to send query */ bool -pool_is_node_to_be_sent(POOL_QUERY_CONTEXT * query_context, int node_id) +pool_is_node_to_be_sent(POOL_QUERY_CONTEXT *query_context, int node_id) { CHECK_QUERY_CONTEXT_IS_VALID; @@ -346,12 +348,12 @@ pool_is_node_to_be_sent_in_current_query(int node_id) int pool_virtual_main_db_node_id(void) { - volatile POOL_REQUEST_INFO *my_req; + volatile POOL_REQUEST_INFO *my_req; POOL_SESSION_CONTEXT *sc; /* - * Check whether failover is in progress and we are child process. - * If so, we will wait for failover to finish. + * Check whether failover is in progress and we are child process. If so, + * we will wait for failover to finish. */ my_req = Req_info; if (processType == PT_CHILD && my_req->switching) @@ -360,17 +362,19 @@ pool_virtual_main_db_node_id(void) POOL_SETMASK(&BlockSig); ereport(WARNING, (errmsg("failover/failback is in progress"), - errdetail("executing failover or failback on backend"), + errdetail("executing failover or failback on backend"), errhint("In a moment you should be able to reconnect to the database"))); POOL_SETMASK(&UnBlockSig); #endif + /* * Wait for failover to finish */ if (wait_for_failover_to_finish() == -2) + /* - * Waiting for failover/failback to finish was timed out. - * Time to exit this process (and session disconnection). + * Waiting for failover/failback to finish was timed out. Time to + * exit this process (and session disconnection). */ child_exit(POOL_EXIT_AND_RESTART); } @@ -380,9 +384,9 @@ pool_virtual_main_db_node_id(void) { /* * We used to return REAL_MAIN_NODE_ID here. Problem with it is, it - * is possible that REAL_MAIN_NODE_ID could be changed - * anytime. Suppose REAL_MAIN_NODE_ID == my_main_node_id == 1. Then - * due to failback, REAL_MAIN_NODE_ID is changed to 0. Then + * is possible that REAL_MAIN_NODE_ID could be changed anytime. + * Suppose REAL_MAIN_NODE_ID == my_main_node_id == 1. Then due to + * failback, REAL_MAIN_NODE_ID is changed to 0. Then * MAIN_CONNECTION(cp) will return NULL and any reference to it will * cause segmentation fault. To prevent the issue we should return * my_main_node_id instead. @@ -430,9 +434,9 @@ pool_virtual_main_db_node_id(void) } /* - * No query context exists. If in streaming replication mode, returns primary node - * if exists. Otherwise returns my_main_node_id, which represents the - * last REAL_MAIN_NODE_ID. + * No query context exists. If in streaming replication mode, returns + * primary node if exists. Otherwise returns my_main_node_id, which + * represents the last REAL_MAIN_NODE_ID. */ if (MAIN_REPLICA) { @@ -445,7 +449,7 @@ pool_virtual_main_db_node_id(void) * Set the destination for the current query to the specific backend node. */ void -pool_force_query_node_to_backend(POOL_QUERY_CONTEXT * query_context, int backend_id) +pool_force_query_node_to_backend(POOL_QUERY_CONTEXT *query_context, int backend_id) { CHECK_QUERY_CONTEXT_IS_VALID; @@ -460,7 +464,7 @@ pool_force_query_node_to_backend(POOL_QUERY_CONTEXT * query_context, int backend * Decide where to send queries(thus expecting response) */ void -pool_where_to_send(POOL_QUERY_CONTEXT * query_context, char *query, Node *node) +pool_where_to_send(POOL_QUERY_CONTEXT *query_context, char *query, Node *node) { CHECK_QUERY_CONTEXT_IS_VALID; @@ -481,14 +485,15 @@ pool_where_to_send(POOL_QUERY_CONTEXT * query_context, char *query, Node *node) if (query_context->is_multi_statement) { /* - * If we are in streaming replication mode and we have multi statement query, - * we should send it to primary server only. Otherwise it is possible - * to send a write query to standby servers because we only use the - * first element of the multi statement query and don't care about the - * rest. Typical situation where we are bugged by this is, - * "BEGIN;DELETE FROM table;END". Note that from pgpool-II 3.1.0 - * transactional statements such as "BEGIN" is unconditionally sent to - * all nodes(see send_to_where() for more details). Someday we might + * If we are in streaming replication mode and we have multi + * statement query, we should send it to primary server only. + * Otherwise it is possible to send a write query to standby + * servers because we only use the first element of the multi + * statement query and don't care about the rest. Typical + * situation where we are bugged by this is, "BEGIN;DELETE FROM + * table;END". Note that from pgpool-II 3.1.0 transactional + * statements such as "BEGIN" is unconditionally sent to all + * nodes(see send_to_where() for more details). Someday we might * be able to understand all part of multi statement queries, but * until that day we need this band aid. */ @@ -535,7 +540,7 @@ pool_where_to_send(POOL_QUERY_CONTEXT * query_context, char *query, Node *node) * >0: send to this node_id */ POOL_STATUS -pool_send_and_wait(POOL_QUERY_CONTEXT * query_context, +pool_send_and_wait(POOL_QUERY_CONTEXT *query_context, int send_type, int node_id) { POOL_SESSION_CONTEXT *session_context; @@ -556,10 +561,10 @@ pool_send_and_wait(POOL_QUERY_CONTEXT * query_context, string = NULL; /* - * If the query is BEGIN READ WRITE or BEGIN ... SERIALIZABLE in - * streaming replication mode, we send BEGIN to standbys instead. - * The original_query which is BEGIN READ WRITE is sent to primary. - * The rewritten_query BEGIN is sent to standbys. + * If the query is BEGIN READ WRITE or BEGIN ... SERIALIZABLE in streaming + * replication mode, we send BEGIN to standbys instead. The original_query + * which is BEGIN READ WRITE is sent to primary. The rewritten_query BEGIN + * is sent to standbys. */ if (pool_need_to_treat_as_if_default_transaction(query_context)) { @@ -590,8 +595,9 @@ pool_send_and_wait(POOL_QUERY_CONTEXT * query_context, continue; /* - * If we are in streaming replication mode or logical replication mode, - * we do not send COMMIT/ABORT to standbys if it's in I (idle) state. + * If we are in streaming replication mode or logical replication + * mode, we do not send COMMIT/ABORT to standbys if it's in I (idle) + * state. */ if (is_commit && MAIN_REPLICA && !IS_MAIN_NODE_ID(i) && TSTATE(backend, i) == 'I') { @@ -692,7 +698,7 @@ pool_send_and_wait(POOL_QUERY_CONTEXT * query_context, * >0: send to this node_id */ POOL_STATUS -pool_extended_send_and_wait(POOL_QUERY_CONTEXT * query_context, +pool_extended_send_and_wait(POOL_QUERY_CONTEXT *query_context, char *kind, int len, char *contents, int send_type, int node_id, bool nowait) { @@ -718,10 +724,10 @@ pool_extended_send_and_wait(POOL_QUERY_CONTEXT * query_context, rewritten_begin = NULL; /* - * If the query is BEGIN READ WRITE or BEGIN ... SERIALIZABLE in - * streaming replication mode, we send BEGIN to standbys instead. - * The original_query which is BEGIN READ WRITE is sent to primary. - * The rewritten_query BEGIN is sent to standbys. + * If the query is BEGIN READ WRITE or BEGIN ... SERIALIZABLE in streaming + * replication mode, we send BEGIN to standbys instead. The original_query + * which is BEGIN READ WRITE is sent to primary. The rewritten_query BEGIN + * is sent to standbys. */ if (pool_need_to_treat_as_if_default_transaction(query_context)) { @@ -903,7 +909,8 @@ pool_extended_send_and_wait(POOL_QUERY_CONTEXT * query_context, * From syntactically analysis decide the statement to be sent to the * primary, the standby or either or both in native replication+HR/SR mode. */ -static POOL_DEST send_to_where(Node *node) +static POOL_DEST +send_to_where(Node *node) { /* From storage/lock.h */ @@ -981,15 +988,15 @@ static POOL_DEST send_to_where(Node *node) if (is_start_transaction_query(node)) { /* - * But actually, we send BEGIN to standby if it's BEGIN READ - * WRITE or START TRANSACTION READ WRITE + * But actually, we send BEGIN to standby if it's BEGIN READ WRITE + * or START TRANSACTION READ WRITE */ if (is_read_write((TransactionStmt *) node)) return POOL_BOTH; /* - * Other TRANSACTION start commands are sent to both primary - * and standby + * Other TRANSACTION start commands are sent to both primary and + * standby */ else return POOL_BOTH; @@ -1009,6 +1016,7 @@ static POOL_DEST send_to_where(Node *node) } return POOL_BOTH; } + /* * 2PC commands */ @@ -1059,8 +1067,8 @@ static POOL_DEST send_to_where(Node *node) /* * SET TRANSACTION ISOLATION LEVEL SERIALIZABLE or SET SESSION - * CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE or - * SET transaction_isolation TO 'serializable' SET + * CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE or SET + * transaction_isolation TO 'serializable' SET * default_transaction_isolation TO 'serializable' */ else if (is_set_transaction_serializable(node)) @@ -1069,8 +1077,8 @@ static POOL_DEST send_to_where(Node *node) } /* - * Check "SET TRANSACTION READ WRITE" "SET SESSION CHARACTERISTICS - * AS TRANSACTION READ WRITE" + * Check "SET TRANSACTION READ WRITE" "SET SESSION CHARACTERISTICS AS + * TRANSACTION READ WRITE" */ else if (((VariableSetStmt *) node)->kind == VAR_SET_MULTI && (!strcmp(((VariableSetStmt *) node)->name, "TRANSACTION") || @@ -1165,11 +1173,11 @@ static POOL_DEST send_to_where(Node *node) */ static void -where_to_send_deallocate(POOL_QUERY_CONTEXT * query_context, Node *node) +where_to_send_deallocate(POOL_QUERY_CONTEXT *query_context, Node *node) { DeallocateStmt *d = NULL; ExecuteStmt *e = NULL; - char *name; + char *name; POOL_SENT_MESSAGE *msg; if (IsA(node, DeallocateStmt)) @@ -1217,12 +1225,10 @@ where_to_send_deallocate(POOL_QUERY_CONTEXT * query_context, Node *node) else { /* - * prepared statement was not found. - * There are two cases when this could happen. - * (1) mistakes by client. In this case backend will return ERROR - * anyway. - * (2) previous query was issued as multi-statement query. e.g. - * SELECT 1\;PREPARE foo AS SELECT 1; + * prepared statement was not found. There are two cases when this + * could happen. (1) mistakes by client. In this case backend will + * return ERROR anyway. (2) previous query was issued as + * multi-statement query. e.g. SELECT 1\;PREPARE foo AS SELECT 1; * In this case pgpool does not know anything about the prepared * statement "foo". */ @@ -1431,7 +1437,7 @@ is_serializable(TransactionStmt *node) * The rewritten_query BEGIN is sent to standbys. */ bool -pool_need_to_treat_as_if_default_transaction(POOL_QUERY_CONTEXT * query_context) +pool_need_to_treat_as_if_default_transaction(POOL_QUERY_CONTEXT *query_context) { return (MAIN_REPLICA && is_start_transaction_query(query_context->parse_tree) && @@ -1471,7 +1477,7 @@ is_2pc_transaction_query(Node *node) * Set query state, if a current state is before it than the specified state. */ void -pool_set_query_state(POOL_QUERY_CONTEXT * query_context, POOL_QUERY_STATE state) +pool_set_query_state(POOL_QUERY_CONTEXT *query_context, POOL_QUERY_STATE state) { int i; @@ -1755,7 +1761,7 @@ pool_is_transaction_read_only(Node *node) static void set_virtual_main_node(POOL_QUERY_CONTEXT *query_context) { - int i; + int i; for (i = 0; i < NUM_BACKENDS; i++) { @@ -1774,6 +1780,7 @@ static void set_load_balance_info(POOL_QUERY_CONTEXT *query_context) { POOL_SESSION_CONTEXT *session_context; + session_context = pool_get_session_context(false); if (pool_config->statement_level_load_balance) @@ -1794,10 +1801,12 @@ is_in_list(char *name, List *list) if (name == NULL || list == NIL) return false; - ListCell *cell; - foreach (cell, list) + ListCell *cell; + + foreach(cell, list) { - char *cell_name = (char *)lfirst(cell); + char *cell_name = (char *) lfirst(cell); + if (strcasecmp(name, cell_name) == 0) { ereport(DEBUG1, @@ -1826,7 +1835,7 @@ is_select_object_in_temp_write_list(Node *node, void *context) if (pool_config->disable_load_balance_on_write == DLBOW_DML_ADAPTIVE && session_context->is_in_transaction) { ereport(DEBUG1, - (errmsg("is_select_object_in_temp_write_list: \"%s\", found relation \"%s\"", (char*)context, rgv->relname))); + (errmsg("is_select_object_in_temp_write_list: \"%s\", found relation \"%s\"", (char *) context, rgv->relname))); return is_in_list(rgv->relname, session_context->transaction_temp_write_list); } @@ -1835,15 +1844,15 @@ is_select_object_in_temp_write_list(Node *node, void *context) return raw_expression_tree_walker(node, is_select_object_in_temp_write_list, context); } -static char* -get_associated_object_from_dml_adaptive_relations - (char *left_token, DBObjectTypes object_type) +static char *get_associated_object_from_dml_adaptive_relations + (char *left_token, DBObjectTypes object_type) { - int i; - char *right_token = NULL; + int i; + char *right_token = NULL; + if (!pool_config->parsed_dml_adaptive_object_relationship_list) return NULL; - for (i=0 ;; i++) + for (i = 0;; i++) { if (pool_config->parsed_dml_adaptive_object_relationship_list[i].left_token.name == NULL) break; @@ -1873,13 +1882,14 @@ check_object_relationship_list(char *name, bool is_func_name) if (session_context->is_in_transaction) { - char *right_token = - get_associated_object_from_dml_adaptive_relations - (name, is_func_name? OBJECT_TYPE_FUNCTION : OBJECT_TYPE_RELATION); + char *right_token = + get_associated_object_from_dml_adaptive_relations + (name, is_func_name ? OBJECT_TYPE_FUNCTION : OBJECT_TYPE_RELATION); if (right_token) { MemoryContext old_context = MemoryContextSwitchTo(session_context->memory_context); + session_context->transaction_temp_write_list = lappend(session_context->transaction_temp_write_list, pstrdup(right_token)); MemoryContextSwitchTo(old_context); @@ -1903,7 +1913,7 @@ add_object_into_temp_write_list(Node *node, void *context) RangeVar *rgv = (RangeVar *) node; ereport(DEBUG5, - (errmsg("add_object_into_temp_write_list: \"%s\", found relation \"%s\"", (char*)context, rgv->relname))); + (errmsg("add_object_into_temp_write_list: \"%s\", found relation \"%s\"", (char *) context, rgv->relname))); POOL_SESSION_CONTEXT *session_context = pool_get_session_context(false); MemoryContext old_context = MemoryContextSwitchTo(session_context->memory_context); @@ -1947,7 +1957,7 @@ dml_adaptive(Node *node, char *query) session_context->transaction_temp_write_list = NIL; } - else if(is_commit_or_rollback_query(node)) + else if (is_commit_or_rollback_query(node)) { session_context->is_in_transaction = false; @@ -1961,7 +1971,10 @@ dml_adaptive(Node *node, char *query) return; } - /* If non-selectStmt, find the relname and add it to the transaction temp write list. */ + /* + * If non-selectStmt, find the relname and add it to the transaction + * temp write list. + */ if (!is_select_query(node, query)) add_object_into_temp_write_list(node, query); @@ -1973,7 +1986,7 @@ dml_adaptive(Node *node, char *query) * replication mode and slony mode. Called by pool_where_to_send. */ static void -where_to_send_main_replica(POOL_QUERY_CONTEXT * query_context, char *query, Node *node) +where_to_send_main_replica(POOL_QUERY_CONTEXT *query_context, char *query, Node *node) { POOL_DEST dest; POOL_SESSION_CONTEXT *session_context; @@ -2000,11 +2013,10 @@ where_to_send_main_replica(POOL_QUERY_CONTEXT * query_context, char *query, Node if (is_tx_started_by_multi_statement_query()) { /* - * If we are in an explicit transaction and the transaction - * was started by a multi statement query, we should send - * query to primary node only (which was supposed to be sent - * to all nodes) until the transaction gets committed or - * aborted. + * If we are in an explicit transaction and the transaction was + * started by a multi statement query, we should send query to + * primary node only (which was supposed to be sent to all nodes) + * until the transaction gets committed or aborted. */ pool_set_node_to_be_sent(query_context, PRIMARY_NODE_ID); } @@ -2030,9 +2042,9 @@ where_to_send_main_replica(POOL_QUERY_CONTEXT * query_context, char *query, Node { /* * If (we are outside of an explicit transaction) OR (the - * transaction has not issued a write query yet, AND - * transaction isolation level is not SERIALIZABLE) we might - * be able to load balance. + * transaction has not issued a write query yet, AND transaction + * isolation level is not SERIALIZABLE) we might be able to load + * balance. */ ereport(DEBUG1, @@ -2053,14 +2065,14 @@ where_to_send_main_replica(POOL_QUERY_CONTEXT * query_context, char *query, Node */ /* - * If system catalog is used in the SELECT, we prefer to - * send to the primary. Example: SELECT * FROM pg_class - * WHERE relname = 't1'; Because 't1' is a constant, it's - * hard to recognize as table name. Most use case such - * query is against system catalog, and the table name can - * be a temporary table, it's best to query against - * primary system catalog. Please note that this test must - * be done *before* test using pool_has_temp_table. + * If system catalog is used in the SELECT, we prefer to send + * to the primary. Example: SELECT * FROM pg_class WHERE + * relname = 't1'; Because 't1' is a constant, it's hard to + * recognize as table name. Most use case such query is + * against system catalog, and the table name can be a + * temporary table, it's best to query against primary system + * catalog. Please note that this test must be done *before* + * test using pool_has_temp_table. */ if (pool_has_system_catalog(node)) { @@ -2072,8 +2084,8 @@ where_to_send_main_replica(POOL_QUERY_CONTEXT * query_context, char *query, Node } /* - * If temporary table is used in the SELECT, we prefer to - * send to the primary. + * If temporary table is used in the SELECT, we prefer to send + * to the primary. */ else if (pool_config->check_temp_table && pool_has_temp_table(node)) { @@ -2085,8 +2097,8 @@ where_to_send_main_replica(POOL_QUERY_CONTEXT * query_context, char *query, Node } /* - * If unlogged table is used in the SELECT, we prefer to - * send to the primary. + * If unlogged table is used in the SELECT, we prefer to send + * to the primary. */ else if (pool_config->check_unlogged_table && pool_has_unlogged_table(node)) { @@ -2096,17 +2108,20 @@ where_to_send_main_replica(POOL_QUERY_CONTEXT * query_context, char *query, Node pool_set_node_to_be_sent(query_context, PRIMARY_NODE_ID); } + /* - * When query match the query patterns in primary_routing_query_pattern_list, we - * send only to main node. + * When query match the query patterns in + * primary_routing_query_pattern_list, we send only to main + * node. */ else if (pattern_compare(query, WRITELIST, "primary_routing_query_pattern_list") == 1) { pool_set_node_to_be_sent(query_context, PRIMARY_NODE_ID); } + /* - * If a writing function call is used, we prefer to send - * to the primary. + * If a writing function call is used, we prefer to send to + * the primary. */ else if (pool_has_function_call(node)) { @@ -2129,9 +2144,9 @@ where_to_send_main_replica(POOL_QUERY_CONTEXT * query_context, char *query, Node /* * As streaming replication delay is too much, if - * prefer_lower_delay_standby is true then elect new - * load balance node which is lowest delayed, - * false then send to the primary. + * prefer_lower_delay_standby is true then elect new load + * balance node which is lowest delayed, false then send + * to the primary. */ if (STREAM && check_replication_delay(session_context->load_balance_node_id)) { @@ -2141,7 +2156,7 @@ where_to_send_main_replica(POOL_QUERY_CONTEXT * query_context, char *query, Node if (pool_config->prefer_lower_delay_standby) { - int new_load_balancing_node = select_load_balancing_node(); + int new_load_balancing_node = select_load_balancing_node(); session_context->load_balance_node_id = new_load_balancing_node; session_context->query_context->load_balance_node_id = session_context->load_balance_node_id; @@ -2180,7 +2195,7 @@ where_to_send_main_replica(POOL_QUERY_CONTEXT * query_context, char *query, Node * Called by pool_where_to_send. */ static void -where_to_send_native_replication(POOL_QUERY_CONTEXT * query_context, char *query, Node *node) +where_to_send_native_replication(POOL_QUERY_CONTEXT *query_context, char *query, Node *node) { POOL_SESSION_CONTEXT *session_context; POOL_CONNECTION_POOL *backend; @@ -2193,7 +2208,7 @@ where_to_send_native_replication(POOL_QUERY_CONTEXT * query_context, char *query * from syntactical point of view). */ elog(DEBUG1, "Maybe: load balance mode: %d is_select_query: %d", - pool_config->load_balance_mode, is_select_query(node, query)); + pool_config->load_balance_mode, is_select_query(node, query)); if (pool_config->load_balance_mode && is_select_query(node, query) && @@ -2223,12 +2238,12 @@ where_to_send_native_replication(POOL_QUERY_CONTEXT * query_context, char *query else if (TSTATE(backend, MAIN_NODE_ID) == 'I') { /* - * We are out side transaction. If default transaction is read only, - * we can load balance. + * We are out side transaction. If default transaction is read + * only, we can load balance. */ - static char *si_query = "SELECT current_setting('transaction_read_only')"; + static char *si_query = "SELECT current_setting('transaction_read_only')"; POOL_SELECT_RESULT *res; - bool load_balance = false; + bool load_balance = false; do_query(CONNECTION(backend, MAIN_NODE_ID), si_query, &res, MAJOR(backend)); if (res) @@ -2251,7 +2266,7 @@ where_to_send_native_replication(POOL_QUERY_CONTEXT * query_context, char *query } } } - + /* * If a writing function call is used or replicate_select is true, we * have to send to all nodes since the function may modify database. @@ -2264,10 +2279,9 @@ where_to_send_native_replication(POOL_QUERY_CONTEXT * query_context, char *query } /* - * If (we are outside of an explicit transaction) OR (the - * transaction has not issued a write query yet, AND transaction - * isolation level is not SERIALIZABLE) we might be able to load - * balance. + * If (we are outside of an explicit transaction) OR (the transaction + * has not issued a write query yet, AND transaction isolation level + * is not SERIALIZABLE) we might be able to load balance. */ else if (TSTATE(backend, MAIN_NODE_ID) == 'I' || (!pool_is_writing_transaction() && @@ -2314,22 +2328,23 @@ where_to_send_native_replication(POOL_QUERY_CONTEXT * query_context, char *query int wait_for_failover_to_finish(void) { -#define MAX_FAILOVER_WAIT 30 /* waiting for failover finish timeout in seconds */ +#define MAX_FAILOVER_WAIT 30 /* waiting for failover finish timeout in + * seconds */ - volatile POOL_REQUEST_INFO *my_req; - int ret = 0; - int i; + volatile POOL_REQUEST_INFO *my_req; + int ret = 0; + int i; /* * Wait for failover to finish */ - for (i = 0;i < MAX_FAILOVER_WAIT; i++) + for (i = 0; i < MAX_FAILOVER_WAIT; i++) { my_req = Req_info; if (my_req->switching == 0) return ret; - ret = -1; /* failover/failback finished */ + ret = -1; /* failover/failback finished */ sleep(1); } - return -2; /* timed out */ + return -2; /* timed out */ } diff --git a/src/context/pool_session_context.c b/src/context/pool_session_context.c index eea8df136..6ed64b2de 100644 --- a/src/context/pool_session_context.c +++ b/src/context/pool_session_context.c @@ -34,11 +34,11 @@ #include "context/pool_session_context.h" static POOL_SESSION_CONTEXT session_context_d; -static POOL_SESSION_CONTEXT * session_context = NULL; +static POOL_SESSION_CONTEXT *session_context = NULL; static void GetTranIsolationErrorCb(void *arg); static void init_sent_message_list(void); -static POOL_PENDING_MESSAGE * copy_pending_message(POOL_PENDING_MESSAGE * message); -static void dump_sent_message(char *caller, POOL_SENT_MESSAGE * m); +static POOL_PENDING_MESSAGE *copy_pending_message(POOL_PENDING_MESSAGE *message); +static void dump_sent_message(char *caller, POOL_SENT_MESSAGE *m); static void dml_adaptive_init(void); static void dml_adaptive_destroy(void); @@ -52,7 +52,7 @@ static int Elevel = DEBUG2; * Initialize per session context */ void -pool_init_session_context(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend) +pool_init_session_context(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend) { session_context = &session_context_d; ProcessInfo *process_info; @@ -161,7 +161,7 @@ pool_init_session_context(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * bac /* Initialize temp tables */ pool_temp_tables_init(); - + /* Snapshot isolation state */ session_context->si_state = SI_NO_SNAPSHOT; @@ -434,7 +434,7 @@ pool_remove_sent_messages(char kind) * Destroy sent message */ void -pool_sent_message_destroy(POOL_SENT_MESSAGE * message) +pool_sent_message_destroy(POOL_SENT_MESSAGE *message) { bool in_progress; POOL_QUERY_CONTEXT *qc = NULL; @@ -522,7 +522,7 @@ pool_zap_query_context_in_sent_messages(POOL_QUERY_CONTEXT *query_context) } static void -dump_sent_message(char *caller, POOL_SENT_MESSAGE * m) +dump_sent_message(char *caller, POOL_SENT_MESSAGE *m) { ereport(DEBUG5, (errmsg("called by %s: sent message: address: %p kind: %c name: =%s= state:%d", @@ -560,7 +560,7 @@ dml_adaptive_destroy(void) POOL_SENT_MESSAGE * pool_create_sent_message(char kind, int len, char *contents, int num_tsparams, const char *name, - POOL_QUERY_CONTEXT * query_context) + POOL_QUERY_CONTEXT *query_context) { POOL_SENT_MESSAGE *msg; @@ -589,7 +589,7 @@ pool_create_sent_message(char kind, int len, char *contents, * Add a sent message to sent message list */ void -pool_add_sent_message(POOL_SENT_MESSAGE * message) +pool_add_sent_message(POOL_SENT_MESSAGE *message) { POOL_SENT_MESSAGE *old_msg; POOL_SENT_MESSAGE_LIST *msglist; @@ -682,7 +682,7 @@ pool_get_sent_message(char kind, const char *name, POOL_SENT_MESSAGE_STATE state * Find a sent message by query context. */ POOL_SENT_MESSAGE * -pool_get_sent_message_by_query_context(POOL_QUERY_CONTEXT * query_context) +pool_get_sent_message_by_query_context(POOL_QUERY_CONTEXT *query_context) { int i; POOL_SENT_MESSAGE_LIST *msglist; @@ -705,7 +705,7 @@ pool_get_sent_message_by_query_context(POOL_QUERY_CONTEXT * query_context) * Set message state to POOL_SENT_MESSAGE_STATE to POOL_SENT_MESSAGE_CLOSED. */ void -pool_set_sent_message_state(POOL_SENT_MESSAGE * message) +pool_set_sent_message_state(POOL_SENT_MESSAGE *message) { ereport(DEBUG5, (errmsg("pool_set_sent_message_state: name:%s kind:%c previous state: %d", @@ -738,8 +738,8 @@ void pool_set_writing_transaction(void) { /* - * If disable_transaction_on_write is 'off' or 'dml_adaptive', then never turn on writing - * transaction flag. + * If disable_transaction_on_write is 'off' or 'dml_adaptive', then never + * turn on writing transaction flag. */ if (pool_config->disable_load_balance_on_write != DLBOW_OFF && pool_config->disable_load_balance_on_write != DLBOW_DML_ADAPTIVE) { @@ -968,7 +968,7 @@ init_sent_message_list(void) * is used. Returns true if it is not used. */ bool -can_query_context_destroy(POOL_QUERY_CONTEXT * qc) +can_query_context_destroy(POOL_QUERY_CONTEXT *qc) { int i; int count = 0; @@ -1125,7 +1125,7 @@ pool_pending_message_create(char kind, int len, char *contents) * message was sent. */ void -pool_pending_message_dest_set(POOL_PENDING_MESSAGE * message, POOL_QUERY_CONTEXT * query_context) +pool_pending_message_dest_set(POOL_PENDING_MESSAGE *message, POOL_QUERY_CONTEXT *query_context) { memcpy(message->node_ids, query_context->where_to_send, sizeof(message->node_ids)); @@ -1142,7 +1142,7 @@ pool_pending_message_dest_set(POOL_PENDING_MESSAGE * message, POOL_QUERY_CONTEXT * which indicates which backend nodes the message was sent. */ void -pool_pending_message_query_context_dest_set(POOL_PENDING_MESSAGE * message, POOL_QUERY_CONTEXT * query_context) +pool_pending_message_query_context_dest_set(POOL_PENDING_MESSAGE *message, POOL_QUERY_CONTEXT *query_context) { int i; @@ -1168,7 +1168,7 @@ pool_pending_message_query_context_dest_set(POOL_PENDING_MESSAGE * message, POOL * Set query field of message. */ void -pool_pending_message_query_set(POOL_PENDING_MESSAGE * message, POOL_QUERY_CONTEXT * query_context) +pool_pending_message_query_set(POOL_PENDING_MESSAGE *message, POOL_QUERY_CONTEXT *query_context) { StrNCpy(message->query, query_context->original_query, sizeof(message->query)); } @@ -1177,7 +1177,7 @@ pool_pending_message_query_set(POOL_PENDING_MESSAGE * message, POOL_QUERY_CONTEX * Add one message to the tail of the list. */ void -pool_pending_message_add(POOL_PENDING_MESSAGE * message) +pool_pending_message_add(POOL_PENDING_MESSAGE *message) { MemoryContext old_context; @@ -1354,7 +1354,7 @@ pool_pending_message_get(POOL_MESSAGE_TYPE type) * close message. */ char -pool_get_close_message_spec(POOL_PENDING_MESSAGE * msg) +pool_get_close_message_spec(POOL_PENDING_MESSAGE *msg) { return *msg->contents; } @@ -1364,7 +1364,7 @@ pool_get_close_message_spec(POOL_PENDING_MESSAGE * msg) * The returned pointer is within "msg". */ char * -pool_get_close_message_name(POOL_PENDING_MESSAGE * msg) +pool_get_close_message_name(POOL_PENDING_MESSAGE *msg) { return (msg->contents) + 1; } @@ -1373,7 +1373,8 @@ pool_get_close_message_name(POOL_PENDING_MESSAGE * msg) * Perform deep copy of POOL_PENDING_MESSAGE object in the current memory * context except the query context. */ -static POOL_PENDING_MESSAGE * copy_pending_message(POOL_PENDING_MESSAGE * message) +static POOL_PENDING_MESSAGE * +copy_pending_message(POOL_PENDING_MESSAGE *message) { POOL_PENDING_MESSAGE *msg; @@ -1390,7 +1391,7 @@ static POOL_PENDING_MESSAGE * copy_pending_message(POOL_PENDING_MESSAGE * messag * context except the query context. */ void -pool_pending_message_free_pending_message(POOL_PENDING_MESSAGE * message) +pool_pending_message_free_pending_message(POOL_PENDING_MESSAGE *message) { if (message == NULL) return; @@ -1420,7 +1421,7 @@ pool_pending_message_reset_previous_message(void) * Set previous message. */ void -pool_pending_message_set_previous_message(POOL_PENDING_MESSAGE * message) +pool_pending_message_set_previous_message(POOL_PENDING_MESSAGE *message) { if (!session_context) { @@ -1521,7 +1522,7 @@ pool_check_pending_message_and_reply(POOL_MESSAGE_TYPE type, char kind) * pool_pending_message_free_pending_message. */ POOL_PENDING_MESSAGE * -pool_pending_message_find_lastest_by_query_context(POOL_QUERY_CONTEXT * qc) +pool_pending_message_find_lastest_by_query_context(POOL_QUERY_CONTEXT *qc) { List *msgs; POOL_PENDING_MESSAGE *msg; @@ -1573,7 +1574,7 @@ pool_pending_message_find_lastest_by_query_context(POOL_QUERY_CONTEXT * qc) * the pending message is one of primary or standby node. */ int -pool_pending_message_get_target_backend_id(POOL_PENDING_MESSAGE * msg) +pool_pending_message_get_target_backend_id(POOL_PENDING_MESSAGE *msg) { int backend_id = -1; int i; @@ -1602,8 +1603,8 @@ pool_pending_message_get_message_num_by_backend_id(int backend_id) { ListCell *cell; ListCell *next; - int cnt = 0; - int i; + int cnt = 0; + int i; if (!session_context) { @@ -1641,6 +1642,7 @@ pool_pending_message_set_flush_request(void) foreach(msg_item, session_context->pending_messages) { POOL_PENDING_MESSAGE *msg = (POOL_PENDING_MESSAGE *) lfirst(msg_item); + msg->flush_pending = true; ereport(DEBUG5, (errmsg("pool_pending_message_set_flush_request: msg: %s", @@ -1799,10 +1801,10 @@ pool_temp_tables_destroy(void) * If the table already exists, just replace state. */ void -pool_temp_tables_add(char * tablename, POOL_TEMP_TABLE_STATE state) +pool_temp_tables_add(char *tablename, POOL_TEMP_TABLE_STATE state) { MemoryContext old_context; - POOL_TEMP_TABLE * table; + POOL_TEMP_TABLE *table; if (!session_context) ereport(ERROR, @@ -1832,7 +1834,7 @@ pool_temp_tables_add(char * tablename, POOL_TEMP_TABLE_STATE state) */ POOL_TEMP_TABLE * -pool_temp_tables_find(char * tablename) +pool_temp_tables_find(char *tablename) { ListCell *cell; @@ -1842,7 +1844,8 @@ pool_temp_tables_find(char * tablename) foreach(cell, session_context->temp_tables) { - POOL_TEMP_TABLE * table = (POOL_TEMP_TABLE *)lfirst(cell); + POOL_TEMP_TABLE *table = (POOL_TEMP_TABLE *) lfirst(cell); + if (strcmp(tablename, table->tablename) == 0) return table; } @@ -1855,9 +1858,9 @@ pool_temp_tables_find(char * tablename) * the table state. */ void -pool_temp_tables_delete(char * tablename, POOL_TEMP_TABLE_STATE state) +pool_temp_tables_delete(char *tablename, POOL_TEMP_TABLE_STATE state) { - POOL_TEMP_TABLE * table; + POOL_TEMP_TABLE *table; MemoryContext old_context; if (!session_context) @@ -1914,7 +1917,7 @@ pool_temp_tables_commit_pending(void) Retry: foreach(cell, session_context->temp_tables) { - POOL_TEMP_TABLE * table = (POOL_TEMP_TABLE *)lfirst(cell); + POOL_TEMP_TABLE *table = (POOL_TEMP_TABLE *) lfirst(cell); if (table->state == TEMP_TABLE_CREATING) { @@ -1957,7 +1960,7 @@ pool_temp_tables_remove_pending(void) Retry: foreach(cell, session_context->temp_tables) { - POOL_TEMP_TABLE * table = (POOL_TEMP_TABLE *)lfirst(cell); + POOL_TEMP_TABLE *table = (POOL_TEMP_TABLE *) lfirst(cell); if (table->state == TEMP_TABLE_CREATING || table->state == TEMP_TABLE_DROPPING) { @@ -1985,7 +1988,8 @@ pool_temp_tables_dump(void) foreach(cell, session_context->temp_tables) { - POOL_TEMP_TABLE * table = (POOL_TEMP_TABLE *)lfirst(cell); + POOL_TEMP_TABLE *table = (POOL_TEMP_TABLE *) lfirst(cell); + ereport(DEBUG1, (errmsg("pool_temp_tables_dump: table %s state: %d", table->tablename, table->state))); diff --git a/src/include/auth/pool_auth.h b/src/include/auth/pool_auth.h index 08a21c8a7..a5ee9a183 100644 --- a/src/include/auth/pool_auth.h +++ b/src/include/auth/pool_auth.h @@ -22,12 +22,12 @@ #ifndef pool_auth_h #define pool_auth_h -extern void connection_do_auth(POOL_CONNECTION_POOL_SLOT * cp, char *password); -extern int pool_do_auth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend); -extern int pool_do_reauth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp); -extern void authenticate_frontend(POOL_CONNECTION * frontend); +extern void connection_do_auth(POOL_CONNECTION_POOL_SLOT *cp, char *password); +extern int pool_do_auth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); +extern int pool_do_reauth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp); +extern void authenticate_frontend(POOL_CONNECTION *frontend); extern void pool_random_salt(char *md5Salt); extern void pool_random(void *buf, size_t len); -#endif /* pool_auth_h */ +#endif /* pool_auth_h */ diff --git a/src/include/auth/pool_hba.h b/src/include/auth/pool_hba.h index a6e0a1533..e92404fd9 100644 --- a/src/include/auth/pool_hba.h +++ b/src/include/auth/pool_hba.h @@ -101,10 +101,11 @@ struct HbaLine char *ldapprefix; char *ldapsuffix; /* Additional LDAPl option with pgpool */ - bool backend_use_passwd; /* If true, pgpool use same password to auth backend */ + bool backend_use_passwd; /* If true, pgpool use same password to + * auth backend */ }; extern bool load_hba(char *hbapath); -extern void ClientAuthentication(POOL_CONNECTION * frontend); +extern void ClientAuthentication(POOL_CONNECTION *frontend); #endif /* POOL_HBA_H */ diff --git a/src/include/auth/pool_passwd.h b/src/include/auth/pool_passwd.h index ace61160c..17b07b456 100644 --- a/src/include/auth/pool_passwd.h +++ b/src/include/auth/pool_passwd.h @@ -29,7 +29,8 @@ #define POOL_PASSWD_FILENAME "pool_passwd" #define POOL_PASSWD_LEN 35 -#define MAX_POOL_PASSWD_LEN 132 /* In case of TEXT prefix(4byte) and plain text password(128byte)*/ +#define MAX_POOL_PASSWD_LEN 132 /* In case of TEXT prefix(4byte) and plain + * text password(128byte) */ #define MAX_USER_NAME_LEN 128 #define MAX_PGPASS_LEN 128 @@ -47,7 +48,7 @@ typedef enum * pgpool-II child main process */ POOL_PASSWD_RW, /* open pool_passwd in read/write mode. used * by pg_md5 command */ -} POOL_PASSWD_MODE; +} POOL_PASSWD_MODE; typedef enum PasswordType { @@ -64,16 +65,16 @@ typedef struct UserPassword char *userName; char *password; PasswordType passwordType; -} UserPassword; +} UserPassword; typedef struct PasswordMapping { UserPassword pgpoolUser; UserPassword backendUser; bool mappedUser; -} PasswordMapping; +} PasswordMapping; -extern PasswordMapping * pool_get_user_credentials(char *username); +extern PasswordMapping *pool_get_user_credentials(char *username); extern PasswordType get_password_type(const char *shadow_pass); extern void pool_init_pool_passwd(char *pool_passwd_filename, POOL_PASSWD_MODE mode); extern int pool_create_passwdent(char *username, char *passwd); @@ -84,6 +85,6 @@ extern void pool_reopen_passwd_file(void); extern char *get_decrypted_password(const char *shadow_pass); extern char *read_pool_key(char *key_file_path); extern char *get_pgpool_config_user_password(char *username, char *password_in_config); -extern void delete_passwordMapping(PasswordMapping * pwdMapping); -extern int check_password_type_is_not_md5(char *username, char *password_in_config); +extern void delete_passwordMapping(PasswordMapping *pwdMapping); +extern int check_password_type_is_not_md5(char *username, char *password_in_config); #endif /* POOL_PASSWD_H */ diff --git a/src/include/auth/scram-common.h b/src/include/auth/scram-common.h index 9852f48e6..56ca862c0 100644 --- a/src/include/auth/scram-common.h +++ b/src/include/auth/scram-common.h @@ -82,12 +82,12 @@ extern void scram_HMAC_update(scram_HMAC_ctx *ctx, const char *str, int slen); extern void scram_HMAC_final(uint8 *result, scram_HMAC_ctx *ctx); extern void scram_SaltedPassword(const char *password, const char *salt, - int saltlen, int iterations, uint8 *result); + int saltlen, int iterations, uint8 *result); extern void scram_H(const uint8 *str, int len, uint8 *result); extern void scram_ClientKey(const uint8 *salted_password, uint8 *result); extern void scram_ServerKey(const uint8 *salted_password, uint8 *result); extern char *scram_build_verifier(const char *salt, int saltlen, int iterations, - const char *password); + const char *password); #endif /* SCRAM_COMMON_H */ diff --git a/src/include/auth/scram.h b/src/include/auth/scram.h index 883ab1442..2eaf0c06c 100644 --- a/src/include/auth/scram.h +++ b/src/include/auth/scram.h @@ -48,17 +48,17 @@ /* Routines dedicated to authentication */ extern void *pg_be_scram_init(const char *username, const char *shadow_pass); -extern int pg_be_scram_exchange(void *opaq, char *input, int inputlen, - char **output, int *outputlen, char **logdetail); +extern int pg_be_scram_exchange(void *opaq, char *input, int inputlen, + char **output, int *outputlen, char **logdetail); /* Routines to handle and check SCRAM-SHA-256 verifier */ extern char *pg_be_scram_build_verifier(const char *password); extern bool scram_verify_plain_password(const char *username, - const char *password, const char *verifier); + const char *password, const char *verifier); extern void *pg_fe_scram_init(const char *username, const char *password); extern void pg_fe_scram_exchange(void *opaq, char *input, int inputlen, - char **output, int *outputlen, - bool *done, bool *success); + char **output, int *outputlen, + bool *done, bool *success); extern void pg_fe_scram_free(void *opaq); extern char *pg_fe_scram_build_verifier(const char *password); diff --git a/src/include/context/pool_process_context.h b/src/include/context/pool_process_context.h index a9f9e1002..194b6220a 100644 --- a/src/include/context/pool_process_context.h +++ b/src/include/context/pool_process_context.h @@ -26,7 +26,7 @@ #ifndef POOL_PROCESS_CONTEXT_H #define POOL_PROCESS_CONTEXT_H -//#include "pool.h" +/* #include "pool.h" */ #include "pcp/libpcp_ext.h" #include "utils/pool_signal.h" @@ -57,22 +57,22 @@ typedef struct unsigned int last_alarm_second; unsigned int undo_alarm_second; -} POOL_PROCESS_CONTEXT; +} POOL_PROCESS_CONTEXT; extern void pool_init_process_context(void); -extern POOL_PROCESS_CONTEXT * pool_get_process_context(void); -extern ProcessInfo * pool_get_my_process_info(void); +extern POOL_PROCESS_CONTEXT *pool_get_process_context(void); +extern ProcessInfo *pool_get_my_process_info(void); extern void pool_increment_local_session_id(void); -extern size_t pool_coninfo_size(void); +extern size_t pool_coninfo_size(void); extern int pool_coninfo_num(void); -extern ConnectionInfo * pool_coninfo(int child, int connection_pool, int backend); -extern ConnectionInfo * pool_coninfo_pid(int pid, int connection_pool, int backend); +extern ConnectionInfo *pool_coninfo(int child, int connection_pool, int backend); +extern ConnectionInfo *pool_coninfo_pid(int pid, int connection_pool, int backend); extern void pool_coninfo_set_frontend_connected(int proc_id, int pool_index); extern void pool_coninfo_unset_frontend_connected(int proc_id, int pool_index); -extern ConnectionInfo * pool_coninfo_backend_pid(int backend_pid, int *backend_node_id); -extern void pool_set_connection_will_be_terminated(ConnectionInfo * connInfo); -extern void pool_unset_connection_will_be_terminated(ConnectionInfo * connInfo); +extern ConnectionInfo *pool_coninfo_backend_pid(int backend_pid, int *backend_node_id); +extern void pool_set_connection_will_be_terminated(ConnectionInfo *connInfo); +extern void pool_unset_connection_will_be_terminated(ConnectionInfo *connInfo); extern void pool_alarm(pool_sighandler_t handler, unsigned int second); extern void pool_undo_alarm(void); diff --git a/src/include/context/pool_query_context.h b/src/include/context/pool_query_context.h index 8ca7fb336..1d1ef13eb 100644 --- a/src/include/context/pool_query_context.h +++ b/src/include/context/pool_query_context.h @@ -44,7 +44,7 @@ typedef enum POOL_PARSE_COMPLETE, POOL_BIND_COMPLETE, POOL_EXECUTE_COMPLETE -} POOL_QUERY_STATE; +} POOL_QUERY_STATE; /* * Query context: @@ -62,8 +62,8 @@ typedef struct Node *rewritten_parse_tree; /* rewritten raw parser output if any */ bool where_to_send[MAX_NUM_BACKENDS]; /* DB node map to send * query */ - int load_balance_node_id; /* load balance node id per statement */ - int virtual_main_node_id; /* the 1st DB node to send query */ + int load_balance_node_id; /* load balance node id per statement */ + int virtual_main_node_id; /* the 1st DB node to send query */ POOL_QUERY_STATE query_state[MAX_NUM_BACKENDS]; /* for extended query * protocol */ bool is_cache_safe; /* true if SELECT is safe to cache */ @@ -90,39 +90,39 @@ typedef struct * extended query, do not commit cache if * this flag is true. */ - bool atEnd; /* if true all rows have been already - * fetched from the portal */ + bool atEnd; /* if true all rows have been already fetched + * from the portal */ - bool partial_fetch; /* if true some rows have been fetched by - * an execute with non 0 row option */ + bool partial_fetch; /* if true some rows have been fetched by an + * execute with non 0 row option */ MemoryContext memory_context; /* memory context for query context */ -} POOL_QUERY_CONTEXT; +} POOL_QUERY_CONTEXT; -extern POOL_QUERY_CONTEXT * pool_init_query_context(void); -extern void pool_query_context_destroy(POOL_QUERY_CONTEXT * query_context); -extern POOL_QUERY_CONTEXT * pool_query_context_shallow_copy(POOL_QUERY_CONTEXT * query_context); -extern void pool_start_query(POOL_QUERY_CONTEXT * query_context, char *query, int len, Node *node); -extern void pool_set_node_to_be_sent(POOL_QUERY_CONTEXT * query_context, int node_id); -extern bool pool_is_node_to_be_sent(POOL_QUERY_CONTEXT * query_context, int node_id); -extern void pool_set_node_to_be_sent(POOL_QUERY_CONTEXT * query_context, int node_id); -extern void pool_unset_node_to_be_sent(POOL_QUERY_CONTEXT * query_context, int node_id); -extern void pool_clear_node_to_be_sent(POOL_QUERY_CONTEXT * query_context); -extern void pool_setall_node_to_be_sent(POOL_QUERY_CONTEXT * query_context); -extern bool pool_multi_node_to_be_sent(POOL_QUERY_CONTEXT * query_context); -extern void pool_where_to_send(POOL_QUERY_CONTEXT * query_context, char *query, Node *node); -extern POOL_STATUS pool_send_and_wait(POOL_QUERY_CONTEXT * query_context, int send_type, int node_id); -extern POOL_STATUS pool_extended_send_and_wait(POOL_QUERY_CONTEXT * query_context, char *kind, int len, char *contents, int send_type, int node_id, bool nowait); +extern POOL_QUERY_CONTEXT *pool_init_query_context(void); +extern void pool_query_context_destroy(POOL_QUERY_CONTEXT *query_context); +extern POOL_QUERY_CONTEXT *pool_query_context_shallow_copy(POOL_QUERY_CONTEXT *query_context); +extern void pool_start_query(POOL_QUERY_CONTEXT *query_context, char *query, int len, Node *node); +extern void pool_set_node_to_be_sent(POOL_QUERY_CONTEXT *query_context, int node_id); +extern bool pool_is_node_to_be_sent(POOL_QUERY_CONTEXT *query_context, int node_id); +extern void pool_set_node_to_be_sent(POOL_QUERY_CONTEXT *query_context, int node_id); +extern void pool_unset_node_to_be_sent(POOL_QUERY_CONTEXT *query_context, int node_id); +extern void pool_clear_node_to_be_sent(POOL_QUERY_CONTEXT *query_context); +extern void pool_setall_node_to_be_sent(POOL_QUERY_CONTEXT *query_context); +extern bool pool_multi_node_to_be_sent(POOL_QUERY_CONTEXT *query_context); +extern void pool_where_to_send(POOL_QUERY_CONTEXT *query_context, char *query, Node *node); +extern POOL_STATUS pool_send_and_wait(POOL_QUERY_CONTEXT *query_context, int send_type, int node_id); +extern POOL_STATUS pool_extended_send_and_wait(POOL_QUERY_CONTEXT *query_context, char *kind, int len, char *contents, int send_type, int node_id, bool nowait); extern Node *pool_get_parse_tree(void); extern char *pool_get_query_string(void); extern bool is_set_transaction_serializable(Node *node); extern bool is_start_transaction_query(Node *node); extern bool is_read_write(TransactionStmt *node); extern bool is_serializable(TransactionStmt *node); -extern bool pool_need_to_treat_as_if_default_transaction(POOL_QUERY_CONTEXT * query_context); +extern bool pool_need_to_treat_as_if_default_transaction(POOL_QUERY_CONTEXT *query_context); extern bool is_savepoint_query(Node *node); extern bool is_2pc_transaction_query(Node *node); -extern void pool_set_query_state(POOL_QUERY_CONTEXT * query_context, POOL_QUERY_STATE state); +extern void pool_set_query_state(POOL_QUERY_CONTEXT *query_context, POOL_QUERY_STATE state); extern int statecmp(POOL_QUERY_STATE s1, POOL_QUERY_STATE s2); extern bool pool_is_cache_safe(void); extern void pool_set_cache_safe(void); @@ -131,8 +131,8 @@ extern bool pool_is_cache_exceeded(void); extern void pool_set_cache_exceeded(void); extern void pool_unset_cache_exceeded(void); extern bool pool_is_transaction_read_only(Node *node); -extern void pool_force_query_node_to_backend(POOL_QUERY_CONTEXT * query_context, int backend_id); +extern void pool_force_query_node_to_backend(POOL_QUERY_CONTEXT *query_context, int backend_id); extern void check_object_relationship_list(char *name, bool is_func_name); -extern int wait_for_failover_to_finish(void); +extern int wait_for_failover_to_finish(void); #endif /* POOL_QUERY_CONTEXT_H */ diff --git a/src/include/context/pool_session_context.h b/src/include/context/pool_session_context.h index a662aa01c..e86966e2e 100644 --- a/src/include/context/pool_session_context.h +++ b/src/include/context/pool_session_context.h @@ -43,7 +43,7 @@ typedef enum POOL_READ_COMMITTED, /* Read committed */ POOL_REPEATABLE_READ, /* Repeatable read */ POOL_SERIALIZABLE /* Serializable */ -} POOL_TRANSACTION_ISOLATION; +} POOL_TRANSACTION_ISOLATION; /* * Return values for pool_use_sync_map @@ -63,7 +63,7 @@ typedef enum POOL_SENT_MESSAGE_CREATED, /* initial state of sent message */ POOL_SENT_MESSAGE_CLOSED /* sent message closed but close complete * message has not arrived yet */ -} POOL_SENT_MESSAGE_STATE; +} POOL_SENT_MESSAGE_STATE; /* * Message content of extended query @@ -90,7 +90,7 @@ typedef struct int param_offset; /* Offset from contents where actual bind * parameters are stored. This is meaningful * only when is_cache_safe is true. */ -} POOL_SENT_MESSAGE; +} POOL_SENT_MESSAGE; /* * List of POOL_SENT_MESSAGE (XXX this should have been implemented using a @@ -101,7 +101,7 @@ typedef struct int capacity; /* capacity of list */ int size; /* number of elements */ POOL_SENT_MESSAGE **sent_messages; -} POOL_SENT_MESSAGE_LIST; +} POOL_SENT_MESSAGE_LIST; /* * Received message queue used in extended query/streaming replication mode. @@ -123,7 +123,7 @@ typedef enum POOL_DESCRIBE, POOL_CLOSE, POOL_SYNC -} POOL_MESSAGE_TYPE; +} POOL_MESSAGE_TYPE; typedef struct { @@ -140,29 +140,35 @@ typedef struct bool not_forward_to_frontend; /* Do not forward response from * backend to frontend. This is * used by parse_before_bind() */ - bool node_ids[MAX_NUM_BACKENDS]; /* backend node map which this message was sent to */ + bool node_ids[MAX_NUM_BACKENDS]; /* backend node map which this + * message was sent to */ POOL_QUERY_CONTEXT *query_context; /* query context */ + /* * If "flush" message arrives, this flag is set to true until all buffered * message for frontend are sent out. */ bool flush_pending; - bool is_tx_started_by_multi_statement; /* true if an explicit transaction has been started by - multi statement query */ -} POOL_PENDING_MESSAGE; + bool is_tx_started_by_multi_statement; /* true if an explicit + * transaction has been + * started by multi + * statement query */ +} POOL_PENDING_MESSAGE; -typedef enum { - TEMP_TABLE_CREATING = 1, /* temp table creating, not committed yet. */ - TEMP_TABLE_DROPPING, /* temp table dropping, not committed yet. */ - TEMP_TABLE_CREATE_COMMITTED, /* temp table created and committed. */ - TEMP_TABLE_DROP_COMMITTED, /* temp table dropped and committed. */ -} POOL_TEMP_TABLE_STATE; +typedef enum +{ + TEMP_TABLE_CREATING = 1, /* temp table creating, not committed yet. */ + TEMP_TABLE_DROPPING, /* temp table dropping, not committed yet. */ + TEMP_TABLE_CREATE_COMMITTED, /* temp table created and committed. */ + TEMP_TABLE_DROP_COMMITTED, /* temp table dropped and committed. */ +} POOL_TEMP_TABLE_STATE; -typedef struct { +typedef struct +{ char tablename[MAX_IDENTIFIER_LEN]; /* temporary table name */ - POOL_TEMP_TABLE_STATE state; /* see above */ -} POOL_TEMP_TABLE; + POOL_TEMP_TABLE_STATE state; /* see above */ +} POOL_TEMP_TABLE; typedef enum @@ -306,7 +312,10 @@ typedef struct int preferred_main_node_id; #endif - /* Whether snapshot is acquired in this transaction. Only used by Snapshot Isolation mode. */ + /* + * Whether snapshot is acquired in this transaction. Only used by Snapshot + * Isolation mode. + */ SI_STATE si_state; /* Whether transaction is read only. Only used by Snapshot Isolation mode. */ SI_STATE transaction_read_only; @@ -321,22 +330,24 @@ typedef struct * transaction has been * started by a * multi-statement-query */ + /* - * True if query cache feature disabled until session ends. - * This is set when SET ROLE/SET SESSION AUTHORIZATION executed. + * True if query cache feature disabled until session ends. This is set + * when SET ROLE/SET SESSION AUTHORIZATION executed. */ - bool query_cache_disabled; + bool query_cache_disabled; + /* * True if query cache feature disabled until current transaction ends. * This is set when REVOKE executed in a transaction. */ - bool query_cache_disabled_tx; + bool query_cache_disabled_tx; -} POOL_SESSION_CONTEXT; +} POOL_SESSION_CONTEXT; -extern void pool_init_session_context(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend); +extern void pool_init_session_context(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); extern void pool_session_context_destroy(void); -extern POOL_SESSION_CONTEXT * pool_get_session_context(bool noerror); +extern POOL_SESSION_CONTEXT *pool_get_session_context(bool noerror); extern int pool_get_local_session_id(void); extern bool pool_is_query_in_progress(void); extern void pool_set_query_in_progress(void); @@ -350,18 +361,18 @@ extern void pool_unset_doing_extended_query_message(void); extern bool pool_is_ignore_till_sync(void); extern void pool_set_ignore_till_sync(void); extern void pool_unset_ignore_till_sync(void); -extern POOL_SENT_MESSAGE * pool_create_sent_message(char kind, int len, char *contents, - int num_tsparams, const char *name, - POOL_QUERY_CONTEXT * query_context); -extern void pool_add_sent_message(POOL_SENT_MESSAGE * message); +extern POOL_SENT_MESSAGE *pool_create_sent_message(char kind, int len, char *contents, + int num_tsparams, const char *name, + POOL_QUERY_CONTEXT *query_context); +extern void pool_add_sent_message(POOL_SENT_MESSAGE *message); extern bool pool_remove_sent_message(char kind, const char *name); extern void pool_remove_sent_messages(char kind); extern void pool_clear_sent_message_list(void); -extern void pool_sent_message_destroy(POOL_SENT_MESSAGE * message); -extern POOL_SENT_MESSAGE * pool_get_sent_message(char kind, const char *name, POOL_SENT_MESSAGE_STATE state); -extern void pool_set_sent_message_state(POOL_SENT_MESSAGE * message); +extern void pool_sent_message_destroy(POOL_SENT_MESSAGE *message); +extern POOL_SENT_MESSAGE *pool_get_sent_message(char kind, const char *name, POOL_SENT_MESSAGE_STATE state); +extern void pool_set_sent_message_state(POOL_SENT_MESSAGE *message); extern void pool_zap_query_context_in_sent_messages(POOL_QUERY_CONTEXT *query_context); -extern POOL_SENT_MESSAGE * pool_get_sent_message_by_query_context(POOL_QUERY_CONTEXT * query_context); +extern POOL_SENT_MESSAGE *pool_get_sent_message_by_query_context(POOL_QUERY_CONTEXT *query_context); extern void pool_unset_writing_transaction(void); extern void pool_set_writing_transaction(void); extern bool pool_is_writing_transaction(void); @@ -375,28 +386,28 @@ extern void pool_unset_command_success(void); extern void pool_set_command_success(void); extern bool pool_is_command_success(void); extern void pool_copy_prep_where(bool *src, bool *dest); -extern bool can_query_context_destroy(POOL_QUERY_CONTEXT * qc); +extern bool can_query_context_destroy(POOL_QUERY_CONTEXT *qc); extern void pool_pending_messages_init(void); extern void pool_pending_messages_destroy(void); -extern POOL_PENDING_MESSAGE * pool_pending_message_create(char kind, int len, char *contents); -extern void pool_pending_message_free_pending_message(POOL_PENDING_MESSAGE * message); -extern void pool_pending_message_dest_set(POOL_PENDING_MESSAGE * message, POOL_QUERY_CONTEXT * query_context); -extern void pool_pending_message_query_context_dest_set(POOL_PENDING_MESSAGE * message, POOL_QUERY_CONTEXT * query_context); -extern void pool_pending_message_query_set(POOL_PENDING_MESSAGE * message, POOL_QUERY_CONTEXT * query_context); -extern void pool_pending_message_add(POOL_PENDING_MESSAGE * message); -extern POOL_PENDING_MESSAGE * pool_pending_message_head_message(void); -extern POOL_PENDING_MESSAGE * pool_pending_message_pull_out(void); -extern POOL_PENDING_MESSAGE * pool_pending_message_get(POOL_MESSAGE_TYPE type); -extern char pool_get_close_message_spec(POOL_PENDING_MESSAGE * msg); -extern char *pool_get_close_message_name(POOL_PENDING_MESSAGE * msg); +extern POOL_PENDING_MESSAGE *pool_pending_message_create(char kind, int len, char *contents); +extern void pool_pending_message_free_pending_message(POOL_PENDING_MESSAGE *message); +extern void pool_pending_message_dest_set(POOL_PENDING_MESSAGE *message, POOL_QUERY_CONTEXT *query_context); +extern void pool_pending_message_query_context_dest_set(POOL_PENDING_MESSAGE *message, POOL_QUERY_CONTEXT *query_context); +extern void pool_pending_message_query_set(POOL_PENDING_MESSAGE *message, POOL_QUERY_CONTEXT *query_context); +extern void pool_pending_message_add(POOL_PENDING_MESSAGE *message); +extern POOL_PENDING_MESSAGE *pool_pending_message_head_message(void); +extern POOL_PENDING_MESSAGE *pool_pending_message_pull_out(void); +extern POOL_PENDING_MESSAGE *pool_pending_message_get(POOL_MESSAGE_TYPE type); +extern char pool_get_close_message_spec(POOL_PENDING_MESSAGE *msg); +extern char *pool_get_close_message_name(POOL_PENDING_MESSAGE *msg); extern void pool_pending_message_reset_previous_message(void); -extern void pool_pending_message_set_previous_message(POOL_PENDING_MESSAGE * message); -extern POOL_PENDING_MESSAGE * pool_pending_message_get_previous_message(void); +extern void pool_pending_message_set_previous_message(POOL_PENDING_MESSAGE *message); +extern POOL_PENDING_MESSAGE *pool_pending_message_get_previous_message(void); extern bool pool_pending_message_exists(void); extern const char *pool_pending_message_type_to_string(POOL_MESSAGE_TYPE type); extern void pool_check_pending_message_and_reply(POOL_MESSAGE_TYPE type, char kind); -extern POOL_PENDING_MESSAGE * pool_pending_message_find_lastest_by_query_context(POOL_QUERY_CONTEXT * qc); -extern int pool_pending_message_get_target_backend_id(POOL_PENDING_MESSAGE * msg); +extern POOL_PENDING_MESSAGE *pool_pending_message_find_lastest_by_query_context(POOL_QUERY_CONTEXT *qc); +extern int pool_pending_message_get_target_backend_id(POOL_PENDING_MESSAGE *msg); extern int pool_pending_message_get_message_num_by_backend_id(int backend_id); extern void pool_pending_message_set_flush_request(void); extern void dump_pending_message(void); @@ -409,12 +420,12 @@ extern void pool_unset_suspend_reading_from_frontend(void); extern void pool_temp_tables_init(void); extern void pool_temp_tables_destroy(void); -extern void pool_temp_tables_add(char * tablename, POOL_TEMP_TABLE_STATE state); -extern POOL_TEMP_TABLE * pool_temp_tables_find(char * tablename); -extern void pool_temp_tables_delete(char * tablename, POOL_TEMP_TABLE_STATE state); -extern void pool_temp_tables_commit_pending(void); -extern void pool_temp_tables_remove_pending(void); -extern void pool_temp_tables_dump(void); +extern void pool_temp_tables_add(char *tablename, POOL_TEMP_TABLE_STATE state); +extern POOL_TEMP_TABLE *pool_temp_tables_find(char *tablename); +extern void pool_temp_tables_delete(char *tablename, POOL_TEMP_TABLE_STATE state); +extern void pool_temp_tables_commit_pending(void); +extern void pool_temp_tables_remove_pending(void); +extern void pool_temp_tables_dump(void); extern bool is_tx_started_by_multi_statement_query(void); extern void set_tx_started_by_multi_statement_query(void); diff --git a/src/include/main/health_check.h b/src/include/main/health_check.h index ad26f2f0a..29f59b7fd 100644 --- a/src/include/main/health_check.h +++ b/src/include/main/health_check.h @@ -25,26 +25,36 @@ /* * Health check statistics per node */ -typedef struct { - uint64 total_count; /* total count of health check */ - uint64 success_count; /* total count of successful health check */ - uint64 fail_count; /* total count of failed health check */ - uint64 skip_count; /* total count of skipped health check */ - uint64 retry_count; /* total count of health check retries */ - uint32 max_retry_count; /* max retry count in a health check session */ - uint64 total_health_check_duration; /* sum of health check duration */ - int32 max_health_check_duration; /* maximum duration spent for a health check session in milli seconds */ - int32 min_health_check_duration; /* minimum duration spent for a health check session in milli seconds */ - time_t last_health_check; /* last health check timestamp */ - time_t last_successful_health_check; /* last successful health check timestamp */ - time_t last_skip_health_check; /* last skipped health check timestamp */ - time_t last_failed_health_check; /* last failed health check timestamp */ +typedef struct +{ + uint64 total_count; /* total count of health check */ + uint64 success_count; /* total count of successful health check */ + uint64 fail_count; /* total count of failed health check */ + uint64 skip_count; /* total count of skipped health check */ + uint64 retry_count; /* total count of health check retries */ + uint32 max_retry_count; /* max retry count in a health check + * session */ + uint64 total_health_check_duration; /* sum of health check + * duration */ + int32 max_health_check_duration; /* maximum duration spent for a + * health check session in milli + * seconds */ + int32 min_health_check_duration; /* minimum duration spent for a + * health check session in milli + * seconds */ + time_t last_health_check; /* last health check timestamp */ + time_t last_successful_health_check; /* last successful health + * check timestamp */ + time_t last_skip_health_check; /* last skipped health check timestamp */ + time_t last_failed_health_check; /* last failed health check + * timestamp */ } POOL_HEALTH_CHECK_STATISTICS; -extern volatile POOL_HEALTH_CHECK_STATISTICS *health_check_stats; /* health check stats area in shared memory */ +extern volatile POOL_HEALTH_CHECK_STATISTICS *health_check_stats; /* health check stats + * area in shared memory */ extern void do_health_check_child(int *node_id); -extern size_t health_check_stats_shared_memory_size(void); -extern void health_check_stats_init(POOL_HEALTH_CHECK_STATISTICS *addr); +extern size_t health_check_stats_shared_memory_size(void); +extern void health_check_stats_init(POOL_HEALTH_CHECK_STATISTICS *addr); -#endif /* health_check_h */ +#endif /* health_check_h */ diff --git a/src/include/main/pgpool_logger.h b/src/include/main/pgpool_logger.h index 0b2fc089c..82adbd2e1 100644 --- a/src/include/main/pgpool_logger.h +++ b/src/include/main/pgpool_logger.h @@ -67,7 +67,7 @@ typedef struct int32 pid; /* writer's pid */ char is_last; /* last chunk of message? 't' or 'f' ('T' or * 'F' for CSV case) */ - char data[]; /* data payload starts here */ + char data[]; /* data payload starts here */ } PipeProtoHeader; typedef union diff --git a/src/include/main/pool_internal_comms.h b/src/include/main/pool_internal_comms.h index 6b4dc60d8..b20b85d6f 100644 --- a/src/include/main/pool_internal_comms.h +++ b/src/include/main/pool_internal_comms.h @@ -42,4 +42,4 @@ extern void register_backend_state_sync_req_interrupt(void); extern void register_inform_quarantine_nodes_req(void); extern bool register_node_operation_request(POOL_REQUEST_KIND kind, int *node_id_set, int count, unsigned char flags); -#endif /* pool_internal_comms_h */ +#endif /* pool_internal_comms_h */ diff --git a/src/include/parser/explain.h b/src/include/parser/explain.h index 1a44ae216..b2255b01e 100644 --- a/src/include/parser/explain.h +++ b/src/include/parser/explain.h @@ -19,7 +19,7 @@ typedef enum ExplainFormat EXPLAIN_FORMAT_XML, EXPLAIN_FORMAT_JSON, EXPLAIN_FORMAT_YAML -} ExplainFormat; +} ExplainFormat; typedef struct ExplainState { @@ -41,12 +41,12 @@ typedef struct ExplainState List *rtable_names; /* alias names for RTEs */ List *deparse_cxt; /* context list for deparsing expressions */ Bitmapset *printed_subplans; /* ids of SubPlans we've printed */ -} ExplainState; +} ExplainState; /* Hook for plugins to get control in ExplainOneQuery() */ typedef void (*ExplainOneQuery_hook_type) (Query *query, IntoClause *into, - ExplainState *es, + ExplainState * es, const char *queryString, ParamListInfo params); extern PGDLLIMPORT ExplainOneQuery_hook_type ExplainOneQuery_hook; @@ -57,42 +57,42 @@ extern PGDLLIMPORT explain_get_index_name_hook_type explain_get_index_name_hook; extern void ExplainQuery(ExplainStmt *stmt, const char *queryString, - ParamListInfo params, DestReceiver *dest); + ParamListInfo params, DestReceiver * dest); -extern ExplainState *NewExplainState(void); +extern ExplainState * NewExplainState(void); extern TupleDesc ExplainResultDesc(ExplainStmt *stmt); extern void ExplainOneUtility(Node *utilityStmt, IntoClause *into, - ExplainState *es, - const char *queryString, ParamListInfo params); + ExplainState * es, + const char *queryString, ParamListInfo params); -extern void ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, - ExplainState *es, const char *queryString, - ParamListInfo params, const instr_time *planduration); +extern void ExplainOnePlan(PlannedStmt * plannedstmt, IntoClause *into, + ExplainState * es, const char *queryString, + ParamListInfo params, const instr_time * planduration); -extern void ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc); -extern void ExplainPrintTriggers(ExplainState *es, QueryDesc *queryDesc); +extern void ExplainPrintPlan(ExplainState * es, QueryDesc * queryDesc); +extern void ExplainPrintTriggers(ExplainState * es, QueryDesc * queryDesc); -extern void ExplainQueryText(ExplainState *es, QueryDesc *queryDesc); +extern void ExplainQueryText(ExplainState * es, QueryDesc * queryDesc); -extern void ExplainBeginOutput(ExplainState *es); -extern void ExplainEndOutput(ExplainState *es); -extern void ExplainSeparatePlans(ExplainState *es); +extern void ExplainBeginOutput(ExplainState * es); +extern void ExplainEndOutput(ExplainState * es); +extern void ExplainSeparatePlans(ExplainState * es); extern void ExplainPropertyList(const char *qlabel, List *data, - ExplainState *es); + ExplainState * es); extern void ExplainPropertyListNested(const char *qlabel, List *data, - ExplainState *es); + ExplainState * es); extern void ExplainPropertyText(const char *qlabel, const char *value, - ExplainState *es); + ExplainState * es); extern void ExplainPropertyInteger(const char *qlabel, int value, - ExplainState *es); + ExplainState * es); extern void ExplainPropertyLong(const char *qlabel, long value, - ExplainState *es); + ExplainState * es); extern void ExplainPropertyFloat(const char *qlabel, double value, int ndigits, - ExplainState *es); + ExplainState * es); extern void ExplainPropertyBool(const char *qlabel, bool value, - ExplainState *es); + ExplainState * es); #endif /* EXPLAIN_H */ diff --git a/src/include/parser/extensible.h b/src/include/parser/extensible.h index b11b0a58e..03089137e 100644 --- a/src/include/parser/extensible.h +++ b/src/include/parser/extensible.h @@ -27,7 +27,7 @@ typedef struct ExtensibleNode { NodeTag type; const char *extnodename; /* identifier of ExtensibleNodeMethods */ -} ExtensibleNode; +} ExtensibleNode; /* * node_size is the size of an extensible node of this type in bytes. @@ -62,11 +62,11 @@ typedef struct ExtensibleNodeMethods void (*nodeOut) (struct StringInfoData *str, const struct ExtensibleNode *node); void (*nodeRead) (struct ExtensibleNode *node); -} ExtensibleNodeMethods; +} ExtensibleNodeMethods; -extern void RegisterExtensibleNodeMethods(const ExtensibleNodeMethods *method); +extern void RegisterExtensibleNodeMethods(const ExtensibleNodeMethods * method); extern const ExtensibleNodeMethods *GetExtensibleNodeMethods(const char *name, - bool missing_ok); + bool missing_ok); /* * Flags for custom paths, indicating what capabilities the resulting scan diff --git a/src/include/parser/gramparse.h b/src/include/parser/gramparse.h index db644c278..9571a5ee3 100644 --- a/src/include/parser/gramparse.h +++ b/src/include/parser/gramparse.h @@ -69,10 +69,10 @@ typedef struct base_yy_extra_type /* from parser.c */ -extern int base_yylex(YYSTYPE *lvalp, YYLTYPE *llocp, - core_yyscan_t yyscanner); -extern int minimal_base_yylex(YYSTYPE *lvalp, YYLTYPE *llocp, +extern int base_yylex(YYSTYPE *lvalp, YYLTYPE * llocp, core_yyscan_t yyscanner); +extern int minimal_base_yylex(YYSTYPE *lvalp, YYLTYPE * llocp, + core_yyscan_t yyscanner); /* from gram.y */ extern void parser_init(base_yy_extra_type *yyext); diff --git a/src/include/parser/nodes.h b/src/include/parser/nodes.h index 1d5bb3ed6..d0d4f3cce 100644 --- a/src/include/parser/nodes.h +++ b/src/include/parser/nodes.h @@ -32,9 +32,9 @@ typedef enum NodeTag T_Invalid = 0, /* pgpool Extension */ - T_PgpoolVariableSetStmt, - T_PgpoolVariableShowStmt, - T_PgpoolQueryCacheStmt, + T_PgpoolVariableSetStmt, + T_PgpoolVariableShowStmt, + T_PgpoolQueryCacheStmt, #include "nodetags.h" } NodeTag; @@ -201,7 +201,7 @@ extern void outToken(struct StringInfoData *str, const char *s); extern void outBitmapset(struct StringInfoData *str, const struct Bitmapset *bms); extern void outDatum(struct StringInfoData *str, uintptr_t value, - int typlen, bool typbyval); + int typlen, bool typbyval); extern char *nodeToString(const void *obj); extern char *nodeToStringWithLocations(const void *obj); extern char *bmsToString(const struct Bitmapset *bms); @@ -362,7 +362,7 @@ typedef enum AggStrategy AGG_SORTED, /* grouped agg, input must be sorted */ AGG_HASHED, /* grouped agg, use internal hashtable */ AGG_MIXED, /* grouped agg, hash and sort both used */ -} AggStrategy; +} AggStrategy; /* * AggSplit - @@ -406,13 +406,13 @@ typedef enum SetOpCmd SETOPCMD_INTERSECT_ALL, SETOPCMD_EXCEPT, SETOPCMD_EXCEPT_ALL, -} SetOpCmd; +} SetOpCmd; typedef enum SetOpStrategy { SETOP_SORTED, /* input must be sorted */ SETOP_HASHED, /* use internal hashtable */ -} SetOpStrategy; +} SetOpStrategy; /* * OnConflictAction - diff --git a/src/include/parser/parsenodes.h b/src/include/parser/parsenodes.h index 1593bad65..cf0ee5bcd 100644 --- a/src/include/parser/parsenodes.h +++ b/src/include/parser/parsenodes.h @@ -916,7 +916,7 @@ typedef struct PartitionBoundSpec List *lowerdatums; /* List of PartitionRangeDatums */ List *upperdatums; /* List of PartitionRangeDatums */ - ParseLoc location; /* token location, or -1 if unknown */ + ParseLoc location; /* token location, or -1 if unknown */ } PartitionBoundSpec; /* @@ -950,7 +950,7 @@ typedef struct PartitionRangeDatum typedef struct SinglePartitionSpec { NodeTag type; -} SinglePartitionSpec; +} SinglePartitionSpec; /* * PartitionCmd - info for ALTER TABLE/INDEX ATTACH/DETACH PARTITION commands @@ -1299,7 +1299,7 @@ typedef struct RTEPermissionInfo Bitmapset *selectedCols; /* columns needing SELECT permission */ Bitmapset *insertedCols; /* columns needing INSERT permission */ Bitmapset *updatedCols; /* columns needing UPDATE permission */ -} RTEPermissionInfo; +} RTEPermissionInfo; /* * RangeTblFunction - @@ -2498,7 +2498,7 @@ typedef struct GrantStmt NodeTag type; bool is_grant; /* true = GRANT, false = REVOKE */ GrantTargetType targtype; /* type of the grant target */ - ObjectType objtype; /* kind of object being operated on */ + ObjectType objtype; /* kind of object being operated on */ List *objects; /* list of RangeVar nodes, ObjectWithArgs * nodes, or plain names (as String values) */ List *privileges; /* list of AccessPriv nodes */ @@ -3491,7 +3491,7 @@ typedef struct InlineCodeBlock Oid langOid; /* OID of selected language */ bool langIsTrusted; /* trusted property of the language */ bool atomic; /* atomic execution context */ -} InlineCodeBlock; +} InlineCodeBlock; /* ---------------------- * CALL statement @@ -3521,7 +3521,7 @@ typedef struct CallContext NodeTag type; bool atomic; -} CallContext; +} CallContext; /* ---------------------- * Alter Object Rename Statement diff --git a/src/include/parser/parser.h b/src/include/parser/parser.h index 9e9384d86..e412c438e 100644 --- a/src/include/parser/parser.h +++ b/src/include/parser/parser.h @@ -77,5 +77,5 @@ extern Node *makeIntConst(int val, int location); extern List *get_dummy_write_query_tree(void); extern List *get_dummy_read_query_tree(void); -extern Node * get_dummy_insert_query_node(void); +extern Node *get_dummy_insert_query_node(void); #endif /* PARSER_H */ diff --git a/src/include/parser/pg_class.h b/src/include/parser/pg_class.h index eb5c48ccf..7ebf4c439 100644 --- a/src/include/parser/pg_class.h +++ b/src/include/parser/pg_class.h @@ -145,7 +145,7 @@ CATALOG(pg_class,1259,RelationRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83,Relat * the format of pg_class relation. * ---------------- */ -typedef FormData_pg_class *Form_pg_class; +typedef FormData_pg_class * Form_pg_class; DECLARE_UNIQUE_INDEX_PKEY(pg_class_oid_index, 2662, ClassOidIndexId, pg_class, btree(oid oid_ops)); DECLARE_UNIQUE_INDEX(pg_class_relname_nsp_index, 2663, ClassNameNspIndexId, pg_class, btree(relname name_ops, relnamespace oid_ops)); @@ -164,7 +164,7 @@ MAKE_SYSCACHE(RELNAMENSP, pg_class_relname_nsp_index, 128); #define RELKIND_COMPOSITE_TYPE 'c' /* composite type */ #define RELKIND_FOREIGN_TABLE 'f' /* foreign table */ #define RELKIND_PARTITIONED_TABLE 'p' /* partitioned table */ -#define RELKIND_PARTITIONED_INDEX 'I' /* partitioned index */ +#define RELKIND_PARTITIONED_INDEX 'I' /* partitioned index */ #endif /* NOT_USED_IN_PGPOOL */ diff --git a/src/include/parser/pg_list.h b/src/include/parser/pg_list.h index 738185c19..4a63a466d 100644 --- a/src/include/parser/pg_list.h +++ b/src/include/parser/pg_list.h @@ -97,7 +97,7 @@ typedef struct ForBothCellState const List *l2; int i1; /* current element indexes */ int i2; -} ForBothCellState; +} ForBothCellState; typedef struct ForThreeState { @@ -105,7 +105,7 @@ typedef struct ForThreeState const List *l2; const List *l3; int i; /* common element index */ -} ForThreeState; +} ForThreeState; typedef struct ForFourState { @@ -114,7 +114,7 @@ typedef struct ForFourState const List *l3; const List *l4; int i; /* common element index */ -} ForFourState; +} ForFourState; typedef struct ForFiveState { @@ -124,7 +124,7 @@ typedef struct ForFiveState const List *l4; const List *l5; int i; /* common element index */ -} ForFiveState; +} ForFiveState; /* * These routines are small enough, and used often enough, to justify being diff --git a/src/include/parser/pg_trigger.h b/src/include/parser/pg_trigger.h index 8756f7560..745fe049a 100644 --- a/src/include/parser/pg_trigger.h +++ b/src/include/parser/pg_trigger.h @@ -79,7 +79,7 @@ CATALOG(pg_trigger,2620,TriggerRelationId) * the format of pg_trigger relation. * ---------------- */ -typedef FormData_pg_trigger *Form_pg_trigger; +typedef FormData_pg_trigger * Form_pg_trigger; DECLARE_TOAST(pg_trigger, 2336, 2337); diff --git a/src/include/parser/pg_wchar.h b/src/include/parser/pg_wchar.h index 807e2df83..59582d1ff 100644 --- a/src/include/parser/pg_wchar.h +++ b/src/include/parser/pg_wchar.h @@ -486,7 +486,7 @@ typedef struct uint8 b4_4_lower; /* min/max allowed value for 4th input byte */ uint8 b4_4_upper; -} pg_mb_radix_tree; +} pg_mb_radix_tree; /* * UTF-8 to local code conversion map (for combined characters) @@ -496,7 +496,7 @@ typedef struct uint32 utf1; /* UTF-8 code 1 */ uint32 utf2; /* UTF-8 code 2 */ uint32 code; /* local code */ -} pg_utf_to_local_combined; +} pg_utf_to_local_combined; /* * local code to UTF-8 conversion map (for combined characters) @@ -506,7 +506,7 @@ typedef struct uint32 code; /* local code */ uint32 utf1; /* UTF-8 code 1 */ uint32 utf2; /* UTF-8 code 2 */ -} pg_local_to_utf_combined; +} pg_local_to_utf_combined; /* * callback function for algorithmic encoding conversions (in either direction) @@ -745,14 +745,14 @@ extern unsigned short CNStoBIG5(unsigned short cns, unsigned char lc); extern int UtfToLocal(const unsigned char *utf, int len, unsigned char *iso, - const pg_mb_radix_tree *map, - const pg_utf_to_local_combined *cmap, int cmapsize, + const pg_mb_radix_tree * map, + const pg_utf_to_local_combined * cmap, int cmapsize, utf_local_conversion_func conv_func, int encoding, bool noError); extern int LocalToUtf(const unsigned char *iso, int len, unsigned char *utf, - const pg_mb_radix_tree *map, - const pg_local_to_utf_combined *cmap, int cmapsize, + const pg_mb_radix_tree * map, + const pg_local_to_utf_combined * cmap, int cmapsize, utf_local_conversion_func conv_func, int encoding, bool noError); @@ -787,7 +787,7 @@ extern int mic2latin_with_table(const unsigned char *mic, unsigned char *p, const unsigned char *tab, bool noError); #ifdef WIN32 -extern WCHAR *pgwin32_message_to_UTF16(const char *str, int len, int *utf16len); +extern WCHAR * pgwin32_message_to_UTF16(const char *str, int len, int *utf16len); #endif #endif /* PG_WCHAR_H */ diff --git a/src/include/parser/pool_parser.h b/src/include/parser/pool_parser.h index 1c1e46c25..f10a9f8da 100644 --- a/src/include/parser/pool_parser.h +++ b/src/include/parser/pool_parser.h @@ -186,6 +186,6 @@ typedef int16 AttrNumber; * for portability. Don't use "offsetof(struct s, f[0])", as this doesn't * work with MSVC and with C++ compilers. */ -#define FLEXIBLE_ARRAY_MEMBER /* empty */ +#define FLEXIBLE_ARRAY_MEMBER /* empty */ #endif /* POOL_PARSER_H */ diff --git a/src/include/parser/scanner.h b/src/include/parser/scanner.h index 4c6953a31..8c78b0a57 100644 --- a/src/include/parser/scanner.h +++ b/src/include/parser/scanner.h @@ -136,12 +136,12 @@ extern PGDLLIMPORT const uint16 ScanKeywordTokens[]; /* Entry points in parser/scan.l */ extern core_yyscan_t scanner_init(const char *str, - int slen, + int slen, core_yy_extra_type *yyext, const ScanKeywordList *keywordlist, const uint16 *keyword_tokens); extern void scanner_finish(core_yyscan_t yyscanner); -extern int core_yylex(core_YYSTYPE *yylval_param, YYLTYPE *yylloc_param, +extern int core_yylex(core_YYSTYPE *yylval_param, YYLTYPE * yylloc_param, core_yyscan_t yyscanner); extern int scanner_errposition(int location, core_yyscan_t yyscanner); extern void setup_scanner_errposition_callback(ScannerCallbackState *scbstate, diff --git a/src/include/pcp/libpcp_ext.h b/src/include/pcp/libpcp_ext.h index 3a6d87858..fe5d9a362 100644 --- a/src/include/pcp/libpcp_ext.h +++ b/src/include/pcp/libpcp_ext.h @@ -65,7 +65,7 @@ typedef enum CON_CONNECT_WAIT, /* waiting for connection starting */ CON_UP, /* up and running */ CON_DOWN /* down, disconnected */ -} BACKEND_STATUS; +} BACKEND_STATUS; /* backend status name strings */ #define BACKEND_STATUS_CON_UNUSED "unused" @@ -80,7 +80,7 @@ typedef enum typedef struct { BACKEND_STATUS status[MAX_NUM_BACKENDS]; -} BackendStatusRecord; +} BackendStatusRecord; typedef enum { @@ -88,7 +88,7 @@ typedef enum ROLE_REPLICA, ROLE_PRIMARY, ROLE_STANDBY -} SERVER_ROLE; +} SERVER_ROLE; /* * PostgreSQL backend descriptor. Placed on shared memory area. @@ -98,24 +98,31 @@ typedef struct char backend_hostname[MAX_DB_HOST_NAMELEN]; /* backend host name */ int backend_port; /* backend port numbers */ BACKEND_STATUS backend_status; /* backend status */ - char pg_backend_status[NAMEDATALEN]; /* backend status examined by show pool_nodes and pcp_node_info*/ + char pg_backend_status[NAMEDATALEN]; /* backend status examined by + * show pool_nodes and + * pcp_node_info */ time_t status_changed_time; /* backend status changed time */ double backend_weight; /* normalized backend load balance ratio */ double unnormalized_weight; /* described parameter */ char backend_data_directory[MAX_PATH_LENGTH]; - char backend_application_name[NAMEDATALEN]; /* application_name for walreceiver */ + char backend_application_name[NAMEDATALEN]; /* application_name for + * walreceiver */ unsigned short flag; /* various flags */ bool quarantine; /* true if node is CON_DOWN because of * quarantine */ uint64 standby_delay; /* The replication delay against the primary */ - bool standby_delay_by_time; /* true if standby_delay is measured in microseconds, not bytes */ + bool standby_delay_by_time; /* true if standby_delay is measured + * in microseconds, not bytes */ SERVER_ROLE role; /* Role of server. used by pcp_node_info and * failover() to keep track of quarantined * primary node */ - char pg_role[NAMEDATALEN]; /* backend role examined by show pool_nodes and pcp_node_info*/ - char replication_state [NAMEDATALEN]; /* "state" from pg_stat_replication */ - char replication_sync_state [NAMEDATALEN]; /* "sync_state" from pg_stat_replication */ -} BackendInfo; + char pg_role[NAMEDATALEN]; /* backend role examined by show + * pool_nodes and pcp_node_info */ + char replication_state[NAMEDATALEN]; /* "state" from + * pg_stat_replication */ + char replication_sync_state[NAMEDATALEN]; /* "sync_state" from + * pg_stat_replication */ +} BackendInfo; typedef struct { @@ -125,7 +132,7 @@ typedef struct * reloading pgpool.conf. */ BackendInfo backend_info[MAX_NUM_BACKENDS]; -} BackendDesc; +} BackendDesc; typedef enum { @@ -134,7 +141,7 @@ typedef enum IDLE, IDLE_IN_TRANS, CONNECTING -} ProcessStatus; +} ProcessStatus; /* * mamimum cancel key length @@ -152,11 +159,11 @@ typedef struct int major; /* protocol major version */ int minor; /* protocol minor version */ int pid; /* backend process id */ - char key[MAX_CANCELKEY_LENGTH]; /* cancel key */ + char key[MAX_CANCELKEY_LENGTH]; /* cancel key */ int32 keylen; /* cancel key length */ int counter; /* used counter */ time_t create_time; /* connection creation time */ - time_t client_connection_time; /* client connection time */ + time_t client_connection_time; /* client connection time */ time_t client_disconnection_time; /* client last disconnection time */ int client_idle_duration; /* client idle duration time (s) */ int load_balancing_node; /* load balancing node */ @@ -175,7 +182,7 @@ typedef struct * it should not be treated as a backend node failure. This flag is used * to handle pg_terminate_backend() */ -} ConnectionInfo; +} ConnectionInfo; /* * process information @@ -188,24 +195,27 @@ typedef struct { pid_t pid; /* OS's process id */ time_t start_time; /* fork() time */ - char connected; /* if not 0 this process is already used*/ + char connected; /* if not 0 this process is already used */ int wait_for_connect; /* waiting time for client connection (s) */ ConnectionInfo *connection_info; /* head of the connection info for * this process */ - int client_connection_count; /* how many times clients used this process */ - ProcessStatus status; - char client_host[NI_MAXHOST]; /* client host. Only valid if status != WAIT_FOR_CONNECT */ - char client_port[NI_MAXSERV]; /* client port. Only valid if status != WAIT_FOR_CONNECT */ - char statement[MAXSTMTLEN]; /* the last statement sent to backend */ - uint64 node_ids[2]; /* "statement" is sent to the node id (bitmap) */ + int client_connection_count; /* how many times clients used + * this process */ + ProcessStatus status; + char client_host[NI_MAXHOST]; /* client host. Only valid if + * status != WAIT_FOR_CONNECT */ + char client_port[NI_MAXSERV]; /* client port. Only valid if + * status != WAIT_FOR_CONNECT */ + char statement[MAXSTMTLEN]; /* the last statement sent to backend */ + uint64 node_ids[2]; /* "statement" is sent to the node id (bitmap) */ bool need_to_restart; /* If non 0, exit this child process as * soon as current session ends. Typical * case this flag being set is failback a * node in streaming replication mode. */ bool exit_if_idle; - int pooled_connections; /* Total number of pooled connections - * by this child */ -} ProcessInfo; + int pooled_connections; /* Total number of pooled connections by + * this child */ +} ProcessInfo; /* * reporting types @@ -229,7 +239,7 @@ typedef struct char name[POOLCONFIG_MAXNAMELEN + 1]; char value[POOLCONFIG_MAXVALLEN + 1]; char desc[POOLCONFIG_MAXDESCLEN + 1]; -} POOL_REPORT_CONFIG; +} POOL_REPORT_CONFIG; /* nodes report struct */ typedef struct @@ -248,7 +258,7 @@ typedef struct char rep_state[POOLCONFIG_MAXWEIGHTLEN + 1]; char rep_sync_state[POOLCONFIG_MAXWEIGHTLEN + 1]; char last_status_change[POOLCONFIG_MAXDATELEN]; -} POOL_REPORT_NODES; +} POOL_REPORT_NODES; /* processes report struct */ typedef struct @@ -261,7 +271,7 @@ typedef struct char backend_connection_time[POOLCONFIG_MAXDATELEN + 1]; char pool_counter[POOLCONFIG_MAXCOUNTLEN + 1]; char status[POOLCONFIG_MAXPROCESSSTATUSLEN + 1]; -} POOL_REPORT_PROCESSES; +} POOL_REPORT_PROCESSES; /* pools reporting struct */ typedef struct @@ -287,13 +297,13 @@ typedef struct char client_host[NI_MAXHOST]; char client_port[NI_MAXSERV]; char statement[MAXSTMTLEN]; -} POOL_REPORT_POOLS; +} POOL_REPORT_POOLS; /* version struct */ typedef struct { char version[POOLCONFIG_MAXVALLEN + 1]; -} POOL_REPORT_VERSION; +} POOL_REPORT_VERSION; /* health check statistics report struct */ typedef struct @@ -304,21 +314,21 @@ typedef struct char status[POOLCONFIG_MAXSTATLEN + 1]; char role[POOLCONFIG_MAXWEIGHTLEN + 1]; char last_status_change[POOLCONFIG_MAXDATELEN]; - char total_count[POOLCONFIG_MAXLONGCOUNTLEN+1]; - char success_count[POOLCONFIG_MAXLONGCOUNTLEN+1]; - char fail_count[POOLCONFIG_MAXLONGCOUNTLEN+1]; - char skip_count[POOLCONFIG_MAXLONGCOUNTLEN+1]; - char retry_count[POOLCONFIG_MAXLONGCOUNTLEN+1]; - char average_retry_count[POOLCONFIG_MAXLONGCOUNTLEN+1]; - char max_retry_count[POOLCONFIG_MAXCOUNTLEN+1]; - char max_health_check_duration[POOLCONFIG_MAXCOUNTLEN+1]; - char min_health_check_duration[POOLCONFIG_MAXCOUNTLEN+1]; - char average_health_check_duration[POOLCONFIG_MAXLONGCOUNTLEN+1]; + char total_count[POOLCONFIG_MAXLONGCOUNTLEN + 1]; + char success_count[POOLCONFIG_MAXLONGCOUNTLEN + 1]; + char fail_count[POOLCONFIG_MAXLONGCOUNTLEN + 1]; + char skip_count[POOLCONFIG_MAXLONGCOUNTLEN + 1]; + char retry_count[POOLCONFIG_MAXLONGCOUNTLEN + 1]; + char average_retry_count[POOLCONFIG_MAXLONGCOUNTLEN + 1]; + char max_retry_count[POOLCONFIG_MAXCOUNTLEN + 1]; + char max_health_check_duration[POOLCONFIG_MAXCOUNTLEN + 1]; + char min_health_check_duration[POOLCONFIG_MAXCOUNTLEN + 1]; + char average_health_check_duration[POOLCONFIG_MAXLONGCOUNTLEN + 1]; char last_health_check[POOLCONFIG_MAXDATELEN]; char last_successful_health_check[POOLCONFIG_MAXDATELEN]; char last_skip_health_check[POOLCONFIG_MAXDATELEN]; char last_failed_health_check[POOLCONFIG_MAXDATELEN]; -} POOL_HEALTH_CHECK_STATS; +} POOL_HEALTH_CHECK_STATS; /* show backend statistics report struct */ typedef struct @@ -333,11 +343,11 @@ typedef struct char update_cnt[POOLCONFIG_MAXWEIGHTLEN + 1]; char delete_cnt[POOLCONFIG_MAXWEIGHTLEN + 1]; char ddl_cnt[POOLCONFIG_MAXWEIGHTLEN + 1]; - char other_cnt[POOLCONFIG_MAXWEIGHTLEN + 1]; - char panic_cnt[POOLCONFIG_MAXWEIGHTLEN + 1]; - char fatal_cnt[POOLCONFIG_MAXWEIGHTLEN + 1]; - char error_cnt[POOLCONFIG_MAXWEIGHTLEN + 1]; -} POOL_BACKEND_STATS; + char other_cnt[POOLCONFIG_MAXWEIGHTLEN + 1]; + char panic_cnt[POOLCONFIG_MAXWEIGHTLEN + 1]; + char fatal_cnt[POOLCONFIG_MAXWEIGHTLEN + 1]; + char error_cnt[POOLCONFIG_MAXWEIGHTLEN + 1]; +} POOL_BACKEND_STATS; typedef enum { @@ -401,8 +411,8 @@ extern PCPResultInfo * pcp_node_info(PCPConnInfo * pcpCon, int nid); extern PCPResultInfo * pcp_health_check_stats(PCPConnInfo * pcpCon, int nid); extern PCPResultInfo * pcp_process_count(PCPConnInfo * pcpConn); extern PCPResultInfo * pcp_process_info(PCPConnInfo * pcpConn, int pid); -extern PCPResultInfo * pcp_reload_config(PCPConnInfo * pcpConn,char command_scope); -extern PCPResultInfo * pcp_log_rotate(PCPConnInfo * pcpConn,char command_scope); +extern PCPResultInfo * pcp_reload_config(PCPConnInfo * pcpConn, char command_scope); +extern PCPResultInfo * pcp_log_rotate(PCPConnInfo * pcpConn, char command_scope); extern PCPResultInfo * pcp_invalidate_query_cache(PCPConnInfo * pcpConn); extern PCPResultInfo * pcp_detach_node(PCPConnInfo * pcpConn, int nid); @@ -430,8 +440,8 @@ extern int pcp_result_is_empty(PCPResultInfo * res); extern char *role_to_str(SERVER_ROLE role); -extern int * pool_health_check_stats_offsets(int *n); -extern int * pool_report_pools_offsets(int *n); +extern int *pool_health_check_stats_offsets(int *n); +extern int *pool_report_pools_offsets(int *n); /* ------------------------------ * pcp_error.c diff --git a/src/include/pcp/pcp.h b/src/include/pcp/pcp.h index 2aab91a10..e40b96bdc 100644 --- a/src/include/pcp/pcp.h +++ b/src/include/pcp/pcp.h @@ -42,7 +42,8 @@ typedef struct PCPWDNodeInfo char nodeName[WD_MAX_HOST_NAMELEN]; char hostName[WD_MAX_HOST_NAMELEN]; /* host name */ char stateName[WD_MAX_HOST_NAMELEN]; /* state name */ - char membership_status_string[WD_MAX_HOST_NAMELEN]; /* membership status of this node */ + char membership_status_string[WD_MAX_HOST_NAMELEN]; /* membership status of + * this node */ int wd_port; /* watchdog port */ int wd_priority; /* node priority in leader election */ int pgpool_port; /* pgpool port */ diff --git a/src/include/pcp/pcp_stream.h b/src/include/pcp/pcp_stream.h index b718b64fd..ad006b4f5 100644 --- a/src/include/pcp/pcp_stream.h +++ b/src/include/pcp/pcp_stream.h @@ -41,13 +41,13 @@ typedef struct int po; /* pending data offset */ int bufsz; /* pending data buffer size */ int len; /* pending data length */ -} PCP_CONNECTION; +} PCP_CONNECTION; -extern PCP_CONNECTION * pcp_open(int fd); -extern void pcp_close(PCP_CONNECTION * pc); -extern int pcp_read(PCP_CONNECTION * pc, void *buf, int len); -extern int pcp_write(PCP_CONNECTION * pc, void *buf, int len); -extern int pcp_flush(PCP_CONNECTION * pc); +extern PCP_CONNECTION *pcp_open(int fd); +extern void pcp_close(PCP_CONNECTION *pc); +extern int pcp_read(PCP_CONNECTION *pc, void *buf, int len); +extern int pcp_write(PCP_CONNECTION *pc, void *buf, int len); +extern int pcp_flush(PCP_CONNECTION *pc); #define UNIX_DOMAIN_PATH "/tmp" diff --git a/src/include/pcp/pcp_worker.h b/src/include/pcp/pcp_worker.h index 6b5710fcd..90e6f82a3 100644 --- a/src/include/pcp/pcp_worker.h +++ b/src/include/pcp/pcp_worker.h @@ -29,4 +29,4 @@ extern void pcp_mark_recovery_finished(void); extern bool pcp_mark_recovery_in_progress(void); -#endif /* pcp_worker_h */ +#endif /* pcp_worker_h */ diff --git a/src/include/pcp/recovery.h b/src/include/pcp/recovery.h index bbf069033..2280a766c 100644 --- a/src/include/pcp/recovery.h +++ b/src/include/pcp/recovery.h @@ -24,7 +24,7 @@ extern void start_recovery(int recovery_node); extern void finish_recovery(void); -extern int wait_connection_closed(void); -extern int ensure_conn_counter_validity(void); +extern int wait_connection_closed(void); +extern int ensure_conn_counter_validity(void); -#endif /* recovery_h */ +#endif /* recovery_h */ diff --git a/src/include/pool.h b/src/include/pool.h index c34a06d2a..233d36608 100644 --- a/src/include/pool.h +++ b/src/include/pool.h @@ -95,7 +95,7 @@ typedef enum POOL_ERROR, POOL_FATAL, POOL_DEADLOCK -} POOL_STATUS; +} POOL_STATUS; typedef enum { @@ -103,7 +103,7 @@ typedef enum POOL_SOCKET_VALID, POOL_SOCKET_ERROR, POOL_SOCKET_EOF -} POOL_SOCKET_STATE; +} POOL_SOCKET_STATE; /* * Imported from src/include/libpq/pqcomm.h as of PostgreSQL 18. @@ -164,7 +164,7 @@ typedef struct StartupPacket_v2 char options[SM_OPTIONS]; /* Optional additional args */ char unused[SM_UNUSED]; /* Unused */ char tty[SM_TTY]; /* Tty for debug output */ -} StartupPacket_v2; +} StartupPacket_v2; /* startup packet info */ typedef struct @@ -185,8 +185,8 @@ typedef struct CancelPacket { int protoVersion; /* Protocol version */ int pid; /* backend process id */ - char key[MAX_CANCELKEY_LENGTH]; /* cancel key */ -} CancelPacket; + char key[MAX_CANCELKEY_LENGTH]; /* cancel key */ +} CancelPacket; #define MAX_PASSWORD_SIZE 1024 @@ -285,7 +285,7 @@ typedef struct PasswordMapping *passwordMapping; ConnectionInfo *con_info; /* shared memory coninfo used for handling the * query containing pg_terminate_backend */ -} POOL_CONNECTION; +} POOL_CONNECTION; /* * connection pool structure @@ -294,26 +294,28 @@ typedef struct { StartupPacket *sp; /* startup packet info */ int pid; /* backend pid */ - char key[MAX_CANCELKEY_LENGTH]; /* cancel key */ + char key[MAX_CANCELKEY_LENGTH]; /* cancel key */ + /* - * Cancel key length. In protocol version 3.0, it is 4. - * In 3.2 or later, the maximum length is 256. + * Cancel key length. In protocol version 3.0, it is 4. In 3.2 or later, + * the maximum length is 256. */ int32 keylen; POOL_CONNECTION *con; time_t closetime; /* absolute time in second when the connection * closed if 0, that means the connection is * under use. */ + /* * Protocol version after negotiation. If nplen == 0, no negotiation has * been done. */ int negotiated_major; int negotiated_minor; - char *negotiateProtocolMsg; /* Raw NegotiateProtocol messag */ + char *negotiateProtocolMsg; /* Raw NegotiateProtocol messag */ int32 nplen; /* message length of NegotiateProtocol messag */ -} POOL_CONNECTION_POOL_SLOT; +} POOL_CONNECTION_POOL_SLOT; typedef struct { @@ -324,7 +326,7 @@ typedef struct */ ConnectionInfo *info; POOL_CONNECTION_POOL_SLOT *slots[MAX_NUM_BACKENDS]; -} POOL_CONNECTION_POOL; +} POOL_CONNECTION_POOL; /* Defined in pool_session_context.h */ @@ -343,7 +345,7 @@ extern int pool_get_major_version(void); extern bool pool_is_node_to_be_sent_in_current_query(int node_id); extern int pool_virtual_main_db_node_id(void); -extern BACKEND_STATUS * my_backend_status[]; +extern BACKEND_STATUS *my_backend_status[]; extern int my_main_node_id; #define VALID_BACKEND(backend_id) \ @@ -402,7 +404,7 @@ typedef enum POOL_NODE_STATUS_PRIMARY, /* primary node */ POOL_NODE_STATUS_STANDBY, /* standby node */ POOL_NODE_STATUS_INVALID /* invalid node (split brain, stand alone) */ -} POOL_NODE_STATUS; +} POOL_NODE_STATUS; /* Clustering mode macros */ #define REPLICATION (pool_config->backend_clustering_mode == CM_NATIVE_REPLICATION || \ @@ -432,10 +434,11 @@ typedef enum #define ACCEPT_FD_SEM 4 #define SI_CRITICAL_REGION_SEM 5 #define FOLLOW_PRIMARY_SEM 6 -#define MAIN_EXIT_HANDLER_SEM 7 /* used in exit_hander in pgpool main process */ +#define MAIN_EXIT_HANDLER_SEM 7 /* used in exit_hander in pgpool main + * process */ #define MAX_REQUEST_QUEUE_SIZE 10 -#define MAX_SEC_WAIT_FOR_CLUSTER_TRANSACTION 10 /* time in seconds to keep +#define MAX_SEC_WAIT_FOR_CLUSTER_TRANSACTION 10 /* time in seconds to keep * retrying for a watchdog * command if the cluster is * not in stable state */ @@ -465,7 +468,7 @@ typedef enum CLOSE_IDLE_REQUEST, PROMOTE_NODE_REQUEST, NODE_QUARANTINE_REQUEST -} POOL_REQUEST_KIND; +} POOL_REQUEST_KIND; #define REQ_DETAIL_SWITCHOVER 0x00000001 /* failover due to switch over */ #define REQ_DETAIL_WATCHDOG 0x00000002 /* failover req from watchdog */ @@ -473,8 +476,10 @@ typedef enum * require majority vote */ #define REQ_DETAIL_UPDATE 0x00000008 /* failover req is just an update * node status request */ -#define REQ_DETAIL_PROMOTE 0x00000010 /* failover req is actually promoting the specified standby node. - * current primary will be detached */ +#define REQ_DETAIL_PROMOTE 0x00000010 /* failover req is actually + * promoting the specified standby + * node. current primary will be + * detached */ typedef struct { @@ -482,36 +487,46 @@ typedef struct unsigned char request_details; /* option flags kind */ int node_id[MAX_NUM_BACKENDS]; /* request node id */ int count; /* request node ids count */ -} POOL_REQUEST_NODE; +} POOL_REQUEST_NODE; typedef struct { POOL_REQUEST_NODE request[MAX_REQUEST_QUEUE_SIZE]; int request_queue_head; int request_queue_tail; - int main_node_id; /* the youngest node id which is not in down + int main_node_id; /* the youngest node id which is not in down * status */ int primary_node_id; /* the primary node id in streaming * replication mode */ - int conn_counter; /* number of connections from clients to pgpool */ + int conn_counter; /* number of connections from clients to + * pgpool */ bool switching; /* it true, failover or failback is in * progress */ - /* greater than 0 if follow primary command or detach_false_primary in - * execution */ + + /* + * greater than 0 if follow primary command or detach_false_primary in + * execution + */ bool follow_primary_count; - bool follow_primary_lock_pending; /* watchdog process can't wait - * for follow_primary lock acquisition - * in case it is held at the time of - * request. - * This flag indicates that lock was requested - * by watchdog coordinator and next contender should - * wait for the coordinator to release the lock - */ - bool follow_primary_lock_held_remotely; /* true when lock is held by - watchdog coordinator*/ - bool follow_primary_ongoing; /* true if follow primary command is ongoing */ - bool query_cache_invalidate_request; /* true if pcp_invalidate_query_cache requested */ -} POOL_REQUEST_INFO; + bool follow_primary_lock_pending; /* watchdog process can't wait + * for follow_primary lock + * acquisition in case it is + * held at the time of + * request. This flag + * indicates that lock was + * requested by watchdog + * coordinator and next + * contender should wait for + * the coordinator to release + * the lock */ + bool follow_primary_lock_held_remotely; /* true when lock is held + * by watchdog coordinator */ + bool follow_primary_ongoing; /* true if follow primary command is + * ongoing */ + bool query_cache_invalidate_request; /* true if + * pcp_invalidate_query_cache + * requested */ +} POOL_REQUEST_INFO; /* description of row. corresponding to RowDescription message */ typedef struct @@ -523,13 +538,13 @@ typedef struct int typeoid; /* data type oid */ int size; /* data length minus means variable data type */ int mod; /* data type modifier */ -} AttrInfo; +} AttrInfo; typedef struct { int num_attrs; /* number of attributes */ AttrInfo *attrinfo; -} RowDesc; +} RowDesc; typedef struct { @@ -539,7 +554,7 @@ typedef struct * excluding termination null */ char **data; /* actual row character data terminated with * null */ -} POOL_SELECT_RESULT; +} POOL_SELECT_RESULT; /* * recovery mode @@ -572,8 +587,9 @@ typedef enum PT_PCP_WORKER, PT_HEALTH_CHECK, PT_LOGGER, - PT_LAST_PTYPE /* last ptype marker. any ptype must be above this. */ -} ProcessType; + PT_LAST_PTYPE /* last ptype marker. any ptype must be above + * this. */ +} ProcessType; typedef enum @@ -585,17 +601,17 @@ typedef enum BACKEND_CONNECTING, PROCESSING, EXITING -} ProcessState; +} ProcessState; /* * Snapshot isolation manage area in shared memory */ typedef struct { - uint32 commit_counter; /* number of committing children */ + uint32 commit_counter; /* number of committing children */ uint32 snapshot_counter; /* number of snapshot acquiring children */ - pid_t *snapshot_waiting_children; /* array size is num_init_children */ - pid_t *commit_waiting_children; /* array size is num_init_children */ + pid_t *snapshot_waiting_children; /* array size is num_init_children */ + pid_t *commit_waiting_children; /* array size is num_init_children */ } SI_ManageInfo; /* @@ -606,14 +622,14 @@ extern pid_t mypid; /* parent pid */ extern pid_t myProcPid; /* process pid */ extern ProcessType processType; extern ProcessState processState; -extern bool reset_query_error; /* true if error occurs in reset queries */ +extern bool reset_query_error; /* true if error occurs in reset queries */ extern void set_application_name(ProcessType ptype); extern void set_application_name_with_string(char *string); extern void set_application_name_with_suffix(ProcessType ptype, int suffix); extern char *get_application_name(void); extern char *get_application_name_for_process(ProcessType ptype); -void SetProcessGlobalVariables(ProcessType pType); +void SetProcessGlobalVariables(ProcessType pType); extern volatile SI_ManageInfo *si_manage_info; extern volatile sig_atomic_t sigusr2_received; @@ -623,9 +639,9 @@ extern volatile sig_atomic_t backend_timer_expired; /* flag for connection extern volatile sig_atomic_t health_check_timer_expired; /* non 0 if health check * timer expired */ extern int my_proc_id; /* process table id (!= UNIX's PID) */ -extern ProcessInfo * process_info; /* shmem process information table */ -extern ConnectionInfo * con_info; /* shmem connection info table */ -extern POOL_REQUEST_INFO * Req_info; +extern ProcessInfo *process_info; /* shmem process information table */ +extern ConnectionInfo *con_info; /* shmem connection info table */ +extern POOL_REQUEST_INFO *Req_info; extern volatile sig_atomic_t *InRecovery; extern volatile sig_atomic_t got_sighup; extern volatile sig_atomic_t exit_request; @@ -660,7 +676,7 @@ extern void pcp_main(int *fds); extern void do_child(int *fds); extern void child_exit(int code); -extern void cancel_request(CancelPacket * sp, int32 len); +extern void cancel_request(CancelPacket *sp, int32 len); extern void check_stop_request(void); extern void pool_initialize_private_backend_status(void); extern int send_to_pg_frontend(char *data, int len, bool flush); @@ -673,22 +689,22 @@ extern void set_process_status(ProcessStatus status); extern void *pool_shared_memory_create(size_t size); extern void pool_shmem_exit(int code); extern void initialize_shared_memory_main_segment(size_t size); -extern void * pool_shared_memory_segment_get_chunk(size_t size); +extern void *pool_shared_memory_segment_get_chunk(size_t size); /* pgpool_main.c*/ -extern BackendInfo * pool_get_node_info(int node_number); +extern BackendInfo *pool_get_node_info(int node_number); extern int pool_get_node_count(void); extern int *pool_get_process_list(int *array_size); -extern ProcessInfo * pool_get_process_info(pid_t pid); +extern ProcessInfo *pool_get_process_info(pid_t pid); extern void pool_sleep(unsigned int second); extern int PgpoolMain(bool discard_status, bool clear_memcache_oidmaps); extern int pool_send_to_frontend(char *data, int len, bool flush); extern int pool_frontend_exists(void); extern pid_t pool_waitpid(int *status); extern int write_status_file(void); -extern POOL_NODE_STATUS * verify_backend_node_status(POOL_CONNECTION_POOL_SLOT * *slots); -extern POOL_NODE_STATUS * pool_get_node_status(void); +extern POOL_NODE_STATUS *verify_backend_node_status(POOL_CONNECTION_POOL_SLOT **slots); +extern POOL_NODE_STATUS *pool_get_node_status(void); extern void pool_set_backend_status_changed_time(int backend_id); extern int get_next_main_node(void); extern bool pool_acquire_follow_primary_lock(bool block, bool remote_reques); @@ -702,10 +718,10 @@ extern size_t strlcpy(char *dst, const char *src, size_t siz); /* pool_worker_child.c */ extern void do_worker_child(void); -extern int get_query_result(POOL_CONNECTION_POOL_SLOT * *slots, int backend_id, char *query, POOL_SELECT_RESULT * *res); +extern int get_query_result(POOL_CONNECTION_POOL_SLOT **slots, int backend_id, char *query, POOL_SELECT_RESULT **res); /* utils/pg_strong_random.c */ -void pg_strong_random_init(void); -bool pg_strong_random(void *buf, size_t len); +void pg_strong_random_init(void); +bool pg_strong_random(void *buf, size_t len); #endif /* POOL_H */ diff --git a/src/include/pool_config.h b/src/include/pool_config.h index 4dece394e..3d12c0a9f 100644 --- a/src/include/pool_config.h +++ b/src/include/pool_config.h @@ -55,20 +55,20 @@ typedef struct int type; int flag; regex_t regexv; -} RegPattern; +} RegPattern; typedef enum ProcessManagementModes { PM_STATIC = 1, PM_DYNAMIC -} ProcessManagementModes; +} ProcessManagementModes; typedef enum ProcessManagementSstrategies { PM_STRATEGY_AGGRESSIVE = 1, PM_STRATEGY_GENTLE, PM_STRATEGY_LAZY -} ProcessManagementSstrategies; +} ProcessManagementSstrategies; typedef enum NativeReplicationSubModes { @@ -85,28 +85,28 @@ typedef enum ClusteringModes CM_SLONY, CM_RAW, CM_SNAPSHOT_ISOLATION -} ClusteringModes; +} ClusteringModes; typedef enum LogStandbyDelayModes { LSD_ALWAYS = 1, LSD_OVER_THRESHOLD, LSD_NONE -} LogStandbyDelayModes; +} LogStandbyDelayModes; typedef enum MemCacheMethod { SHMEM_CACHE = 1, MEMCACHED_CACHE -} MemCacheMethod; +} MemCacheMethod; typedef enum WdLifeCheckMethod { LIFECHECK_BY_QUERY = 1, LIFECHECK_BY_HB, LIFECHECK_BY_EXTERNAL -} WdLifeCheckMethod; +} WdLifeCheckMethod; typedef enum DLBOW_OPTION { @@ -115,13 +115,13 @@ typedef enum DLBOW_OPTION DLBOW_TRANS_TRANSACTION, DLBOW_ALWAYS, DLBOW_DML_ADAPTIVE -} DLBOW_OPTION; +} DLBOW_OPTION; typedef enum RELQTARGET_OPTION { RELQTARGET_PRIMARY = 1, RELQTARGET_LOAD_BALANCE_NODE -} RELQTARGET_OPTION; +} RELQTARGET_OPTION; typedef enum CHECK_TEMP_TABLE_OPTION { @@ -130,7 +130,7 @@ typedef enum CHECK_TEMP_TABLE_OPTION CHECK_TEMP_NONE, CHECK_TEMP_ON, CHECK_TEMP_OFF, -} CHECK_TEMP_TABLE_OPTION; +} CHECK_TEMP_TABLE_OPTION; /* log_backend_messages */ typedef enum BGMSG_OPTION @@ -156,13 +156,13 @@ typedef struct WdNodeInfo char hostname[WD_MAX_HOST_NAMELEN]; /* host name */ int pgpool_port; /* pgpool port */ int wd_port; /* watchdog port */ -} WdNodeInfo; +} WdNodeInfo; typedef struct WdNodesConfig { int num_wd; /* number of watchdogs */ - WdNodeInfo wd_node_info[MAX_WATCHDOG_NUM]; -} WdNodesConfig; + WdNodeInfo wd_node_info[MAX_WATCHDOG_NUM]; +} WdNodesConfig; typedef struct @@ -170,7 +170,7 @@ typedef struct char addr[WD_MAX_HOST_NAMELEN]; char if_name[WD_MAX_IF_NAME_LEN]; int dest_port; -} WdHbIf; +} WdHbIf; #define WD_INFO(wd_id) (pool_config->wd_nodes.wd_node_info[(wd_id)]) #define WD_HB_IF(if_id) (pool_config->hb_dest_if[(if_id)]) @@ -190,7 +190,7 @@ typedef struct * retries */ int connect_timeout; /* timeout value before giving up * connecting to backend */ -} HealthCheckParams; +} HealthCheckParams; /* * For dml adaptive object relations @@ -203,41 +203,41 @@ typedef enum OBJECT_TYPE_FUNCTION, OBJECT_TYPE_RELATION, OBJECT_TYPE_UNKNOWN -} DBObjectTypes; +} DBObjectTypes; typedef struct { - char *name; + char *name; DBObjectTypes object_type; -} DBObject; +} DBObject; typedef struct { DBObject left_token; DBObject right_token; -} DBObjectRelation; +} DBObjectRelation; /* * configuration parameters */ typedef struct { - ClusteringModes backend_clustering_mode; /* Backend clustering mode */ - ProcessManagementModes process_management; + ClusteringModes backend_clustering_mode; /* Backend clustering mode */ + ProcessManagementModes process_management; ProcessManagementSstrategies process_management_strategy; - char **listen_addresses; /* hostnames/IP addresses to listen on */ + char **listen_addresses; /* hostnames/IP addresses to listen on */ int port; /* port # to bind */ - char **pcp_listen_addresses; /* PCP listen address to listen on */ + char **pcp_listen_addresses; /* PCP listen address to listen on */ int pcp_port; /* PCP port # to bind */ - char **unix_socket_directories; /* pgpool socket directories */ - char *unix_socket_group; /* owner group of pgpool sockets */ + char **unix_socket_directories; /* pgpool socket directories */ + char *unix_socket_group; /* owner group of pgpool sockets */ int unix_socket_permissions; /* pgpool sockets permissions */ char *wd_ipc_socket_dir; /* watchdog command IPC socket directory */ - char **pcp_socket_dir; /* PCP socket directory */ - int num_init_children; /* Maximum number of child to - * accept connections */ - int min_spare_children; /* Minimum number of idle children */ - int max_spare_children; /* Minimum number of idle children */ + char **pcp_socket_dir; /* PCP socket directory */ + int num_init_children; /* Maximum number of child to accept + * connections */ + int min_spare_children; /* Minimum number of idle children */ + int max_spare_children; /* Minimum number of idle children */ int listen_backlog_multiplier; /* determines the size of the * connection queue */ int reserved_connections; /* # of reserved connections */ @@ -270,7 +270,7 @@ typedef struct char *pid_file_name; /* pid file name */ bool replication_mode; /* replication mode */ bool log_connections; /* logs incoming connections */ - bool log_disconnections; /* logs closing connections */ + bool log_disconnections; /* logs closing connections */ bool log_pcp_processes; /* logs pcp processes */ bool log_hostname; /* resolve hostname */ bool enable_pool_hba; /* enables pool_hba.conf file @@ -295,19 +295,21 @@ typedef struct * false, just abort the * transaction to keep * the consistency. */ - bool auto_failback; /* If true, backend node reattach, - * when backend node detached and + bool auto_failback; /* If true, backend node reattach, when + * backend node detached and * replication_status is 'stream' */ - int auto_failback_interval; /* min interval of executing auto_failback */ + int auto_failback_interval; /* min interval of executing + * auto_failback */ bool replicate_select; /* replicate SELECT statement when load * balancing is disabled. */ char **reset_query_list; /* comma separated list of queries to be * issued at the end of session */ char **read_only_function_list; /* list of functions with no side - * effects */ + * effects */ char **write_function_list; /* list of functions with side effects */ - char **primary_routing_query_pattern_list; /* list of query patterns that - * should be sent to primary node */ + char **primary_routing_query_pattern_list; /* list of query patterns + * that should be sent to + * primary node */ char *log_line_prefix; /* printf-style string to output at * beginning of each log line */ int log_error_verbosity; /* controls how much detail about @@ -320,8 +322,8 @@ typedef struct bool logging_collector; int log_rotation_age; int log_rotation_size; - char *log_directory; - char *log_filename; + char *log_directory; + char *log_filename; bool log_truncate_on_rotation; int log_file_mode; @@ -333,15 +335,19 @@ typedef struct * greater than 0 to enable the * functionality. */ - int delay_threshold_by_time; /* If the standby server delays more than - * delay_threshold_in_time, any query goes to the - * primary only. The unit is in seconds. 0 - * disables the check. Default is 0. - * If delay_threshold_in_time is greater than 0, - * delay_threshold will be ignored. - * Note that health_check_period required to be - * greater than 0 to enable the - * functionality. */ + int delay_threshold_by_time; /* If the standby server delays + * more than + * delay_threshold_in_time, any + * query goes to the primary only. + * The unit is in seconds. 0 + * disables the check. Default is + * 0. If delay_threshold_in_time + * is greater than 0, + * delay_threshold will be + * ignored. Note that + * health_check_period required to + * be greater than 0 to enable the + * functionality. */ bool prefer_lower_delay_standby; @@ -366,11 +372,11 @@ typedef struct char *sr_check_database; /* PostgreSQL database name for streaming * replication check */ char *failover_command; /* execute command when failover happens */ - char *follow_primary_command; /* execute command when failover is + char *follow_primary_command; /* execute command when failover is * ended */ char *failback_command; /* execute command when failback happens */ - bool failover_on_backend_error; /* If true, trigger fail over when + bool failover_on_backend_error; /* If true, trigger fail over when * writing to the backend * communication socket fails. * This is the same behavior of @@ -378,8 +384,8 @@ typedef struct * set to false, pgpool will * report an error and disconnect * the session. */ - bool failover_on_backend_shutdown; /* If true, trigger fail over - when backend is going down */ + bool failover_on_backend_shutdown; /* If true, trigger fail over + * when backend is going down */ bool detach_false_primary; /* If true, detach false primary */ char *recovery_user; /* PostgreSQL user name for online recovery */ char *recovery_password; /* PostgreSQL user password for online @@ -406,8 +412,8 @@ typedef struct bool log_statement; /* logs all SQL statements */ bool log_per_node_statement; /* logs per node detailed SQL * statements */ - bool notice_per_node_statement; /* logs notice message for per node detailed SQL - * statements */ + bool notice_per_node_statement; /* logs notice message for per + * node detailed SQL statements */ bool log_client_messages; /* If true, logs any client messages */ int log_backend_messages; /* logs any backend messages */ char *lobj_lock_table; /* table name to lock for rewriting @@ -422,20 +428,27 @@ typedef struct /* followings till syslog, does not exist in the configuration file */ int num_reset_queries; /* number of queries in reset_query_list */ - int num_listen_addresses; /* number of entries in listen_addresses */ - int num_pcp_listen_addresses; /* number of entries in pcp_listen_addresses */ - int num_unix_socket_directories; /* number of entries in unix_socket_directories */ - int num_pcp_socket_directories; /* number of entries in pcp_socket_dir */ + int num_listen_addresses; /* number of entries in + * listen_addresses */ + int num_pcp_listen_addresses; /* number of entries in + * pcp_listen_addresses */ + int num_unix_socket_directories; /* number of entries in + * unix_socket_directories */ + int num_pcp_socket_directories; /* number of entries in + * pcp_socket_dir */ int num_read_only_function_list; /* number of functions in - * read_only_function_list */ + * read_only_function_list */ int num_write_function_list; /* number of functions in * write_function_list */ - int num_cache_safe_memqcache_table_list; /* number of functions in - * cache_safe_memqcache_table_list */ - int num_cache_unsafe_memqcache_table_list; /* number of functions in - * cache_unsafe_memqcache_table_list */ - int num_primary_routing_query_pattern_list; /* number of query patterns in - * primary_routing_query_pattern_list */ + int num_cache_safe_memqcache_table_list; /* number of functions + * in + * cache_safe_memqcache_table_list */ + int num_cache_unsafe_memqcache_table_list; /* number of functions + * in + * cache_unsafe_memqcache_table_list */ + int num_primary_routing_query_pattern_list; /* number of query + * patterns in + * primary_routing_query_pattern_list */ int num_wd_monitoring_interfaces_list; /* number of items in * wd_monitoring_interfaces_list */ /* ssl configuration */ @@ -446,25 +459,32 @@ typedef struct char *ssl_ca_cert; /* path to root (CA) certificate */ char *ssl_ca_cert_dir; /* path to directory containing CA * certificates */ - char *ssl_crl_file; /* path to the SSL certificate revocation list file */ + char *ssl_crl_file; /* path to the SSL certificate revocation list + * file */ char *ssl_ciphers; /* allowed ssl ciphers */ - bool ssl_prefer_server_ciphers; /*Use SSL cipher preferences, rather than the client's*/ + bool ssl_prefer_server_ciphers; /* Use SSL cipher preferences, + * rather than the client's */ char *ssl_ecdh_curve; /* the curve to use in ECDH key exchange */ - char *ssl_dh_params_file; /* path to the Diffie-Hellman parameters contained file */ - char *ssl_passphrase_command; /* path to the Diffie-Hellman parameters contained file */ + char *ssl_dh_params_file; /* path to the Diffie-Hellman parameters + * contained file */ + char *ssl_passphrase_command; /* path to the Diffie-Hellman + * parameters contained file */ int64 relcache_expire; /* relation cache life time in seconds */ int relcache_size; /* number of relation cache life entry */ - CHECK_TEMP_TABLE_OPTION check_temp_table; /* how to check temporary table */ + CHECK_TEMP_TABLE_OPTION check_temp_table; /* how to check temporary + * table */ bool check_unlogged_table; /* enable unlogged table check */ - bool enable_shared_relcache; /* If true, relation cache stored in memory cache */ - RELQTARGET_OPTION relcache_query_target; /* target node to send relcache queries */ + bool enable_shared_relcache; /* If true, relation cache stored in + * memory cache */ + RELQTARGET_OPTION relcache_query_target; /* target node to send + * relcache queries */ /* * followings are for regex support and do not exist in the configuration * file */ - RegPattern *lists_patterns; /* Precompiled regex patterns for write/readonly - * lists */ + RegPattern *lists_patterns; /* Precompiled regex patterns for + * write/readonly lists */ int pattc; /* number of regexp pattern */ int current_pattern_size; /* size of the regex pattern array */ @@ -502,8 +522,10 @@ typedef struct * by default */ char *memqcache_oiddir; /* Temporary work directory to record * table oids */ - char **cache_safe_memqcache_table_list; /* list of tables to memqcache */ - char **cache_unsafe_memqcache_table_list; /* list of tables not to memqcache */ + char **cache_safe_memqcache_table_list; /* list of tables to + * memqcache */ + char **cache_unsafe_memqcache_table_list; /* list of tables not to + * memqcache */ RegPattern *lists_memqcache_table_patterns; /* Precompiled regex patterns * for cache safe/unsafe lists */ @@ -515,12 +537,11 @@ typedef struct * user_redirect_preference_list = * 'postgres:primary,user[0-4]:1,user[5-9]:2' */ - char *user_redirect_preference_list; /* raw string in - * pgpool.conf */ - RegArray *redirect_usernames; /* Precompiled regex patterns for db + char *user_redirect_preference_list; /* raw string in pgpool.conf */ + RegArray *redirect_usernames; /* Precompiled regex patterns for db * preference list */ - Left_right_tokens *user_redirect_tokens; /* db redirect for dbname and node - * string */ + Left_right_tokens *user_redirect_tokens; /* db redirect for dbname and + * node string */ /* * database_redirect_preference_list = @@ -571,10 +592,13 @@ typedef struct * will not be load balanced * until the session ends. */ - char *dml_adaptive_object_relationship_list; /* objects relationship list*/ + char *dml_adaptive_object_relationship_list; /* objects relationship + * list */ DBObjectRelation *parsed_dml_adaptive_object_relationship_list; - bool statement_level_load_balance; /* if on, select load balancing node per statement */ + bool statement_level_load_balance; /* if on, select load + * balancing node per + * statement */ /* * add for watchdog @@ -589,23 +613,26 @@ typedef struct * failover requests to * build consensus */ bool enable_consensus_with_half_votes; - /* apply majority rule for consensus - * and quorum computation at 50% of - * votes in a cluster with an even - * number of nodes. - */ + + /* + * apply majority rule for consensus and quorum computation at 50% of + * votes in a cluster with an even number of nodes. + */ bool wd_remove_shutdown_nodes; - /* revoke membership of properly shutdown watchdog - * nodes. - */ - int wd_lost_node_removal_timeout; - /* timeout in seconds to revoke membership of - * LOST watchdog nodes - */ - int wd_no_show_node_removal_timeout; - /* time in seconds to revoke membership of - * NO-SHOW watchdog node - */ + + /* + * revoke membership of properly shutdown watchdog nodes. + */ + int wd_lost_node_removal_timeout; + + /* + * timeout in seconds to revoke membership of LOST watchdog nodes + */ + int wd_no_show_node_removal_timeout; + + /* + * time in seconds to revoke membership of NO-SHOW watchdog node + */ WdLifeCheckMethod wd_lifecheck_method; /* method of lifecheck. * 'heartbeat' or 'query' */ @@ -617,10 +644,11 @@ typedef struct * leader pgpool goes down. */ int wd_priority; /* watchdog node priority, during leader * election */ - int pgpool_node_id; /* pgpool (watchdog) node id */ + int pgpool_node_id; /* pgpool (watchdog) node id */ WdNodesConfig wd_nodes; /* watchdog lists */ char *trusted_servers; /* icmp reachable server list (A,B,C) */ - char *trusted_server_command; /* Executes this command when upper servers are observed */ + char *trusted_server_command; /* Executes this command when upper + * servers are observed */ char *delegate_ip; /* delegate IP address */ int wd_interval; /* lifecheck interval (sec) */ char *wd_authkey; /* Authentication key for watchdog @@ -642,17 +670,19 @@ typedef struct * signal (sec) */ int wd_heartbeat_deadtime; /* Deadtime interval for heartbeat * signal (sec) */ - WdHbIf hb_ifs[WD_MAX_IF_NUM]; /* heartbeat interfaces of all watchdog nodes */ - WdHbIf hb_dest_if[WD_MAX_IF_NUM]; /* heartbeat destination interfaces */ - int num_hb_dest_if; /* number of interface devices */ + WdHbIf hb_ifs[WD_MAX_IF_NUM]; /* heartbeat interfaces of all + * watchdog nodes */ + WdHbIf hb_dest_if[WD_MAX_IF_NUM]; /* heartbeat destination + * interfaces */ + int num_hb_dest_if; /* number of interface devices */ char **wd_monitoring_interfaces_list; /* network interface name list * to be monitored by watchdog */ - bool health_check_test; /* if on, enable health check testing */ + bool health_check_test; /* if on, enable health check testing */ -} POOL_CONFIG; +} POOL_CONFIG; -extern POOL_CONFIG * pool_config; -extern char config_file_dir[]; /* directory path of config file pgpool.conf */ +extern POOL_CONFIG *pool_config; +extern char config_file_dir[]; /* directory path of config file pgpool.conf */ typedef enum { @@ -661,7 +691,7 @@ typedef enum CFGCXT_RELOAD, CFGCXT_PCP, CFGCXT_SESSION -} ConfigContext; +} ConfigContext; typedef struct ConfigVariable { @@ -675,7 +705,7 @@ extern int pool_init_config(void); extern bool pool_get_config(const char *config_file, ConfigContext context); extern int eval_logical(const char *str); extern char *pool_flag_to_str(unsigned short flag); -extern char *backend_status_to_str(BackendInfo * bi); +extern char *backend_status_to_str(BackendInfo *bi); /* methods used for regexp support */ extern int add_regex_pattern(const char *type, char *s); diff --git a/src/include/pool_config_variables.h b/src/include/pool_config_variables.h index 7aaa65052..1c6a2955e 100644 --- a/src/include/pool_config_variables.h +++ b/src/include/pool_config_variables.h @@ -43,7 +43,7 @@ typedef enum WATCHDOG_LIFECHECK, GENERAL_CONFIG, CACHE_CONFIG -} config_group; +} config_group; typedef enum { @@ -58,7 +58,7 @@ typedef enum CONFIG_VAR_TYPE_DOUBLE_ARRAY, CONFIG_VAR_TYPE_STRING_ARRAY, CONFIG_VAR_TYPE_GROUP -} config_type; +} config_type; /* * The possible values of an enum variable are specified by an array of @@ -96,17 +96,17 @@ typedef enum #define DEFAULT_FOR_NO_VALUE_ARRAY_VAR 0x0020 /* From PG's src/include/utils/guc.h */ -#define GUC_UNIT_KB 0x1000 /* value is in kilobytes */ -#define GUC_UNIT_BLOCKS 0x2000 /* value is in blocks */ -#define GUC_UNIT_XBLOCKS 0x3000 /* value is in xlog blocks */ -#define GUC_UNIT_MB 0x4000 /* value is in megabytes */ -#define GUC_UNIT_BYTE 0x8000 /* value is in bytes */ -#define GUC_UNIT_MEMORY 0xF000 /* mask for size-related units */ - -#define GUC_UNIT_MS 0x10000 /* value is in milliseconds */ -#define GUC_UNIT_S 0x20000 /* value is in seconds */ -#define GUC_UNIT_MIN 0x30000 /* value is in minutes */ -#define GUC_UNIT_TIME 0xF0000 /* mask for time-related units */ +#define GUC_UNIT_KB 0x1000 /* value is in kilobytes */ +#define GUC_UNIT_BLOCKS 0x2000 /* value is in blocks */ +#define GUC_UNIT_XBLOCKS 0x3000 /* value is in xlog blocks */ +#define GUC_UNIT_MB 0x4000 /* value is in megabytes */ +#define GUC_UNIT_BYTE 0x8000 /* value is in bytes */ +#define GUC_UNIT_MEMORY 0xF000 /* mask for size-related units */ + +#define GUC_UNIT_MS 0x10000 /* value is in milliseconds */ +#define GUC_UNIT_S 0x20000 /* value is in seconds */ +#define GUC_UNIT_MIN 0x30000 /* value is in minutes */ +#define GUC_UNIT_TIME 0xF0000 /* mask for time-related units */ #define GUC_UNIT (GUC_UNIT_MEMORY | GUC_UNIT_TIME) /* @@ -335,17 +335,17 @@ struct config_grouped_array_var extern void InitializeConfigOptions(void); extern bool set_one_config_option(const char *name, const char *value, - ConfigContext context, GucSource source, int elevel); + ConfigContext context, GucSource source, int elevel); extern bool set_config_options(ConfigVariable *head_p, - ConfigContext context, GucSource source, int elevel); + ConfigContext context, GucSource source, int elevel); #ifndef POOL_PRIVATE -extern bool report_config_variable(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, const char *var_name); -extern bool report_all_variables(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend); -extern bool set_config_option_for_session(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, const char *name, const char *value); -bool reset_all_variables(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend); +extern bool report_config_variable(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, const char *var_name); +extern bool report_all_variables(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); +extern bool set_config_option_for_session(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, const char *name, const char *value); +bool reset_all_variables(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); #endif #endif /* POOL_CONFIG_VARIABLES_H */ diff --git a/src/include/pool_type.h b/src/include/pool_type.h index 8db8ed000..6e8fe85dc 100644 --- a/src/include/pool_type.h +++ b/src/include/pool_type.h @@ -108,12 +108,12 @@ typedef enum { LOAD_UNSELECTED = 0, LOAD_SELECTED -} LOAD_BALANCE_STATUS; +} LOAD_BALANCE_STATUS; extern int assert_enabled; extern void ExceptionalCondition(const char *conditionName, - const char *errorType, - const char *fileName, int lineNumber) __attribute__((noreturn)); + const char *errorType, + const char *fileName, int lineNumber) __attribute__((noreturn)); #define MAXIMUM_ALIGNOF 8 diff --git a/src/include/protocol/pool_connection_pool.h b/src/include/protocol/pool_connection_pool.h index b7f35ce7e..225b9c09d 100644 --- a/src/include/protocol/pool_connection_pool.h +++ b/src/include/protocol/pool_connection_pool.h @@ -22,14 +22,14 @@ #ifndef pool_connection_pool_h #define pool_connection_pool_h -extern POOL_CONNECTION_POOL * pool_connection_pool; /* connection pool */ +extern POOL_CONNECTION_POOL *pool_connection_pool; /* connection pool */ -extern int pool_init_cp(void); -extern POOL_CONNECTION_POOL * pool_create_cp(void); -extern POOL_CONNECTION_POOL * pool_get_cp(char *user, char *database, int protoMajor, int check_socket); +extern int pool_init_cp(void); +extern POOL_CONNECTION_POOL *pool_create_cp(void); +extern POOL_CONNECTION_POOL *pool_get_cp(char *user, char *database, int protoMajor, int check_socket); extern void pool_discard_cp(char *user, char *database, int protoMajor); extern void pool_backend_timer(void); -extern void pool_connection_pool_timer(POOL_CONNECTION_POOL * backend); +extern void pool_connection_pool_timer(POOL_CONNECTION_POOL *backend); extern RETSIGTYPE pool_backend_timer_handler(int sig); extern int connect_inet_domain_socket(int slot, bool retry); extern int connect_unix_domain_socket(int slot, bool retry); @@ -40,4 +40,4 @@ extern void close_all_backend_connections(void); extern void update_pooled_connection_count(void); extern int in_use_backend_id(POOL_CONNECTION_POOL *pool); -#endif /* pool_connection_pool_h */ +#endif /* pool_connection_pool_h */ diff --git a/src/include/protocol/pool_pg_utils.h b/src/include/protocol/pool_pg_utils.h index bd9493572..7a9117788 100644 --- a/src/include/protocol/pool_pg_utils.h +++ b/src/include/protocol/pool_pg_utils.h @@ -31,27 +31,26 @@ */ typedef struct { - short major; /* major version number in up to 3 digits decimal. - * Examples: 120, 110, 100, 96. - */ - short minor; /* minor version number in up to 2 digits decimal. - * Examples: 0, 1, 2, 10, 23. - */ - char version_string[MAX_PG_VERSION_STRING+1]; /* original version string */ -} PGVersion; + short major; /* major version number in up to 3 digits + * decimal. Examples: 120, 110, 100, 96. */ + short minor; /* minor version number in up to 2 digits + * decimal. Examples: 0, 1, 2, 10, 23. */ + char version_string[MAX_PG_VERSION_STRING + 1]; /* original version + * string */ +} PGVersion; -extern void send_startup_packet(POOL_CONNECTION_POOL_SLOT * cp); +extern void send_startup_packet(POOL_CONNECTION_POOL_SLOT *cp); extern void pool_free_startup_packet(StartupPacket *sp); -extern POOL_CONNECTION_POOL_SLOT * make_persistent_db_connection( - int db_node_id, char *hostname, int port, char *dbname, char *user, char *password, bool retry); -extern POOL_CONNECTION_POOL_SLOT * make_persistent_db_connection_noerror( - int db_node_id, char *hostname, int port, char *dbname, char *user, char *password, bool retry); -extern void discard_persistent_db_connection(POOL_CONNECTION_POOL_SLOT * cp); +extern POOL_CONNECTION_POOL_SLOT *make_persistent_db_connection( + int db_node_id, char *hostname, int port, char *dbname, char *user, char *password, bool retry); +extern POOL_CONNECTION_POOL_SLOT *make_persistent_db_connection_noerror( + int db_node_id, char *hostname, int port, char *dbname, char *user, char *password, bool retry); +extern void discard_persistent_db_connection(POOL_CONNECTION_POOL_SLOT *cp); extern int select_load_balancing_node(void); -extern PGVersion *Pgversion(POOL_CONNECTION_POOL * backend); +extern PGVersion *Pgversion(POOL_CONNECTION_POOL *backend); /* pool_pg_utils.c */ extern bool si_snapshot_prepared(void); @@ -62,4 +61,4 @@ extern void si_commit_request(void); extern void si_commit_done(void); extern int check_replication_delay(int node_id); -#endif /* pool_pg_utils_h */ +#endif /* pool_pg_utils_h */ diff --git a/src/include/protocol/pool_process_query.h b/src/include/protocol/pool_process_query.h index e799b4d9d..f54b694a1 100644 --- a/src/include/protocol/pool_process_query.h +++ b/src/include/protocol/pool_process_query.h @@ -30,57 +30,57 @@ extern void reset_variables(void); extern void reset_connection(void); -extern void per_node_statement_log(POOL_CONNECTION_POOL * backend, +extern void per_node_statement_log(POOL_CONNECTION_POOL *backend, int node_id, char *query); -extern int pool_extract_error_message(bool read_kind, POOL_CONNECTION * backend, +extern int pool_extract_error_message(bool read_kind, POOL_CONNECTION *backend, int major, bool unread, char **message); -extern POOL_STATUS do_command(POOL_CONNECTION * frontend, POOL_CONNECTION * backend, +extern POOL_STATUS do_command(POOL_CONNECTION *frontend, POOL_CONNECTION *backend, char *query, int protoMajor, int pid, char *key, int keylen, int no_ready_for_query); -extern void do_query(POOL_CONNECTION * backend, char *query, POOL_SELECT_RESULT * *result, int major); -extern void free_select_result(POOL_SELECT_RESULT * result); +extern void do_query(POOL_CONNECTION *backend, char *query, POOL_SELECT_RESULT **result, int major); +extern void free_select_result(POOL_SELECT_RESULT *result); extern int compare(const void *p1, const void *p2); -extern void do_error_execute_command(POOL_CONNECTION_POOL * backend, int node_id, int major); -extern POOL_STATUS pool_discard_packet_contents(POOL_CONNECTION_POOL * cp); +extern void do_error_execute_command(POOL_CONNECTION_POOL *backend, int node_id, int major); +extern POOL_STATUS pool_discard_packet_contents(POOL_CONNECTION_POOL *cp); extern void pool_dump_valid_backend(int backend_id); -extern bool pool_push_pending_data(POOL_CONNECTION * backend); +extern bool pool_push_pending_data(POOL_CONNECTION *backend); -extern void pool_send_frontend_exits(POOL_CONNECTION_POOL * backend); -extern POOL_STATUS ParameterStatus(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend); +extern void pool_send_frontend_exits(POOL_CONNECTION_POOL *backend); +extern POOL_STATUS ParameterStatus(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); -extern void pool_send_error_message(POOL_CONNECTION * frontend, int protoMajor, - char *code, - char *message, - char *detail, - char *hint, - char *file, - int line); -extern void pool_send_fatal_message(POOL_CONNECTION * frontend, int protoMajor, - char *code, - char *message, - char *detail, - char *hint, - char *file, - int line); -extern void pool_send_severity_message(POOL_CONNECTION * frontend, int protoMajor, - char *code, - char *message, - char *detail, - char *hint, - char *file, - char *severity, - int line); +extern void pool_send_error_message(POOL_CONNECTION *frontend, int protoMajor, + char *code, + char *message, + char *detail, + char *hint, + char *file, + int line); +extern void pool_send_fatal_message(POOL_CONNECTION *frontend, int protoMajor, + char *code, + char *message, + char *detail, + char *hint, + char *file, + int line); +extern void pool_send_severity_message(POOL_CONNECTION *frontend, int protoMajor, + char *code, + char *message, + char *detail, + char *hint, + char *file, + char *severity, + int line); -extern POOL_STATUS SimpleForwardToFrontend(char kind, POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend); -extern POOL_STATUS SimpleForwardToBackend(char kind, POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, int len, char *contents); +extern POOL_STATUS SimpleForwardToFrontend(char kind, POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); +extern POOL_STATUS SimpleForwardToBackend(char kind, POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, int len, char *contents); -extern POOL_STATUS pool_process_query(POOL_CONNECTION * frontend, -POOL_CONNECTION_POOL * backend, -int reset_request); -extern bool is_backend_cache_empty(POOL_CONNECTION_POOL * backend); -extern void pool_send_readyforquery(POOL_CONNECTION * frontend); +extern POOL_STATUS pool_process_query(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, + int reset_request); +extern bool is_backend_cache_empty(POOL_CONNECTION_POOL *backend); +extern void pool_send_readyforquery(POOL_CONNECTION *frontend); extern char *extract_error_kind(char *message, int major); -#endif /* pool_process_query_h */ +#endif /* pool_process_query_h */ diff --git a/src/include/protocol/pool_proto_modules.h b/src/include/protocol/pool_proto_modules.h index 28668aa6e..ae6ec5269 100644 --- a/src/include/protocol/pool_proto_modules.h +++ b/src/include/protocol/pool_proto_modules.h @@ -48,112 +48,112 @@ extern char *parsed_query; /* * modules defined in pool_proto_modules.c */ -extern POOL_STATUS SimpleQuery(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend, +extern POOL_STATUS SimpleQuery(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, int len, char *contents); -extern POOL_STATUS Execute(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend, +extern POOL_STATUS Execute(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, int len, char *contents); -extern POOL_STATUS Parse(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend, +extern POOL_STATUS Parse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, int len, char *contents); -extern POOL_STATUS Bind(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend, +extern POOL_STATUS Bind(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, int len, char *contents); -extern POOL_STATUS Describe(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend, +extern POOL_STATUS Describe(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, int len, char *contents); -extern POOL_STATUS Close(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend, +extern POOL_STATUS Close(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, int len, char *contents); -extern POOL_STATUS FunctionCall3(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend, +extern POOL_STATUS FunctionCall3(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, int len, char *contents); -extern POOL_STATUS ReadyForQuery(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend, bool send_ready, bool cache_commit); +extern POOL_STATUS ReadyForQuery(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, bool send_ready, bool cache_commit); -extern POOL_STATUS ParseComplete(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend); +extern POOL_STATUS ParseComplete(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); -extern POOL_STATUS BindComplete(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend); +extern POOL_STATUS BindComplete(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); -extern POOL_STATUS CloseComplete(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend); +extern POOL_STATUS CloseComplete(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); -extern POOL_STATUS ParameterDescription(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend); +extern POOL_STATUS ParameterDescription(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); -extern POOL_STATUS ErrorResponse3(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend); +extern POOL_STATUS ErrorResponse3(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); -extern POOL_STATUS CopyInResponse(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend); +extern POOL_STATUS CopyInResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); -extern POOL_STATUS CopyOutResponse(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend); +extern POOL_STATUS CopyOutResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); -extern POOL_STATUS CopyDataRows(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend, int copyin); +extern POOL_STATUS CopyDataRows(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, int copyin); -extern POOL_STATUS FunctionCall(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend); +extern POOL_STATUS FunctionCall(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); -extern POOL_STATUS ProcessFrontendResponse(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend); +extern POOL_STATUS ProcessFrontendResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); -extern POOL_STATUS ProcessBackendResponse(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend, +extern POOL_STATUS ProcessBackendResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, int *state, short *num_fields); -extern void handle_query_context(POOL_CONNECTION_POOL * backend);; +extern void handle_query_context(POOL_CONNECTION_POOL *backend);; extern void pool_emit_log_for_message_length_diff(int *length_array, char *name); -extern void per_node_statement_notice(POOL_CONNECTION_POOL * backend, int node_id, char *query); +extern void per_node_statement_notice(POOL_CONNECTION_POOL *backend, int node_id, char *query); extern void log_backend_messages(unsigned char kind, int backend_id); /* * modules defined in pool_proto2.c */ -extern POOL_STATUS AsciiRow(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend, +extern POOL_STATUS AsciiRow(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, short num_fields); -extern POOL_STATUS BinaryRow(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend, +extern POOL_STATUS BinaryRow(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, short num_fields); -extern POOL_STATUS CompletedResponse(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend); +extern POOL_STATUS CompletedResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); -extern POOL_STATUS CursorResponse(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend); +extern POOL_STATUS CursorResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); -extern void EmptyQueryResponse(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend); +extern void EmptyQueryResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); -extern POOL_STATUS FunctionResultResponse(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend); +extern POOL_STATUS FunctionResultResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); -extern POOL_STATUS NotificationResponse(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend); +extern POOL_STATUS NotificationResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); -extern int RowDescription(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend, - short *result); +extern int RowDescription(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, + short *result); -extern void wait_for_query_response_with_trans_cleanup(POOL_CONNECTION * frontend, POOL_CONNECTION * backend, +extern void wait_for_query_response_with_trans_cleanup(POOL_CONNECTION *frontend, POOL_CONNECTION *backend, int protoVersion, int pid, char *key, int keylen); -extern POOL_STATUS wait_for_query_response(POOL_CONNECTION * frontend, POOL_CONNECTION * backend, int protoVersion); +extern POOL_STATUS wait_for_query_response(POOL_CONNECTION *frontend, POOL_CONNECTION *backend, int protoVersion); extern bool is_select_query(Node *node, char *sql); extern bool is_commit_query(Node *node); extern bool is_rollback_query(Node *node); @@ -161,57 +161,57 @@ extern bool is_commit_or_rollback_query(Node *node); extern bool is_rollback_to_query(Node *node); extern bool is_strict_query(Node *node); /* returns non 0 if this is strict * query */ -extern int need_insert_lock(POOL_CONNECTION_POOL * backend, char *query, Node *node); -extern POOL_STATUS insert_lock(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, char *query, InsertStmt *node, int lock_kind); +extern int need_insert_lock(POOL_CONNECTION_POOL *backend, char *query, Node *node); +extern POOL_STATUS insert_lock(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, char *query, InsertStmt *node, int lock_kind); extern char *parse_copy_data(char *buf, int len, char delimiter, int col_id); extern int check_copy_from_stdin(Node *node); /* returns non 0 if this is a * COPY FROM STDIN */ -extern void query_ps_status(char *query, POOL_CONNECTION_POOL * backend); /* show ps status */ -extern POOL_STATUS start_internal_transaction(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, Node *node); -extern POOL_STATUS end_internal_transaction(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend); -extern int detect_deadlock_error(POOL_CONNECTION * backend, int major); -extern int detect_serialization_error(POOL_CONNECTION * backend, int major, bool unread); -extern int detect_active_sql_transaction_error(POOL_CONNECTION * backend, int major); -extern int detect_query_cancel_error(POOL_CONNECTION * backend, int major); -extern int detect_idle_in_transaction_session_timeout_error(POOL_CONNECTION * backend, int major); -extern int detect_idle_session_timeout_error(POOL_CONNECTION * backend, int major); -extern bool is_partition_table(POOL_CONNECTION_POOL * backend, Node *node); -extern POOL_STATUS pool_discard_packet(POOL_CONNECTION_POOL * cp); -extern void query_cache_register(char kind, POOL_CONNECTION * frontend, char *database, char *data, int data_len); +extern void query_ps_status(char *query, POOL_CONNECTION_POOL *backend); /* show ps status */ +extern POOL_STATUS start_internal_transaction(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, Node *node); +extern POOL_STATUS end_internal_transaction(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); +extern int detect_deadlock_error(POOL_CONNECTION *backend, int major); +extern int detect_serialization_error(POOL_CONNECTION *backend, int major, bool unread); +extern int detect_active_sql_transaction_error(POOL_CONNECTION *backend, int major); +extern int detect_query_cancel_error(POOL_CONNECTION *backend, int major); +extern int detect_idle_in_transaction_session_timeout_error(POOL_CONNECTION *backend, int major); +extern int detect_idle_session_timeout_error(POOL_CONNECTION *backend, int major); +extern bool is_partition_table(POOL_CONNECTION_POOL *backend, Node *node); +extern POOL_STATUS pool_discard_packet(POOL_CONNECTION_POOL *cp); +extern void query_cache_register(char kind, POOL_CONNECTION *frontend, char *database, char *data, int data_len); extern int is_drop_database(Node *node); /* returns non 0 if this is a DROP * DATABASE command */ -extern void send_simplequery_message(POOL_CONNECTION * backend, int len, char *string, int major); -extern POOL_STATUS send_extended_protocol_message(POOL_CONNECTION_POOL * backend, +extern void send_simplequery_message(POOL_CONNECTION *backend, int len, char *string, int major); +extern POOL_STATUS send_extended_protocol_message(POOL_CONNECTION_POOL *backend, int node_id, char *kind, int len, char *string); -extern int synchronize(POOL_CONNECTION * cp); -extern void read_kind_from_backend(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, char *decided_kind); -extern void read_kind_from_one_backend(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, char *kind, int node); -extern void do_error_command(POOL_CONNECTION * backend, int major); -extern void raise_intentional_error_if_need(POOL_CONNECTION_POOL * backend); +extern int synchronize(POOL_CONNECTION *cp); +extern void read_kind_from_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, char *decided_kind); +extern void read_kind_from_one_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, char *kind, int node); +extern void do_error_command(POOL_CONNECTION *backend, int major); +extern void raise_intentional_error_if_need(POOL_CONNECTION_POOL *backend); -extern void pool_at_command_success(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend); +extern void pool_at_command_success(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); /* * modules defined in CommandComplete.c */ -extern POOL_STATUS CommandComplete(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, bool command_complete); +extern POOL_STATUS CommandComplete(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, bool command_complete); -extern int pool_read_message_length(POOL_CONNECTION_POOL * cp); -extern int *pool_read_message_length2(POOL_CONNECTION_POOL * cp); -extern signed char pool_read_kind(POOL_CONNECTION_POOL * cp); -extern int pool_read_int(POOL_CONNECTION_POOL * cp); +extern int pool_read_message_length(POOL_CONNECTION_POOL *cp); +extern int *pool_read_message_length2(POOL_CONNECTION_POOL *cp); +extern signed char pool_read_kind(POOL_CONNECTION_POOL *cp); +extern int pool_read_int(POOL_CONNECTION_POOL *cp); /* pool_proto2.c */ -extern POOL_STATUS ErrorResponse(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend); +extern POOL_STATUS ErrorResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); -extern void NoticeResponse(POOL_CONNECTION * frontend, - POOL_CONNECTION_POOL * backend); +extern void NoticeResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); -extern char per_node_error_log(POOL_CONNECTION_POOL * backend, int node_id, +extern char per_node_error_log(POOL_CONNECTION_POOL *backend, int node_id, char *query, char *prefix, bool unread); extern void init_pi_set(void); diff --git a/src/include/query_cache/pool_memqcache.h b/src/include/query_cache/pool_memqcache.h index 0e6b1aba8..8c809b37e 100644 --- a/src/include/query_cache/pool_memqcache.h +++ b/src/include/query_cache/pool_memqcache.h @@ -42,7 +42,7 @@ * block". Each block is assigned a "cache block id", which is * starting with 0. */ -typedef char *POOL_CACHE_BLOCK; /* pointer to cache block */ +typedef char *POOL_CACHE_BLOCK; /* pointer to cache block */ typedef unsigned int POOL_CACHE_BLOCKID; /* cache block id */ typedef unsigned int POOL_CACHE_ITEMID; /* cache item id */ @@ -53,7 +53,7 @@ typedef struct { POOL_CACHE_BLOCKID blockid; POOL_CACHE_ITEMID itemid; -} POOL_CACHEID; /* cache id */ +} POOL_CACHEID; /* cache id */ /* * Each block has management space called "cache block header" at the @@ -70,12 +70,12 @@ typedef struct unsigned char flags; /* flags. see above */ unsigned int num_items; /* number of items */ unsigned int free_bytes; /* total free space in bytes */ -} POOL_CACHE_BLOCK_HEADER; +} POOL_CACHE_BLOCK_HEADER; typedef struct { char query_hash[POOL_MD5_HASHKEYLEN]; -} POOL_QUERY_HASH; +} POOL_QUERY_HASH; #define POOL_ITEM_USED 0x0001 /* is this item used? */ #define POOL_ITEM_HAS_NEXT 0x0002 /* is this item has "next" item? */ @@ -90,7 +90,7 @@ typedef struct POOL_CACHEID next; /* next cache item if any */ unsigned int offset; /* item offset in this block */ unsigned char flags; /* flags. see above */ -} POOL_CACHE_ITEM_POINTER; +} POOL_CACHE_ITEM_POINTER; /* * Each block holds several "cache item", which consists of variable @@ -114,13 +114,13 @@ typedef struct unsigne |