Skip to content

Commit

Permalink
Revert include-unchanged-toast option
Browse files Browse the repository at this point in the history
Per discussion in issue #74, we can't rely on access unchanged TOAST
data because it is not in the WAL stream.

It reverts commits 947043e
ce82d73 and
d86a13b .
  • Loading branch information
Euler Taveira committed Aug 29, 2018
1 parent d4c0e81 commit 66d836d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 50 deletions.
3 changes: 2 additions & 1 deletion expected/bytea.out

Large diffs are not rendered by default.

44 changes: 19 additions & 25 deletions expected/toast.out

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sql/bytea.sql
Expand Up @@ -18,5 +18,5 @@ INSERT INTO xpto (bincol) SELECT decode(string_agg(to_char(round(g.i * random())
UPDATE xpto SET rand1 = 123.456 WHERE id = 1;
DELETE FROM xpto WHERE id = 1;

SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'pretty-print', '1', 'include-typmod', '0', 'include-unchanged-toast', '0');
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'pretty-print', '1', 'include-typmod', '0');
SELECT 'stop' FROM pg_drop_replication_slot('regression_slot');
6 changes: 1 addition & 5 deletions sql/toast.sql
Expand Up @@ -27,11 +27,7 @@ UPDATE xpto SET toasted_col1 = (SELECT string_agg(g.i::text, '') FROM generate_s

UPDATE xpto SET rand1 = 123.456 WHERE id = 1;

SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'pretty-print', '1', 'include-typmod', '0', 'include-unchanged-toast', '0');
DELETE FROM xpto WHERE id = 1;

UPDATE xpto SET rand1 = 234.567 WHERE id = 1;

-- include-unchanged-toast=1 is the default
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'pretty-print', '1', 'include-typmod', '0');

SELECT 'stop' FROM pg_drop_replication_slot('regression_slot');
21 changes: 3 additions & 18 deletions wal2json.c
Expand Up @@ -39,7 +39,6 @@ typedef struct
bool include_type_oids; /* include data type oids */
bool include_typmod; /* include typmod in types */
bool include_not_null; /* include not-null constraints */
bool include_unchanged_toast; /* include unchanged TOAST field values in output */

bool pretty_print; /* pretty-print JSON? */
bool write_in_chunks; /* write in chunks? */
Expand Down Expand Up @@ -140,7 +139,6 @@ pg_decode_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt, bool is
data->write_in_chunks = false;
data->include_lsn = false;
data->include_not_null = false;
data->include_unchanged_toast = true;
data->filter_tables = NIL;

/* pretty print */
Expand Down Expand Up @@ -304,19 +302,6 @@ pg_decode_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt, bool is
errmsg("could not parse value \"%s\" for parameter \"%s\"",
strVal(elem->arg), elem->defname)));
}
else if (strcmp(elem->defname, "include-unchanged-toast") == 0)
{
if (elem->arg == NULL)
{
elog(LOG, "include-unchanged-toast is null");
data->include_unchanged_toast = true;
}
else if (!parse_bool(strVal(elem->arg), &data->include_unchanged_toast))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("could not parse value \"%s\" for parameter \"%s\"",
strVal(elem->arg), elem->defname)));
}
else if (strcmp(elem->defname, "filter-tables") == 0)
{
char *rawstr;
Expand Down Expand Up @@ -579,10 +564,10 @@ tuple_to_stringinfo(LogicalDecodingContext *ctx, TupleDesc tupdesc, HeapTuple tu
if (isnull && replident)
continue;

if (!isnull && typisvarlena && VARATT_IS_EXTERNAL_ONDISK(origval) && !data->include_unchanged_toast)
/* XXX Unchanged TOAST Datum does not need to be output */
if (!isnull && typisvarlena && VARATT_IS_EXTERNAL_ONDISK(origval))
{
/* TOAST value is not returned if include-unchanged-toast is specified */
elog(DEBUG2, "column \"%s\" has an unchanged TOAST - excluding", NameStr(attr->attname));
elog(WARNING, "column \"%s\" has an unchanged TOAST", NameStr(attr->attname));
continue;
}

Expand Down

0 comments on commit 66d836d

Please sign in to comment.