1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-26 01:22:12 +03:00

Implement SQL99 OVERLAY(). Allows substitution of a substring in a string.

Implement SQL99 SIMILAR TO as a synonym for our existing operator "~".
Implement SQL99 regular expression SUBSTRING(string FROM pat FOR escape).
 Extend the definition to make the FOR clause optional.
 Define textregexsubstr() to actually implement this feature.
Update the regression test to include these new string features.
 All tests pass.
Rename the regular expression support routines from "pg95_xxx" to "pg_xxx".
Define CREATE CHARACTER SET in the parser per SQL99. No implementation yet.
This commit is contained in:
Thomas G. Lockhart
2002-06-11 15:32:33 +00:00
parent 469cb65aca
commit 090dd22de6
4 changed files with 1808 additions and 1700 deletions

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.27 2002/02/12 22:25:15 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.28 2002/06/11 15:32:32 thomas Exp $
--> -->
<chapter id="tutorial-advanced"> <chapter id="tutorial-advanced">
@ -114,7 +114,6 @@ CREATE TABLE weather (
prcp real, prcp real,
date date date date
); );
</programlisting> </programlisting>
Now try inserting an invalid record: Now try inserting an invalid record:
@ -126,7 +125,6 @@ INSERT INTO weather VALUES ('Berkeley', 45, 53, 0.0, '1994-11-28');
<screen> <screen>
ERROR: &lt;unnamed&gt; referential integrity violation - key referenced from weather not found in cities ERROR: &lt;unnamed&gt; referential integrity violation - key referenced from weather not found in cities
</screen> </screen>
</para> </para>
<para> <para>
@ -162,6 +160,7 @@ ERROR: &lt;unnamed&gt; referential integrity violation - key referenced from we
Suppose that we want to record a payment of $100.00 from Alice's account Suppose that we want to record a payment of $100.00 from Alice's account
to Bob's account. Simplifying outrageously, the SQL commands for this to Bob's account. Simplifying outrageously, the SQL commands for this
might look like might look like
<programlisting> <programlisting>
UPDATE accounts SET balance = balance - 100.00 UPDATE accounts SET balance = balance - 100.00
WHERE name = 'Alice'; WHERE name = 'Alice';
@ -172,6 +171,9 @@ UPDATE accounts SET balance = balance + 100.00
UPDATE branches SET balance = balance + 100.00 UPDATE branches SET balance = balance + 100.00
WHERE name = (SELECT branch_name FROM accounts WHERE name = 'Bob'); WHERE name = (SELECT branch_name FROM accounts WHERE name = 'Bob');
</programlisting> </programlisting>
</para>
<para>
The details of these commands are not important here; the important The details of these commands are not important here; the important
point is that there are several separate updates involved to accomplish point is that there are several separate updates involved to accomplish
this rather simple operation. Our bank's officers will want to be this rather simple operation. Our bank's officers will want to be
@ -219,6 +221,7 @@ UPDATE branches SET balance = balance + 100.00
the SQL commands of the transaction with the SQL commands of the transaction with
<command>BEGIN</> and <command>COMMIT</> commands. So our banking <command>BEGIN</> and <command>COMMIT</> commands. So our banking
transaction would actually look like transaction would actually look like
<programlisting> <programlisting>
BEGIN; BEGIN;
UPDATE accounts SET balance = balance - 100.00 UPDATE accounts SET balance = balance - 100.00
@ -226,6 +229,9 @@ UPDATE accounts SET balance = balance - 100.00
-- etc etc -- etc etc
COMMIT; COMMIT;
</programlisting> </programlisting>
</para>
<para>
If, partway through the transaction, we decide we don't want to If, partway through the transaction, we decide we don't want to
commit (perhaps we just noticed that Alice's balance went negative), commit (perhaps we just noticed that Alice's balance went negative),
we can issue the command <command>ROLLBACK</> instead of we can issue the command <command>ROLLBACK</> instead of
@ -310,7 +316,9 @@ CREATE TABLE capitals (
state char(2) state char(2)
) INHERITS (cities); ) INHERITS (cities);
</programlisting> </programlisting>
</para>
<para>
In this case, a row of <classname>capitals</classname> In this case, a row of <classname>capitals</classname>
<firstterm>inherits</firstterm> all columns (<structfield>name</>, <firstterm>inherits</firstterm> all columns (<structfield>name</>,
<structfield>population</>, and <structfield>altitude</>) from its <structfield>population</>, and <structfield>altitude</>) from its
@ -397,7 +405,6 @@ SELECT name, altitude
site</ulink> for links to more resources. site</ulink> for links to more resources.
</para> </para>
</sect1> </sect1>
</chapter> </chapter>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.92 2002/05/03 04:11:07 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.93 2002/06/11 15:32:32 thomas Exp $
--> -->
<chapter id="datatype"> <chapter id="datatype">
@ -2637,7 +2637,8 @@ SELECT * FROM test1 WHERE a;
The <type>inet</type> type holds an IP host address, and The <type>inet</type> type holds an IP host address, and
optionally the identity of the subnet it is in, all in one field. optionally the identity of the subnet it is in, all in one field.
The subnet identity is represented by the number of bits in the The subnet identity is represented by the number of bits in the
network part of the address (the <quote>netmask</quote>). If the netmask is 32, network part of the address (the <quote>netmask</quote>). If the
netmask is 32,
then the value does not indicate a subnet, only a single host. then the value does not indicate a subnet, only a single host.
Note that if you want to accept networks only, you should use the Note that if you want to accept networks only, you should use the
<type>cidr</type> type rather than <type>inet</type>. <type>cidr</type> type rather than <type>inet</type>.

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.138 2002/05/22 17:20:58 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.139 2002/06/11 15:32:33 thomas Exp $
--> -->
<appendix id="release"> <appendix id="release">
@ -44,6 +44,9 @@ Access privileges on procedural languages
CREATE DATABASE has OWNER option so superuser can create DB for someone else CREATE DATABASE has OWNER option so superuser can create DB for someone else
Kerberos 5 support now works with Heimdal Kerberos 5 support now works with Heimdal
Database and user-specific session defaults for run-time configuration variables (ALTER DATABASE ... SET and ALTER USER ... SET) Database and user-specific session defaults for run-time configuration variables (ALTER DATABASE ... SET and ALTER USER ... SET)
String function OVERLAY() implemented per SQL99
Regular expression operator SIMILAR TO implemented per SQL99
Regular expression function SUBSTRING() implemented per SQL99
]]></literallayout> ]]></literallayout>
</sect1> </sect1>