Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 12:15 AM
Greg Sabino Mullane
 
Posts: n/a
Default New pg_dump options: exclude tables/schemas, multiple all,wildcards

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message


Attached is a patch to hopefully make pg_dump a lot more useful.
I started out by making it simply able to avoid dumping a single
table, but, inspired by David Fetter's patch last November, also
added in support for multiple items and limited wildcard matching.

-n and -N control the schemas, and -t and -T control the tables.

Wildcards can be a star at the start, the end, or on both sides
of a term. The patch acts inclusively with conflicts: the -t
option trumps the -N option.

Some examples:

To dump all tables beginning with the string "slony", plus
all tables with the word "log" inside of them:

pg_dump -t "slony*" -t "*log*"

To dump all schemas except "dev" and "qa", and all tables
except those ending in "large":

pg_dump -N "dev" -N "qa" -T "*large"

--
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200601152100
http://biglumber.com/x/web?pk=2529DF...9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iD8DBQFDyv9NvJuQZxSWSsgRAup9AKD110JJtJBYYPV5JxFROo vfeddrSACg3IZ3
BqczBImC8UCVmik3YFHvDeQ=
=Y9zs
-----END PGP SIGNATURE-----



---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-18-2008, 12:15 AM
Alvaro Herrera
 
Posts: n/a
Default Re: New pg_dump options: exclude tables/schemas, multiple all, wildcards

Greg Sabino Mullane wrote:

> Attached is a patch to hopefully make pg_dump a lot more useful.
> I started out by making it simply able to avoid dumping a single
> table, but, inspired by David Fetter's patch last November, also
> added in support for multiple items and limited wildcard matching.


I wonder if there's a way to have the server process the matching? That
way we could have LIKE expressions in the switches, which would be
simpler in the code and more powerful. I don't know how pg_dump works
so I can't really answer the question. We desperately need this
capability however, as patches have been floating since before 8.0 and
we still don't have it.

--
Alvaro Herrera Developer, http://www.PostgreSQL.org
"Si quieres ser creativo, aprende el arte de perder el tiempo"

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-18-2008, 12:15 AM
Greg Sabino Mullane
 
Posts: n/a
Default Re: New pg_dump options: exclude tables/schemas, multiple all, wildcards


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> I wonder if there's a way to have the server process the matching? That
> way we could have LIKE expressions in the switches, which would be
> simpler in the code and more powerful. I don't know how pg_dump works
> so I can't really answer the question. We desperately need this
> capability however, as patches have been floating since before 8.0 and
> we still don't have it.


It won't fit into the existing code easily, but it could probably be done.
I toyed around with making the regex more robust, but three things
stopped me:

1) The "star at start" and "star at end" catches probably 99% of the cases,
and is way better than what we have now, so better a bird in the hand...

2) It would be a lot more work to send it to the backend or import some
of the regex code.

and most importantly:

3) It would require yet more arguments to pg_dump. The moment we start allowing
regular expression characters that are also valid identifier names (e.g. "."
and "_") we'll need some way to tell pg_dump whether we mean a literal search
or a regular expression one. Which probably means more arguments or at least
modifying the existing one in a possibly nonintuitive, and definitely more
complex, manner. I'm open to suggestions, however, but I don't want to make
things too byzantine for the users.

- --
Greg Sabino Mullane greg@endpoint.com greg@turnstep.com
PGP Key: 0x14964AC8 200601171718
http://biglumber.com/x/web?pk=2529DF...9B906714964AC8

-----BEGIN PGP SIGNATURE-----

iD8DBQFDzW5jvJuQZxSWSsgRAqrhAJoDvsOerxbi1ay3heRyfh ubk3sw1wCdGDd6
6GAk6NVRjfwELzQeLeA7m5s=
=e6WP
-----END PGP SIGNATURE-----



---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-18-2008, 12:15 AM
Tom Lane
 
Posts: n/a
Default Re: New pg_dump options: exclude tables/schemas, multiple all, wildcards

"Greg Sabino Mullane" <greg@turnstep.com> writes:
> 2) It would be a lot more work to send it to the backend or import some
> of the regex code.


Importing regex code into pg_dump certainly sounds like a loser.
However, it doesn't seem to me that it'd be that hard to issue
commands like
select relname from pg_class where relname like <pattern>
then save aside this list to match against stuff-to-dump.

> 3) It would require yet more arguments to pg_dump. The moment we start allowing
> regular expression characters that are also valid identifier names (e.g. "."
> and "_") we'll need some way to tell pg_dump whether we mean a literal search
> or a regular expression one.


However, we are going to have that problem in spades if we do a
half-baked pattern feature now and then want to improve it later.
I think it'd be better to get it right the first time.

In practice, I don't think that LIKE-style patterns (% and _ wildcards)
will pose a serious compatibility problem if we just decree that the
-n and -t switches now take patterns rather than plain names. I agree
that regex-style patterns would open some gotchas, but what's wrong with
standardizing on LIKE patterns?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-18-2008, 12:15 AM
Greg Sabino Mullane
 
Posts: n/a
Default Re: New pg_dump options: exclude tables/schemas, multiple all, wildcards


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> In practice, I don't think that LIKE-style patterns (% and _ wildcards)
> will pose a serious compatibility problem if we just decree that the
> -n and -t switches now take patterns rather than plain names. I agree
> that regex-style patterns would open some gotchas, but what's wrong with
> standardizing on LIKE patterns?


Sounds good, but the more I think about it, why don't we just use regexes via
the ~ operator? After all, if we want to exclude schemas starting with an
underscore from pg_dump, then -N '^_.*' is no worse than -N '\\_%' and has
the added advantage of being more like regexes people are used to. I guess
my earlier 'which is which' argument isn't too much to worry about either -
chances are very slim that an existing script is using a -t argument that
contains regular expressions. Plus, while the underscore is common in
namespace names, a period is not.

- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200601172005
http://biglumber.com/x/web?pk=2529DF...9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iD8DBQFDzZSpvJuQZxSWSsgRAiEQAKD5YXJjne5ZjbSUyHLiVK rEBtLPxQCfbsN8
JlQH5S+UVTogKpyRQJoU6jk=
=Sfcu
-----END PGP SIGNATURE-----



---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-18-2008, 12:15 AM
Tom Lane
 
Posts: n/a
Default Re: New pg_dump options: exclude tables/schemas, multiple all, wildcards

"Greg Sabino Mullane" <greg@turnstep.com> writes:
> Plus, while the underscore is common in
> namespace names, a period is not.


That's a good point ... there might actually be less risk of collision
with existing habits if we go with regex instead of LIKE conventions for
the patterns. Even though regex has many more special characters, none
seem very likely to appear in ordinary table or schema names.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-18-2008, 12:15 AM
Bruce Momjian
 
Posts: n/a
Default Re: New pg_dump options: exclude tables/schemas, multiple

Tom Lane wrote:
> > 3) It would require yet more arguments to pg_dump. The moment we start allowing
> > regular expression characters that are also valid identifier names (e.g. "."
> > and "_") we'll need some way to tell pg_dump whether we mean a literal search
> > or a regular expression one.

>
> However, we are going to have that problem in spades if we do a
> half-baked pattern feature now and then want to improve it later.
> I think it'd be better to get it right the first time.
>
> In practice, I don't think that LIKE-style patterns (% and _ wildcards)
> will pose a serious compatibility problem if we just decree that the
> -n and -t switches now take patterns rather than plain names. I agree
> that regex-style patterns would open some gotchas, but what's wrong with
> standardizing on LIKE patterns?


I am concerned about the number of object names that have an underscore.
It seems regex would have fewer conflicts, even though it has more
special characters.

--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-18-2008, 12:15 AM
Bruce Momjian
 
Posts: n/a
Default Re: New pg_dump options: exclude tables/schemas, multiple

Bruce Momjian wrote:
> Tom Lane wrote:
> > > 3) It would require yet more arguments to pg_dump. The moment we start allowing
> > > regular expression characters that are also valid identifier names (e.g. "."
> > > and "_") we'll need some way to tell pg_dump whether we mean a literal search
> > > or a regular expression one.

> >
> > However, we are going to have that problem in spades if we do a
> > half-baked pattern feature now and then want to improve it later.
> > I think it'd be better to get it right the first time.
> >
> > In practice, I don't think that LIKE-style patterns (% and _ wildcards)
> > will pose a serious compatibility problem if we just decree that the
> > -n and -t switches now take patterns rather than plain names. I agree
> > that regex-style patterns would open some gotchas, but what's wrong with
> > standardizing on LIKE patterns?

>
> I am concerned about the number of object names that have an underscore.
> It seems regex would have fewer conflicts, even though it has more
> special characters.


Sorry, I see the group came to the same conclusion. I should have read
to the end of the thread.

--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-18-2008, 12:18 AM
Bruce Momjian
 
Posts: n/a
Default Re: New pg_dump options: exclude tables/schemas, multiple


Where are we on this patch? Should we add code to do regex calls to the
backend using '~'.

---------------------------------------------------------------------------

Greg Sabino Mullane wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> NotDashEscaped: You need GnuPG to verify this message
>
>
> Attached is a patch to hopefully make pg_dump a lot more useful.
> I started out by making it simply able to avoid dumping a single
> table, but, inspired by David Fetter's patch last November, also
> added in support for multiple items and limited wildcard matching.
>
> -n and -N control the schemas, and -t and -T control the tables.
>
> Wildcards can be a star at the start, the end, or on both sides
> of a term. The patch acts inclusively with conflicts: the -t
> option trumps the -N option.
>
> Some examples:
>
> To dump all tables beginning with the string "slony", plus
> all tables with the word "log" inside of them:
>
> pg_dump -t "slony*" -t "*log*"
>
> To dump all schemas except "dev" and "qa", and all tables
> except those ending in "large":
>
> pg_dump -N "dev" -N "qa" -T "*large"
>
> --
> Greg Sabino Mullane greg@turnstep.com
> PGP Key: 0x14964AC8 200601152100
> http://biglumber.com/x/web?pk=2529DF...9B906714964AC8
> -----BEGIN PGP SIGNATURE-----
>
> iD8DBQFDyv9NvJuQZxSWSsgRAup9AKD110JJtJBYYPV5JxFROo vfeddrSACg3IZ3
> BqczBImC8UCVmik3YFHvDeQ=
> =Y9zs
> -----END PGP SIGNATURE-----
>


[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org


--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-18-2008, 12:18 AM
Greg Sabino Mullane
 
Posts: n/a
Default Re: New pg_dump options: exclude tables/schemas, multiple


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> Where are we on this patch? Should we add code to do regex calls
> to the backend using '~'.


Yes - I am planning to submit a new patch when I get a few spare
cycles. Hopefully no more than a few days from now.

- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200602011424
http://biglumber.com/x/web?pk=2529DF...9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iD8DBQFD4QsBvJuQZxSWSsgRAs6XAKCCEobXLaOQfTf0PXpFTl 0f90cNWQCgi6wO
g4F6pcP6mjjLYsdkjrKAvF8=
=jJFm
-----END PGP SIGNATURE-----



---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:14 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506