aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2005-04-07 01:51:41 +0000
committerNeil Conway <neilc@samurai.com>2005-04-07 01:51:41 +0000
commitf5ab0a14ea83eb6c27196b0c5d600b7f8b8b75fc (patch)
tree3a40f9e70af0338c3dd1210b859f1a7445a40e6c /src/backend/utils/adt/ruleutils.c
parentbe2f825d51176bd21a627a529476f94de5bad4c2 (diff)
downloadpostgresql-f5ab0a14ea83eb6c27196b0c5d600b7f8b8b75fc.tar.gz
postgresql-f5ab0a14ea83eb6c27196b0c5d600b7f8b8b75fc.zip
Add a "USING" clause to DELETE, which is equivalent to the FROM clause
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.
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 2f8e86e4b06..a6e5699357c 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -3,7 +3,7 @@
* 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;
}