Thread: Feature: pg_dump: ability to specify WHERE clause expression for -t/--table option

Okay,
  Because I'm hardheaded as well as anxious to implement my own ideas
for the challenge of it :) ...


I've extended the the -t/--table option to optionally accept a WHERE
clause expression following the table pattern.

The user can, for example, run:
        pg_dump -t "tab1:col1>15" -t "tab2:col1>25"
and it will dump only tab1 WHERE col1>15 and tab2 WHERE col2>25

Since the -t/--table option already supports accepting wildcard table
names, the WHERE clause expression applies to all tables matching a
pattern.

The only backwards incompatibility is that if a table name pattern
contains a ':', then the pattern must be quoted otherwise the ':' that
is part of the pattern will be interpreted as a separator between a
pattern and an expression.  If ':' is too common a character to be found
in table patterns, then it can easily be changed (in the pg_dump.sgml
file and in one place with a #define at the top of pg_dump.c).

As before, I have implemented and tested that it works when generating
either COPY statements (the default), or INSERT statements (-d and -D).
These two modes of operation have two different sections of code that
select the data to be dumped.

The code changes should be in conformance to the existing coding style
within pg_dump.

I've made minimal changes to the pg_dump.sgml file as well to affect
the man page.

The patch should be applied from the root of the source tree with a -p1
option to the patch command. The patch is against version 8.3.1 source
code.


Thanks *again* for a great DB,
  Davy


==

P.S.
  This submission is my final response to the previous thread titled:
        "Feature: give pg_dump a WHERE clause expression"

  Please forgive the submitted patch that I know may never get merged
in.  I merely wanted the final result posted/archived somewhere public
in case any other lurkers were interested for their own purposes.  But
if you're at all curious, try it out.  You might like it :)

  Thanks again for all your feedback.


Attachment