From d5fd0e4aab34ddb0d46d0a22ac2780201986d490 Mon Sep 17 00:00:00 2001 From: Dave Cramer Date: Tue, 7 Jul 2020 14:12:20 -0400 Subject: [PATCH 3/4] Actually set the default to unchanged as per the comment Make more readable and fix up whitespace Fix up error messages --- .../libpqwalreceiver/libpqwalreceiver.c | 3 +- src/backend/replication/logical/proto.c | 5 +- src/backend/replication/pgoutput/pgoutput.c | 54 +++++++++---------- src/include/pg_config_manual.h | 2 +- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c index 08313fa2a5..7399eec852 100644 --- a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c +++ b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c @@ -423,7 +423,8 @@ libpqrcv_startstreaming(WalReceiverConn *conn, appendStringInfo(&cmd, ", publication_names %s", pubnames_literal); PQfreemem(pubnames_literal); pfree(pubnames_str); - if (options->proto.logical.binary) { + if (options->proto.logical.binary) + { appendStringInfo(&cmd, ", binary 'true'"); appendStringInfo(&cmd, ", sizeof_datum '%zu'", sizeof(Datum)); appendStringInfo(&cmd, ", sizeof_int '%zu'", sizeof(int)); diff --git a/src/backend/replication/logical/proto.c b/src/backend/replication/logical/proto.c index 73148f39f3..a98d843174 100644 --- a/src/backend/replication/logical/proto.c +++ b/src/backend/replication/logical/proto.c @@ -163,13 +163,16 @@ logicalrep_read_insert(StringInfo in, LogicalRepTupleData *newtup) char action; LogicalRepRelId relid; + /* read the relation id */ relid = pq_getmsgint(in, 4); + action = pq_getmsgbyte(in); if (action != 'N') elog(ERROR, "expected new tuple but got %d", action); logicalrep_read_tuple(in, newtup); + return relid; } @@ -525,7 +528,7 @@ logicalrep_read_tuple(StringInfo in, LogicalRepTupleData *tuple) /* default is unchanged */ tuple->format = palloc(natts * sizeof(char)); - memset(tuple->format, 't', natts * sizeof(char)); + memset(tuple->format, 'u', natts * sizeof(char)); /* Read the data */ diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index 65c2e5d658..c1c0fc8f8e 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -140,7 +140,6 @@ parse_output_parameters(List *options, uint32 *protocol_version, bool float8_byval; bool integer_datetimes; - // default to false *binary_basetypes = false; @@ -158,7 +157,7 @@ parse_output_parameters(List *options, uint32 *protocol_version, if (protocol_version_given) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("conflicting or redundant options %s already provided", defel->defname))); + errmsg("conflicting or redundant options, \"%s\" already provided", defel->defname))); protocol_version_given = true; if (!scanint8(strVal(defel->arg), true, &parsed)) @@ -179,7 +178,7 @@ parse_output_parameters(List *options, uint32 *protocol_version, if (publication_names_given) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("conflicting or redundant options %s already provided", defel->defname))); + errmsg("conflicting or redundant options, \"%s\" already provided", defel->defname))); publication_names_given = true; if (!SplitIdentifierString(strVal(defel->arg), ',', @@ -194,7 +193,7 @@ parse_output_parameters(List *options, uint32 *protocol_version, if (binary_option_given) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("conflicting or redundant options %s already provided", defel->defname))); + errmsg("conflicting or redundant options, \"%s\" already provided", defel->defname))); binary_option_given = true; if (!parse_bool(strVal(defel->arg), &parsed)) @@ -212,7 +211,7 @@ parse_output_parameters(List *options, uint32 *protocol_version, if (sizeof_datum_given) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("conflicting or redundant options %s already provided", defel->defname))); + errmsg("conflicting or redundant options, \"%s\" already provided", defel->defname))); sizeof_datum_given = true; if (!scanint8(strVal(defel->arg), true, &datum_size)) @@ -226,7 +225,7 @@ parse_output_parameters(List *options, uint32 *protocol_version, if (sizeof_int_given) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("conflicting or redundant options %s already provided", defel->defname))); + errmsg("conflicting or redundant options, \"%s\" already provided", defel->defname))); sizeof_int_given = true; if (!scanint8(strVal(defel->arg), true, &int_size)) @@ -240,7 +239,7 @@ parse_output_parameters(List *options, uint32 *protocol_version, if (sizeof_long_given) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("conflicting or redundant options %s already provided", defel->defname))); + errmsg("conflicting or redundant options, \"%s\" already provided", defel->defname))); sizeof_long_given = true; if (!scanint8(strVal(defel->arg), true, &long_size)) @@ -254,7 +253,7 @@ parse_output_parameters(List *options, uint32 *protocol_version, if (big_endian_given) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("conflicting or redundant options %s already provided", defel->defname))); + errmsg("conflicting or redundant options, \"%s\" already provided", defel->defname))); big_endian_given = true; if (!parse_bool(strVal(defel->arg), &bigendian)) @@ -268,7 +267,7 @@ parse_output_parameters(List *options, uint32 *protocol_version, if (float4_byval_given) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("conflicting or redundant options %s already provided", defel->defname))); + errmsg("conflicting or redundant options, \"%s\" already provided", defel->defname))); float4_byval_given = true; if (!parse_bool(strVal(defel->arg), &float4_byval)) @@ -282,7 +281,7 @@ parse_output_parameters(List *options, uint32 *protocol_version, if (float8_byval_given) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("conflicting or redundant options %s already provided", defel->defname))); + errmsg("conflicting or redundant options, \"%s\" already provided", defel->defname))); float8_byval_given = true; if (!parse_bool(strVal(defel->arg), &float8_byval)) @@ -296,7 +295,7 @@ parse_output_parameters(List *options, uint32 *protocol_version, if (integer_datetimes_given) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("conflicting or redundant options %s already provided", defel->defname))); + errmsg("conflicting or redundant options, \"%s\" already provided", defel->defname))); integer_datetimes_given = true; if (!parse_bool(strVal(defel->arg), &integer_datetimes)) @@ -328,52 +327,49 @@ parse_output_parameters(List *options, uint32 *protocol_version, ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("incompatible long size"))); - if( + #ifdef WORDS_BIGENDIAN - true + if (bigendian!=true) #else - false + if (bigendian!=false) + #endif - != bigendian) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("incompatible endianness"))); - if( float4_byval != #if PG_VERSION_NUM >= 130000 - true + if(float4_byval!=true) #else #ifdef USE_FLOAT4_BYVAL - true + if(float4_byval!=true) #else - false + if(float4_byval!=false) #endif #endif - ) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("incompatible float4_byval"))); - if( float8_byval != + + #ifdef USE_FLOAT8_BYVAL - true + if(float8_byval!=true) #else - false + if(float8_byval!=false) #endif - ) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("incompatible float8_byval"))); - if ( integer_datetimes != + #if PG_VERSION_NUM >= 100000 - true + if (integer_datetimes!=true) #else #ifdef USE_INTEGER_DATETIMES - true + if (integer_datetimes!=true) #else - false + if (integer_datetimes!=false) #endif #endif - ) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("incompatible integer_datetimes"))); diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h index ec4fa01f30..8f3ec6bde1 100644 --- a/src/include/pg_config_manual.h +++ b/src/include/pg_config_manual.h @@ -336,7 +336,7 @@ * Enable debugging print statements for WAL-related operations; see * also the wal_debug GUC var. */ -#define WAL_DEBUG +/* #define WAL_DEBUG */ /* * Enable tracing of resource consumption during sort operations; -- 2.20.1 (Apple Git-117)