Re: [HACKERS] IS OF
| От | Joe Conway |
|---|---|
| Тема | Re: [HACKERS] IS OF |
| Дата | |
| Msg-id | 3F333523.7070105@joeconway.com обсуждение исходный текст |
| Ответы |
Re: [HACKERS] IS OF
|
| Список | pgsql-patches |
Bruce Momjian wrote:
> Can someone suggest where to document IS OF, and either document it's
> non-standard behavior or supply patch?
>
Doc patch attached for IS OF. Please apply.
Thanks,
Joe
> ---------------------------------------------------------------------------
>
> Joe Conway wrote:
>
>>Gavin Sherry wrote:
>>
>>>8.14 <type predicate> to be exact.
>>>
>>
>>8.18 in SQL200x. I don't think the current implementation quite meets
>>the spec however:
>>
>>regression=# select f2 is null, f2 is of(int) from bar;
>> ?column? | ?column?
>>----------+----------
>> f | t
>> t | t
>>(2 rows)
>>
>>If I read the spec correctly, the null value should return null, not 't'
>>in the above.
>>
>>General Rules
>>1) Let V be the result of evaluating the <row value predicand>.
>>2) Let ST be the set consisting of every type that is either some
>> exclusively specified type, or a subtype of some inclusively
>> specified type.
>>3) Let TPR be the result of evaluating the <type predicate>.
>>
>>Case:
>>a) If V is the null value, then TPR is Unknown.
>>b) If the most specific type of V is a member of ST, then TPR is True .
>>c) Otherwise, TPR is False
>>
Index: doc/src/sgml/reference.sgml
===================================================================
RCS file: /opt/src/cvs/pgsql-server/doc/src/sgml/reference.sgml,v
retrieving revision 1.45
diff -c -r1.45 reference.sgml
*** doc/src/sgml/reference.sgml 27 Jun 2003 14:45:25 -0000 1.45
--- doc/src/sgml/reference.sgml 8 Aug 2003 05:16:26 -0000
***************
*** 108,113 ****
--- 108,114 ----
&fetch;
&grant;
&insert;
+ &isof;
&listen;
&load;
&lock;
Index: doc/src/sgml/ref/allfiles.sgml
===================================================================
RCS file: /opt/src/cvs/pgsql-server/doc/src/sgml/ref/allfiles.sgml,v
retrieving revision 1.54
diff -c -r1.54 allfiles.sgml
*** doc/src/sgml/ref/allfiles.sgml 27 Jun 2003 14:45:25 -0000 1.54
--- doc/src/sgml/ref/allfiles.sgml 8 Aug 2003 04:45:35 -0000
***************
*** 76,81 ****
--- 76,82 ----
<!entity fetch system "fetch.sgml">
<!entity grant system "grant.sgml">
<!entity insert system "insert.sgml">
+ <!entity isof system "isof.sgml">
<!entity listen system "listen.sgml">
<!entity load system "load.sgml">
<!entity lock system "lock.sgml">
Index: doc/src/sgml/ref/isof.sgml
===================================================================
RCS file: doc/src/sgml/ref/isof.sgml
diff -N doc/src/sgml/ref/isof.sgml
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- doc/src/sgml/ref/isof.sgml 8 Aug 2003 05:20:46 -0000
***************
*** 0 ****
--- 1,84 ----
+ <refentry id="SQL-ISOF">
+ <refmeta>
+ <refentrytitle id="SQL-ISOF-TITLE">IS OF</refentrytitle>
+ <refmiscinfo>SQL - Language Statements</refmiscinfo>
+ </refmeta>
+
+ <refnamediv>
+ <refname>IS OF</refname>
+ <refpurpose>specify a type test</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <synopsis>
+ <replaceable class="parameter">expression</replaceable> IS [ NOT ] OF ( <replaceable
class="PARAMETER">typename</replaceable>[,... ] )
+ </synopsis>
+ </refsynopsisdiv>
+
+ <refsect1 id="sql-isof-description">
+ <title>Description</title>
+
+ <para>
+ This command allows an expression to be checked against a list
+ of data types. It returns TRUE if any data type in the list matches
+ that of the <replaceable class="parameter">expression</replaceable>,
+ FALSE otherwise.
+ </para>
+
+ </refsect1>
+
+ <refsect1>
+ <title>Examples</title>
+ <programlisting>
+ regression=# SELECT 1::int4 IS OF (int4, int8);
+ ?column?
+ ----------
+ t
+ (1 row)
+
+ regression=# SELECT 1::int4 IS OF (text);
+ ?column?
+ ----------
+ f
+ (1 row)
+
+ regression=# SELECT ARRAY['a'] IS OF (text[]);
+ ?column?
+ ----------
+ t
+ (1 row)
+ </programlisting>
+ </refsect1>
+
+ <refsect1 id="sql-isof-compat">
+ <title>Compatibility</title>
+
+ <para>
+ The SQL standard specifies that <literal>IS OF</literal>
+ must result in <literal>UNKNOWN</literal> if
+ <replaceable class="parameter">expression</replaceable> is
+ <literal>NULL</literal>. The <productname>PostgreSQL</productname>
+ implementation results in <literal>TRUE</literal> or <literal>FALSE</literal>
+ as appropriate based on the data type assigned by the planner.
+ Otherwise, this command is fully conforming.
+ </para>
+ </refsect1>
+
+ </refentry>
+
+ <!-- Keep this comment at the end of the file
+ Local variables:
+ mode: sgml
+ sgml-omittag:nil
+ sgml-shorttag:t
+ sgml-minimize-attributes:nil
+ sgml-always-quote-attributes:t
+ sgml-indent-step:1
+ sgml-indent-data:t
+ sgml-parent-document:nil
+ sgml-default-dtd-file:"../reference.ced"
+ sgml-exposed-tags:nil
+ sgml-local-catalogs:"/usr/lib/sgml/catalog"
+ sgml-local-ecat-files:nil
+ End:
+ -->
В списке pgsql-patches по дате отправления: