public inbox for [email protected]  
help / color / mirror / Atom feed
pg_dump -t '"Table"' for cmd.exe
3+ messages / 3 participants
[nested] [flat]

* pg_dump -t '"Table"' for cmd.exe
@ 2012-11-13 01:45  Mike Toews <[email protected]>
  0 siblings, 2 replies; 3+ messages in thread

From: Mike Toews @ 2012-11-13 01:45 UTC (permalink / raw)
  To: pgsql-docs

I'm not sure if this is worth documenting, but pg_dumping mixed-case tables
with the '-t table' option appears to not be accurately documented
for cmd.exe. Here are my four attempts, with only the last as success:

Intuitive (supplying "My Table" like "My Database"), but not correct:
C:\>"C:\Program Files\PostgreSQL\9.1\bin\pg_dump.exe" -U postgres -t "My
Table" "My Database"
pg_dump: No matching tables were found

As documented in last example at
http://www.postgresql.org/docs/9.1/static/app-pgdump.html
C:\>"C:\Program Files\PostgreSQL\9.1\bin\pg_dump.exe" -U postgres -t '"My
Table"' "My Database"
pg_dump: No matching tables were found

Escaping quotes, but using single quotes:
C:\>"C:\Program Files\PostgreSQL\9.1\bin\pg_dump.exe" -U postgres -t '\"My
Table\"' "My Database"
pg_dump: too many command-line arguments (first is "My Database")

Escaping quotes, but using double quotes:
C:\>"C:\Program Files\PostgreSQL\9.1\bin\pg_dump.exe" -U postgres -t "\"My
Table\"" "My Database"

works!

-Mike


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pg_dump -t '"Table"' for cmd.exe
@ 2012-11-14 03:49  Josh Kupershmidt <[email protected]>
  parent: Mike Toews <[email protected]>
  1 sibling, 0 replies; 3+ messages in thread

From: Josh Kupershmidt @ 2012-11-14 03:49 UTC (permalink / raw)
  To: Mike Toews <[email protected]>; +Cc: pgsql-docs

On Mon, Nov 12, 2012 at 8:45 PM, Mike Toews <[email protected]> wrote:
> I'm not sure if this is worth documenting, but pg_dumping mixed-case tables
> with the '-t table' option appears to not be accurately documented for
> cmd.exe. Here are my four attempts, with only the last as success:

I believe this complaint is basically the same as this recent one:
  http://archives.postgresql.org/pgsql-bugs/2012-10/msg00044.php

and this behavior confused me recently as well. I agree the behavior
should be documented, though it should be documented for all our
utilities which accept a --table argument and pass it on as a
supposedly already-escaped identifier.

Incidentally, I'm really not fond of the existing behavior because it:
 a.) is counterintuitive
 b.) requires the user to escape table names themselves, and how were
they even supposed to have a chance of programmatically doing this
properly before we exposed PQescapeIdentifier()
 c.) opens possible SQL injection holes, e.g.
  reindexdb --table='foo; ALTER ROLE limited WITH superuser'

Josh




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pg_dump -t '"Table"' for cmd.exe
@ 2013-07-01 18:53  Bruce Momjian <[email protected]>
  parent: Mike Toews <[email protected]>
  1 sibling, 0 replies; 3+ messages in thread

From: Bruce Momjian @ 2013-07-01 18:53 UTC (permalink / raw)
  To: Mike Toews <[email protected]>; +Cc: pgsql-docs

On Tue, Nov 13, 2012 at 02:45:05PM +1300, Mike Toews wrote:
> I'm not sure if this is worth documenting, but pg_dumping mixed-case tables
> with the '-t table' option appears to not be accurately documented for cmd.exe.
> Here are my four attempts, with only the last as success:
> 
> Intuitive (supplying "My Table" like "My Database"), but not correct:
> C:\>"C:\Program Files\PostgreSQL\9.1\bin\pg_dump.exe" -U postgres -t "My Table"
> "My Database"
> pg_dump: No matching tables were found
> 
> As documented in last example at http://www.postgresql.org/docs/9.1/static/
> app-pgdump.html
> C:\>"C:\Program Files\PostgreSQL\9.1\bin\pg_dump.exe" -U postgres -t '"My
> Table"' "My Database"
> pg_dump: No matching tables were found
> 
> Escaping quotes, but using single quotes:
> C:\>"C:\Program Files\PostgreSQL\9.1\bin\pg_dump.exe" -U postgres -t '\"My
> Table\"' "My Database"
> pg_dump: too many command-line arguments (first is "My Database")
> 
> Escaping quotes, but using double quotes:
> C:\>"C:\Program Files\PostgreSQL\9.1\bin\pg_dump.exe" -U postgres -t "\"My
> Table\"" "My Database"
> 
> works!

Good point.  Docs updated with attached patch, and patched to 9.3 beta
as well.

-- 
  Bruce Momjian  <[email protected]>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +


-- 
Sent via pgsql-docs mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs


Attachments:

  [text/x-diff] quote.diff (596B, 2-quote.diff)
  download | inline diff:
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
new file mode 100644
index 2b5e95b..1ed5e4f
*** a/doc/src/sgml/ref/pg_dump.sgml
--- b/doc/src/sgml/ref/pg_dump.sgml
*************** CREATE DATABASE foo WITH TEMPLATE templa
*** 1224,1230 ****
     like
  
  <screen>
! <prompt>$</prompt> <userinput>pg_dump -t '"MixedCaseName"' mydb &gt; mytab.sql</userinput>
  </screen></para>
  
   </refsect1>
--- 1224,1230 ----
     like
  
  <screen>
! <prompt>$</prompt> <userinput>pg_dump -t "\"MixedCaseName\"" mydb &gt; mytab.sql</userinput>
  </screen></para>
  
   </refsect1>


^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2013-07-01 18:53 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-11-13 01:45 pg_dump -t '"Table"' for cmd.exe Mike Toews <[email protected]>
2012-11-14 03:49 ` Josh Kupershmidt <[email protected]>
2013-07-01 18:53 ` Bruce Momjian <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox