Tom Lane wrote:
> momjian@svr1.postgresql.org (Bruce Momjian) writes:
> > Attached is a patch that addressed all the discussed issues that
> > did not break backward compatability,
>
> Was this patch actually agreed to? I hadn't gotten around to looking
> at it because I thought Peter was still objecting to the whole idea.
>
> > including the ability to
> > output ISO-8601 compliant intervals by setting datestyle to
> > iso8601basic.
>
> This is a horrid, horrid idea. Datestyle is already a complete mess
> because it is being used to control several things; it should have been
> two or possibly three GUC variables not one. Sticking in yet another
> behavior is just not acceptable IMHO, especially when it's defined as
> non-orthogonally as that.
>
> Please revert that part of the patch and instead invent a new GUC
> variable that's specifically for interval formatting.
>
> BTW, I can tell without looking that the patch is deficient in
> documentation; if it has effects on GUC variables, why is there no
> mod in runtime.sgml?
OK, I have backed out the patch. Peter did object, but I said I thought
the submitter had addressed the objections (backward compatibility) and
I asked for someone to tell me the objections, and no one replied, so I
assumed it was OK and it went through the standard patch application
process.
The patch is attached if someone wants to modify it to head in the
direction that most developers prefer.
--
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
? log
? config.log
? GNUmakefile
? config.status
? doc/src/sgml/HISTORY
? src/Makefile.custom
? src/Makefile.global
? src/log
? src/backend/postgres
? src/backend/catalog/postgres.bki
? src/backend/catalog/postgres.description
? src/backend/utils/mb/conversion_procs/conversion_create.sql
? src/backend/utils/mb/conversion_procs/ascii_and_mic/libascii_and_mic.so.0.0
? src/backend/utils/mb/conversion_procs/cyrillic_and_mic/libcyrillic_and_mic.so.0.0
? src/backend/utils/mb/conversion_procs/euc_cn_and_mic/libeuc_cn_and_mic.so.0.0
? src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/libeuc_jp_and_sjis.so.0.0
? src/backend/utils/mb/conversion_procs/euc_kr_and_mic/libeuc_kr_and_mic.so.0.0
? src/backend/utils/mb/conversion_procs/euc_tw_and_big5/libeuc_tw_and_big5.so.0.0
? src/backend/utils/mb/conversion_procs/latin2_and_win1250/liblatin2_and_win1250.so.0.0
? src/backend/utils/mb/conversion_procs/latin_and_mic/liblatin_and_mic.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_ascii/libutf8_and_ascii.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_big5/libutf8_and_big5.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/libutf8_and_cyrillic.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/libutf8_and_euc_cn.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/libutf8_and_euc_jp.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/libutf8_and_euc_kr.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/libutf8_and_euc_tw.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_gb18030/libutf8_and_gb18030.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_gbk/libutf8_and_gbk.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_iso8859/libutf8_and_iso8859.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/libutf8_and_iso8859_1.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_johab/libutf8_and_johab.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_sjis/libutf8_and_sjis.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_tcvn/libutf8_and_tcvn.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_uhc/libutf8_and_uhc.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_win1250/libutf8_and_win1250.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_win1256/libutf8_and_win1256.so.0.0
? src/backend/utils/mb/conversion_procs/utf8_and_win874/libutf8_and_win874.so.0.0
? src/bin/initdb/initdb
? src/bin/initlocation/initlocation
? src/bin/ipcclean/ipcclean
? src/bin/pg_config/pg_config
? src/bin/pg_controldata/pg_controldata
? src/bin/pg_ctl/pg_ctl
? src/bin/pg_dump/pg_dump
? src/bin/pg_dump/pg_restore
? src/bin/pg_dump/pg_dumpall
? src/bin/pg_encoding/pg_encoding
? src/bin/pg_resetxlog/pg_resetxlog
? src/bin/pgtclsh/pgtclsh
? src/bin/pgtclsh/pgtksh
? src/bin/psql/psql
? src/bin/scripts/createdb
? src/bin/scripts/dropdb
? src/bin/scripts/createlang
? src/bin/scripts/createuser
? src/bin/scripts/droplang
? src/bin/scripts/dropuser
? src/bin/scripts/clusterdb
? src/bin/scripts/vacuumdb
? src/include/pg_config.h
? src/include/stamp-h
? src/interfaces/ecpg/compatlib/libecpg_compat.so.1.1
? src/interfaces/ecpg/ecpglib/libecpg.so.4.1
? src/interfaces/ecpg/pgtypeslib/libpgtypes.so.1.1
? src/interfaces/ecpg/preproc/ecpg
? src/interfaces/libpgtcl/libpgtcl.so.2.5
? src/interfaces/libpq/libpq.so.3.2
? src/pl/plperl/SPI.c
? src/pl/plperl/libplperl.so.0.0
? src/pl/plpgsql/src/libplpgsql.so.1.0
? src/pl/tcl/libpltcl.so.2.0
? src/pl/tcl/modules/pltcl_loadmod
? src/pl/tcl/modules/pltcl_delmod
? src/pl/tcl/modules/pltcl_listmod
? src/test/regress/pg_regress
? src/test/regress/log
? src/test/regress/tmp_check
? src/test/regress/results
? src/test/regress/expected/copy.out
? src/test/regress/expected/create_function_1.out
? src/test/regress/expected/create_function_2.out
? src/test/regress/expected/misc.out
? src/test/regress/expected/constraints.out
? src/test/regress/sql/copy.sql
? src/test/regress/sql/create_function_1.sql
? src/test/regress/sql/create_function_2.sql
? src/test/regress/sql/misc.sql
? src/test/regress/sql/constraints.sql
? src/tools/thread/thread_test
Index: doc/src/sgml/datatype.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/datatype.sgml,v
retrieving revision 1.135
retrieving revision 1.136
diff -c -r1.135 -r1.136
*** doc/src/sgml/datatype.sgml 1 Dec 2003 22:07:55 -0000 1.135
--- doc/src/sgml/datatype.sgml 20 Dec 2003 15:32:54 -0000 1.136
***************
*** 1,5 ****
--- 1,5 ----
***************
*** 1785,1790 ****
--- 1785,1841 ----
p should be between 0 and 6, and
defaults to the precision of the input literal.
+
+
+
+ Alternatively, interval values can be written as
+ ISO 8601 time intervals, using the "Format with time-unit designators".
+ This format always starts with the character 'P'</>, followed
+ by a string of values followed by single character time-unit designators.
+ A 'T'</> separates the date and time parts of the interval.
+
+
+
+ Format: PnYnMnDTnHnMnS
+
+
+ In this format, 'n'</> gets replaced by a number, and
+ Y</> represents years,
+ M</> (in the date part) months,
+ D</> months,
+ H</> hours,
+ M</> (in the time part) minutes,
+ and S</> seconds.
+
+
+
+
On Sat, 20 Dec 2003, Bruce Momjian wrote:
>Tom Lane wrote:
>>This is a horrid, horrid idea. Datestyle is already a complete mess
>> ...
>>Please revert that part of the patch and instead invent a new GUC
>>variable that's specifically for interval formatting.
>
> OK, I have backed out the patch. [...]
Short summary...
Before I try this, through email someone suggested yet a
different idea...
Would formatting functions for intervals such as...
to_iso8601basic_char(interval) -- return ISO-8601 basic fmt interval
to_iso8601basic_char(timestamp) -- return ISO-8601 basic fmt date/time
would be better than a new GUC variable?
Longer...
Tom Lane wrote:
>
> This is a horrid, horrid idea. Datestyle is already a complete mess
> because it is being used to control several things; it should have
> been two or possibly three GUC variables not one. Sticking in yet
> another behavior is just not acceptable IMHO, especially when it's
> defined as non-orthogonally as that.
>
> Please revert that part of the patch and instead invent a new GUC
> variable that's specifically for interval formatting.
First I just wanted to say how it ended up using datestyle...
In the earlier discussion when Andrew asked about a way of outputting
ISO-8601 Basic Format time intervals, the use of datestyle came up,
and noone objected to the use of datestyle at that point.
... Tom was suggesting:
http://archives.postgresql.org/pgsql-patches/2003-09/msg00122.php
TL>
TL> Perhaps call it "compact" or "terse" datestyle?
... and Peter suggested:
http://archives.postgresql.org/pgsql-patches/2003-09/msg00129.php
PE>
PE> iso8601
PE>
PE> Keep in mind that SQL itself is also a kind of ISO, so being
PE> more specific is useful.
Regarding the non-orthogonality, I was suspecting that most
applications that use ISO-8601 Basic Formats would use them
consistently for dates (19990131) and intervals (P1Y1M).
But I do see your point and agree this isn't a good solution.
If the developers would like separate GUC variables for
formatting dates vs intervals, I would be happy to do so.
On the other hand, if the idea of outputting ISO-8601
intervals is likely to be rejected anyway, I'd be happy
to not do it too. :-)
Or, how would people feel instead about formatting functions
to produce the various ISO-8601 formats?
to_iso8601basic_char(timestamp)
to_iso8601basic_char(interval)
I think this could be especially useful since the docs:
http://developer.postgresql.org/docs/postgres/functions-formatting.html
say that "to_char(interval, text)" is being deprecated,
meaning that converting intervals to formats other systems
accept will soon become harder.
Personally, though, I'm most interested in the input side.
I have an application that uses ISO-8601 Basic Format
for all it's time information (Dates, Times, and Intervals), and
wanted to load this information into PostgreSQL. I was happy
to see that Dates and Times loaded.
Unfortunately intervals did not.
A quick investigation showed that PostgreSQL currently has an
undocumented shorthand is similar but frustratingly different
from ISO-8601:
(i.e. '1Y1M'::interval means '1 year 1 minute' to PostgreSQL 7.3X,
while 'P1Y1M' means '1 year 1 month' to ISO-8601).
Even if nothing is done to the output side, allowing inputting
of such intervals would benefit me.
Would the developers prefer a patch allowing the inputting
of such intervals, and not support outputting at all?
> BTW, I can tell without looking that the patch is deficient in
> documentation; if it has effects on GUC variables, why is there no
> mod in runtime.sgml?
Point well taken. Before I submit any future patches I will try
to be more careful in this regard.
Ron
PS: The spec I'm referring to is ISO-8601... Section 5.5.4.2
http://www.webaugur.com/bibliotheca/standards/iso8601/154N362/index-25.html
Ron Mayer writes:
> Would formatting functions for intervals such as...
> to_iso8601basic_char(interval) -- return ISO-8601 basic fmt interval
> to_iso8601basic_char(timestamp) -- return ISO-8601 basic fmt date/time
> would be better than a new GUC variable?
I could see arguments for both --- in the timestamp world we have
DateStyle to control the default output format, plus to_char when you
want something different. I'd suggest continuing with your plan of
providing GUC control over the default interval format (just use a
separate GUC variable, please, for orthogonality). If you want to add
an explicit formatting function later, you can do that too.
BTW, I do not recall exactly why Karel wants to deprecate
to_char(interval), but I don't think it's because of any fundamental
objection to the notion of a formatting function. I think it was
because the present definition is badly designed and needs to be
replaced with a different API.
regards, tom lane
Added to TODO:
* Add GUC variable to allow output of interval values in ISO8601 format
---------------------------------------------------------------------------
Tom Lane wrote:
> Ron Mayer writes:
> > Would formatting functions for intervals such as...
> > to_iso8601basic_char(interval) -- return ISO-8601 basic fmt interval
> > to_iso8601basic_char(timestamp) -- return ISO-8601 basic fmt date/time
> > would be better than a new GUC variable?
>
> I could see arguments for both --- in the timestamp world we have
> DateStyle to control the default output format, plus to_char when you
> want something different. I'd suggest continuing with your plan of
> providing GUC control over the default interval format (just use a
> separate GUC variable, please, for orthogonality). If you want to add
> an explicit formatting function later, you can do that too.
>
> BTW, I do not recall exactly why Karel wants to deprecate
> to_char(interval), but I don't think it's because of any fundamental
> objection to the notion of a formatting function. I think it was
> because the present definition is badly designed and needs to be
> replaced with a different API.
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>
--
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