in UPDATE. We also now issue a NOTICE if a query has _any_ implicit
range table entries -- in the past, we would only warn about implicit
RTEs in SELECTs with at least one explicit RTE.
As a result of the warning change, 25 of the regression tests had to
be updated. I also took the opportunity to remove some bogus whitespace
differences between some of the float4 and float8 variants. I believe
I have correctly updated all the platform-specific variants, but let
me know if that's not the case.
Original patch for DELETE ... USING from Euler Taveira de Oliveira,
reworked by Neil Conway.
index 6b6c8bf66d8672bfdf58c2d7b5b0ff1623233716..954391a228b0647fd300f18c2f4a6953bb581ef9 100644 (file)
<!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/delete.sgml,v 1.22 2005年01月09日 05:57:45 tgl Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/delete.sgml,v 1.23 2005年04月07日 01:51:37 neilc Exp $
PostgreSQL documentation
-->
<refsynopsisdiv>
<synopsis>
-DELETE FROM [ ONLY ] <replaceable class="PARAMETER">table</replaceable> [ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
+DELETE FROM [ ONLY ] <replaceable class="PARAMETER">table</replaceable>
+ [ USING <replaceable class="PARAMETER">usinglist</replaceable> ]
+ [ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
</synopsis>
</refsynopsisdiv>
@@ -49,10 +51,19 @@ DELETE FROM [ ONLY ] <replaceable class="PARAMETER">table</replaceable> [ WHERE
<literal>ONLY</literal> clause.
</para>
+ <para>
+ There are two ways to delete rows in a table using information
+ contained in other tables in the database: using sub-selects, or
+ specifying additional tables in the <literal>USING</literal> clause.
+ Which technique is more appropriate depends on the specific
+ circumstances.
+ </para>
+
<para>
You must have the <literal>DELETE</literal> privilege on the table
to delete from it, as well as the <literal>SELECT</literal>
- privilege for any table whose values are read in the <replaceable
+ privilege for any table in the <literal>USING</literal> clause or
+ whose values are read in the <replaceable
class="parameter">condition</replaceable>.
</para>
</refsect1>
@@ -70,6 +81,20 @@ DELETE FROM [ ONLY ] <replaceable class="PARAMETER">table</replaceable> [ WHERE
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><replaceable class="PARAMETER">usinglist</replaceable></term>
+ <listitem>
+ <para>
+ A list of table expressions, allowing columns from other tables
+ to appear in the <literal>WHERE</> condition. This is similar
+ to the list of tables that can be specified in the <xref
+ linkend="sql-from" endterm="sql-from-title"> of a
+ <command>SELECT</command> statement; for example, an alias for
+ the table name can be specified.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><replaceable class="parameter">condition</replaceable></term>
<listitem>
@@ -105,10 +130,11 @@ DELETE <replaceable class="parameter">count</replaceable>
<para>
<productname>PostgreSQL</productname> lets you reference columns of
- other tables in the <literal>WHERE</> condition. For example, to
- delete all films produced by a given producer, one might do
+ other tables in the <literal>WHERE</> condition by specifying the
+ other tables in the <literal>USING</literal> clause. For example,
+ to delete all films produced by a given producer, one might do
<programlisting>
-DELETE FROM films
+DELETE FROM films USING producers
WHERE producer_id = producers.id AND producers.name = 'foo';
</programlisting>
What is essentially happening here is a join between <structname>films</>
WHERE producer_id IN (SELECT id FROM producers WHERE name = 'foo');
</programlisting>
In some cases the join style is easier to write or faster to
- execute than the sub-select style. One objection to the join style
- is that there is no explicit list of what tables are being used,
- which makes the style somewhat error-prone; also it cannot handle
- self-joins.
+ execute than the sub-select style.
+ </para>
+
+ <para>
+ If <varname>add_missing_from</varname> is enabled, any relations
+ mentioned in the <literal>WHERE</literal> condition will be
+ implicitly added to the <literal>USING</literal> clause.
</para>
</refsect1>
<title>Compatibility</title>
<para>
- This command conforms to the SQL standard, except that the ability to
- reference other tables in the <literal>WHERE</> clause is a
- <productname>PostgreSQL</productname> extension.
+ This command conforms to the SQL standard, except that the
+ <literal>USING</> clause and the ability to reference other tables
+ in the <literal>WHERE</> clause are <productname>PostgreSQL</>
+ extensions.
</para>
</refsect1>
</refentry>
index e314959e3739a22ef8321c66051de657b1bf620d..0e480f5e086a8c387bfddd4262d565095373b5fb 100644 (file)
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.300 2005年04月06日 16:34:05 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.301 2005年04月07日 01:51:38 neilc Exp $
*
*-------------------------------------------------------------------------
*/
COPY_NODE_FIELD(relation);
COPY_NODE_FIELD(whereClause);
+ COPY_NODE_FIELD(usingClause);
return newnode;
}
index 958e320b47d4b18646e90bf6f2fc46ead0fc12d8..fb5990970059c265a47f6e2eb13185a2e0d65709 100644 (file)
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.239 2005年04月06日 16:34:05 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.240 2005年04月07日 01:51:38 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -675,6 +675,7 @@ _equalDeleteStmt(DeleteStmt *a, DeleteStmt *b)
{
COMPARE_NODE_FIELD(relation);
COMPARE_NODE_FIELD(whereClause);
+ COMPARE_NODE_FIELD(usingClause);
return true;
}
index 191f4446b0697df667f1013b1bc402666a6893ee..4dad0ae80affe749ba3541d10553dc16cf39ff8b 100644 (file)
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.317 2005年04月06日 16:34:06 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.318 2005年04月07日 01:51:38 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -479,6 +479,14 @@ transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt)
qry->distinctClause = NIL;
+ /*
+ * The USING clause is non-standard SQL syntax, and is equivalent
+ * in functionality to the FROM list that can be specified for
+ * UPDATE. The USING keyword is used rather than FROM because FROM
+ * is already a keyword in the DELETE syntax.
+ */
+ transformFromClause(pstate, stmt->usingClause);
+
/* fix where clause */
qual = transformWhereClause(pstate, stmt->whereClause, "WHERE");
index 6bbf4a4de1820e2daa7fa46e2e481980254d6d3e..c33a7e657384410262563d15af7bf99bd2e77a10 100644 (file)
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.486 2005年03月31日 22:46:11 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.487 2005年04月07日 01:51:38 neilc Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
transaction_mode_list_or_empty
TableFuncElementList
prep_type_clause prep_type_list
- execute_param_clause
+ execute_param_clause using_clause
%type <range> into_clause OptTempTableName
*
*****************************************************************************/
-DeleteStmt: DELETE_P FROM relation_expr where_clause
+DeleteStmt: DELETE_P FROM relation_expr using_clause where_clause
{
DeleteStmt *n = makeNode(DeleteStmt);
n->relation = 3ドル;
- n->whereClause = 4ドル;
+ n->usingClause = 4ドル;
+ n->whereClause = 5ドル;
$$ = (Node *)n;
}
;
+using_clause:
+ USING from_list { $$ = 2ドル; }
+ | /*EMPTY*/ { $$ = NIL; }
+ ;
+
LockStmt: LOCK_P opt_table qualified_name_list opt_lock opt_nowait
{
LockStmt *n = makeNode(LockStmt);
index 031bfa8fe245af95515185d74f2cff5a6ee08382..edd59917e9332c6fc7f5b3a623478ce7e84dbfc5 100644 (file)
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.104 2005年04月06日 16:34:06 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.105 2005年04月07日 01:51:39 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -596,6 +596,7 @@ colNameToVar(ParseState *pstate, char *colname, bool localonly)
RangeTblEntry *rte = rt_fetch(varno, pstate->p_rtable);
/* joins are always inFromCl, so no need to check */
+ Assert(rte->inFromCl);
/* use orig_pstate here to get the right sublevels_up */
newresult = scanRTEForColumn(orig_pstate, rte, colname);
/*
* Generate a warning or error about an implicit RTE, if appropriate.
*
- * If ADD_MISSING_FROM is not enabled, raise an error.
- *
- * Our current theory on warnings is that we should allow "SELECT foo.*"
- * but warn about a mixture of explicit and implicit RTEs.
+ * If ADD_MISSING_FROM is not enabled, raise an error. Otherwise, emit
+ * a warning.
*/
static void
warnAutoRange(ParseState *pstate, RangeVar *relation)
{
- bool foundInFromCl = false;
- ListCell *temp;
-
if (!add_missing_from)
{
if (pstate->parentParseState != NULL)
@@ -1990,19 +1986,9 @@ warnAutoRange(ParseState *pstate, RangeVar *relation)
errmsg("missing FROM-clause entry for table \"%s\"",
relation->relname)));
}
-
- foreach(temp, pstate->p_rtable)
- {
- RangeTblEntry *rte = lfirst(temp);
-
- if (rte->inFromCl)
- {
- foundInFromCl = true;
- break;
- }
- }
- if (foundInFromCl)
+ else
{
+ /* just issue a warning */
if (pstate->parentParseState != NULL)
ereport(NOTICE,
(errcode(ERRCODE_UNDEFINED_TABLE),
index 2f8e86e4b06e50ecfe3977c12f1b8d88218ba50e..a6e5699357ca82a4a85b39e9ddac8ec786957128 100644 (file)
* back to source text
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.190 2005年04月06日 16:34:06 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.191 2005年04月07日 01:51:39 neilc Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -199,7 +199,8 @@ static void get_func_expr(FuncExpr *expr, deparse_context *context,
static void get_agg_expr(Aggref *aggref, deparse_context *context);
static void get_const_expr(Const *constval, deparse_context *context);
static void get_sublink_expr(SubLink *sublink, deparse_context *context);
-static void get_from_clause(Query *query, deparse_context *context);
+static void get_from_clause(Query *query, const char *prefix,
+ deparse_context *context);
static void get_from_clause_item(Node *jtnode, Query *query,
deparse_context *context);
static void get_from_clause_alias(Alias *alias, int varno,
@@ -2020,7 +2021,7 @@ get_basic_select_query(Query *query, deparse_context *context,
}
/* Add the FROM clause if needed */
- get_from_clause(query, context);
+ get_from_clause(query, " FROM ", context);
/* Add the WHERE clause if given */
if (query->jointree->quals != NULL)
@@ -2325,7 +2326,7 @@ get_update_query_def(Query *query, deparse_context *context)
}
/* Add the FROM clause if needed */
- get_from_clause(query, context);
+ get_from_clause(query, " FROM ", context);
/* Finally add a WHERE clause if given */
if (query->jointree->quals != NULL)
@@ -2361,6 +2362,9 @@ get_delete_query_def(Query *query, deparse_context *context)
only_marker(rte),
generate_relation_name(rte->relid));
+ /* Add the USING clause if given */
+ get_from_clause(query, " USING ", context);
+
/* Add a WHERE clause if given */
if (query->jointree->quals != NULL)
{
@@ -3805,10 +3809,14 @@ get_sublink_expr(SubLink *sublink, deparse_context *context)
/* ----------
* get_from_clause - Parse back a FROM clause
+ *
+ * "prefix" is the keyword that denotes the start of the list of FROM
+ * elements. It is FROM when used to parse back SELECT and UPDATE, but
+ * is USING when parsing back DELETE.
* ----------
*/
static void
-get_from_clause(Query *query, deparse_context *context)
+get_from_clause(Query *query, const char *prefix, deparse_context *context)
{
StringInfo buf = context->buf;
bool first = true;
@@ -3840,7 +3848,7 @@ get_from_clause(Query *query, deparse_context *context)
if (first)
{
- appendContextKeyword(context, " FROM ",
+ appendContextKeyword(context, prefix,
-PRETTYINDENT_STD, PRETTYINDENT_STD, 2);
first = false;
}
index aa7c686fb6b0e831830adb5faa6a8c6d35dcf333..f8645f030c2c2c13c61262b69f0cabf816eb8bc9 100644 (file)
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.123 2005年04月04日 07:19:44 neilc Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.124 2005年04月07日 01:51:39 neilc Exp $
*/
/*----------------------------------------------------------------------
else if (pg_strcasecmp(prev2_wd, "DELETE") == 0 &&
pg_strcasecmp(prev_wd, "FROM") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
- /* Complete DELETE FROM <table> with "WHERE" (perhaps a safe idea?) */
+ /* Complete DELETE FROM <table> */
else if (pg_strcasecmp(prev3_wd, "DELETE") == 0 &&
pg_strcasecmp(prev2_wd, "FROM") == 0)
- COMPLETE_WITH_CONST("WHERE");
+ {
+ static const char *const list_DELETE[] =
+ {"USING", "WHERE", "SET", NULL};
+
+ COMPLETE_WITH_LIST(list_DELETE);
+ }
+ /* XXX: implement tab completion for DELETE ... USING */
/* EXPLAIN */
index 85016f351123ee92c3fe79ea3f0e2515a713b126..e8a44c34b2f18241edba6aee3735dc446acb5370 100644 (file)
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.276 2005年04月06日 16:34:07 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.277 2005年04月07日 01:51:40 neilc Exp $
*
*-------------------------------------------------------------------------
*/
NodeTag type;
RangeVar *relation; /* relation to delete from */
Node *whereClause; /* qualifications */
+ List *usingClause; /* optional using clause for more tables */
} DeleteStmt;
/* ----------------------
index 358902f28f051240ce058754281b2401e60ed5a9..309fb1d6710c611084287d2c4f021c38d2da08d7 100644 (file)
@@ -37,7 +37,7 @@ INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
ERROR: invalid input syntax for type abstime: "bad date format"
INSERT INTO ABSTIME_TBL (f1) VALUES ('Jun 10, 1843');
-- test abstime operators
-SELECT '' AS eight, ABSTIME_TBL.*;
+SELECT '' AS eight, * FROM ABSTIME_TBL;
eight | f1
-------+------------------------------
| Sun Jan 14 03:14:21 1973 PST
@@ -49,7 +49,7 @@ SELECT '' AS eight, ABSTIME_TBL.*;
| invalid
(7 rows)
-SELECT '' AS six, ABSTIME_TBL.*
+SELECT '' AS six, * FROM ABSTIME_TBL
WHERE ABSTIME_TBL.f1 < abstime 'Jun 30, 2001';
six | f1
-----+------------------------------
| Sat May 10 23:59:12 1947 PST
(5 rows)
-SELECT '' AS six, ABSTIME_TBL.*
+SELECT '' AS six, * FROM ABSTIME_TBL
WHERE ABSTIME_TBL.f1 > abstime '-infinity';
six | f1
-----+------------------------------
| invalid
(6 rows)
-SELECT '' AS six, ABSTIME_TBL.*
+SELECT '' AS six, * FROM ABSTIME_TBL
WHERE abstime 'May 10, 1947 23:59:12' <> ABSTIME_TBL.f1;
six | f1
-----+------------------------------
| invalid
(6 rows)
-SELECT '' AS three, ABSTIME_TBL.*
+SELECT '' AS three, * FROM ABSTIME_TBL
WHERE abstime 'epoch' >= ABSTIME_TBL.f1;
three | f1
-------+------------------------------
@@ -93,7 +93,7 @@ SELECT '' AS three, ABSTIME_TBL.*
| Sat May 10 23:59:12 1947 PST
(3 rows)
-SELECT '' AS four, ABSTIME_TBL.*
+SELECT '' AS four, * FROM ABSTIME_TBL
WHERE ABSTIME_TBL.f1 <= abstime 'Jan 14, 1973 03:14:21';
four | f1
------+------------------------------
| Sat May 10 23:59:12 1947 PST
(4 rows)
-SELECT '' AS four, ABSTIME_TBL.*
+SELECT '' AS four, * FROM ABSTIME_TBL
WHERE ABSTIME_TBL.f1 <?>
tinterval '["Apr 1 1950 00:00:00" "Dec 30 1999 23:00:00"]';
four | f1
index 06f2fac16b56b32317e44b6bb222796467695f15..93e475b673ff6a8d04b9469e48b22530bbf5ca94 100644 (file)
@@ -59,7 +59,7 @@ INSERT INTO BOOLTBL1 (f1) VALUES (bool 't');
INSERT INTO BOOLTBL1 (f1) VALUES (bool 'True');
INSERT INTO BOOLTBL1 (f1) VALUES (bool 'true');
-- BOOLTBL1 should be full of true's at this point
-SELECT '' AS t_3, BOOLTBL1.*;
+SELECT '' AS t_3, BOOLTBL1.* FROM BOOLTBL1;
t_3 | f1
-----+----
| t
VALUES (bool 'XXX');
ERROR: invalid input syntax for type boolean: "XXX"
-- BOOLTBL2 should be full of false's at this point
-SELECT '' AS f_4, BOOLTBL2.*;
+SELECT '' AS f_4, BOOLTBL2.* FROM BOOLTBL2;
f_4 | f1
-----+----
| f
(4 rows)
SELECT '' AS tf_12, BOOLTBL1.*, BOOLTBL2.*
+ FROM BOOLTBL1, BOOLTBL2
WHERE BOOLTBL2.f1 <> BOOLTBL1.f1;
tf_12 | f1 | f1
-------+----+----
@@ -142,6 +143,7 @@ SELECT '' AS tf_12, BOOLTBL1.*, BOOLTBL2.*
(12 rows)
SELECT '' AS tf_12, BOOLTBL1.*, BOOLTBL2.*
+ FROM BOOLTBL1, BOOLTBL2
WHERE boolne(BOOLTBL2.f1,BOOLTBL1.f1);
tf_12 | f1 | f1
-------+----+----
@@ -160,6 +162,7 @@ SELECT '' AS tf_12, BOOLTBL1.*, BOOLTBL2.*
(12 rows)
SELECT '' AS ff_4, BOOLTBL1.*, BOOLTBL2.*
+ FROM BOOLTBL1, BOOLTBL2
WHERE BOOLTBL2.f1 = BOOLTBL1.f1 and BOOLTBL1.f1 = bool 'false';
ff_4 | f1 | f1
------+----+----
@@ -170,6 +173,7 @@ SELECT '' AS ff_4, BOOLTBL1.*, BOOLTBL2.*
(4 rows)
SELECT '' AS tf_12_ff_4, BOOLTBL1.*, BOOLTBL2.*
+ FROM BOOLTBL1, BOOLTBL2
WHERE BOOLTBL2.f1 = BOOLTBL1.f1 or BOOLTBL1.f1 = bool 'true'
ORDER BY BOOLTBL1.f1, BOOLTBL2.f1;
tf_12_ff_4 | f1 | f1
index edde87f315d5156d8492e9860a4e1a79916c91ab..02b07dfe61767d67af51f51d94b70b34259a1aa1 100644 (file)
@@ -27,7 +27,7 @@ INSERT INTO BOX_TBL (f1) VALUES ('(2.3, 4.5)');
ERROR: invalid input syntax for type box: "(2.3, 4.5)"
INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad');
ERROR: invalid input syntax for type box: "asdfasdf(ad"
-SELECT '' AS four, BOX_TBL.*;
+SELECT '' AS four, * FROM BOX_TBL;
four | f1
------+---------------------
| (2,2),(0,0)
index 0c46e07976233fc0c6e7e3f947b5c1c490111189..a0ba3d4a8c0ccbba04acafbaf84c28a18531bacb 100644 (file)
@@ -25,7 +25,7 @@ INSERT INTO CHAR_TBL (f1) VALUES ('');
INSERT INTO CHAR_TBL (f1) VALUES ('cd');
ERROR: value too long for type character(1)
INSERT INTO CHAR_TBL (f1) VALUES ('c ');
-SELECT '' AS seven, CHAR_TBL.*;
+SELECT '' AS seven, * FROM CHAR_TBL;
seven | f1
-------+----
| a
@@ -111,7 +111,7 @@ INSERT INTO CHAR_TBL (f1) VALUES ('abcd');
INSERT INTO CHAR_TBL (f1) VALUES ('abcde');
ERROR: value too long for type character(4)
INSERT INTO CHAR_TBL (f1) VALUES ('abcd ');
-SELECT '' AS four, CHAR_TBL.*;
+SELECT '' AS four, * FROM CHAR_TBL;
four | f1
------+------
| a
index 0d5be3097d0d93ae762ee1d2089ec231b7b9dd87..4cc081deae70beb8a2877c71f77bfb765a660d35 100644 (file)
@@ -25,7 +25,7 @@ INSERT INTO CHAR_TBL (f1) VALUES ('');
INSERT INTO CHAR_TBL (f1) VALUES ('cd');
ERROR: value too long for type character(1)
INSERT INTO CHAR_TBL (f1) VALUES ('c ');
-SELECT '' AS seven, CHAR_TBL.*;
+SELECT '' AS seven, * FROM CHAR_TBL;
seven | f1
-------+----
| a
@@ -111,7 +111,7 @@ INSERT INTO CHAR_TBL (f1) VALUES ('abcd');
INSERT INTO CHAR_TBL (f1) VALUES ('abcde');
ERROR: value too long for type character(4)
INSERT INTO CHAR_TBL (f1) VALUES ('abcd ');
-SELECT '' AS four, CHAR_TBL.*;
+SELECT '' AS four, * FROM CHAR_TBL;
four | f1
------+------
| a
index 2189e3004964592155ef41e3e5969ce1e559f6e4..775d1bd1a77a68e9954c0dc4205944edf9325262 100644 (file)
-- CLASS POPULATION
-- (any resemblance to real life is purely coincidental)
--
-INSERT INTO tenk2 VALUES (tenk1.*);
+INSERT INTO tenk2 SELECT * FROM tenk1;
SELECT * INTO TABLE onek2 FROM onek;
-INSERT INTO fast_emp4000 VALUES (slow_emp4000.*);
+INSERT INTO fast_emp4000 SELECT * FROM slow_emp4000;
SELECT *
INTO TABLE Bprime
FROM tenk1
index b6be7450638d2096fc0c8df86ef14173dcd135e6..79eed2b7a6ee2463e4bf64df9b965e6b4d7d4357 100644 (file)
@@ -126,8 +126,8 @@ NOTICE: view "v12_temp" will be a temporary view
-- a view should also be temporary if it references a temporary sequence
CREATE SEQUENCE seq1;
CREATE TEMPORARY SEQUENCE seq1_temp;
-CREATE VIEW v9 AS SELECT seq1.is_called;
-CREATE VIEW v13_temp AS SELECT seq1_temp.is_called;
+CREATE VIEW v9 AS SELECT seq1.is_called FROM seq1;
+CREATE VIEW v13_temp AS SELECT seq1_temp.is_called FROM seq1_temp;
NOTICE: view "v13_temp" will be a temporary view
SELECT relname FROM pg_class
WHERE relname LIKE 'v_'
index 8e0d643d2551b0d0d5a4aff2eb854bcea85d0091..a696a6d1c5148a91c3e7cacaa66b8557bbef0917 100644 (file)
-- FLOAT4
--
CREATE TABLE FLOAT4_TBL (f1 float4);
-INSERT INTO FLOAT4_TBL(f1) VALUES ('0.0');
-INSERT INTO FLOAT4_TBL(f1) VALUES ('1004.30');
-INSERT INTO FLOAT4_TBL(f1) VALUES ('-34.84');
+INSERT INTO FLOAT4_TBL(f1) VALUES ('0.0');
+INSERT INTO FLOAT4_TBL(f1) VALUES ('1004.30');
+INSERT INTO FLOAT4_TBL(f1) VALUES (' -34.84 ');
INSERT INTO FLOAT4_TBL(f1) VALUES ('1.2345678901234e+20');
INSERT INTO FLOAT4_TBL(f1) VALUES ('1.2345678901234e-20');
-- test for over and under flow
@@ -85,7 +85,7 @@ SELECT 'nan'::float4 / 'nan'::float4;
NaN
(1 row)
-SELECT '' AS five, FLOAT4_TBL.*;
+SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+--------------
| 0
@@ -183,7 +183,7 @@ SELECT '' AS three, f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f
-- test divide by zero
SELECT '' AS bad, f.f1 / '0.0' from FLOAT4_TBL f;
ERROR: division by zero
-SELECT '' AS five, FLOAT4_TBL.*;
+SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+--------------
| 0
@@ -207,7 +207,7 @@ SELECT '' AS five, f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f;
UPDATE FLOAT4_TBL
SET f1 = FLOAT4_TBL.f1 * '-1'
WHERE FLOAT4_TBL.f1 > '0.0';
-SELECT '' AS five, FLOAT4_TBL.*;
+SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+---------------
| 0
index 8ababaad6e7f3cb86bb264ec82ee8acf846501a3..b94816eaebd19ce85fd63e74bf5493febd55e359 100644 (file)
@@ -85,7 +85,7 @@ SELECT 'nan'::float4 / 'nan'::float4;
NaN
(1 row)
-SELECT '' AS five, FLOAT4_TBL.*;
+SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+-------------
| 0
@@ -183,7 +183,7 @@ SELECT '' AS three, f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f
-- test divide by zero
SELECT '' AS bad, f.f1 / '0.0' from FLOAT4_TBL f;
ERROR: division by zero
-SELECT '' AS five, FLOAT4_TBL.*;
+SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+-------------
| 0
@@ -207,7 +207,7 @@ SELECT '' AS five, f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f;
UPDATE FLOAT4_TBL
SET f1 = FLOAT4_TBL.f1 * '-1'
WHERE FLOAT4_TBL.f1 > '0.0';
-SELECT '' AS five, FLOAT4_TBL.*;
+SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+--------------
| 0
index a7f15c5bbde4a817c2755e1a6819a4401ee21a50..63d5e33c936bec8876475389c711c03bf2e1fd2b 100644 (file)
-- FLOAT8
--
CREATE TABLE FLOAT8_TBL(f1 float8);
-INSERT INTO FLOAT8_TBL(f1) VALUES ('0.0');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30');
-INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
+INSERT INTO FLOAT8_TBL(f1) VALUES (' 0.0 ');
+INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30');
+INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e+200');
INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e-200');
-- test for underflow and overflow handling
@@ -85,7 +85,7 @@ SELECT 'nan'::float8 / 'nan'::float8;
NaN
(1 row)
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+----------------------
| 0
@@ -328,7 +328,7 @@ SELECT '' AS five, f.f1, ||/f.f1 AS cbrt_f1 FROM FLOAT8_TBL f;
| 1.2345678901234e-200 | 2.3112042409018e-067
(5 rows)
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+----------------------
| 0
@@ -353,7 +353,7 @@ SELECT '' AS bad, exp(f.f1) from FLOAT8_TBL f;
ERROR: result is out of range
SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
ERROR: division by zero
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+-----------------------
| 0
@@ -380,7 +380,7 @@ INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1004.30');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e+200');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e-200');
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+-----------------------
| 0
index c466ce6402d142c88fdd45f511bc880a2c3bc629..7f345c4b37e1ff27a5b104029a939e0f20551007 100644 (file)
@@ -84,7 +84,7 @@ SELECT 'nan'::float8 / 'nan'::float8;
NaN
(1 row)
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+----------------------
| 0
@@ -327,7 +327,7 @@ SELECT '' AS five, f.f1, ||/f.f1 AS cbrt_f1 FROM FLOAT8_TBL f;
| 1.2345678901234e-200 | 2.3112042409018e-067
(5 rows)
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+----------------------
| 0
@@ -352,7 +352,7 @@ SELECT '' AS bad, exp(f.f1) from FLOAT8_TBL f;
ERROR: result is out of range
SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
ERROR: division by zero
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+-----------------------
| 0
@@ -379,7 +379,7 @@ INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1004.30');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e+200');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e-200');
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+-----------------------
| 0
index afa892ae243245d0802f90406c35117fcbcc4d90..a22ca55e2288fb31a090248eed8874aa0fd4474e 100644 (file)
@@ -93,7 +93,7 @@ SELECT 'nan'::float8 / 'nan'::float8;
NaN
(1 row)
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+----------------------
| 0
@@ -336,7 +336,7 @@ SELECT '' AS five, f.f1, ||/f.f1 AS cbrt_f1 FROM FLOAT8_TBL f;
| 1.2345678901234e-200 | 2.3112042409018e-67
(5 rows)
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+----------------------
| 0
@@ -361,7 +361,7 @@ SELECT '' AS bad, exp(f.f1) from FLOAT8_TBL f;
ERROR: result is out of range
SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
ERROR: division by zero
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+-----------------------
| 0
@@ -386,7 +386,7 @@ INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1004.30');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e+200');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e-200');
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+-----------------------
| 0
index a6b1ae2c04c3e39d32bd6116729d62963fda24b9..dbb0b1a69d5a070dbb9e5a6c524c900cf4ded5ad 100644 (file)
@@ -93,7 +93,7 @@ SELECT 'nan'::float8 / 'nan'::float8;
NaN
(1 row)
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+----------------------
| 0
@@ -336,7 +336,7 @@ SELECT '' AS five, f.f1, ||/f.f1 AS cbrt_f1 FROM FLOAT8_TBL f;
| 1.2345678901234e-200 | 2.3112042409018e-67
(5 rows)
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+----------------------
| 0
@@ -361,7 +361,7 @@ SELECT '' AS bad, exp(f.f1) from FLOAT8_TBL f;
ERROR: result is out of range
SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
ERROR: division by zero
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+-----------------------
| 0
@@ -386,7 +386,7 @@ INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1004.30');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e+200');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e-200');
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+-----------------------
| 0
index 579f80abfeb0b85fcec0308b1227eca285908399..fbf8c721768942519dfaa814dec8312e0c9ed297 100644 (file)
@@ -85,7 +85,7 @@ SELECT 'nan'::float8 / 'nan'::float8;
NaN
(1 row)
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+----------------------
| 0
@@ -328,7 +328,7 @@ SELECT '' AS five, f.f1, ||/f.f1 AS cbrt_f1 FROM FLOAT8_TBL f;
| 1.2345678901234e-200 | 2.3112042409018e-67
(5 rows)
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+----------------------
| 0
@@ -353,7 +353,7 @@ SELECT '' AS bad, exp(f.f1) from FLOAT8_TBL f;
ERROR: result is out of range
SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
ERROR: division by zero
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+-----------------------
| 0
@@ -380,7 +380,7 @@ INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1004.30');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e+200');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e-200');
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
five | f1
------+-----------------------
| 0
index db687e5a2429452445f9ab5213bc0e09c5870b47..432c932480e9b16032c9e629f153bcd6ec25294b 100644 (file)
-- HASH_INDEX
-- grep 843938989 hash.data
--
-SELECT hash_i4_heap.*
+SELECT * FROM hash_i4_heap
WHERE hash_i4_heap.random = 843938989;
seqno | random
-------+-----------
-- hash index
-- grep 66766766 hash.data
--
-SELECT hash_i4_heap.*
+SELECT * FROM hash_i4_heap
WHERE hash_i4_heap.random = 66766766;
seqno | random
-------+--------
-- hash index
-- grep 1505703298 hash.data
--
-SELECT hash_name_heap.*
+SELECT * FROM hash_name_heap
WHERE hash_name_heap.random = '1505703298'::name;
seqno | random
-------+------------
-- hash index
-- grep 7777777 hash.data
--
-SELECT hash_name_heap.*
+SELECT * FROM hash_name_heap
WHERE hash_name_heap.random = '7777777'::name;
seqno | random
-------+--------
-- hash index
-- grep 1351610853 hash.data
--
-SELECT hash_txt_heap.*
+SELECT * FROM hash_txt_heap
WHERE hash_txt_heap.random = '1351610853'::text;
seqno | random
-------+------------
-- hash index
-- grep 111111112222222233333333 hash.data
--
-SELECT hash_txt_heap.*
+SELECT * FROM hash_txt_heap
WHERE hash_txt_heap.random = '111111112222222233333333'::text;
seqno | random
-------+--------
-- hash index
-- grep 444705537 hash.data
--
-SELECT hash_f8_heap.*
+SELECT * FROM hash_f8_heap
WHERE hash_f8_heap.random = '444705537'::float8;
seqno | random
-------+-----------
-- hash index
-- grep 88888888 hash.data
--
-SELECT hash_f8_heap.*
+SELECT * FROM hash_f8_heap
WHERE hash_f8_heap.random = '88888888'::float8;
seqno | random
-------+--------
index d35241dab93c6bd61ad44912f9680572207a97bb..ca8bc3d0e5ca536d80a11a7cdb2eb4e4e28441fc 100644 (file)
@@ -2213,6 +2213,7 @@ SELECT '' AS "226", d1.f1 AS timestamp1, d2.f1 AS timestamp2, d1.f1 - d2.f1 AS d
-- abstime, reltime arithmetic
--
SELECT '' AS ten, ABSTIME_TBL.f1 AS abstime, RELTIME_TBL.f1 AS reltime
+ FROM ABSTIME_TBL, RELTIME_TBL
WHERE (ABSTIME_TBL.f1 + RELTIME_TBL.f1) < abstime 'Jan 14 14:00:00 1971'
ORDER BY abstime, reltime;
ten | abstime | reltime
@@ -2232,7 +2233,7 @@ SELECT '' AS ten, ABSTIME_TBL.f1 AS abstime, RELTIME_TBL.f1 AS reltime
-- these four queries should return the same answer
-- the "infinity" and "-infinity" tuples in ABSTIME_TBL cannot be added and
-- therefore, should not show up in the results.
-SELECT '' AS three, ABSTIME_TBL.*
+SELECT '' AS three, * FROM ABSTIME_TBL
WHERE (ABSTIME_TBL.f1 + reltime '@ 3 year') -- +3 years
< abstime 'Jan 14 14:00:00 1977';
three | f1
| Sat May 10 23:59:12 1947 PST
(3 rows)
-SELECT '' AS three, ABSTIME_TBL.*
+SELECT '' AS three, * FROM ABSTIME_TBL
WHERE (ABSTIME_TBL.f1 + reltime '@ 3 year ago') -- -3 years
< abstime 'Jan 14 14:00:00 1971';
three | f1
| Sat May 10 23:59:12 1947 PST
(3 rows)
-SELECT '' AS three, ABSTIME_TBL.*
+SELECT '' AS three, * FROM ABSTIME_TBL
WHERE (ABSTIME_TBL.f1 - reltime '@ 3 year') -- -(+3) years
< abstime 'Jan 14 14:00:00 1971';
three | f1
| Sat May 10 23:59:12 1947 PST
(3 rows)
-SELECT '' AS three, ABSTIME_TBL.*
+SELECT '' AS three, * FROM ABSTIME_TBL
WHERE (ABSTIME_TBL.f1 - reltime '@ 3 year ago') -- -(-3) years
< abstime 'Jan 14 14:00:00 1977';
three | f1
index f72aeb278aed71a8033bad14353d70523491cf57..e34e85bc97133a06e5d8542625899cb858f7ee43 100644 (file)
@@ -27,7 +27,7 @@ INSERT INTO INT2_TBL(f1) VALUES ('123 dt');
ERROR: invalid input syntax for integer: "123 dt"
INSERT INTO INT2_TBL(f1) VALUES ('');
ERROR: invalid input syntax for integer: ""
-SELECT '' AS five, INT2_TBL.*;
+SELECT '' AS five, * FROM INT2_TBL;
five | f1
------+--------
| 0
index 0e6049f29a86cfc2c9b11f1dfc67bcd318e61593..3e0eff13a3122a890470e6eafe8d4eb5a1916fa1 100644 (file)
@@ -27,7 +27,7 @@ INSERT INTO INT4_TBL(f1) VALUES ('123 5');
ERROR: invalid input syntax for integer: "123 5"
INSERT INTO INT4_TBL(f1) VALUES ('');
ERROR: invalid input syntax for integer: ""
-SELECT '' AS five, INT4_TBL.*;
+SELECT '' AS five, * FROM INT4_TBL;
five | f1
------+-------------
| 0
index 8ba178c8bf3ce2e1b6eaec2ce926d43c5d3907ed..ab89b2232d595c9562801f89d51ce9965eeb7df3 100644 (file)
@@ -62,7 +62,7 @@ ERROR: invalid input syntax for type interval: "badly formatted interval"
INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 30 eons ago');
ERROR: invalid input syntax for type interval: "@ 30 eons ago"
-- test interval operators
-SELECT '' AS ten, INTERVAL_TBL.*;
+SELECT '' AS ten, * FROM INTERVAL_TBL;
ten | f1
-----+-----------------
| 00:01:00
@@ -77,7 +77,7 @@ SELECT '' AS ten, INTERVAL_TBL.*;
| 5 mons 12:00:00
(10 rows)
-SELECT '' AS nine, INTERVAL_TBL.*
+SELECT '' AS nine, * FROM INTERVAL_TBL
WHERE INTERVAL_TBL.f1 <> interval '@ 10 days';
nine | f1
------+-----------------
@@ -92,7 +92,7 @@ SELECT '' AS nine, INTERVAL_TBL.*
| 5 mons 12:00:00
(9 rows)
-SELECT '' AS three, INTERVAL_TBL.*
+SELECT '' AS three, * FROM INTERVAL_TBL
WHERE INTERVAL_TBL.f1 <= interval '@ 5 hours';
three | f1
-------+-----------
| -00:00:14
(3 rows)
-SELECT '' AS three, INTERVAL_TBL.*
+SELECT '' AS three, * FROM INTERVAL_TBL
WHERE INTERVAL_TBL.f1 < interval '@ 1 day';
three | f1
-------+-----------
| -00:00:14
(3 rows)
-SELECT '' AS one, INTERVAL_TBL.*
+SELECT '' AS one, * FROM INTERVAL_TBL
WHERE INTERVAL_TBL.f1 = interval '@ 34 years';
one | f1
-----+----------
| 34 years
(1 row)
-SELECT '' AS five, INTERVAL_TBL.*
+SELECT '' AS five, * FROM INTERVAL_TBL
WHERE INTERVAL_TBL.f1 >= interval '@ 1 month';
five | f1
------+-----------------
| 5 mons 12:00:00
(5 rows)
-SELECT '' AS nine, INTERVAL_TBL.*
+SELECT '' AS nine, * FROM INTERVAL_TBL
WHERE INTERVAL_TBL.f1 > interval '@ 3 seconds ago';
nine | f1
------+-----------------
(45 rows)
SET DATESTYLE = 'postgres';
-SELECT '' AS ten, INTERVAL_TBL.*;
+SELECT '' AS ten, * FROM INTERVAL_TBL;
ten | f1
-----+-------------------------------
| @ 1 min
index 83f6939945cced1109ce831fcb10755342a583e3..c01136970c3a6520799190086b200ef777a73069 100644 (file)
DROP TABLE t3;
DROP TABLE J1_TBL;
DROP TABLE J2_TBL;
+-- Both DELETE and UPDATE allow the specification of additional tables
+-- to "join" against to determine which rows should be modified.
+CREATE TEMP TABLE t1 (a int, b int);
+CREATE TEMP TABLE t2 (a int, b int);
+CREATE TEMP TABLE t3 (x int, y int);
+INSERT INTO t1 VALUES (5, 10);
+INSERT INTO t1 VALUES (15, 20);
+INSERT INTO t1 VALUES (100, 100);
+INSERT INTO t1 VALUES (200, 1000);
+INSERT INTO t2 VALUES (200, 2000);
+INSERT INTO t3 VALUES (5, 20);
+INSERT INTO t3 VALUES (6, 7);
+INSERT INTO t3 VALUES (7, 8);
+INSERT INTO t3 VALUES (500, 100);
+DELETE FROM t3 USING t1 table1 WHERE t3.x = table1.a;
+SELECT * FROM t3;
+ x | y
+-----+-----
+ 6 | 7
+ 7 | 8
+ 500 | 100
+(3 rows)
+
+DELETE FROM t3 USING t1 JOIN t2 USING (a) WHERE t3.x > t1.a;
+SELECT * FROM t3;
+ x | y
+---+---
+ 6 | 7
+ 7 | 8
+(2 rows)
+
+DELETE FROM t3 USING t3 t3_other WHERE t3.x = t3_other.x AND t3.y = t3_other.y;
+SELECT * FROM t3;
+ x | y
+---+---
+(0 rows)
+
index e8c8f44d048188641fec4f101b497256b8d5be1f..c3bfb04fb471f3c81f27306d7922e429596e0491 100644 (file)
DROP TABLE t3;
DROP TABLE J1_TBL;
DROP TABLE J2_TBL;
+-- Both DELETE and UPDATE allow the specification of additional tables
+-- to "join" against to determine which rows should be modified.
+CREATE TEMP TABLE t1 (a int, b int);
+CREATE TEMP TABLE t2 (a int, b int);
+CREATE TEMP TABLE t3 (x int, y int);
+INSERT INTO t1 VALUES (5, 10);
+INSERT INTO t1 VALUES (15, 20);
+INSERT INTO t1 VALUES (100, 100);
+INSERT INTO t1 VALUES (200, 1000);
+INSERT INTO t2 VALUES (200, 2000);
+INSERT INTO t3 VALUES (5, 20);
+INSERT INTO t3 VALUES (6, 7);
+INSERT INTO t3 VALUES (7, 8);
+INSERT INTO t3 VALUES (500, 100);
+DELETE FROM t3 USING t1 table1 WHERE t3.x = table1.a;
+SELECT * FROM t3;
+ x | y
+-----+-----
+ 6 | 7
+ 7 | 8
+ 500 | 100
+(3 rows)
+
+DELETE FROM t3 USING t1 JOIN t2 USING (a) WHERE t3.x > t1.a;
+SELECT * FROM t3;
+ x | y
+---+---
+ 6 | 7
+ 7 | 8
+(2 rows)
+
+DELETE FROM t3 USING t3 t3_other WHERE t3.x = t3_other.x AND t3.y = t3_other.y;
+SELECT * FROM t3;
+ x | y
+---+---
+(0 rows)
index f6c3a17fe51f659d98a572df3913545dfc6aedec..b359d52822571f522d1110435014b04b7f0659da 100644 (file)
@@ -26,7 +26,7 @@ INSERT INTO NAME_TBL(f1) VALUES ('343f%2a');
INSERT INTO NAME_TBL(f1) VALUES ('d34aaasdf');
INSERT INTO NAME_TBL(f1) VALUES ('');
INSERT INTO NAME_TBL(f1) VALUES ('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ');
-SELECT '' AS seven, NAME_TBL.*;
+SELECT '' AS seven, * FROM NAME_TBL;
seven | f1
-------+-----------------------------------------------------------------
| 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
index 22976218069c47011d810262d9255a8a926d47a3..e01db08c202a2b514ccb4d3bd15cbb5d98326dfa 100644 (file)
@@ -32,7 +32,7 @@ INSERT INTO OID_TBL(f1) VALUES ('32958209582039852935');
ERROR: value "32958209582039852935" is out of range for type oid
INSERT INTO OID_TBL(f1) VALUES ('-23582358720398502385');
ERROR: value "-23582358720398502385" is out of range for type oid
-SELECT '' AS six, OID_TBL.*;
+SELECT '' AS six, * FROM OID_TBL;
six | f1
-----+------------
| 1234
index 1ad75abdb2eaa8ee8596ecab9297eab246cb82de..b77a42b3243a3bfde387e1b97fc94679e4769bc3 100644 (file)
@@ -15,7 +15,7 @@ INSERT INTO POINT_TBL(f1) VALUES ('(10.0 10.0)');
ERROR: invalid input syntax for type point: "(10.0 10.0)"
INSERT INTO POINT_TBL(f1) VALUES ('(10.0,10.0');
ERROR: invalid input syntax for type point: "(10.0,10.0"
-SELECT '' AS six, POINT_TBL.*;
+SELECT '' AS six, * FROM POINT_TBL;
six | f1
-----+------------
| (0,0)
index 5ffa39b1bc6e771ebfd1b66077c508520c6913f6..e9032d4dbcdead66dcf5a91fce12d64286b28c07 100644 (file)
@@ -30,7 +30,7 @@ INSERT INTO POLYGON_TBL(f1) VALUES ('(0,1,2,3');
ERROR: invalid input syntax for type polygon: "(0,1,2,3"
INSERT INTO POLYGON_TBL(f1) VALUES ('asdf');
ERROR: invalid input syntax for type polygon: "asdf"
-SELECT '' AS four, POLYGON_TBL.*;
+SELECT '' AS four, * FROM POLYGON_TBL;
four | f1
------+---------------------
| ((2,0),(2,4),(0,0))
index c5b6ffbc28791b02fdb287f2af5e192d505e070e..8ac111b5e18dc6db8f05444ba9ebd965815870a3 100644 (file)
@@ -128,7 +128,7 @@ ERROR: permission denied for relation atest1
UPDATE atest2 SET col2 = NULL; -- ok
UPDATE atest2 SET col2 = NOT col2; -- fails; requires SELECT on atest2
ERROR: permission denied for relation atest2
-UPDATE atest2 SET col2 = true WHERE atest1.a = 5; -- ok
+UPDATE atest2 SET col2 = true FROM atest1 WHERE atest1.a = 5; -- ok
SELECT * FROM atest1 FOR UPDATE; -- fail
ERROR: permission denied for relation atest1
SELECT * FROM atest2 FOR UPDATE; -- fail
index 50f2dba1382ac860cc0e26e928235bfebe0949cb..8f4faef1248fdc4915e598e83ddd677b2ebdceaa 100644 (file)
@@ -14,7 +14,7 @@ ERROR: invalid input syntax for type reltime: "badly formatted reltime"
INSERT INTO RELTIME_TBL (f1) VALUES ('@ 30 eons ago');
ERROR: invalid input syntax for type reltime: "@ 30 eons ago"
-- test reltime operators
-SELECT '' AS six, RELTIME_TBL.*;
+SELECT '' AS six, * FROM RELTIME_TBL;
six | f1
-----+---------------
| @ 1 min
@@ -25,7 +25,7 @@ SELECT '' AS six, RELTIME_TBL.*;
| @ 14 secs ago
(6 rows)
-SELECT '' AS five, RELTIME_TBL.*
+SELECT '' AS five, * FROM RELTIME_TBL
WHERE RELTIME_TBL.f1 <> reltime '@ 10 days';
five | f1
------+---------------
@@ -36,7 +36,7 @@ SELECT '' AS five, RELTIME_TBL.*
| @ 14 secs ago
(5 rows)
-SELECT '' AS three, RELTIME_TBL.*
+SELECT '' AS three, * FROM RELTIME_TBL
WHERE RELTIME_TBL.f1 <= reltime '@ 5 hours';
three | f1
-------+---------------
@@ -45,7 +45,7 @@ SELECT '' AS three, RELTIME_TBL.*
| @ 14 secs ago
(3 rows)
-SELECT '' AS three, RELTIME_TBL.*
+SELECT '' AS three, * FROM RELTIME_TBL
WHERE RELTIME_TBL.f1 < reltime '@ 1 day';
three | f1
-------+---------------
| @ 14 secs ago
(3 rows)
-SELECT '' AS one, RELTIME_TBL.*
+SELECT '' AS one, * FROM RELTIME_TBL
WHERE RELTIME_TBL.f1 = reltime '@ 34 years';
one | f1
-----+------------
| @ 34 years
(1 row)
-SELECT '' AS two, RELTIME_TBL.*
+SELECT '' AS two, * FROM RELTIME_TBL
WHERE RELTIME_TBL.f1 >= reltime '@ 1 month';
two | f1
-----+------------
| @ 3 mons
(2 rows)
-SELECT '' AS five, RELTIME_TBL.*
+SELECT '' AS five, * FROM RELTIME_TBL
WHERE RELTIME_TBL.f1 > reltime '@ 3 seconds ago';
five | f1
------+------------
index 0d46494596c722303210abba9ae36db2c2222cdf..5c4c0ef6f2a15014f406f774dc11526fc92aead3 100644 (file)
(3 rows)
delete from rtest_v1;
-insert into rtest_v1 select rtest_t2.a, rtest_t3.b where rtest_t2.a = rtest_t3.a;
+insert into rtest_v1 select rtest_t2.a, rtest_t3.b
+ from rtest_t2, rtest_t3
+ where rtest_t2.a = rtest_t3.a;
select * from rtest_v1;
a | b
---+----
(3 rows)
-- updates in a mergejoin
-update rtest_v1 set b = rtest_t2.b where a = rtest_t2.a;
+update rtest_v1 set b = rtest_t2.b from rtest_t2 where rtest_v1.a = rtest_t2.a;
select * from rtest_v1;
a | b
---+----
15 | 35
(8 rows)
-update rtest_v1 set a = rtest_t3.a + 20 where b = rtest_t3.b;
+update rtest_v1 set a = rtest_t3.a + 20 from rtest_t3 where rtest_v1.b = rtest_t3.b;
select * from rtest_v1;
a | b
----+----
@@ -435,7 +437,7 @@ select ename, who = current_user as "matches user", action, newsal, oldsal from
(8 rows)
update rtest_empmass set salary = salary + '1000.00';
-update rtest_emp set salary = rtest_empmass.salary where ename = rtest_empmass.ename;
+update rtest_emp set salary = rtest_empmass.salary from rtest_empmass where rtest_emp.ename = rtest_empmass.ename;
select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal;
ename | matches user | action | newsal | oldsal
----------------------+--------------+------------+------------+------------
@@ -452,7 +454,7 @@ select ename, who = current_user as "matches user", action, newsal, oldsal from
wieck | t | honored | 7,000ドル.00 | 6,000ドル.00
(11 rows)
-delete from rtest_emp where ename = rtest_empmass.ename;
+delete from rtest_emp using rtest_empmass where rtest_emp.ename = rtest_empmass.ename;
select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal;
ename | matches user | action | newsal | oldsal
----------------------+--------------+------------+------------+------------
index 7974d141c54143bc3b88a202fe1d53e2b7a0524b..b51aea8fb5c0639842cd59fca443b7aa37144736 100644 (file)
-- btree index
-- awk '{if(1ドル<10){print;}else{next;}}' onek.data | sort +0n -1
--
-SELECT onek.* WHERE onek.unique1 < 10
+SELECT * FROM onek
+ WHERE onek.unique1 < 10
ORDER BY onek.unique1;
unique1 | unique2 | two | four | ten | twenty | hundred | thousand | twothousand | fivethous | tenthous | odd | even | stringu1 | stringu2 | string4
---------+---------+-----+------+-----+--------+---------+----------+-------------+-----------+----------+-----+------+----------+----------+---------
@@ -23,7 +24,7 @@ SELECT onek.* WHERE onek.unique1 < 10
--
-- awk '{if(1ドル<20){print 1,ドル14ドル;}else{next;}}' onek.data | sort +0nr -1
--
-SELECT onek.unique1, onek.stringu1
+SELECT onek.unique1, onek.stringu1 FROM onek
WHERE onek.unique1 < 20
ORDER BY unique1 using >;
unique1 | stringu1
@@ -53,7 +54,7 @@ SELECT onek.unique1, onek.stringu1
--
-- awk '{if(1ドル>980){print 1,ドル14ドル;}else{next;}}' onek.data | sort +1d -2
--
-SELECT onek.unique1, onek.stringu1
+SELECT onek.unique1, onek.stringu1 FROM onek
WHERE onek.unique1 > 980
ORDER BY stringu1 using <;
unique1 | stringu1
@@ -84,7 +85,7 @@ SELECT onek.unique1, onek.stringu1
-- awk '{if(1ドル>980){print 1,ドル16ドル;}else{next;}}' onek.data |
-- sort +1d -2 +0nr -1
--
-SELECT onek.unique1, onek.string4
+SELECT onek.unique1, onek.string4 FROM onek
WHERE onek.unique1 > 980
ORDER BY string4 using <, unique1 using >;
unique1 | string4
-- awk '{if(1ドル>980){print 1,ドル16ドル;}else{next;}}' onek.data |
-- sort +1dr -2 +0n -1
--
-SELECT onek.unique1, onek.string4
+SELECT onek.unique1, onek.string4 FROM onek
WHERE onek.unique1 > 980
ORDER BY string4 using >, unique1 using <;
unique1 | string4
-- awk '{if(1ドル<20){print 1,ドル16ドル;}else{next;}}' onek.data |
-- sort +0nr -1 +1d -2
--
-SELECT onek.unique1, onek.string4
+SELECT onek.unique1, onek.string4 FROM onek
WHERE onek.unique1 < 20
ORDER BY unique1 using >, string4 using <;
unique1 | string4
-- awk '{if(1ドル<20){print 1,ドル16ドル;}else{next;}}' onek.data |
-- sort +0n -1 +1dr -2
--
-SELECT onek.unique1, onek.string4
+SELECT onek.unique1, onek.string4 FROM onek
WHERE onek.unique1 < 20
ORDER BY unique1 using <, string4 using >;
unique1 | string4
--
-- awk '{if(1ドル<10){print 0ドル;}else{next;}}' onek.data | sort +0n -1
--
-SELECT onek2.* WHERE onek2.unique1 < 10;
+SELECT onek2.* FROM onek2 WHERE onek2.unique1 < 10;
unique1 | unique2 | two | four | ten | twenty | hundred | thousand | twothousand | fivethous | tenthous | odd | even | stringu1 | stringu2 | string4
---------+---------+-----+------+-----+--------+---------+----------+-------------+-----------+----------+-----+------+----------+----------+---------
0 | 998 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | AAAAAA | KMBAAA | OOOOxx
@@ -232,7 +233,7 @@ SELECT onek2.* WHERE onek2.unique1 < 10;
--
-- awk '{if(1ドル<20){print 1,ドル14ドル;}else{next;}}' onek.data | sort +0nr -1
--
-SELECT onek2.unique1, onek2.stringu1
+SELECT onek2.unique1, onek2.stringu1 FROM onek2
WHERE onek2.unique1 < 20
ORDER BY unique1 using >;
unique1 | stringu1
--
-- awk '{if(1ドル>980){print 1,ドル14ドル;}else{next;}}' onek.data | sort +1d -2
--
-SELECT onek2.unique1, onek2.stringu1
+SELECT onek2.unique1, onek2.stringu1 FROM onek2
WHERE onek2.unique1 > 980;
unique1 | stringu1
---------+----------
index 3cb215a47024268135a78b1807c957d8d4818f03..5644cbc49326fca72e0ddd9567e7009c249e6951 100644 (file)
VALUES ('["" "infinity"]');
ERROR: invalid input syntax for type abstime: ""
-- test tinterval operators
-SELECT '' AS five, TINTERVAL_TBL.*;
+SELECT '' AS five, * FROM TINTERVAL_TBL;
five | f1
------+-----------------------------------------------------------------
| ["-infinity" "infinity"]
index 952875cfdf1a269d323e1bffa0cf5d651164790e..06a8a8f47c5b209b78d20fefe0a8e4db166d943b 100644 (file)
(0 rows)
DELETE FROM temptest; -- ok
-UPDATE temptest SET a = 0 WHERE a = 1 AND writetest.a = temptest.a; -- ok
+UPDATE temptest SET a = 0 FROM writetest WHERE temptest.a = 1 AND writetest.a = temptest.a; -- ok
PREPARE test AS UPDATE writetest SET a = 0; -- ok
EXECUTE test; -- fail
ERROR: transaction is read-only
index e33782eed74a818666bcc93591cd3d6fafeb9df5..48a77f5e130160d54f31c71a64e1e15f8a4bb4f5 100644 (file)
@@ -14,7 +14,7 @@ INSERT INTO VARCHAR_TBL (f1) VALUES ('');
INSERT INTO VARCHAR_TBL (f1) VALUES ('cd');
ERROR: value too long for type character varying(1)
INSERT INTO VARCHAR_TBL (f1) VALUES ('c ');
-SELECT '' AS seven, VARCHAR_TBL.*;
+SELECT '' AS seven, * FROM VARCHAR_TBL;
seven | f1
-------+----
| a
@@ -100,7 +100,7 @@ INSERT INTO VARCHAR_TBL (f1) VALUES ('abcd');
INSERT INTO VARCHAR_TBL (f1) VALUES ('abcde');
ERROR: value too long for type character varying(4)
INSERT INTO VARCHAR_TBL (f1) VALUES ('abcd ');
-SELECT '' AS four, VARCHAR_TBL.*;
+SELECT '' AS four, * FROM VARCHAR_TBL;
four | f1
------+------
| a
index a24ca34211018d35fd79177ebcdac9c89ea930ca..d726e4cc438c0a272092653d8cb8ba1f5e63e3d8 100644 (file)
@@ -14,7 +14,7 @@ INSERT INTO VARCHAR_TBL (f1) VALUES ('');
INSERT INTO VARCHAR_TBL (f1) VALUES ('cd');
ERROR: value too long for type character varying(1)
INSERT INTO VARCHAR_TBL (f1) VALUES ('c ');
-SELECT '' AS seven, VARCHAR_TBL.*;
+SELECT '' AS seven, * FROM VARCHAR_TBL;
seven | f1
-------+----
| a
@@ -100,7 +100,7 @@ INSERT INTO VARCHAR_TBL (f1) VALUES ('abcd');
INSERT INTO VARCHAR_TBL (f1) VALUES ('abcde');
ERROR: value too long for type character varying(4)
INSERT INTO VARCHAR_TBL (f1) VALUES ('abcd ');
-SELECT '' AS four, VARCHAR_TBL.*;
+SELECT '' AS four, * FROM VARCHAR_TBL;
four | f1
------+------
| a
index cfaaea95131169ff79fdd2084ef431ed37dd0470..c82b1405978628f002254f10abb0cba52f83fef2 100644 (file)
--
UPDATE tmp
SET stringu1 = reverse_name(onek.stringu1)
+ FROM onek
WHERE onek.stringu1 = 'JBAAAA' and
onek.stringu1 = tmp.stringu1;
UPDATE tmp
SET stringu1 = reverse_name(onek2.stringu1)
+ FROM onek2
WHERE onek2.stringu1 = 'JCAAAA' and
onek2.stringu1 = tmp.stringu1;
index 28a0f284838be2cb7865e8744759552eaf2f2bc4..cbaeb6295739a12f412ff8aa287fb7ac8e9637cc 100644 (file)
@@ -37,24 +37,24 @@ INSERT INTO ABSTIME_TBL (f1) VALUES ('Jun 10, 1843');
-- test abstime operators
-SELECT '' AS eight, ABSTIME_TBL.*;
+SELECT '' AS eight, * FROM ABSTIME_TBL;
-SELECT '' AS six, ABSTIME_TBL.*
+SELECT '' AS six, * FROM ABSTIME_TBL
WHERE ABSTIME_TBL.f1 < abstime 'Jun 30, 2001';
-SELECT '' AS six, ABSTIME_TBL.*
+SELECT '' AS six, * FROM ABSTIME_TBL
WHERE ABSTIME_TBL.f1 > abstime '-infinity';
-SELECT '' AS six, ABSTIME_TBL.*
+SELECT '' AS six, * FROM ABSTIME_TBL
WHERE abstime 'May 10, 1947 23:59:12' <> ABSTIME_TBL.f1;
-SELECT '' AS three, ABSTIME_TBL.*
+SELECT '' AS three, * FROM ABSTIME_TBL
WHERE abstime 'epoch' >= ABSTIME_TBL.f1;
-SELECT '' AS four, ABSTIME_TBL.*
+SELECT '' AS four, * FROM ABSTIME_TBL
WHERE ABSTIME_TBL.f1 <= abstime 'Jan 14, 1973 03:14:21';
-SELECT '' AS four, ABSTIME_TBL.*
+SELECT '' AS four, * FROM ABSTIME_TBL
WHERE ABSTIME_TBL.f1 <?>
tinterval '["Apr 1 1950 00:00:00" "Dec 30 1999 23:00:00"]';
index 86d4bb428ce5702089eabc491fde95b16a162578..df97dfab3b38fba7af0644dee7128affe5765d9d 100644 (file)
@@ -37,7 +37,7 @@ INSERT INTO BOOLTBL1 (f1) VALUES (bool 'true');
-- BOOLTBL1 should be full of true's at this point
-SELECT '' AS t_3, BOOLTBL1.*;
+SELECT '' AS t_3, BOOLTBL1.* FROM BOOLTBL1;
SELECT '' AS t_3, BOOLTBL1.*
VALUES (bool 'XXX');
-- BOOLTBL2 should be full of false's at this point
-SELECT '' AS f_4, BOOLTBL2.*;
+SELECT '' AS f_4, BOOLTBL2.* FROM BOOLTBL2;
SELECT '' AS tf_12, BOOLTBL1.*, BOOLTBL2.*
+ FROM BOOLTBL1, BOOLTBL2
WHERE BOOLTBL2.f1 <> BOOLTBL1.f1;
SELECT '' AS tf_12, BOOLTBL1.*, BOOLTBL2.*
+ FROM BOOLTBL1, BOOLTBL2
WHERE boolne(BOOLTBL2.f1,BOOLTBL1.f1);
SELECT '' AS ff_4, BOOLTBL1.*, BOOLTBL2.*
+ FROM BOOLTBL1, BOOLTBL2
WHERE BOOLTBL2.f1 = BOOLTBL1.f1 and BOOLTBL1.f1 = bool 'false';
SELECT '' AS tf_12_ff_4, BOOLTBL1.*, BOOLTBL2.*
+ FROM BOOLTBL1, BOOLTBL2
WHERE BOOLTBL2.f1 = BOOLTBL1.f1 or BOOLTBL1.f1 = bool 'true'
ORDER BY BOOLTBL1.f1, BOOLTBL2.f1;
index 68dbe138223ec0f9f10d95e935983592a5ff72f3..6e5935ceb65f81300380e947aac2ac6e41d2f96e 100644 (file)
@@ -37,7 +37,7 @@ INSERT INTO BOX_TBL (f1) VALUES ('(2.3, 4.5)');
INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad');
-SELECT '' AS four, BOX_TBL.*;
+SELECT '' AS four, * FROM BOX_TBL;
SELECT '' AS four, b.*, area(b.f1) as barea
FROM BOX_TBL b;
index 049f22fad39e5cbbdc7203db59932981d61c6203..fcaef7e086d02c65055677be01c13a38dc8dc074 100644 (file)
@@ -32,7 +32,7 @@ INSERT INTO CHAR_TBL (f1) VALUES ('cd');
INSERT INTO CHAR_TBL (f1) VALUES ('c ');
-SELECT '' AS seven, CHAR_TBL.*;
+SELECT '' AS seven, * FROM CHAR_TBL;
SELECT '' AS six, c.*
FROM CHAR_TBL c
@@ -72,4 +72,4 @@ INSERT INTO CHAR_TBL (f1) VALUES ('abcd');
INSERT INTO CHAR_TBL (f1) VALUES ('abcde');
INSERT INTO CHAR_TBL (f1) VALUES ('abcd ');
-SELECT '' AS four, CHAR_TBL.*;
+SELECT '' AS four, * FROM CHAR_TBL;
index a4cb816fa01c260f1fa81769a4e14a12bcf37759..40c9b417d9346650b4a82dec69a1e7934c776f7d 100644 (file)
-- (any resemblance to real life is purely coincidental)
--
-INSERT INTO tenk2 VALUES (tenk1.*);
+INSERT INTO tenk2 SELECT * FROM tenk1;
SELECT * INTO TABLE onek2 FROM onek;
-
-INSERT INTO fast_emp4000 VALUES (slow_emp4000.*);
+INSERT INTO fast_emp4000 SELECT * FROM slow_emp4000;
SELECT *
INTO TABLE Bprime
index 008ebae7045a86d6a8113e9043172338347ff7bd..30a9bb1152da9731c2bb2a1af1d4b76439404bee 100644 (file)
@@ -127,8 +127,8 @@ CREATE VIEW v12_temp AS SELECT true FROM v11_temp;
-- a view should also be temporary if it references a temporary sequence
CREATE SEQUENCE seq1;
CREATE TEMPORARY SEQUENCE seq1_temp;
-CREATE VIEW v9 AS SELECT seq1.is_called;
-CREATE VIEW v13_temp AS SELECT seq1_temp.is_called;
+CREATE VIEW v9 AS SELECT seq1.is_called FROM seq1;
+CREATE VIEW v13_temp AS SELECT seq1_temp.is_called FROM seq1_temp;
SELECT relname FROM pg_class
WHERE relname LIKE 'v_'
index 916431fbcc0a5461d44c77690ee85e5a55e4854e..a2140f547e5b3b6e561c659e9dbba32dbdce71f5 100644 (file)
@@ -42,7 +42,7 @@ SELECT 'Infinity'::float4 / 'Infinity'::float4;
SELECT 'nan'::float4 / 'nan'::float4;
-SELECT '' AS five, FLOAT4_TBL.*;
+SELECT '' AS five, * FROM FLOAT4_TBL;
SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE f.f1 <> '1004.3';
@@ -71,7 +71,7 @@ SELECT '' AS three, f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f
-- test divide by zero
SELECT '' AS bad, f.f1 / '0.0' from FLOAT4_TBL f;
-SELECT '' AS five, FLOAT4_TBL.*;
+SELECT '' AS five, * FROM FLOAT4_TBL;
-- test the unary float4abs operator
SELECT '' AS five, f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f;
SET f1 = FLOAT4_TBL.f1 * '-1'
WHERE FLOAT4_TBL.f1 > '0.0';
-SELECT '' AS five, FLOAT4_TBL.*;
+SELECT '' AS five, * FROM FLOAT4_TBL;
index 0ff71be5d423b78fb26526f624cfbd5324d38b5c..fc38e372d523ba22770e82c38484d4458711e3fd 100644 (file)
@@ -41,7 +41,7 @@ SELECT 'Infinity'::float8 + 100.0;
SELECT 'Infinity'::float8 / 'Infinity'::float8;
SELECT 'nan'::float8 / 'nan'::float8;
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <> '1004.3';
SELECT '' AS five, f.f1, ||/f.f1 AS cbrt_f1 FROM FLOAT8_TBL f;
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
UPDATE FLOAT8_TBL
SET f1 = FLOAT8_TBL.f1 * '-1'
@@ -137,7 +137,7 @@ SELECT '' AS bad, exp(f.f1) from FLOAT8_TBL f;
SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
-- test for over- and underflow
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');
@@ -163,5 +163,5 @@ INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e+200');
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e-200');
-SELECT '' AS five, FLOAT8_TBL.*;
+SELECT '' AS five, * FROM FLOAT8_TBL;
index cfd77d5720367031f70b77b39f021e1a4c5e26ba..b0811b7dc0a817be9dd7799bfca3476931fdbd0f 100644 (file)
-- grep 843938989 hash.data
--
-SELECT hash_i4_heap.*
+SELECT * FROM hash_i4_heap
WHERE hash_i4_heap.random = 843938989;
--
-- hash index
-- grep 66766766 hash.data
--
-SELECT hash_i4_heap.*
+SELECT * FROM hash_i4_heap
WHERE hash_i4_heap.random = 66766766;
--
-- hash index
-- grep 1505703298 hash.data
--
-SELECT hash_name_heap.*
+SELECT * FROM hash_name_heap
WHERE hash_name_heap.random = '1505703298'::name;
--
-- hash index
-- grep 7777777 hash.data
--
-SELECT hash_name_heap.*
+SELECT * FROM hash_name_heap
WHERE hash_name_heap.random = '7777777'::name;
--
-- hash index
-- grep 1351610853 hash.data
--
-SELECT hash_txt_heap.*
+SELECT * FROM hash_txt_heap
WHERE hash_txt_heap.random = '1351610853'::text;
--
-- hash index
-- grep 111111112222222233333333 hash.data
--
-SELECT hash_txt_heap.*
+SELECT * FROM hash_txt_heap
WHERE hash_txt_heap.random = '111111112222222233333333'::text;
--
-- hash index
-- grep 444705537 hash.data
--
-SELECT hash_f8_heap.*
+SELECT * FROM hash_f8_heap
WHERE hash_f8_heap.random = '444705537'::float8;
--
-- hash index
-- grep 88888888 hash.data
--
-SELECT hash_f8_heap.*
+SELECT * FROM hash_f8_heap
WHERE hash_f8_heap.random = '88888888'::float8;
--
index 874700c4b92d901f4ecd5c38836d7b978654467b..afc9feb0c802d6e8a03e24d0123f6c450bad3587 100644 (file)
@@ -256,6 +256,7 @@ SELECT '' AS "226", d1.f1 AS timestamp1, d2.f1 AS timestamp2, d1.f1 - d2.f1 AS d
--
SELECT '' AS ten, ABSTIME_TBL.f1 AS abstime, RELTIME_TBL.f1 AS reltime
+ FROM ABSTIME_TBL, RELTIME_TBL
WHERE (ABSTIME_TBL.f1 + RELTIME_TBL.f1) < abstime 'Jan 14 14:00:00 1971'
ORDER BY abstime, reltime;
@@ -263,19 +264,19 @@ SELECT '' AS ten, ABSTIME_TBL.f1 AS abstime, RELTIME_TBL.f1 AS reltime
-- the "infinity" and "-infinity" tuples in ABSTIME_TBL cannot be added and
-- therefore, should not show up in the results.
-SELECT '' AS three, ABSTIME_TBL.*
+SELECT '' AS three, * FROM ABSTIME_TBL
WHERE (ABSTIME_TBL.f1 + reltime '@ 3 year') -- +3 years
< abstime 'Jan 14 14:00:00 1977';
-SELECT '' AS three, ABSTIME_TBL.*
+SELECT '' AS three, * FROM ABSTIME_TBL
WHERE (ABSTIME_TBL.f1 + reltime '@ 3 year ago') -- -3 years
< abstime 'Jan 14 14:00:00 1971';
-SELECT '' AS three, ABSTIME_TBL.*
+SELECT '' AS three, * FROM ABSTIME_TBL
WHERE (ABSTIME_TBL.f1 - reltime '@ 3 year') -- -(+3) years
< abstime 'Jan 14 14:00:00 1971';
-SELECT '' AS three, ABSTIME_TBL.*
+SELECT '' AS three, * FROM ABSTIME_TBL
WHERE (ABSTIME_TBL.f1 - reltime '@ 3 year ago') -- -(-3) years
< abstime 'Jan 14 14:00:00 1977';
index 81bff55712043a04ca0ada992400f26d5d67f8ca..65c89e4abdd0b03dd0c8eb093bfbbac88d6cb095 100644 (file)
@@ -29,7 +29,7 @@ INSERT INTO INT2_TBL(f1) VALUES ('123 dt');
INSERT INTO INT2_TBL(f1) VALUES ('');
-SELECT '' AS five, INT2_TBL.*;
+SELECT '' AS five, * FROM INT2_TBL;
SELECT '' AS four, i.* FROM INT2_TBL i WHERE i.f1 <> int2 '0';
index b4c3929d09f112a1816c52e9d549694681c33ad7..5212c687952724d26a19a25717a8fc7f7c75a1d2 100644 (file)
@@ -29,7 +29,7 @@ INSERT INTO INT4_TBL(f1) VALUES ('123 5');
INSERT INTO INT4_TBL(f1) VALUES ('');
-SELECT '' AS five, INT4_TBL.*;
+SELECT '' AS five, * FROM INT4_TBL;
SELECT '' AS four, i.* FROM INT4_TBL i WHERE i.f1 <> int2 '0';
index b6a6eb20ef30b1986beb00bf60c29f944ab0c670..a05d818a330fbf5ad07705e0b8276088e74fad79 100644 (file)
@@ -32,24 +32,24 @@ INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 30 eons ago');
-- test interval operators
-SELECT '' AS ten, INTERVAL_TBL.*;
+SELECT '' AS ten, * FROM INTERVAL_TBL;
-SELECT '' AS nine, INTERVAL_TBL.*
+SELECT '' AS nine, * FROM INTERVAL_TBL
WHERE INTERVAL_TBL.f1 <> interval '@ 10 days';
-SELECT '' AS three, INTERVAL_TBL.*
+SELECT '' AS three, * FROM INTERVAL_TBL
WHERE INTERVAL_TBL.f1 <= interval '@ 5 hours';
-SELECT '' AS three, INTERVAL_TBL.*
+SELECT '' AS three, * FROM INTERVAL_TBL
WHERE INTERVAL_TBL.f1 < interval '@ 1 day';
-SELECT '' AS one, INTERVAL_TBL.*
+SELECT '' AS one, * FROM INTERVAL_TBL
WHERE INTERVAL_TBL.f1 = interval '@ 34 years';
-SELECT '' AS five, INTERVAL_TBL.*
+SELECT '' AS five, * FROM INTERVAL_TBL
WHERE INTERVAL_TBL.f1 >= interval '@ 1 month';
-SELECT '' AS nine, INTERVAL_TBL.*
+SELECT '' AS nine, * FROM INTERVAL_TBL
WHERE INTERVAL_TBL.f1 > interval '@ 3 seconds ago';
SELECT '' AS fortyfive, r1.*, r2.*
@@ -59,7 +59,7 @@ SELECT '' AS fortyfive, r1.*, r2.*
SET DATESTYLE = 'postgres';
-SELECT '' AS ten, INTERVAL_TBL.*;
+SELECT '' AS ten, * FROM INTERVAL_TBL;
-- test avg(interval), which is somewhat fragile since people have been
-- known to change the allowed input syntax for type interval without
index 9bda6f1d00249377bb888ab993d79041f7b7926a..ba48cad7fe6548b89483211632f78836bc2df7ed 100644 (file)
DROP TABLE J1_TBL;
DROP TABLE J2_TBL;
+
+-- Both DELETE and UPDATE allow the specification of additional tables
+-- to "join" against to determine which rows should be modified.
+
+CREATE TEMP TABLE t1 (a int, b int);
+CREATE TEMP TABLE t2 (a int, b int);
+CREATE TEMP TABLE t3 (x int, y int);
+
+INSERT INTO t1 VALUES (5, 10);
+INSERT INTO t1 VALUES (15, 20);
+INSERT INTO t1 VALUES (100, 100);
+INSERT INTO t1 VALUES (200, 1000);
+INSERT INTO t2 VALUES (200, 2000);
+INSERT INTO t3 VALUES (5, 20);
+INSERT INTO t3 VALUES (6, 7);
+INSERT INTO t3 VALUES (7, 8);
+INSERT INTO t3 VALUES (500, 100);
+
+DELETE FROM t3 USING t1 table1 WHERE t3.x = table1.a;
+SELECT * FROM t3;
+DELETE FROM t3 USING t1 JOIN t2 USING (a) WHERE t3.x > t1.a;
+SELECT * FROM t3;
+DELETE FROM t3 USING t3 t3_other WHERE t3.x = t3_other.x AND t3.y = t3_other.y;
+SELECT * FROM t3;
\ No newline at end of file
index 58fa0120fda2699d525606e8aba312c90776b819..1c7a6716eea935f1f21345ddac30b2c53b49cd95 100644 (file)
@@ -29,7 +29,7 @@ INSERT INTO NAME_TBL(f1) VALUES ('');
INSERT INTO NAME_TBL(f1) VALUES ('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ');
-SELECT '' AS seven, NAME_TBL.*;
+SELECT '' AS seven, * FROM NAME_TBL;
SELECT '' AS six, c.f1 FROM NAME_TBL c WHERE c.f1 <> '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
index e2357cd2e5610a35aa128a7eedcf3d0879b69c08..1bdb127a4ae86898869cadd808ed06ec277fbd30 100644 (file)
@@ -26,8 +26,7 @@ INSERT INTO OID_TBL(f1) VALUES (' - 500');
INSERT INTO OID_TBL(f1) VALUES ('32958209582039852935');
INSERT INTO OID_TBL(f1) VALUES ('-23582358720398502385');
-SELECT '' AS six, OID_TBL.*;
-
+SELECT '' AS six, * FROM OID_TBL;
SELECT '' AS one, o.* FROM OID_TBL o WHERE o.f1 = 1234;
index 6c6867c43253d73f1daef33c3b768b69642aa020..bc45f9f0d803155b7d2e24fea20ac6e221e1bc72 100644 (file)
@@ -24,7 +24,7 @@ INSERT INTO POINT_TBL(f1) VALUES ('(10.0 10.0)');
INSERT INTO POINT_TBL(f1) VALUES ('(10.0,10.0');
-SELECT '' AS six, POINT_TBL.*;
+SELECT '' AS six, * FROM POINT_TBL;
-- left of
SELECT '' AS three, p.* FROM POINT_TBL p WHERE p.f1 << '(0.0, 0.0)';
index 99d674e8d29dcd414176ca091065f2a28c2269c4..1e20f38175336742549c8e2fb44594c4fa4897c5 100644 (file)
@@ -38,7 +38,7 @@ INSERT INTO POLYGON_TBL(f1) VALUES ('(0,1,2,3');
INSERT INTO POLYGON_TBL(f1) VALUES ('asdf');
-SELECT '' AS four, POLYGON_TBL.*;
+SELECT '' AS four, * FROM POLYGON_TBL;
-- overlap
SELECT '' AS three, p.*
index d3e9b54303584afcb892e2f4e094f00a75181942..3e224c556a205f8a1acb5171b200743f7b10fb78 100644 (file)
@@ -78,7 +78,7 @@ INSERT INTO atest1 SELECT 1, b FROM atest1; -- fail
UPDATE atest1 SET a = 1 WHERE a = 2; -- fail
UPDATE atest2 SET col2 = NULL; -- ok
UPDATE atest2 SET col2 = NOT col2; -- fails; requires SELECT on atest2
-UPDATE atest2 SET col2 = true WHERE atest1.a = 5; -- ok
+UPDATE atest2 SET col2 = true FROM atest1 WHERE atest1.a = 5; -- ok
SELECT * FROM atest1 FOR UPDATE; -- fail
SELECT * FROM atest2 FOR UPDATE; -- fail
DELETE FROM atest2; -- fail
index 53295d3e66bdd31941f8502a143908937aa7f9cb..a07b64e29d876bffda91d0c5c10a639c679cbd6e 100644 (file)
@@ -24,28 +24,27 @@ INSERT INTO RELTIME_TBL (f1) VALUES ('@ 30 eons ago');
-- test reltime operators
-SELECT '' AS six, RELTIME_TBL.*;
+SELECT '' AS six, * FROM RELTIME_TBL;
-SELECT '' AS five, RELTIME_TBL.*
+SELECT '' AS five, * FROM RELTIME_TBL
WHERE RELTIME_TBL.f1 <> reltime '@ 10 days';
-SELECT '' AS three, RELTIME_TBL.*
+SELECT '' AS three, * FROM RELTIME_TBL
WHERE RELTIME_TBL.f1 <= reltime '@ 5 hours';
-SELECT '' AS three, RELTIME_TBL.*
+SELECT '' AS three, * FROM RELTIME_TBL
WHERE RELTIME_TBL.f1 < reltime '@ 1 day';
-SELECT '' AS one, RELTIME_TBL.*
+SELECT '' AS one, * FROM RELTIME_TBL
WHERE RELTIME_TBL.f1 = reltime '@ 34 years';
-SELECT '' AS two, RELTIME_TBL.*
+SELECT '' AS two, * FROM RELTIME_TBL
WHERE RELTIME_TBL.f1 >= reltime '@ 1 month';
-SELECT '' AS five, RELTIME_TBL.*
+SELECT '' AS five, * FROM RELTIME_TBL
WHERE RELTIME_TBL.f1 > reltime '@ 3 seconds ago';
SELECT '' AS fifteen, r1.*, r2.*
FROM RELTIME_TBL r1, RELTIME_TBL r2
WHERE r1.f1 > r2.f1
ORDER BY r1.f1, r2.f1;
-
index cd0ae43c3e61c09d91d99d902450c87684d6d2a4..ead8011a313dd058d337afe65bb8603f1a70ac54 100644 (file)
update rtest_v1 set b = 88 where b < 50;
select * from rtest_v1;
delete from rtest_v1;
-insert into rtest_v1 select rtest_t2.a, rtest_t3.b where rtest_t2.a = rtest_t3.a;
+insert into rtest_v1 select rtest_t2.a, rtest_t3.b
+ from rtest_t2, rtest_t3
+ where rtest_t2.a = rtest_t3.a;
select * from rtest_v1;
-- updates in a mergejoin
-update rtest_v1 set b = rtest_t2.b where a = rtest_t2.a;
+update rtest_v1 set b = rtest_t2.b from rtest_t2 where rtest_v1.a = rtest_t2.a;
select * from rtest_v1;
insert into rtest_v1 select * from rtest_t3;
select * from rtest_v1;
update rtest_t1 set a = a + 10 where b > 30;
select * from rtest_v1;
-update rtest_v1 set a = rtest_t3.a + 20 where b = rtest_t3.b;
+update rtest_v1 set a = rtest_t3.a + 20 from rtest_t3 where rtest_v1.b = rtest_t3.b;
select * from rtest_v1;
--
@@ -285,9 +287,9 @@ insert into rtest_empmass values ('mayr', '6000.00');
insert into rtest_emp select * from rtest_empmass;
select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal;
update rtest_empmass set salary = salary + '1000.00';
-update rtest_emp set salary = rtest_empmass.salary where ename = rtest_empmass.ename;
+update rtest_emp set salary = rtest_empmass.salary from rtest_empmass where rtest_emp.ename = rtest_empmass.ename;
select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal;
-delete from rtest_emp where ename = rtest_empmass.ename;
+delete from rtest_emp using rtest_empmass where rtest_emp.ename = rtest_empmass.ename;
select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal;
--
index ee9389dc59706c645735332123687c548bb01b74..02aac6c50687901e7197a044d503ec62b8fc1741 100644 (file)
-- btree index
-- awk '{if(1ドル<10){print;}else{next;}}' onek.data | sort +0n -1
--
-SELECT onek.* WHERE onek.unique1 < 10
+SELECT * FROM onek
+ WHERE onek.unique1 < 10
ORDER BY onek.unique1;
--
-- awk '{if(1ドル<20){print 1,ドル14ドル;}else{next;}}' onek.data | sort +0nr -1
--
-SELECT onek.unique1, onek.stringu1
+SELECT onek.unique1, onek.stringu1 FROM onek
WHERE onek.unique1 < 20
ORDER BY unique1 using >;
--
-- awk '{if(1ドル>980){print 1,ドル14ドル;}else{next;}}' onek.data | sort +1d -2
--
-SELECT onek.unique1, onek.stringu1
+SELECT onek.unique1, onek.stringu1 FROM onek
WHERE onek.unique1 > 980
ORDER BY stringu1 using <;
@@ -26,7 +27,7 @@ SELECT onek.unique1, onek.stringu1
-- awk '{if(1ドル>980){print 1,ドル16ドル;}else{next;}}' onek.data |
-- sort +1d -2 +0nr -1
--
-SELECT onek.unique1, onek.string4
+SELECT onek.unique1, onek.string4 FROM onek
WHERE onek.unique1 > 980
ORDER BY string4 using <, unique1 using >;
@@ -34,7 +35,7 @@ SELECT onek.unique1, onek.string4
-- awk '{if(1ドル>980){print 1,ドル16ドル;}else{next;}}' onek.data |
-- sort +1dr -2 +0n -1
--
-SELECT onek.unique1, onek.string4
+SELECT onek.unique1, onek.string4 FROM onek
WHERE onek.unique1 > 980
ORDER BY string4 using >, unique1 using <;
@@ -42,7 +43,7 @@ SELECT onek.unique1, onek.string4
-- awk '{if(1ドル<20){print 1,ドル16ドル;}else{next;}}' onek.data |
-- sort +0nr -1 +1d -2
--
-SELECT onek.unique1, onek.string4
+SELECT onek.unique1, onek.string4 FROM onek
WHERE onek.unique1 < 20
ORDER BY unique1 using >, string4 using <;
@@ -50,7 +51,7 @@ SELECT onek.unique1, onek.string4
-- awk '{if(1ドル<20){print 1,ドル16ドル;}else{next;}}' onek.data |
-- sort +0n -1 +1dr -2
--
-SELECT onek.unique1, onek.string4
+SELECT onek.unique1, onek.string4 FROM onek
WHERE onek.unique1 < 20
ORDER BY unique1 using <, string4 using >;
--
-- awk '{if(1ドル<10){print 0ドル;}else{next;}}' onek.data | sort +0n -1
--
-SELECT onek2.* WHERE onek2.unique1 < 10;
+SELECT onek2.* FROM onek2 WHERE onek2.unique1 < 10;
--
-- awk '{if(1ドル<20){print 1,ドル14ドル;}else{next;}}' onek.data | sort +0nr -1
--
-SELECT onek2.unique1, onek2.stringu1
+SELECT onek2.unique1, onek2.stringu1 FROM onek2
WHERE onek2.unique1 < 20
ORDER BY unique1 using >;
--
-- awk '{if(1ドル>980){print 1,ドル14ドル;}else{next;}}' onek.data | sort +1d -2
--
-SELECT onek2.unique1, onek2.stringu1
+SELECT onek2.unique1, onek2.stringu1 FROM onek2
WHERE onek2.unique1 > 980;
index dabf504e0c283b677cccf9cda53a4f559ea0b4f8..82d61dda3e826367f42c6b272ad763072839611b 100644 (file)
-- test tinterval operators
-SELECT '' AS five, TINTERVAL_TBL.*;
+SELECT '' AS five, * FROM TINTERVAL_TBL;
-- length ==
SELECT '' AS one, t.*
index 6aebfcc867e6770a8d4441ef48c1a9e5295bd959..247d6facb8ea842b96324ac0e4b3a983321ecd7e 100644 (file)
INSERT INTO writetest VALUES (1); -- fail
SELECT * FROM writetest; -- ok
DELETE FROM temptest; -- ok
-UPDATE temptest SET a = 0 WHERE a = 1 AND writetest.a = temptest.a; -- ok
+UPDATE temptest SET a = 0 FROM writetest WHERE temptest.a = 1 AND writetest.a = temptest.a; -- ok
PREPARE test AS UPDATE writetest SET a = 0; -- ok
EXECUTE test; -- fail
SELECT * FROM writetest, temptest; -- ok
index 70fa8afb4b3754bc06240f419f67363a9ec56f4b..414c585d9a305bf59e2d7806c8a5e7175bf35965 100644 (file)
@@ -23,7 +23,7 @@ INSERT INTO VARCHAR_TBL (f1) VALUES ('cd');
INSERT INTO VARCHAR_TBL (f1) VALUES ('c ');
-SELECT '' AS seven, VARCHAR_TBL.*;
+SELECT '' AS seven, * FROM VARCHAR_TBL;
SELECT '' AS six, c.*
FROM VARCHAR_TBL c
@@ -63,4 +63,4 @@ INSERT INTO VARCHAR_TBL (f1) VALUES ('abcd');
INSERT INTO VARCHAR_TBL (f1) VALUES ('abcde');
INSERT INTO VARCHAR_TBL (f1) VALUES ('abcd ');
-SELECT '' AS four, VARCHAR_TBL.*;
+SELECT '' AS four, * FROM VARCHAR_TBL;