Index: doc/src/sgml/func.sgml
===================================================================
RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/func.sgml,v
retrieving revision 1.134
diff -c -r1.134 func.sgml
*** doc/src/sgml/func.sgml	6 Dec 2002 05:20:12 -0000	1.134
--- doc/src/sgml/func.sgml	16 Jan 2003 18:11:18 -0000
***************
*** 657,663 ****
        <row>
         <entry><function>random</function>()</entry>
         <entry><type>dp</type></entry>
!        <entry>value between 0.0 to 1.0</entry>
         <entry><literal>random()</literal></entry>
         <entry></entry>
        </row>
--- 657,663 ----
        <row>
         <entry><function>random</function>()</entry>
         <entry><type>dp</type></entry>
!        <entry>pseudo-randomly generated value between 0.0 to 1.0</entry>
         <entry><literal>random()</literal></entry>
         <entry></entry>
        </row>
***************
*** 677,690 ****
         <entry><literal>round(42.4382, 2)</literal></entry>
         <entry>42.44</entry>
        </row>
! <!--
!      <row>
!       <entry><function>setseed</function>(<replaceable>new-seed</replaceable>)</entry>
!       <entry>set seed for subsequent random() calls</entry>
!       <entry><literal>setseed(0.54823)</literal></entry>
!       <entry></entry>
!      </row>
! -->
        <row>
         <entry><function>sign</function>(<type>numeric</type>)</entry>
         <entry><type>numeric</type></entry>
--- 677,691 ----
         <entry><literal>round(42.4382, 2)</literal></entry>
         <entry>42.44</entry>
        </row>
! 
!       <row>
!        <entry><function>setseed</function>(<type>dp</type>)</entry>
!        <entry><type>int32</type></entry>
!        <entry>set seed for subsequent random() calls</entry>
!        <entry><literal>setseed(0.54823)</literal></entry>
!        <entry>1177314959</entry>
!       </row>
! 
        <row>
         <entry><function>sign</function>(<type>numeric</type>)</entry>
         <entry><type>numeric</type></entry>
***************
*** 951,957 ****
         <entry><function>substring</function>(<parameter>string</parameter> from <replaceable>pattern</replaceable> for <replaceable>escape</replaceable>)</entry>
         <entry><type>text</type></entry>
         <entry>
!         Extract substring matching SQL regular expression
          <indexterm>
           <primary>substring</primary>
          </indexterm>
--- 952,959 ----
         <entry><function>substring</function>(<parameter>string</parameter> from <replaceable>pattern</replaceable> for <replaceable>escape</replaceable>)</entry>
         <entry><type>text</type></entry>
         <entry>
!         Extract substring matching <acronym>SQL</acronym> regular
!         expression
          <indexterm>
           <primary>substring</primary>
          </indexterm>
***************
*** 1164,1170 ****
         <entry><type>text</type></entry>
         <entry>
          Return the given string suitably quoted to be used as an identifier
! 	in an SQL query string.
  	Quotes are added only if necessary (i.e., if the string contains
  	non-identifier characters or would be case-folded).
  	Embedded quotes are properly doubled.
--- 1166,1172 ----
         <entry><type>text</type></entry>
         <entry>
          Return the given string suitably quoted to be used as an identifier
! 	in an <acronym>SQL</acronym> query string.
  	Quotes are added only if necessary (i.e., if the string contains
  	non-identifier characters or would be case-folded).
  	Embedded quotes are properly doubled.
***************
*** 1178,1184 ****
         <entry><type>text</type></entry>
         <entry>
          Return the given string suitably quoted to be used as a literal
! 	in an SQL query string.
  	Embedded quotes and backslashes are properly doubled.
         </entry>
         <entry><literal>quote_literal('O\'Reilly')</literal></entry>
--- 1180,1186 ----
         <entry><type>text</type></entry>
         <entry>
          Return the given string suitably quoted to be used as a literal
! 	in an <acronym>SQL</acronym> query string.
  	Embedded quotes and backslashes are properly doubled.
         </entry>
         <entry><literal>quote_literal('O\'Reilly')</literal></entry>
***************
*** 2505,2518 ****
       <function>SUBSTRING(<parameter>string</parameter> FROM
       <replaceable>pattern</replaceable> FOR
       <replaceable>escape</replaceable>)</function>, provides
!      extraction of a substring that matches a SQL99 regular expression
!      pattern.  As with <literal>SIMILAR TO</>, the specified pattern
!      must match to the entire data string, else the function fails and
!      returns null.  To indicate the part of the pattern that should be
!      returned on success, SQL99 specifies that the pattern must
!      contain two occurrences of the escape character followed by
!      double quote (<literal>"</>).  The text matching the portion of
!      the pattern between these markers is returned.
      </para>
  
     <para>
--- 2507,2521 ----
       <function>SUBSTRING(<parameter>string</parameter> FROM
       <replaceable>pattern</replaceable> FOR
       <replaceable>escape</replaceable>)</function>, provides
!      extraction of a substring that matches a <acronym>SQL99</acronym>
!      regular expression pattern.  As with <literal>SIMILAR TO</>, the
!      specified pattern must match to the entire data string, else the
!      function fails and returns null.  To indicate the part of the
!      pattern that should be returned on success,
!      <acronym>SQL99</acronym> specifies that the pattern must contain
!      two occurrences of the escape character followed by double quote
!      (<literal>"</>).  The text matching the portion of the pattern
!      between these markers is returned.
      </para>
  
     <para>
***************
*** 5127,5137 ****
     </table>
  
    <para>
!    For largely historical reasons, the sequence to be operated on by
!    a sequence-function call is specified by a text-string argument.
!    To achieve some compatibility with the handling of ordinary SQL
!    names, the sequence functions convert their argument to lower case
!    unless the string is double-quoted.  Thus
  <programlisting>
  nextval('foo')      <lineannotation>operates on sequence <literal>foo</literal></>
  nextval('FOO')      <lineannotation>operates on sequence <literal>foo</literal></>
--- 5130,5140 ----
     </table>
  
    <para>
!    For largely historical reasons, the sequence to be operated on by a
!    sequence-function call is specified by a text-string argument.  To
!    achieve some compatibility with the handling of ordinary
!    <acronym>SQL</acronym> names, the sequence functions convert their
!    argument to lower case unless the string is double-quoted.  Thus
  <programlisting>
  nextval('foo')      <lineannotation>operates on sequence <literal>foo</literal></>
  nextval('FOO')      <lineannotation>operates on sequence <literal>foo</literal></>
***************
*** 5582,5588 ****
     <para>
      The <function>current_setting</function> is used to obtain the current
      value of the <parameter>setting_name</parameter> setting, as a query
!     result. It is the equivalent to the SQL <command>SHOW</command> command.
      For example:
  <programlisting>
  select current_setting('DateStyle');
--- 5585,5592 ----
     <para>
      The <function>current_setting</function> is used to obtain the current
      value of the <parameter>setting_name</parameter> setting, as a query
!     result. It is the equivalent to the <acronym>SQL</acronym>
!     <command>SHOW</command> command.
      For example:
  <programlisting>
  select current_setting('DateStyle');
***************
*** 5599,5606 ****
      If <parameter>is_local</parameter> is set to <literal>true</literal>,
      the new value will only apply to the current transaction. If you want
      the new value to apply for the current session, use
!     <literal>false</literal> instead. It is the equivalent to the SQL
!     <command>SET</command> command. For example:
  <programlisting>
  select set_config('show_statement_stats','off','f');
   set_config
--- 5603,5610 ----
      If <parameter>is_local</parameter> is set to <literal>true</literal>,
      the new value will only apply to the current transaction. If you want
      the new value to apply for the current session, use
!     <literal>false</literal> instead. It is the equivalent to the
!     <acronym>SQL</acronym> <command>SET</command> command. For example:
  <programlisting>
  select set_config('show_statement_stats','off','f');
   set_config
Index: src/backend/utils/adt/misc.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/utils/adt/misc.c,v
retrieving revision 1.27
diff -c -r1.27 misc.c
*** src/backend/utils/adt/misc.c	4 Sep 2002 20:31:28 -0000	1.27
--- src/backend/utils/adt/misc.c	16 Jan 2003 18:10:49 -0000
***************
*** 44,118 ****
  }
  
  /*
-  * oidrand (oid o, int4 X)-
-  *	  Takes in an oid and a int4 X, and will return 'true' about 1/X of
-  *	  the time.  If X == 0, this will always return true.
-  *	  Useful for doing random sampling or subsetting.
-  *
-  * Example use:
-  *	   select * from TEMP where oidrand(TEMP.oid, 10)
-  * will return about 1/10 of the tuples in TEMP
-  *
-  * NOTE: the OID input is not used at all.	It is there just because of
-  * an old optimizer bug: a qual expression containing no variables was
-  * mistakenly assumed to be a constant.  Pretending to access the row's OID
-  * prevented the optimizer from treating the oidrand() result as constant.
-  */
- 
- static bool random_initialized = false;
- 
- Datum
- oidrand(PG_FUNCTION_ARGS)
- {
- #ifdef NOT_USED
- 	Oid			o = PG_GETARG_OID(0);
- #endif
- 	int32		X = PG_GETARG_INT32(1);
- 	bool		result;
- 
- 	if (X == 0)
- 		PG_RETURN_BOOL(true);
- 
- 	/*
- 	 * We do this because the cancel key is actually a random, so we don't
- 	 * want them to be able to request random numbers using our postmaster
- 	 * seeded value.
- 	 */
- 	if (!random_initialized)
- 	{
- 		srandom((unsigned int) time(NULL));
- 		random_initialized = true;
- 	}
- 
- 	result = (random() % X == 0);
- 	PG_RETURN_BOOL(result);
- }
- 
- /*
-    oidsrand(int32 X) -
- 	  seeds the random number generator
- 	  always returns true
- */
- Datum
- oidsrand(PG_FUNCTION_ARGS)
- {
- 	int32		X = PG_GETARG_INT32(0);
- 
- 	srandom((unsigned int) X);
- 	random_initialized = true;
- 	PG_RETURN_BOOL(true);
- }
- 
- 
- Datum
- userfntest(PG_FUNCTION_ARGS)
- {
- 	int32		i = PG_GETARG_INT32(0);
- 
- 	PG_RETURN_INT32(i);
- }
- 
- /*
   * current_database()
   *	Expose the current database to the user
   */
--- 44,49 ----
Index: src/include/catalog/catversion.h
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/include/catalog/catversion.h,v
retrieving revision 1.172
diff -c -r1.172 catversion.h
*** src/include/catalog/catversion.h	10 Jan 2003 21:08:15 -0000	1.172
--- src/include/catalog/catversion.h	16 Jan 2003 18:09:06 -0000
***************
*** 53,58 ****
   */
  
  /*							yyyymmddN */
! #define CATALOG_VERSION_NO	200301101
  
  #endif
--- 53,58 ----
   */
  
  /*							yyyymmddN */
! #define CATALOG_VERSION_NO	200301151
  
  #endif
Index: src/include/catalog/pg_proc.h
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/include/catalog/pg_proc.h,v
retrieving revision 1.281
diff -c -r1.281 pg_proc.h
*** src/include/catalog/pg_proc.h	9 Jan 2003 00:58:41 -0000	1.281
--- src/include/catalog/pg_proc.h	16 Jan 2003 18:10:56 -0000
***************
*** 944,955 ****
  /* OIDS 700 - 799 */
  DATA(insert OID = 710 (  getpgusername	   PGNSP PGUID 12 f f t f s 0 19 "" current_user - _null_ ));
  DESCR("deprecated -- use current_user");
- DATA(insert OID = 711 (  userfntest		   PGNSP PGUID 12 f f t f i 1 23 "23"  userfntest - _null_ ));
- DESCR("");
- DATA(insert OID = 713 (  oidrand		   PGNSP PGUID 12 f f t f v 2 16 "26 23"	oidrand - _null_ ));
- DESCR("random");
- DATA(insert OID = 715 (  oidsrand		   PGNSP PGUID 12 f f t f v 1 16 "23"  oidsrand - _null_ ));
- DESCR("seed random number generator");
  DATA(insert OID = 716 (  oidlt			   PGNSP PGUID 12 f f t f i 2 16 "26 26"	oidlt - _null_ ));
  DESCR("less-than");
  DATA(insert OID = 717 (  oidle			   PGNSP PGUID 12 f f t f i 2 16 "26 26"	oidle - _null_ ));
--- 944,949 ----
Index: src/include/utils/builtins.h
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/include/utils/builtins.h,v
retrieving revision 1.206
diff -c -r1.206 builtins.h
*** src/include/utils/builtins.h	6 Dec 2002 05:20:28 -0000	1.206
--- src/include/utils/builtins.h	16 Jan 2003 18:22:56 -0000
***************
*** 315,323 ****
  /* misc.c */
  extern Datum nullvalue(PG_FUNCTION_ARGS);
  extern Datum nonnullvalue(PG_FUNCTION_ARGS);
- extern Datum oidrand(PG_FUNCTION_ARGS);
- extern Datum oidsrand(PG_FUNCTION_ARGS);
- extern Datum userfntest(PG_FUNCTION_ARGS);
  extern Datum current_database(PG_FUNCTION_ARGS);
  
  /* not_in.c */
--- 315,320 ----
Index: src/test/regress/expected/random.out
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/test/regress/expected/random.out,v
retrieving revision 1.3
diff -c -r1.3 random.out
*** src/test/regress/expected/random.out	6 Jan 2000 06:40:54 -0000	1.3
--- src/test/regress/expected/random.out	16 Jan 2003 18:20:15 -0000
***************
*** 15,25 ****
  --  have a regression test which can pass/fail
  -- - thomas 1998-08-17
  SELECT count(*) AS random INTO RANDOM_TBL
!   FROM onek WHERE oidrand(onek.oid, 10);
  -- select again, the count should be different
  INSERT INTO RANDOM_TBL (random)
    SELECT count(*)
!   FROM onek WHERE oidrand(onek.oid, 10);
  -- now test the results for randomness in the correct range
  SELECT random, count(random) FROM RANDOM_TBL
    GROUP BY random HAVING count(random) > 1;
--- 15,25 ----
  --  have a regression test which can pass/fail
  -- - thomas 1998-08-17
  SELECT count(*) AS random INTO RANDOM_TBL
!   FROM onek WHERE random() < 1.0/10;
  -- select again, the count should be different
  INSERT INTO RANDOM_TBL (random)
    SELECT count(*)
!   FROM onek WHERE random() < 1.0/10;
  -- now test the results for randomness in the correct range
  SELECT random, count(random) FROM RANDOM_TBL
    GROUP BY random HAVING count(random) > 1;
Index: src/test/regress/sql/random.sql
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/test/regress/sql/random.sql,v
retrieving revision 1.3
diff -c -r1.3 random.sql
*** src/test/regress/sql/random.sql	6 Jan 2000 06:41:55 -0000	1.3
--- src/test/regress/sql/random.sql	16 Jan 2003 18:18:03 -0000
***************
*** 12,23 ****
  --  have a regression test which can pass/fail
  -- - thomas 1998-08-17
  SELECT count(*) AS random INTO RANDOM_TBL
!   FROM onek WHERE oidrand(onek.oid, 10);
  
  -- select again, the count should be different
  INSERT INTO RANDOM_TBL (random)
    SELECT count(*)
!   FROM onek WHERE oidrand(onek.oid, 10);
  
  -- now test the results for randomness in the correct range
  SELECT random, count(random) FROM RANDOM_TBL
--- 12,23 ----
  --  have a regression test which can pass/fail
  -- - thomas 1998-08-17
  SELECT count(*) AS random INTO RANDOM_TBL
!   FROM onek WHERE random() < 1.0/10;
  
  -- select again, the count should be different
  INSERT INTO RANDOM_TBL (random)
    SELECT count(*)
!   FROM onek WHERE random() < 1.0/10;
  
  -- now test the results for randomness in the correct range
  SELECT random, count(random) FROM RANDOM_TBL
