Is there a problem about the archive?
I posted this addition to the patch on July 2, and received it over the
patches mailing list. Still, it doesn't appear in cvs, in "unapplied
patches" or in the mailing list archive! So although that message made
its way through the list server, it didn't end up in the archive, but
was lost.
In the meantime, some changes occurred to cvs, which merged smoothly.
For convenience, the attached diffs against the latest cvs versions.
Regards,
Andreas
Previous message (2003-07-02):
The patch has been updated, the attached files will replace my previous
post completely against ruleutils.c 1.143.
pg_get_indexdef is extended to take 3 arguments:
pg_get_indexdef(index_oid, columnNr_int, prettyOpt_int)
Still, pg_get_indexdef(oid) will deliver the same result as it used to be.
The second parameter selects the nth expression of an index
(1..indnatts). If zero, a complete CREATE INDEX statement is generated
to obtain the previous behaviour.
The third is the pretty-print option as mentioned before.
example:
pg_get_indexdef(12345, 0, 7) -> CREATE INDEX foo ON bar (numcol,
length(txtcol), intcol2, length(txtcol2))
pg_get_indexdef(12345, 1, 7) -> numcol
pg_get_indexdef(12345, 2, 7) -> length(txtcol)
Regards,
Andreas
> The attached patches will add
> pg_get_ruledef(oid, int)
> pg_get_viewdef(text, int)
> pg_get_viewdef(oid, int)
> pg_get_indexdef(oid, int)
> pg_get_constraintdef(oid, int)
> pg_get_expr(text, oid, int)
>
> If the last parameter "pretty-print" is 0, these function will return
> the same result as their original counterparts without that parameter.
> The source is based on ruleutils.c 1.143, and should return exactly
> the same result as before if no pretty-print is selected. My tests
> didn't show any differences for pg_dump output with old or new version.
>
> The pretty-print parameter is evaluated bit-wise.
>
> PRETTY_PAREN 1 - Parentheses are checked; only necessary
> parentheses will be emitted.
>
> PRETTY_INDENT 2 - pretty indentation and line formatting is performed
>
> PRETTY_OPPAREN 4 - For T_BoolExpr operators, AND/OR/NOT precedence
> is checked, for T_OpExpr +-*/% precedence is
> checked. If precedence is identified, parentheses are omitted.
> This option is only active if PRETTY_PAREN is
> also used.