Re: Add --include-table-data-where option to pg_dump, to export onlya subset of table data - Mailing list pgsql-hackers

From Carter Thaxton
Subject Re: Add --include-table-data-where option to pg_dump, to export onlya subset of table data
Date
Msg-id CAGiT_HPF-0P_Az5aJ3UayJfmCd-0zqO1o1v-MJEqmzC1r959xw@mail.gmail.com
Whole thread Raw
In response to Re: Add --include-table-data-where option to pg_dump, to export onlya subset of table data  (Thomas Munro <thomas.munro@enterprisedb.com>)
Responses Re: Add --include-table-data-where option to pg_dump, to export onlya subset of table data  (Carter Thaxton <carter.thaxton@gmail.com>)
List pgsql-hackers
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.

Done.  And thanks for the tip about COPT=-Werror

 
 /*
  * 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).

Yeah, I'm just trying to fit into the surrounding code as much as possible.  If you have a specific recommendation, I'm all ears.
SimpleOidList is only used by pg_dump, so if we want to rename or refactor this data structure, it won't have much widespread impact.

And you're right that the list is not going to be particularly large.  Consider that it's already a simple linked-list, and not some more complex hashtable, for the use cases that it already covers in pg_dump.  For all of these uses, it will only be as large as the number of options provided on the command-line.

 
+ 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.

Done.  Didn't realize psprintf() was available here.

 
typo
And fixed typos.

Thanks for the review!
Attachment

pgsql-hackers by date:

Previous
From: Vladimir Sitnikov
Date:
Subject: Re: Subplan result caching
Next
From: Stephen Frost
Date:
Subject: Re: Shared PostgreSQL libraries and symbol versioning