Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
3e803f72
Commit
3e803f72
authored
Feb 19, 2007
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add "isodow" option to EXTRACT() and date_part() where Sunday = 7.
parent
27d6ee04
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
13 deletions
+42
-13
doc/src/sgml/func.sgml
doc/src/sgml/func.sgml
+27
-8
src/backend/utils/adt/datetime.c
src/backend/utils/adt/datetime.c
+2
-1
src/backend/utils/adt/timestamp.c
src/backend/utils/adt/timestamp.c
+7
-1
src/include/utils/datetime.h
src/include/utils/datetime.h
+2
-1
src/interfaces/ecpg/pgtypeslib/dt.h
src/interfaces/ecpg/pgtypeslib/dt.h
+2
-1
src/interfaces/ecpg/pgtypeslib/dt_common.c
src/interfaces/ecpg/pgtypeslib/dt_common.c
+2
-1
No files found.
doc/src/sgml/func.sgml
View file @
3e803f72
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.36
1 2007/02/16 07:46:54 petere
Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.36
2 2007/02/19 17:41:38 momjian
Exp $ -->
<chapter
id=
"functions"
>
<chapter
id=
"functions"
>
<title>
Functions and Operators
</title>
<title>
Functions and Operators
</title>
...
@@ -5732,8 +5732,8 @@ SELECT EXTRACT(DECADE FROM TIMESTAMP '2001-02-16 20:38:40');
...
@@ -5732,8 +5732,8 @@ SELECT EXTRACT(DECADE FROM TIMESTAMP '2001-02-16 20:38:40');
<term><literal>
dow
</literal></term>
<term><literal>
dow
</literal></term>
<listitem>
<listitem>
<para>
<para>
The day of the week
(0 - 6; Sunday is 0) (for
The day of the week
as Sunday(
<literal>
0
</>
) to
<type>
timestamp
</type>
values only
)
Saturday(
<literal>
6
</>
)
</para>
</para>
<screen>
<screen>
...
@@ -5741,7 +5741,7 @@ SELECT EXTRACT(DOW FROM TIMESTAMP '2001-02-16 20:38:40');
...
@@ -5741,7 +5741,7 @@ SELECT EXTRACT(DOW FROM TIMESTAMP '2001-02-16 20:38:40');
<lineannotation>
Result:
</lineannotation><computeroutput>
5
</computeroutput>
<lineannotation>
Result:
</lineannotation><computeroutput>
5
</computeroutput>
</screen>
</screen>
<para>
<para>
Note that
<function>
extract
</function>
's day of the week numbering is
Note that
<function>
extract
</function>
's day of the week numbering is
different from that of the
<function>
to_char
</function>
function.
different from that of the
<function>
to_char
</function>
function.
</para>
</para>
...
@@ -5752,7 +5752,7 @@ SELECT EXTRACT(DOW FROM TIMESTAMP '2001-02-16 20:38:40');
...
@@ -5752,7 +5752,7 @@ SELECT EXTRACT(DOW FROM TIMESTAMP '2001-02-16 20:38:40');
<term><literal>
doy
</literal></term>
<term><literal>
doy
</literal></term>
<listitem>
<listitem>
<para>
<para>
The day of the year (1 - 365/366)
(for
<type>
timestamp
</type>
values only)
The day of the year (1 - 365/366)
</para>
</para>
<screen>
<screen>
...
@@ -5805,6 +5805,26 @@ SELECT EXTRACT(HOUR FROM TIMESTAMP '2001-02-16 20:38:40');
...
@@ -5805,6 +5805,26 @@ SELECT EXTRACT(HOUR FROM TIMESTAMP '2001-02-16 20:38:40');
</listitem>
</listitem>
</varlistentry>
</varlistentry>
<varlistentry>
<term><literal>
isodow
</literal></term>
<listitem>
<para>
The day of the week as Monday(
<literal>
1
</>
) to
Sunday(
<literal>
7
</>
)
</para>
<screen>
SELECT EXTRACT(ISODOW FROM TIMESTAMP '2001-02-18 20:38:40');
<lineannotation>
Result:
</lineannotation><computeroutput>
7
</computeroutput>
</screen>
<para>
This is identical to
<literal>
dow
</>
except for Sunday. This
matches the
<acronym>
ISO
</>
8601 day of the week numbering.
</para>
</listitem>
</varlistentry>
<varlistentry>
<varlistentry>
<term><literal>
isoyear
</literal></term>
<term><literal>
isoyear
</literal></term>
<listitem>
<listitem>
...
@@ -5923,8 +5943,7 @@ SELECT EXTRACT(MONTH FROM INTERVAL '2 years 13 months');
...
@@ -5923,8 +5943,7 @@ SELECT EXTRACT(MONTH FROM INTERVAL '2 years 13 months');
<term><literal>
quarter
</literal></term>
<term><literal>
quarter
</literal></term>
<listitem>
<listitem>
<para>
<para>
The quarter of the year (1 - 4) that the day is in (for
The quarter of the year (1 - 4) that the day is in
<type>
timestamp
</type>
values only)
</para>
</para>
<screen>
<screen>
...
@@ -5989,7 +6008,7 @@ SELECT EXTRACT(SECOND FROM TIME '17:12:28.5');
...
@@ -5989,7 +6008,7 @@ SELECT EXTRACT(SECOND FROM TIME '17:12:28.5');
(
<acronym>
ISO
</acronym>
8601), the first week of a year
(
<acronym>
ISO
</acronym>
8601), the first week of a year
contains January 4 of that year. (The
<acronym>
ISO
</acronym>
-8601
contains January 4 of that year. (The
<acronym>
ISO
</acronym>
-8601
week starts on Monday.) In other words, the first Thursday of
week starts on Monday.) In other words, the first Thursday of
a year is in week 1 of that year.
(for
<type>
timestamp
</type>
values only)
a year is in week 1 of that year.
</para>
</para>
<para>
<para>
Because of this, it is possible for early January dates to be part of the
Because of this, it is possible for early January dates to be part of the
...
...
src/backend/utils/adt/datetime.c
View file @
3e803f72
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.17
6 2007/02/16 03:39:45
momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.17
7 2007/02/19 17:41:39
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -125,6 +125,7 @@ static const datetkn datetktbl[] = {
...
@@ -125,6 +125,7 @@ static const datetkn datetktbl[] = {
{
"h"
,
UNITS
,
DTK_HOUR
},
/* "hour" */
{
"h"
,
UNITS
,
DTK_HOUR
},
/* "hour" */
{
LATE
,
RESERV
,
DTK_LATE
},
/* "infinity" reserved for "late time" */
{
LATE
,
RESERV
,
DTK_LATE
},
/* "infinity" reserved for "late time" */
{
INVALID
,
RESERV
,
DTK_INVALID
},
/* "invalid" reserved for bad time */
{
INVALID
,
RESERV
,
DTK_INVALID
},
/* "invalid" reserved for bad time */
{
"isodow"
,
RESERV
,
DTK_ISODOW
},
/* ISO day of week, Sunday == 7 */
{
"isoyear"
,
UNITS
,
DTK_ISOYEAR
},
/* year in terms of the ISO week date */
{
"isoyear"
,
UNITS
,
DTK_ISOYEAR
},
/* year in terms of the ISO week date */
{
"j"
,
UNITS
,
DTK_JULIAN
},
{
"j"
,
UNITS
,
DTK_JULIAN
},
{
"jan"
,
MONTH
,
1
},
{
"jan"
,
MONTH
,
1
},
...
...
src/backend/utils/adt/timestamp.c
View file @
3e803f72
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.17
2 2007/02/16 03:39:45
momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.17
3 2007/02/19 17:41:39
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -4112,11 +4112,14 @@ timestamp_part(PG_FUNCTION_ARGS)
...
@@ -4112,11 +4112,14 @@ timestamp_part(PG_FUNCTION_ARGS)
break
;
break
;
}
}
case
DTK_DOW
:
case
DTK_DOW
:
case
DTK_ISODOW
:
if
(
timestamp2tm
(
timestamp
,
NULL
,
tm
,
&
fsec
,
NULL
,
NULL
)
!=
0
)
if
(
timestamp2tm
(
timestamp
,
NULL
,
tm
,
&
fsec
,
NULL
,
NULL
)
!=
0
)
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DATETIME_VALUE_OUT_OF_RANGE
),
(
errcode
(
ERRCODE_DATETIME_VALUE_OUT_OF_RANGE
),
errmsg
(
"timestamp out of range"
)));
errmsg
(
"timestamp out of range"
)));
result
=
j2day
(
date2j
(
tm
->
tm_year
,
tm
->
tm_mon
,
tm
->
tm_mday
));
result
=
j2day
(
date2j
(
tm
->
tm_year
,
tm
->
tm_mon
,
tm
->
tm_mday
));
if
(
val
==
DTK_ISODOW
&&
result
==
0
)
result
=
7
;
break
;
break
;
case
DTK_DOY
:
case
DTK_DOY
:
...
@@ -4322,11 +4325,14 @@ timestamptz_part(PG_FUNCTION_ARGS)
...
@@ -4322,11 +4325,14 @@ timestamptz_part(PG_FUNCTION_ARGS)
break
;
break
;
case
DTK_DOW
:
case
DTK_DOW
:
case
DTK_ISODOW
:
if
(
timestamp2tm
(
timestamp
,
&
tz
,
tm
,
&
fsec
,
&
tzn
,
NULL
)
!=
0
)
if
(
timestamp2tm
(
timestamp
,
&
tz
,
tm
,
&
fsec
,
&
tzn
,
NULL
)
!=
0
)
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DATETIME_VALUE_OUT_OF_RANGE
),
(
errcode
(
ERRCODE_DATETIME_VALUE_OUT_OF_RANGE
),
errmsg
(
"timestamp out of range"
)));
errmsg
(
"timestamp out of range"
)));
result
=
j2day
(
date2j
(
tm
->
tm_year
,
tm
->
tm_mon
,
tm
->
tm_mday
));
result
=
j2day
(
date2j
(
tm
->
tm_year
,
tm
->
tm_mon
,
tm
->
tm_mday
));
if
(
val
==
DTK_ISODOW
&&
result
==
0
)
result
=
7
;
break
;
break
;
case
DTK_DOY
:
case
DTK_DOY
:
...
...
src/include/utils/datetime.h
View file @
3e803f72
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $PostgreSQL: pgsql/src/include/utils/datetime.h,v 1.6
4 2007/02/16 03:39:45
momjian Exp $
* $PostgreSQL: pgsql/src/include/utils/datetime.h,v 1.6
5 2007/02/19 17:41:39
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -166,6 +166,7 @@
...
@@ -166,6 +166,7 @@
#define DTK_TZ_HOUR 34
#define DTK_TZ_HOUR 34
#define DTK_TZ_MINUTE 35
#define DTK_TZ_MINUTE 35
#define DTK_ISOYEAR 36
#define DTK_ISOYEAR 36
#define DTK_ISODOW 37
/*
/*
...
...
src/interfaces/ecpg/pgtypeslib/dt.h
View file @
3e803f72
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt.h,v 1.3
5 2007/02/16 03:39:45
momjian Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt.h,v 1.3
6 2007/02/19 17:41:39
momjian Exp $ */
#ifndef DT_H
#ifndef DT_H
#define DT_H
#define DT_H
...
@@ -158,6 +158,7 @@ typedef double fsec_t;
...
@@ -158,6 +158,7 @@ typedef double fsec_t;
#define DTK_TZ_HOUR 34
#define DTK_TZ_HOUR 34
#define DTK_TZ_MINUTE 35
#define DTK_TZ_MINUTE 35
#define DTK_ISOYEAR 36
#define DTK_ISOYEAR 36
#define DTK_ISODOW 37
/*
/*
...
...
src/interfaces/ecpg/pgtypeslib/dt_common.c
View file @
3e803f72
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c,v 1.3
6 2006/09/26 07:56:56 meskes
Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c,v 1.3
7 2007/02/19 17:41:39 momjian
Exp $ */
#include "postgres_fe.h"
#include "postgres_fe.h"
...
@@ -214,6 +214,7 @@ static datetkn datetktbl[] = {
...
@@ -214,6 +214,7 @@ static datetkn datetktbl[] = {
{
"irkst"
,
DTZ
,
POS
(
36
)},
/* Irkutsk Summer Time */
{
"irkst"
,
DTZ
,
POS
(
36
)},
/* Irkutsk Summer Time */
{
"irkt"
,
TZ
,
POS
(
32
)},
/* Irkutsk Time */
{
"irkt"
,
TZ
,
POS
(
32
)},
/* Irkutsk Time */
{
"irt"
,
TZ
,
POS
(
14
)},
/* Iran Time */
{
"irt"
,
TZ
,
POS
(
14
)},
/* Iran Time */
{
"isodow"
,
RESERV
,
DTK_ISODOW
},
/* ISO day of week, Sunday == 7 */
#if 0
#if 0
isst
isst
#endif
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment