as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/* -----------------------------------------------------------------------
|
|
|
|
* formatting.c
|
|
|
|
*
|
2008-08-22 19:57:34 +02:00
|
|
|
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.146 2008/08/22 17:57:34 momjian Exp $
|
2000-02-08 16:57:01 +01:00
|
|
|
*
|
|
|
|
*
|
2008-01-01 20:46:01 +01:00
|
|
|
* Portions Copyright (c) 1999-2008, PostgreSQL Global Development Group
|
2000-02-08 16:57:01 +01:00
|
|
|
*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*
|
2000-04-12 19:17:23 +02:00
|
|
|
* TO_CHAR(); TO_TIMESTAMP(); TO_DATE(); TO_NUMBER();
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*
|
2000-04-12 19:17:23 +02:00
|
|
|
* The PostgreSQL routines for a timestamp/int/float/numeric formatting,
|
2002-09-20 05:54:57 +02:00
|
|
|
* inspired by the Oracle TO_CHAR() / TO_DATE() / TO_NUMBER() routines.
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*
|
|
|
|
*
|
2000-04-12 19:17:23 +02:00
|
|
|
* Cache & Memory:
|
|
|
|
* Routines use (itself) internal cache for format pictures.
|
|
|
|
*
|
2007-02-17 02:51:42 +01:00
|
|
|
* The cache uses a static buffer and is persistent across transactions. If
|
|
|
|
* the format-picture is bigger than the cache buffer, the parser is called
|
|
|
|
* always.
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*
|
2000-04-12 19:17:23 +02:00
|
|
|
* NOTE for Number version:
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* All in this version is implemented as keywords ( => not used
|
2000-04-12 19:17:23 +02:00
|
|
|
* suffixes), because a format picture is for *one* item (number)
|
|
|
|
* only. It not is as a timestamp version, where each keyword (can)
|
|
|
|
* has suffix.
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*
|
2000-04-12 19:17:23 +02:00
|
|
|
* NOTE for Timestamp routines:
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
* In this module the POSIX 'struct tm' type is *not* used, but rather
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* PgSQL type, which has tm_mon based on one (*non* zero) and
|
2000-04-12 19:17:23 +02:00
|
|
|
* year *not* based on 1900, but is used full year number.
|
2000-04-07 21:17:51 +02:00
|
|
|
* Module supports AD / BC / AM / PM.
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*
|
2000-04-12 19:17:23 +02:00
|
|
|
* Supported types for to_char():
|
|
|
|
*
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
* Timestamp, Numeric, int4, int8, float4, float8
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*
|
2000-04-12 19:17:23 +02:00
|
|
|
* Supported types for reverse conversion:
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
* Timestamp - to_timestamp()
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* Date - to_date()
|
2000-04-12 19:17:23 +02:00
|
|
|
* Numeric - to_number()
|
|
|
|
*
|
|
|
|
*
|
2000-07-03 18:01:33 +02:00
|
|
|
* Karel Zak
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*
|
2001-10-25 07:50:21 +02:00
|
|
|
* TODO
|
|
|
|
* - better number building (formatting) / parsing, now it isn't
|
|
|
|
* ideal code
|
2001-09-12 06:01:57 +02:00
|
|
|
* - use Assert()
|
2000-12-15 20:15:09 +01:00
|
|
|
* - add support for abstime
|
|
|
|
* - add support for roman number to standard number conversion
|
|
|
|
* - add support for number spelling
|
|
|
|
* - add support for string to string formatting (we must be better
|
2001-03-22 05:01:46 +01:00
|
|
|
* than Oracle :-),
|
|
|
|
* to_char('Hello', 'X X X X X') -> 'H e l l o'
|
|
|
|
*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* -----------------------------------------------------------------------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/* ----------
|
|
|
|
* UnComment me for DEBUG
|
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-07 21:17:51 +02:00
|
|
|
/***
|
2000-04-12 19:17:23 +02:00
|
|
|
#define DEBUG_TO_FROM_CHAR
|
2002-03-06 07:10:59 +01:00
|
|
|
#define DEBUG_elog_output DEBUG3
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
***/
|
|
|
|
|
2001-06-25 23:11:45 +02:00
|
|
|
#include "postgres.h"
|
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <math.h>
|
2000-01-26 07:33:49 +01:00
|
|
|
#include <float.h>
|
2007-06-29 03:51:35 +02:00
|
|
|
#include <limits.h>
|
2008-05-19 20:08:16 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* towlower() and friends should be in <wctype.h>, but some pre-C99 systems
|
|
|
|
* declare them in <wchar.h>.
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_WCHAR_H
|
|
|
|
#include <wchar.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_WCTYPE_H
|
|
|
|
#include <wctype.h>
|
|
|
|
#endif
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
#include "utils/builtins.h"
|
2000-07-01 23:27:14 +02:00
|
|
|
#include "utils/date.h"
|
|
|
|
#include "utils/datetime.h"
|
2000-07-01 16:10:32 +02:00
|
|
|
#include "utils/formatting.h"
|
2000-07-01 23:27:14 +02:00
|
|
|
#include "utils/int8.h"
|
2001-06-25 23:11:45 +02:00
|
|
|
#include "utils/numeric.h"
|
2000-07-01 23:27:14 +02:00
|
|
|
#include "utils/pg_locale.h"
|
2007-02-08 19:19:33 +01:00
|
|
|
#include "mb/pg_wchar.h"
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* Routines type
|
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
#define DCH_TYPE 1 /* DATE-TIME version */
|
|
|
|
#define NUM_TYPE 2 /* NUMBER version */
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* KeyWord Index (ascii from position 32 (' ') to 126 (~))
|
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-07 21:17:51 +02:00
|
|
|
#define KeyWord_INDEX_SIZE ('~' - ' ')
|
|
|
|
#define KeyWord_INDEX_FILTER(_c) ((_c) <= ' ' || (_c) >= '~' ? 0 : 1)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
/* ----------
|
2000-04-12 19:17:23 +02:00
|
|
|
* Maximal length of one node
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
#define DCH_MAX_ITEM_SIZ 9 /* max julian day */
|
|
|
|
#define NUM_MAX_ITEM_SIZ 8 /* roman number (RN has 15 chars) */
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
/* ----------
|
2000-03-16 02:35:41 +01:00
|
|
|
* More is in float.c
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
|
|
|
*/
|
2007-06-29 03:51:35 +02:00
|
|
|
#define MAXFLOATWIDTH 60
|
|
|
|
#define MAXDOUBLEWIDTH 500
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2007-02-08 19:19:33 +01:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/* ----------
|
2004-11-01 15:33:10 +01:00
|
|
|
* External (defined in PgSQL datetime.c (timestamp utils))
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
|
|
|
*/
|
2001-03-22 05:01:46 +01:00
|
|
|
extern char *months[], /* month abbreviation */
|
|
|
|
*days[]; /* full days */
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
/* ----------
|
2000-04-12 19:17:23 +02:00
|
|
|
* Format parser structs
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
char *name; /* suffix string */
|
|
|
|
int len, /* suffix length */
|
|
|
|
id, /* used in node->suffix */
|
|
|
|
type; /* prefix / postfix */
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
} KeySuffix;
|
|
|
|
|
2004-10-13 03:25:13 +02:00
|
|
|
typedef struct FormatNode FormatNode;
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
const char *name;
|
|
|
|
int len;
|
|
|
|
int id;
|
|
|
|
bool is_digit;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
} KeyWord;
|
|
|
|
|
2004-10-13 03:25:13 +02:00
|
|
|
struct FormatNode
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
int type; /* node type */
|
2005-03-26 01:41:31 +01:00
|
|
|
const KeyWord *key; /* if node type is KEYWORD */
|
2008-03-22 23:32:19 +01:00
|
|
|
char character; /* if node type is CHAR */
|
|
|
|
int suffix; /* keyword suffix */
|
2004-10-13 03:25:13 +02:00
|
|
|
};
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
#define NODE_TYPE_END 1
|
2000-04-12 19:17:23 +02:00
|
|
|
#define NODE_TYPE_ACTION 2
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
#define NODE_TYPE_CHAR 3
|
|
|
|
|
|
|
|
#define SUFFTYPE_PREFIX 1
|
|
|
|
#define SUFFTYPE_POSTFIX 2
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* Full months
|
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
static char *months_full[] = {
|
|
|
|
"January", "February", "March", "April", "May", "June", "July",
|
|
|
|
"August", "September", "October", "November", "December", NULL
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
};
|
|
|
|
|
2006-02-12 05:44:15 +01:00
|
|
|
static char *days_short[] = {
|
|
|
|
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL
|
|
|
|
};
|
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/* ----------
|
2008-03-22 23:32:19 +01:00
|
|
|
* AD / BC
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
2005-08-18 06:37:08 +02:00
|
|
|
* There is no 0 AD. Years go from 1 BC to 1 AD, so we make it
|
|
|
|
* positive and map year == -1 to year zero, and shift all negative
|
|
|
|
* years up one. For interval years, we just return the year.
|
|
|
|
*/
|
|
|
|
#define ADJUST_YEAR(year, is_interval) ((is_interval) ? (year) : ((year) <= 0 ? -((year) - 1) : (year)))
|
2000-04-12 19:17:23 +02:00
|
|
|
#define BC_STR_ORIG " BC"
|
2000-04-07 21:17:51 +02:00
|
|
|
|
|
|
|
#define A_D_STR "A.D."
|
|
|
|
#define a_d_STR "a.d."
|
|
|
|
#define AD_STR "AD"
|
|
|
|
#define ad_STR "ad"
|
|
|
|
|
|
|
|
#define B_C_STR "B.C."
|
|
|
|
#define b_c_STR "b.c."
|
|
|
|
#define BC_STR "BC"
|
|
|
|
#define bc_STR "bc"
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* AM / PM
|
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
#define A_M_STR "A.M."
|
|
|
|
#define a_m_STR "a.m."
|
|
|
|
#define AM_STR "AM"
|
|
|
|
#define am_STR "am"
|
|
|
|
|
|
|
|
#define P_M_STR "P.M."
|
|
|
|
#define p_m_STR "p.m."
|
|
|
|
#define PM_STR "PM"
|
|
|
|
#define pm_STR "pm"
|
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
/* ----------
|
|
|
|
* Months in roman-numeral
|
2008-03-22 23:32:19 +01:00
|
|
|
* (Must be in reverse order for seq_search (in FROM_CHAR), because
|
|
|
|
* 'VIII' must have higher precedence than 'V')
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
static char *rm_months_upper[] =
|
|
|
|
{"XII", "XI", "X", "IX", "VIII", "VII", "VI", "V", "IV", "III", "II", "I", NULL};
|
2000-04-07 21:17:51 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
static char *rm_months_lower[] =
|
|
|
|
{"xii", "xi", "x", "ix", "viii", "vii", "vi", "v", "iv", "iii", "ii", "i", NULL};
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* Roman numbers
|
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
static char *rm1[] = {"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", NULL};
|
|
|
|
static char *rm10[] = {"X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC", NULL};
|
|
|
|
static char *rm100[] = {"C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM", NULL};
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
/* ----------
|
|
|
|
* Ordinal postfixes
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
static char *numTH[] = {"ST", "ND", "RD", "TH", NULL};
|
|
|
|
static char *numth[] = {"st", "nd", "rd", "th", NULL};
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
/* ----------
|
|
|
|
* Flags & Options:
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
#define ONE_UPPER 1 /* Name */
|
|
|
|
#define ALL_UPPER 2 /* NAME */
|
|
|
|
#define ALL_LOWER 3 /* name */
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
#define FULL_SIZ 0
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
#define MAX_MON_LEN 3
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
#define MAX_DY_LEN 3
|
|
|
|
|
|
|
|
#define TH_UPPER 1
|
|
|
|
#define TH_LOWER 2
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* Number description struct
|
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
int pre, /* (count) numbers before decimal */
|
|
|
|
post, /* (count) numbers after decimal */
|
|
|
|
lsign, /* want locales sign */
|
2003-03-10 23:28:22 +01:00
|
|
|
flag, /* number parameters */
|
2001-03-22 05:01:46 +01:00
|
|
|
pre_lsign_num, /* tmp value for lsign */
|
|
|
|
multi, /* multiplier for 'V' */
|
|
|
|
zero_start, /* position of first zero */
|
|
|
|
zero_end, /* position of last zero */
|
|
|
|
need_locale; /* needs it locale */
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
} NUMDesc;
|
|
|
|
|
|
|
|
/* ----------
|
2000-04-12 19:17:23 +02:00
|
|
|
* Flags for NUMBER version
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
|
|
|
*/
|
2003-03-27 17:35:31 +01:00
|
|
|
#define NUM_F_DECIMAL (1 << 1)
|
|
|
|
#define NUM_F_LDECIMAL (1 << 2)
|
2005-05-25 23:40:43 +02:00
|
|
|
#define NUM_F_ZERO (1 << 3)
|
2003-08-04 02:43:34 +02:00
|
|
|
#define NUM_F_BLANK (1 << 4)
|
2003-03-27 17:35:31 +01:00
|
|
|
#define NUM_F_FILLMODE (1 << 5)
|
2003-08-04 02:43:34 +02:00
|
|
|
#define NUM_F_LSIGN (1 << 6)
|
2003-03-27 17:35:31 +01:00
|
|
|
#define NUM_F_BRACKET (1 << 7)
|
2003-08-04 02:43:34 +02:00
|
|
|
#define NUM_F_MINUS (1 << 8)
|
2005-05-25 23:40:43 +02:00
|
|
|
#define NUM_F_PLUS (1 << 9)
|
2003-08-04 02:43:34 +02:00
|
|
|
#define NUM_F_ROMAN (1 << 10)
|
2005-05-25 23:40:43 +02:00
|
|
|
#define NUM_F_MULTI (1 << 11)
|
2003-08-04 02:43:34 +02:00
|
|
|
#define NUM_F_PLUS_POST (1 << 12)
|
2003-03-27 17:35:31 +01:00
|
|
|
#define NUM_F_MINUS_POST (1 << 13)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2005-07-27 14:44:10 +02:00
|
|
|
#define NUM_LSIGN_PRE (-1)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
#define NUM_LSIGN_POST 1
|
|
|
|
#define NUM_LSIGN_NONE 0
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* Tests
|
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
#define IS_DECIMAL(_f) ((_f)->flag & NUM_F_DECIMAL)
|
|
|
|
#define IS_LDECIMAL(_f) ((_f)->flag & NUM_F_LDECIMAL)
|
2001-03-22 05:01:46 +01:00
|
|
|
#define IS_ZERO(_f) ((_f)->flag & NUM_F_ZERO)
|
2000-04-12 19:17:23 +02:00
|
|
|
#define IS_BLANK(_f) ((_f)->flag & NUM_F_BLANK)
|
|
|
|
#define IS_FILLMODE(_f) ((_f)->flag & NUM_F_FILLMODE)
|
|
|
|
#define IS_BRACKET(_f) ((_f)->flag & NUM_F_BRACKET)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
#define IS_MINUS(_f) ((_f)->flag & NUM_F_MINUS)
|
2000-02-08 16:57:01 +01:00
|
|
|
#define IS_LSIGN(_f) ((_f)->flag & NUM_F_LSIGN)
|
2001-03-22 05:01:46 +01:00
|
|
|
#define IS_PLUS(_f) ((_f)->flag & NUM_F_PLUS)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
#define IS_ROMAN(_f) ((_f)->flag & NUM_F_ROMAN)
|
|
|
|
#define IS_MULTI(_f) ((_f)->flag & NUM_F_MULTI)
|
|
|
|
|
2000-03-16 02:35:41 +01:00
|
|
|
/* ----------
|
2000-04-12 19:17:23 +02:00
|
|
|
* Format picture cache
|
2000-07-03 18:01:33 +02:00
|
|
|
* (cache size:
|
2001-03-22 05:01:46 +01:00
|
|
|
* Number part = NUM_CACHE_SIZE * NUM_CACHE_FIELDS
|
2000-03-16 02:35:41 +01:00
|
|
|
* Date-time part = DCH_CACHE_SIZE * DCH_CACHE_FIELDS
|
|
|
|
* )
|
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
#define NUM_CACHE_SIZE 64
|
2000-03-16 02:35:41 +01:00
|
|
|
#define NUM_CACHE_FIELDS 16
|
|
|
|
#define DCH_CACHE_SIZE 128
|
|
|
|
#define DCH_CACHE_FIELDS 16
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
FormatNode format[DCH_CACHE_SIZE + 1];
|
|
|
|
char str[DCH_CACHE_SIZE + 1];
|
2001-03-22 05:01:46 +01:00
|
|
|
int age;
|
2000-03-16 02:35:41 +01:00
|
|
|
} DCHCacheEntry;
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
FormatNode format[NUM_CACHE_SIZE + 1];
|
|
|
|
char str[NUM_CACHE_SIZE + 1];
|
2001-03-22 05:01:46 +01:00
|
|
|
int age;
|
2000-04-12 19:17:23 +02:00
|
|
|
NUMDesc Num;
|
2000-03-16 02:35:41 +01:00
|
|
|
} NUMCacheEntry;
|
|
|
|
|
2000-07-03 18:01:33 +02:00
|
|
|
/* global cache for --- date/time part */
|
2001-03-22 05:01:46 +01:00
|
|
|
static DCHCacheEntry DCHCache[DCH_CACHE_FIELDS + 1];
|
2000-07-03 18:01:33 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
static int n_DCHCache = 0; /* number of entries */
|
|
|
|
static int DCHCounter = 0;
|
2000-03-16 02:35:41 +01:00
|
|
|
|
2000-07-03 18:01:33 +02:00
|
|
|
/* global cache for --- number part */
|
2001-03-22 05:01:46 +01:00
|
|
|
static NUMCacheEntry NUMCache[NUM_CACHE_FIELDS + 1];
|
2000-12-15 20:15:09 +01:00
|
|
|
static NUMCacheEntry *last_NUMCacheEntry;
|
2000-07-03 18:01:33 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
static int n_NUMCache = 0; /* number of entries */
|
|
|
|
static int NUMCounter = 0;
|
2000-03-16 02:35:41 +01:00
|
|
|
|
2000-12-15 20:15:09 +01:00
|
|
|
#define MAX_INT32 (2147483600)
|
2000-03-16 02:35:41 +01:00
|
|
|
|
2000-07-03 18:01:33 +02:00
|
|
|
/* ----------
|
|
|
|
* For char->date/time conversion
|
|
|
|
* ----------
|
|
|
|
*/
|
2001-03-22 05:01:46 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int hh,
|
|
|
|
am,
|
|
|
|
pm,
|
|
|
|
mi,
|
|
|
|
ss,
|
|
|
|
ssss,
|
|
|
|
d,
|
|
|
|
dd,
|
|
|
|
ddd,
|
|
|
|
mm,
|
2001-09-06 05:22:42 +02:00
|
|
|
ms,
|
2007-02-16 04:39:46 +01:00
|
|
|
iyear,
|
2002-01-02 23:09:23 +01:00
|
|
|
year,
|
2001-03-22 05:01:46 +01:00
|
|
|
bc,
|
|
|
|
iw,
|
|
|
|
ww,
|
2001-10-25 07:50:21 +02:00
|
|
|
w,
|
2001-03-22 05:01:46 +01:00
|
|
|
cc,
|
|
|
|
q,
|
2001-09-06 05:22:42 +02:00
|
|
|
j,
|
2005-03-25 17:08:40 +01:00
|
|
|
us,
|
2005-10-15 04:49:52 +02:00
|
|
|
yysz; /* is it YY or YYYY ? */
|
2000-07-03 18:01:33 +02:00
|
|
|
} TmFromChar;
|
|
|
|
|
2005-07-27 14:44:10 +02:00
|
|
|
#define ZERO_tmfc(_X) memset(_X, 0, sizeof(TmFromChar))
|
2000-07-03 18:01:33 +02:00
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
/* ----------
|
|
|
|
* Debug
|
|
|
|
* ----------
|
|
|
|
*/
|
2000-07-03 18:01:33 +02:00
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2005-07-27 14:44:10 +02:00
|
|
|
#define DEBUG_TMFC(_X) \
|
2005-03-25 17:08:40 +01:00
|
|
|
elog(DEBUG_elog_output, "TMFC:\nhh %d\nam %d\npm %d\nmi %d\nss %d\nssss %d\nd %d\ndd %d\nddd %d\nmm %d\nms: %d\nyear %d\nbc %d\niw %d\nww %d\nw %d\ncc %d\nq %d\nj %d\nus: %d\nyysz: %d", \
|
2001-09-06 05:22:42 +02:00
|
|
|
(_X)->hh, (_X)->am, (_X)->pm, (_X)->mi, (_X)->ss, \
|
|
|
|
(_X)->ssss, (_X)->d, (_X)->dd, (_X)->ddd, (_X)->mm, (_X)->ms, \
|
2002-01-02 23:09:23 +01:00
|
|
|
(_X)->year, (_X)->bc, (_X)->iw, (_X)->ww, (_X)->w, \
|
2005-03-25 17:08:40 +01:00
|
|
|
(_X)->cc, (_X)->q, (_X)->j, (_X)->us, (_X)->yysz);
|
2005-07-27 14:44:10 +02:00
|
|
|
#define DEBUG_TM(_X) \
|
2000-07-03 18:01:33 +02:00
|
|
|
elog(DEBUG_elog_output, "TM:\nsec %d\nyear %d\nmin %d\nwday %d\nhour %d\nyday %d\nmday %d\nnisdst %d\nmon %d\n",\
|
2001-09-06 05:22:42 +02:00
|
|
|
(_X)->tm_sec, (_X)->tm_year,\
|
|
|
|
(_X)->tm_min, (_X)->tm_wday, (_X)->tm_hour, (_X)->tm_yday,\
|
|
|
|
(_X)->tm_mday, (_X)->tm_isdst, (_X)->tm_mon)
|
|
|
|
#else
|
2005-07-27 14:44:10 +02:00
|
|
|
#define DEBUG_TMFC(_X)
|
|
|
|
#define DEBUG_TM(_X)
|
2000-07-03 18:01:33 +02:00
|
|
|
#endif
|
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
/* ----------
|
|
|
|
* Datetime to char conversion
|
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
typedef struct TmToChar
|
|
|
|
{
|
2004-08-29 07:07:03 +02:00
|
|
|
struct pg_tm tm; /* classic 'tm' struct */
|
2002-04-21 21:52:18 +02:00
|
|
|
fsec_t fsec; /* fractional seconds */
|
2001-10-25 07:50:21 +02:00
|
|
|
char *tzn; /* timezone */
|
2001-09-06 05:22:42 +02:00
|
|
|
} TmToChar;
|
|
|
|
|
|
|
|
#define tmtcTm(_X) (&(_X)->tm)
|
2001-10-25 07:50:21 +02:00
|
|
|
#define tmtcTzn(_X) ((_X)->tzn)
|
2001-09-06 05:22:42 +02:00
|
|
|
#define tmtcFsec(_X) ((_X)->fsec)
|
|
|
|
|
2005-07-27 14:44:10 +02:00
|
|
|
#define ZERO_tm(_X) \
|
2005-08-18 15:43:08 +02:00
|
|
|
do { \
|
|
|
|
(_X)->tm_sec = (_X)->tm_year = (_X)->tm_min = (_X)->tm_wday = \
|
|
|
|
(_X)->tm_hour = (_X)->tm_yday = (_X)->tm_isdst = 0; \
|
|
|
|
(_X)->tm_mday = (_X)->tm_mon = 1; \
|
|
|
|
} while(0)
|
2000-07-03 18:01:33 +02:00
|
|
|
|
2005-07-27 14:44:10 +02:00
|
|
|
#define ZERO_tmtc(_X) \
|
2005-08-18 15:43:08 +02:00
|
|
|
do { \
|
|
|
|
ZERO_tm( tmtcTm(_X) ); \
|
|
|
|
tmtcFsec(_X) = 0; \
|
|
|
|
tmtcTzn(_X) = NULL; \
|
|
|
|
} while(0)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2005-12-03 17:45:06 +01:00
|
|
|
/*
|
|
|
|
* to_char(time) appears to to_char() as an interval, so this check
|
|
|
|
* is really for interval and time data types.
|
|
|
|
*/
|
2005-08-18 06:37:08 +02:00
|
|
|
#define INVALID_FOR_INTERVAL \
|
2005-08-18 15:43:08 +02:00
|
|
|
do { \
|
|
|
|
if (is_interval) \
|
|
|
|
ereport(ERROR, \
|
|
|
|
(errcode(ERRCODE_INVALID_DATETIME_FORMAT), \
|
|
|
|
errmsg("invalid format specification for an interval value"), \
|
|
|
|
errhint("Intervals are not tied to specific calendar dates."))); \
|
|
|
|
} while(0)
|
2005-10-15 04:49:52 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/*****************************************************************************
|
2008-03-22 23:32:19 +01:00
|
|
|
* KeyWord definitions
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
/* ----------
|
|
|
|
* Suffixes:
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
#define DCH_S_FM 0x01
|
|
|
|
#define DCH_S_TH 0x02
|
|
|
|
#define DCH_S_th 0x04
|
|
|
|
#define DCH_S_SP 0x08
|
2006-02-12 05:44:15 +01:00
|
|
|
#define DCH_S_TM 0x10
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
/* ----------
|
|
|
|
* Suffix tests
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
|
|
|
*/
|
2005-05-25 23:40:43 +02:00
|
|
|
#define S_THth(_s) ((((_s) & DCH_S_TH) || ((_s) & DCH_S_th)) ? 1 : 0)
|
|
|
|
#define S_TH(_s) (((_s) & DCH_S_TH) ? 1 : 0)
|
|
|
|
#define S_th(_s) (((_s) & DCH_S_th) ? 1 : 0)
|
|
|
|
#define S_TH_TYPE(_s) (((_s) & DCH_S_TH) ? TH_UPPER : TH_LOWER)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2005-05-25 23:40:43 +02:00
|
|
|
#define S_FM(_s) (((_s) & DCH_S_FM) ? 1 : 0)
|
|
|
|
#define S_SP(_s) (((_s) & DCH_S_SP) ? 1 : 0)
|
2006-02-12 05:44:15 +01:00
|
|
|
#define S_TM(_s) (((_s) & DCH_S_TM) ? 1 : 0)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* Suffixes definition for DATE-TIME TO/FROM CHAR
|
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
static KeySuffix DCH_suff[] = {
|
2000-04-12 19:17:23 +02:00
|
|
|
{"FM", 2, DCH_S_FM, SUFFTYPE_PREFIX},
|
|
|
|
{"fm", 2, DCH_S_FM, SUFFTYPE_PREFIX},
|
2006-02-12 05:44:15 +01:00
|
|
|
{"TM", 2, DCH_S_TM, SUFFTYPE_PREFIX},
|
|
|
|
{"tm", 2, DCH_S_TM, SUFFTYPE_PREFIX},
|
2000-04-12 19:17:23 +02:00
|
|
|
{"TH", 2, DCH_S_TH, SUFFTYPE_POSTFIX},
|
|
|
|
{"th", 2, DCH_S_th, SUFFTYPE_POSTFIX},
|
|
|
|
{"SP", 2, DCH_S_SP, SUFFTYPE_POSTFIX},
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/* last */
|
2000-04-12 19:17:23 +02:00
|
|
|
{NULL, 0, 0, 0}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* Format-pictures (KeyWord).
|
2000-04-12 19:17:23 +02:00
|
|
|
*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* The KeyWord field; alphabetic sorted, *BUT* strings alike is sorted
|
2000-04-12 19:17:23 +02:00
|
|
|
* complicated -to-> easy:
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*
|
2000-04-12 19:17:23 +02:00
|
|
|
* (example: "DDD","DD","Day","D" )
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*
|
|
|
|
* (this specific sort needs the algorithm for sequential search for strings,
|
2000-04-12 19:17:23 +02:00
|
|
|
* which not has exact end; -> How keyword is in "HH12blabla" ? - "HH"
|
|
|
|
* or "HH12"? You must first try "HH12", because "HH" is in string, but
|
|
|
|
* it is not good.
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*
|
2000-04-12 19:17:23 +02:00
|
|
|
* (!)
|
2003-03-10 23:28:22 +01:00
|
|
|
* - Position for the keyword is similar as position in the enum DCH/NUM_poz.
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* (!)
|
|
|
|
*
|
2000-04-12 19:17:23 +02:00
|
|
|
* For fast search is used the 'int index[]', index is ascii table from position
|
|
|
|
* 32 (' ') to 126 (~), in this index is DCH_ / NUM_ enums for each ASCII
|
|
|
|
* position or -1 if char is not used in the KeyWord. Search example for
|
2000-02-08 16:57:01 +01:00
|
|
|
* string "MM":
|
2000-04-12 19:17:23 +02:00
|
|
|
* 1) see in index to index['M' - 32],
|
2007-02-16 04:39:46 +01:00
|
|
|
* 2) take keywords position (enum DCH_MI) from index
|
2000-04-12 19:17:23 +02:00
|
|
|
* 3) run sequential search in keywords[] from this position
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*
|
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
typedef enum
|
|
|
|
{
|
2001-10-28 07:26:15 +01:00
|
|
|
DCH_A_D,
|
|
|
|
DCH_A_M,
|
|
|
|
DCH_AD,
|
|
|
|
DCH_AM,
|
|
|
|
DCH_B_C,
|
|
|
|
DCH_BC,
|
|
|
|
DCH_CC,
|
|
|
|
DCH_DAY,
|
|
|
|
DCH_DDD,
|
|
|
|
DCH_DD,
|
|
|
|
DCH_DY,
|
|
|
|
DCH_Day,
|
|
|
|
DCH_Dy,
|
|
|
|
DCH_D,
|
|
|
|
DCH_FX, /* global suffix */
|
|
|
|
DCH_HH24,
|
|
|
|
DCH_HH12,
|
|
|
|
DCH_HH,
|
2007-02-16 04:39:46 +01:00
|
|
|
DCH_IDDD,
|
|
|
|
DCH_ID,
|
2001-10-28 07:26:15 +01:00
|
|
|
DCH_IW,
|
2003-12-25 04:36:24 +01:00
|
|
|
DCH_IYYY,
|
|
|
|
DCH_IYY,
|
|
|
|
DCH_IY,
|
|
|
|
DCH_I,
|
2001-10-28 07:26:15 +01:00
|
|
|
DCH_J,
|
|
|
|
DCH_MI,
|
|
|
|
DCH_MM,
|
|
|
|
DCH_MONTH,
|
|
|
|
DCH_MON,
|
|
|
|
DCH_MS,
|
|
|
|
DCH_Month,
|
|
|
|
DCH_Mon,
|
|
|
|
DCH_P_M,
|
|
|
|
DCH_PM,
|
|
|
|
DCH_Q,
|
|
|
|
DCH_RM,
|
|
|
|
DCH_SSSS,
|
|
|
|
DCH_SS,
|
|
|
|
DCH_TZ,
|
|
|
|
DCH_US,
|
|
|
|
DCH_WW,
|
|
|
|
DCH_W,
|
|
|
|
DCH_Y_YYY,
|
|
|
|
DCH_YYYY,
|
|
|
|
DCH_YYY,
|
|
|
|
DCH_YY,
|
|
|
|
DCH_Y,
|
|
|
|
DCH_a_d,
|
|
|
|
DCH_a_m,
|
|
|
|
DCH_ad,
|
|
|
|
DCH_am,
|
|
|
|
DCH_b_c,
|
|
|
|
DCH_bc,
|
|
|
|
DCH_cc,
|
|
|
|
DCH_day,
|
|
|
|
DCH_ddd,
|
|
|
|
DCH_dd,
|
|
|
|
DCH_dy,
|
|
|
|
DCH_d,
|
|
|
|
DCH_fx,
|
|
|
|
DCH_hh24,
|
|
|
|
DCH_hh12,
|
|
|
|
DCH_hh,
|
2007-02-16 04:39:46 +01:00
|
|
|
DCH_iddd,
|
|
|
|
DCH_id,
|
2001-10-28 07:26:15 +01:00
|
|
|
DCH_iw,
|
2003-12-25 04:36:24 +01:00
|
|
|
DCH_iyyy,
|
|
|
|
DCH_iyy,
|
|
|
|
DCH_iy,
|
|
|
|
DCH_i,
|
2001-10-28 07:26:15 +01:00
|
|
|
DCH_j,
|
|
|
|
DCH_mi,
|
|
|
|
DCH_mm,
|
|
|
|
DCH_month,
|
|
|
|
DCH_mon,
|
|
|
|
DCH_ms,
|
|
|
|
DCH_p_m,
|
|
|
|
DCH_pm,
|
|
|
|
DCH_q,
|
|
|
|
DCH_rm,
|
|
|
|
DCH_ssss,
|
|
|
|
DCH_ss,
|
|
|
|
DCH_tz,
|
|
|
|
DCH_us,
|
|
|
|
DCH_ww,
|
|
|
|
DCH_w,
|
|
|
|
DCH_y_yyy,
|
|
|
|
DCH_yyyy,
|
|
|
|
DCH_yyy,
|
|
|
|
DCH_yy,
|
|
|
|
DCH_y,
|
2000-04-07 21:17:51 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/* last */
|
2001-10-28 07:26:15 +01:00
|
|
|
_DCH_last_
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
} DCH_poz;
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
typedef enum
|
|
|
|
{
|
2001-10-28 07:26:15 +01:00
|
|
|
NUM_COMMA,
|
|
|
|
NUM_DEC,
|
|
|
|
NUM_0,
|
|
|
|
NUM_9,
|
|
|
|
NUM_B,
|
|
|
|
NUM_C,
|
|
|
|
NUM_D,
|
|
|
|
NUM_E,
|
|
|
|
NUM_FM,
|
|
|
|
NUM_G,
|
|
|
|
NUM_L,
|
|
|
|
NUM_MI,
|
|
|
|
NUM_PL,
|
|
|
|
NUM_PR,
|
|
|
|
NUM_RN,
|
|
|
|
NUM_SG,
|
|
|
|
NUM_SP,
|
|
|
|
NUM_S,
|
|
|
|
NUM_TH,
|
|
|
|
NUM_V,
|
|
|
|
NUM_b,
|
|
|
|
NUM_c,
|
|
|
|
NUM_d,
|
|
|
|
NUM_e,
|
|
|
|
NUM_fm,
|
|
|
|
NUM_g,
|
|
|
|
NUM_l,
|
|
|
|
NUM_mi,
|
|
|
|
NUM_pl,
|
|
|
|
NUM_pr,
|
|
|
|
NUM_rn,
|
|
|
|
NUM_sg,
|
|
|
|
NUM_sp,
|
|
|
|
NUM_s,
|
|
|
|
NUM_th,
|
|
|
|
NUM_v,
|
2000-04-12 19:17:23 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/* last */
|
2001-10-28 07:26:15 +01:00
|
|
|
_NUM_last_
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
} NUM_poz;
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* KeyWords for DATE-TIME version
|
|
|
|
* ----------
|
|
|
|
*/
|
2005-03-26 01:41:31 +01:00
|
|
|
static const KeyWord DCH_keywords[] = {
|
2008-03-22 23:32:19 +01:00
|
|
|
/* name, len, id, is_digit is in Index */
|
|
|
|
{"A.D.", 4, DCH_A_D, FALSE}, /* A */
|
|
|
|
{"A.M.", 4, DCH_A_M, FALSE},
|
|
|
|
{"AD", 2, DCH_AD, FALSE},
|
|
|
|
{"AM", 2, DCH_AM, FALSE},
|
|
|
|
{"B.C.", 4, DCH_B_C, FALSE}, /* B */
|
|
|
|
{"BC", 2, DCH_BC, FALSE},
|
|
|
|
{"CC", 2, DCH_CC, TRUE}, /* C */
|
|
|
|
{"DAY", 3, DCH_DAY, FALSE}, /* D */
|
|
|
|
{"DDD", 3, DCH_DDD, TRUE},
|
|
|
|
{"DD", 2, DCH_DD, TRUE},
|
|
|
|
{"DY", 2, DCH_DY, FALSE},
|
|
|
|
{"Day", 3, DCH_Day, FALSE},
|
|
|
|
{"Dy", 2, DCH_Dy, FALSE},
|
|
|
|
{"D", 1, DCH_D, TRUE},
|
|
|
|
{"FX", 2, DCH_FX, FALSE}, /* F */
|
|
|
|
{"HH24", 4, DCH_HH24, TRUE}, /* H */
|
|
|
|
{"HH12", 4, DCH_HH12, TRUE},
|
|
|
|
{"HH", 2, DCH_HH, TRUE},
|
|
|
|
{"IDDD", 4, DCH_IDDD, TRUE}, /* I */
|
|
|
|
{"ID", 2, DCH_ID, TRUE},
|
|
|
|
{"IW", 2, DCH_IW, TRUE},
|
|
|
|
{"IYYY", 4, DCH_IYYY, TRUE},
|
|
|
|
{"IYY", 3, DCH_IYY, TRUE},
|
|
|
|
{"IY", 2, DCH_IY, TRUE},
|
|
|
|
{"I", 1, DCH_I, TRUE},
|
|
|
|
{"J", 1, DCH_J, TRUE}, /* J */
|
|
|
|
{"MI", 2, DCH_MI, TRUE}, /* M */
|
|
|
|
{"MM", 2, DCH_MM, TRUE},
|
|
|
|
{"MONTH", 5, DCH_MONTH, FALSE},
|
|
|
|
{"MON", 3, DCH_MON, FALSE},
|
|
|
|
{"MS", 2, DCH_MS, TRUE},
|
|
|
|
{"Month", 5, DCH_Month, FALSE},
|
|
|
|
{"Mon", 3, DCH_Mon, FALSE},
|
|
|
|
{"P.M.", 4, DCH_P_M, FALSE}, /* P */
|
|
|
|
{"PM", 2, DCH_PM, FALSE},
|
|
|
|
{"Q", 1, DCH_Q, TRUE}, /* Q */
|
|
|
|
{"RM", 2, DCH_RM, FALSE}, /* R */
|
|
|
|
{"SSSS", 4, DCH_SSSS, TRUE}, /* S */
|
|
|
|
{"SS", 2, DCH_SS, TRUE},
|
|
|
|
{"TZ", 2, DCH_TZ, FALSE}, /* T */
|
|
|
|
{"US", 2, DCH_US, TRUE}, /* U */
|
|
|
|
{"WW", 2, DCH_WW, TRUE}, /* W */
|
|
|
|
{"W", 1, DCH_W, TRUE},
|
|
|
|
{"Y,YYY", 5, DCH_Y_YYY, TRUE}, /* Y */
|
|
|
|
{"YYYY", 4, DCH_YYYY, TRUE},
|
|
|
|
{"YYY", 3, DCH_YYY, TRUE},
|
|
|
|
{"YY", 2, DCH_YY, TRUE},
|
|
|
|
{"Y", 1, DCH_Y, TRUE},
|
|
|
|
{"a.d.", 4, DCH_a_d, FALSE}, /* a */
|
|
|
|
{"a.m.", 4, DCH_a_m, FALSE},
|
|
|
|
{"ad", 2, DCH_ad, FALSE},
|
|
|
|
{"am", 2, DCH_am, FALSE},
|
|
|
|
{"b.c.", 4, DCH_b_c, FALSE}, /* b */
|
|
|
|
{"bc", 2, DCH_bc, FALSE},
|
|
|
|
{"cc", 2, DCH_CC, TRUE}, /* c */
|
|
|
|
{"day", 3, DCH_day, FALSE}, /* d */
|
|
|
|
{"ddd", 3, DCH_DDD, TRUE},
|
|
|
|
{"dd", 2, DCH_DD, TRUE},
|
|
|
|
{"dy", 2, DCH_dy, FALSE},
|
|
|
|
{"d", 1, DCH_D, TRUE},
|
|
|
|
{"fx", 2, DCH_FX, FALSE}, /* f */
|
|
|
|
{"hh24", 4, DCH_HH24, TRUE}, /* h */
|
|
|
|
{"hh12", 4, DCH_HH12, TRUE},
|
|
|
|
{"hh", 2, DCH_HH, TRUE},
|
|
|
|
{"iddd", 4, DCH_IDDD, TRUE}, /* i */
|
|
|
|
{"id", 2, DCH_ID, TRUE},
|
|
|
|
{"iw", 2, DCH_IW, TRUE},
|
|
|
|
{"iyyy", 4, DCH_IYYY, TRUE},
|
|
|
|
{"iyy", 3, DCH_IYY, TRUE},
|
|
|
|
{"iy", 2, DCH_IY, TRUE},
|
|
|
|
{"i", 1, DCH_I, TRUE},
|
|
|
|
{"j", 1, DCH_J, TRUE}, /* j */
|
|
|
|
{"mi", 2, DCH_MI, TRUE}, /* m */
|
|
|
|
{"mm", 2, DCH_MM, TRUE},
|
|
|
|
{"month", 5, DCH_month, FALSE},
|
|
|
|
{"mon", 3, DCH_mon, FALSE},
|
|
|
|
{"ms", 2, DCH_MS, TRUE},
|
|
|
|
{"p.m.", 4, DCH_p_m, FALSE}, /* p */
|
|
|
|
{"pm", 2, DCH_pm, FALSE},
|
|
|
|
{"q", 1, DCH_Q, TRUE}, /* q */
|
|
|
|
{"rm", 2, DCH_rm, FALSE}, /* r */
|
|
|
|
{"ssss", 4, DCH_SSSS, TRUE}, /* s */
|
|
|
|
{"ss", 2, DCH_SS, TRUE},
|
|
|
|
{"tz", 2, DCH_tz, FALSE}, /* t */
|
|
|
|
{"us", 2, DCH_US, TRUE}, /* u */
|
|
|
|
{"ww", 2, DCH_WW, TRUE}, /* w */
|
|
|
|
{"w", 1, DCH_W, TRUE},
|
|
|
|
{"y,yyy", 5, DCH_Y_YYY, TRUE}, /* y */
|
|
|
|
{"yyyy", 4, DCH_YYYY, TRUE},
|
|
|
|
{"yyy", 3, DCH_YYY, TRUE},
|
|
|
|
{"yy", 2, DCH_YY, TRUE},
|
|
|
|
{"y", 1, DCH_Y, TRUE},
|
|
|
|
|
|
|
|
/* last */
|
|
|
|
{NULL, 0, 0, 0}
|
|
|
|
};
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
/* ----------
|
2008-03-22 23:32:19 +01:00
|
|
|
* KeyWords for NUMBER version (is_digit field is not needful here...)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
|
|
|
*/
|
2005-03-26 01:41:31 +01:00
|
|
|
static const KeyWord NUM_keywords[] = {
|
2008-03-22 23:32:19 +01:00
|
|
|
/* name, len, id is in Index */
|
|
|
|
{",", 1, NUM_COMMA}, /* , */
|
|
|
|
{".", 1, NUM_DEC}, /* . */
|
|
|
|
{"0", 1, NUM_0}, /* 0 */
|
|
|
|
{"9", 1, NUM_9}, /* 9 */
|
|
|
|
{"B", 1, NUM_B}, /* B */
|
|
|
|
{"C", 1, NUM_C}, /* C */
|
|
|
|
{"D", 1, NUM_D}, /* D */
|
|
|
|
{"E", 1, NUM_E}, /* E */
|
|
|
|
{"FM", 2, NUM_FM}, /* F */
|
|
|
|
{"G", 1, NUM_G}, /* G */
|
|
|
|
{"L", 1, NUM_L}, /* L */
|
|
|
|
{"MI", 2, NUM_MI}, /* M */
|
|
|
|
{"PL", 2, NUM_PL}, /* P */
|
|
|
|
{"PR", 2, NUM_PR},
|
|
|
|
{"RN", 2, NUM_RN}, /* R */
|
|
|
|
{"SG", 2, NUM_SG}, /* S */
|
|
|
|
{"SP", 2, NUM_SP},
|
|
|
|
{"S", 1, NUM_S},
|
|
|
|
{"TH", 2, NUM_TH}, /* T */
|
|
|
|
{"V", 1, NUM_V}, /* V */
|
|
|
|
{"b", 1, NUM_B}, /* b */
|
|
|
|
{"c", 1, NUM_C}, /* c */
|
|
|
|
{"d", 1, NUM_D}, /* d */
|
|
|
|
{"e", 1, NUM_E}, /* e */
|
|
|
|
{"fm", 2, NUM_FM}, /* f */
|
|
|
|
{"g", 1, NUM_G}, /* g */
|
|
|
|
{"l", 1, NUM_L}, /* l */
|
|
|
|
{"mi", 2, NUM_MI}, /* m */
|
|
|
|
{"pl", 2, NUM_PL}, /* p */
|
|
|
|
{"pr", 2, NUM_PR},
|
|
|
|
{"rn", 2, NUM_rn}, /* r */
|
|
|
|
{"sg", 2, NUM_SG}, /* s */
|
|
|
|
{"sp", 2, NUM_SP},
|
|
|
|
{"s", 1, NUM_S},
|
|
|
|
{"th", 2, NUM_th}, /* t */
|
|
|
|
{"v", 1, NUM_V}, /* v */
|
|
|
|
|
|
|
|
/* last */
|
|
|
|
{NULL, 0, 0}
|
|
|
|
};
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* KeyWords index for DATE-TIME version
|
|
|
|
* ----------
|
|
|
|
*/
|
2005-10-15 04:49:52 +02:00
|
|
|
static const int DCH_index[KeyWord_INDEX_SIZE] = {
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/*
|
|
|
|
0 1 2 3 4 5 6 7 8 9
|
|
|
|
*/
|
2003-03-10 23:28:22 +01:00
|
|
|
/*---- first 0..31 chars are skipped ----*/
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
-1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
|
-1, -1, -1, -1, -1, DCH_A_D, DCH_B_C, DCH_CC, DCH_DAY, -1,
|
2007-02-16 04:39:46 +01:00
|
|
|
DCH_FX, -1, DCH_HH24, DCH_IDDD, DCH_J, -1, -1, DCH_MI, -1, -1,
|
2001-09-06 05:22:42 +02:00
|
|
|
DCH_P_M, DCH_Q, DCH_RM, DCH_SSSS, DCH_TZ, DCH_US, -1, DCH_WW, -1, DCH_Y_YYY,
|
2000-04-12 19:17:23 +02:00
|
|
|
-1, -1, -1, -1, -1, -1, -1, DCH_a_d, DCH_b_c, DCH_cc,
|
2007-02-16 04:39:46 +01:00
|
|
|
DCH_day, -1, DCH_fx, -1, DCH_hh24, DCH_iddd, DCH_j, -1, -1, DCH_mi,
|
2001-09-06 05:22:42 +02:00
|
|
|
-1, -1, DCH_p_m, DCH_q, DCH_rm, DCH_ssss, DCH_tz, DCH_us, -1, DCH_ww,
|
2000-04-12 19:17:23 +02:00
|
|
|
-1, DCH_y_yyy, -1, -1, -1, -1
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
/*---- chars over 126 are skipped ----*/
|
2000-04-12 19:17:23 +02:00
|
|
|
};
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* KeyWords index for NUMBER version
|
|
|
|
* ----------
|
|
|
|
*/
|
2005-10-15 04:49:52 +02:00
|
|
|
static const int NUM_index[KeyWord_INDEX_SIZE] = {
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/*
|
|
|
|
0 1 2 3 4 5 6 7 8 9
|
|
|
|
*/
|
2008-03-22 23:32:19 +01:00
|
|
|
/*---- first 0..31 chars are skipped ----*/
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
-1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
|
-1, -1, -1, -1, NUM_COMMA, -1, NUM_DEC, -1, NUM_0, -1,
|
|
|
|
-1, -1, -1, -1, -1, -1, -1, NUM_9, -1, -1,
|
|
|
|
-1, -1, -1, -1, -1, -1, NUM_B, NUM_C, NUM_D, NUM_E,
|
|
|
|
NUM_FM, NUM_G, -1, -1, -1, -1, NUM_L, NUM_MI, -1, -1,
|
|
|
|
NUM_PL, -1, NUM_RN, NUM_SG, NUM_TH, -1, NUM_V, -1, -1, -1,
|
|
|
|
-1, -1, -1, -1, -1, -1, -1, -1, NUM_b, NUM_c,
|
|
|
|
NUM_d, NUM_e, NUM_fm, NUM_g, -1, -1, -1, -1, NUM_l, NUM_mi,
|
|
|
|
-1, -1, NUM_pl, -1, NUM_rn, NUM_sg, NUM_th, -1, NUM_v, -1,
|
|
|
|
-1, -1, -1, -1, -1, -1
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
/*---- chars over 126 are skipped ----*/
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* Number processor struct
|
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
typedef struct NUMProc
|
|
|
|
{
|
2005-08-17 23:47:55 +02:00
|
|
|
bool is_to_char;
|
2001-03-22 05:01:46 +01:00
|
|
|
NUMDesc *Num; /* number description */
|
|
|
|
|
|
|
|
int sign, /* '-' or '+' */
|
|
|
|
sign_wrote, /* was sign write */
|
|
|
|
num_count, /* number of write digits */
|
|
|
|
num_in, /* is inside number */
|
|
|
|
num_curr, /* current position in number */
|
|
|
|
num_pre, /* space before first number */
|
|
|
|
|
|
|
|
read_dec, /* to_number - was read dec. point */
|
2004-10-28 20:55:08 +02:00
|
|
|
read_post, /* to_number - number of dec. digit */
|
|
|
|
read_pre; /* to_number - number non-dec. digit */
|
2001-03-22 05:01:46 +01:00
|
|
|
|
|
|
|
char *number, /* string with number */
|
2003-03-10 23:28:22 +01:00
|
|
|
*number_p, /* pointer to current number position */
|
2001-03-22 05:01:46 +01:00
|
|
|
*inout, /* in / out buffer */
|
2003-03-10 23:28:22 +01:00
|
|
|
*inout_p, /* pointer to current inout position */
|
2005-10-15 04:49:52 +02:00
|
|
|
*last_relevant, /* last relevant number after decimal point */
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2001-10-28 07:26:15 +01:00
|
|
|
*L_negative_sign, /* Locale */
|
2001-03-22 05:01:46 +01:00
|
|
|
*L_positive_sign,
|
|
|
|
*decimal,
|
|
|
|
*L_thousands_sep,
|
|
|
|
*L_currency_symbol;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
} NUMProc;
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* Functions
|
|
|
|
* ----------
|
|
|
|
*/
|
2005-03-26 01:41:31 +01:00
|
|
|
static const KeyWord *index_seq_search(char *str, const KeyWord *kw,
|
2005-10-15 04:49:52 +02:00
|
|
|
const int *index);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
static KeySuffix *suff_search(char *str, KeySuffix *suf, int type);
|
|
|
|
static void NUMDesc_prepare(NUMDesc *num, FormatNode *n);
|
2005-03-26 01:41:31 +01:00
|
|
|
static void parse_format(FormatNode *node, char *str, const KeyWord *kw,
|
|
|
|
KeySuffix *suf, const int *index, int ver, NUMDesc *Num);
|
2008-03-22 23:32:19 +01:00
|
|
|
|
|
|
|
static void DCH_to_char(FormatNode *node, bool is_interval,
|
|
|
|
TmToChar *in, char *out);
|
|
|
|
static void DCH_from_char(FormatNode *node, char *in, TmFromChar *out);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2005-03-26 01:41:31 +01:00
|
|
|
static void dump_index(const KeyWord *k, const int *index);
|
2000-04-12 19:17:23 +02:00
|
|
|
static void dump_node(FormatNode *node, int max);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static char *get_th(char *num, int type);
|
|
|
|
static char *str_numth(char *dest, char *num, int type);
|
2006-04-19 20:49:09 +02:00
|
|
|
static int strspace_len(char *str);
|
2001-10-25 07:50:21 +02:00
|
|
|
static int strdigits_len(char *str);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
static int seq_search(char *name, char **array, int type, int max, int *len);
|
2003-08-25 18:13:27 +02:00
|
|
|
static void do_to_timestamp(text *date_txt, text *fmt,
|
2005-10-15 04:49:52 +02:00
|
|
|
struct pg_tm * tm, fsec_t *fsec);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
static char *fill_str(char *str, int c, int max);
|
2008-03-25 23:42:46 +01:00
|
|
|
static FormatNode *NUM_cache(int len, NUMDesc *Num, text *pars_str, bool *shouldFree);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
static char *int_to_roman(int number);
|
|
|
|
static void NUM_prepare_locale(NUMProc *Np);
|
2000-02-08 16:57:01 +01:00
|
|
|
static char *get_last_relevant_decnum(char *num);
|
2000-04-12 19:17:23 +02:00
|
|
|
static void NUM_numpart_from_char(NUMProc *Np, int id, int plen);
|
|
|
|
static void NUM_numpart_to_char(NUMProc *Np, int id);
|
|
|
|
static char *NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
|
2005-08-17 23:47:55 +02:00
|
|
|
int plen, int sign, bool is_to_char);
|
2000-04-12 19:17:23 +02:00
|
|
|
static DCHCacheEntry *DCH_cache_search(char *str);
|
|
|
|
static DCHCacheEntry *DCH_cache_getnew(char *str);
|
2000-12-15 20:15:09 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
static NUMCacheEntry *NUM_cache_search(char *str);
|
|
|
|
static NUMCacheEntry *NUM_cache_getnew(char *str);
|
2000-12-15 20:15:09 +01:00
|
|
|
static void NUM_cache_remove(NUMCacheEntry *ent);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2007-02-08 19:19:33 +01:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/* ----------
|
|
|
|
* Fast sequential search, use index for data selection which
|
2002-09-20 05:54:57 +02:00
|
|
|
* go to seq. cycle (it is very fast for unwanted strings)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* (can't be used binary search in format parsing)
|
|
|
|
* ----------
|
|
|
|
*/
|
2005-03-26 01:41:31 +01:00
|
|
|
static const KeyWord *
|
|
|
|
index_seq_search(char *str, const KeyWord *kw, const int *index)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
{
|
2000-04-12 19:17:23 +02:00
|
|
|
int poz;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
if (!KeyWord_INDEX_FILTER(*str))
|
2004-01-07 19:56:30 +01:00
|
|
|
return NULL;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
if ((poz = *(index + (*str - ' '))) > -1)
|
|
|
|
{
|
2005-03-26 01:41:31 +01:00
|
|
|
const KeyWord *k = kw + poz;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (!strncmp(str, k->name, k->len))
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
return k;
|
|
|
|
k++;
|
|
|
|
if (!k->name)
|
2004-01-07 19:56:30 +01:00
|
|
|
return NULL;
|
2000-04-12 19:17:23 +02:00
|
|
|
} while (*str == *k->name);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2004-01-07 19:56:30 +01:00
|
|
|
return NULL;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static KeySuffix *
|
|
|
|
suff_search(char *str, KeySuffix *suf, int type)
|
|
|
|
{
|
2000-04-12 19:17:23 +02:00
|
|
|
KeySuffix *s;
|
|
|
|
|
|
|
|
for (s = suf; s->name != NULL; s++)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
if (s->type != type)
|
|
|
|
continue;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
if (!strncmp(str, s->name, s->len))
|
|
|
|
return s;
|
|
|
|
}
|
2004-01-07 19:56:30 +01:00
|
|
|
return NULL;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* Prepare NUMDesc (number description struct) via FormatNode struct
|
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
static void
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
NUMDesc_prepare(NUMDesc *num, FormatNode *n)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (n->type != NODE_TYPE_ACTION)
|
|
|
|
return;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
switch (n->key->id)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
case NUM_9:
|
2000-02-08 16:57:01 +01:00
|
|
|
if (IS_BRACKET(num))
|
2000-12-15 20:15:09 +01:00
|
|
|
{
|
|
|
|
NUM_cache_remove(last_NUMCacheEntry);
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
|
|
|
errmsg("\"9\" must be ahead of \"PR\"")));
|
2000-12-15 20:15:09 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
if (IS_MULTI(num))
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
++num->multi;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (IS_DECIMAL(num))
|
2000-02-08 16:57:01 +01:00
|
|
|
++num->post;
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
++num->pre;
|
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
case NUM_0:
|
2000-02-08 16:57:01 +01:00
|
|
|
if (IS_BRACKET(num))
|
2000-12-15 20:15:09 +01:00
|
|
|
{
|
|
|
|
NUM_cache_remove(last_NUMCacheEntry);
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
|
|
|
errmsg("\"0\" must be ahead of \"PR\"")));
|
2000-12-15 20:15:09 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
if (!IS_ZERO(num) && !IS_DECIMAL(num))
|
|
|
|
{
|
|
|
|
num->flag |= NUM_F_ZERO;
|
2000-02-08 16:57:01 +01:00
|
|
|
num->zero_start = num->pre + 1;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
if (!IS_DECIMAL(num))
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
++num->pre;
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
2000-02-08 16:57:01 +01:00
|
|
|
++num->post;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-02-08 16:57:01 +01:00
|
|
|
num->zero_end = num->pre + num->post;
|
2000-04-12 19:17:23 +02:00
|
|
|
break;
|
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
case NUM_B:
|
2000-04-12 19:17:23 +02:00
|
|
|
if (num->pre == 0 && num->post == 0 && (!IS_ZERO(num)))
|
|
|
|
num->flag |= NUM_F_BLANK;
|
|
|
|
break;
|
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
case NUM_D:
|
|
|
|
num->flag |= NUM_F_LDECIMAL;
|
|
|
|
num->need_locale = TRUE;
|
|
|
|
case NUM_DEC:
|
|
|
|
if (IS_DECIMAL(num))
|
2000-12-15 20:15:09 +01:00
|
|
|
{
|
|
|
|
NUM_cache_remove(last_NUMCacheEntry);
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
|
|
|
errmsg("multiple decimal points")));
|
2000-12-15 20:15:09 +01:00
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
if (IS_MULTI(num))
|
2000-12-15 20:15:09 +01:00
|
|
|
{
|
|
|
|
NUM_cache_remove(last_NUMCacheEntry);
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
2005-10-15 04:49:52 +02:00
|
|
|
errmsg("cannot use \"V\" and decimal point together")));
|
2000-12-15 20:15:09 +01:00
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
num->flag |= NUM_F_DECIMAL;
|
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
case NUM_FM:
|
|
|
|
num->flag |= NUM_F_FILLMODE;
|
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
case NUM_S:
|
2000-02-08 16:57:01 +01:00
|
|
|
if (IS_LSIGN(num))
|
2000-12-15 20:15:09 +01:00
|
|
|
{
|
|
|
|
NUM_cache_remove(last_NUMCacheEntry);
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
|
|
|
errmsg("not unique \"S\"")));
|
2000-12-15 20:15:09 +01:00
|
|
|
}
|
2000-02-08 16:57:01 +01:00
|
|
|
if (IS_PLUS(num) || IS_MINUS(num) || IS_BRACKET(num))
|
2000-12-15 20:15:09 +01:00
|
|
|
{
|
|
|
|
NUM_cache_remove(last_NUMCacheEntry);
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
|
|
|
errmsg("cannot use \"S\" and \"PL\"/\"MI\"/\"SG\"/\"PR\" together")));
|
2000-12-15 20:15:09 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
if (!IS_DECIMAL(num))
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
num->lsign = NUM_LSIGN_PRE;
|
|
|
|
num->pre_lsign_num = num->pre;
|
2000-02-08 16:57:01 +01:00
|
|
|
num->need_locale = TRUE;
|
|
|
|
num->flag |= NUM_F_LSIGN;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (num->lsign == NUM_LSIGN_NONE)
|
|
|
|
{
|
|
|
|
num->lsign = NUM_LSIGN_POST;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
num->need_locale = TRUE;
|
2000-02-08 16:57:01 +01:00
|
|
|
num->flag |= NUM_F_LSIGN;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
case NUM_MI:
|
2000-02-08 16:57:01 +01:00
|
|
|
if (IS_LSIGN(num))
|
2000-12-15 20:15:09 +01:00
|
|
|
{
|
|
|
|
NUM_cache_remove(last_NUMCacheEntry);
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
|
|
|
errmsg("cannot use \"S\" and \"MI\" together")));
|
2000-12-15 20:15:09 +01:00
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
num->flag |= NUM_F_MINUS;
|
2003-03-27 17:35:31 +01:00
|
|
|
if (IS_DECIMAL(num))
|
|
|
|
num->flag |= NUM_F_MINUS_POST;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
case NUM_PL:
|
2000-02-08 16:57:01 +01:00
|
|
|
if (IS_LSIGN(num))
|
2000-12-15 20:15:09 +01:00
|
|
|
{
|
|
|
|
NUM_cache_remove(last_NUMCacheEntry);
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
|
|
|
errmsg("cannot use \"S\" and \"PL\" together")));
|
2000-12-15 20:15:09 +01:00
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
num->flag |= NUM_F_PLUS;
|
2003-03-27 17:35:31 +01:00
|
|
|
if (IS_DECIMAL(num))
|
|
|
|
num->flag |= NUM_F_PLUS_POST;
|
2000-04-12 19:17:23 +02:00
|
|
|
break;
|
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
case NUM_SG:
|
2000-02-08 16:57:01 +01:00
|
|
|
if (IS_LSIGN(num))
|
2000-12-15 20:15:09 +01:00
|
|
|
{
|
|
|
|
NUM_cache_remove(last_NUMCacheEntry);
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
|
|
|
errmsg("cannot use \"S\" and \"SG\" together")));
|
2000-12-15 20:15:09 +01:00
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
num->flag |= NUM_F_MINUS;
|
|
|
|
num->flag |= NUM_F_PLUS;
|
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
case NUM_PR:
|
2000-02-08 16:57:01 +01:00
|
|
|
if (IS_LSIGN(num) || IS_PLUS(num) || IS_MINUS(num))
|
2000-12-15 20:15:09 +01:00
|
|
|
{
|
|
|
|
NUM_cache_remove(last_NUMCacheEntry);
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
|
|
|
errmsg("cannot use \"PR\" and \"S\"/\"PL\"/\"MI\"/\"SG\" together")));
|
2000-12-15 20:15:09 +01:00
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
num->flag |= NUM_F_BRACKET;
|
2000-04-12 19:17:23 +02:00
|
|
|
break;
|
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
case NUM_rn:
|
|
|
|
case NUM_RN:
|
|
|
|
num->flag |= NUM_F_ROMAN;
|
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
case NUM_L:
|
|
|
|
case NUM_G:
|
2000-04-12 19:17:23 +02:00
|
|
|
num->need_locale = TRUE;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
case NUM_V:
|
|
|
|
if (IS_DECIMAL(num))
|
2000-12-15 20:15:09 +01:00
|
|
|
{
|
|
|
|
NUM_cache_remove(last_NUMCacheEntry);
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
2005-10-15 04:49:52 +02:00
|
|
|
errmsg("cannot use \"V\" and decimal point together")));
|
2000-12-15 20:15:09 +01:00
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
num->flag |= NUM_F_MULTI;
|
2000-04-12 19:17:23 +02:00
|
|
|
break;
|
|
|
|
|
2000-02-08 16:57:01 +01:00
|
|
|
case NUM_E:
|
2000-12-15 20:15:09 +01:00
|
|
|
NUM_cache_remove(last_NUMCacheEntry);
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
|
|
|
errmsg("\"E\" is not supported")));
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------
|
2000-04-12 19:17:23 +02:00
|
|
|
* Format parser, search small keywords and keyword's suffixes, and make
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* format-node tree.
|
|
|
|
*
|
2000-04-12 19:17:23 +02:00
|
|
|
* for DATE-TIME & NUMBER version
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
static void
|
2005-03-26 01:41:31 +01:00
|
|
|
parse_format(FormatNode *node, char *str, const KeyWord *kw,
|
|
|
|
KeySuffix *suf, const int *index, int ver, NUMDesc *Num)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
KeySuffix *s;
|
|
|
|
FormatNode *n;
|
|
|
|
int node_set = 0,
|
|
|
|
suffix,
|
|
|
|
last = 0;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2003-07-27 06:53:12 +02:00
|
|
|
elog(DEBUG_elog_output, "to_char/number(): run parser");
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
n = node;
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
while (*str)
|
|
|
|
{
|
|
|
|
suffix = 0;
|
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-04-12 19:17:23 +02:00
|
|
|
* Prefix
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (ver == DCH_TYPE && (s = suff_search(str, suf, SUFFTYPE_PREFIX)) != NULL)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
suffix |= s->id;
|
|
|
|
if (s->len)
|
|
|
|
str += s->len;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-04-12 19:17:23 +02:00
|
|
|
* Keyword
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (*str && (n->key = index_seq_search(str, kw, index)) != NULL)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
n->type = NODE_TYPE_ACTION;
|
|
|
|
n->suffix = 0;
|
2000-04-12 19:17:23 +02:00
|
|
|
node_set = 1;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
if (n->key->len)
|
|
|
|
str += n->key->len;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-04-12 19:17:23 +02:00
|
|
|
* NUM version: Prepare global NUMDesc struct
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (ver == NUM_TYPE)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
NUMDesc_prepare(Num, n);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* Postfix
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (ver == DCH_TYPE && *str && (s = suff_search(str, suf, SUFFTYPE_POSTFIX)) != NULL)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
suffix |= s->id;
|
|
|
|
if (s->len)
|
|
|
|
str += s->len;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (*str)
|
|
|
|
{
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-04-12 19:17:23 +02:00
|
|
|
* Special characters '\' and '"'
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (*str == '"' && last != '\\')
|
|
|
|
{
|
|
|
|
int x = 0;
|
|
|
|
|
|
|
|
while (*(++str))
|
|
|
|
{
|
|
|
|
if (*str == '"' && x != '\\')
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
str++;
|
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (*str == '\\' && x != '\\')
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
x = '\\';
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
n->type = NODE_TYPE_CHAR;
|
|
|
|
n->character = *str;
|
2004-01-07 19:56:30 +01:00
|
|
|
n->key = NULL;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
n->suffix = 0;
|
|
|
|
++n;
|
2000-04-12 19:17:23 +02:00
|
|
|
x = *str;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
node_set = 0;
|
|
|
|
suffix = 0;
|
|
|
|
last = 0;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (*str && *str == '\\' && last != '\\' && *(str + 1) == '"')
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
last = *str;
|
|
|
|
str++;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (*str)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
n->type = NODE_TYPE_CHAR;
|
|
|
|
n->character = *str;
|
2004-01-07 19:56:30 +01:00
|
|
|
n->key = NULL;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
node_set = 1;
|
|
|
|
last = 0;
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
/* end */
|
|
|
|
if (node_set)
|
|
|
|
{
|
|
|
|
if (n->type == NODE_TYPE_ACTION)
|
|
|
|
n->suffix = suffix;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
++n;
|
|
|
|
|
|
|
|
n->suffix = 0;
|
|
|
|
node_set = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
n->type = NODE_TYPE_END;
|
|
|
|
n->suffix = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* DEBUG: Dump the FormatNode Tree (debug)
|
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
|
|
|
|
|
|
|
#define DUMP_THth(_suf) (S_TH(_suf) ? "TH" : (S_th(_suf) ? "th" : " "))
|
|
|
|
#define DUMP_FM(_suf) (S_FM(_suf) ? "FM" : " ")
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
static void
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
dump_node(FormatNode *node, int max)
|
|
|
|
{
|
2000-04-12 19:17:23 +02:00
|
|
|
FormatNode *n;
|
|
|
|
int a;
|
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
elog(DEBUG_elog_output, "to_from-char(): DUMP FORMAT");
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
for (a = 0, n = node; a <= max; n++, a++)
|
|
|
|
{
|
|
|
|
if (n->type == NODE_TYPE_ACTION)
|
|
|
|
elog(DEBUG_elog_output, "%d:\t NODE_TYPE_ACTION '%s'\t(%s,%s)",
|
2005-10-15 04:49:52 +02:00
|
|
|
a, n->key->name, DUMP_THth(n->suffix), DUMP_FM(n->suffix));
|
2000-04-12 19:17:23 +02:00
|
|
|
else if (n->type == NODE_TYPE_CHAR)
|
|
|
|
elog(DEBUG_elog_output, "%d:\t NODE_TYPE_CHAR '%c'", a, n->character);
|
|
|
|
else if (n->type == NODE_TYPE_END)
|
|
|
|
{
|
|
|
|
elog(DEBUG_elog_output, "%d:\t NODE_TYPE_END", a);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
return;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
2003-07-27 06:53:12 +02:00
|
|
|
elog(DEBUG_elog_output, "%d:\t unknown NODE!", a);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
}
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* DEBUG */
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
/*****************************************************************************
|
2000-04-12 19:17:23 +02:00
|
|
|
* Private utils
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/* ----------
|
2000-04-12 19:17:23 +02:00
|
|
|
* Return ST/ND/RD/TH for simple (1..9) numbers
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* type --> 0 upper, 1 lower
|
2000-04-12 19:17:23 +02:00
|
|
|
* ----------
|
|
|
|
*/
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
static char *
|
|
|
|
get_th(char *num, int type)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
int len = strlen(num),
|
|
|
|
last,
|
|
|
|
seclast;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
last = *(num + (len - 1));
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
if (!isdigit((unsigned char) last))
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
|
|
|
errmsg("\"%s\" is not a number", num)));
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-07-01 23:27:14 +02:00
|
|
|
/*
|
2001-03-22 05:01:46 +01:00
|
|
|
* All "teens" (<x>1[0-9]) get 'TH/th', while <x>[02-9][123] still get
|
|
|
|
* 'ST/st', 'ND/nd', 'RD/rd', respectively
|
2000-07-01 23:27:14 +02:00
|
|
|
*/
|
2001-03-22 05:01:46 +01:00
|
|
|
if ((len > 1) && ((seclast = num[len - 2]) == '1'))
|
2000-04-12 19:17:23 +02:00
|
|
|
last = 0;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
switch (last)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
case '1':
|
2000-04-12 19:17:23 +02:00
|
|
|
if (type == TH_UPPER)
|
|
|
|
return numTH[0];
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
return numth[0];
|
|
|
|
case '2':
|
2000-04-12 19:17:23 +02:00
|
|
|
if (type == TH_UPPER)
|
|
|
|
return numTH[1];
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
return numth[1];
|
|
|
|
case '3':
|
2000-04-12 19:17:23 +02:00
|
|
|
if (type == TH_UPPER)
|
|
|
|
return numTH[2];
|
|
|
|
return numth[2];
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
default:
|
2000-04-12 19:17:23 +02:00
|
|
|
if (type == TH_UPPER)
|
|
|
|
return numTH[3];
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
return numth[3];
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------
|
2000-04-12 19:17:23 +02:00
|
|
|
* Convert string-number to ordinal string-number
|
|
|
|
* type --> 0 upper, 1 lower
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
str_numth(char *dest, char *num, int type)
|
|
|
|
{
|
2005-01-13 02:40:13 +01:00
|
|
|
if (dest != num)
|
|
|
|
strcpy(dest, num);
|
|
|
|
strcat(dest, get_th(num, type));
|
2000-04-12 19:17:23 +02:00
|
|
|
return dest;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
|
2008-06-23 21:27:19 +02:00
|
|
|
/*
|
|
|
|
* If the system provides the needed functions for wide-character manipulation
|
|
|
|
* (which are all standardized by C99), then we implement upper/lower/initcap
|
|
|
|
* using wide-character functions, if necessary. Otherwise we use the
|
|
|
|
* traditional <ctype.h> functions, which of course will not work as desired
|
|
|
|
* in multibyte character sets. Note that in either case we are effectively
|
|
|
|
* assuming that the database character encoding matches the encoding implied
|
|
|
|
* by LC_CTYPE.
|
|
|
|
*/
|
|
|
|
|
2008-07-12 02:44:38 +02:00
|
|
|
/*
|
2008-06-23 21:27:19 +02:00
|
|
|
* wide-character-aware lower function
|
2008-07-12 02:44:38 +02:00
|
|
|
*
|
2008-06-23 21:27:19 +02:00
|
|
|
* We pass the number of bytes so we can pass varlena and char*
|
2008-07-12 02:44:38 +02:00
|
|
|
* to this function. The result is a palloc'd, null-terminated string.
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*/
|
2008-06-23 21:27:19 +02:00
|
|
|
char *
|
2008-07-12 02:44:38 +02:00
|
|
|
str_tolower(const char *buff, size_t nbytes)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2008-05-19 20:08:16 +02:00
|
|
|
char *result;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2002-09-20 05:54:57 +02:00
|
|
|
if (!buff)
|
|
|
|
return NULL;
|
|
|
|
|
2008-05-19 20:08:16 +02:00
|
|
|
#ifdef USE_WIDE_UPPER_LOWER
|
|
|
|
if (pg_database_encoding_max_length() > 1 && !lc_ctype_is_c())
|
2008-06-23 21:27:19 +02:00
|
|
|
{
|
|
|
|
wchar_t *workspace;
|
|
|
|
int curr_char = 0;
|
|
|
|
|
|
|
|
/* Output workspace cannot have more codes than input bytes */
|
|
|
|
workspace = (wchar_t *) palloc((nbytes + 1) * sizeof(wchar_t));
|
|
|
|
|
2008-06-26 18:06:37 +02:00
|
|
|
char2wchar(workspace, nbytes + 1, buff, nbytes);
|
2008-06-23 21:27:19 +02:00
|
|
|
|
|
|
|
for (curr_char = 0; workspace[curr_char] != 0; curr_char++)
|
|
|
|
workspace[curr_char] = towlower(workspace[curr_char]);
|
|
|
|
|
|
|
|
/* Make result large enough; case change might change number of bytes */
|
|
|
|
result = palloc(curr_char * MB_CUR_MAX + 1);
|
|
|
|
|
|
|
|
wchar2char(result, workspace, curr_char * MB_CUR_MAX + 1);
|
|
|
|
pfree(workspace);
|
|
|
|
}
|
2008-05-19 20:08:16 +02:00
|
|
|
else
|
|
|
|
#endif /* USE_WIDE_UPPER_LOWER */
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2008-05-19 20:08:16 +02:00
|
|
|
char *p;
|
|
|
|
|
2008-06-23 21:27:19 +02:00
|
|
|
result = pnstrdup(buff, nbytes);
|
2008-05-19 20:08:16 +02:00
|
|
|
|
|
|
|
for (p = result; *p; p++)
|
2008-06-23 21:27:19 +02:00
|
|
|
*p = pg_tolower((unsigned char) *p);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2007-02-08 19:19:33 +01:00
|
|
|
|
2008-05-19 20:08:16 +02:00
|
|
|
return result;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
|
2008-07-12 02:44:38 +02:00
|
|
|
/*
|
2008-06-23 21:27:19 +02:00
|
|
|
* wide-character-aware upper function
|
2008-07-12 02:44:38 +02:00
|
|
|
*
|
2008-06-23 21:27:19 +02:00
|
|
|
* We pass the number of bytes so we can pass varlena and char*
|
2008-07-12 02:44:38 +02:00
|
|
|
* to this function. The result is a palloc'd, null-terminated string.
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*/
|
2008-06-23 21:27:19 +02:00
|
|
|
char *
|
2008-07-12 02:44:38 +02:00
|
|
|
str_toupper(const char *buff, size_t nbytes)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2008-05-19 20:08:16 +02:00
|
|
|
char *result;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2002-09-20 05:54:57 +02:00
|
|
|
if (!buff)
|
|
|
|
return NULL;
|
|
|
|
|
2008-05-19 20:08:16 +02:00
|
|
|
#ifdef USE_WIDE_UPPER_LOWER
|
|
|
|
if (pg_database_encoding_max_length() > 1 && !lc_ctype_is_c())
|
2008-06-23 21:27:19 +02:00
|
|
|
{
|
|
|
|
wchar_t *workspace;
|
|
|
|
int curr_char = 0;
|
|
|
|
|
|
|
|
/* Output workspace cannot have more codes than input bytes */
|
|
|
|
workspace = (wchar_t *) palloc((nbytes + 1) * sizeof(wchar_t));
|
|
|
|
|
2008-06-26 18:06:37 +02:00
|
|
|
char2wchar(workspace, nbytes + 1, buff, nbytes);
|
2008-06-23 21:27:19 +02:00
|
|
|
|
|
|
|
for (curr_char = 0; workspace[curr_char] != 0; curr_char++)
|
|
|
|
workspace[curr_char] = towupper(workspace[curr_char]);
|
|
|
|
|
|
|
|
/* Make result large enough; case change might change number of bytes */
|
|
|
|
result = palloc(curr_char * MB_CUR_MAX + 1);
|
|
|
|
|
|
|
|
wchar2char(result, workspace, curr_char * MB_CUR_MAX + 1);
|
|
|
|
pfree(workspace);
|
|
|
|
}
|
2008-05-19 20:08:16 +02:00
|
|
|
else
|
|
|
|
#endif /* USE_WIDE_UPPER_LOWER */
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2008-05-19 20:08:16 +02:00
|
|
|
char *p;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2008-06-23 21:27:19 +02:00
|
|
|
result = pnstrdup(buff, nbytes);
|
2007-02-08 19:19:33 +01:00
|
|
|
|
2008-05-19 20:08:16 +02:00
|
|
|
for (p = result; *p; p++)
|
2008-06-23 21:27:19 +02:00
|
|
|
*p = pg_toupper((unsigned char) *p);
|
2008-05-19 20:08:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2008-06-23 21:27:19 +02:00
|
|
|
|
2008-07-12 02:44:38 +02:00
|
|
|
/*
|
2008-05-19 20:08:16 +02:00
|
|
|
* wide-character-aware initcap function
|
2008-07-12 02:44:38 +02:00
|
|
|
*
|
2008-06-23 21:27:19 +02:00
|
|
|
* We pass the number of bytes so we can pass varlena and char*
|
2008-07-12 02:44:38 +02:00
|
|
|
* to this function. The result is a palloc'd, null-terminated string.
|
2007-02-08 19:19:33 +01:00
|
|
|
*/
|
2008-06-23 21:27:19 +02:00
|
|
|
char *
|
2008-07-12 02:44:38 +02:00
|
|
|
str_initcap(const char *buff, size_t nbytes)
|
2007-02-08 19:19:33 +01:00
|
|
|
{
|
2008-05-19 20:08:16 +02:00
|
|
|
char *result;
|
|
|
|
bool wasalnum = false;
|
|
|
|
|
2007-02-08 19:19:33 +01:00
|
|
|
if (!buff)
|
|
|
|
return NULL;
|
|
|
|
|
2008-05-19 20:08:16 +02:00
|
|
|
#ifdef USE_WIDE_UPPER_LOWER
|
2007-02-08 19:19:33 +01:00
|
|
|
if (pg_database_encoding_max_length() > 1 && !lc_ctype_is_c())
|
|
|
|
{
|
2008-05-19 20:08:16 +02:00
|
|
|
wchar_t *workspace;
|
2008-06-23 21:27:19 +02:00
|
|
|
int curr_char = 0;
|
|
|
|
|
|
|
|
/* Output workspace cannot have more codes than input bytes */
|
|
|
|
workspace = (wchar_t *) palloc((nbytes + 1) * sizeof(wchar_t));
|
2008-05-19 20:08:16 +02:00
|
|
|
|
2008-06-26 18:06:37 +02:00
|
|
|
char2wchar(workspace, nbytes + 1, buff, nbytes);
|
2007-02-08 19:19:33 +01:00
|
|
|
|
2008-06-23 21:27:19 +02:00
|
|
|
for (curr_char = 0; workspace[curr_char] != 0; curr_char++)
|
2007-02-08 19:19:33 +01:00
|
|
|
{
|
2008-05-19 20:08:16 +02:00
|
|
|
if (wasalnum)
|
2008-06-23 21:27:19 +02:00
|
|
|
workspace[curr_char] = towlower(workspace[curr_char]);
|
2008-05-19 20:08:16 +02:00
|
|
|
else
|
2008-06-23 21:27:19 +02:00
|
|
|
workspace[curr_char] = towupper(workspace[curr_char]);
|
|
|
|
wasalnum = iswalnum(workspace[curr_char]);
|
2007-02-08 19:19:33 +01:00
|
|
|
}
|
|
|
|
|
2008-06-23 21:27:19 +02:00
|
|
|
/* Make result large enough; case change might change number of bytes */
|
|
|
|
result = palloc(curr_char * MB_CUR_MAX + 1);
|
2007-02-08 19:19:33 +01:00
|
|
|
|
2008-06-23 21:27:19 +02:00
|
|
|
wchar2char(result, workspace, curr_char * MB_CUR_MAX + 1);
|
2008-05-19 20:08:16 +02:00
|
|
|
pfree(workspace);
|
|
|
|
}
|
2007-02-08 19:19:33 +01:00
|
|
|
else
|
2008-05-19 20:08:16 +02:00
|
|
|
#endif /* USE_WIDE_UPPER_LOWER */
|
2007-02-08 19:19:33 +01:00
|
|
|
{
|
2008-05-19 20:08:16 +02:00
|
|
|
char *p;
|
2007-02-08 19:19:33 +01:00
|
|
|
|
2008-06-23 21:27:19 +02:00
|
|
|
result = pnstrdup(buff, nbytes);
|
2008-05-19 20:08:16 +02:00
|
|
|
|
|
|
|
for (p = result; *p; p++)
|
2007-02-08 19:19:33 +01:00
|
|
|
{
|
2008-05-19 20:08:16 +02:00
|
|
|
if (wasalnum)
|
|
|
|
*p = pg_tolower((unsigned char) *p);
|
|
|
|
else
|
|
|
|
*p = pg_toupper((unsigned char) *p);
|
|
|
|
wasalnum = isalnum((unsigned char) *p);
|
2007-02-08 19:19:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-19 20:08:16 +02:00
|
|
|
return result;
|
2007-02-08 19:19:33 +01:00
|
|
|
}
|
|
|
|
|
2008-07-12 02:44:38 +02:00
|
|
|
/* convenience routines for when the input is null-terminated */
|
|
|
|
|
|
|
|
static char *
|
|
|
|
str_tolower_z(const char *buff)
|
|
|
|
{
|
|
|
|
return str_tolower(buff, strlen(buff));
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
str_toupper_z(const char *buff)
|
|
|
|
{
|
|
|
|
return str_toupper(buff, strlen(buff));
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
str_initcap_z(const char *buff)
|
|
|
|
{
|
|
|
|
return str_initcap(buff, strlen(buff));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/* ----------
|
|
|
|
* Sequential search with to upper/lower conversion
|
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
static int
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
seq_search(char *name, char **array, int type, int max, int *len)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
char *p,
|
|
|
|
*n,
|
|
|
|
**a;
|
|
|
|
int last,
|
|
|
|
i;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*len = 0;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (!*name)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
return -1;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
/* set first char */
|
2001-12-10 16:34:05 +01:00
|
|
|
if (type == ONE_UPPER || type == ALL_UPPER)
|
2004-05-07 02:24:59 +02:00
|
|
|
*name = pg_toupper((unsigned char) *name);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
else if (type == ALL_LOWER)
|
2004-05-07 02:24:59 +02:00
|
|
|
*name = pg_tolower((unsigned char) *name);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
for (last = 0, a = array; *a != NULL; a++)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/* comperate first chars */
|
|
|
|
if (*name != **a)
|
|
|
|
continue;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
for (i = 1, p = *a + 1, n = name + 1;; n++, p++, i++)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/* search fragment (max) only */
|
2000-04-12 19:17:23 +02:00
|
|
|
if (max && i == max)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*len = i;
|
|
|
|
return a - array;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/* full size */
|
2000-04-12 19:17:23 +02:00
|
|
|
if (*p == '\0')
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*len = i;
|
|
|
|
return a - array;
|
|
|
|
}
|
|
|
|
/* Not found in array 'a' */
|
2000-04-12 19:17:23 +02:00
|
|
|
if (*n == '\0')
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* Convert (but convert new chars only)
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (i > last)
|
|
|
|
{
|
|
|
|
if (type == ONE_UPPER || type == ALL_LOWER)
|
2004-05-07 02:24:59 +02:00
|
|
|
*n = pg_tolower((unsigned char) *n);
|
2000-04-12 19:17:23 +02:00
|
|
|
else if (type == ALL_UPPER)
|
2004-05-07 02:24:59 +02:00
|
|
|
*n = pg_toupper((unsigned char) *n);
|
2000-04-12 19:17:23 +02:00
|
|
|
last = i;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
|
|
|
|
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* elog(DEBUG_elog_output, "N: %c, P: %c, A: %s (%s)", *n, *p, *a,
|
|
|
|
* name);
|
2000-04-12 19:17:23 +02:00
|
|
|
*/
|
|
|
|
#endif
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
if (*n != *p)
|
2000-04-12 19:17:23 +02:00
|
|
|
break;
|
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
return -1;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
|
|
|
/* -----------
|
2000-04-12 19:17:23 +02:00
|
|
|
* DEBUG: Call for debug and for index checking; (Show ASCII char
|
|
|
|
* and defined keyword for each used position
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
2000-04-12 19:17:23 +02:00
|
|
|
*/
|
|
|
|
static void
|
2005-03-26 01:41:31 +01:00
|
|
|
dump_index(const KeyWord *k, const int *index)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
int i,
|
|
|
|
count = 0,
|
|
|
|
free_i = 0;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
elog(DEBUG_elog_output, "TO-FROM_CHAR: Dump KeyWord Index:");
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
for (i = 0; i < KeyWord_INDEX_SIZE; i++)
|
|
|
|
{
|
|
|
|
if (index[i] != -1)
|
|
|
|
{
|
|
|
|
elog(DEBUG_elog_output, "\t%c: %s, ", i + 32, k[index[i]].name);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
count++;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
free_i++;
|
|
|
|
elog(DEBUG_elog_output, "\t(%d) %c %d", i, i + 32, index[i]);
|
|
|
|
}
|
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
elog(DEBUG_elog_output, "\n\t\tUsed positions: %d,\n\t\tFree positions: %d",
|
2000-04-12 19:17:23 +02:00
|
|
|
count, free_i);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* DEBUG */
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* Skip TM / th in FROM_CHAR
|
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
#define SKIP_THth(_suf) (S_THth(_suf) ? 2 : 0)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2000-11-25 06:00:33 +01:00
|
|
|
/* ----------
|
|
|
|
* Return TRUE if next format picture is not digit value
|
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
is_next_separator(FormatNode *n)
|
|
|
|
{
|
|
|
|
if (n->type == NODE_TYPE_END)
|
|
|
|
return FALSE;
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2000-11-25 06:00:33 +01:00
|
|
|
if (n->type == NODE_TYPE_ACTION && S_THth(n->suffix))
|
|
|
|
return TRUE;
|
2001-03-22 05:01:46 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Next node
|
2000-11-25 06:00:33 +01:00
|
|
|
*/
|
2001-03-22 05:01:46 +01:00
|
|
|
n++;
|
|
|
|
|
2000-11-25 06:00:33 +01:00
|
|
|
if (n->type == NODE_TYPE_END)
|
|
|
|
return FALSE;
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2000-11-25 06:00:33 +01:00
|
|
|
if (n->type == NODE_TYPE_ACTION)
|
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
if (n->key->is_digit)
|
2000-11-25 06:00:33 +01:00
|
|
|
return FALSE;
|
2001-03-22 05:01:46 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2000-12-03 21:45:40 +01:00
|
|
|
else if (isdigit((unsigned char) n->character))
|
2000-11-25 06:00:33 +01:00
|
|
|
return FALSE;
|
2001-03-22 05:01:46 +01:00
|
|
|
|
|
|
|
return TRUE; /* some non-digit input (separator) */
|
2000-11-25 06:00:33 +01:00
|
|
|
}
|
|
|
|
|
2006-04-19 20:49:09 +02:00
|
|
|
static int
|
|
|
|
strspace_len(char *str)
|
|
|
|
{
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
while (*str && isspace((unsigned char) *str))
|
|
|
|
{
|
|
|
|
str++;
|
|
|
|
len++;
|
|
|
|
}
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
static int
|
|
|
|
strdigits_len(char *str)
|
|
|
|
{
|
2001-10-25 07:50:21 +02:00
|
|
|
char *p = str;
|
2006-04-19 20:49:09 +02:00
|
|
|
int len;
|
2001-10-25 07:50:21 +02:00
|
|
|
|
2006-04-19 20:49:09 +02:00
|
|
|
len = strspace_len(str);
|
|
|
|
p += len;
|
2006-10-04 02:30:14 +02:00
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
while (*p && isdigit((unsigned char) *p) && len <= DCH_MAX_ITEM_SIZ)
|
2001-09-06 05:22:42 +02:00
|
|
|
{
|
|
|
|
len++;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2003-07-27 06:53:12 +02:00
|
|
|
#define AMPM_ERROR ereport(ERROR, \
|
|
|
|
(errcode(ERRCODE_INVALID_DATETIME_FORMAT), \
|
|
|
|
errmsg("invalid AM/PM string")));
|
2000-07-03 18:01:33 +02:00
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
#define CHECK_SEQ_SEARCH(_l, _s) \
|
|
|
|
do { \
|
|
|
|
if ((_l) <= 0) { \
|
|
|
|
ereport(ERROR, \
|
|
|
|
(errcode(ERRCODE_INVALID_DATETIME_FORMAT), \
|
|
|
|
errmsg("invalid value for %s", (_s)))); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/* ----------
|
2008-03-22 23:32:19 +01:00
|
|
|
* Process a TmToChar struct as denoted by a list of FormatNodes.
|
|
|
|
* The formatted data is written to the string pointed to by 'out'.
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
|
|
|
*/
|
2008-03-22 23:32:19 +01:00
|
|
|
static void
|
|
|
|
DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
FormatNode *n;
|
|
|
|
char *s;
|
|
|
|
struct pg_tm *tm = &in->tm;
|
2008-07-12 02:44:38 +02:00
|
|
|
char buff[DCH_CACHE_SIZE];
|
2008-03-22 23:32:19 +01:00
|
|
|
int i;
|
2001-09-06 05:22:42 +02:00
|
|
|
|
2008-05-19 20:08:16 +02:00
|
|
|
/* cache localized days and months */
|
|
|
|
cache_locale_time();
|
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
s = out;
|
|
|
|
for (n = node; n->type != NODE_TYPE_END; n++)
|
2001-09-06 05:22:42 +02:00
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
if (n->type != NODE_TYPE_ACTION)
|
|
|
|
{
|
|
|
|
*s = n->character;
|
|
|
|
s++;
|
|
|
|
continue;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
switch (n->key->id)
|
|
|
|
{
|
|
|
|
case DCH_A_M:
|
|
|
|
case DCH_P_M:
|
|
|
|
strcpy(s, (tm->tm_hour % HOURS_PER_DAY >= HOURS_PER_DAY / 2)
|
2005-12-03 17:45:06 +01:00
|
|
|
? P_M_STR : A_M_STR);
|
2008-03-22 23:32:19 +01:00
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_AM:
|
|
|
|
case DCH_PM:
|
|
|
|
strcpy(s, (tm->tm_hour % HOURS_PER_DAY >= HOURS_PER_DAY / 2)
|
2005-12-03 17:45:06 +01:00
|
|
|
? PM_STR : AM_STR);
|
2008-03-22 23:32:19 +01:00
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_a_m:
|
|
|
|
case DCH_p_m:
|
|
|
|
strcpy(s, (tm->tm_hour % HOURS_PER_DAY >= HOURS_PER_DAY / 2)
|
2005-12-03 17:45:06 +01:00
|
|
|
? p_m_STR : a_m_STR);
|
2008-03-22 23:32:19 +01:00
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_am:
|
|
|
|
case DCH_pm:
|
|
|
|
strcpy(s, (tm->tm_hour % HOURS_PER_DAY >= HOURS_PER_DAY / 2)
|
2005-12-03 17:45:06 +01:00
|
|
|
? pm_STR : am_STR);
|
2008-03-22 23:32:19 +01:00
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_HH:
|
|
|
|
case DCH_HH12:
|
|
|
|
sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 2,
|
2005-12-03 17:45:06 +01:00
|
|
|
tm->tm_hour % (HOURS_PER_DAY / 2) == 0 ? 12 :
|
2006-10-04 02:30:14 +02:00
|
|
|
tm->tm_hour % (HOURS_PER_DAY / 2));
|
2008-03-22 23:32:19 +01:00
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, 0);
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_HH24:
|
|
|
|
sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 2, tm->tm_hour);
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_MI:
|
|
|
|
sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 2, tm->tm_min);
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_SS:
|
|
|
|
sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 2, tm->tm_sec);
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_MS: /* millisecond */
|
|
|
|
#ifdef HAVE_INT64_TIMESTAMP
|
|
|
|
sprintf(s, "%03d", (int) (in->fsec / INT64CONST(1000)));
|
|
|
|
#else
|
|
|
|
/* No rint() because we can't overflow and we might print US */
|
|
|
|
sprintf(s, "%03d", (int) (in->fsec * 1000));
|
|
|
|
#endif
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_US: /* microsecond */
|
|
|
|
#ifdef HAVE_INT64_TIMESTAMP
|
|
|
|
sprintf(s, "%06d", (int) in->fsec);
|
|
|
|
#else
|
|
|
|
/* don't use rint() because we can't overflow 1000 */
|
|
|
|
sprintf(s, "%06d", (int) (in->fsec * 1000000));
|
|
|
|
#endif
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_SSSS:
|
|
|
|
sprintf(s, "%d", tm->tm_hour * SECS_PER_HOUR +
|
|
|
|
tm->tm_min * SECS_PER_MINUTE +
|
|
|
|
tm->tm_sec);
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_tz:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
if (tmtcTzn(in))
|
|
|
|
{
|
2008-07-12 02:44:38 +02:00
|
|
|
char *p = str_tolower_z(tmtcTzn(in));
|
2008-03-22 23:32:19 +01:00
|
|
|
|
2008-07-12 02:44:38 +02:00
|
|
|
strcpy(s, p);
|
2008-03-22 23:32:19 +01:00
|
|
|
pfree(p);
|
|
|
|
s += strlen(s);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DCH_TZ:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
if (tmtcTzn(in))
|
|
|
|
{
|
|
|
|
strcpy(s, tmtcTzn(in));
|
|
|
|
s += strlen(s);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DCH_A_D:
|
|
|
|
case DCH_B_C:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
strcpy(s, (tm->tm_year <= 0 ? B_C_STR : A_D_STR));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_AD:
|
|
|
|
case DCH_BC:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
strcpy(s, (tm->tm_year <= 0 ? BC_STR : AD_STR));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_a_d:
|
|
|
|
case DCH_b_c:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
strcpy(s, (tm->tm_year <= 0 ? b_c_STR : a_d_STR));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_ad:
|
|
|
|
case DCH_bc:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
strcpy(s, (tm->tm_year <= 0 ? bc_STR : ad_STR));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_MONTH:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
if (!tm->tm_mon)
|
|
|
|
break;
|
|
|
|
if (S_TM(n->suffix))
|
2008-07-12 02:44:38 +02:00
|
|
|
strcpy(s, str_toupper_z(localized_full_months[tm->tm_mon - 1]));
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
2008-06-23 21:27:19 +02:00
|
|
|
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9,
|
2008-07-12 02:44:38 +02:00
|
|
|
str_toupper_z(months_full[tm->tm_mon - 1]));
|
2008-03-22 23:32:19 +01:00
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_Month:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
if (!tm->tm_mon)
|
|
|
|
break;
|
|
|
|
if (S_TM(n->suffix))
|
2008-07-12 02:44:38 +02:00
|
|
|
strcpy(s, str_initcap_z(localized_full_months[tm->tm_mon - 1]));
|
2008-03-22 23:32:19 +01:00
|
|
|
else
|
|
|
|
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, months_full[tm->tm_mon - 1]);
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_month:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
if (!tm->tm_mon)
|
|
|
|
break;
|
|
|
|
if (S_TM(n->suffix))
|
2008-07-12 02:44:38 +02:00
|
|
|
strcpy(s, str_tolower_z(localized_full_months[tm->tm_mon - 1]));
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, months_full[tm->tm_mon - 1]);
|
|
|
|
*s = pg_tolower((unsigned char) *s);
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
2008-03-22 23:32:19 +01:00
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_MON:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
if (!tm->tm_mon)
|
|
|
|
break;
|
|
|
|
if (S_TM(n->suffix))
|
2008-07-12 02:44:38 +02:00
|
|
|
strcpy(s, str_toupper_z(localized_abbrev_months[tm->tm_mon - 1]));
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
2008-07-12 02:44:38 +02:00
|
|
|
strcpy(s, str_toupper_z(months[tm->tm_mon - 1]));
|
2008-03-22 23:32:19 +01:00
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_Mon:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
if (!tm->tm_mon)
|
|
|
|
break;
|
|
|
|
if (S_TM(n->suffix))
|
2008-07-12 02:44:38 +02:00
|
|
|
strcpy(s, str_initcap_z(localized_abbrev_months[tm->tm_mon - 1]));
|
2008-03-22 23:32:19 +01:00
|
|
|
else
|
|
|
|
strcpy(s, months[tm->tm_mon - 1]);
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_mon:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
if (!tm->tm_mon)
|
|
|
|
break;
|
|
|
|
if (S_TM(n->suffix))
|
2008-07-12 02:44:38 +02:00
|
|
|
strcpy(s, str_tolower_z(localized_abbrev_months[tm->tm_mon - 1]));
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
strcpy(s, months[tm->tm_mon - 1]);
|
|
|
|
*s = pg_tolower((unsigned char) *s);
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
2008-03-22 23:32:19 +01:00
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_MM:
|
|
|
|
sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 2, tm->tm_mon);
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_DAY:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
if (S_TM(n->suffix))
|
2008-07-12 02:44:38 +02:00
|
|
|
strcpy(s, str_toupper_z(localized_full_days[tm->tm_wday]));
|
2001-10-25 07:50:21 +02:00
|
|
|
else
|
2008-06-23 21:27:19 +02:00
|
|
|
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9,
|
2008-07-12 02:44:38 +02:00
|
|
|
str_toupper_z(days[tm->tm_wday]));
|
2008-03-22 23:32:19 +01:00
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_Day:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
if (S_TM(n->suffix))
|
2008-07-12 02:44:38 +02:00
|
|
|
strcpy(s, str_initcap_z(localized_full_days[tm->tm_wday]));
|
2008-03-22 23:32:19 +01:00
|
|
|
else
|
|
|
|
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, days[tm->tm_wday]);
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_day:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
if (S_TM(n->suffix))
|
2008-07-12 02:44:38 +02:00
|
|
|
strcpy(s, str_tolower_z(localized_full_days[tm->tm_wday]));
|
2001-10-25 07:50:21 +02:00
|
|
|
else
|
2001-09-06 05:22:42 +02:00
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, days[tm->tm_wday]);
|
|
|
|
*s = pg_tolower((unsigned char) *s);
|
2001-10-25 07:50:21 +02:00
|
|
|
}
|
2008-03-22 23:32:19 +01:00
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_DY:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
if (S_TM(n->suffix))
|
2008-07-12 02:44:38 +02:00
|
|
|
strcpy(s, str_toupper_z(localized_abbrev_days[tm->tm_wday]));
|
2000-11-25 06:00:33 +01:00
|
|
|
else
|
2008-07-12 02:44:38 +02:00
|
|
|
strcpy(s, str_toupper_z(days_short[tm->tm_wday]));
|
2008-03-22 23:32:19 +01:00
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_Dy:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
if (S_TM(n->suffix))
|
2008-07-12 02:44:38 +02:00
|
|
|
strcpy(s, str_initcap_z(localized_abbrev_days[tm->tm_wday]));
|
2001-03-22 05:01:46 +01:00
|
|
|
else
|
2008-03-22 23:32:19 +01:00
|
|
|
strcpy(s, days_short[tm->tm_wday]);
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_dy:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
if (S_TM(n->suffix))
|
2008-07-12 02:44:38 +02:00
|
|
|
strcpy(s, str_tolower_z(localized_abbrev_days[tm->tm_wday]));
|
2008-03-22 23:32:19 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy(s, days_short[tm->tm_wday]);
|
|
|
|
*s = pg_tolower((unsigned char) *s);
|
|
|
|
}
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_DDD:
|
|
|
|
case DCH_IDDD:
|
|
|
|
sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 3,
|
|
|
|
(n->key->id == DCH_DDD) ?
|
|
|
|
tm->tm_yday :
|
|
|
|
date2isoyearday(tm->tm_year, tm->tm_mon, tm->tm_mday));
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_DD:
|
|
|
|
sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 2, tm->tm_mday);
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_D:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
sprintf(s, "%d", tm->tm_wday + 1);
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_ID:
|
|
|
|
INVALID_FOR_INTERVAL;
|
|
|
|
sprintf(s, "%d", (tm->tm_wday == 0) ? 7 : tm->tm_wday);
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_WW:
|
|
|
|
sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 2,
|
|
|
|
(tm->tm_yday - 1) / 7 + 1);
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_IW:
|
|
|
|
sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 2,
|
|
|
|
date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday));
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_Q:
|
|
|
|
if (!tm->tm_mon)
|
|
|
|
break;
|
|
|
|
sprintf(s, "%d", (tm->tm_mon - 1) / 3 + 1);
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_CC:
|
|
|
|
if (is_interval) /* straight calculation */
|
|
|
|
i = tm->tm_year / 100;
|
|
|
|
else /* century 21 starts in 2001 */
|
|
|
|
i = (tm->tm_year - 1) / 100 + 1;
|
|
|
|
if (i <= 99 && i >= -99)
|
|
|
|
sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 2, i);
|
|
|
|
else
|
|
|
|
sprintf(s, "%d", i);
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_Y_YYY:
|
|
|
|
i = ADJUST_YEAR(tm->tm_year, is_interval) / 1000;
|
|
|
|
sprintf(s, "%d,%03d", i,
|
|
|
|
ADJUST_YEAR(tm->tm_year, is_interval) - (i * 1000));
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_YYYY:
|
|
|
|
case DCH_IYYY:
|
|
|
|
if (tm->tm_year <= 9999 && tm->tm_year >= -9998)
|
|
|
|
sprintf(s, "%0*d",
|
|
|
|
S_FM(n->suffix) ? 0 : 4,
|
|
|
|
n->key->id == DCH_YYYY ?
|
|
|
|
ADJUST_YEAR(tm->tm_year, is_interval) :
|
|
|
|
ADJUST_YEAR(date2isoyear(
|
|
|
|
tm->tm_year,
|
|
|
|
tm->tm_mon,
|
|
|
|
tm->tm_mday), is_interval));
|
|
|
|
else
|
|
|
|
sprintf(s, "%d",
|
|
|
|
n->key->id == DCH_YYYY ?
|
|
|
|
ADJUST_YEAR(tm->tm_year, is_interval) :
|
|
|
|
ADJUST_YEAR(date2isoyear(
|
|
|
|
tm->tm_year,
|
|
|
|
tm->tm_mon,
|
|
|
|
tm->tm_mday), is_interval));
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_YYY:
|
|
|
|
case DCH_IYY:
|
|
|
|
snprintf(buff, sizeof(buff), "%03d",
|
|
|
|
n->key->id == DCH_YYY ?
|
|
|
|
ADJUST_YEAR(tm->tm_year, is_interval) :
|
|
|
|
ADJUST_YEAR(date2isoyear(tm->tm_year,
|
|
|
|
tm->tm_mon, tm->tm_mday),
|
|
|
|
is_interval));
|
|
|
|
i = strlen(buff);
|
|
|
|
strcpy(s, buff + (i - 3));
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_YY:
|
|
|
|
case DCH_IY:
|
|
|
|
snprintf(buff, sizeof(buff), "%02d",
|
|
|
|
n->key->id == DCH_YY ?
|
|
|
|
ADJUST_YEAR(tm->tm_year, is_interval) :
|
|
|
|
ADJUST_YEAR(date2isoyear(tm->tm_year,
|
|
|
|
tm->tm_mon, tm->tm_mday),
|
|
|
|
is_interval));
|
|
|
|
i = strlen(buff);
|
|
|
|
strcpy(s, buff + (i - 2));
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_Y:
|
|
|
|
case DCH_I:
|
|
|
|
snprintf(buff, sizeof(buff), "%1d",
|
|
|
|
n->key->id == DCH_Y ?
|
|
|
|
ADJUST_YEAR(tm->tm_year, is_interval) :
|
|
|
|
ADJUST_YEAR(date2isoyear(tm->tm_year,
|
|
|
|
tm->tm_mon, tm->tm_mday),
|
|
|
|
is_interval));
|
|
|
|
i = strlen(buff);
|
|
|
|
strcpy(s, buff + (i - 1));
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_RM:
|
|
|
|
if (!tm->tm_mon)
|
|
|
|
break;
|
|
|
|
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -4,
|
|
|
|
rm_months_upper[12 - tm->tm_mon]);
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_rm:
|
|
|
|
if (!tm->tm_mon)
|
|
|
|
break;
|
|
|
|
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -4,
|
|
|
|
rm_months_lower[12 - tm->tm_mon]);
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_W:
|
|
|
|
sprintf(s, "%d", (tm->tm_mday - 1) / 7 + 1);
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
case DCH_J:
|
|
|
|
sprintf(s, "%d", date2j(tm->tm_year, tm->tm_mon, tm->tm_mday));
|
|
|
|
if (S_THth(n->suffix))
|
|
|
|
str_numth(s, s, S_TH_TYPE(n->suffix));
|
|
|
|
s += strlen(s);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
*s = '\0';
|
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
/* ----------
|
2008-03-22 23:32:19 +01:00
|
|
|
* Process a string as denoted by a list of FormatNodes.
|
|
|
|
* The TmFromChar struct pointed to by 'out' is populated with the results.
|
|
|
|
*
|
|
|
|
* Note: we currently don't have any to_interval() function, so there
|
|
|
|
* is no need here for INVALID_FOR_INTERVAL checks.
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
|
|
|
*/
|
2008-03-22 23:32:19 +01:00
|
|
|
static void
|
|
|
|
DCH_from_char(FormatNode *node, char *in, TmFromChar *out)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
FormatNode *n;
|
|
|
|
char *s;
|
|
|
|
int len,
|
|
|
|
x;
|
|
|
|
int *target;
|
|
|
|
bool fx_mode = false;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
for (n = node, s = in; n->type != NODE_TYPE_END && *s != '\0'; n++)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
if (n->type != NODE_TYPE_ACTION)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
s++;
|
|
|
|
/* Ignore spaces when not in FX (fixed width) mode */
|
|
|
|
if (isspace((unsigned char) n->character) && !fx_mode)
|
2007-02-08 19:19:33 +01:00
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
while (*s != '\0' && isspace((unsigned char) *s))
|
|
|
|
s++;
|
2007-02-08 19:19:33 +01:00
|
|
|
}
|
2008-03-22 23:32:19 +01:00
|
|
|
continue;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
switch (n->key->id)
|
|
|
|
{
|
|
|
|
case DCH_FX:
|
|
|
|
fx_mode = true;
|
|
|
|
break;
|
|
|
|
case DCH_A_M:
|
|
|
|
case DCH_P_M:
|
|
|
|
if (strncmp(s, P_M_STR, n->key->len) == 0)
|
|
|
|
out->pm = TRUE;
|
|
|
|
else if (strncmp(s, A_M_STR, n->key->len) == 0)
|
|
|
|
out->am = TRUE;
|
|
|
|
else
|
|
|
|
AMPM_ERROR;
|
|
|
|
s += strlen(P_M_STR);
|
|
|
|
break;
|
|
|
|
case DCH_AM:
|
|
|
|
case DCH_PM:
|
|
|
|
if (strncmp(s, PM_STR, n->key->len) == 0)
|
|
|
|
out->pm = TRUE;
|
|
|
|
else if (strncmp(s, AM_STR, n->key->len) == 0)
|
|
|
|
out->am = TRUE;
|
|
|
|
else
|
|
|
|
AMPM_ERROR;
|
|
|
|
s += strlen(PM_STR);
|
|
|
|
break;
|
|
|
|
case DCH_a_m:
|
|
|
|
case DCH_p_m:
|
|
|
|
if (strncmp(s, p_m_STR, n->key->len) == 0)
|
|
|
|
out->pm = TRUE;
|
|
|
|
else if (strncmp(s, a_m_STR, n->key->len) == 0)
|
|
|
|
out->am = TRUE;
|
|
|
|
else
|
|
|
|
AMPM_ERROR;
|
|
|
|
s += strlen(p_m_STR);
|
|
|
|
break;
|
|
|
|
case DCH_am:
|
|
|
|
case DCH_pm:
|
|
|
|
if (strncmp(s, pm_STR, n->key->len) == 0)
|
|
|
|
out->pm = TRUE;
|
|
|
|
else if (strncmp(s, am_STR, n->key->len) == 0)
|
|
|
|
out->am = TRUE;
|
|
|
|
else
|
|
|
|
AMPM_ERROR;
|
|
|
|
s += strlen(pm_STR);
|
|
|
|
break;
|
|
|
|
case DCH_HH:
|
|
|
|
case DCH_HH12:
|
|
|
|
if (S_FM(n->suffix) || is_next_separator(n))
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
sscanf(s, "%d", &out->hh);
|
|
|
|
s += strdigits_len(s) + SKIP_THth(n->suffix);
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
sscanf(s, "%02d", &out->hh);
|
|
|
|
s += strspace_len(s) + 2 + SKIP_THth(n->suffix);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DCH_HH24:
|
|
|
|
if (S_FM(n->suffix) || is_next_separator(n))
|
|
|
|
{
|
|
|
|
sscanf(s, "%d", &out->hh);
|
|
|
|
s += strdigits_len(s) + SKIP_THth(n->suffix);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sscanf(s, "%02d", &out->hh);
|
|
|
|
s += strspace_len(s) + 2 + SKIP_THth(n->suffix);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DCH_MI:
|
|
|
|
if (S_FM(n->suffix) || is_next_separator(n))
|
|
|
|
{
|
|
|
|
sscanf(s, "%d", &out->mi);
|
|
|
|
s += strdigits_len(s) + SKIP_THth(n->suffix);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sscanf(s, "%02d", &out->mi);
|
|
|
|
s += strspace_len(s) + 2 + SKIP_THth(n->suffix);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DCH_SS:
|
|
|
|
if (S_FM(n->suffix) || is_next_separator(n))
|
|
|
|
{
|
|
|
|
sscanf(s, "%d", &out->ss);
|
|
|
|
s += strdigits_len(s) + SKIP_THth(n->suffix);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sscanf(s, "%02d", &out->ss);
|
|
|
|
s += strspace_len(s) + 2 + SKIP_THth(n->suffix);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DCH_MS: /* millisecond */
|
|
|
|
if (is_next_separator(n))
|
|
|
|
{
|
|
|
|
sscanf(s, "%d", &out->ms);
|
|
|
|
len = x = strdigits_len(s);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sscanf(s, "%03d", &out->ms);
|
|
|
|
x = strdigits_len(s);
|
|
|
|
len = x = x > 3 ? 3 : x;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
2007-11-15 22:14:46 +01:00
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
/*
|
|
|
|
* 25 is 0.25 and 250 is 0.25 too; 025 is 0.025 and not 0.25
|
|
|
|
*/
|
|
|
|
out->ms *= x == 1 ? 100 :
|
|
|
|
x == 2 ? 10 : 1;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
s += len + SKIP_THth(n->suffix);
|
|
|
|
break;
|
|
|
|
case DCH_US: /* microsecond */
|
|
|
|
if (is_next_separator(n))
|
|
|
|
{
|
|
|
|
sscanf(s, "%d", &out->us);
|
|
|
|
len = x = strdigits_len(s);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sscanf(s, "%06d", &out->us);
|
|
|
|
x = strdigits_len(s);
|
|
|
|
len = x = x > 6 ? 6 : x;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
out->us *= x == 1 ? 100000 :
|
|
|
|
x == 2 ? 10000 :
|
|
|
|
x == 3 ? 1000 :
|
|
|
|
x == 4 ? 100 :
|
|
|
|
x == 5 ? 10 : 1;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
s += len + SKIP_THth(n->suffix);
|
|
|
|
break;
|
|
|
|
case DCH_SSSS:
|
|
|
|
if (S_FM(n->suffix) || is_next_separator(n))
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
sscanf(s, "%d", &out->ssss);
|
|
|
|
s += strdigits_len(s) + SKIP_THth(n->suffix);
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
sscanf(s, "%05d", &out->ssss);
|
|
|
|
s += strspace_len(s) + 5 + SKIP_THth(n->suffix);
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
2008-03-22 23:32:19 +01:00
|
|
|
break;
|
|
|
|
case DCH_tz:
|
|
|
|
case DCH_TZ:
|
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
|
|
|
errmsg("\"TZ\"/\"tz\" format patterns are not supported in to_date")));
|
|
|
|
case DCH_A_D:
|
|
|
|
case DCH_B_C:
|
|
|
|
if (strncmp(s, B_C_STR, n->key->len) == 0)
|
|
|
|
out->bc = TRUE;
|
|
|
|
s += n->key->len;
|
|
|
|
break;
|
|
|
|
case DCH_AD:
|
|
|
|
case DCH_BC:
|
|
|
|
if (strncmp(s, BC_STR, n->key->len) == 0)
|
|
|
|
out->bc = TRUE;
|
|
|
|
s += n->key->len;
|
|
|
|
break;
|
|
|
|
case DCH_a_d:
|
|
|
|
case DCH_b_c:
|
|
|
|
if (strncmp(s, b_c_STR, n->key->len) == 0)
|
|
|
|
out->bc = TRUE;
|
|
|
|
s += n->key->len;
|
|
|
|
break;
|
|
|
|
case DCH_ad:
|
|
|
|
case DCH_bc:
|
|
|
|
if (strncmp(s, bc_STR, n->key->len) == 0)
|
|
|
|
out->bc = TRUE;
|
|
|
|
s += n->key->len;
|
|
|
|
break;
|
|
|
|
case DCH_MONTH:
|
|
|
|
case DCH_Month:
|
|
|
|
case DCH_month:
|
|
|
|
out->mm = seq_search(s, months_full, ONE_UPPER, FULL_SIZ, &len) + 1;
|
|
|
|
CHECK_SEQ_SEARCH(len, "MONTH/Month/month");
|
|
|
|
s += len;
|
|
|
|
break;
|
|
|
|
case DCH_MON:
|
|
|
|
case DCH_Mon:
|
|
|
|
case DCH_mon:
|
|
|
|
out->mm = seq_search(s, months, ONE_UPPER, MAX_MON_LEN, &len) + 1;
|
|
|
|
CHECK_SEQ_SEARCH(len, "MON/Mon/mon");
|
|
|
|
s += len;
|
|
|
|
break;
|
|
|
|
case DCH_MM:
|
|
|
|
if (S_FM(n->suffix) || is_next_separator(n))
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
sscanf(s, "%d", &out->mm);
|
|
|
|
s += strdigits_len(s) + SKIP_THth(n->suffix);
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
sscanf(s, "%02d", &out->mm);
|
|
|
|
s += strspace_len(s) + 2 + SKIP_THth(n->suffix);
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
2008-03-22 23:32:19 +01:00
|
|
|
break;
|
|
|
|
case DCH_DAY:
|
|
|
|
case DCH_Day:
|
|
|
|
case DCH_day:
|
|
|
|
out->d = seq_search(s, days, ONE_UPPER, FULL_SIZ, &len);
|
|
|
|
CHECK_SEQ_SEARCH(len, "DAY/Day/day");
|
|
|
|
s += len;
|
|
|
|
break;
|
|
|
|
case DCH_DY:
|
|
|
|
case DCH_Dy:
|
|
|
|
case DCH_dy:
|
|
|
|
out->d = seq_search(s, days, ONE_UPPER, MAX_DY_LEN, &len);
|
|
|
|
CHECK_SEQ_SEARCH(len, "DY/Dy/dy");
|
|
|
|
s += len;
|
|
|
|
break;
|
|
|
|
case DCH_DDD:
|
|
|
|
case DCH_IDDD:
|
|
|
|
if (S_FM(n->suffix) || is_next_separator(n))
|
2000-07-03 18:01:33 +02:00
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
sscanf(s, "%d", &out->ddd);
|
|
|
|
s += strdigits_len(s) + SKIP_THth(n->suffix);
|
2000-07-03 18:01:33 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
sscanf(s, "%03d", &out->ddd);
|
|
|
|
s += strspace_len(s) + 3 + SKIP_THth(n->suffix);
|
2000-07-03 18:01:33 +02:00
|
|
|
}
|
2008-03-22 23:32:19 +01:00
|
|
|
break;
|
|
|
|
case DCH_DD:
|
|
|
|
if (S_FM(n->suffix) || is_next_separator(n))
|
2000-08-29 06:41:48 +02:00
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
sscanf(s, "%d", &out->dd);
|
|
|
|
s += strdigits_len(s) + SKIP_THth(n->suffix);
|
2000-08-29 06:41:48 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
sscanf(s, "%02d", &out->dd);
|
|
|
|
s += strspace_len(s) + 2 + SKIP_THth(n->suffix);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DCH_D:
|
|
|
|
case DCH_ID:
|
|
|
|
sscanf(s, "%1d", &out->d);
|
|
|
|
if (n->key->id == DCH_D)
|
|
|
|
out->d--;
|
|
|
|
s += strspace_len(s) + 1 + SKIP_THth(n->suffix);
|
|
|
|
break;
|
|
|
|
case DCH_WW:
|
|
|
|
if (S_FM(n->suffix) || is_next_separator(n))
|
|
|
|
{
|
|
|
|
sscanf(s, "%d", &out->ww);
|
|
|
|
s += strdigits_len(s) + SKIP_THth(n->suffix);
|
2000-08-29 06:41:48 +02:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
2001-09-06 05:22:42 +02:00
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
sscanf(s, "%02d", &out->ww);
|
|
|
|
s += strspace_len(s) + 2 + SKIP_THth(n->suffix);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DCH_IW:
|
|
|
|
if (S_FM(n->suffix) || is_next_separator(n))
|
|
|
|
{
|
|
|
|
sscanf(s, "%d", &out->iw);
|
|
|
|
s += strdigits_len(s) + SKIP_THth(n->suffix);
|
2001-09-06 05:22:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
sscanf(s, "%02d", &out->iw);
|
|
|
|
s += strspace_len(s) + 2 + SKIP_THth(n->suffix);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DCH_Q:
|
|
|
|
/*
|
|
|
|
* We ignore Q when converting to date because it is not
|
|
|
|
* normative.
|
|
|
|
*/
|
|
|
|
s += strspace_len(s) + 1 + SKIP_THth(n->suffix);
|
|
|
|
break;
|
|
|
|
case DCH_CC:
|
|
|
|
if (S_FM(n->suffix) || is_next_separator(n))
|
|
|
|
{
|
|
|
|
sscanf(s, "%d", &out->cc);
|
|
|
|
s += strdigits_len(s) + SKIP_THth(n->suffix);
|
2001-09-06 05:22:42 +02:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
2008-03-22 23:32:19 +01:00
|
|
|
{
|
|
|
|
sscanf(s, "%02d", &out->cc);
|
|
|
|
s += strspace_len(s) + 2 + SKIP_THth(n->suffix);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DCH_Y_YYY:
|
|
|
|
sscanf(s, "%d,%03d", &x, &out->year);
|
|
|
|
out->year += (x * 1000);
|
|
|
|
out->yysz = 4;
|
|
|
|
s += strdigits_len(s) + 4 + SKIP_THth(n->suffix);
|
|
|
|
break;
|
|
|
|
case DCH_YYYY:
|
|
|
|
case DCH_IYYY:
|
|
|
|
target = (n->key->id == DCH_YYYY) ? &out->year : &out->iyear;
|
2007-02-16 04:39:46 +01:00
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
if (S_FM(n->suffix) || is_next_separator(n))
|
2001-09-06 05:22:42 +02:00
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
sscanf(s, "%d", target);
|
|
|
|
out->yysz = 4;
|
|
|
|
s += strdigits_len(s) + SKIP_THth(n->suffix);
|
2001-09-06 05:22:42 +02:00
|
|
|
}
|
2000-11-25 06:00:33 +01:00
|
|
|
else
|
2001-09-06 05:22:42 +02:00
|
|
|
{
|
2008-03-22 23:32:19 +01:00
|
|
|
sscanf(s, "%04d", target);
|
|
|
|
out->yysz = 4;
|
|
|
|
s += strspace_len(s) + 4 + SKIP_THth(n->suffix);
|
2001-09-06 05:22:42 +02:00
|
|
|
}
|
2008-03-22 23:32:19 +01:00
|
|
|
break;
|
|
|
|
case DCH_YYY:
|
|
|
|
case DCH_IYY:
|
|
|
|
target = (n->key->id == DCH_YYY) ? &out->year : &out->iyear;
|
2007-02-16 04:39:46 +01:00
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
sscanf(s, "%03d", target);
|
2002-03-06 07:10:59 +01:00
|
|
|
|
2002-01-02 23:09:23 +01:00
|
|
|
/*
|
2002-09-04 22:31:48 +02:00
|
|
|
* 3-digit year: '100' ... '999' = 1100 ... 1999 '000' ...
|
|
|
|
* '099' = 2000 ... 2099
|
2002-01-02 23:09:23 +01:00
|
|
|
*/
|
2008-03-22 23:32:19 +01:00
|
|
|
if (*target >= 100)
|
|
|
|
*target += 1000;
|
2002-01-02 23:09:23 +01:00
|
|
|
else
|
2008-03-22 23:32:19 +01:00
|
|
|
*target += 2000;
|
|
|
|
out->yysz = 3;
|
|
|
|
s += strspace_len(s) + 3 + SKIP_THth(n->suffix);
|
|
|
|
break;
|
|
|
|
case DCH_YY:
|
|
|
|
case DCH_IY:
|
|
|
|
target = (n->key->id == DCH_YY) ? &out->year : &out->iyear;
|
2007-02-16 04:39:46 +01:00
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
sscanf(s, "%02d", target);
|
2002-01-02 23:09:23 +01:00
|
|
|
|
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* 2-digit year: '00' ... '69' = 2000 ... 2069 '70' ... '99'
|
|
|
|
* = 1970 ... 1999
|
2002-03-06 07:10:59 +01:00
|
|
|
*/
|
2008-03-22 23:32:19 +01:00
|
|
|
if (*target < 70)
|
|
|
|
*target += 2000;
|
2002-01-02 23:09:23 +01:00
|
|
|
else
|
2008-03-22 23:32:19 +01:00
|
|
|
*target += 1900;
|
|
|
|
out->yysz = 2;
|
|
|
|
s += strspace_len(s) + 2 + SKIP_THth(n->suffix);
|
|
|
|
break;
|
|
|
|
case DCH_Y:
|
|
|
|
case DCH_I:
|
|
|
|
target = (n->key->id == DCH_Y) ? &out->year : &out->iyear;
|
2007-02-16 04:39:46 +01:00
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
sscanf(s, "%1d", target);
|
2002-03-06 07:10:59 +01:00
|
|
|
|
2002-01-02 23:09:23 +01:00
|
|
|
/*
|
|
|
|
* 1-digit year: always +2000
|
|
|
|
*/
|
2008-03-22 23:32:19 +01:00
|
|
|
*target += 2000;
|
|
|
|
out->yysz = 1;
|
|
|
|
s += strspace_len(s) + 1 + SKIP_THth(n->suffix);
|
|
|
|
break;
|
|
|
|
case DCH_RM:
|
|
|
|
out->mm = 12 - seq_search(s, rm_months_upper, ALL_UPPER, FULL_SIZ, &len);
|
2000-04-12 19:17:23 +02:00
|
|
|
CHECK_SEQ_SEARCH(len, "RM");
|
2008-03-22 23:32:19 +01:00
|
|
|
s += len;
|
|
|
|
break;
|
|
|
|
case DCH_rm:
|
|
|
|
out->mm = 12 - seq_search(s, rm_months_lower, ALL_LOWER, FULL_SIZ, &len);
|
2000-04-12 19:17:23 +02:00
|
|
|
CHECK_SEQ_SEARCH(len, "rm");
|
2008-03-22 23:32:19 +01:00
|
|
|
s += len;
|
|
|
|
break;
|
|
|
|
case DCH_W:
|
|
|
|
sscanf(s, "%1d", &out->w);
|
|
|
|
s += strspace_len(s) + 1 + SKIP_THth(n->suffix);
|
|
|
|
break;
|
|
|
|
case DCH_J:
|
|
|
|
sscanf(s, "%d", &out->j);
|
|
|
|
s += strdigits_len(s) + SKIP_THth(n->suffix);
|
|
|
|
break;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2000-03-16 02:35:41 +01:00
|
|
|
static DCHCacheEntry *
|
2000-04-12 19:17:23 +02:00
|
|
|
DCH_cache_getnew(char *str)
|
2000-03-16 02:35:41 +01:00
|
|
|
{
|
2000-04-12 19:17:23 +02:00
|
|
|
DCHCacheEntry *ent = NULL;
|
|
|
|
|
2002-09-20 05:54:57 +02:00
|
|
|
/* counter overload check - paranoia? */
|
2000-04-12 19:17:23 +02:00
|
|
|
if (DCHCounter + DCH_CACHE_FIELDS >= MAX_INT32)
|
|
|
|
{
|
2000-03-16 02:35:41 +01:00
|
|
|
DCHCounter = 0;
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
for (ent = DCHCache; ent <= (DCHCache + DCH_CACHE_FIELDS); ent++)
|
|
|
|
ent->age = (++DCHCounter);
|
2000-03-16 02:35:41 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-03-16 02:35:41 +01:00
|
|
|
* Cache is full - needs remove any older entry
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (n_DCHCache > DCH_CACHE_FIELDS)
|
|
|
|
{
|
|
|
|
DCHCacheEntry *old = DCHCache + 0;
|
2000-03-16 02:35:41 +01:00
|
|
|
|
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2003-07-27 06:53:12 +02:00
|
|
|
elog(DEBUG_elog_output, "cache is full (%d)", n_DCHCache);
|
2000-04-12 19:17:23 +02:00
|
|
|
#endif
|
|
|
|
for (ent = DCHCache; ent <= (DCHCache + DCH_CACHE_FIELDS); ent++)
|
|
|
|
{
|
2000-03-16 02:35:41 +01:00
|
|
|
if (ent->age < old->age)
|
|
|
|
old = ent;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
2000-03-16 02:35:41 +01:00
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
|
|
|
elog(DEBUG_elog_output, "OLD: '%s' AGE: %d", old->str, old->age);
|
2000-04-12 19:17:23 +02:00
|
|
|
#endif
|
2002-09-20 05:54:57 +02:00
|
|
|
StrNCpy(old->str, str, DCH_CACHE_SIZE + 1);
|
2000-03-16 02:35:41 +01:00
|
|
|
/* old->format fill parser */
|
|
|
|
old->age = (++DCHCounter);
|
|
|
|
return old;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2000-03-16 02:35:41 +01:00
|
|
|
elog(DEBUG_elog_output, "NEW (%d)", n_DCHCache);
|
2000-04-12 19:17:23 +02:00
|
|
|
#endif
|
2000-03-16 02:35:41 +01:00
|
|
|
ent = DCHCache + n_DCHCache;
|
2002-09-20 05:54:57 +02:00
|
|
|
StrNCpy(ent->str, str, DCH_CACHE_SIZE + 1);
|
2000-03-16 02:35:41 +01:00
|
|
|
/* ent->format fill parser */
|
|
|
|
ent->age = (++DCHCounter);
|
|
|
|
++n_DCHCache;
|
|
|
|
return ent;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2004-08-29 07:07:03 +02:00
|
|
|
return NULL; /* never */
|
2000-03-16 02:35:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static DCHCacheEntry *
|
2000-04-12 19:17:23 +02:00
|
|
|
DCH_cache_search(char *str)
|
2000-03-16 02:35:41 +01:00
|
|
|
{
|
2000-04-12 19:17:23 +02:00
|
|
|
int i = 0;
|
|
|
|
DCHCacheEntry *ent;
|
2000-03-16 02:35:41 +01:00
|
|
|
|
2002-09-20 05:54:57 +02:00
|
|
|
/* counter overload check - paranoia? */
|
2000-04-12 19:17:23 +02:00
|
|
|
if (DCHCounter + DCH_CACHE_FIELDS >= MAX_INT32)
|
|
|
|
{
|
2000-03-16 02:35:41 +01:00
|
|
|
DCHCounter = 0;
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
for (ent = DCHCache; ent <= (DCHCache + DCH_CACHE_FIELDS); ent++)
|
|
|
|
ent->age = (++DCHCounter);
|
2000-03-16 02:35:41 +01:00
|
|
|
}
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
for (ent = DCHCache; ent <= (DCHCache + DCH_CACHE_FIELDS); ent++)
|
|
|
|
{
|
2000-03-16 02:35:41 +01:00
|
|
|
if (i == n_DCHCache)
|
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
if (strcmp(ent->str, str) == 0)
|
|
|
|
{
|
2000-03-16 02:35:41 +01:00
|
|
|
ent->age = (++DCHCounter);
|
|
|
|
return ent;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
i++;
|
2000-03-16 02:35:41 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2004-01-07 19:56:30 +01:00
|
|
|
return NULL;
|
2000-03-16 02:35:41 +01:00
|
|
|
}
|
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
/*
|
|
|
|
* Format a date/time or interval into a string according to fmt.
|
|
|
|
* We parse fmt into a list of FormatNodes. This is then passed to DCH_to_char
|
|
|
|
* for formatting.
|
|
|
|
*/
|
2001-09-06 05:22:42 +02:00
|
|
|
static text *
|
2005-08-18 06:37:08 +02:00
|
|
|
datetime_to_char_body(TmToChar *tmtc, text *fmt, bool is_interval)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
FormatNode *format;
|
2003-09-03 16:59:41 +02:00
|
|
|
char *fmt_str,
|
2004-08-29 07:07:03 +02:00
|
|
|
*result;
|
|
|
|
bool incache;
|
2008-03-25 23:42:46 +01:00
|
|
|
int fmt_len;
|
2005-10-20 17:59:46 +02:00
|
|
|
text *res;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-12-01 06:17:19 +01:00
|
|
|
* Convert fmt to C string
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*/
|
2008-03-25 23:42:46 +01:00
|
|
|
fmt_str = text_to_cstring(fmt);
|
|
|
|
fmt_len = strlen(fmt_str);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2005-10-20 17:59:46 +02:00
|
|
|
* Allocate workspace for result as C string
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*/
|
2003-09-03 16:59:41 +02:00
|
|
|
result = palloc((fmt_len * DCH_MAX_ITEM_SIZ) + 1);
|
2005-10-20 17:59:46 +02:00
|
|
|
*result = '\0';
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* Allocate new memory if format picture is bigger than static cache and
|
|
|
|
* not use cache (call parser always)
|
2000-07-03 18:01:33 +02:00
|
|
|
*/
|
2003-09-03 16:59:41 +02:00
|
|
|
if (fmt_len > DCH_CACHE_SIZE)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2003-09-03 16:59:41 +02:00
|
|
|
format = (FormatNode *) palloc((fmt_len + 1) * sizeof(FormatNode));
|
2001-09-06 05:22:42 +02:00
|
|
|
incache = FALSE;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2003-09-03 16:59:41 +02:00
|
|
|
parse_format(format, fmt_str, DCH_keywords,
|
2000-04-12 19:17:23 +02:00
|
|
|
DCH_suff, DCH_index, DCH_TYPE, NULL);
|
|
|
|
|
2004-08-29 07:07:03 +02:00
|
|
|
(format + fmt_len)->type = NODE_TYPE_END; /* Paranoia? */
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* Use cache buffers
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
DCHCacheEntry *ent;
|
2004-08-29 07:07:03 +02:00
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
incache = TRUE;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2003-09-03 16:59:41 +02:00
|
|
|
if ((ent = DCH_cache_search(fmt_str)) == NULL)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2003-09-03 16:59:41 +02:00
|
|
|
ent = DCH_cache_getnew(fmt_str);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* Not in the cache, must run parser and save a new format-picture
|
|
|
|
* to the cache.
|
2000-07-03 18:01:33 +02:00
|
|
|
*/
|
2003-09-03 16:59:41 +02:00
|
|
|
parse_format(ent->format, fmt_str, DCH_keywords,
|
2001-03-22 05:01:46 +01:00
|
|
|
DCH_suff, DCH_index, DCH_TYPE, NULL);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2004-08-29 07:07:03 +02:00
|
|
|
(ent->format + fmt_len)->type = NODE_TYPE_END; /* Paranoia? */
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2003-09-03 16:59:41 +02:00
|
|
|
/* dump_node(ent->format, fmt_len); */
|
2000-04-07 21:17:51 +02:00
|
|
|
/* dump_index(DCH_keywords, DCH_index); */
|
2000-04-12 19:17:23 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
format = ent->format;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2005-10-20 17:59:46 +02:00
|
|
|
/* The real work is here */
|
2008-03-22 23:32:19 +01:00
|
|
|
DCH_to_char(format, is_interval, tmtc, result);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
if (!incache)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
pfree(format);
|
|
|
|
|
2003-09-03 16:59:41 +02:00
|
|
|
pfree(fmt_str);
|
2000-03-16 02:35:41 +01:00
|
|
|
|
2005-10-20 17:59:46 +02:00
|
|
|
/* convert C-string result to TEXT format */
|
2008-03-25 23:42:46 +01:00
|
|
|
res = cstring_to_text(result);
|
2001-09-06 05:22:42 +02:00
|
|
|
|
2003-09-03 16:59:41 +02:00
|
|
|
pfree(result);
|
2005-10-20 17:59:46 +02:00
|
|
|
return res;
|
2001-09-06 05:22:42 +02:00
|
|
|
}
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public routines
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
/* -------------------
|
|
|
|
* TIMESTAMP to_char()
|
|
|
|
* -------------------
|
|
|
|
*/
|
|
|
|
Datum
|
|
|
|
timestamp_to_char(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2001-10-25 07:50:21 +02:00
|
|
|
Timestamp dt = PG_GETARG_TIMESTAMP(0);
|
|
|
|
text *fmt = PG_GETARG_TEXT_P(1),
|
|
|
|
*res;
|
|
|
|
TmToChar tmtc;
|
2005-10-20 17:59:46 +02:00
|
|
|
struct pg_tm *tm;
|
|
|
|
int thisdate;
|
2001-09-28 10:09:14 +02:00
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
if ((VARSIZE(fmt) - VARHDRSZ) <= 0 || TIMESTAMP_NOT_FINITE(dt))
|
2001-09-28 10:09:14 +02:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
|
|
|
ZERO_tmtc(&tmtc);
|
2005-10-20 17:59:46 +02:00
|
|
|
tm = tmtcTm(&tmtc);
|
2001-09-28 10:09:14 +02:00
|
|
|
|
2005-10-20 17:59:46 +02:00
|
|
|
if (timestamp2tm(dt, NULL, tm, &tmtcFsec(&tmtc), NULL, NULL) != 0)
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
|
|
|
errmsg("timestamp out of range")));
|
2001-09-28 10:09:14 +02:00
|
|
|
|
2005-10-20 17:59:46 +02:00
|
|
|
thisdate = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday);
|
|
|
|
tm->tm_wday = (thisdate + 1) % 7;
|
|
|
|
tm->tm_yday = thisdate - date2j(tm->tm_year, 1, 1) + 1;
|
|
|
|
|
2005-08-18 06:37:08 +02:00
|
|
|
if (!(res = datetime_to_char_body(&tmtc, fmt, false)))
|
2001-09-28 10:09:14 +02:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
|
|
|
PG_RETURN_TEXT_P(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
timestamptz_to_char(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
TimestampTz dt = PG_GETARG_TIMESTAMP(0);
|
2001-10-25 07:50:21 +02:00
|
|
|
text *fmt = PG_GETARG_TEXT_P(1),
|
|
|
|
*res;
|
|
|
|
TmToChar tmtc;
|
2003-07-27 06:53:12 +02:00
|
|
|
int tz;
|
2005-10-20 17:59:46 +02:00
|
|
|
struct pg_tm *tm;
|
|
|
|
int thisdate;
|
2001-09-06 05:22:42 +02:00
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
if ((VARSIZE(fmt) - VARHDRSZ) <= 0 || TIMESTAMP_NOT_FINITE(dt))
|
2001-09-06 05:22:42 +02:00
|
|
|
PG_RETURN_NULL();
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
ZERO_tmtc(&tmtc);
|
2005-10-20 17:59:46 +02:00
|
|
|
tm = tmtcTm(&tmtc);
|
2000-03-16 02:35:41 +01:00
|
|
|
|
2005-10-20 17:59:46 +02:00
|
|
|
if (timestamp2tm(dt, &tz, tm, &tmtcFsec(&tmtc), &tmtcTzn(&tmtc), NULL) != 0)
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
|
|
|
errmsg("timestamp out of range")));
|
2001-09-06 05:22:42 +02:00
|
|
|
|
2005-10-20 17:59:46 +02:00
|
|
|
thisdate = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday);
|
|
|
|
tm->tm_wday = (thisdate + 1) % 7;
|
|
|
|
tm->tm_yday = thisdate - date2j(tm->tm_year, 1, 1) + 1;
|
|
|
|
|
2005-08-18 06:37:08 +02:00
|
|
|
if (!(res = datetime_to_char_body(&tmtc, fmt, false)))
|
2001-09-06 05:22:42 +02:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
|
|
|
PG_RETURN_TEXT_P(res);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
/* -------------------
|
|
|
|
* INTERVAL to_char()
|
|
|
|
* -------------------
|
|
|
|
*/
|
|
|
|
Datum
|
|
|
|
interval_to_char(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2001-10-25 07:50:21 +02:00
|
|
|
Interval *it = PG_GETARG_INTERVAL_P(0);
|
|
|
|
text *fmt = PG_GETARG_TEXT_P(1),
|
|
|
|
*res;
|
|
|
|
TmToChar tmtc;
|
2005-10-20 17:59:46 +02:00
|
|
|
struct pg_tm *tm;
|
2001-09-06 05:22:42 +02:00
|
|
|
|
|
|
|
if ((VARSIZE(fmt) - VARHDRSZ) <= 0)
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
|
|
|
ZERO_tmtc(&tmtc);
|
2005-10-20 17:59:46 +02:00
|
|
|
tm = tmtcTm(&tmtc);
|
2001-09-06 05:22:42 +02:00
|
|
|
|
2005-10-20 17:59:46 +02:00
|
|
|
if (interval2tm(*it, tm, &tmtcFsec(&tmtc)) != 0)
|
2001-09-06 05:22:42 +02:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2005-10-20 17:59:46 +02:00
|
|
|
/* wday is meaningless, yday approximates the total span in days */
|
|
|
|
tm->tm_yday = (tm->tm_year * MONTHS_PER_YEAR + tm->tm_mon) * DAYS_PER_MONTH + tm->tm_mday;
|
|
|
|
|
2005-08-18 06:37:08 +02:00
|
|
|
if (!(res = datetime_to_char_body(&tmtc, fmt, true)))
|
2001-09-06 05:22:42 +02:00
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
|
|
|
PG_RETURN_TEXT_P(res);
|
|
|
|
}
|
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/* ---------------------
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
* TO_TIMESTAMP()
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*
|
2001-09-28 10:09:14 +02:00
|
|
|
* Make Timestamp from date_str which is formatted at argument 'fmt'
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
* ( to_timestamp is reverse to_char() )
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ---------------------
|
|
|
|
*/
|
2000-07-01 23:27:14 +02:00
|
|
|
Datum
|
|
|
|
to_timestamp(PG_FUNCTION_ARGS)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
{
|
2001-10-25 07:50:21 +02:00
|
|
|
text *date_txt = PG_GETARG_TEXT_P(0);
|
|
|
|
text *fmt = PG_GETARG_TEXT_P(1);
|
|
|
|
Timestamp result;
|
2003-08-25 18:13:27 +02:00
|
|
|
int tz;
|
2004-08-29 07:07:03 +02:00
|
|
|
struct pg_tm tm;
|
2003-08-25 18:13:27 +02:00
|
|
|
fsec_t fsec;
|
|
|
|
|
|
|
|
do_to_timestamp(date_txt, fmt, &tm, &fsec);
|
|
|
|
|
2007-08-04 03:26:54 +02:00
|
|
|
tz = DetermineTimeZoneOffset(&tm, session_timezone);
|
2003-08-25 18:13:27 +02:00
|
|
|
|
|
|
|
if (tm2timestamp(&tm, fsec, &tz, &result) != 0)
|
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
|
|
|
errmsg("timestamp out of range")));
|
|
|
|
|
|
|
|
PG_RETURN_TIMESTAMP(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* TO_DATE
|
|
|
|
* Make Date from date_str which is formated at argument 'fmt'
|
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
Datum
|
|
|
|
to_date(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
text *date_txt = PG_GETARG_TEXT_P(0);
|
|
|
|
text *fmt = PG_GETARG_TEXT_P(1);
|
|
|
|
DateADT result;
|
2004-08-29 07:07:03 +02:00
|
|
|
struct pg_tm tm;
|
2003-08-25 18:13:27 +02:00
|
|
|
fsec_t fsec;
|
|
|
|
|
|
|
|
do_to_timestamp(date_txt, fmt, &tm, &fsec);
|
|
|
|
|
|
|
|
result = date2j(tm.tm_year, tm.tm_mon, tm.tm_mday) - POSTGRES_EPOCH_JDATE;
|
|
|
|
|
|
|
|
PG_RETURN_DATEADT(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* do_to_timestamp: shared code for to_timestamp and to_date
|
|
|
|
*
|
2004-05-21 07:08:06 +02:00
|
|
|
* Parse the 'date_txt' according to 'fmt', return results as a struct pg_tm
|
2003-08-25 18:13:27 +02:00
|
|
|
* and fractional seconds.
|
2008-03-22 23:32:19 +01:00
|
|
|
*
|
|
|
|
* We parse 'fmt' into a list of FormatNodes, which is then passed to
|
|
|
|
* DCH_from_char to populate a TmFromChar with the parsed contents of
|
|
|
|
* 'date_txt'.
|
|
|
|
*
|
|
|
|
* The TmFromChar is then analysed and converted into the final results in
|
|
|
|
* struct 'tm' and 'fsec'.
|
2003-08-25 18:13:27 +02:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
do_to_timestamp(text *date_txt, text *fmt,
|
2005-10-15 04:49:52 +02:00
|
|
|
struct pg_tm * tm, fsec_t *fsec)
|
2003-08-25 18:13:27 +02:00
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
FormatNode *format;
|
2001-10-25 07:50:21 +02:00
|
|
|
TmFromChar tmfc;
|
2007-02-16 04:39:46 +01:00
|
|
|
int fmt_len,
|
|
|
|
year;
|
2003-08-25 18:13:27 +02:00
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
ZERO_tmfc(&tmfc);
|
2003-08-25 18:13:27 +02:00
|
|
|
ZERO_tm(tm);
|
|
|
|
*fsec = 0;
|
2001-09-06 05:22:42 +02:00
|
|
|
|
2008-03-25 23:42:46 +01:00
|
|
|
fmt_len = VARSIZE_ANY_EXHDR(fmt);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2003-09-03 16:59:41 +02:00
|
|
|
if (fmt_len)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2004-08-29 07:07:03 +02:00
|
|
|
char *fmt_str;
|
|
|
|
char *date_str;
|
|
|
|
bool incache;
|
|
|
|
|
2008-03-25 23:42:46 +01:00
|
|
|
fmt_str = text_to_cstring(fmt);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* Allocate new memory if format picture is bigger than static cache
|
|
|
|
* and not use cache (call parser always)
|
2000-07-03 18:01:33 +02:00
|
|
|
*/
|
2003-09-03 16:59:41 +02:00
|
|
|
if (fmt_len > DCH_CACHE_SIZE)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2003-09-03 16:59:41 +02:00
|
|
|
format = (FormatNode *) palloc((fmt_len + 1) * sizeof(FormatNode));
|
2001-09-06 05:22:42 +02:00
|
|
|
incache = FALSE;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2003-09-03 16:59:41 +02:00
|
|
|
parse_format(format, fmt_str, DCH_keywords,
|
2000-04-12 19:17:23 +02:00
|
|
|
DCH_suff, DCH_index, DCH_TYPE, NULL);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2004-08-29 07:07:03 +02:00
|
|
|
(format + fmt_len)->type = NODE_TYPE_END; /* Paranoia? */
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* Use cache buffers
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
DCHCacheEntry *ent;
|
2004-08-29 07:07:03 +02:00
|
|
|
|
2003-09-03 16:59:41 +02:00
|
|
|
incache = TRUE;
|
2001-10-25 07:50:21 +02:00
|
|
|
|
2003-09-03 16:59:41 +02:00
|
|
|
if ((ent = DCH_cache_search(fmt_str)) == NULL)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2003-09-03 16:59:41 +02:00
|
|
|
ent = DCH_cache_getnew(fmt_str);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-03-16 02:35:41 +01:00
|
|
|
* Not in the cache, must run parser and save a new
|
2000-04-12 19:17:23 +02:00
|
|
|
* format-picture to the cache.
|
2001-03-22 07:16:21 +01:00
|
|
|
*/
|
2003-09-03 16:59:41 +02:00
|
|
|
parse_format(ent->format, fmt_str, DCH_keywords,
|
2000-04-12 19:17:23 +02:00
|
|
|
DCH_suff, DCH_index, DCH_TYPE, NULL);
|
|
|
|
|
2004-08-29 07:07:03 +02:00
|
|
|
(ent->format + fmt_len)->type = NODE_TYPE_END; /* Paranoia? */
|
2000-04-12 19:17:23 +02:00
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2003-09-03 16:59:41 +02:00
|
|
|
/* dump_node(ent->format, fmt_len); */
|
2000-03-16 02:35:41 +01:00
|
|
|
/* dump_index(DCH_keywords, DCH_index); */
|
2000-04-12 19:17:23 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
format = ent->format;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2003-09-03 16:59:41 +02:00
|
|
|
/* dump_node(format, fmt_len); */
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
#endif
|
|
|
|
|
2008-03-25 23:42:46 +01:00
|
|
|
date_str = text_to_cstring(date_txt);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2008-03-22 23:32:19 +01:00
|
|
|
DCH_from_char(format, date_str, &tmfc);
|
2000-12-01 06:17:19 +01:00
|
|
|
|
|
|
|
pfree(date_str);
|
2003-09-03 16:59:41 +02:00
|
|
|
pfree(fmt_str);
|
|
|
|
if (!incache)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
pfree(format);
|
|
|
|
}
|
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
DEBUG_TMFC(&tmfc);
|
2001-09-06 05:22:42 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* Convert values that user define for FROM_CHAR (to_date/to_timestamp) to
|
|
|
|
* standard 'tm'
|
2001-03-22 05:01:46 +01:00
|
|
|
*/
|
2001-09-06 05:22:42 +02:00
|
|
|
if (tmfc.ssss)
|
2000-07-03 18:01:33 +02:00
|
|
|
{
|
2001-10-25 07:50:21 +02:00
|
|
|
int x = tmfc.ssss;
|
2000-12-23 05:05:31 +01:00
|
|
|
|
2005-07-21 05:56:25 +02:00
|
|
|
tm->tm_hour = x / SECS_PER_HOUR;
|
|
|
|
x %= SECS_PER_HOUR;
|
|
|
|
tm->tm_min = x / SECS_PER_MINUTE;
|
|
|
|
x %= SECS_PER_MINUTE;
|
2003-08-25 18:13:27 +02:00
|
|
|
tm->tm_sec = x;
|
2000-12-23 05:05:31 +01:00
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
if (tmfc.ww)
|
|
|
|
tmfc.ddd = (tmfc.ww - 1) * 7 + 1;
|
2000-07-03 18:01:33 +02:00
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
if (tmfc.w)
|
|
|
|
tmfc.dd = (tmfc.w - 1) * 7 + 1;
|
2000-07-03 18:01:33 +02:00
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
if (tmfc.ss)
|
2003-08-25 18:13:27 +02:00
|
|
|
tm->tm_sec = tmfc.ss;
|
2001-09-06 05:22:42 +02:00
|
|
|
if (tmfc.mi)
|
2003-08-25 18:13:27 +02:00
|
|
|
tm->tm_min = tmfc.mi;
|
2001-09-06 05:22:42 +02:00
|
|
|
if (tmfc.hh)
|
2003-08-25 18:13:27 +02:00
|
|
|
tm->tm_hour = tmfc.hh;
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
if (tmfc.pm || tmfc.am)
|
2001-03-22 05:01:46 +01:00
|
|
|
{
|
2003-08-25 18:13:27 +02:00
|
|
|
if (tm->tm_hour < 1 || tm->tm_hour > 12)
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
|
|
|
errmsg("AM/PM hour must be between 1 and 12")));
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2003-08-25 18:13:27 +02:00
|
|
|
if (tmfc.pm && tm->tm_hour < 12)
|
|
|
|
tm->tm_hour += 12;
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2003-08-25 18:13:27 +02:00
|
|
|
else if (tmfc.am && tm->tm_hour == 12)
|
|
|
|
tm->tm_hour = 0;
|
2001-03-22 05:01:46 +01:00
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
switch (tmfc.q)
|
2000-07-03 18:01:33 +02:00
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
case 1:
|
2003-08-25 18:13:27 +02:00
|
|
|
tm->tm_mday = 1;
|
|
|
|
tm->tm_mon = 1;
|
2001-03-22 05:01:46 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2003-08-25 18:13:27 +02:00
|
|
|
tm->tm_mday = 1;
|
|
|
|
tm->tm_mon = 4;
|
2001-03-22 05:01:46 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2003-08-25 18:13:27 +02:00
|
|
|
tm->tm_mday = 1;
|
|
|
|
tm->tm_mon = 7;
|
2001-03-22 05:01:46 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2003-08-25 18:13:27 +02:00
|
|
|
tm->tm_mday = 1;
|
|
|
|
tm->tm_mon = 10;
|
2001-03-22 05:01:46 +01:00
|
|
|
break;
|
2000-07-03 18:01:33 +02:00
|
|
|
}
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2007-02-16 04:39:46 +01:00
|
|
|
/*
|
2007-11-15 22:14:46 +01:00
|
|
|
* Only one year value is used. If iyear (the ISO year) is defined, it
|
|
|
|
* takes precedence. Otherwise year (the Gregorian year) is used.
|
2007-02-16 04:39:46 +01:00
|
|
|
*/
|
|
|
|
year = (tmfc.iyear) ? tmfc.iyear : tmfc.year;
|
|
|
|
|
|
|
|
if (year)
|
2005-03-25 17:08:40 +01:00
|
|
|
{
|
2007-01-13 00:34:55 +01:00
|
|
|
/*
|
2007-11-15 22:14:46 +01:00
|
|
|
* If CC and YY (or Y) are provided, use YY as 2 low-order digits for
|
|
|
|
* the year in the given century. Keep in mind that the 21st century
|
|
|
|
* runs from 2001-2100, not 2000-2099.
|
2007-01-13 00:34:55 +01:00
|
|
|
*
|
|
|
|
* If a 4-digit year is provided, we use that and ignore CC.
|
|
|
|
*/
|
|
|
|
if (tmfc.cc && tmfc.yysz <= 2)
|
2005-03-25 17:08:40 +01:00
|
|
|
{
|
2007-02-16 04:39:46 +01:00
|
|
|
tm->tm_year = year % 100;
|
2007-01-13 00:34:55 +01:00
|
|
|
if (tm->tm_year)
|
|
|
|
tm->tm_year += (tmfc.cc - 1) * 100;
|
|
|
|
else
|
|
|
|
tm->tm_year = tmfc.cc * 100;
|
2005-03-25 17:08:40 +01:00
|
|
|
}
|
|
|
|
else
|
2007-02-16 04:39:46 +01:00
|
|
|
tm->tm_year = year;
|
2005-03-25 17:08:40 +01:00
|
|
|
}
|
2007-01-13 00:34:55 +01:00
|
|
|
else if (tmfc.cc) /* use first year of century */
|
|
|
|
tm->tm_year = (tmfc.cc - 1) * 100 + 1;
|
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
if (tmfc.bc)
|
2000-11-25 06:00:33 +01:00
|
|
|
{
|
2003-08-25 18:13:27 +02:00
|
|
|
if (tm->tm_year > 0)
|
|
|
|
tm->tm_year = -(tm->tm_year - 1);
|
2000-11-25 06:00:33 +01:00
|
|
|
else
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
|
|
|
errmsg("inconsistent use of year %04d and \"BC\"",
|
2003-08-25 18:13:27 +02:00
|
|
|
tm->tm_year)));
|
2001-03-22 05:01:46 +01:00
|
|
|
}
|
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
if (tmfc.j)
|
2003-08-25 18:13:27 +02:00
|
|
|
j2date(tmfc.j, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
if (tmfc.iw)
|
2007-02-16 04:39:46 +01:00
|
|
|
{
|
2007-11-15 22:14:46 +01:00
|
|
|
/*
|
|
|
|
* Since the user has employed the IW field, it is assumed that the
|
|
|
|
* value in tmfc.d is in ISO day-of-week form (1 = Monday), as set by
|
|
|
|
* the ID field. Mixing IW and D will yield weird results.
|
2007-02-16 04:39:46 +01:00
|
|
|
*
|
2007-11-15 22:14:46 +01:00
|
|
|
* tmfc.iyear must have been set (e.g., with IYYY) for this to work
|
|
|
|
* properly (an ISO week without an ISO year is meaningless).
|
2007-02-16 04:39:46 +01:00
|
|
|
*
|
2007-11-15 22:14:46 +01:00
|
|
|
* If tmfc.d is not set, then the date is left at the beginning of the
|
|
|
|
* ISO week (Monday).
|
2007-02-16 04:39:46 +01:00
|
|
|
*/
|
|
|
|
if (tmfc.d)
|
|
|
|
isoweekdate2date(tmfc.iw, tmfc.d, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
|
|
|
|
else
|
|
|
|
isoweek2date(tmfc.iw, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
|
|
|
|
}
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
if (tmfc.d)
|
2003-08-25 18:13:27 +02:00
|
|
|
tm->tm_wday = tmfc.d;
|
2001-09-06 05:22:42 +02:00
|
|
|
if (tmfc.dd)
|
2003-08-25 18:13:27 +02:00
|
|
|
tm->tm_mday = tmfc.dd;
|
2007-02-16 04:39:46 +01:00
|
|
|
if (tmfc.ddd && !tmfc.iyear)
|
2003-08-25 18:13:27 +02:00
|
|
|
tm->tm_yday = tmfc.ddd;
|
2001-09-06 05:22:42 +02:00
|
|
|
if (tmfc.mm)
|
2003-08-25 18:13:27 +02:00
|
|
|
tm->tm_mon = tmfc.mm;
|
2000-07-03 18:01:33 +02:00
|
|
|
|
2003-08-25 18:13:27 +02:00
|
|
|
if (tmfc.ddd && (tm->tm_mon <= 1 || tm->tm_mday <= 1))
|
2000-07-03 18:01:33 +02:00
|
|
|
{
|
2007-02-16 04:39:46 +01:00
|
|
|
/*
|
2007-11-15 22:14:46 +01:00
|
|
|
* If the iyear field is set, the value of ddd is taken to be an ISO
|
|
|
|
* day-of-year. Otherwise, it is a Gregorian day-of-year. Either way,
|
|
|
|
* since the month and day fields have not been set by some other
|
|
|
|
* means, the value of ddd will be used to compute them.
|
2007-02-16 04:39:46 +01:00
|
|
|
*/
|
|
|
|
if (tmfc.iyear)
|
|
|
|
{
|
2007-11-15 22:14:46 +01:00
|
|
|
int j0; /* zeroth day of the ISO year, in Julian */
|
|
|
|
|
2007-02-16 04:39:46 +01:00
|
|
|
j0 = isoweek2j(tmfc.iyear, 1) - 1;
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2007-02-16 04:39:46 +01:00
|
|
|
j2date(j0 + tmfc.ddd, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int *y,
|
|
|
|
i;
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2007-02-16 04:39:46 +01:00
|
|
|
int ysum[2][13] = {
|
|
|
|
{31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 0},
|
|
|
|
{31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366, 0}};
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2007-02-16 04:39:46 +01:00
|
|
|
if (!tm->tm_year)
|
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
2007-11-15 22:14:46 +01:00
|
|
|
errmsg("cannot calculate day of year without year information")));
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2007-02-16 04:39:46 +01:00
|
|
|
y = ysum[isleap(tm->tm_year)];
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2007-02-16 04:39:46 +01:00
|
|
|
for (i = 0; i <= 11; i++)
|
|
|
|
{
|
|
|
|
if (tm->tm_yday < y[i])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (tm->tm_mon <= 1)
|
|
|
|
tm->tm_mon = i + 1;
|
|
|
|
|
|
|
|
if (tm->tm_mday <= 1)
|
|
|
|
tm->tm_mday = i == 0 ? tm->tm_yday :
|
|
|
|
tm->tm_yday - y[i - 1];
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
}
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2002-04-21 21:52:18 +02:00
|
|
|
#ifdef HAVE_INT64_TIMESTAMP
|
|
|
|
if (tmfc.ms)
|
2003-08-25 18:13:27 +02:00
|
|
|
*fsec += tmfc.ms * 1000;
|
2002-04-21 21:52:18 +02:00
|
|
|
if (tmfc.us)
|
2003-08-25 18:13:27 +02:00
|
|
|
*fsec += tmfc.us;
|
2002-04-21 21:52:18 +02:00
|
|
|
#else
|
2001-09-06 05:22:42 +02:00
|
|
|
if (tmfc.ms)
|
2003-08-25 18:13:27 +02:00
|
|
|
*fsec += (double) tmfc.ms / 1000;
|
2001-09-06 05:22:42 +02:00
|
|
|
if (tmfc.us)
|
2003-08-25 18:13:27 +02:00
|
|
|
*fsec += (double) tmfc.us / 1000000;
|
2002-04-21 21:52:18 +02:00
|
|
|
#endif
|
2001-09-06 05:22:42 +02:00
|
|
|
|
2003-08-25 18:13:27 +02:00
|
|
|
DEBUG_TM(tm);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-04-12 19:17:23 +02:00
|
|
|
* the NUMBER version part
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
fill_str(char *str, int c, int max)
|
|
|
|
{
|
|
|
|
memset(str, c, max);
|
2007-06-29 03:51:35 +02:00
|
|
|
*(str + max) = '\0';
|
2000-04-12 19:17:23 +02:00
|
|
|
return str;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
|
2000-07-03 18:01:33 +02:00
|
|
|
#define zeroize_NUM(_n) \
|
|
|
|
do { \
|
2000-04-12 19:17:23 +02:00
|
|
|
(_n)->flag = 0; \
|
2000-03-16 02:35:41 +01:00
|
|
|
(_n)->lsign = 0; \
|
|
|
|
(_n)->pre = 0; \
|
|
|
|
(_n)->post = 0; \
|
2001-03-22 05:01:46 +01:00
|
|
|
(_n)->pre_lsign_num = 0; \
|
2000-03-16 02:35:41 +01:00
|
|
|
(_n)->need_locale = 0; \
|
|
|
|
(_n)->multi = 0; \
|
|
|
|
(_n)->zero_start = 0; \
|
|
|
|
(_n)->zero_end = 0; \
|
2000-07-03 18:01:33 +02:00
|
|
|
} while(0)
|
2000-03-16 02:35:41 +01:00
|
|
|
|
|
|
|
static NUMCacheEntry *
|
2000-04-12 19:17:23 +02:00
|
|
|
NUM_cache_getnew(char *str)
|
2000-03-16 02:35:41 +01:00
|
|
|
{
|
2000-04-12 19:17:23 +02:00
|
|
|
NUMCacheEntry *ent = NULL;
|
|
|
|
|
2002-09-20 05:54:57 +02:00
|
|
|
/* counter overload check - paranoia? */
|
2000-04-12 19:17:23 +02:00
|
|
|
if (NUMCounter + NUM_CACHE_FIELDS >= MAX_INT32)
|
|
|
|
{
|
2000-03-16 02:35:41 +01:00
|
|
|
NUMCounter = 0;
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
for (ent = NUMCache; ent <= (NUMCache + NUM_CACHE_FIELDS); ent++)
|
|
|
|
ent->age = (++NUMCounter);
|
2000-03-16 02:35:41 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-03-16 02:35:41 +01:00
|
|
|
* Cache is full - needs remove any older entry
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (n_NUMCache > NUM_CACHE_FIELDS)
|
|
|
|
{
|
|
|
|
NUMCacheEntry *old = NUMCache + 0;
|
2000-03-16 02:35:41 +01:00
|
|
|
|
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
|
|
|
elog(DEBUG_elog_output, "Cache is full (%d)", n_NUMCache);
|
|
|
|
#endif
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
for (ent = NUMCache; ent <= (NUMCache + NUM_CACHE_FIELDS); ent++)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
/*
|
|
|
|
* entry removed via NUM_cache_remove() can be used here
|
2000-12-15 20:15:09 +01:00
|
|
|
*/
|
2001-03-22 05:01:46 +01:00
|
|
|
if (*ent->str == '\0')
|
2000-12-15 20:15:09 +01:00
|
|
|
{
|
|
|
|
old = ent;
|
|
|
|
break;
|
|
|
|
}
|
2000-03-16 02:35:41 +01:00
|
|
|
if (ent->age < old->age)
|
|
|
|
old = ent;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2003-07-27 06:53:12 +02:00
|
|
|
elog(DEBUG_elog_output, "OLD: \"%s\" AGE: %d", old->str, old->age);
|
2000-04-12 19:17:23 +02:00
|
|
|
#endif
|
2002-09-20 05:54:57 +02:00
|
|
|
StrNCpy(old->str, str, NUM_CACHE_SIZE + 1);
|
2000-03-16 02:35:41 +01:00
|
|
|
/* old->format fill parser */
|
|
|
|
old->age = (++NUMCounter);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-03-16 02:35:41 +01:00
|
|
|
ent = old;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2000-03-16 02:35:41 +01:00
|
|
|
elog(DEBUG_elog_output, "NEW (%d)", n_NUMCache);
|
2000-04-12 19:17:23 +02:00
|
|
|
#endif
|
2000-03-16 02:35:41 +01:00
|
|
|
ent = NUMCache + n_NUMCache;
|
2002-09-20 05:54:57 +02:00
|
|
|
StrNCpy(ent->str, str, NUM_CACHE_SIZE + 1);
|
2000-03-16 02:35:41 +01:00
|
|
|
/* ent->format fill parser */
|
|
|
|
ent->age = (++NUMCounter);
|
|
|
|
++n_NUMCache;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-03-16 02:35:41 +01:00
|
|
|
zeroize_NUM(&ent->Num);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-12-15 20:15:09 +01:00
|
|
|
last_NUMCacheEntry = ent;
|
2000-04-12 19:17:23 +02:00
|
|
|
return ent; /* never */
|
2000-03-16 02:35:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static NUMCacheEntry *
|
2000-04-12 19:17:23 +02:00
|
|
|
NUM_cache_search(char *str)
|
2000-03-16 02:35:41 +01:00
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
int i = 0;
|
2000-04-12 19:17:23 +02:00
|
|
|
NUMCacheEntry *ent;
|
2000-03-16 02:35:41 +01:00
|
|
|
|
2002-09-20 05:54:57 +02:00
|
|
|
/* counter overload check - paranoia? */
|
2000-04-12 19:17:23 +02:00
|
|
|
if (NUMCounter + NUM_CACHE_FIELDS >= MAX_INT32)
|
|
|
|
{
|
2000-03-16 02:35:41 +01:00
|
|
|
NUMCounter = 0;
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
for (ent = NUMCache; ent <= (NUMCache + NUM_CACHE_FIELDS); ent++)
|
|
|
|
ent->age = (++NUMCounter);
|
2000-03-16 02:35:41 +01:00
|
|
|
}
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
for (ent = NUMCache; ent <= (NUMCache + NUM_CACHE_FIELDS); ent++)
|
|
|
|
{
|
2000-03-16 02:35:41 +01:00
|
|
|
if (i == n_NUMCache)
|
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
if (strcmp(ent->str, str) == 0)
|
|
|
|
{
|
2000-03-16 02:35:41 +01:00
|
|
|
ent->age = (++NUMCounter);
|
2000-12-15 20:15:09 +01:00
|
|
|
last_NUMCacheEntry = ent;
|
2000-03-16 02:35:41 +01:00
|
|
|
return ent;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
i++;
|
2000-03-16 02:35:41 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2004-01-07 19:56:30 +01:00
|
|
|
return NULL;
|
2000-03-16 02:35:41 +01:00
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2000-12-15 20:15:09 +01:00
|
|
|
static void
|
|
|
|
NUM_cache_remove(NUMCacheEntry *ent)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
|
|
|
elog(DEBUG_elog_output, "REMOVING ENTRY (%s)", ent->str);
|
|
|
|
#endif
|
|
|
|
*ent->str = '\0';
|
|
|
|
ent->age = 0;
|
|
|
|
}
|
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
/* ----------
|
|
|
|
* Cache routine for NUM to_char version
|
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
static FormatNode *
|
2008-03-25 23:42:46 +01:00
|
|
|
NUM_cache(int len, NUMDesc *Num, text *pars_str, bool *shouldFree)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
FormatNode *format = NULL;
|
|
|
|
char *str;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2008-03-25 23:42:46 +01:00
|
|
|
str = text_to_cstring(pars_str);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* Allocate new memory if format picture is bigger than static cache and
|
|
|
|
* not use cache (call parser always). This branches sets shouldFree to
|
|
|
|
* true, accordingly.
|
2000-12-15 20:15:09 +01:00
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (len > NUM_CACHE_SIZE)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
format = (FormatNode *) palloc((len + 1) * sizeof(FormatNode));
|
2002-09-20 05:54:57 +02:00
|
|
|
|
|
|
|
*shouldFree = true;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
zeroize_NUM(Num);
|
|
|
|
|
|
|
|
parse_format(format, str, NUM_keywords,
|
|
|
|
NULL, NUM_index, NUM_TYPE, Num);
|
|
|
|
|
2002-09-20 05:54:57 +02:00
|
|
|
(format + len)->type = NODE_TYPE_END; /* Paranoia? */
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-03-16 02:35:41 +01:00
|
|
|
* Use cache buffers
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
NUMCacheEntry *ent;
|
|
|
|
|
2002-09-20 05:54:57 +02:00
|
|
|
*shouldFree = false;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
if ((ent = NUM_cache_search(str)) == NULL)
|
|
|
|
{
|
2000-03-16 02:35:41 +01:00
|
|
|
ent = NUM_cache_getnew(str);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* Not in the cache, must run parser and save a new format-picture
|
|
|
|
* to the cache.
|
2001-03-22 07:16:21 +01:00
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
parse_format(ent->format, str, NUM_keywords,
|
|
|
|
NULL, NUM_index, NUM_TYPE, &ent->Num);
|
|
|
|
|
2002-09-20 05:54:57 +02:00
|
|
|
(ent->format + len)->type = NODE_TYPE_END; /* Paranoia? */
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
format = ent->format;
|
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* Copy cache to used struct
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
Num->flag = ent->Num.flag;
|
|
|
|
Num->lsign = ent->Num.lsign;
|
|
|
|
Num->pre = ent->Num.pre;
|
|
|
|
Num->post = ent->Num.post;
|
|
|
|
Num->pre_lsign_num = ent->Num.pre_lsign_num;
|
|
|
|
Num->need_locale = ent->Num.need_locale;
|
|
|
|
Num->multi = ent->Num.multi;
|
|
|
|
Num->zero_start = ent->Num.zero_start;
|
|
|
|
Num->zero_end = ent->Num.zero_end;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2000-04-07 21:17:51 +02:00
|
|
|
/* dump_node(format, len); */
|
2000-04-12 19:17:23 +02:00
|
|
|
dump_index(NUM_keywords, NUM_index);
|
|
|
|
#endif
|
2000-04-07 21:17:51 +02:00
|
|
|
|
2000-03-16 02:35:41 +01:00
|
|
|
pfree(str);
|
|
|
|
return format;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
int_to_roman(int number)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
int len = 0,
|
2005-06-22 03:43:05 +02:00
|
|
|
num = 0;
|
2001-03-22 05:01:46 +01:00
|
|
|
char *p = NULL,
|
|
|
|
*result,
|
|
|
|
numstr[5];
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
result = (char *) palloc(16);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*result = '\0';
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (number > 3999 || number < 1)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
fill_str(result, '#', 15);
|
|
|
|
return result;
|
|
|
|
}
|
2001-02-27 09:13:31 +01:00
|
|
|
len = snprintf(numstr, sizeof(numstr), "%d", number);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
for (p = numstr; *p != '\0'; p++, --len)
|
|
|
|
{
|
|
|
|
num = *p - 49; /* 48 ascii + 1 */
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
if (num < 0)
|
|
|
|
continue;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (len > 3)
|
|
|
|
{
|
|
|
|
while (num-- != -1)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
strcat(result, "M");
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (len == 3)
|
|
|
|
strcat(result, rm100[num]);
|
|
|
|
else if (len == 2)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
strcat(result, rm10[num]);
|
2000-04-12 19:17:23 +02:00
|
|
|
else if (len == 1)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
strcat(result, rm1[num]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* Locale
|
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
NUM_prepare_locale(NUMProc *Np)
|
|
|
|
{
|
2000-04-12 19:17:23 +02:00
|
|
|
if (Np->Num->need_locale)
|
|
|
|
{
|
|
|
|
struct lconv *lconv;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* Get locales
|
|
|
|
*/
|
|
|
|
lconv = PGLC_localeconv();
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* Positive / Negative number sign
|
|
|
|
*/
|
|
|
|
if (lconv->negative_sign && *lconv->negative_sign)
|
|
|
|
Np->L_negative_sign = lconv->negative_sign;
|
|
|
|
else
|
|
|
|
Np->L_negative_sign = "-";
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2006-02-13 00:48:23 +01:00
|
|
|
if (lconv->positive_sign && *lconv->positive_sign)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
Np->L_positive_sign = lconv->positive_sign;
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
|
|
|
Np->L_positive_sign = "+";
|
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* Number decimal point
|
|
|
|
*/
|
|
|
|
if (lconv->decimal_point && *lconv->decimal_point)
|
|
|
|
Np->decimal = lconv->decimal_point;
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
Np->decimal = ".";
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2007-02-13 03:00:55 +01:00
|
|
|
if (!IS_LDECIMAL(Np->Num))
|
|
|
|
Np->decimal = ".";
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Number thousands separator
|
2007-11-15 22:14:46 +01:00
|
|
|
*
|
|
|
|
* Some locales (e.g. broken glibc pt_BR), have a comma for decimal,
|
2007-11-22 16:10:05 +01:00
|
|
|
* but "" for thousands_sep, so we set the thousands_sep too.
|
2007-11-22 18:51:39 +01:00
|
|
|
* http://archives.postgresql.org/pgsql-hackers/2007-11/msg00772.php
|
2007-02-13 03:00:55 +01:00
|
|
|
*/
|
|
|
|
if (lconv->thousands_sep && *lconv->thousands_sep)
|
|
|
|
Np->L_thousands_sep = lconv->thousands_sep;
|
2007-11-22 16:10:05 +01:00
|
|
|
/* Make sure thousands separator doesn't match decimal point symbol. */
|
2007-11-21 23:28:18 +01:00
|
|
|
else if (strcmp(Np->decimal, ",") != 0)
|
2007-02-13 03:00:55 +01:00
|
|
|
Np->L_thousands_sep = ",";
|
2007-11-21 23:28:18 +01:00
|
|
|
else
|
|
|
|
Np->L_thousands_sep = ".";
|
2007-02-13 03:00:55 +01:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* Currency symbol
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (lconv->currency_symbol && *lconv->currency_symbol)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
Np->L_currency_symbol = lconv->currency_symbol;
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
|
|
|
Np->L_currency_symbol = " ";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* Default values
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->L_negative_sign = "-";
|
|
|
|
Np->L_positive_sign = "+";
|
|
|
|
Np->decimal = ".";
|
2007-11-15 22:14:46 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->L_thousands_sep = ",";
|
|
|
|
Np->L_currency_symbol = " ";
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------
|
2000-02-08 16:57:01 +01:00
|
|
|
* Return pointer of last relevant number after decimal point
|
2000-04-12 19:17:23 +02:00
|
|
|
* 12.0500 --> last relevant is '5'
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
2000-04-12 19:17:23 +02:00
|
|
|
*/
|
2000-02-08 16:57:01 +01:00
|
|
|
static char *
|
|
|
|
get_last_relevant_decnum(char *num)
|
|
|
|
{
|
2000-04-12 19:17:23 +02:00
|
|
|
char *result,
|
2001-03-22 05:01:46 +01:00
|
|
|
*p = strchr(num, '.');
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2003-07-27 06:53:12 +02:00
|
|
|
elog(DEBUG_elog_output, "get_last_relevant_decnum()");
|
2000-03-16 02:35:41 +01:00
|
|
|
#endif
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (!p)
|
2000-02-08 16:57:01 +01:00
|
|
|
p = num;
|
|
|
|
result = p;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
while (*(++p))
|
|
|
|
{
|
|
|
|
if (*p != '0')
|
2000-02-08 16:57:01 +01:00
|
|
|
result = p;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-02-08 16:57:01 +01:00
|
|
|
return result;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------
|
2000-02-08 16:57:01 +01:00
|
|
|
* Number extraction for TO_NUMBER()
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* ----------
|
|
|
|
*/
|
2000-02-08 16:57:01 +01:00
|
|
|
static void
|
2000-04-12 19:17:23 +02:00
|
|
|
NUM_numpart_from_char(NUMProc *Np, int id, int plen)
|
2000-02-08 16:57:01 +01:00
|
|
|
{
|
2005-10-15 04:49:52 +02:00
|
|
|
bool isread = FALSE;
|
|
|
|
|
2000-02-08 16:57:01 +01:00
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2004-10-28 20:55:08 +02:00
|
|
|
elog(DEBUG_elog_output, " --- scan start --- id=%s",
|
2005-10-15 04:49:52 +02:00
|
|
|
(id == NUM_0 || id == NUM_9) ? "NUM_0/9" : id == NUM_DEC ? "NUM_DEC" : "???");
|
2000-02-08 16:57:01 +01:00
|
|
|
#endif
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
if (*Np->inout_p == ' ')
|
|
|
|
Np->inout_p++;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2000-03-16 02:35:41 +01:00
|
|
|
#define OVERLOAD_TEST (Np->inout_p >= Np->inout + plen)
|
2005-10-15 04:49:52 +02:00
|
|
|
#define AMOUNT_TEST(_s) (plen-(Np->inout_p-Np->inout) >= _s)
|
2000-03-16 02:35:41 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
if (*Np->inout_p == ' ')
|
|
|
|
Np->inout_p++;
|
|
|
|
|
2000-03-08 02:34:41 +01:00
|
|
|
if (OVERLOAD_TEST)
|
|
|
|
return;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2004-10-28 20:55:08 +02:00
|
|
|
* read sign before number
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*/
|
2005-10-15 04:49:52 +02:00
|
|
|
if (*Np->number == ' ' && (id == NUM_0 || id == NUM_9) &&
|
|
|
|
(Np->read_pre + Np->read_post) == 0)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2000-02-08 16:57:01 +01:00
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2005-10-15 04:49:52 +02:00
|
|
|
elog(DEBUG_elog_output, "Try read sign (%c), locale positive: %s, negative: %s",
|
|
|
|
*Np->inout_p, Np->L_positive_sign, Np->L_negative_sign);
|
2000-04-12 19:17:23 +02:00
|
|
|
#endif
|
2001-03-22 07:16:21 +01:00
|
|
|
|
|
|
|
/*
|
2000-02-08 16:57:01 +01:00
|
|
|
* locale sign
|
|
|
|
*/
|
2004-10-28 20:55:08 +02:00
|
|
|
if (IS_LSIGN(Np->Num) && Np->Num->lsign == NUM_LSIGN_PRE)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2005-10-15 04:49:52 +02:00
|
|
|
int x = 0;
|
|
|
|
|
2000-02-08 16:57:01 +01:00
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2004-10-28 20:55:08 +02:00
|
|
|
elog(DEBUG_elog_output, "Try read locale pre-sign (%c)", *Np->inout_p);
|
2000-04-12 19:17:23 +02:00
|
|
|
#endif
|
2005-10-15 04:49:52 +02:00
|
|
|
if ((x = strlen(Np->L_negative_sign)) &&
|
2004-10-28 20:55:08 +02:00
|
|
|
AMOUNT_TEST(x) &&
|
2005-10-15 04:49:52 +02:00
|
|
|
strncmp(Np->inout_p, Np->L_negative_sign, x) == 0)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2004-10-28 20:55:08 +02:00
|
|
|
Np->inout_p += x;
|
2000-02-08 16:57:01 +01:00
|
|
|
*Np->number = '-';
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2005-10-15 04:49:52 +02:00
|
|
|
else if ((x = strlen(Np->L_positive_sign)) &&
|
|
|
|
AMOUNT_TEST(x) &&
|
|
|
|
strncmp(Np->inout_p, Np->L_positive_sign, x) == 0)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2004-10-28 20:55:08 +02:00
|
|
|
Np->inout_p += x;
|
2000-02-08 16:57:01 +01:00
|
|
|
*Np->number = '+';
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2000-02-08 16:57:01 +01:00
|
|
|
}
|
2004-10-28 20:55:08 +02:00
|
|
|
else
|
|
|
|
{
|
2000-02-08 16:57:01 +01:00
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2004-10-28 20:55:08 +02:00
|
|
|
elog(DEBUG_elog_output, "Try read simple sign (%c)", *Np->inout_p);
|
2000-04-12 19:17:23 +02:00
|
|
|
#endif
|
2005-10-15 04:49:52 +02:00
|
|
|
|
2004-10-28 20:55:08 +02:00
|
|
|
/*
|
|
|
|
* simple + - < >
|
|
|
|
*/
|
|
|
|
if (*Np->inout_p == '-' || (IS_BRACKET(Np->Num) &&
|
|
|
|
*Np->inout_p == '<'))
|
|
|
|
{
|
2005-10-15 04:49:52 +02:00
|
|
|
*Np->number = '-'; /* set - */
|
2004-10-28 20:55:08 +02:00
|
|
|
Np->inout_p++;
|
|
|
|
}
|
|
|
|
else if (*Np->inout_p == '+')
|
|
|
|
{
|
2005-10-15 04:49:52 +02:00
|
|
|
*Np->number = '+'; /* set + */
|
2004-10-28 20:55:08 +02:00
|
|
|
Np->inout_p++;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
2000-02-08 16:57:01 +01:00
|
|
|
}
|
2000-03-16 02:35:41 +01:00
|
|
|
|
2000-03-08 02:34:41 +01:00
|
|
|
if (OVERLOAD_TEST)
|
|
|
|
return;
|
2005-10-15 04:49:52 +02:00
|
|
|
|
2004-10-28 20:55:08 +02:00
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
|
|
|
elog(DEBUG_elog_output, "Scan for numbers (%c), current number: '%s'", *Np->inout_p, Np->number);
|
|
|
|
#endif
|
2005-10-15 04:49:52 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-02-08 16:57:01 +01:00
|
|
|
* read digit
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (isdigit((unsigned char) *Np->inout_p))
|
|
|
|
{
|
2000-02-08 16:57:01 +01:00
|
|
|
if (Np->read_dec && Np->read_post == Np->Num->post)
|
|
|
|
return;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-02-08 16:57:01 +01:00
|
|
|
*Np->number_p = *Np->inout_p;
|
|
|
|
Np->number_p++;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-02-08 16:57:01 +01:00
|
|
|
if (Np->read_dec)
|
|
|
|
Np->read_post++;
|
2004-10-28 20:55:08 +02:00
|
|
|
else
|
|
|
|
Np->read_pre++;
|
2000-02-08 16:57:01 +01:00
|
|
|
|
2004-10-28 20:55:08 +02:00
|
|
|
isread = TRUE;
|
2005-10-15 04:49:52 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2003-07-27 06:53:12 +02:00
|
|
|
elog(DEBUG_elog_output, "Read digit (%c)", *Np->inout_p);
|
2000-04-12 19:17:23 +02:00
|
|
|
#endif
|
2005-10-15 04:49:52 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* read decimal point
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
2004-10-28 20:55:08 +02:00
|
|
|
else if (IS_DECIMAL(Np->Num) && Np->read_dec == FALSE)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2000-02-08 16:57:01 +01:00
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2003-07-27 06:53:12 +02:00
|
|
|
elog(DEBUG_elog_output, "Try read decimal point (%c)", *Np->inout_p);
|
2000-04-12 19:17:23 +02:00
|
|
|
#endif
|
|
|
|
if (*Np->inout_p == '.')
|
|
|
|
{
|
2000-02-08 16:57:01 +01:00
|
|
|
*Np->number_p = '.';
|
|
|
|
Np->number_p++;
|
|
|
|
Np->read_dec = TRUE;
|
2004-10-28 20:55:08 +02:00
|
|
|
isread = TRUE;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
int x = strlen(Np->decimal);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-02-08 16:57:01 +01:00
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2003-07-27 06:53:12 +02:00
|
|
|
elog(DEBUG_elog_output, "Try read locale point (%c)",
|
|
|
|
*Np->inout_p);
|
2000-04-12 19:17:23 +02:00
|
|
|
#endif
|
2005-10-15 04:49:52 +02:00
|
|
|
if (x && AMOUNT_TEST(x) && strncmp(Np->inout_p, Np->decimal, x) == 0)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
Np->inout_p += x - 1;
|
2000-02-08 16:57:01 +01:00
|
|
|
*Np->number_p = '.';
|
|
|
|
Np->number_p++;
|
|
|
|
Np->read_dec = TRUE;
|
2004-10-28 20:55:08 +02:00
|
|
|
isread = TRUE;
|
2000-02-08 16:57:01 +01:00
|
|
|
}
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
2004-10-28 20:55:08 +02:00
|
|
|
|
|
|
|
if (OVERLOAD_TEST)
|
|
|
|
return;
|
2005-10-15 04:49:52 +02:00
|
|
|
|
2004-10-28 20:55:08 +02:00
|
|
|
/*
|
|
|
|
* Read sign behind "last" number
|
|
|
|
*
|
2005-10-15 04:49:52 +02:00
|
|
|
* We need sign detection because determine exact position of post-sign is
|
|
|
|
* difficult:
|
2004-10-28 20:55:08 +02:00
|
|
|
*
|
2005-11-22 19:17:34 +01:00
|
|
|
* FM9999.9999999S -> 123.001- 9.9S -> .5- FM9.999999MI ->
|
|
|
|
* 5.01-
|
2004-10-28 20:55:08 +02:00
|
|
|
*/
|
|
|
|
if (*Np->number == ' ' && Np->read_pre + Np->read_post > 0)
|
|
|
|
{
|
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* locale sign (NUM_S) is always anchored behind a last number, if: -
|
|
|
|
* locale sign expected - last read char was NUM_0/9 or NUM_DEC - and
|
|
|
|
* next char is not digit
|
|
|
|
*/
|
|
|
|
if (IS_LSIGN(Np->Num) && isread &&
|
|
|
|
(Np->inout_p + 1) <= Np->inout + plen &&
|
|
|
|
!isdigit((unsigned char) *(Np->inout_p + 1)))
|
2004-10-28 20:55:08 +02:00
|
|
|
{
|
2005-10-15 04:49:52 +02:00
|
|
|
int x;
|
|
|
|
char *tmp = Np->inout_p++;
|
|
|
|
|
2004-10-28 20:55:08 +02:00
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
|
|
|
elog(DEBUG_elog_output, "Try read locale post-sign (%c)", *Np->inout_p);
|
|
|
|
#endif
|
2005-10-15 04:49:52 +02:00
|
|
|
if ((x = strlen(Np->L_negative_sign)) &&
|
2004-10-28 20:55:08 +02:00
|
|
|
AMOUNT_TEST(x) &&
|
2005-10-15 04:49:52 +02:00
|
|
|
strncmp(Np->inout_p, Np->L_negative_sign, x) == 0)
|
2004-10-28 20:55:08 +02:00
|
|
|
{
|
2005-10-15 04:49:52 +02:00
|
|
|
Np->inout_p += x - 1; /* -1 .. NUM_processor() do inout_p++ */
|
2004-10-28 20:55:08 +02:00
|
|
|
*Np->number = '-';
|
|
|
|
}
|
2005-10-15 04:49:52 +02:00
|
|
|
else if ((x = strlen(Np->L_positive_sign)) &&
|
|
|
|
AMOUNT_TEST(x) &&
|
|
|
|
strncmp(Np->inout_p, Np->L_positive_sign, x) == 0)
|
2004-10-28 20:55:08 +02:00
|
|
|
{
|
2005-10-15 04:49:52 +02:00
|
|
|
Np->inout_p += x - 1; /* -1 .. NUM_processor() do inout_p++ */
|
2004-10-28 20:55:08 +02:00
|
|
|
*Np->number = '+';
|
|
|
|
}
|
|
|
|
if (*Np->number == ' ')
|
|
|
|
/* no sign read */
|
|
|
|
Np->inout_p = tmp;
|
|
|
|
}
|
2005-10-15 04:49:52 +02:00
|
|
|
|
2004-10-28 20:55:08 +02:00
|
|
|
/*
|
|
|
|
* try read non-locale sign, it's happen only if format is not exact
|
|
|
|
* and we cannot determine sign position of MI/PL/SG, an example:
|
|
|
|
*
|
2005-10-15 04:49:52 +02:00
|
|
|
* FM9.999999MI -> 5.01-
|
2004-10-28 20:55:08 +02:00
|
|
|
*
|
2005-11-22 19:17:34 +01:00
|
|
|
* if (.... && IS_LSIGN(Np->Num)==FALSE) prevents read wrong formats
|
|
|
|
* like to_number('1 -', '9S') where sign is not anchored to last
|
|
|
|
* number.
|
2004-10-28 20:55:08 +02:00
|
|
|
*/
|
2005-10-15 04:49:52 +02:00
|
|
|
else if (isread == FALSE && IS_LSIGN(Np->Num) == FALSE &&
|
|
|
|
(IS_PLUS(Np->Num) || IS_MINUS(Np->Num)))
|
2004-10-28 20:55:08 +02:00
|
|
|
{
|
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
|
|
|
elog(DEBUG_elog_output, "Try read simple post-sign (%c)", *Np->inout_p);
|
|
|
|
#endif
|
2005-10-15 04:49:52 +02:00
|
|
|
|
2004-10-28 20:55:08 +02:00
|
|
|
/*
|
|
|
|
* simple + -
|
|
|
|
*/
|
|
|
|
if (*Np->inout_p == '-' || *Np->inout_p == '+')
|
|
|
|
/* NUM_processor() do inout_p++ */
|
|
|
|
*Np->number = *Np->inout_p;
|
|
|
|
}
|
|
|
|
}
|
2000-02-08 16:57:01 +01:00
|
|
|
}
|
|
|
|
|
2003-03-27 17:35:31 +01:00
|
|
|
#define IS_PREDEC_SPACE(_n) \
|
|
|
|
(IS_ZERO((_n)->Num)==FALSE && \
|
|
|
|
(_n)->number == (_n)->number_p && \
|
|
|
|
*(_n)->number == '0' && \
|
2003-08-04 02:43:34 +02:00
|
|
|
(_n)->Num->post != 0)
|
2003-03-27 17:35:31 +01:00
|
|
|
|
2000-02-08 16:57:01 +01:00
|
|
|
/* ----------
|
|
|
|
* Add digit or sign to number-string
|
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
static void
|
2000-04-12 19:17:23 +02:00
|
|
|
NUM_numpart_to_char(NUMProc *Np, int id)
|
|
|
|
{
|
2003-08-04 02:43:34 +02:00
|
|
|
int end;
|
|
|
|
|
2000-02-08 16:57:01 +01:00
|
|
|
if (IS_ROMAN(Np->Num))
|
|
|
|
return;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-02-08 16:57:01 +01:00
|
|
|
/* Note: in this elog() output not set '\0' in 'inout' */
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
|
|
|
|
2000-02-08 16:57:01 +01:00
|
|
|
/*
|
2000-04-12 19:17:23 +02:00
|
|
|
* Np->num_curr is number of current item in format-picture, it is not
|
|
|
|
* current position in inout!
|
|
|
|
*/
|
|
|
|
elog(DEBUG_elog_output,
|
2003-07-27 06:53:12 +02:00
|
|
|
"SIGN_WROTE: %d, CURRENT: %d, NUMBER_P: \"%s\", INOUT: \"%s\"",
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->sign_wrote,
|
|
|
|
Np->num_curr,
|
|
|
|
Np->number_p,
|
|
|
|
Np->inout);
|
|
|
|
#endif
|
2000-02-08 16:57:01 +01:00
|
|
|
Np->num_in = FALSE;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* Write sign if real number will write to output Note: IS_PREDEC_SPACE()
|
|
|
|
* handle "9.9" --> " .1"
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*/
|
2003-08-04 02:43:34 +02:00
|
|
|
if (Np->sign_wrote == FALSE &&
|
|
|
|
(Np->num_curr >= Np->num_pre || (IS_ZERO(Np->Num) && Np->Num->zero_start == Np->num_curr)) &&
|
|
|
|
(IS_PREDEC_SPACE(Np) == FALSE || (Np->last_relevant && *Np->last_relevant == '.')))
|
|
|
|
{
|
2000-04-12 19:17:23 +02:00
|
|
|
if (IS_LSIGN(Np->Num))
|
|
|
|
{
|
2003-03-27 17:35:31 +01:00
|
|
|
if (Np->Num->lsign == NUM_LSIGN_PRE)
|
|
|
|
{
|
|
|
|
if (Np->sign == '-')
|
|
|
|
strcpy(Np->inout_p, Np->L_negative_sign);
|
|
|
|
else
|
|
|
|
strcpy(Np->inout_p, Np->L_positive_sign);
|
|
|
|
Np->inout_p += strlen(Np->inout_p);
|
|
|
|
Np->sign_wrote = TRUE;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (IS_BRACKET(Np->Num))
|
|
|
|
{
|
2003-03-27 17:35:31 +01:00
|
|
|
*Np->inout_p = Np->sign == '+' ? ' ' : '<';
|
2000-02-08 16:57:01 +01:00
|
|
|
++Np->inout_p;
|
2003-03-27 17:35:31 +01:00
|
|
|
Np->sign_wrote = TRUE;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (Np->sign == '+')
|
|
|
|
{
|
2003-03-27 17:35:31 +01:00
|
|
|
if (!IS_FILLMODE(Np->Num))
|
|
|
|
{
|
2003-08-04 02:43:34 +02:00
|
|
|
*Np->inout_p = ' '; /* Write + */
|
2003-03-27 17:35:31 +01:00
|
|
|
++Np->inout_p;
|
|
|
|
}
|
|
|
|
Np->sign_wrote = TRUE;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (Np->sign == '-')
|
|
|
|
{ /* Write - */
|
2000-02-08 16:57:01 +01:00
|
|
|
*Np->inout_p = '-';
|
2000-04-12 19:17:23 +02:00
|
|
|
++Np->inout_p;
|
2003-03-27 17:35:31 +01:00
|
|
|
Np->sign_wrote = TRUE;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
}
|
2003-08-04 02:43:34 +02:00
|
|
|
|
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-02-08 16:57:01 +01:00
|
|
|
* digits / FM / Zero / Dec. point
|
|
|
|
*/
|
2003-03-27 17:35:31 +01:00
|
|
|
if (id == NUM_9 || id == NUM_0 || id == NUM_D || id == NUM_DEC)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
if (Np->num_curr < Np->num_pre &&
|
|
|
|
(Np->Num->zero_start > Np->num_curr || !IS_ZERO(Np->Num)))
|
|
|
|
{
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-04-12 19:17:23 +02:00
|
|
|
* Write blank space
|
|
|
|
*/
|
|
|
|
if (!IS_FILLMODE(Np->Num))
|
|
|
|
{
|
|
|
|
*Np->inout_p = ' '; /* Write ' ' */
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
++Np->inout_p;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (IS_ZERO(Np->Num) &&
|
|
|
|
Np->num_curr < Np->num_pre &&
|
|
|
|
Np->Num->zero_start <= Np->num_curr)
|
|
|
|
{
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-02-08 16:57:01 +01:00
|
|
|
* Write ZERO
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
*Np->inout_p = '0'; /* Write '0' */
|
2000-02-08 16:57:01 +01:00
|
|
|
++Np->inout_p;
|
|
|
|
Np->num_in = TRUE;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2003-03-10 23:28:22 +01:00
|
|
|
* Write Decimal point
|
2001-03-22 07:16:21 +01:00
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (*Np->number_p == '.')
|
|
|
|
{
|
|
|
|
if (!Np->last_relevant || *Np->last_relevant != '.')
|
|
|
|
{
|
2000-02-08 16:57:01 +01:00
|
|
|
strcpy(Np->inout_p, Np->decimal); /* Write DEC/D */
|
|
|
|
Np->inout_p += strlen(Np->inout_p);
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
2003-08-04 02:43:34 +02:00
|
|
|
|
2002-09-20 05:57:09 +02:00
|
|
|
/*
|
|
|
|
* Ora 'n' -- FM9.9 --> 'n.'
|
|
|
|
*/
|
2003-08-04 02:43:34 +02:00
|
|
|
else if (IS_FILLMODE(Np->Num) &&
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->last_relevant && *Np->last_relevant == '.')
|
|
|
|
{
|
2000-02-08 16:57:01 +01:00
|
|
|
strcpy(Np->inout_p, Np->decimal); /* Write DEC/D */
|
|
|
|
Np->inout_p += strlen(Np->inout_p);
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-02-08 16:57:01 +01:00
|
|
|
* Write Digits
|
|
|
|
*/
|
|
|
|
if (Np->last_relevant && Np->number_p > Np->last_relevant &&
|
2000-04-12 19:17:23 +02:00
|
|
|
id != NUM_0)
|
2000-02-08 16:57:01 +01:00
|
|
|
;
|
2003-08-04 02:43:34 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
/*
|
2003-03-27 17:35:31 +01:00
|
|
|
* '0.1' -- 9.9 --> ' .1'
|
2000-02-08 16:57:01 +01:00
|
|
|
*/
|
2003-03-27 17:35:31 +01:00
|
|
|
else if (IS_PREDEC_SPACE(Np))
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
if (!IS_FILLMODE(Np->Num))
|
|
|
|
{
|
2000-02-08 16:57:01 +01:00
|
|
|
*Np->inout_p = ' ';
|
|
|
|
++Np->inout_p;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
2003-08-04 02:43:34 +02:00
|
|
|
|
2002-09-20 05:57:09 +02:00
|
|
|
/*
|
2003-03-27 17:35:31 +01:00
|
|
|
* '0' -- FM9.9 --> '0.'
|
2002-09-20 05:57:09 +02:00
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
else if (Np->last_relevant && *Np->last_relevant == '.')
|
|
|
|
{
|
2000-02-08 16:57:01 +01:00
|
|
|
*Np->inout_p = '0';
|
|
|
|
++Np->inout_p;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*Np->inout_p = *Np->number_p; /* Write DIGIT */
|
2000-02-08 16:57:01 +01:00
|
|
|
++Np->inout_p;
|
|
|
|
Np->num_in = TRUE;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2000-02-08 16:57:01 +01:00
|
|
|
++Np->number_p;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
2003-03-27 17:35:31 +01:00
|
|
|
|
2003-03-27 18:10:55 +01:00
|
|
|
end = Np->num_count + (Np->num_pre ? 1 : 0) + (IS_DECIMAL(Np->Num) ? 1 : 0);
|
2003-08-04 02:43:34 +02:00
|
|
|
|
2003-03-27 17:35:31 +01:00
|
|
|
if (Np->last_relevant && Np->last_relevant == Np->number_p)
|
|
|
|
end = Np->num_curr;
|
2003-08-04 02:43:34 +02:00
|
|
|
|
|
|
|
if (Np->num_curr + 1 == end)
|
2003-03-27 17:35:31 +01:00
|
|
|
{
|
|
|
|
if (Np->sign_wrote == TRUE && IS_BRACKET(Np->Num))
|
|
|
|
{
|
|
|
|
*Np->inout_p = Np->sign == '+' ? ' ' : '>';
|
|
|
|
++Np->inout_p;
|
|
|
|
}
|
|
|
|
else if (IS_LSIGN(Np->Num) && Np->Num->lsign == NUM_LSIGN_POST)
|
|
|
|
{
|
|
|
|
if (Np->sign == '-')
|
|
|
|
strcpy(Np->inout_p, Np->L_negative_sign);
|
|
|
|
else
|
|
|
|
strcpy(Np->inout_p, Np->L_positive_sign);
|
|
|
|
Np->inout_p += strlen(Np->inout_p);
|
|
|
|
}
|
|
|
|
}
|
2000-02-08 16:57:01 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-02-08 16:57:01 +01:00
|
|
|
++Np->num_curr;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-09-12 06:01:57 +02:00
|
|
|
/*
|
|
|
|
* Note: 'plen' is used in FROM_CHAR conversion and it's length of
|
|
|
|
* input (inout). In TO_CHAR conversion it's space before first number.
|
|
|
|
*/
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
static char *
|
2000-04-12 19:17:23 +02:00
|
|
|
NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
|
2005-08-17 23:47:55 +02:00
|
|
|
int plen, int sign, bool is_to_char)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
{
|
2000-04-12 19:17:23 +02:00
|
|
|
FormatNode *n;
|
2001-03-22 05:01:46 +01:00
|
|
|
NUMProc _Np,
|
|
|
|
*Np = &_Np;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2003-04-02 04:33:52 +02:00
|
|
|
MemSet(Np, 0, sizeof(NUMProc));
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->Num = Num;
|
2005-08-17 23:47:55 +02:00
|
|
|
Np->is_to_char = is_to_char;
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->number = number;
|
|
|
|
Np->inout = inout;
|
2000-02-08 16:57:01 +01:00
|
|
|
Np->last_relevant = NULL;
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->read_post = 0;
|
2005-10-15 04:49:52 +02:00
|
|
|
Np->read_pre = 0;
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->read_dec = FALSE;
|
2000-02-08 16:57:01 +01:00
|
|
|
|
|
|
|
if (Np->Num->zero_start)
|
|
|
|
--Np->Num->zero_start;
|
2003-08-04 02:43:34 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-04-12 19:17:23 +02:00
|
|
|
* Roman correction
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (IS_ROMAN(Np->Num))
|
|
|
|
{
|
2005-08-17 23:47:55 +02:00
|
|
|
if (!Np->is_to_char)
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
|
|
|
errmsg("\"RN\" not supported")));
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
Np->Num->lsign = Np->Num->pre_lsign_num = Np->Num->post =
|
|
|
|
Np->Num->pre = Np->num_pre = Np->sign = 0;
|
|
|
|
|
|
|
|
if (IS_FILLMODE(Np->Num))
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
Np->Num->flag = 0;
|
|
|
|
Np->Num->flag |= NUM_F_FILLMODE;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
Np->Num->flag = 0;
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->Num->flag |= NUM_F_ROMAN;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-02-08 16:57:01 +01:00
|
|
|
* Sign
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*/
|
2005-08-17 23:47:55 +02:00
|
|
|
if (is_to_char)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
Np->sign = sign;
|
2003-08-04 02:43:34 +02:00
|
|
|
|
2003-03-27 17:35:31 +01:00
|
|
|
/* MI/PL/SG - write sign itself and not in number */
|
|
|
|
if (IS_PLUS(Np->Num) || IS_MINUS(Np->Num))
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2003-08-04 02:43:34 +02:00
|
|
|
if (IS_PLUS(Np->Num) && IS_MINUS(Np->Num) == FALSE)
|
|
|
|
Np->sign_wrote = FALSE; /* need sign */
|
2003-04-02 04:33:52 +02:00
|
|
|
else
|
2003-08-04 02:43:34 +02:00
|
|
|
Np->sign_wrote = TRUE; /* needn't sign */
|
2000-02-08 16:57:01 +01:00
|
|
|
}
|
|
|
|
else
|
2003-03-27 17:35:31 +01:00
|
|
|
{
|
|
|
|
if (Np->sign != '-')
|
|
|
|
{
|
|
|
|
if (IS_BRACKET(Np->Num) && IS_FILLMODE(Np->Num))
|
|
|
|
Np->Num->flag &= ~NUM_F_BRACKET;
|
|
|
|
if (IS_MINUS(Np->Num))
|
|
|
|
Np->Num->flag &= ~NUM_F_MINUS;
|
|
|
|
}
|
|
|
|
else if (Np->sign != '+' && IS_PLUS(Np->Num))
|
|
|
|
Np->Num->flag &= ~NUM_F_PLUS;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
if (Np->sign == '+' && IS_FILLMODE(Np->Num) && IS_LSIGN(Np->Num) == FALSE)
|
|
|
|
Np->sign_wrote = TRUE; /* needn't sign */
|
2003-03-27 17:35:31 +01:00
|
|
|
else
|
2003-08-04 02:43:34 +02:00
|
|
|
Np->sign_wrote = FALSE; /* need sign */
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2003-03-27 17:35:31 +01:00
|
|
|
if (Np->Num->lsign == NUM_LSIGN_PRE && Np->Num->pre == Np->Num->pre_lsign_num)
|
|
|
|
Np->Num->lsign = NUM_LSIGN_POST;
|
|
|
|
}
|
2000-02-08 16:57:01 +01:00
|
|
|
}
|
2005-08-17 23:47:55 +02:00
|
|
|
else
|
|
|
|
Np->sign = FALSE;
|
2000-02-08 16:57:01 +01:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-02-08 16:57:01 +01:00
|
|
|
* Count
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->num_count = Np->Num->post + Np->Num->pre - 1;
|
2000-02-08 16:57:01 +01:00
|
|
|
|
2005-08-17 23:47:55 +02:00
|
|
|
if (is_to_char)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2000-02-08 16:57:01 +01:00
|
|
|
Np->num_pre = plen;
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
if (IS_FILLMODE(Np->Num))
|
|
|
|
{
|
2000-02-08 16:57:01 +01:00
|
|
|
if (IS_DECIMAL(Np->Num))
|
|
|
|
Np->last_relevant = get_last_relevant_decnum(
|
2003-08-04 02:43:34 +02:00
|
|
|
Np->number +
|
2005-10-15 04:49:52 +02:00
|
|
|
((Np->Num->zero_end - Np->num_pre > 0) ?
|
|
|
|
Np->Num->zero_end - Np->num_pre : 0));
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
if (Np->sign_wrote == FALSE && Np->num_pre == 0)
|
2000-02-08 16:57:01 +01:00
|
|
|
++Np->num_count;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-02-08 16:57:01 +01:00
|
|
|
Np->num_pre = 0;
|
2000-04-12 19:17:23 +02:00
|
|
|
*Np->number = ' '; /* sign space */
|
|
|
|
*(Np->number + 1) = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
Np->num_in = 0;
|
|
|
|
Np->num_curr = 0;
|
|
|
|
|
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
|
|
|
elog(DEBUG_elog_output,
|
2003-03-27 17:35:31 +01:00
|
|
|
"\n\tSIGN: '%c'\n\tNUM: '%s'\n\tPRE: %d\n\tPOST: %d\n\tNUM_COUNT: %d\n\tNUM_PRE: %d\n\tSIGN_WROTE: %s\n\tZERO: %s\n\tZERO_START: %d\n\tZERO_END: %d\n\tLAST_RELEVANT: %s\n\tBRACKET: %s\n\tPLUS: %s\n\tMINUS: %s\n\tFILLMODE: %s\n\tROMAN: %s",
|
|
|
|
Np->sign,
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->number,
|
|
|
|
Np->Num->pre,
|
|
|
|
Np->Num->post,
|
|
|
|
Np->num_count,
|
|
|
|
Np->num_pre,
|
|
|
|
Np->sign_wrote ? "Yes" : "No",
|
|
|
|
IS_ZERO(Np->Num) ? "Yes" : "No",
|
|
|
|
Np->Num->zero_start,
|
|
|
|
Np->Num->zero_end,
|
2003-03-27 17:35:31 +01:00
|
|
|
Np->last_relevant ? Np->last_relevant : "<not set>",
|
|
|
|
IS_BRACKET(Np->Num) ? "Yes" : "No",
|
|
|
|
IS_PLUS(Np->Num) ? "Yes" : "No",
|
|
|
|
IS_MINUS(Np->Num) ? "Yes" : "No",
|
|
|
|
IS_FILLMODE(Np->Num) ? "Yes" : "No",
|
|
|
|
IS_ROMAN(Np->Num) ? "Yes" : "No"
|
2003-08-04 02:43:34 +02:00
|
|
|
);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
#endif
|
2000-02-08 16:57:01 +01:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* Locale
|
|
|
|
*/
|
|
|
|
NUM_prepare_locale(Np);
|
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* Processor direct cycle
|
|
|
|
*/
|
2005-08-17 23:47:55 +02:00
|
|
|
if (Np->is_to_char)
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->number_p = Np->number;
|
2005-08-17 23:47:55 +02:00
|
|
|
else
|
|
|
|
Np->number_p = Np->number + 1; /* first char is space for sign */
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
for (n = node, Np->inout_p = Np->inout; n->type != NODE_TYPE_END; n++)
|
|
|
|
{
|
2005-08-17 23:47:55 +02:00
|
|
|
if (!Np->is_to_char)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* Check non-string inout end
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (Np->inout_p >= Np->inout + plen)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
break;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* Format pictures actions
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (n->type == NODE_TYPE_ACTION)
|
|
|
|
{
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-04-12 19:17:23 +02:00
|
|
|
* Create/reading digit/zero/blank/sing
|
2004-10-28 20:55:08 +02:00
|
|
|
*
|
2005-10-15 04:49:52 +02:00
|
|
|
* 'NUM_S' note: The locale sign is anchored to number and we
|
|
|
|
* read/write it when we work with first or last number
|
|
|
|
* (NUM_0/NUM_9). This is reason why NUM_S missing in follow
|
|
|
|
* switch().
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
switch (n->key->id)
|
|
|
|
{
|
|
|
|
case NUM_9:
|
|
|
|
case NUM_0:
|
|
|
|
case NUM_DEC:
|
|
|
|
case NUM_D:
|
2005-08-17 23:47:55 +02:00
|
|
|
if (Np->is_to_char)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
NUM_numpart_to_char(Np, n->key->id);
|
|
|
|
continue; /* for() */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NUM_numpart_from_char(Np, n->key->id, plen);
|
|
|
|
break; /* switch() case: */
|
|
|
|
}
|
|
|
|
|
|
|
|
case NUM_COMMA:
|
2005-08-17 23:47:55 +02:00
|
|
|
if (Np->is_to_char)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
if (!Np->num_in)
|
|
|
|
{
|
|
|
|
if (IS_FILLMODE(Np->Num))
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
*Np->inout_p = ' ';
|
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
else
|
2000-04-12 19:17:23 +02:00
|
|
|
*Np->inout_p = ',';
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2005-08-17 23:47:55 +02:00
|
|
|
else
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
if (!Np->num_in)
|
|
|
|
{
|
|
|
|
if (IS_FILLMODE(Np->Num))
|
|
|
|
continue;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NUM_G:
|
2005-08-17 23:47:55 +02:00
|
|
|
if (Np->is_to_char)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
if (!Np->num_in)
|
|
|
|
{
|
|
|
|
if (IS_FILLMODE(Np->Num))
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int x = strlen(Np->L_thousands_sep);
|
|
|
|
|
|
|
|
memset(Np->inout_p, ' ', x);
|
|
|
|
Np->inout_p += x - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy(Np->inout_p, Np->L_thousands_sep);
|
|
|
|
Np->inout_p += strlen(Np->inout_p) - 1;
|
|
|
|
}
|
|
|
|
}
|
2005-08-17 23:47:55 +02:00
|
|
|
else
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
if (!Np->num_in)
|
|
|
|
{
|
|
|
|
if (IS_FILLMODE(Np->Num))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Np->inout_p += strlen(Np->L_thousands_sep) - 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NUM_L:
|
2005-08-17 23:47:55 +02:00
|
|
|
if (Np->is_to_char)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
strcpy(Np->inout_p, Np->L_currency_symbol);
|
|
|
|
Np->inout_p += strlen(Np->inout_p) - 1;
|
|
|
|
}
|
2005-08-17 23:47:55 +02:00
|
|
|
else
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->inout_p += strlen(Np->L_currency_symbol) - 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NUM_RN:
|
|
|
|
if (IS_FILLMODE(Np->Num))
|
|
|
|
{
|
|
|
|
strcpy(Np->inout_p, Np->number_p);
|
|
|
|
Np->inout_p += strlen(Np->inout_p) - 1;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2000-02-08 16:57:01 +01:00
|
|
|
else
|
2001-12-05 03:06:19 +01:00
|
|
|
{
|
|
|
|
sprintf(Np->inout_p, "%15s", Np->number_p);
|
|
|
|
Np->inout_p += strlen(Np->inout_p) - 1;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
break;
|
2001-10-25 07:50:21 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
case NUM_rn:
|
|
|
|
if (IS_FILLMODE(Np->Num))
|
|
|
|
{
|
2008-07-12 02:44:38 +02:00
|
|
|
strcpy(Np->inout_p, str_tolower_z(Np->number_p));
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->inout_p += strlen(Np->inout_p) - 1;
|
|
|
|
}
|
|
|
|
else
|
2001-12-05 03:06:19 +01:00
|
|
|
{
|
2008-07-12 02:44:38 +02:00
|
|
|
sprintf(Np->inout_p, "%15s", str_tolower_z(Np->number_p));
|
2001-12-05 03:06:19 +01:00
|
|
|
Np->inout_p += strlen(Np->inout_p) - 1;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NUM_th:
|
|
|
|
if (IS_ROMAN(Np->Num) || *Np->number == '#' ||
|
|
|
|
Np->sign == '-' || IS_DECIMAL(Np->Num))
|
|
|
|
continue;
|
|
|
|
|
2005-08-17 23:47:55 +02:00
|
|
|
if (Np->is_to_char)
|
2000-04-12 19:17:23 +02:00
|
|
|
strcpy(Np->inout_p, get_th(Np->number, TH_LOWER));
|
|
|
|
Np->inout_p += 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NUM_TH:
|
|
|
|
if (IS_ROMAN(Np->Num) || *Np->number == '#' ||
|
|
|
|
Np->sign == '-' || IS_DECIMAL(Np->Num))
|
|
|
|
continue;
|
|
|
|
|
2005-08-17 23:47:55 +02:00
|
|
|
if (Np->is_to_char)
|
2000-04-12 19:17:23 +02:00
|
|
|
strcpy(Np->inout_p, get_th(Np->number, TH_UPPER));
|
|
|
|
Np->inout_p += 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NUM_MI:
|
2005-08-17 23:47:55 +02:00
|
|
|
if (Np->is_to_char)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
if (Np->sign == '-')
|
|
|
|
*Np->inout_p = '-';
|
2003-03-27 17:35:31 +01:00
|
|
|
else if (IS_FILLMODE(Np->Num))
|
|
|
|
continue;
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
|
|
|
*Np->inout_p = ' ';
|
|
|
|
}
|
2005-08-17 23:47:55 +02:00
|
|
|
else
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
if (*Np->inout_p == '-')
|
|
|
|
*Np->number = '-';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NUM_PL:
|
2005-08-17 23:47:55 +02:00
|
|
|
if (Np->is_to_char)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
if (Np->sign == '+')
|
|
|
|
*Np->inout_p = '+';
|
2003-03-27 17:35:31 +01:00
|
|
|
else if (IS_FILLMODE(Np->Num))
|
|
|
|
continue;
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
|
|
|
*Np->inout_p = ' ';
|
|
|
|
}
|
2005-08-17 23:47:55 +02:00
|
|
|
else
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
if (*Np->inout_p == '+')
|
|
|
|
*Np->number = '+';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NUM_SG:
|
2005-08-17 23:47:55 +02:00
|
|
|
if (Np->is_to_char)
|
2000-04-12 19:17:23 +02:00
|
|
|
*Np->inout_p = Np->sign;
|
|
|
|
|
2005-08-17 23:47:55 +02:00
|
|
|
else
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
if (*Np->inout_p == '-')
|
|
|
|
*Np->number = '-';
|
|
|
|
else if (*Np->inout_p == '+')
|
|
|
|
*Np->number = '+';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
break;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* Remove to output char from input in TO_CHAR
|
|
|
|
*/
|
2005-08-17 23:47:55 +02:00
|
|
|
if (Np->is_to_char)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*Np->inout_p = n->character;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->inout_p++;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2005-08-17 23:47:55 +02:00
|
|
|
if (Np->is_to_char)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*Np->inout_p = '\0';
|
2000-04-12 19:17:23 +02:00
|
|
|
return Np->inout;
|
|
|
|
}
|
2005-08-17 23:47:55 +02:00
|
|
|
else
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
if (*(Np->number_p - 1) == '.')
|
|
|
|
*(Np->number_p - 1) = '\0';
|
2000-02-08 16:57:01 +01:00
|
|
|
else
|
|
|
|
*Np->number_p = '\0';
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-02-08 16:57:01 +01:00
|
|
|
* Correction - precision of dec. number
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->Num->post = Np->read_post;
|
2000-02-08 16:57:01 +01:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2000-04-12 19:17:23 +02:00
|
|
|
elog(DEBUG_elog_output, "TO_NUMBER (number): '%s'", Np->number);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
#endif
|
|
|
|
return Np->number;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* MACRO: Start part of NUM - for all NUM's to_char variants
|
|
|
|
* (sorry, but I hate copy same code - macro is better..)
|
|
|
|
* ----------
|
|
|
|
*/
|
2000-07-03 18:01:33 +02:00
|
|
|
#define NUM_TOCHAR_prepare \
|
|
|
|
do { \
|
2008-03-25 23:42:46 +01:00
|
|
|
len = VARSIZE_ANY_EXHDR(fmt); \
|
2007-06-29 03:51:35 +02:00
|
|
|
if (len <= 0 || len >= (INT_MAX-VARHDRSZ)/NUM_MAX_ITEM_SIZ) \
|
2008-03-25 23:42:46 +01:00
|
|
|
PG_RETURN_TEXT_P(cstring_to_text("")); \
|
2007-06-29 03:51:35 +02:00
|
|
|
result = (text *) palloc0((len * NUM_MAX_ITEM_SIZ) + 1 + VARHDRSZ); \
|
2008-03-25 23:42:46 +01:00
|
|
|
format = NUM_cache(len, &Num, fmt, &shouldFree); \
|
2000-07-06 01:12:09 +02:00
|
|
|
} while (0)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* MACRO: Finish part of NUM
|
|
|
|
* ----------
|
|
|
|
*/
|
2000-07-03 18:01:33 +02:00
|
|
|
#define NUM_TOCHAR_finish \
|
|
|
|
do { \
|
2007-11-15 22:14:46 +01:00
|
|
|
NUM_processor(format, &Num, VARDATA(result), numstr, plen, sign, true); \
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
\
|
2007-06-29 03:51:35 +02:00
|
|
|
if (shouldFree) \
|
|
|
|
pfree(format); \
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
\
|
2007-06-29 03:51:35 +02:00
|
|
|
/* \
|
|
|
|
* Convert null-terminated representation of result to standard text. \
|
|
|
|
* The result is usually much bigger than it needs to be, but there \
|
|
|
|
* seems little point in realloc'ing it smaller. \
|
2000-03-16 02:35:41 +01:00
|
|
|
*/ \
|
2007-06-29 03:51:35 +02:00
|
|
|
len = strlen(VARDATA(result)); \
|
|
|
|
SET_VARSIZE(result, len + VARHDRSZ); \
|
|
|
|
} while (0)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
/* -------------------
|
2000-04-12 19:17:23 +02:00
|
|
|
* NUMERIC to_number() (convert string to numeric)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* -------------------
|
|
|
|
*/
|
2000-07-01 23:27:14 +02:00
|
|
|
Datum
|
|
|
|
numeric_to_number(PG_FUNCTION_ARGS)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
text *value = PG_GETARG_TEXT_P(0);
|
|
|
|
text *fmt = PG_GETARG_TEXT_P(1);
|
|
|
|
NUMDesc Num;
|
|
|
|
Datum result;
|
2000-04-12 19:17:23 +02:00
|
|
|
FormatNode *format;
|
2001-03-22 05:01:46 +01:00
|
|
|
char *numstr;
|
2002-09-20 05:54:57 +02:00
|
|
|
bool shouldFree;
|
2001-03-22 05:01:46 +01:00
|
|
|
int len = 0;
|
|
|
|
int scale,
|
|
|
|
precision;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
len = VARSIZE(fmt) - VARHDRSZ;
|
|
|
|
|
2007-11-15 22:14:46 +01:00
|
|
|
if (len <= 0 || len >= INT_MAX / NUM_MAX_ITEM_SIZ)
|
2000-07-01 23:27:14 +02:00
|
|
|
PG_RETURN_NULL();
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
2008-03-25 23:42:46 +01:00
|
|
|
format = NUM_cache(len, &Num, fmt, &shouldFree);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
numstr = (char *) palloc((len * NUM_MAX_ITEM_SIZ) + 1);
|
|
|
|
|
|
|
|
NUM_processor(format, &Num, VARDATA(value), numstr,
|
2005-08-17 23:47:55 +02:00
|
|
|
VARSIZE(value) - VARHDRSZ, 0, false);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-02-08 16:57:01 +01:00
|
|
|
scale = Num.post;
|
2002-02-18 15:25:40 +01:00
|
|
|
precision = Max(0, Num.pre) + scale;
|
2000-03-16 02:35:41 +01:00
|
|
|
|
2002-09-20 05:54:57 +02:00
|
|
|
if (shouldFree)
|
2000-03-16 02:35:41 +01:00
|
|
|
pfree(format);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-07-01 23:27:14 +02:00
|
|
|
result = DirectFunctionCall3(numeric_in,
|
2001-03-22 05:01:46 +01:00
|
|
|
CStringGetDatum(numstr),
|
|
|
|
ObjectIdGetDatum(InvalidOid),
|
2005-10-15 04:49:52 +02:00
|
|
|
Int32GetDatum(((precision << 16) | scale) + VARHDRSZ));
|
2000-03-16 02:35:41 +01:00
|
|
|
pfree(numstr);
|
|
|
|
return result;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------
|
|
|
|
* NUMERIC to_char()
|
|
|
|
* ------------------
|
2000-04-12 19:17:23 +02:00
|
|
|
*/
|
2000-07-01 23:27:14 +02:00
|
|
|
Datum
|
|
|
|
numeric_to_char(PG_FUNCTION_ARGS)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
Numeric value = PG_GETARG_NUMERIC(0);
|
|
|
|
text *fmt = PG_GETARG_TEXT_P(1);
|
|
|
|
NUMDesc Num;
|
2000-04-12 19:17:23 +02:00
|
|
|
FormatNode *format;
|
2007-06-29 03:51:35 +02:00
|
|
|
text *result;
|
2002-09-20 05:54:57 +02:00
|
|
|
bool shouldFree;
|
2001-03-22 05:01:46 +01:00
|
|
|
int len = 0,
|
|
|
|
plen = 0,
|
|
|
|
sign = 0;
|
|
|
|
char *numstr,
|
|
|
|
*orgnum,
|
|
|
|
*p;
|
|
|
|
Numeric x;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
NUM_TOCHAR_prepare;
|
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* On DateType depend part (numeric)
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (IS_ROMAN(&Num))
|
|
|
|
{
|
2000-07-01 23:27:14 +02:00
|
|
|
x = DatumGetNumeric(DirectFunctionCall2(numeric_round,
|
2001-03-22 05:01:46 +01:00
|
|
|
NumericGetDatum(value),
|
|
|
|
Int32GetDatum(0)));
|
2000-07-29 05:26:51 +02:00
|
|
|
numstr = orgnum =
|
|
|
|
int_to_roman(DatumGetInt32(DirectFunctionCall1(numeric_int4,
|
2005-10-15 04:49:52 +02:00
|
|
|
NumericGetDatum(x))));
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Numeric val = value;
|
|
|
|
|
|
|
|
if (IS_MULTI(&Num))
|
|
|
|
{
|
2000-07-01 23:27:14 +02:00
|
|
|
Numeric a = DatumGetNumeric(DirectFunctionCall1(int4_numeric,
|
2005-10-15 04:49:52 +02:00
|
|
|
Int32GetDatum(10)));
|
2000-07-01 23:27:14 +02:00
|
|
|
Numeric b = DatumGetNumeric(DirectFunctionCall1(int4_numeric,
|
2005-10-15 04:49:52 +02:00
|
|
|
Int32GetDatum(Num.multi)));
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-07-29 05:26:51 +02:00
|
|
|
x = DatumGetNumeric(DirectFunctionCall2(numeric_power,
|
|
|
|
NumericGetDatum(a),
|
|
|
|
NumericGetDatum(b)));
|
|
|
|
val = DatumGetNumeric(DirectFunctionCall2(numeric_mul,
|
2005-10-15 04:49:52 +02:00
|
|
|
NumericGetDatum(value),
|
|
|
|
NumericGetDatum(x)));
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
Num.pre += Num.multi;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-07-01 23:27:14 +02:00
|
|
|
x = DatumGetNumeric(DirectFunctionCall2(numeric_round,
|
2001-03-22 05:01:46 +01:00
|
|
|
NumericGetDatum(val),
|
|
|
|
Int32GetDatum(Num.post)));
|
2000-07-01 23:27:14 +02:00
|
|
|
orgnum = DatumGetCString(DirectFunctionCall1(numeric_out,
|
2001-03-22 05:01:46 +01:00
|
|
|
NumericGetDatum(x)));
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (*orgnum == '-')
|
2007-06-29 03:51:35 +02:00
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
sign = '-';
|
2000-04-12 19:17:23 +02:00
|
|
|
numstr = orgnum + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
sign = '+';
|
|
|
|
numstr = orgnum;
|
|
|
|
}
|
|
|
|
if ((p = strchr(numstr, '.')))
|
2000-04-12 19:17:23 +02:00
|
|
|
len = p - numstr;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
else
|
|
|
|
len = strlen(numstr);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (Num.pre > len)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
plen = Num.pre - len;
|
2000-04-12 19:17:23 +02:00
|
|
|
else if (len > Num.pre)
|
|
|
|
{
|
2007-06-29 03:51:35 +02:00
|
|
|
numstr = (char *) palloc(Num.pre + Num.post + 2);
|
|
|
|
fill_str(numstr, '#', Num.pre + Num.post + 1);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*(numstr + Num.pre) = '.';
|
2000-03-16 02:35:41 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
2000-02-08 16:57:01 +01:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
NUM_TOCHAR_finish;
|
2000-07-01 23:27:14 +02:00
|
|
|
PG_RETURN_TEXT_P(result);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------
|
|
|
|
* INT4 to_char()
|
|
|
|
* ---------------
|
2000-04-12 19:17:23 +02:00
|
|
|
*/
|
2000-07-01 23:27:14 +02:00
|
|
|
Datum
|
|
|
|
int4_to_char(PG_FUNCTION_ARGS)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
int32 value = PG_GETARG_INT32(0);
|
|
|
|
text *fmt = PG_GETARG_TEXT_P(1);
|
|
|
|
NUMDesc Num;
|
2000-04-12 19:17:23 +02:00
|
|
|
FormatNode *format;
|
2007-06-29 03:51:35 +02:00
|
|
|
text *result;
|
2002-09-20 05:54:57 +02:00
|
|
|
bool shouldFree;
|
2001-03-22 05:01:46 +01:00
|
|
|
int len = 0,
|
|
|
|
plen = 0,
|
|
|
|
sign = 0;
|
|
|
|
char *numstr,
|
|
|
|
*orgnum;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
NUM_TOCHAR_prepare;
|
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* On DateType depend part (int32)
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (IS_ROMAN(&Num))
|
|
|
|
numstr = orgnum = int_to_roman(value);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (IS_MULTI(&Num))
|
|
|
|
{
|
2000-06-05 09:29:25 +02:00
|
|
|
orgnum = DatumGetCString(DirectFunctionCall1(int4out,
|
2001-03-22 05:01:46 +01:00
|
|
|
Int32GetDatum(value * ((int32) pow((double) 10, (double) Num.multi)))));
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
Num.pre += Num.multi;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
2000-06-05 09:29:25 +02:00
|
|
|
{
|
|
|
|
orgnum = DatumGetCString(DirectFunctionCall1(int4out,
|
2005-10-15 04:49:52 +02:00
|
|
|
Int32GetDatum(value)));
|
2000-06-05 09:29:25 +02:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (*orgnum == '-')
|
2007-06-29 03:51:35 +02:00
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
sign = '-';
|
2007-06-29 03:51:35 +02:00
|
|
|
orgnum++;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
sign = '+';
|
2007-06-29 03:51:35 +02:00
|
|
|
len = strlen(orgnum);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (Num.post)
|
|
|
|
{
|
2000-12-01 06:17:19 +01:00
|
|
|
numstr = (char *) palloc(len + Num.post + 2);
|
2007-06-29 03:51:35 +02:00
|
|
|
strcpy(numstr, orgnum);
|
2000-04-12 19:17:23 +02:00
|
|
|
*(numstr + len) = '.';
|
2007-06-29 03:51:35 +02:00
|
|
|
memset(numstr + len + 1, '0', Num.post);
|
2000-12-01 06:17:19 +01:00
|
|
|
*(numstr + len + Num.post + 1) = '\0';
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
2007-06-29 03:51:35 +02:00
|
|
|
numstr = orgnum;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (Num.pre > len)
|
|
|
|
plen = Num.pre - len;
|
|
|
|
else if (len > Num.pre)
|
|
|
|
{
|
2007-06-29 03:51:35 +02:00
|
|
|
numstr = (char *) palloc(Num.pre + Num.post + 2);
|
|
|
|
fill_str(numstr, '#', Num.pre + Num.post + 1);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*(numstr + Num.pre) = '.';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NUM_TOCHAR_finish;
|
2000-07-01 23:27:14 +02:00
|
|
|
PG_RETURN_TEXT_P(result);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------
|
|
|
|
* INT8 to_char()
|
|
|
|
* ---------------
|
2000-04-12 19:17:23 +02:00
|
|
|
*/
|
2000-07-01 23:27:14 +02:00
|
|
|
Datum
|
|
|
|
int8_to_char(PG_FUNCTION_ARGS)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
int64 value = PG_GETARG_INT64(0);
|
|
|
|
text *fmt = PG_GETARG_TEXT_P(1);
|
|
|
|
NUMDesc Num;
|
2000-04-12 19:17:23 +02:00
|
|
|
FormatNode *format;
|
2007-06-29 03:51:35 +02:00
|
|
|
text *result;
|
2002-09-20 05:54:57 +02:00
|
|
|
bool shouldFree;
|
2001-03-22 05:01:46 +01:00
|
|
|
int len = 0,
|
|
|
|
plen = 0,
|
|
|
|
sign = 0;
|
|
|
|
char *numstr,
|
|
|
|
*orgnum;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
NUM_TOCHAR_prepare;
|
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* On DateType depend part (int32)
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (IS_ROMAN(&Num))
|
|
|
|
{
|
2000-07-01 23:27:14 +02:00
|
|
|
/* Currently don't support int8 conversion to roman... */
|
|
|
|
numstr = orgnum = int_to_roman(DatumGetInt32(
|
2005-10-15 04:49:52 +02:00
|
|
|
DirectFunctionCall1(int84, Int64GetDatum(value))));
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (IS_MULTI(&Num))
|
|
|
|
{
|
|
|
|
double multi = pow((double) 10, (double) Num.multi);
|
|
|
|
|
2000-07-01 23:27:14 +02:00
|
|
|
value = DatumGetInt64(DirectFunctionCall2(int8mul,
|
2005-10-15 04:49:52 +02:00
|
|
|
Int64GetDatum(value),
|
|
|
|
DirectFunctionCall1(dtoi8,
|
|
|
|
Float8GetDatum(multi))));
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
Num.pre += Num.multi;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
2000-07-01 23:27:14 +02:00
|
|
|
|
|
|
|
orgnum = DatumGetCString(DirectFunctionCall1(int8out,
|
2005-10-15 04:49:52 +02:00
|
|
|
Int64GetDatum(value)));
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (*orgnum == '-')
|
2007-06-29 03:51:35 +02:00
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
sign = '-';
|
2007-06-29 03:51:35 +02:00
|
|
|
orgnum++;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
sign = '+';
|
2007-06-29 03:51:35 +02:00
|
|
|
len = strlen(orgnum);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (Num.post)
|
|
|
|
{
|
2000-12-01 06:17:19 +01:00
|
|
|
numstr = (char *) palloc(len + Num.post + 2);
|
2007-06-29 03:51:35 +02:00
|
|
|
strcpy(numstr, orgnum);
|
2000-04-12 19:17:23 +02:00
|
|
|
*(numstr + len) = '.';
|
2007-06-29 03:51:35 +02:00
|
|
|
memset(numstr + len + 1, '0', Num.post);
|
2000-12-01 06:17:19 +01:00
|
|
|
*(numstr + len + Num.post + 1) = '\0';
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
2007-06-29 03:51:35 +02:00
|
|
|
numstr = orgnum;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (Num.pre > len)
|
|
|
|
plen = Num.pre - len;
|
|
|
|
else if (len > Num.pre)
|
|
|
|
{
|
2007-06-29 03:51:35 +02:00
|
|
|
numstr = (char *) palloc(Num.pre + Num.post + 2);
|
|
|
|
fill_str(numstr, '#', Num.pre + Num.post + 1);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*(numstr + Num.pre) = '.';
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
NUM_TOCHAR_finish;
|
2000-07-01 23:27:14 +02:00
|
|
|
PG_RETURN_TEXT_P(result);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -----------------
|
|
|
|
* FLOAT4 to_char()
|
|
|
|
* -----------------
|
2000-04-12 19:17:23 +02:00
|
|
|
*/
|
2000-07-01 23:27:14 +02:00
|
|
|
Datum
|
|
|
|
float4_to_char(PG_FUNCTION_ARGS)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
float4 value = PG_GETARG_FLOAT4(0);
|
|
|
|
text *fmt = PG_GETARG_TEXT_P(1);
|
|
|
|
NUMDesc Num;
|
2000-04-12 19:17:23 +02:00
|
|
|
FormatNode *format;
|
2007-06-29 03:51:35 +02:00
|
|
|
text *result;
|
2002-09-20 05:54:57 +02:00
|
|
|
bool shouldFree;
|
2001-03-22 05:01:46 +01:00
|
|
|
int len = 0,
|
|
|
|
plen = 0,
|
|
|
|
sign = 0;
|
|
|
|
char *numstr,
|
|
|
|
*orgnum,
|
|
|
|
*p;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
NUM_TOCHAR_prepare;
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
if (IS_ROMAN(&Num))
|
2000-07-01 23:27:14 +02:00
|
|
|
numstr = orgnum = int_to_roman((int) rint(value));
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
|
|
|
{
|
2000-07-01 23:27:14 +02:00
|
|
|
float4 val = value;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (IS_MULTI(&Num))
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
float multi = pow((double) 10, (double) Num.multi);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-07-01 23:27:14 +02:00
|
|
|
val = value * multi;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
Num.pre += Num.multi;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
orgnum = (char *) palloc(MAXFLOATWIDTH + 1);
|
2002-09-20 05:54:57 +02:00
|
|
|
snprintf(orgnum, MAXFLOATWIDTH + 1, "%.0f", fabs(val));
|
2001-12-05 03:06:19 +01:00
|
|
|
len = strlen(orgnum);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
if (Num.pre > len)
|
|
|
|
plen = Num.pre - len;
|
|
|
|
if (len >= FLT_DIG)
|
2000-04-12 19:17:23 +02:00
|
|
|
Num.post = 0;
|
2000-02-08 16:57:01 +01:00
|
|
|
else if (Num.post + len > FLT_DIG)
|
2000-04-12 19:17:23 +02:00
|
|
|
Num.post = FLT_DIG - len;
|
2002-09-20 05:54:57 +02:00
|
|
|
snprintf(orgnum, MAXFLOATWIDTH + 1, "%.*f", Num.post, val);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (*orgnum == '-')
|
|
|
|
{ /* < 0 */
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
sign = '-';
|
2000-04-12 19:17:23 +02:00
|
|
|
numstr = orgnum + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
sign = '+';
|
|
|
|
numstr = orgnum;
|
|
|
|
}
|
|
|
|
if ((p = strchr(numstr, '.')))
|
2000-04-12 19:17:23 +02:00
|
|
|
len = p - numstr;
|
|
|
|
else
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
len = strlen(numstr);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (Num.pre > len)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
plen = Num.pre - len;
|
2000-04-12 19:17:23 +02:00
|
|
|
else if (len > Num.pre)
|
|
|
|
{
|
2007-06-29 03:51:35 +02:00
|
|
|
numstr = (char *) palloc(Num.pre + Num.post + 2);
|
|
|
|
fill_str(numstr, '#', Num.pre + Num.post + 1);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*(numstr + Num.pre) = '.';
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
NUM_TOCHAR_finish;
|
2000-07-01 23:27:14 +02:00
|
|
|
PG_RETURN_TEXT_P(result);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -----------------
|
|
|
|
* FLOAT8 to_char()
|
|
|
|
* -----------------
|
2000-04-12 19:17:23 +02:00
|
|
|
*/
|
2000-07-01 23:27:14 +02:00
|
|
|
Datum
|
|
|
|
float8_to_char(PG_FUNCTION_ARGS)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
float8 value = PG_GETARG_FLOAT8(0);
|
|
|
|
text *fmt = PG_GETARG_TEXT_P(1);
|
|
|
|
NUMDesc Num;
|
2000-04-12 19:17:23 +02:00
|
|
|
FormatNode *format;
|
2007-06-29 03:51:35 +02:00
|
|
|
text *result;
|
2002-09-20 05:54:57 +02:00
|
|
|
bool shouldFree;
|
2001-03-22 05:01:46 +01:00
|
|
|
int len = 0,
|
|
|
|
plen = 0,
|
|
|
|
sign = 0;
|
|
|
|
char *numstr,
|
|
|
|
*orgnum,
|
|
|
|
*p;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
NUM_TOCHAR_prepare;
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
if (IS_ROMAN(&Num))
|
2000-07-01 23:27:14 +02:00
|
|
|
numstr = orgnum = int_to_roman((int) rint(value));
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
|
|
|
{
|
2000-07-01 23:27:14 +02:00
|
|
|
float8 val = value;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (IS_MULTI(&Num))
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
double multi = pow((double) 10, (double) Num.multi);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-07-01 23:27:14 +02:00
|
|
|
val = value * multi;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
Num.pre += Num.multi;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
orgnum = (char *) palloc(MAXDOUBLEWIDTH + 1);
|
2002-09-20 05:54:57 +02:00
|
|
|
len = snprintf(orgnum, MAXDOUBLEWIDTH + 1, "%.0f", fabs(val));
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
if (Num.pre > len)
|
|
|
|
plen = Num.pre - len;
|
|
|
|
if (len >= DBL_DIG)
|
2000-04-12 19:17:23 +02:00
|
|
|
Num.post = 0;
|
2000-02-08 16:57:01 +01:00
|
|
|
else if (Num.post + len > DBL_DIG)
|
2000-04-12 19:17:23 +02:00
|
|
|
Num.post = DBL_DIG - len;
|
2002-09-20 05:54:57 +02:00
|
|
|
snprintf(orgnum, MAXDOUBLEWIDTH + 1, "%.*f", Num.post, val);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (*orgnum == '-')
|
|
|
|
{ /* < 0 */
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
sign = '-';
|
2000-04-12 19:17:23 +02:00
|
|
|
numstr = orgnum + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
sign = '+';
|
|
|
|
numstr = orgnum;
|
|
|
|
}
|
|
|
|
if ((p = strchr(numstr, '.')))
|
2000-04-12 19:17:23 +02:00
|
|
|
len = p - numstr;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
else
|
|
|
|
len = strlen(numstr);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (Num.pre > len)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
plen = Num.pre - len;
|
2000-04-12 19:17:23 +02:00
|
|
|
else if (len > Num.pre)
|
|
|
|
{
|
2007-06-29 03:51:35 +02:00
|
|
|
numstr = (char *) palloc(Num.pre + Num.post + 2);
|
|
|
|
fill_str(numstr, '#', Num.pre + Num.post + 1);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
*(numstr + Num.pre) = '.';
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
NUM_TOCHAR_finish;
|
2000-07-01 23:27:14 +02:00
|
|
|
PG_RETURN_TEXT_P(result);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
}
|