47 #include <openssl/conf.h>
48 #include <openssl/dh.h>
49 #ifndef OPENSSL_NO_ECDH
50 #include <openssl/ec.h>
52 #include <openssl/x509v3.h>
68 static int verify_cb(
int ok, X509_STORE_CTX *ctx);
71 const unsigned char **out,
72 unsigned char *outlen,
73 const unsigned char *in,
101 int ssl_ver_min = -1;
102 int ssl_ver_max = -1;
107 #ifdef HAVE_OPENSSL_INIT_SSL
108 OPENSSL_init_ssl(OPENSSL_INIT_LOAD_CONFIG, NULL);
110 OPENSSL_config(NULL);
112 SSL_load_error_strings();
127 context = SSL_CTX_new(SSLv23_method());
131 (
errmsg(
"could not create SSL context: %s",
140 SSL_CTX_set_mode(
context, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
145 (*openssl_tls_init_hook) (
context, isServerStart);
156 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
157 errmsg(
"could not load server certificate file \"%s\": %s",
170 if (SSL_CTX_use_PrivateKey_file(
context,
172 SSL_FILETYPE_PEM) != 1)
176 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
177 errmsg(
"private key file \"%s\" cannot be reloaded because it requires a passphrase",
181 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
182 errmsg(
"could not load private key file \"%s\": %s",
187 if (SSL_CTX_check_private_key(
context) != 1)
190 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
191 errmsg(
"check of private key failed: %s",
200 if (ssl_ver_min == -1)
204 (
errmsg(
"%s setting \"%s\" not supported by this build",
205 "ssl_min_protocol_version",
214 (
errmsg(
"could not set minimum SSL protocol version")));
223 if (ssl_ver_max == -1)
227 (
errmsg(
"%s setting \"%s\" not supported by this build",
228 "ssl_max_protocol_version",
237 (
errmsg(
"could not set maximum SSL protocol version")));
250 if (ssl_ver_min > ssl_ver_max)
253 (
errmsg(
"could not set SSL protocol version range"),
255 "ssl_min_protocol_version",
256 "ssl_max_protocol_version")));
262 SSL_CTX_set_options(
context, SSL_OP_NO_TICKET);
265 SSL_CTX_set_session_cache_mode(
context, SSL_SESS_CACHE_OFF);
268 SSL_CTX_set_options(
context, SSL_OP_NO_COMPRESSION);
278 #ifdef SSL_OP_NO_RENEGOTIATION
279 SSL_CTX_set_options(
context, SSL_OP_NO_RENEGOTIATION);
281 #ifdef SSL_OP_NO_CLIENT_RENEGOTIATION
282 SSL_CTX_set_options(
context, SSL_OP_NO_CLIENT_RENEGOTIATION);
295 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
296 errmsg(
"could not set the cipher list (no valid ciphers available)")));
302 SSL_CTX_set_options(
context, SSL_OP_CIPHER_SERVER_PREFERENCE);
309 STACK_OF(X509_NAME) * root_cert_list;
312 (root_cert_list = SSL_load_client_CA_file(
ssl_ca_file)) == NULL)
315 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
316 errmsg(
"could not load root certificate file \"%s\": %s",
328 SSL_CTX_set_client_CA_list(
context, root_cert_list);
337 SSL_VERIFY_CLIENT_ONCE),
348 X509_STORE *cvstore = SSL_CTX_get_cert_store(
context);
353 if (X509_STORE_load_locations(cvstore,
358 X509_STORE_set_flags(cvstore,
359 X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL);
364 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
365 errmsg(
"could not load SSL certificate revocation list file \"%s\": %s",
372 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
373 errmsg(
"could not load SSL certificate revocation list directory \"%s\": %s",
380 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
381 errmsg(
"could not load SSL certificate revocation list file \"%s\" or directory \"%s\": %s",
401 ssl_loaded_verify_locations =
true;
403 ssl_loaded_verify_locations =
false;
420 ssl_loaded_verify_locations =
false;
430 bool give_proto_hint;
438 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
439 errmsg(
"could not initialize SSL connection: SSL context not set up")));
452 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
453 errmsg(
"could not initialize SSL connection: %s",
460 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
461 errmsg(
"could not set SSL socket: %s",
465 port->ssl_in_use =
true;
479 r = SSL_accept(
port->ssl);
482 err = SSL_get_error(
port->ssl, r);
492 ecode = ERR_get_error();
495 case SSL_ERROR_WANT_READ:
496 case SSL_ERROR_WANT_WRITE:
505 if (
err == SSL_ERROR_WANT_READ)
511 WAIT_EVENT_SSL_OPEN_SERVER);
513 case SSL_ERROR_SYSCALL:
514 if (r < 0 && errno != 0)
517 errmsg(
"could not accept SSL connection: %m")));
520 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
521 errmsg(
"could not accept SSL connection: EOF detected")));
524 switch (ERR_GET_REASON(ecode))
539 case SSL_R_NO_PROTOCOLS_AVAILABLE:
540 case SSL_R_UNSUPPORTED_PROTOCOL:
541 case SSL_R_BAD_PROTOCOL_VERSION_NUMBER:
542 case SSL_R_UNKNOWN_PROTOCOL:
543 case SSL_R_UNKNOWN_SSL_VERSION:
544 case SSL_R_UNSUPPORTED_SSL_VERSION:
545 case SSL_R_WRONG_SSL_VERSION:
546 case SSL_R_WRONG_VERSION_NUMBER:
547 case SSL_R_TLSV1_ALERT_PROTOCOL_VERSION:
548 #ifdef SSL_R_VERSION_TOO_HIGH
549 case SSL_R_VERSION_TOO_HIGH:
551 #ifdef SSL_R_VERSION_TOO_LOW
552 case SSL_R_VERSION_TOO_LOW:
554 give_proto_hint =
true;
557 give_proto_hint =
false;
561 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
562 errmsg(
"could not accept SSL connection: %s",
566 errhint(
"This may indicate that the client does not support any SSL protocol version between %s and %s.",
569 MIN_OPENSSL_TLS_VERSION,
572 MAX_OPENSSL_TLS_VERSION) : 0));
575 case SSL_ERROR_ZERO_RETURN:
577 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
578 errmsg(
"could not accept SSL connection: EOF detected")));
582 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
583 errmsg(
"unrecognized SSL error code: %d",
591 port->alpn_used =
false;
593 const unsigned char *selected;
596 SSL_get0_alpn_selected(
port->ssl, &selected, &
len);
599 if (selected != NULL)
604 port->alpn_used =
true;
610 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
611 errmsg(
"received SSL connection request with unexpected ALPN protocol")));
617 port->peer = SSL_get_peer_certificate(
port->ssl);
620 port->peer_cn = NULL;
621 port->peer_dn = NULL;
622 port->peer_cert_valid =
false;
623 if (
port->peer != NULL)
626 X509_NAME *x509name = X509_get_subject_name(
port->peer);
629 BUF_MEM *bio_buf = NULL;
631 len = X509_NAME_get_text_by_NID(x509name, NID_commonName, NULL, 0);
637 r = X509_NAME_get_text_by_NID(x509name, NID_commonName, peer_cn,
651 if (
len != strlen(peer_cn))
654 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
655 errmsg(
"SSL certificate's common name contains embedded null")));
660 port->peer_cn = peer_cn;
663 bio = BIO_new(BIO_s_mem());
666 if (
port->peer_cn != NULL)
669 port->peer_cn = NULL;
681 if (X509_NAME_print_ex(bio, x509name, 0, XN_FLAG_RFC2253) == -1 ||
682 BIO_get_mem_ptr(bio, &bio_buf) <= 0)
685 if (
port->peer_cn != NULL)
688 port->peer_cn = NULL;
693 memcpy(peer_dn, bio_buf->data, bio_buf->length);
694 len = bio_buf->length;
697 if (
len != strlen(peer_dn))
700 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
701 errmsg(
"SSL certificate's distinguished name contains embedded null")));
703 if (
port->peer_cn != NULL)
706 port->peer_cn = NULL;
711 port->peer_dn = peer_dn;
713 port->peer_cert_valid =
true;
724 SSL_shutdown(
port->ssl);
727 port->ssl_in_use =
false;
732 X509_free(
port->peer);
739 port->peer_cn = NULL;
745 port->peer_dn = NULL;
758 n = SSL_read(
port->ssl, ptr,
len);
759 err = SSL_get_error(
port->ssl, n);
760 ecode = (
err != SSL_ERROR_NONE || n < 0) ? ERR_get_error() : 0;
766 case SSL_ERROR_WANT_READ:
771 case SSL_ERROR_WANT_WRITE:
776 case SSL_ERROR_SYSCALL:
778 if (n != -1 || errno == 0)
786 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
791 case SSL_ERROR_ZERO_RETURN:
797 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
798 errmsg(
"unrecognized SSL error code: %d",
817 n = SSL_write(
port->ssl, ptr,
len);
818 err = SSL_get_error(
port->ssl, n);
819 ecode = (
err != SSL_ERROR_NONE || n < 0) ? ERR_get_error() : 0;
825 case SSL_ERROR_WANT_READ:
830 case SSL_ERROR_WANT_WRITE:
835 case SSL_ERROR_SYSCALL:
843 if (n != -1 || errno == 0)
851 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
856 case SSL_ERROR_ZERO_RETURN:
867 (
errcode(ERRCODE_PROTOCOL_VIOLATION),
868 errmsg(
"unrecognized SSL error code: %d",
904 BIO_clear_retry_flags(h);
910 BIO_set_retry_read(h);
924 BIO_clear_retry_flags(h);
930 BIO_set_retry_write(h);
942 BIO_METHOD *biom = (BIO_METHOD *) BIO_s_socket();
943 #ifdef HAVE_BIO_METH_NEW
946 my_bio_index = BIO_get_new_index();
947 if (my_bio_index == -1)
949 my_bio_index |= (BIO_TYPE_DESCRIPTOR | BIO_TYPE_SOURCE_SINK);
950 my_bio_methods = BIO_meth_new(my_bio_index,
"PostgreSQL backend socket");
958 !BIO_meth_set_create(
my_bio_methods, BIO_meth_get_create(biom)) ||
959 !BIO_meth_set_destroy(
my_bio_methods, BIO_meth_get_destroy(biom)) ||
960 !BIO_meth_set_callback_ctrl(
my_bio_methods, BIO_meth_get_callback_ctrl(biom)))
984 BIO_METHOD *bio_method;
987 if (bio_method == NULL)
989 SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
992 bio = BIO_new(bio_method);
996 SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
999 BIO_set_app_data(bio,
port);
1001 BIO_set_fd(bio,
fd, BIO_NOCLOSE);
1002 SSL_set_bio(
port->ssl, bio, bio);
1027 errmsg(
"could not open DH parameters file \"%s\": %m",
1032 dh = PEM_read_DHparams(fp, NULL, NULL, NULL);
1038 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
1039 errmsg(
"could not load DH parameters file: %s",
1045 if (DH_check(dh, &codes) == 0)
1048 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
1049 errmsg(
"invalid DH parameters: %s",
1054 if (codes & DH_CHECK_P_NOT_PRIME)
1057 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
1058 errmsg(
"invalid DH parameters: p is not prime")));
1062 if ((codes & DH_NOT_SUITABLE_GENERATOR) &&
1063 (codes & DH_CHECK_P_NOT_SAFE_PRIME))
1066 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
1067 errmsg(
"invalid DH parameters: neither suitable generator or safe prime")));
1091 dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);
1108 const char *prompt =
"Enter PEM pass phrase:";
1144 size_t namelen = strlen(
name);
1145 char *truncated =
name;
1162 truncated[0] = truncated[1] = truncated[2] =
'.';
1186 const char *errstring;
1197 depth = X509_STORE_CTX_get_error_depth(ctx);
1198 errcode = X509_STORE_CTX_get_error(ctx);
1199 errstring = X509_verify_cert_error_string(
errcode);
1203 _(
"Client certificate verification failed at depth %d: %s."),
1206 cert = X509_STORE_CTX_get_current_cert(ctx);
1234 sn = X509_get_serialNumber(cert);
1235 b = ASN1_INTEGER_to_BN(sn, NULL);
1236 serialno = BN_bn2dec(
b);
1240 _(
"Failed certificate data (unverified): subject \"%s\", serial number %s, issuer \"%s\"."),
1241 sub_prepared, serialno ? serialno :
_(
"unknown"),
1245 OPENSSL_free(serialno);
1246 pfree(iss_prepared);
1247 pfree(sub_prepared);
1265 desc = SSL_state_string_long(ssl);
1269 case SSL_CB_HANDSHAKE_START:
1273 case SSL_CB_HANDSHAKE_DONE:
1277 case SSL_CB_ACCEPT_LOOP:
1281 case SSL_CB_ACCEPT_EXIT:
1285 case SSL_CB_CONNECT_LOOP:
1289 case SSL_CB_CONNECT_EXIT:
1293 case SSL_CB_READ_ALERT:
1297 case SSL_CB_WRITE_ALERT:
1313 const unsigned char **out,
1314 unsigned char *outlen,
1315 const unsigned char *in,
1326 Assert(userdata != NULL);
1331 retval = SSL_select_next_proto((
unsigned char **) out, outlen,
1334 if (*out == NULL || *outlen >
sizeof(
alpn_protos) || *outlen <= 0)
1335 return SSL_TLSEXT_ERR_NOACK;
1337 if (retval == OPENSSL_NPN_NEGOTIATED)
1338 return SSL_TLSEXT_ERR_OK;
1339 else if (retval == OPENSSL_NPN_NO_OVERLAP)
1340 return SSL_TLSEXT_ERR_NOACK;
1342 return SSL_TLSEXT_ERR_NOACK;
1364 SSL_CTX_set_options(
context, SSL_OP_SINGLE_DH_USE);
1373 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
1374 errmsg(
"DH: could not load DH parameters")));
1378 if (SSL_CTX_set_tmp_dh(
context, dh) != 1)
1381 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
1382 errmsg(
"DH: could not set DH parameters: %s",
1400 #ifndef OPENSSL_NO_ECDH
1408 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
1413 ecdh = EC_KEY_new_by_curve_name(nid);
1417 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
1418 errmsg(
"ECDH: could not create key")));
1422 SSL_CTX_set_options(
context, SSL_OP_SINGLE_ECDH_USE);
1423 SSL_CTX_set_tmp_ecdh(
context, ecdh);
1442 const char *errreason;
1443 static char errbuf[36];
1446 return _(
"no SSL error reported");
1447 errreason = ERR_reason_error_string(ecode);
1448 if (errreason != NULL)
1457 #ifdef ERR_SYSTEM_ERROR
1458 if (ERR_SYSTEM_ERROR(ecode))
1459 return strerror(ERR_GET_REASON(ecode));
1463 snprintf(errbuf,
sizeof(errbuf),
_(
"SSL error code %lu"), ecode);
1474 SSL_get_cipher_bits(
port->ssl, &bits);
1485 return SSL_get_version(
port->ssl);
1494 return SSL_get_cipher(
port->ssl);
1522 ASN1_INTEGER *serial;
1526 serial = X509_get_serialNumber(
port->peer);
1527 b = ASN1_INTEGER_to_BN(serial, NULL);
1543 const EVP_MD *algo_type = NULL;
1544 unsigned char hash[EVP_MAX_MD_SIZE];
1545 unsigned int hash_size;
1549 server_cert = SSL_get_certificate(
port->ssl);
1550 if (server_cert == NULL)
1558 #if HAVE_X509_GET_SIGNATURE_INFO
1559 if (!X509_get_signature_info(server_cert, &algo_nid, NULL, NULL, NULL))
1561 if (!OBJ_find_sigid_algs(X509_get_signature_nid(server_cert),
1564 elog(
ERROR,
"could not determine server certificate signature algorithm");
1576 algo_type = EVP_sha256();
1579 algo_type = EVP_get_digestbynid(algo_nid);
1580 if (algo_type == NULL)
1581 elog(
ERROR,
"could not find digest for NID %s",
1582 OBJ_nid2sn(algo_nid));
1587 if (!X509_digest(server_cert, algo_type,
hash, &hash_size))
1588 elog(
ERROR,
"could not generate server certificate hash");
1590 cert_hash =
palloc(hash_size);
1591 memcpy(cert_hash,
hash, hash_size);
1604 BIO *membuf = BIO_new(BIO_s_mem());
1607 count = X509_NAME_entry_count(
name);
1610 const char *field_name;
1619 (
errcode(ERRCODE_OUT_OF_MEMORY),
1620 errmsg(
"could not create BIO")));
1622 (void) BIO_set_close(membuf, BIO_CLOSE);
1623 for (
i = 0;
i < count;
i++)
1625 e = X509_NAME_get_entry(
name,
i);
1626 nid = OBJ_obj2nid(X509_NAME_ENTRY_get_object(
e));
1627 if (nid == NID_undef)
1629 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1630 errmsg(
"could not get NID for ASN1_OBJECT object")));
1631 v = X509_NAME_ENTRY_get_data(
e);
1632 field_name = OBJ_nid2sn(nid);
1633 if (field_name == NULL)
1634 field_name = OBJ_nid2ln(nid);
1635 if (field_name == NULL)
1637 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1638 errmsg(
"could not convert NID %d to an ASN1_OBJECT structure", nid)));
1639 BIO_printf(membuf,
"/%s=", field_name);
1640 ASN1_STRING_print_ex(membuf, v,
1641 ((ASN1_STRFLGS_RFC2253 & ~ASN1_STRFLGS_ESC_MSB)
1642 | ASN1_STRFLGS_UTF8_CONVERT));
1647 BIO_write(membuf, &nullterm, 1);
1648 size = BIO_get_mem_data(membuf, &sp);
1654 if (BIO_free(membuf) != 1)
1655 elog(
ERROR,
"could not free OpenSSL BIO structure");
1682 return TLS1_VERSION;
1684 #ifdef TLS1_1_VERSION
1685 return TLS1_1_VERSION;
1690 #ifdef TLS1_2_VERSION
1691 return TLS1_2_VERSION;
1696 #ifdef TLS1_3_VERSION
1697 return TLS1_3_VERSION;
1726 return "(unrecognized)";
bool check_ssl_key_file_permissions(const char *ssl_key_file, bool isServerStart)
int run_ssl_passphrase_command(const char *prompt, bool is_server_start, char *buf, int size)
static const char * ssl_protocol_version_to_string(int v)
static const char * cert_errdetail
const char * be_tls_get_version(Port *port)
static void info_cb(const SSL *ssl, int type, int args)
static const char * SSLerrmessage(unsigned long ecode)
void be_tls_destroy(void)
int be_tls_init(bool isServerStart)
openssl_tls_init_hook_typ openssl_tls_init_hook
int be_tls_get_cipher_bits(Port *port)
int be_tls_open_server(Port *port)
char * be_tls_get_certificate_hash(Port *port, size_t *len)
static int alpn_cb(SSL *ssl, const unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *userdata)
static DH * load_dh_buffer(const char *buffer, size_t len)
static BIO_METHOD * my_bio_methods
static int dummy_ssl_passwd_cb(char *buf, int size, int rwflag, void *userdata)
static int my_SSL_set_fd(Port *port, int fd)
static void default_openssl_tls_init(SSL_CTX *context, bool isServerStart)
static char * prepare_cert_name(char *name)
void be_tls_get_peer_serial(Port *port, char *ptr, size_t len)
static int ssl_protocol_version_to_openssl(int v)
static BIO_METHOD * my_BIO_s_socket(void)
static bool initialize_dh(SSL_CTX *context, bool isServerStart)
void be_tls_close(Port *port)
void be_tls_get_peer_issuer_name(Port *port, char *ptr, size_t len)
ssize_t be_tls_read(Port *port, void *ptr, size_t len, int *waitfor)
static char * X509_NAME_to_cstring(X509_NAME *name)
ssize_t be_tls_write(Port *port, void *ptr, size_t len, int *waitfor)
static int ssl_external_passwd_cb(char *buf, int size, int rwflag, void *userdata)
static SSL_CTX * SSL_context
static bool ssl_is_server_start
const char * be_tls_get_cipher(Port *port)
static bool SSL_initialized
static int verify_cb(int ok, X509_STORE_CTX *ctx)
static bool initialize_ecdh(SSL_CTX *context, bool isServerStart)
static bool dummy_ssl_passwd_cb_called
static DH * load_dh_file(char *filename, bool isServerStart)
static const unsigned char alpn_protos[]
static int my_sock_write(BIO *h, const char *buf, int size)
void be_tls_get_peer_subject_name(Port *port, char *ptr, size_t len)
static int my_sock_read(BIO *h, char *buf, int size)
char * ssl_dh_params_file
int ssl_min_protocol_version
ssize_t secure_raw_read(Port *port, void *ptr, size_t len)
bool SSLPreferServerCiphers
int ssl_max_protocol_version
char * ssl_passphrase_command
bool ssl_passphrase_command_supports_reload
ssize_t secure_raw_write(Port *port, const void *ptr, size_t len)
#define unconstify(underlying_type, expr)
#define Assert(condition)
static void PGresult * res
int errcode_for_socket_access(void)
int errmsg_internal(const char *fmt,...)
int errdetail_internal(const char *fmt,...)
int errcode_for_file_access(void)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void err(int eval, const char *fmt,...)
FILE * AllocateFile(const char *name, const char *mode)
const char * GetConfigOption(const char *name, bool missing_ok, bool restrict_privileged)
int WaitLatchOrSocket(Latch *latch, int wakeEvents, pgsocket sock, long timeout, uint32 wait_event_info)
#define WL_SOCKET_READABLE
#define WL_EXIT_ON_PM_DEATH
#define WL_SOCKET_WRITEABLE
char * pg_any_to_server(const char *s, int len, int encoding)
char * pstrdup(const char *in)
void pfree(void *pointer)
MemoryContext TopMemoryContext
void * MemoryContextAlloc(MemoryContext context, Size size)
size_t strlcpy(char *dst, const char *src, size_t siz)
#define PG_ALPN_PROTOCOL_VECTOR
static int fd(const char *x, int i)
int SSL_CTX_set_max_proto_version(SSL_CTX *ctx, int version)
int SSL_CTX_set_min_proto_version(SSL_CTX *ctx, int version)
static unsigned hash(unsigned *uv, int n)
static pg_noinline void Size size
char * pg_clean_ascii(const char *str, int alloc_flags)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)