as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
|
|
|
*
|
2004-10-13 03:25:13 +02:00
|
|
|
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.79 2004/10/13 01:25:11 neilc Exp $
|
2000-02-08 16:57:01 +01:00
|
|
|
*
|
|
|
|
*
|
2004-08-29 06:13:13 +02:00
|
|
|
* Portions Copyright (c) 1999-2004, 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.
|
|
|
|
*
|
2000-03-16 02:35:41 +01:00
|
|
|
* The cache uses a static buffers and is persistent across transactions.
|
2000-04-12 19:17:23 +02:00
|
|
|
* If format-picture is bigger than cache buffer, 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>
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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"
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
#define MAXFLOATWIDTH 64
|
|
|
|
#define MAXDOUBLEWIDTH 128
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
|
|
* External (defined in PgSQL dt.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
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
char *name; /* keyword */
|
|
|
|
/* action for keyword */
|
|
|
|
int len, /* keyword length */
|
2004-10-13 03:25:13 +02:00
|
|
|
(*action) (int arg, char *inout, int suf, int flag, FormatNode *node, void *data),
|
2001-03-22 05:01:46 +01:00
|
|
|
id; /* keyword id */
|
|
|
|
bool isitdigit; /* is expected output/input 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 */
|
|
|
|
KeyWord *key; /* if node type is KEYWORD */
|
|
|
|
int character, /* if node type is CHAR */
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* AC / DC
|
|
|
|
* ----------
|
|
|
|
*/
|
2004-03-30 17:53:18 +02:00
|
|
|
#define YEAR_ABS(_y) (_y <= 0 ? -(_y -1) : _y)
|
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
|
|
|
|
* (Must be conversely for seq_search (in FROM_CHAR), because
|
|
|
|
* 'VIII' must be over '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
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
#define TO_CHAR 1
|
2000-04-12 19:17:23 +02:00
|
|
|
#define FROM_CHAR 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
|
|
|
|
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
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* Flags for DCH version
|
|
|
|
* ----------
|
|
|
|
*/
|
2001-03-22 05:01:46 +01:00
|
|
|
static int DCH_global_flag = 0;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
#define DCH_F_FX 0x01
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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_FX (DCH_global_flag & DCH_F_FX)
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* 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)
|
|
|
|
#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)
|
2003-03-27 17:35:31 +01:00
|
|
|
#define NUM_F_PLUS (1 << 9)
|
2003-08-04 02:43:34 +02:00
|
|
|
#define NUM_F_ROMAN (1 << 10)
|
2003-03-27 17:35:31 +01: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
|
|
|
|
|
|
|
#define NUM_LSIGN_PRE -1
|
|
|
|
#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,
|
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,
|
|
|
|
us;
|
2000-07-03 18:01:33 +02:00
|
|
|
} TmFromChar;
|
|
|
|
|
2001-09-06 05:22:42 +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
|
2001-09-06 05:22:42 +02:00
|
|
|
#define DEBUG_TMFC( _X ) \
|
2002-01-02 23:09:23 +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", \
|
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, \
|
2001-09-06 05:22:42 +02:00
|
|
|
(_X)->cc, (_X)->q, (_X)->j, (_X)->us);
|
|
|
|
#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
|
|
|
|
#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)
|
|
|
|
|
2000-07-03 18:01:33 +02:00
|
|
|
#define ZERO_tm( _X ) \
|
|
|
|
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)
|
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
#define ZERO_tmtc( _X ) \
|
|
|
|
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
|
|
|
|
|
|
|
/*****************************************************************************
|
2000-04-12 19:17:23 +02:00
|
|
|
* KeyWords definition & action
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
|
|
static int dch_global(int arg, char *inout, int suf, int flag, FormatNode *node, void *data);
|
|
|
|
static int dch_time(int arg, char *inout, int suf, int flag, FormatNode *node, void *data);
|
|
|
|
static int dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
#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)
|
|
|
|
|
|
|
|
#define S_FM(_s) ((_s & DCH_S_FM) ? 1 : 0)
|
|
|
|
#define S_SP(_s) ((_s & DCH_S_SP) ? 1 : 0)
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* 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},
|
|
|
|
{"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],
|
2000-02-08 16:57:01 +01:00
|
|
|
* 2) take keywords position (enum DCH_MM) 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,
|
|
|
|
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,
|
|
|
|
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
|
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
static KeyWord DCH_keywords[] = {
|
2000-12-03 21:45:40 +01:00
|
|
|
/* keyword, len, func, type, isitdigit is in Index */
|
2000-11-25 06:00:33 +01:00
|
|
|
{"A.D.", 4, dch_date, DCH_A_D, FALSE}, /* A */
|
|
|
|
{"A.M.", 4, dch_time, DCH_A_M, FALSE},
|
|
|
|
{"AD", 2, dch_date, DCH_AD, FALSE},
|
|
|
|
{"AM", 2, dch_time, DCH_AM, FALSE},
|
|
|
|
{"B.C.", 4, dch_date, DCH_B_C, FALSE}, /* B */
|
|
|
|
{"BC", 2, dch_date, DCH_BC, FALSE},
|
2001-03-22 05:01:46 +01:00
|
|
|
{"CC", 2, dch_date, DCH_CC, TRUE}, /* C */
|
2000-11-25 06:00:33 +01:00
|
|
|
{"DAY", 3, dch_date, DCH_DAY, FALSE}, /* D */
|
|
|
|
{"DDD", 3, dch_date, DCH_DDD, TRUE},
|
|
|
|
{"DD", 2, dch_date, DCH_DD, TRUE},
|
|
|
|
{"DY", 2, dch_date, DCH_DY, FALSE},
|
|
|
|
{"Day", 3, dch_date, DCH_Day, FALSE},
|
|
|
|
{"Dy", 2, dch_date, DCH_Dy, FALSE},
|
|
|
|
{"D", 1, dch_date, DCH_D, TRUE},
|
|
|
|
{"FX", 2, dch_global, DCH_FX, FALSE}, /* F */
|
|
|
|
{"HH24", 4, dch_time, DCH_HH24, TRUE}, /* H */
|
|
|
|
{"HH12", 4, dch_time, DCH_HH12, TRUE},
|
|
|
|
{"HH", 2, dch_time, DCH_HH, TRUE},
|
2001-03-22 05:01:46 +01:00
|
|
|
{"IW", 2, dch_date, DCH_IW, TRUE}, /* I */
|
2003-12-25 04:36:24 +01:00
|
|
|
{"IYYY", 4, dch_date, DCH_IYYY, TRUE},
|
|
|
|
{"IYY", 3, dch_date, DCH_IYY, TRUE},
|
|
|
|
{"IY", 2, dch_date, DCH_IY, TRUE},
|
|
|
|
{"I", 1, dch_date, DCH_I, TRUE},
|
2001-03-22 05:01:46 +01:00
|
|
|
{"J", 1, dch_date, DCH_J, TRUE}, /* J */
|
2000-11-25 06:00:33 +01:00
|
|
|
{"MI", 2, dch_time, DCH_MI, TRUE},
|
|
|
|
{"MM", 2, dch_date, DCH_MM, TRUE},
|
|
|
|
{"MONTH", 5, dch_date, DCH_MONTH, FALSE},
|
|
|
|
{"MON", 3, dch_date, DCH_MON, FALSE},
|
2001-09-06 05:22:42 +02:00
|
|
|
{"MS", 2, dch_time, DCH_MS, TRUE},
|
2000-11-25 06:00:33 +01:00
|
|
|
{"Month", 5, dch_date, DCH_Month, FALSE},
|
|
|
|
{"Mon", 3, dch_date, DCH_Mon, FALSE},
|
|
|
|
{"P.M.", 4, dch_time, DCH_P_M, FALSE}, /* P */
|
|
|
|
{"PM", 2, dch_time, DCH_PM, FALSE},
|
2001-03-22 05:01:46 +01:00
|
|
|
{"Q", 1, dch_date, DCH_Q, TRUE}, /* Q */
|
|
|
|
{"RM", 2, dch_date, DCH_RM, FALSE}, /* R */
|
|
|
|
{"SSSS", 4, dch_time, DCH_SSSS, TRUE}, /* S */
|
2000-11-25 06:00:33 +01:00
|
|
|
{"SS", 2, dch_time, DCH_SS, TRUE},
|
2001-03-22 05:01:46 +01:00
|
|
|
{"TZ", 2, dch_time, DCH_TZ, FALSE}, /* T */
|
2001-10-25 07:50:21 +02:00
|
|
|
{"US", 2, dch_time, DCH_US, TRUE}, /* U */
|
2001-03-22 05:01:46 +01:00
|
|
|
{"WW", 2, dch_date, DCH_WW, TRUE}, /* W */
|
2000-11-25 06:00:33 +01:00
|
|
|
{"W", 1, dch_date, DCH_W, TRUE},
|
|
|
|
{"Y,YYY", 5, dch_date, DCH_Y_YYY, TRUE}, /* Y */
|
|
|
|
{"YYYY", 4, dch_date, DCH_YYYY, TRUE},
|
|
|
|
{"YYY", 3, dch_date, DCH_YYY, TRUE},
|
|
|
|
{"YY", 2, dch_date, DCH_YY, TRUE},
|
|
|
|
{"Y", 1, dch_date, DCH_Y, TRUE},
|
|
|
|
{"a.d.", 4, dch_date, DCH_a_d, FALSE}, /* a */
|
|
|
|
{"a.m.", 4, dch_time, DCH_a_m, FALSE},
|
|
|
|
{"ad", 2, dch_date, DCH_ad, FALSE},
|
|
|
|
{"am", 2, dch_time, DCH_am, FALSE},
|
|
|
|
{"b.c.", 4, dch_date, DCH_b_c, FALSE}, /* b */
|
|
|
|
{"bc", 2, dch_date, DCH_bc, FALSE},
|
2001-03-22 05:01:46 +01:00
|
|
|
{"cc", 2, dch_date, DCH_CC, TRUE}, /* c */
|
2000-11-25 06:00:33 +01:00
|
|
|
{"day", 3, dch_date, DCH_day, FALSE}, /* d */
|
|
|
|
{"ddd", 3, dch_date, DCH_DDD, TRUE},
|
|
|
|
{"dd", 2, dch_date, DCH_DD, TRUE},
|
|
|
|
{"dy", 2, dch_date, DCH_dy, FALSE},
|
|
|
|
{"d", 1, dch_date, DCH_D, TRUE},
|
|
|
|
{"fx", 2, dch_global, DCH_FX, FALSE}, /* f */
|
|
|
|
{"hh24", 4, dch_time, DCH_HH24, TRUE}, /* h */
|
|
|
|
{"hh12", 4, dch_time, DCH_HH12, TRUE},
|
|
|
|
{"hh", 2, dch_time, DCH_HH, TRUE},
|
2001-03-22 05:01:46 +01:00
|
|
|
{"iw", 2, dch_date, DCH_IW, TRUE}, /* i */
|
2003-12-25 04:36:24 +01:00
|
|
|
{"iyyy", 4, dch_date, DCH_IYYY, TRUE},
|
|
|
|
{"iyy", 3, dch_date, DCH_IYY, TRUE},
|
|
|
|
{"iy", 2, dch_date, DCH_IY, TRUE},
|
|
|
|
{"i", 1, dch_date, DCH_I, TRUE},
|
2001-03-22 05:01:46 +01:00
|
|
|
{"j", 1, dch_time, DCH_J, TRUE}, /* j */
|
|
|
|
{"mi", 2, dch_time, DCH_MI, TRUE}, /* m */
|
2000-11-25 06:00:33 +01:00
|
|
|
{"mm", 2, dch_date, DCH_MM, TRUE},
|
|
|
|
{"month", 5, dch_date, DCH_month, FALSE},
|
|
|
|
{"mon", 3, dch_date, DCH_mon, FALSE},
|
2001-09-06 05:22:42 +02:00
|
|
|
{"ms", 2, dch_time, DCH_MS, TRUE},
|
2000-11-25 06:00:33 +01:00
|
|
|
{"p.m.", 4, dch_time, DCH_p_m, FALSE}, /* p */
|
|
|
|
{"pm", 2, dch_time, DCH_pm, FALSE},
|
2001-03-22 05:01:46 +01:00
|
|
|
{"q", 1, dch_date, DCH_Q, TRUE}, /* q */
|
|
|
|
{"rm", 2, dch_date, DCH_rm, FALSE}, /* r */
|
|
|
|
{"ssss", 4, dch_time, DCH_SSSS, TRUE}, /* s */
|
2000-11-25 06:00:33 +01:00
|
|
|
{"ss", 2, dch_time, DCH_SS, TRUE},
|
2001-03-22 05:01:46 +01:00
|
|
|
{"tz", 2, dch_time, DCH_tz, FALSE}, /* t */
|
2001-09-06 05:22:42 +02:00
|
|
|
{"us", 2, dch_time, DCH_US, TRUE}, /* u */
|
2001-03-22 05:01:46 +01:00
|
|
|
{"ww", 2, dch_date, DCH_WW, TRUE}, /* w */
|
2000-11-25 06:00:33 +01:00
|
|
|
{"w", 1, dch_date, DCH_W, TRUE},
|
|
|
|
{"y,yyy", 5, dch_date, DCH_Y_YYY, TRUE}, /* y */
|
|
|
|
{"yyyy", 4, dch_date, DCH_YYYY, TRUE},
|
|
|
|
{"yyy", 3, dch_date, DCH_YYY, TRUE},
|
|
|
|
{"yy", 2, dch_date, DCH_YY, TRUE},
|
|
|
|
{"y", 1, dch_date, DCH_Y, 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
|
|
|
/* last */
|
2000-04-12 19:17:23 +02:00
|
|
|
{NULL, 0, NULL, 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-12-03 21:45:40 +01:00
|
|
|
* KeyWords for NUMBER version (now, isitdigit info 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
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
static KeyWord NUM_keywords[] = {
|
|
|
|
/* keyword, len, func. type is in Index */
|
|
|
|
{",", 1, NULL, NUM_COMMA}, /* , */
|
|
|
|
{".", 1, NULL, NUM_DEC}, /* . */
|
|
|
|
{"0", 1, NULL, NUM_0}, /* 0 */
|
|
|
|
{"9", 1, NULL, NUM_9}, /* 9 */
|
|
|
|
{"B", 1, NULL, NUM_B}, /* B */
|
|
|
|
{"C", 1, NULL, NUM_C}, /* C */
|
|
|
|
{"D", 1, NULL, NUM_D}, /* D */
|
|
|
|
{"E", 1, NULL, NUM_E}, /* E */
|
|
|
|
{"FM", 2, NULL, NUM_FM}, /* F */
|
|
|
|
{"G", 1, NULL, NUM_G}, /* G */
|
|
|
|
{"L", 1, NULL, NUM_L}, /* L */
|
|
|
|
{"MI", 2, NULL, NUM_MI}, /* M */
|
|
|
|
{"PL", 2, NULL, NUM_PL}, /* P */
|
|
|
|
{"PR", 2, NULL, NUM_PR},
|
|
|
|
{"RN", 2, NULL, NUM_RN}, /* R */
|
|
|
|
{"SG", 2, NULL, NUM_SG}, /* S */
|
|
|
|
{"SP", 2, NULL, NUM_SP},
|
|
|
|
{"S", 1, NULL, NUM_S},
|
|
|
|
{"TH", 2, NULL, NUM_TH}, /* T */
|
|
|
|
{"V", 1, NULL, NUM_V}, /* V */
|
|
|
|
{"b", 1, NULL, NUM_B}, /* b */
|
|
|
|
{"c", 1, NULL, NUM_C}, /* c */
|
|
|
|
{"d", 1, NULL, NUM_D}, /* d */
|
|
|
|
{"e", 1, NULL, NUM_E}, /* e */
|
|
|
|
{"fm", 2, NULL, NUM_FM}, /* f */
|
|
|
|
{"g", 1, NULL, NUM_G}, /* g */
|
|
|
|
{"l", 1, NULL, NUM_L}, /* l */
|
|
|
|
{"mi", 2, NULL, NUM_MI}, /* m */
|
|
|
|
{"pl", 2, NULL, NUM_PL}, /* p */
|
|
|
|
{"pr", 2, NULL, NUM_PR},
|
|
|
|
{"rn", 2, NULL, NUM_rn}, /* r */
|
|
|
|
{"sg", 2, NULL, NUM_SG}, /* s */
|
|
|
|
{"sp", 2, NULL, NUM_SP},
|
|
|
|
{"s", 1, NULL, NUM_S},
|
|
|
|
{"th", 2, NULL, NUM_th}, /* t */
|
|
|
|
{"v", 1, NULL, NUM_V}, /* v */
|
|
|
|
|
|
|
|
/* last */
|
|
|
|
{NULL, 0, NULL, 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
|
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
static 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,
|
2000-08-29 06:41:48 +02:00
|
|
|
DCH_FX, -1, DCH_HH24, DCH_IW, 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,
|
2000-08-29 06:41:48 +02:00
|
|
|
DCH_day, -1, DCH_fx, -1, DCH_hh24, DCH_iw, 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
|
|
|
|
|
|
|
/*---- chars over 126 are skiped ----*/
|
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
|
|
|
|
* ----------
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
static 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
|
|
|
|
*/
|
|
|
|
/*---- first 0..31 chars are skiped ----*/
|
|
|
|
|
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
|
|
|
|
|
|
|
/*---- chars over 126 are skiped ----*/
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* Number processor struct
|
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
typedef struct NUMProc
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
int type; /* FROM_CHAR (TO_NUMBER) or TO_CHAR */
|
|
|
|
|
|
|
|
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 */
|
|
|
|
read_post; /* to_number - number of dec. digit */
|
|
|
|
|
|
|
|
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 */
|
2001-03-22 05:01:46 +01:00
|
|
|
*last_relevant, /* last relevant number after decimal
|
|
|
|
* point */
|
|
|
|
|
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
|
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
static KeyWord *index_seq_search(char *str, KeyWord *kw, int *index);
|
|
|
|
static KeySuffix *suff_search(char *str, KeySuffix *suf, int type);
|
|
|
|
static void NUMDesc_prepare(NUMDesc *num, FormatNode *n);
|
2000-04-12 19:17:23 +02:00
|
|
|
static void parse_format(FormatNode *node, char *str, KeyWord *kw,
|
|
|
|
KeySuffix *suf, int *index, int ver, NUMDesc *Num);
|
2001-09-06 05:22:42 +02:00
|
|
|
static char *DCH_processor(FormatNode *node, char *inout, int flag, void *data);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
|
|
static void dump_index(KeyWord *k, int *index);
|
|
|
|
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);
|
2001-10-25 07:50:21 +02:00
|
|
|
static int strdigits_len(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
|
|
|
static char *str_toupper(char *buff);
|
|
|
|
static char *str_tolower(char *buff);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-04-07 21:17:51 +02:00
|
|
|
/* static int is_acdc(char *str, int *len); */
|
2000-04-12 19:17:23 +02:00
|
|
|
static int seq_search(char *name, char **array, int type, int max, int *len);
|
2001-09-06 05:22:42 +02:00
|
|
|
static int dch_global(int arg, char *inout, int suf, int flag, FormatNode *node, void *data);
|
|
|
|
static int dch_time(int arg, char *inout, int suf, int flag, FormatNode *node, void *data);
|
|
|
|
static int dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data);
|
2003-08-25 18:13:27 +02:00
|
|
|
static void do_to_timestamp(text *date_txt, text *fmt,
|
2004-08-29 07:07:03 +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);
|
2002-09-20 05:54:57 +02:00
|
|
|
static FormatNode *NUM_cache(int len, NUMDesc *Num, char *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,
|
|
|
|
int plen, int sign, int type);
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* 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)
|
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
static KeyWord *
|
2000-04-12 19:17:23 +02:00
|
|
|
index_seq_search(char *str, KeyWord *kw, 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)
|
|
|
|
{
|
2000-07-01 23:27:14 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
KeyWord *k = kw + poz;
|
|
|
|
|
|
|
|
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),
|
2003-08-04 02:43:34 +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),
|
2003-08-04 02:43:34 +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
|
|
|
|
parse_format(FormatNode *node, char *str, KeyWord *kw,
|
|
|
|
KeySuffix *suf, 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
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
n->type = NODE_TYPE_END;
|
|
|
|
n->suffix = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------
|
2000-04-12 19:17:23 +02:00
|
|
|
* Call keyword's function for each of (action) node in format-node tree
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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 *
|
2001-09-06 05:22:42 +02:00
|
|
|
DCH_processor(FormatNode *node, char *inout, int flag, void *data)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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;
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
|
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
|
|
|
* Zeroing global flags
|
|
|
|
*/
|
|
|
|
DCH_global_flag = 0;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
for (n = node, s = inout; n->type != NODE_TYPE_END; n++)
|
|
|
|
{
|
2004-08-29 07:07:03 +02:00
|
|
|
if (flag == FROM_CHAR && *s == '\0')
|
|
|
|
|
2003-09-03 16:59:41 +02:00
|
|
|
/*
|
2004-08-29 07:07:03 +02:00
|
|
|
* The input string is shorter than format picture, so it's
|
|
|
|
* good time to break this loop...
|
|
|
|
*
|
|
|
|
* Note: this isn't relevant for TO_CHAR mode, beacuse it use
|
|
|
|
* 'inout' allocated by format picture length.
|
2003-09-03 16:59:41 +02:00
|
|
|
*/
|
|
|
|
break;
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
if (n->type == NODE_TYPE_ACTION)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
int 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
|
|
|
* Call node action function
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
|
|
len = n->key->action(n->key->id, s, n->suffix, flag, n, data);
|
2000-04-12 19:17:23 +02:00
|
|
|
if (len > 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
|
|
|
s += len;
|
2000-02-08 16:57:01 +01:00
|
|
|
else if (len == -1)
|
2000-04-12 19:17:23 +02:00
|
|
|
continue;
|
2000-07-01 23:27:14 +02: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
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (flag == 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
|
|
|
*s = n->character;
|
2000-07-01 23:27:14 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
|
|
|
{
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-04-12 19:17:23 +02:00
|
|
|
* Skip blank space in FROM_CHAR's input
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
|
|
if (isspace((unsigned char) n->character) && IS_FX == 0)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2000-12-03 21:45:40 +01:00
|
|
|
while (*s != '\0' && isspace((unsigned char) *(s + 1)))
|
2000-04-12 19:17:23 +02:00
|
|
|
++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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-08-29 07:07:03 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
++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
|
|
|
}
|
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 (flag == TO_CHAR)
|
|
|
|
*s = '\0';
|
|
|
|
return inout;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* 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)",
|
|
|
|
a, n->key->name, DUMP_THth(n->suffix), DUMP_FM(n->suffix));
|
|
|
|
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);
|
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
|
|
|
}
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
sprintf(dest, "%s%s", num, 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
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------
|
2002-09-20 05:54:57 +02:00
|
|
|
* Convert string to upper-string. Input string is modified in place.
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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_toupper(char *buff)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
char *p_buff = 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
|
|
|
|
2002-09-20 05:54:57 +02:00
|
|
|
if (!buff)
|
|
|
|
return NULL;
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
while (*p_buff)
|
|
|
|
{
|
2004-05-07 02:24:59 +02:00
|
|
|
*p_buff = pg_toupper((unsigned char) *p_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
|
|
|
++p_buff;
|
|
|
|
}
|
|
|
|
return buff;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------
|
2002-09-20 05:54:57 +02:00
|
|
|
* Convert string to lower-string. Input string is modified in place.
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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_tolower(char *buff)
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
char *p_buff = 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
|
|
|
|
2002-09-20 05:54:57 +02:00
|
|
|
if (!buff)
|
|
|
|
return NULL;
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
while (*p_buff)
|
|
|
|
{
|
2004-05-07 02:24:59 +02:00
|
|
|
*p_buff = pg_tolower((unsigned char) *p_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
|
|
|
++p_buff;
|
|
|
|
}
|
|
|
|
return buff;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* 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
|
|
|
|
|
|
|
|
/*
|
|
|
|
* elog(DEBUG_elog_output, "N: %c, P: %c, A: %s (%s)", *n, *p,
|
|
|
|
* *a, name);
|
|
|
|
*/
|
|
|
|
#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
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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_index(KeyWord *k, int *index)
|
|
|
|
{
|
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-03-16 02:35:41 +01:00
|
|
|
* Global format option for DCH 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
|
|
|
* ----------
|
|
|
|
*/
|
|
|
|
static int
|
2001-09-06 05:22:42 +02:00
|
|
|
dch_global(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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 (arg == DCH_FX)
|
|
|
|
DCH_global_flag |= DCH_F_FX;
|
2000-02-08 16:57:01 +01: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
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2000-12-03 21:45:40 +01:00
|
|
|
if (n->key->isitdigit)
|
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
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
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
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
|
|
* Master function of TIME for:
|
2000-08-29 06:41:48 +02:00
|
|
|
* TO_CHAR - write (inout) formated string
|
|
|
|
* FROM_CHAR - scan (inout) string by course of FormatNode
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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 int
|
2001-09-06 05:22:42 +02:00
|
|
|
dch_time(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
|
|
char *p_inout = inout;
|
2004-08-29 07:07:03 +02:00
|
|
|
struct pg_tm *tm = NULL;
|
2001-10-25 07:50:21 +02:00
|
|
|
TmFromChar *tmfc = NULL;
|
|
|
|
TmToChar *tmtc = NULL;
|
2001-09-06 05:22:42 +02:00
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
if (flag == TO_CHAR)
|
2001-09-06 05:22:42 +02:00
|
|
|
{
|
|
|
|
tmtc = (TmToChar *) data;
|
|
|
|
tm = tmtcTm(tmtc);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
tmfc = (TmFromChar *) data;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
switch (arg)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
case DCH_A_M:
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_P_M:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
strcpy(inout, ((tm->tm_hour > 11
|
|
|
|
&& tm->tm_hour < 24) ? P_M_STR : A_M_STR));
|
2000-04-12 19:17:23 +02:00
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
if (strncmp(inout, P_M_STR, 4) == 0)
|
|
|
|
tmfc->pm = TRUE;
|
|
|
|
else if (strncmp(inout, A_M_STR, 4) == 0)
|
2001-03-22 05:01:46 +01:00
|
|
|
tmfc->am = TRUE;
|
2000-07-03 18:01:33 +02:00
|
|
|
else
|
2001-03-22 05:01:46 +01:00
|
|
|
AMPM_ERROR;
|
2000-04-12 19:17:23 +02:00
|
|
|
return 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
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_AM:
|
|
|
|
case DCH_PM:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
strcpy(inout, ((tm->tm_hour > 11
|
|
|
|
&& tm->tm_hour < 24) ? PM_STR : AM_STR));
|
2000-02-08 16:57:01 +01: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
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
if (strncmp(inout, PM_STR, 2) == 0)
|
|
|
|
tmfc->pm = TRUE;
|
|
|
|
else if (strncmp(inout, AM_STR, 2) == 0)
|
|
|
|
tmfc->am = TRUE;
|
|
|
|
else
|
2001-03-22 05:01:46 +01:00
|
|
|
AMPM_ERROR;
|
2000-02-08 16:57:01 +01: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
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_a_m:
|
|
|
|
case DCH_p_m:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
strcpy(inout, ((tm->tm_hour > 11
|
|
|
|
&& tm->tm_hour < 24) ? p_m_STR : a_m_STR));
|
2000-04-12 19:17:23 +02:00
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
if (strncmp(inout, p_m_STR, 4) == 0)
|
|
|
|
tmfc->pm = TRUE;
|
|
|
|
else if (strncmp(inout, a_m_STR, 4) == 0)
|
|
|
|
tmfc->am = TRUE;
|
|
|
|
else
|
2001-03-22 05:01:46 +01:00
|
|
|
AMPM_ERROR;
|
2000-04-12 19:17:23 +02:00
|
|
|
return 3;
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_am:
|
|
|
|
case DCH_pm:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
strcpy(inout, ((tm->tm_hour > 11
|
2001-03-22 05:01:46 +01:00
|
|
|
&& tm->tm_hour < 24) ? pm_STR : am_STR));
|
2000-02-08 16:57:01 +01: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
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
if (strncmp(inout, pm_STR, 2) == 0)
|
|
|
|
tmfc->pm = TRUE;
|
|
|
|
else if (strncmp(inout, am_STR, 2) == 0)
|
|
|
|
tmfc->am = TRUE;
|
|
|
|
else
|
2001-03-22 05:01:46 +01:00
|
|
|
AMPM_ERROR;
|
2000-04-12 19:17:23 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_HH:
|
|
|
|
case DCH_HH12:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2,
|
|
|
|
tm->tm_hour == 0 ? 12 :
|
|
|
|
tm->tm_hour < 13 ? tm->tm_hour : tm->tm_hour - 12);
|
|
|
|
if (S_THth(suf))
|
|
|
|
str_numth(p_inout, inout, 0);
|
|
|
|
if (S_FM(suf) || S_THth(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 1;
|
2000-07-01 23:27:14 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2001-09-06 05:22:42 +02:00
|
|
|
if (S_FM(suf) || is_next_separator(node))
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
sscanf(inout, "%d", &tmfc->hh);
|
2001-09-06 05:22:42 +02:00
|
|
|
return strdigits_len(inout) - 1 + SKIP_THth(suf);
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
sscanf(inout, "%02d", &tmfc->hh);
|
2000-04-12 19:17:23 +02:00
|
|
|
return 1 + SKIP_THth(suf);
|
|
|
|
}
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_HH24:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, tm->tm_hour);
|
|
|
|
if (S_THth(suf))
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
if (S_FM(suf) || S_THth(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2001-09-06 05:22:42 +02:00
|
|
|
if (S_FM(suf) || is_next_separator(node))
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
sscanf(inout, "%d", &tmfc->hh);
|
2001-09-06 05:22:42 +02:00
|
|
|
return strdigits_len(inout) - 1 + SKIP_THth(suf);
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
sscanf(inout, "%02d", &tmfc->hh);
|
2000-04-12 19:17:23 +02:00
|
|
|
return 1 + SKIP_THth(suf);
|
|
|
|
}
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_MI:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, tm->tm_min);
|
|
|
|
if (S_THth(suf))
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
if (S_FM(suf) || S_THth(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2001-09-06 05:22:42 +02:00
|
|
|
if (S_FM(suf) || is_next_separator(node))
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
sscanf(inout, "%d", &tmfc->mi);
|
2001-09-06 05:22:42 +02:00
|
|
|
return strdigits_len(inout) - 1 + SKIP_THth(suf);
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
sscanf(inout, "%02d", &tmfc->mi);
|
2000-04-12 19:17:23 +02:00
|
|
|
return 1 + SKIP_THth(suf);
|
|
|
|
}
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_SS:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, tm->tm_sec);
|
|
|
|
if (S_THth(suf))
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
if (S_FM(suf) || S_THth(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 1;
|
2000-07-01 23:27:14 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2001-09-06 05:22:42 +02:00
|
|
|
if (S_FM(suf) || is_next_separator(node))
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
sscanf(inout, "%d", &tmfc->ss);
|
2001-09-06 05:22:42 +02:00
|
|
|
return strdigits_len(inout) - 1 + SKIP_THth(suf);
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
sscanf(inout, "%02d", &tmfc->ss);
|
2000-04-12 19:17:23 +02:00
|
|
|
return 1 + SKIP_THth(suf);
|
|
|
|
}
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2001-10-25 07:50:21 +02:00
|
|
|
case DCH_MS: /* millisecond */
|
2001-09-06 05:22:42 +02:00
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
2002-04-21 21:52:18 +02:00
|
|
|
#ifdef HAVE_INT64_TIMESTAMP
|
|
|
|
sprintf(inout, "%03d", (int) (tmtc->fsec / INT64CONST(1000)));
|
|
|
|
#else
|
2001-09-06 05:22:42 +02:00
|
|
|
sprintf(inout, "%03d", (int) rint(tmtc->fsec * 1000));
|
2002-04-21 21:52:18 +02:00
|
|
|
#endif
|
2001-09-06 05:22:42 +02:00
|
|
|
if (S_THth(suf))
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
if (S_THth(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2001-10-25 07:50:21 +02:00
|
|
|
int len,
|
|
|
|
x;
|
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
if (is_next_separator(node))
|
|
|
|
{
|
|
|
|
sscanf(inout, "%d", &tmfc->ms);
|
|
|
|
len = x = strdigits_len(inout);
|
|
|
|
}
|
2001-10-25 07:50:21 +02:00
|
|
|
else
|
2001-09-06 05:22:42 +02:00
|
|
|
{
|
|
|
|
sscanf(inout, "%03d", &tmfc->ms);
|
|
|
|
x = strdigits_len(inout);
|
2001-10-25 07:50:21 +02:00
|
|
|
len = x = x > 3 ? 3 : x;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 25 is 0.25 and 250 is 0.25 too; 025 is 0.025 and not
|
|
|
|
* 0.25
|
|
|
|
*/
|
|
|
|
tmfc->ms *= x == 1 ? 100 :
|
|
|
|
x == 2 ? 10 : 1;
|
|
|
|
|
|
|
|
/*
|
2002-03-06 07:10:59 +01:00
|
|
|
* elog(DEBUG3, "X: %d, MS: %d, LEN: %d", x, tmfc->ms,
|
2001-10-25 07:50:21 +02:00
|
|
|
* len);
|
2001-09-06 05:22:42 +02:00
|
|
|
*/
|
|
|
|
return len - 1 + SKIP_THth(suf);
|
|
|
|
}
|
|
|
|
break;
|
2001-10-25 07:50:21 +02:00
|
|
|
case DCH_US: /* microsecond */
|
2001-09-06 05:22:42 +02:00
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
2002-04-21 21:52:18 +02:00
|
|
|
#ifdef HAVE_INT64_TIMESTAMP
|
|
|
|
sprintf(inout, "%06d", (int) tmtc->fsec);
|
|
|
|
#else
|
2001-10-25 07:50:21 +02:00
|
|
|
sprintf(inout, "%06d", (int) rint(tmtc->fsec * 1000000));
|
2002-04-21 21:52:18 +02:00
|
|
|
#endif
|
2001-09-06 05:22:42 +02:00
|
|
|
if (S_THth(suf))
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
if (S_THth(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2001-10-25 07:50:21 +02:00
|
|
|
int len,
|
|
|
|
x;
|
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
if (is_next_separator(node))
|
|
|
|
{
|
|
|
|
sscanf(inout, "%d", &tmfc->us);
|
|
|
|
len = x = strdigits_len(inout);
|
|
|
|
}
|
2001-10-25 07:50:21 +02:00
|
|
|
else
|
2001-09-06 05:22:42 +02:00
|
|
|
{
|
|
|
|
sscanf(inout, "%06d", &tmfc->us);
|
|
|
|
x = strdigits_len(inout);
|
2001-10-25 07:50:21 +02:00
|
|
|
len = x = x > 6 ? 6 : x;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmfc->us *= x == 1 ? 100000 :
|
|
|
|
x == 2 ? 10000 :
|
|
|
|
x == 3 ? 1000 :
|
|
|
|
x == 4 ? 100 :
|
|
|
|
x == 5 ? 10 : 1;
|
|
|
|
|
|
|
|
/*
|
2002-03-06 07:10:59 +01:00
|
|
|
* elog(DEBUG3, "X: %d, US: %d, LEN: %d", x, tmfc->us,
|
2001-10-25 07:50:21 +02:00
|
|
|
* len);
|
|
|
|
*/
|
2001-09-06 05:22:42 +02:00
|
|
|
return len - 1 + SKIP_THth(suf);
|
|
|
|
}
|
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_SSSS:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
sprintf(inout, "%d", tm->tm_hour * 3600 +
|
|
|
|
tm->tm_min * 60 +
|
|
|
|
tm->tm_sec);
|
|
|
|
if (S_THth(suf))
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
}
|
2001-03-22 05:01:46 +01:00
|
|
|
else if (flag == FROM_CHAR)
|
2000-07-03 18:01:33 +02:00
|
|
|
{
|
2001-09-06 05:22:42 +02:00
|
|
|
if (S_FM(suf) || is_next_separator(node))
|
|
|
|
{
|
2000-11-25 06:00:33 +01:00
|
|
|
sscanf(inout, "%d", &tmfc->ssss);
|
2001-09-06 05:22:42 +02:00
|
|
|
return strdigits_len(inout) - 1 + SKIP_THth(suf);
|
|
|
|
}
|
2000-11-25 06:00:33 +01:00
|
|
|
else
|
2001-09-06 05:22:42 +02:00
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
sscanf(inout, "%05d", &tmfc->ssss);
|
2001-09-06 05:22:42 +02:00
|
|
|
return 4 + SKIP_THth(suf);
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DCH_tz:
|
|
|
|
case DCH_TZ:
|
2001-09-06 05:22:42 +02:00
|
|
|
if (flag == TO_CHAR && tmtcTzn(tmtc))
|
2000-07-03 18:01:33 +02:00
|
|
|
{
|
2001-10-25 07:50:21 +02:00
|
|
|
int siz = strlen(tmtcTzn(tmtc));
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2000-07-03 18:01:33 +02:00
|
|
|
if (arg == DCH_TZ)
|
2001-09-06 05:22:42 +02:00
|
|
|
strcpy(inout, tmtcTzn(tmtc));
|
2001-03-22 05:01:46 +01:00
|
|
|
else
|
2000-07-03 18:01:33 +02:00
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
char *p = palloc(siz);
|
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
strcpy(p, tmtcTzn(tmtc));
|
2000-07-03 18:01:33 +02:00
|
|
|
strcpy(inout, str_tolower(p));
|
|
|
|
pfree(p);
|
|
|
|
}
|
|
|
|
return siz - 1;
|
2001-03-22 05:01:46 +01:00
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
|
|
|
errmsg("\"TZ\"/\"tz\" not supported")));
|
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
|
|
|
}
|
|
|
|
|
2000-07-03 18:01:33 +02:00
|
|
|
#define CHECK_SEQ_SEARCH(_l, _s) \
|
|
|
|
do { \
|
2003-07-27 06:53:12 +02:00
|
|
|
if ((_l) <= 0) { \
|
|
|
|
ereport(ERROR, \
|
|
|
|
(errcode(ERRCODE_INVALID_DATETIME_FORMAT), \
|
|
|
|
errmsg("invalid value for %s", (_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
|
|
|
} \
|
2000-07-03 18:01:33 +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
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* Master of DATE for:
|
2000-08-29 06:41:48 +02:00
|
|
|
* TO_CHAR - write (inout) formated string
|
2000-07-03 18:01:33 +02:00
|
|
|
* FROM_CHAR - scan (inout) string by course of FormatNode
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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 int
|
2001-09-06 05:22:42 +02:00
|
|
|
dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data)
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
|
|
char buff[DCH_CACHE_SIZE],
|
|
|
|
*p_inout;
|
|
|
|
int i,
|
|
|
|
len;
|
2004-08-29 07:07:03 +02:00
|
|
|
struct pg_tm *tm = NULL;
|
2001-10-25 07:50:21 +02:00
|
|
|
TmFromChar *tmfc = NULL;
|
|
|
|
TmToChar *tmtc = NULL;
|
2001-09-06 05:22:42 +02:00
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
if (flag == TO_CHAR)
|
2001-09-06 05:22:42 +02:00
|
|
|
{
|
|
|
|
tmtc = (TmToChar *) data;
|
|
|
|
tm = tmtcTm(tmtc);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
tmfc = (TmFromChar *) data;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
|
|
|
|
p_inout = inout;
|
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-04-12 19:17:23 +02:00
|
|
|
* In the FROM-char is not difference between "January" or "JANUARY"
|
2001-03-22 07:16:21 +01:00
|
|
|
* or "january", all is before search convert to "first-upper". This
|
|
|
|
* convention is used for MONTH, MON, DAY, DY
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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 (flag == FROM_CHAR)
|
|
|
|
{
|
|
|
|
if (arg == DCH_MONTH || arg == DCH_Month || arg == DCH_month)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
tmfc->mm = seq_search(inout, months_full, ONE_UPPER, FULL_SIZ, &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
|
|
|
CHECK_SEQ_SEARCH(len, "MONTH/Month/month");
|
2000-04-12 19:17:23 +02:00
|
|
|
if (S_FM(suf))
|
|
|
|
return len - 1;
|
|
|
|
else
|
|
|
|
return 8;
|
2000-07-01 23:27:14 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (arg == DCH_MON || arg == DCH_Mon || arg == DCH_mon)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
tmfc->mm = seq_search(inout, months, ONE_UPPER, MAX_MON_LEN, &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
|
|
|
CHECK_SEQ_SEARCH(len, "MON/Mon/mon");
|
|
|
|
return 2;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (arg == DCH_DAY || arg == DCH_Day || arg == DCH_day)
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
tmfc->d = seq_search(inout, days, ONE_UPPER, FULL_SIZ, &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
|
|
|
CHECK_SEQ_SEARCH(len, "DAY/Day/day");
|
2000-04-12 19:17:23 +02:00
|
|
|
if (S_FM(suf))
|
|
|
|
return len - 1;
|
|
|
|
else
|
|
|
|
return 8;
|
2000-07-01 23:27:14 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (arg == DCH_DY || arg == DCH_Dy || arg == DCH_dy)
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
tmfc->d = seq_search(inout, days, ONE_UPPER, MAX_DY_LEN, &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
|
|
|
CHECK_SEQ_SEARCH(len, "DY/Dy/dy");
|
|
|
|
return 2;
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (arg)
|
|
|
|
{
|
2000-07-01 23:27:14 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_A_D:
|
|
|
|
case DCH_B_C:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
2004-03-30 17:53:18 +02:00
|
|
|
strcpy(inout, (tm->tm_year <= 0 ? B_C_STR : A_D_STR));
|
2000-04-12 19:17:23 +02:00
|
|
|
return 3;
|
2000-07-01 23:27:14 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
if (strncmp(inout, B_C_STR, 4) == 0)
|
|
|
|
tmfc->bc = TRUE;
|
2000-04-12 19:17:23 +02:00
|
|
|
return 3;
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_AD:
|
|
|
|
case DCH_BC:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
2004-03-30 17:53:18 +02:00
|
|
|
strcpy(inout, (tm->tm_year <= 0 ? BC_STR : AD_STR));
|
2000-02-08 16:57:01 +01:00
|
|
|
return 1;
|
2000-07-01 23:27:14 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
if (strncmp(inout, BC_STR, 2) == 0)
|
|
|
|
tmfc->bc = TRUE;
|
2000-02-08 16:57:01 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_a_d:
|
|
|
|
case DCH_b_c:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
2004-03-30 17:53:18 +02:00
|
|
|
strcpy(inout, (tm->tm_year <= 0 ? b_c_STR : a_d_STR));
|
2000-04-07 21:17:51 +02:00
|
|
|
return 3;
|
2000-07-01 23:27:14 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
if (strncmp(inout, b_c_STR, 4) == 0)
|
|
|
|
tmfc->bc = TRUE;
|
2000-04-07 21:17:51 +02:00
|
|
|
return 3;
|
2000-02-08 16:57:01 +01:00
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_ad:
|
|
|
|
case DCH_bc:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
2004-03-30 17:53:18 +02:00
|
|
|
strcpy(inout, (tm->tm_year <= 0 ? bc_STR : ad_STR));
|
2000-04-12 19:17:23 +02:00
|
|
|
return 1;
|
2000-07-01 23:27:14 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
if (strncmp(inout, bc_STR, 2) == 0)
|
|
|
|
tmfc->bc = TRUE;
|
2000-04-12 19:17:23 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_MONTH:
|
|
|
|
strcpy(inout, months_full[tm->tm_mon - 1]);
|
|
|
|
sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, str_toupper(inout));
|
|
|
|
if (S_FM(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 8;
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_Month:
|
|
|
|
sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, months_full[tm->tm_mon - 1]);
|
|
|
|
if (S_FM(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 8;
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_month:
|
|
|
|
sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, months_full[tm->tm_mon - 1]);
|
2004-05-07 02:24:59 +02:00
|
|
|
*inout = pg_tolower((unsigned char) *inout);
|
2000-04-12 19:17:23 +02:00
|
|
|
if (S_FM(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 8;
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_MON:
|
|
|
|
strcpy(inout, months[tm->tm_mon - 1]);
|
|
|
|
inout = str_toupper(inout);
|
|
|
|
return 2;
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_Mon:
|
|
|
|
strcpy(inout, months[tm->tm_mon - 1]);
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
case DCH_mon:
|
|
|
|
strcpy(inout, months[tm->tm_mon - 1]);
|
2004-05-07 02:24:59 +02:00
|
|
|
*inout = pg_tolower((unsigned char) *inout);
|
2000-04-12 19:17:23 +02:00
|
|
|
return 2;
|
|
|
|
|
|
|
|
case DCH_MM:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, tm->tm_mon);
|
|
|
|
if (S_THth(suf))
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
if (S_FM(suf) || S_THth(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 1;
|
2000-07-01 23:27:14 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2001-09-06 05:22:42 +02:00
|
|
|
if (S_FM(suf) || is_next_separator(node))
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
sscanf(inout, "%d", &tmfc->mm);
|
2001-09-06 05:22:42 +02:00
|
|
|
return strdigits_len(inout) - 1 + SKIP_THth(suf);
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
sscanf(inout, "%02d", &tmfc->mm);
|
2000-04-12 19:17:23 +02:00
|
|
|
return 1 + SKIP_THth(suf);
|
|
|
|
}
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_DAY:
|
|
|
|
strcpy(inout, days[tm->tm_wday]);
|
|
|
|
sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, str_toupper(inout));
|
|
|
|
if (S_FM(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 8;
|
|
|
|
|
|
|
|
case DCH_Day:
|
|
|
|
sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, days[tm->tm_wday]);
|
|
|
|
if (S_FM(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 8;
|
|
|
|
|
|
|
|
case DCH_day:
|
|
|
|
sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, days[tm->tm_wday]);
|
2004-05-07 02:24:59 +02:00
|
|
|
*inout = pg_tolower((unsigned char) *inout);
|
2000-04-12 19:17:23 +02:00
|
|
|
if (S_FM(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 8;
|
|
|
|
|
|
|
|
case DCH_DY:
|
|
|
|
strcpy(inout, days[tm->tm_wday]);
|
|
|
|
inout = str_toupper(inout);
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
case DCH_Dy:
|
|
|
|
strcpy(inout, days[tm->tm_wday]);
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
case DCH_dy:
|
|
|
|
strcpy(inout, days[tm->tm_wday]);
|
2004-05-07 02:24:59 +02:00
|
|
|
*inout = pg_tolower((unsigned char) *inout);
|
2000-04-12 19:17:23 +02:00
|
|
|
return 2;
|
|
|
|
|
|
|
|
case DCH_DDD:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
sprintf(inout, "%0*d", S_FM(suf) ? 0 : 3, tm->tm_yday);
|
|
|
|
if (S_THth(suf))
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
if (S_FM(suf) || S_THth(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 2;
|
2000-07-01 23:27:14 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2001-09-06 05:22:42 +02:00
|
|
|
if (S_FM(suf) || is_next_separator(node))
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
sscanf(inout, "%d", &tmfc->ddd);
|
2001-09-06 05:22:42 +02:00
|
|
|
return strdigits_len(inout) - 1 + SKIP_THth(suf);
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
sscanf(inout, "%03d", &tmfc->ddd);
|
2000-04-12 19:17:23 +02:00
|
|
|
return 2 + SKIP_THth(suf);
|
|
|
|
}
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_DD:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, tm->tm_mday);
|
|
|
|
if (S_THth(suf))
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
if (S_FM(suf) || S_THth(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 1;
|
2000-07-01 23:27:14 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2001-09-06 05:22:42 +02:00
|
|
|
if (S_FM(suf) || is_next_separator(node))
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
sscanf(inout, "%d", &tmfc->dd);
|
2001-09-06 05:22:42 +02:00
|
|
|
return strdigits_len(inout) - 1 + SKIP_THth(suf);
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
sscanf(inout, "%02d", &tmfc->dd);
|
2000-04-12 19:17:23 +02:00
|
|
|
return 1 + SKIP_THth(suf);
|
|
|
|
}
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_D:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
sprintf(inout, "%d", tm->tm_wday + 1);
|
|
|
|
if (S_THth(suf))
|
|
|
|
{
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
sscanf(inout, "%1d", &tmfc->d);
|
2000-04-12 19:17:23 +02:00
|
|
|
return 0 + SKIP_THth(suf);
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_WW:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2,
|
2001-03-22 05:01:46 +01:00
|
|
|
(tm->tm_yday - 1) / 7 + 1);
|
2000-04-12 19:17:23 +02:00
|
|
|
if (S_THth(suf))
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
if (S_FM(suf) || S_THth(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
2001-03-22 05:01:46 +01:00
|
|
|
else if (flag == FROM_CHAR)
|
2000-07-03 18:01:33 +02:00
|
|
|
{
|
2001-09-06 05:22:42 +02:00
|
|
|
if (S_FM(suf) || is_next_separator(node))
|
2000-07-03 18:01:33 +02:00
|
|
|
{
|
|
|
|
sscanf(inout, "%d", &tmfc->ww);
|
2001-09-06 05:22:42 +02:00
|
|
|
return strdigits_len(inout) - 1 + SKIP_THth(suf);
|
2000-07-03 18:01:33 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sscanf(inout, "%02d", &tmfc->ww);
|
|
|
|
return 1 + SKIP_THth(suf);
|
|
|
|
}
|
|
|
|
}
|
2000-08-29 06:41:48 +02:00
|
|
|
break;
|
|
|
|
case DCH_IW:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2,
|
2001-03-22 05:01:46 +01:00
|
|
|
date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday));
|
2000-08-29 06:41:48 +02:00
|
|
|
if (S_THth(suf))
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
if (S_FM(suf) || S_THth(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
2001-03-22 05:01:46 +01:00
|
|
|
else if (flag == FROM_CHAR)
|
2000-08-29 06:41:48 +02:00
|
|
|
{
|
2001-09-06 05:22:42 +02:00
|
|
|
if (S_FM(suf) || is_next_separator(node))
|
2000-08-29 06:41:48 +02:00
|
|
|
{
|
|
|
|
sscanf(inout, "%d", &tmfc->iw);
|
2001-09-06 05:22:42 +02:00
|
|
|
return strdigits_len(inout) - 1 + SKIP_THth(suf);
|
2000-08-29 06:41:48 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sscanf(inout, "%02d", &tmfc->iw);
|
|
|
|
return 1 + SKIP_THth(suf);
|
|
|
|
}
|
|
|
|
}
|
2001-03-22 05:01:46 +01:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_Q:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
sprintf(inout, "%d", (tm->tm_mon - 1) / 3 + 1);
|
|
|
|
if (S_THth(suf))
|
|
|
|
{
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
2000-07-03 18:01:33 +02:00
|
|
|
{
|
|
|
|
sscanf(inout, "%1d", &tmfc->q);
|
|
|
|
return 0 + SKIP_THth(suf);
|
|
|
|
}
|
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_CC:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
i = tm->tm_year / 100 + 1;
|
|
|
|
if (i <= 99 && i >= -99)
|
|
|
|
sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, i);
|
|
|
|
else
|
|
|
|
sprintf(inout, "%d", i);
|
|
|
|
if (S_THth(suf))
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
2000-07-03 18:01:33 +02:00
|
|
|
{
|
2001-09-06 05:22:42 +02:00
|
|
|
if (S_FM(suf) || is_next_separator(node))
|
|
|
|
{
|
|
|
|
sscanf(inout, "%d", &tmfc->cc);
|
|
|
|
return strdigits_len(inout) - 1 + SKIP_THth(suf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sscanf(inout, "%02d", &tmfc->cc);
|
|
|
|
return 1 + SKIP_THth(suf);
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
}
|
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_Y_YYY:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
i = YEAR_ABS(tm->tm_year) / 1000;
|
|
|
|
sprintf(inout, "%d,%03d", i, YEAR_ABS(tm->tm_year) - (i * 1000));
|
|
|
|
if (S_THth(suf))
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
int cc;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2002-01-02 23:09:23 +01:00
|
|
|
sscanf(inout, "%d,%03d", &cc, &tmfc->year);
|
|
|
|
tmfc->year += (cc * 1000);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
return strdigits_len(inout) + 3 + SKIP_THth(suf);
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_YYYY:
|
2003-12-25 04:36:24 +01:00
|
|
|
case DCH_IYYY:
|
2000-04-12 19:17:23 +02:00
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
if (tm->tm_year <= 9999 && tm->tm_year >= -9998)
|
2003-12-25 04:36:24 +01:00
|
|
|
sprintf(inout, "%0*d",
|
2004-08-29 07:07:03 +02:00
|
|
|
S_FM(suf) ? 0 : 4,
|
|
|
|
arg == DCH_YYYY ?
|
|
|
|
YEAR_ABS(tm->tm_year) :
|
|
|
|
YEAR_ABS(date2isoyear(
|
|
|
|
tm->tm_year,
|
|
|
|
tm->tm_mon,
|
|
|
|
tm->tm_mday)));
|
2000-04-12 19:17:23 +02:00
|
|
|
else
|
2003-12-25 04:36:24 +01:00
|
|
|
sprintf(inout, "%d",
|
2004-08-29 07:07:03 +02:00
|
|
|
arg == DCH_YYYY ?
|
|
|
|
YEAR_ABS(tm->tm_year) :
|
|
|
|
YEAR_ABS(date2isoyear(
|
|
|
|
tm->tm_year,
|
|
|
|
tm->tm_mon,
|
|
|
|
tm->tm_mday)));
|
2000-04-12 19:17:23 +02:00
|
|
|
if (S_THth(suf))
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2001-09-06 05:22:42 +02:00
|
|
|
if (S_FM(suf) || is_next_separator(node))
|
|
|
|
{
|
2002-01-02 23:09:23 +01:00
|
|
|
sscanf(inout, "%d", &tmfc->year);
|
2001-09-06 05:22:42 +02:00
|
|
|
return strdigits_len(inout) - 1 + SKIP_THth(suf);
|
|
|
|
}
|
2000-11-25 06:00:33 +01:00
|
|
|
else
|
2001-09-06 05:22:42 +02:00
|
|
|
{
|
2002-01-02 23:09:23 +01:00
|
|
|
sscanf(inout, "%04d", &tmfc->year);
|
2001-09-06 05:22:42 +02:00
|
|
|
return 3 + SKIP_THth(suf);
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_YYY:
|
2003-12-25 04:36:24 +01:00
|
|
|
case DCH_IYY:
|
2000-04-12 19:17:23 +02:00
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
2003-12-25 04:36:24 +01:00
|
|
|
snprintf(buff, sizeof(buff), "%03d",
|
2004-08-29 07:07:03 +02:00
|
|
|
arg == DCH_YYY ?
|
|
|
|
YEAR_ABS(tm->tm_year) :
|
|
|
|
YEAR_ABS(date2isoyear(tm->tm_year,
|
|
|
|
tm->tm_mon, tm->tm_mday)));
|
2000-04-12 19:17:23 +02:00
|
|
|
i = strlen(buff);
|
|
|
|
strcpy(inout, buff + (i - 3));
|
|
|
|
if (S_THth(suf))
|
|
|
|
{
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
return 2;
|
2000-07-01 23:27:14 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2002-01-02 23:09:23 +01:00
|
|
|
sscanf(inout, "%03d", &tmfc->year);
|
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
|
|
|
*/
|
|
|
|
if (tmfc->year >= 100)
|
|
|
|
tmfc->year += 1000;
|
|
|
|
else
|
|
|
|
tmfc->year += 2000;
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
return 2 + SKIP_THth(suf);
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_YY:
|
2003-12-25 04:36:24 +01:00
|
|
|
case DCH_IY:
|
2000-04-12 19:17:23 +02:00
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
2003-12-25 04:36:24 +01:00
|
|
|
snprintf(buff, sizeof(buff), "%02d",
|
2004-08-29 07:07:03 +02:00
|
|
|
arg == DCH_YY ?
|
|
|
|
YEAR_ABS(tm->tm_year) :
|
|
|
|
YEAR_ABS(date2isoyear(tm->tm_year,
|
|
|
|
tm->tm_mon, tm->tm_mday)));
|
2000-04-12 19:17:23 +02:00
|
|
|
i = strlen(buff);
|
|
|
|
strcpy(inout, buff + (i - 2));
|
|
|
|
if (S_THth(suf))
|
|
|
|
{
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
return 1;
|
2000-07-01 23:27:14 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2002-01-02 23:09:23 +01:00
|
|
|
sscanf(inout, "%02d", &tmfc->year);
|
|
|
|
|
|
|
|
/*
|
2002-09-04 22:31:48 +02:00
|
|
|
* 2-digit year: '00' ... '69' = 2000 ... 2069 '70' ...
|
|
|
|
* '99' = 1970 ... 1999
|
2002-03-06 07:10:59 +01:00
|
|
|
*/
|
2002-01-02 23:09:23 +01:00
|
|
|
if (tmfc->year < 70)
|
|
|
|
tmfc->year += 2000;
|
|
|
|
else
|
|
|
|
tmfc->year += 1900;
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
return 1 + SKIP_THth(suf);
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_Y:
|
2003-12-25 04:36:24 +01:00
|
|
|
case DCH_I:
|
2000-04-12 19:17:23 +02:00
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
2003-12-25 04:36:24 +01:00
|
|
|
snprintf(buff, sizeof(buff), "%1d",
|
2004-08-29 07:07:03 +02:00
|
|
|
arg == DCH_Y ?
|
|
|
|
YEAR_ABS(tm->tm_year) :
|
|
|
|
YEAR_ABS(date2isoyear(tm->tm_year,
|
|
|
|
tm->tm_mon, tm->tm_mday)));
|
2000-04-12 19:17:23 +02:00
|
|
|
i = strlen(buff);
|
|
|
|
strcpy(inout, buff + (i - 1));
|
|
|
|
if (S_THth(suf))
|
|
|
|
{
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2002-01-02 23:09:23 +01:00
|
|
|
sscanf(inout, "%1d", &tmfc->year);
|
2002-03-06 07:10:59 +01:00
|
|
|
|
2002-01-02 23:09:23 +01:00
|
|
|
/*
|
|
|
|
* 1-digit year: always +2000
|
|
|
|
*/
|
|
|
|
tmfc->year += 2000;
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
return 0 + SKIP_THth(suf);
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_RM:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
sprintf(inout, "%*s", S_FM(suf) ? 0 : -4,
|
|
|
|
rm_months_upper[12 - tm->tm_mon]);
|
|
|
|
if (S_FM(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 3;
|
2000-07-01 23:27:14 +02:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2000-07-03 18:01:33 +02:00
|
|
|
tmfc->mm = 12 - seq_search(inout, rm_months_upper, ALL_UPPER, FULL_SIZ, &len);
|
2000-04-12 19:17:23 +02:00
|
|
|
CHECK_SEQ_SEARCH(len, "RM");
|
|
|
|
if (S_FM(suf))
|
|
|
|
return len - 1;
|
|
|
|
else
|
|
|
|
return 3;
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_rm:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
sprintf(inout, "%*s", S_FM(suf) ? 0 : -4,
|
|
|
|
rm_months_lower[12 - tm->tm_mon]);
|
|
|
|
if (S_FM(suf))
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
else
|
|
|
|
return 3;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
|
|
|
{
|
2001-12-10 16:34:05 +01:00
|
|
|
tmfc->mm = 12 - seq_search(inout, rm_months_lower, ALL_LOWER, FULL_SIZ, &len);
|
2000-04-12 19:17:23 +02:00
|
|
|
CHECK_SEQ_SEARCH(len, "rm");
|
|
|
|
if (S_FM(suf))
|
|
|
|
return len - 1;
|
|
|
|
else
|
|
|
|
return 3;
|
|
|
|
}
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_W:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
sprintf(inout, "%d", (tm->tm_mday - 1) / 7 + 1);
|
2000-04-12 19:17:23 +02:00
|
|
|
if (S_THth(suf))
|
|
|
|
{
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
2000-07-03 18:01:33 +02:00
|
|
|
{
|
|
|
|
sscanf(inout, "%1d", &tmfc->w);
|
|
|
|
return 0 + SKIP_THth(suf);
|
|
|
|
}
|
|
|
|
break;
|
2000-04-12 19:17:23 +02:00
|
|
|
case DCH_J:
|
|
|
|
if (flag == TO_CHAR)
|
|
|
|
{
|
|
|
|
sprintf(inout, "%d", date2j(tm->tm_year, tm->tm_mon, tm->tm_mday));
|
|
|
|
if (S_THth(suf))
|
|
|
|
str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
|
|
return strlen(p_inout) - 1;
|
|
|
|
}
|
|
|
|
else if (flag == FROM_CHAR)
|
2000-07-03 18:01:33 +02:00
|
|
|
{
|
|
|
|
sscanf(inout, "%d", &tmfc->j);
|
2001-09-06 05:22:42 +02:00
|
|
|
return strdigits_len(inout) - 1 + SKIP_THth(suf);
|
2000-07-03 18:01:33 +02:00
|
|
|
}
|
|
|
|
break;
|
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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
static text *
|
|
|
|
datetime_to_char_body(TmToChar *tmtc, text *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 05:01:46 +01:00
|
|
|
FormatNode *format;
|
2004-08-29 07:07:03 +02:00
|
|
|
struct pg_tm *tm = NULL;
|
2003-09-03 16:59:41 +02:00
|
|
|
char *fmt_str,
|
2004-08-29 07:07:03 +02:00
|
|
|
*result;
|
|
|
|
bool incache;
|
|
|
|
int fmt_len = VARSIZE(fmt) - VARHDRSZ;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
tm = tmtcTm(tmtc);
|
2000-04-12 19:17:23 +02:00
|
|
|
tm->tm_wday = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) + 1) % 7;
|
|
|
|
tm->tm_yday = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(tm->tm_year, 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
|
|
|
|
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
|
|
|
*/
|
2003-09-03 16:59:41 +02:00
|
|
|
fmt_str = (char *) palloc(fmt_len + 1);
|
|
|
|
memcpy(fmt_str, VARDATA(fmt), fmt_len);
|
|
|
|
*(fmt_str + fmt_len) = '\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
|
|
|
/*
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/include/utils/formatting.h
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
2000-01-26 00:53:56 +01:00
|
|
|
* Allocate result
|
|
|
|
*/
|
2003-09-03 16:59:41 +02:00
|
|
|
result = palloc((fmt_len * DCH_MAX_ITEM_SIZ) + 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
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-04-12 19:17:23 +02:00
|
|
|
* Allocate new memory if format picture is bigger than static cache
|
2004-08-29 07:07:03 +02:00
|
|
|
* 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-07-01 23:27:14 +02: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
|
|
|
* 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
|
|
|
/*
|
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.
|
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
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
DCH_processor(format, result, TO_CHAR, (void *) tmtc);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-03-16 02:35:41 +01:00
|
|
|
* for result is allocated max memory, which current format-picture
|
2001-09-06 05:22:42 +02:00
|
|
|
* needs, now it allocate result with real size
|
2000-04-12 19:17:23 +02:00
|
|
|
*/
|
2003-09-03 16:59:41 +02:00
|
|
|
if (result && *result)
|
2001-09-06 05:22:42 +02:00
|
|
|
{
|
2004-08-29 07:07:03 +02:00
|
|
|
int len = strlen(result);
|
|
|
|
|
2003-09-03 16:59:41 +02:00
|
|
|
if (len)
|
|
|
|
{
|
|
|
|
text *res = (text *) palloc(len + 1 + VARHDRSZ);
|
2001-09-06 05:22:42 +02:00
|
|
|
|
2003-09-03 16:59:41 +02:00
|
|
|
memcpy(VARDATA(res), result, len);
|
|
|
|
VARATT_SIZEP(res) = len + VARHDRSZ;
|
|
|
|
pfree(result);
|
|
|
|
return res;
|
|
|
|
}
|
2000-09-25 14:58:47 +02:00
|
|
|
}
|
2003-09-03 16:59:41 +02:00
|
|
|
pfree(result);
|
2001-09-06 05:22:42 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
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;
|
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);
|
|
|
|
|
2003-07-27 06:53:12 +02:00
|
|
|
if (timestamp2tm(dt, NULL, tmtcTm(&tmtc), &tmtcFsec(&tmtc), NULL) != 0)
|
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
|
|
|
errmsg("timestamp out of range")));
|
2001-09-28 10:09:14 +02:00
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
if (!(res = datetime_to_char_body(&tmtc, fmt)))
|
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;
|
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);
|
2000-03-16 02:35:41 +01:00
|
|
|
|
2003-07-27 06:53:12 +02:00
|
|
|
if (timestamp2tm(dt, &tz, tmtcTm(&tmtc), &tmtcFsec(&tmtc), &tmtcTzn(&tmtc)) != 0)
|
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
|
|
|
|
errmsg("timestamp out of range")));
|
2001-09-06 05:22:42 +02:00
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
if (!(res = datetime_to_char_body(&tmtc, fmt)))
|
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;
|
2001-09-06 05:22:42 +02:00
|
|
|
|
|
|
|
if ((VARSIZE(fmt) - VARHDRSZ) <= 0)
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
|
|
|
ZERO_tmtc(&tmtc);
|
|
|
|
|
|
|
|
if (interval2tm(*it, tmtcTm(&tmtc), &tmtcFsec(&tmtc)) != 0)
|
|
|
|
PG_RETURN_NULL();
|
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
if (!(res = datetime_to_char_body(&tmtc, fmt)))
|
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);
|
|
|
|
|
|
|
|
tz = DetermineLocalTimeZone(&tm);
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
do_to_timestamp(text *date_txt, text *fmt,
|
2004-08-29 07:07:03 +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;
|
2004-08-29 07:07:03 +02:00
|
|
|
int fmt_len;
|
2003-08-25 18:13:27 +02:00
|
|
|
|
|
|
|
ZERO_tm(tm);
|
|
|
|
*fsec = 0;
|
2001-09-06 05:22:42 +02:00
|
|
|
|
|
|
|
ZERO_tmfc(&tmfc);
|
2000-07-01 16:10:32 +02:00
|
|
|
|
2003-09-03 16:59:41 +02:00
|
|
|
fmt_len = VARSIZE(fmt) - VARHDRSZ;
|
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
|
|
|
int date_len;
|
|
|
|
char *fmt_str;
|
|
|
|
char *date_str;
|
|
|
|
bool incache;
|
|
|
|
|
2003-09-03 16:59:41 +02:00
|
|
|
fmt_str = (char *) palloc(fmt_len + 1);
|
|
|
|
memcpy(fmt_str, VARDATA(fmt), fmt_len);
|
|
|
|
*(fmt_str + fmt_len) = '\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
|
|
|
/*
|
|
|
|
* Allocate new memory if format picture is bigger than static
|
2003-09-03 16:59:41 +02:00
|
|
|
* 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
|
|
|
{
|
2000-07-01 23:27:14 +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;
|
|
|
|
}
|
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-04-12 19:17:23 +02:00
|
|
|
* Call action for each node in FormatNode tree
|
|
|
|
*/
|
|
|
|
#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
|
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-12-01 06:17:19 +01:00
|
|
|
* Convert date to C string
|
|
|
|
*/
|
|
|
|
date_len = VARSIZE(date_txt) - VARHDRSZ;
|
|
|
|
date_str = (char *) palloc(date_len + 1);
|
|
|
|
memcpy(date_str, VARDATA(date_txt), date_len);
|
|
|
|
*(date_str + date_len) = '\0';
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-09-06 05:22:42 +02:00
|
|
|
DCH_processor(format, date_str, FROM_CHAR, (void *) &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
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
2003-08-25 18:13:27 +02:00
|
|
|
tm->tm_hour = x / 3600;
|
2000-12-23 05:05:31 +01:00
|
|
|
x %= 3600;
|
2003-08-25 18:13:27 +02:00
|
|
|
tm->tm_min = x / 60;
|
2000-12-23 05:05:31 +01:00
|
|
|
x %= 60;
|
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.cc)
|
2003-08-25 18:13:27 +02:00
|
|
|
tm->tm_year = (tmfc.cc - 1) * 100;
|
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
|
|
|
|
2002-01-02 23:09:23 +01:00
|
|
|
if (tmfc.year)
|
2003-08-25 18:13:27 +02:00
|
|
|
tm->tm_year = tmfc.year;
|
2000-11-25 06:00:33 +01:00
|
|
|
|
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)
|
2003-08-25 18:13:27 +02:00
|
|
|
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;
|
2001-09-06 05:22:42 +02:00
|
|
|
if (tmfc.ddd)
|
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
|
|
|
|
2000-08-29 06:41:48 +02:00
|
|
|
/*
|
2001-09-06 05:22:42 +02:00
|
|
|
* we don't ignore DDD
|
2000-08-29 06:41:48 +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
|
|
|
{
|
|
|
|
/* count mday and mon from yday */
|
2001-03-22 05:01:46 +01:00
|
|
|
int *y,
|
|
|
|
i;
|
|
|
|
|
|
|
|
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}};
|
|
|
|
|
2003-08-25 18:13:27 +02:00
|
|
|
if (!tm->tm_year)
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_INVALID_DATETIME_FORMAT),
|
2004-08-29 07:07:03 +02:00
|
|
|
errmsg("cannot calculate day of year without year information")));
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2003-08-25 18:13:27 +02:00
|
|
|
y = ysum[isleap(tm->tm_year)];
|
2001-03-22 05:01:46 +01:00
|
|
|
|
|
|
|
for (i = 0; i <= 11; i++)
|
|
|
|
{
|
2003-08-25 18:13:27 +02:00
|
|
|
if (tm->tm_yday < y[i])
|
2000-07-03 18:01:33 +02:00
|
|
|
break;
|
2001-03-22 05:01:46 +01:00
|
|
|
}
|
2003-08-25 18:13:27 +02:00
|
|
|
if (tm->tm_mon <= 1)
|
|
|
|
tm->tm_mon = i + 1;
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2003-08-25 18:13:27 +02:00
|
|
|
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);
|
2000-04-12 19:17:23 +02:00
|
|
|
*(str + max + 1) = '\0';
|
|
|
|
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 *
|
2002-09-20 05:54:57 +02:00
|
|
|
NUM_cache(int len, NUMDesc *Num, char *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
|
|
|
|
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
|
|
|
* Convert VARDATA() to string
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
str = (char *) palloc(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
|
|
|
memcpy(str, pars_str, len);
|
2000-04-12 19:17:23 +02:00
|
|
|
*(str + len) = '\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
|
|
|
/*
|
2000-04-12 19:17:23 +02:00
|
|
|
* Allocate new memory if format picture is bigger than static cache
|
2002-09-20 05:54:57 +02:00
|
|
|
* 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
|
|
|
/*
|
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
|
|
|
*/
|
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,
|
|
|
|
num = 0,
|
|
|
|
set = 0;
|
|
|
|
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 (num == -1 && set == 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
|
|
|
continue;
|
|
|
|
set = 1;
|
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)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
|
|
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
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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 (lconv->positive_sign && *lconv->positive_sign)
|
|
|
|
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 thousands separator
|
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 (lconv->thousands_sep && *lconv->thousands_sep)
|
|
|
|
Np->L_thousands_sep = lconv->thousands_sep;
|
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->L_thousands_sep = ",";
|
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
|
|
|
* Number decimal point
|
|
|
|
*/
|
|
|
|
if (lconv->decimal_point && *lconv->decimal_point)
|
|
|
|
Np->decimal = lconv->decimal_point;
|
2004-08-30 04:54:42 +02:00
|
|
|
|
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
|
|
|
|
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 = " ";
|
|
|
|
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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_LDECIMAL(Np->Num))
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->decimal = ".";
|
|
|
|
}
|
|
|
|
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 = ".";
|
2004-08-30 04:54:42 +02: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
|
|
|
{
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-02-08 16:57:01 +01:00
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
|
|
|
elog(DEBUG_elog_output, " --- scan start --- ");
|
|
|
|
#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)
|
|
|
|
|
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
|
|
|
/*
|
2000-02-08 16:57:01 +01:00
|
|
|
* read 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
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (*Np->number == ' ' && (id == NUM_0 || id == NUM_9 || NUM_S))
|
|
|
|
{
|
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 sign (%c)", *Np->inout_p);
|
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
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (IS_LSIGN(Np->Num))
|
|
|
|
{
|
|
|
|
|
|
|
|
int x = strlen(Np->L_negative_sign);
|
|
|
|
|
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 sign (%c)", *Np->inout_p);
|
2000-04-12 19:17:23 +02:00
|
|
|
#endif
|
|
|
|
if (!strncmp(Np->inout_p, Np->L_negative_sign, x))
|
|
|
|
{
|
|
|
|
Np->inout_p += x - 1;
|
2000-02-08 16:57:01 +01:00
|
|
|
*Np->number = '-';
|
|
|
|
return;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
|
|
x = strlen(Np->L_positive_sign);
|
2000-04-12 19:17:23 +02:00
|
|
|
if (!strncmp(Np->inout_p, Np->L_positive_sign, x))
|
|
|
|
{
|
|
|
|
Np->inout_p += x - 1;
|
2000-02-08 16:57:01 +01:00
|
|
|
*Np->number = '+';
|
|
|
|
return;
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
|
|
}
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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
|
|
|
#ifdef DEBUG_TO_FROM_CHAR
|
2003-07-27 06:53:12 +02:00
|
|
|
elog(DEBUG_elog_output, "Try read simple sign (%c)", *Np->inout_p);
|
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
|
|
|
* simple + - < >
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (*Np->inout_p == '-' || (IS_BRACKET(Np->Num) &&
|
2003-08-04 02:43:34 +02:00
|
|
|
*Np->inout_p == '<'))
|
2000-04-12 19:17:23 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
*Np->number = '-'; /* set - */
|
2000-02-08 16:57:01 +01:00
|
|
|
Np->inout_p++;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
else if (*Np->inout_p == '+')
|
|
|
|
{
|
|
|
|
|
|
|
|
*Np->number = '+'; /* set + */
|
2000-02-08 16:57:01 +01: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;
|
2000-04-12 19:17:23 +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++;
|
|
|
|
|
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
|
|
|
|
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-04-12 19:17:23 +02:00
|
|
|
* read decimal point
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
else if (IS_DECIMAL(Np->Num))
|
|
|
|
{
|
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;
|
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
|
|
|
|
if (!strncmp(Np->inout_p, Np->decimal, x))
|
|
|
|
{
|
|
|
|
Np->inout_p += x - 1;
|
2000-02-08 16:57:01 +01:00
|
|
|
*Np->number_p = '.';
|
|
|
|
Np->number_p++;
|
|
|
|
Np->read_dec = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
}
|
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
|
|
|
/*
|
2003-08-04 02:43:34 +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-02-08 16:57:01 +01:00
|
|
|
|
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,
|
|
|
|
int plen, int sign, int 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
|
|
|
{
|
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;
|
|
|
|
Np->type = type;
|
|
|
|
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;
|
|
|
|
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))
|
|
|
|
{
|
|
|
|
if (Np->type == FROM_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
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (type == FROM_CHAR)
|
|
|
|
Np->sign = FALSE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
if (type == TO_CHAR)
|
|
|
|
{
|
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 +
|
2001-03-22 05:01:46 +01: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
|
|
|
|
*/
|
2000-04-12 19:17:23 +02:00
|
|
|
if (Np->type == FROM_CHAR)
|
|
|
|
Np->number_p = Np->number + 1; /* first char is space for 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
|
|
|
else if (Np->type == TO_CHAR)
|
2000-04-12 19:17:23 +02:00
|
|
|
Np->number_p = Np->number;
|
|
|
|
|
|
|
|
for (n = node, Np->inout_p = Np->inout; n->type != NODE_TYPE_END; n++)
|
|
|
|
{
|
2000-02-08 16:57:01 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
if (Np->type == FROM_CHAR)
|
|
|
|
{
|
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
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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:
|
|
|
|
if (Np->type == TO_CHAR)
|
|
|
|
{
|
|
|
|
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:
|
|
|
|
if (Np->type == TO_CHAR)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
else if (Np->type == FROM_CHAR)
|
|
|
|
{
|
|
|
|
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:
|
|
|
|
if (Np->type == TO_CHAR)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (Np->type == FROM_CHAR)
|
|
|
|
{
|
|
|
|
if (!Np->num_in)
|
|
|
|
{
|
|
|
|
if (IS_FILLMODE(Np->Num))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Np->inout_p += strlen(Np->L_thousands_sep) - 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NUM_L:
|
|
|
|
if (Np->type == TO_CHAR)
|
|
|
|
{
|
|
|
|
strcpy(Np->inout_p, Np->L_currency_symbol);
|
|
|
|
Np->inout_p += strlen(Np->inout_p) - 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (Np->type == FROM_CHAR)
|
|
|
|
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))
|
|
|
|
{
|
|
|
|
strcpy(Np->inout_p, str_tolower(Np->number_p));
|
|
|
|
Np->inout_p += strlen(Np->inout_p) - 1;
|
|
|
|
}
|
|
|
|
else
|
2001-12-05 03:06:19 +01:00
|
|
|
{
|
|
|
|
sprintf(Np->inout_p, "%15s", str_tolower(Np->number_p));
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (Np->type == TO_CHAR)
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (Np->type == TO_CHAR)
|
|
|
|
strcpy(Np->inout_p, get_th(Np->number, TH_UPPER));
|
|
|
|
Np->inout_p += 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NUM_MI:
|
|
|
|
if (Np->type == TO_CHAR)
|
|
|
|
{
|
|
|
|
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 = ' ';
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (Np->type == FROM_CHAR)
|
|
|
|
{
|
|
|
|
if (*Np->inout_p == '-')
|
|
|
|
*Np->number = '-';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NUM_PL:
|
|
|
|
if (Np->type == TO_CHAR)
|
|
|
|
{
|
|
|
|
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 = ' ';
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (Np->type == FROM_CHAR)
|
|
|
|
{
|
|
|
|
if (*Np->inout_p == '+')
|
|
|
|
*Np->number = '+';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NUM_SG:
|
|
|
|
if (Np->type == TO_CHAR)
|
|
|
|
*Np->inout_p = Np->sign;
|
|
|
|
|
|
|
|
else if (Np->type == FROM_CHAR)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
if (Np->type == TO_CHAR)
|
|
|
|
*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
|
|
|
|
|
|
|
if (Np->type == 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 = '\0';
|
2000-04-12 19:17:23 +02:00
|
|
|
return Np->inout;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (Np->type == FROM_CHAR)
|
|
|
|
{
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------
|
|
|
|
* 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 { \
|
2000-04-12 19:17:23 +02:00
|
|
|
len = VARSIZE(fmt) - VARHDRSZ; \
|
2000-07-01 23:27:14 +02:00
|
|
|
if (len <= 0) \
|
2000-07-06 01:12:09 +02:00
|
|
|
return DirectFunctionCall1(textin, CStringGetDatum("")); \
|
2000-07-03 18:01:33 +02:00
|
|
|
result = (text *) palloc( (len * NUM_MAX_ITEM_SIZ) + 1 + VARHDRSZ); \
|
2003-03-27 17:35:31 +01:00
|
|
|
memset(result, 0, (len * NUM_MAX_ITEM_SIZ) + 1 + VARHDRSZ ); \
|
2002-09-20 05:54:57 +02:00
|
|
|
format = NUM_cache(len, &Num, VARDATA(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 { \
|
2000-04-12 19:17:23 +02:00
|
|
|
NUM_processor(format, &Num, VARDATA(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
|
|
|
numstr, plen, sign, TO_CHAR); \
|
|
|
|
pfree(orgnum); \
|
|
|
|
\
|
2002-09-20 05:54:57 +02:00
|
|
|
if (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
|
|
|
pfree(format); \
|
|
|
|
\
|
2001-03-22 07:16:21 +01:00
|
|
|
/*
|
2000-03-16 02:35:41 +01:00
|
|
|
* for result is allocated max memory, which current format-picture\
|
|
|
|
* needs, now it must be re-allocate to result real size \
|
|
|
|
*/ \
|
2000-09-25 14:58:47 +02:00
|
|
|
if (!(len = strlen(VARDATA(result)))) \
|
|
|
|
{ \
|
|
|
|
pfree(result); \
|
|
|
|
PG_RETURN_NULL(); \
|
|
|
|
} \
|
|
|
|
\
|
2000-04-12 19:17:23 +02:00
|
|
|
result_tmp = result; \
|
|
|
|
result = (text *) palloc( len + 1 + VARHDRSZ); \
|
2000-03-16 02:35:41 +01:00
|
|
|
\
|
2000-04-12 19:17:23 +02:00
|
|
|
strcpy( VARDATA(result), VARDATA(result_tmp)); \
|
2000-07-04 01:10:14 +02:00
|
|
|
VARATT_SIZEP(result) = len + VARHDRSZ; \
|
2000-03-16 02:35:41 +01:00
|
|
|
pfree(result_tmp); \
|
2000-07-03 18:01:33 +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
|
|
|
|
|
|
|
/* -------------------
|
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;
|
|
|
|
|
2000-07-01 23:27:14 +02:00
|
|
|
if (len <= 0)
|
|
|
|
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
|
|
|
|
2002-09-20 05:54:57 +02:00
|
|
|
format = NUM_cache(len, &Num, VARDATA(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,
|
|
|
|
VARSIZE(value) - VARHDRSZ, 0, FROM_CHAR);
|
|
|
|
|
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),
|
|
|
|
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;
|
2001-03-22 05:01:46 +01:00
|
|
|
text *result,
|
|
|
|
*result_tmp;
|
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,
|
2001-03-22 05:01:46 +01:00
|
|
|
NumericGetDatum(x))));
|
2000-04-12 19:17:23 +02:00
|
|
|
pfree(x);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Numeric val = value;
|
|
|
|
|
|
|
|
if (IS_MULTI(&Num))
|
|
|
|
{
|
2000-07-01 23:27:14 +02:00
|
|
|
Numeric a = DatumGetNumeric(DirectFunctionCall1(int4_numeric,
|
2001-03-22 05:01:46 +01:00
|
|
|
Int32GetDatum(10)));
|
2000-07-01 23:27:14 +02:00
|
|
|
Numeric b = DatumGetNumeric(DirectFunctionCall1(int4_numeric,
|
2001-03-22 05:01:46 +01: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,
|
2001-03-22 05:01:46 +01:00
|
|
|
NumericGetDatum(value),
|
|
|
|
NumericGetDatum(x)));
|
2000-03-16 02:35:41 +01:00
|
|
|
pfree(x);
|
|
|
|
pfree(a);
|
|
|
|
pfree(b);
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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-03-16 02:35:41 +01:00
|
|
|
pfree(x);
|
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)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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(numstr, '#', Num.pre);
|
|
|
|
*(numstr + Num.pre) = '.';
|
2000-02-08 16:57:01 +01:00
|
|
|
fill_str(numstr + 1 + Num.pre, '#', Num.post);
|
2000-03-16 02:35:41 +01:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-03-16 02:35:41 +01:00
|
|
|
if (IS_MULTI(&Num))
|
2000-04-12 19:17:23 +02:00
|
|
|
pfree(val);
|
|
|
|
}
|
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;
|
2001-03-22 05:01:46 +01:00
|
|
|
text *result,
|
|
|
|
*result_tmp;
|
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,
|
2001-03-22 05:01:46 +01:00
|
|
|
Int32GetDatum(value)));
|
2000-06-05 09:29:25 +02:00
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
len = strlen(orgnum);
|
|
|
|
|
|
|
|
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
|
|
|
--len;
|
|
|
|
}
|
|
|
|
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 = '+';
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (Num.post)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
int i;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-12-01 06:17:19 +01:00
|
|
|
numstr = (char *) palloc(len + Num.post + 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
|
|
|
strcpy(numstr, orgnum + (*orgnum == '-' ? 1 : 0));
|
2000-04-12 19:17:23 +02:00
|
|
|
*(numstr + len) = '.';
|
|
|
|
|
2000-12-01 06:17:19 +01:00
|
|
|
for (i = len + 1; i <= len + Num.post; i++)
|
2000-04-12 19:17:23 +02:00
|
|
|
*(numstr + i) = '0';
|
2000-12-01 06:17:19 +01:00
|
|
|
*(numstr + len + Num.post + 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
|
|
|
pfree(orgnum);
|
2000-04-12 19:17:23 +02:00
|
|
|
orgnum = 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
|
|
|
numstr = orgnum + (*orgnum == '-' ? 1 : 0);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (Num.pre > len)
|
|
|
|
plen = Num.pre - len;
|
|
|
|
else if (len > Num.pre)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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(numstr, '#', Num.pre);
|
|
|
|
*(numstr + Num.pre) = '.';
|
2000-02-08 16:57:01 +01:00
|
|
|
fill_str(numstr + 1 + Num.pre, '#', Num.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_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;
|
2001-03-22 05:01:46 +01:00
|
|
|
text *result,
|
|
|
|
*result_tmp;
|
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(
|
2001-03-22 05:01:46 +01: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,
|
2001-03-22 05:01:46 +01: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,
|
2001-03-22 05:01:46 +01:00
|
|
|
Int64GetDatum(value)));
|
2000-04-12 19:17:23 +02:00
|
|
|
len = strlen(orgnum);
|
|
|
|
|
|
|
|
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
|
|
|
--len;
|
|
|
|
}
|
|
|
|
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 = '+';
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (Num.post)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
int i;
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-12-01 06:17:19 +01:00
|
|
|
numstr = (char *) palloc(len + Num.post + 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
|
|
|
strcpy(numstr, orgnum + (*orgnum == '-' ? 1 : 0));
|
2000-04-12 19:17:23 +02:00
|
|
|
*(numstr + len) = '.';
|
|
|
|
|
2000-12-01 06:17:19 +01:00
|
|
|
for (i = len + 1; i <= len + Num.post; i++)
|
2000-04-12 19:17:23 +02:00
|
|
|
*(numstr + i) = '0';
|
2000-12-01 06:17:19 +01:00
|
|
|
*(numstr + len + Num.post + 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
|
|
|
pfree(orgnum);
|
2000-04-12 19:17:23 +02:00
|
|
|
orgnum = 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
|
|
|
numstr = orgnum + (*orgnum == '-' ? 1 : 0);
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
if (Num.pre > len)
|
|
|
|
plen = Num.pre - len;
|
|
|
|
else if (len > Num.pre)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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(numstr, '#', Num.pre);
|
|
|
|
*(numstr + Num.pre) = '.';
|
2000-02-08 16:57:01 +01:00
|
|
|
fill_str(numstr + 1 + Num.pre, '#', Num.post);
|
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;
|
2001-03-22 05:01:46 +01:00
|
|
|
text *result,
|
|
|
|
*result_tmp;
|
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)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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(numstr, '#', Num.pre);
|
|
|
|
*(numstr + Num.pre) = '.';
|
2000-02-08 16:57:01 +01:00
|
|
|
fill_str(numstr + 1 + Num.pre, '#', Num.post);
|
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;
|
2001-03-22 05:01:46 +01:00
|
|
|
text *result,
|
|
|
|
*result_tmp;
|
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)
|
|
|
|
{
|
as attache of this mail is patch (to the main tree) with to_char's
family functions. Contain:
conversion from a datetype to formatted text:
to_char( datetime, text)
to_char( timestamp, text)
to_char( int4, text)
to_char( int8, text)
to_char( float4, text)
to_char( float8, text)
to_char( numeric, text)
vice versa:
to_date ( text, text)
to_datetime ( text, text)
to_timestamp ( text, text)
to_number ( text, text) (convert to numeric)
PostgreSQL to_char is very compatible with Oracle's to_char(), but not
total exactly (now). Small differentions are in number formating. It will
fix in next to_char() version.
! If will this patch aplly to the main tree, must be delete the current
to_char version in contrib (directory "dateformat" and note in contrib's
README), this patch not erase it (sorry Bruce).
The patch patching files:
doc/src/sgml/func.sgml
^^^^^^^^
Hmm, I'm not sure if my English... :( Check it anyone (volunteer)?
Thomas, it is right? SGML is not my primary lang and compile
the current PG docs tree is very happy job (hard variables setting in
docs/sgml/Makefile --> HSTYLE= /home/users/t/thomas/.... :-)
What add any definition to global configure.in and set Makefiles in docs
tree via ./configure?
src/backend/utils/adt/Makefile
src/backend/utils/adt/formatting.c
src/include/catalog/pg_proc.h
src/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(numstr, '#', Num.pre);
|
|
|
|
*(numstr + Num.pre) = '.';
|
2000-02-08 16:57:01 +01:00
|
|
|
fill_str(numstr + 1 + Num.pre, '#', Num.post);
|
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
|
|
|
}
|