Re: Add --include-table-data-where option to pg_dump, to export only a subset of table data

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Carter Thaxton <carter(dot)thaxton(at)gmail(dot)com>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add --include-table-data-where option to pg_dump, to export only a subset of table data
Date: 2018-05-23 09:07:49
Message-ID: CAEepm=1ycd4+4370XAdYB6qK=B-Xy6SqAHhcJs+5Fpbx3J0q5g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, May 23, 2018 at 5:18 PM, Carter Thaxton
<carter(dot)thaxton(at)gmail(dot)com> wrote:
> Ah yes, thanks. I did in fact have colors enabled.
> I've attached a new patch generated by `git format-patch`. Hopefully that's
> correct.

pg_dump.c:2323:2: warning: ISO C90 forbids mixed declarations and code
[-Wdeclaration-after-statement]
char *filter_clause = NULL;
^

You need to declare this variable at the top of its scope. If you're
using GCC or Clang you might consider building with COPT=-Werror so
that any compiler warnings will stop the build from succeeding.

This doesn't build on Windows[1], probably for the same reason.

/*
* Is OID present in the list?
+ * Also return extra pointer-sized data by setting extra_data paramter
*/
bool
-simple_oid_list_member(SimpleOidList *list, Oid val)
+simple_oid_list_member2(SimpleOidList *list, Oid val, void **extra_data)

I feel like that isn't in the spirit of Lisp "member". It's now a
kind of association list. I wonder if we are really constrained to
use the cave-man facilities in fe_utils anyway. Though I suppose this
list is never going to be super large so maybe the data structure
doesn't matter too much (famous last words).

+ char *where_clause = pg_malloc(strlen(filter_clause) + 8 + 1);
+ strcpy(where_clause, "WHERE (");
+ strcat(where_clause, filter_clause);
+ strcat(where_clause, ")");

pg_dump.c seems to be allowed to use psprintf() which'd be less
fragile than the above code.

+ /* When match_data is set, split the pattern on the ':' chararcter,

typo

+ * Also return extra pointer-sized data by setting extra_data paramter

typo

[1] https://ci.appveyor.com/project/postgresql-cfbot/postgresql/build/1.0.311

--
Thomas Munro
http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2018-05-23 09:08:35 Re: SCRAM with channel binding downgrade attack
Previous Message Magnus Hagander 2018-05-23 09:01:10 Re: SCRAM with channel binding downgrade attack