I'm trying fix independence of pg_dump.c on postgres.h. And I found
following construct in dumpSequence function:



09391 snprintf(bufm, sizeof(bufm), INT64_FORMAT, SEQ_MINVALUE);
09392 snprintf(bufx, sizeof(bufx), INT64_FORMAT, SEQ_MAXVALUE);
09393
09394 appendPQExpBuffer(query,
09395 "SELECT sequence_name, last_value,
increment_by, "
09396 "CASE WHEN increment_by > 0 AND max_value = %s
THEN NULL "
09397 " WHEN increment_by < 0 AND max_value = -1
THEN NULL "
09398 " ELSE max_value "
09399 "END AS max_value, "
09400 "CASE WHEN increment_by > 0 AND min_value = 1
THEN NULL "
09401 " WHEN increment_by < 0 AND min_value = %s
THEN NULL "
09402 " ELSE min_value "
09403 "END AS min_value, "
09404 "cache_value, is_cycled, is_called from %s",
09405 bufx, bufm,
09406 fmtId(tbinfo->dobj.name));


This construct is used to determine if max_value/min_value is used and
after that pg_dump add NO MAXVALUE to the output instead of the value.
If I compare it with manual documentation NO MAXVALUE uses default value
and I do not see any reason to have this code there. I think we can
remove this code and release dependency on sequence.h.

Any comments?

Zdenek

Search Discussions

  • Tom Lane at Nov 5, 2007 at 7:50 pm

    Zdenek Kotala writes:
    This construct is used to determine if max_value/min_value is used and
    after that pg_dump add NO MAXVALUE to the output instead of the value.
    If I compare it with manual documentation NO MAXVALUE uses default value
    and I do not see any reason to have this code there. I think we can
    remove this code and release dependency on sequence.h.
    IIUC you are proposing that it's okay to print random-huge-values in
    the dumped CREATE SEQUENCE commands. I don't agree with that.
    In particular it would make for a legacy/compatibility issue for
    INT64_IS_BROKEN platforms.

    A better solution might be to move the declarations of
    SEQ_MINVALUE/SEQ_MAXVALUE someplace else.

    regards, tom lane
  • Zdenek Kotala at Nov 5, 2007 at 8:00 pm

    Tom Lane wrote:


    A better solution might be to move the declarations of
    SEQ_MINVALUE/SEQ_MAXVALUE someplace else.
    Hmm. It seems better, but it is also hard to find correct place. :( I'm
    thinking put it into c.h.

    Another question why sequence does not have separate flag which
    determines if it is default/no max value or predefined?

    Any comments, better ideas?

    Zdenek
  • Tom Lane at Nov 5, 2007 at 8:09 pm

    Zdenek Kotala writes:
    Tom Lane wrote:
    A better solution might be to move the declarations of
    SEQ_MINVALUE/SEQ_MAXVALUE someplace else.
    Hmm. It seems better, but it is also hard to find correct place. :( I'm
    thinking put it into c.h.
    The idea that was in the back of my mind was pg_config_manual.h,
    since these numbers could be seen as configuration constants if
    you hold your head at the right angle ...

    regards, tom lane

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-hackers @
categoriespostgresql
postedNov 5, '07 at 7:16p
activeNov 5, '07 at 8:09p
posts4
users2
websitepostgresql.org...
irc#postgresql

2 users in discussion

Tom Lane: 2 posts Zdenek Kotala: 2 posts

People

Translate

site design / logo © 2022 Grokbase