From 8dfc3fa3d39ae4bd8a068aca3334ed3d47005cf1 Mon Sep 17 00:00:00 2001 From: Michael P Date: Thu, 27 Jan 2011 15:40:34 +0900 Subject: Fix for bug 3147497 INSERT.. DEFAULT VALUES This fix is linked to tables having no default values defined. When doing an INSERT.. DEFAULT VALUES, XC was returning an error at planner level when deparsing the query. create table aa(a int); INSERT INTO aa DEFAULT VALUES ; XC result: ERROR: syntax error at or near ")" pg_regress results: INSERT 0 1 In this fix, when an INSERT using DEFAULT VALUES is made, query is directly returned. Patch written by sch19831106 with some editorialization by me. --- src/backend/utils/adt/ruleutils.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 84b1de5dd4..59c818a803 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -55,7 +55,9 @@ #include "utils/syscache.h" #include "utils/typcache.h" #include "utils/xml.h" - +#ifdef PGXC +#include "pgxc/pgxc.h" +#endif /* ---------- * Pretty formatting constants @@ -3221,6 +3223,18 @@ get_insert_query_def(Query *query, deparse_context *context) ListCell *l; List *strippedexprs; +#ifdef PGXC + /* + * In the case of "INSERT ... DEFAULT VALUES" analyzed in pgxc planner, + * return the sql statement directly if the table has no default values. + */ + if (IS_PGXC_COORDINATOR && !IsConnFromCoord() && !query->targetList) + { + appendStringInfo(buf, "%s", query->sql_statement); + return; + } +#endif + /* * If it's an INSERT ... SELECT or VALUES (...), (...), ... there will be * a single RTE for the SELECT or VALUES. -- cgit v1.2.3