Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite34082e

Browse files
committed
Add missing operators of the form interval-plus-datetime, as required for
better SQL compliance in this area, per recent discussion. Mark relatedoperators as commutators where possible. (The system doesn't actually careabout commutator marking for operators not returning boolean, at the moment,but this seems forward-thinking and besides it made it easier to verifythat we hadn't missed any.)Also, remove interval-minus-time and interval-minus-timetz operators.I'm not sure how these got in, but they are nonstandard and had veryobviously broken behavior. (minus is not commutative in anyone's book.)I doubt anyone had ever used 'em, because we'd surely have gotten a bugreport about it if so.
1 parent0b89d26 commite34082e

File tree

8 files changed

+48
-93
lines changed

8 files changed

+48
-93
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.212 2004/07/0218:59:20 joe Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.213 2004/07/0222:49:45 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -4689,7 +4689,10 @@ substring('foobar' from 'o(.)b') <lineannotation>o</lineannotation>
46894689
All the functions and operators described below that take <type>time</type> or <type>timestamp</type>
46904690
inputs actually come in two variants: one that takes <type>time with time zone</type> or <type>timestamp
46914691
with time zone</type>, and one that takes <type>time without time zone</type> or <type>timestamp without time zone</type>.
4692-
For brevity, these variants are not shown separately.
4692+
For brevity, these variants are not shown separately. Also, the
4693+
<literal>+</> and <literal>*</> operators come in commutative pairs (for
4694+
example both date + integer and integer + date); we show only one of each
4695+
such pair.
46934696
</para>
46944697

46954698
<table id="operators-datetime-table">
@@ -4723,12 +4726,6 @@ substring('foobar' from 'o(.)b') <lineannotation>o</lineannotation>
47234726
<entry><literal>timestamp '2001-09-28 03:00'</literal></entry>
47244727
</row>
47254728

4726-
<row>
4727-
<entry> <literal>+</literal> </entry>
4728-
<entry><literal>time '03:00' + date '2001-09-28'</literal></entry>
4729-
<entry><literal>timestamp '2001-09-28 03:00'</literal></entry>
4730-
</row>
4731-
47324729
<row>
47334730
<entry> <literal>+</literal> </entry>
47344731
<entry><literal>interval '1 day' + interval '1 hour'</literal></entry>
@@ -4747,12 +4744,6 @@ substring('foobar' from 'o(.)b') <lineannotation>o</lineannotation>
47474744
<entry><literal>time '04:00'</literal></entry>
47484745
</row>
47494746

4750-
<row>
4751-
<entry> <literal>+</literal> </entry>
4752-
<entry><literal>interval '3 hours' + time '01:00'</literal></entry>
4753-
<entry><literal>time '04:00'</literal></entry>
4754-
</row>
4755-
47564747
<row>
47574748
<entry> <literal>-</literal> </entry>
47584749
<entry><literal>- interval '23 hours'</literal></entry>
@@ -4801,24 +4792,12 @@ substring('foobar' from 'o(.)b') <lineannotation>o</lineannotation>
48014792
<entry><literal>interval '23:00'</literal></entry>
48024793
</row>
48034794

4804-
<row>
4805-
<entry> <literal>-</literal> </entry>
4806-
<entry><literal>interval '2 hours' - time '05:00'</literal></entry>
4807-
<entry><literal>time '03:00'</literal></entry>
4808-
</row>
4809-
48104795
<row>
48114796
<entry> <literal>-</literal> </entry>
48124797
<entry><literal>timestamp '2001-09-29 03:00' - timestamp '2001-09-27 12:00'</literal></entry>
48134798
<entry><literal>interval '1 day 15:00'</literal></entry>
48144799
</row>
48154800

4816-
<row>
4817-
<entry> <literal>*</literal> </entry>
4818-
<entry><literal>double precision '3.5' * interval '1 hour'</literal></entry>
4819-
<entry><literal>interval '03:30'</literal></entry>
4820-
</row>
4821-
48224801
<row>
48234802
<entry> <literal>*</literal> </entry>
48244803
<entry><literal>interval '1 hour' * double precision '3.5'</literal></entry>
@@ -7332,7 +7311,7 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
73327311
<row>
73337312
<entry><literal><function>pg_tablespace_databases</function>(<parameter>tablespace_oid</parameter>)</literal></entry>
73347313
<entry><type>setof oid</type></entry>
7335-
<entry>get set of databaseoids that have objects in the tablespace</entry>
7314+
<entry>get set of databaseOIDs that have objects in the tablespace</entry>
73367315
</row>
73377316
</tbody>
73387317
</tgroup>
@@ -7373,12 +7352,13 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
73737352

73747353
<para>
73757354
<function>pg_tablespace_databases</function> allows usage examination of a
7376-
tablespace. It will return a set ofdatabase oids, that have objects
7355+
tablespace. It will return a set ofOIDs of databases that have objects
73777356
stored in the tablespace. If this function returns any row, the
7378-
tablespace is assumed not to be empty and cannot be dropped. To
7379-
display the actual objects populating the tablespace, you will need
7380-
to connect to the databases returned by
7381-
<function>pg_tablespace_databases</function> to query pg_class.
7357+
tablespace is not empty and cannot be dropped. To
7358+
display the specific objects populating the tablespace, you will need
7359+
to connect to the databases identified by
7360+
<function>pg_tablespace_databases</function> and query their
7361+
<structname>pg_class</> catalogs.
73827362
</para>
73837363

73847364
<indexterm zone="functions-misc">

‎src/backend/utils/adt/date.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.99 2004/06/03 02:08:04 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.100 2004/07/02 22:49:46 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1531,18 +1531,6 @@ time_mi_interval(PG_FUNCTION_ARGS)
15311531
PG_RETURN_TIMEADT(result);
15321532
}
15331533

1534-
/* interval_pl_time()
1535-
* Add time to interval.
1536-
*/
1537-
Datum
1538-
interval_pl_time(PG_FUNCTION_ARGS)
1539-
{
1540-
Datumspan=PG_GETARG_DATUM(0);
1541-
Datumtime=PG_GETARG_DATUM(1);
1542-
1543-
returnDirectFunctionCall2(time_pl_interval,time,span);
1544-
}
1545-
15461534

15471535
/* time_text()
15481536
* Convert time to text data type.

‎src/include/catalog/catversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.242 2004/07/0218:59:24 joe Exp $
40+
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.243 2004/07/0222:49:48 tgl Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO200407021
56+
#defineCATALOG_VERSION_NO200407022
5757

5858
#endif

‎src/include/catalog/pg_operator.h

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $PostgreSQL: pgsql/src/include/catalog/pg_operator.h,v 1.125 2004/03/22 01:38:17 tgl Exp $
11+
* $PostgreSQL: pgsql/src/include/catalog/pg_operator.h,v 1.126 2004/07/02 22:49:48 tgl Exp $
1212
*
1313
* NOTES
1414
* the genbki.sh script reads this file and generates .bki
@@ -451,7 +451,7 @@ DATA(insert OID = 1074 ( "<=" PGNSP PGUID b f 2277 2277 16 1075 1073 0 0 0
451451
DATA(insertOID=1075 (">="PGNSPPGUIDbf2277227716107410720000array_gescalargtselscalargtjoinsel ));
452452

453453
/* date operators */
454-
DATA(insertOID=1076 ("+"PGNSPPGUIDbf108211861114000000date_pl_interval-- ));
454+
DATA(insertOID=1076 ("+"PGNSPPGUIDbf108211861114255100000date_pl_interval-- ));
455455
DATA(insertOID=1077 ("-"PGNSPPGUIDbf108211861114000000date_mi_interval-- ));
456456
DATA(insertOID=1093 ("="PGNSPPGUIDbt1082108216109310941095109510951097date_eqeqseleqjoinsel ));
457457
DATA(insertOID=1094 ("<>"PGNSPPGUIDbf1082108216109410930000date_neneqselneqjoinsel ));
@@ -460,7 +460,7 @@ DATA(insert OID = 1096 ( "<=" PGNSP PGUID b f10821082 16 1098 1097 0 0 0
460460
DATA(insertOID=1097 (">"PGNSPPGUIDbf1082108216109510960000date_gtscalargtselscalargtjoinsel ));
461461
DATA(insertOID=1098 (">="PGNSPPGUIDbf1082108216109610950000date_gescalargtselscalargtjoinsel ));
462462
DATA(insertOID=1099 ("-"PGNSPPGUIDbf1082108223000000date_mi-- ));
463-
DATA(insertOID=1100 ("+"PGNSPPGUIDbf1082231082000000date_pli-- ));
463+
DATA(insertOID=1100 ("+"PGNSPPGUIDbf1082231082255500000date_pli-- ));
464464
DATA(insertOID=1101 ("-"PGNSPPGUIDbf1082231082000000date_mii-- ));
465465

466466
/* time operators */
@@ -470,10 +470,8 @@ DATA(insert OID = 1110 ( "<" PGNSP PGUID b f10831083 16 1112 11130 0 0
470470
DATA(insertOID=1111 ("<="PGNSPPGUIDbf1083108316111311120000time_lescalarltselscalarltjoinsel ));
471471
DATA(insertOID=1112 (">"PGNSPPGUIDbf1083108316111011110000time_gtscalargtselscalargtjoinsel ));
472472
DATA(insertOID=1113 (">="PGNSPPGUIDbf1083108316111111100000time_gescalargtselscalargtjoinsel ));
473-
DATA(insertOID=1269 ("-"PGNSPPGUIDbf118610831083000000interval_mi_time-- ));
474473

475474
/* timetz operators */
476-
DATA(insertOID=1295 ("-"PGNSPPGUIDbf118612661266000000interval_mi_timetz-- ));
477475
DATA(insertOID=1550 ("="PGNSPPGUIDbt1266126616155015511552155215521554timetz_eqeqseleqjoinsel ));
478476
DATA(insertOID=1551 ("<>"PGNSPPGUIDbf1266126616155115500000timetz_neneqselneqjoinsel ));
479477
DATA(insertOID=1552 ("<"PGNSPPGUIDbf1266126616155415550000timetz_ltscalarltselscalarltjoinsel ));
@@ -535,7 +533,7 @@ DATA(insert OID = 1322 ( "<" PGNSP PGUID b f 1184 1184 16 1324 1325 0 0 0 0
535533
DATA(insertOID=1323 ("<="PGNSPPGUIDbf1184118416132513240000timestamptz_lescalarltselscalarltjoinsel ));
536534
DATA(insertOID=1324 (">"PGNSPPGUIDbf1184118416132213230000timestamptz_gtscalargtselscalargtjoinsel ));
537535
DATA(insertOID=1325 (">="PGNSPPGUIDbf1184118416132313220000timestamptz_gescalargtselscalargtjoinsel ));
538-
DATA(insertOID=1327 ("+"PGNSPPGUIDbf118411861184000000timestamptz_pl_interval-- ));
536+
DATA(insertOID=1327 ("+"PGNSPPGUIDbf118411861184255400000timestamptz_pl_interval-- ));
539537
DATA(insertOID=1328 ("-"PGNSPPGUIDbf118411841186000000timestamptz_mi-- ));
540538
DATA(insertOID=1329 ("-"PGNSPPGUIDbf118411861184000000timestamptz_mi_interval-- ));
541539

@@ -551,10 +549,10 @@ DATA(insert OID = 1336 ( "-" PGNSP PGUID l f0 1186 1186 00 0 0 0 0 inte
551549
DATA(insertOID=1337 ("+"PGNSPPGUIDbf118611861186133700000interval_pl-- ));
552550
DATA(insertOID=1338 ("-"PGNSPPGUIDbf118611861186000000interval_mi-- ));
553551

554-
DATA(insertOID=1360 ("+"PGNSPPGUIDbf108210831114000000datetime_pl-- ));
555-
DATA(insertOID=1361 ("+"PGNSPPGUIDbf108212661184000000datetimetz_pl-- ));
556-
DATA(insertOID=1363 ("+"PGNSPPGUIDbf108310821114000000timedate_pl-- ));
557-
DATA(insertOID=1366 ("+"PGNSPPGUIDbf126610821184000000timetzdate_pl-- ));
552+
DATA(insertOID=1360 ("+"PGNSPPGUIDbf108210831114136300000datetime_pl-- ));
553+
DATA(insertOID=1361 ("+"PGNSPPGUIDbf108212661184136600000datetimetz_pl-- ));
554+
DATA(insertOID=1363 ("+"PGNSPPGUIDbf108310821114136000000timedate_pl-- ));
555+
DATA(insertOID=1366 ("+"PGNSPPGUIDbf126610821184136100000timetzdate_pl-- ));
558556

559557
DATA(insertOID=1399 ("-"PGNSPPGUIDbf108310831186000000time_mi_time-- ));
560558

@@ -616,8 +614,8 @@ DATA(insert OID = 1567 ( "##" PGNSP PGUID b f 601603 600 0 0 0 0 0 0 cl
616614
DATA(insertOID=1568 ("##"PGNSPPGUIDbf628603600000000close_lb-- ));
617615
DATA(insertOID=1577 ("##"PGNSPPGUIDbf628601600000000close_ls-- ));
618616
DATA(insertOID=1578 ("##"PGNSPPGUIDbf601601600000000close_lseg-- ));
619-
DATA(insertOID=1583 ("*"PGNSPPGUIDbf11867011186000000interval_mul-- ));
620-
DATA(insertOID=1584 ("*"PGNSPPGUIDbf70111861186000000mul_d_interval-- ));
617+
DATA(insertOID=1583 ("*"PGNSPPGUIDbf11867011186158400000interval_mul-- ));
618+
DATA(insertOID=1584 ("*"PGNSPPGUIDbf70111861186158300000mul_d_interval-- ));
621619
DATA(insertOID=1585 ("/"PGNSPPGUIDbf11867011186000000interval_div-- ));
622620

623621
DATA(insertOID=1586 ("<>"PGNSPPGUIDbf60160116158615350000lseg_neneqselneqjoinsel ));
@@ -716,9 +714,9 @@ DATA(insert OID = 1795 ( "<<" PGNSP PGUID b f 1560 23 1560 0 00 0 0
716714
DATA(insertOID=1796 (">>"PGNSPPGUIDbf1560231560000000bitshiftright-- ));
717715
DATA(insertOID=1797 ("||"PGNSPPGUIDbf156015601560000000bitcat-- ));
718716

719-
DATA(insertOID=1800 ("+"PGNSPPGUIDbf108311861083000000time_pl_interval-- ));
717+
DATA(insertOID=1800 ("+"PGNSPPGUIDbf108311861083184900000time_pl_interval-- ));
720718
DATA(insertOID=1801 ("-"PGNSPPGUIDbf108311861083000000time_mi_interval-- ));
721-
DATA(insertOID=1802 ("+"PGNSPPGUIDbf126611861266000000timetz_pl_interval-- ));
719+
DATA(insertOID=1802 ("+"PGNSPPGUIDbf126611861266255200000timetz_pl_interval-- ));
722720
DATA(insertOID=1803 ("-"PGNSPPGUIDbf126611861266000000timetz_mi_interval-- ));
723721

724722
DATA(insertOID=1804 ("="PGNSPPGUIDbf1562156216180418051806180618061807varbiteqeqseleqjoinsel ));
@@ -728,7 +726,7 @@ DATA(insert OID = 1807 ( ">" PGNSP PGUID b f 1562 1562 16 1806 18080 0 0
728726
DATA(insertOID=1808 ("<="PGNSPPGUIDbf1562156216180918070000varbitlescalarltselscalarltjoinsel ));
729727
DATA(insertOID=1809 (">="PGNSPPGUIDbf1562156216180818060000varbitgescalargtselscalargtjoinsel ));
730728

731-
DATA(insertOID=1849 ("+"PGNSPPGUIDbf118610831083000000interval_pl_time-- ));
729+
DATA(insertOID=1849 ("+"PGNSPPGUIDbf118610831083180000000interval_pl_time-- ));
732730

733731
DATA(insertOID=1862 ("="PGNSPPGUIDbf212016186818639541218641865int28eqeqseleqjoinsel ));
734732
DATA(insertOID=1863 ("<>"PGNSPPGUIDbf212016186918620000int28neneqselneqjoinsel ));
@@ -791,7 +789,7 @@ DATA(insert OID = 2062 ( "<" PGNSP PGUID b f 1114 1114 16 2064 2065 0 0 0 0
791789
DATA(insertOID=2063 ("<="PGNSPPGUIDbf1114111416206520640000timestamp_lescalarltselscalarltjoinsel ));
792790
DATA(insertOID=2064 (">"PGNSPPGUIDbf1114111416206220630000timestamp_gtscalargtselscalargtjoinsel ));
793791
DATA(insertOID=2065 (">="PGNSPPGUIDbf1114111416206320620000timestamp_gescalargtselscalargtjoinsel ));
794-
DATA(insertOID=2066 ("+"PGNSPPGUIDbf111411861114000000timestamp_pl_interval-- ));
792+
DATA(insertOID=2066 ("+"PGNSPPGUIDbf111411861114255300000timestamp_pl_interval-- ));
795793
DATA(insertOID=2067 ("-"PGNSPPGUIDbf111411141186000000timestamp_mi-- ));
796794
DATA(insertOID=2068 ("-"PGNSPPGUIDbf111411861114000000timestamp_mi_interval-- ));
797795

@@ -864,6 +862,13 @@ DATA(insert OID = 2543 ( ">=" PGNSP PGUID b f11841114 16 2535 2540 0 0 0
864862
DATA(insertOID=2544 (">"PGNSPPGUIDbf1184111416253425410000timestamptz_gt_timestampscalargtselscalargtjoinsel ));
865863
DATA(insertOID=2545 ("<>"PGNSPPGUIDbf1184111416253925420000timestamptz_ne_timestampneqselneqjoinsel ));
866864

865+
/* formerly-missing interval + datetime operators */
866+
DATA(insertOID=2551 ("+"PGNSPPGUIDbf118610821114107600000interval_pl_date-- ));
867+
DATA(insertOID=2552 ("+"PGNSPPGUIDbf118612661266180200000interval_pl_timetz-- ));
868+
DATA(insertOID=2553 ("+"PGNSPPGUIDbf118611141114206600000interval_pl_timestamp-- ));
869+
DATA(insertOID=2554 ("+"PGNSPPGUIDbf118611841184132700000interval_pl_timestamptz-- ));
870+
DATA(insertOID=2555 ("+"PGNSPPGUIDbf2310821082110000000integer_pl_date-- ));
871+
867872

868873
/*
869874
* function prototypes

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp