diff --git a/jOOQ/src/main/java/org/jooq/XMLExistsPassingStep.java b/jOOQ/src/main/java/org/jooq/XMLExistsPassingStep.java
new file mode 100644
index 0000000000..8d471534e8
--- /dev/null
+++ b/jOOQ/src/main/java/org/jooq/XMLExistsPassingStep.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Other licenses:
+ * -----------------------------------------------------------------------------
+ * Commercial licenses for this work are available. These replace the above
+ * ASL 2.0 and offer limited warranties, support, maintenance, and commercial
+ * database integrations.
+ *
+ * For more information, please visit: http://www.jooq.org/licenses
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+package org.jooq;
+
+import static org.jooq.SQLDialect.POSTGRES;
+
+/**
+ * A step in the construction of an XMLEXISTS predicate.
+ *
+ * @author Lukas Eder
+ */
+public interface XMLExistsPassingStep {
+
+ /**
+ * Add the PASSING clause to the XMLEXISTS
+ * predicate.
+ */
+ @Support({ POSTGRES })
+ Condition passing(XML xml);
+
+ /**
+ * Add the PASSING clause to the XMLEXISTS
+ * predicate.
+ */
+ @Support({ POSTGRES })
+ Condition passing(Field xml);
+
+ /**
+ * Add the PASSING BY REF clause to the XMLEXISTS
+ * predicate.
+ */
+ @Support({ POSTGRES })
+ Condition passingByRef(XML xml);
+
+ /**
+ * Add the PASSING BY REF clause to the XMLEXISTS
+ * predicate.
+ */
+ @Support({ POSTGRES })
+ Condition passingByRef(Field xml);
+
+ /**
+ * Add the PASSING BY VALUE clause to the XMLEXISTS
+ * predicate.
+ */
+ @Support({ POSTGRES })
+ Condition passingByValue(XML xml);
+
+ /**
+ * Add the PASSING BY VALUE clause to the XMLEXISTS
+ * predicate.
+ */
+ @Support({ POSTGRES })
+ Condition passingByValue(Field xml);
+
+}
diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java
index 0fe51477e5..ad3e5f62fd 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DSL.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java
@@ -391,6 +391,7 @@ import org.jooq.WithAsStep9;
import org.jooq.WithStep;
import org.jooq.XML;
import org.jooq.XMLAttributes;
+import org.jooq.XMLExistsPassingStep;
import org.jooq.conf.Settings;
import org.jooq.exception.SQLDialectNotSupportedException;
import org.jooq.tools.Convert;
@@ -18262,6 +18263,22 @@ public class DSL {
return new XMLAgg(field);
}
+ /**
+ * The XML exists function.
+ */
+ @Support({ POSTGRES })
+ public static XMLExistsPassingStep xmlexists(String xpath) {
+ return xmlexists(Tools.field(xpath));
+ }
+
+ /**
+ * The XML exists function.
+ */
+ @Support({ POSTGRES })
+ public static XMLExistsPassingStep xmlexists(Field xpath) {
+ return new XMLExists(xpath);
+ }
+
// -------------------------------------------------------------------------
// XXX JSON functions
// -------------------------------------------------------------------------
diff --git a/jOOQ/src/main/java/org/jooq/impl/Keywords.java b/jOOQ/src/main/java/org/jooq/impl/Keywords.java
index 347552ca24..e2c25f5f74 100644
--- a/jOOQ/src/main/java/org/jooq/impl/Keywords.java
+++ b/jOOQ/src/main/java/org/jooq/impl/Keywords.java
@@ -293,6 +293,7 @@ final class Keywords {
static final Keyword K_RAISERROR = keyword("raiserror");
static final Keyword K_RECORD = keyword("record");
static final Keyword K_RECURSIVE = keyword("recursive");
+ static final Keyword K_REF = keyword("ref");
static final Keyword K_REFERENCES = keyword("references");
static final Keyword K_REGEXP = keyword("regexp");
static final Keyword K_RENAME = keyword("rename");
@@ -394,6 +395,7 @@ final class Keywords {
static final Keyword K_WITHIN_GROUP = keyword("within group");
static final Keyword K_WITHOUT_ARRAY_WRAPPER = keyword("without_array_wrapper");
static final Keyword K_XML = keyword("xml");
+ static final Keyword K_XMLEXISTS = keyword("xmlexists");
static final Keyword K_XMLTABLE = keyword("xmltable");
static final Keyword K_YEAR = keyword("year");
static final Keyword K_YEAR_MONTH = keyword("year_month");
diff --git a/jOOQ/src/main/java/org/jooq/impl/XMLExists.java b/jOOQ/src/main/java/org/jooq/impl/XMLExists.java
new file mode 100644
index 0000000000..1994cb5482
--- /dev/null
+++ b/jOOQ/src/main/java/org/jooq/impl/XMLExists.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Other licenses:
+ * -----------------------------------------------------------------------------
+ * Commercial licenses for this work are available. These replace the above
+ * ASL 2.0 and offer limited warranties, support, maintenance, and commercial
+ * database integrations.
+ *
+ * For more information, please visit: http://www.jooq.org/licenses
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+package org.jooq.impl;
+
+import static org.jooq.impl.Keywords.K_BY;
+import static org.jooq.impl.Keywords.K_PASSING;
+import static org.jooq.impl.Keywords.K_REF;
+import static org.jooq.impl.Keywords.K_VALUE;
+import static org.jooq.impl.Keywords.K_XMLEXISTS;
+import static org.jooq.impl.XMLExists.PassingMechanism.BY_REF;
+import static org.jooq.impl.XMLExists.PassingMechanism.BY_VALUE;
+
+import org.jooq.Condition;
+import org.jooq.Context;
+import org.jooq.Field;
+import org.jooq.XML;
+import org.jooq.XMLExistsPassingStep;
+
+/**
+ * @author Lukas Eder
+ */
+final class XMLExists extends AbstractCondition implements XMLExistsPassingStep {
+
+ /**
+ * Generated UID
+ */
+ private static final long serialVersionUID = -4881363881968319258L;
+ private final Field xpath;
+ private final Field passing;
+ private final PassingMechanism passingMechanism;
+
+ XMLExists(Field xpath) {
+ this(xpath, null, null);
+ }
+
+ private XMLExists(Field xpath, Field passing, PassingMechanism passingMechanism) {
+ this.xpath = xpath;
+ this.passing = passing;
+ this.passingMechanism = passingMechanism;
+ }
+
+ // -------------------------------------------------------------------------
+ // XXX: DSL API
+ // -------------------------------------------------------------------------
+ @Override
+ public final Condition passing(XML xml) {
+ return passing(Tools.field(xml));
+ }
+
+ @Override
+ public final Condition passing(Field xml) {
+ return new XMLExists(xpath, xml, null);
+ }
+
+ @Override
+ public final Condition passingByRef(XML xml) {
+ return passingByRef(Tools.field(xml));
+ }
+
+ @Override
+ public final Condition passingByRef(Field xml) {
+ return new XMLExists(xpath, xml, BY_REF);
+ }
+
+ @Override
+ public final Condition passingByValue(XML xml) {
+ return passingByRef(Tools.field(xml));
+ }
+
+ @Override
+ public final Condition passingByValue(Field xml) {
+ return new XMLExists(xpath, xml, BY_VALUE);
+ }
+
+ enum PassingMechanism { BY_REF, BY_VALUE }
+
+ // -------------------------------------------------------------------------
+ // XXX: QueryPart API
+ // -------------------------------------------------------------------------
+
+ @Override
+ public final void accept(Context> ctx) {
+ ctx.visit(K_XMLEXISTS).sql('(')
+ .formatIndentStart()
+ .formatNewLine()
+ .visit(xpath)
+ .formatSeparator()
+ .visit(K_PASSING);
+
+ if (passingMechanism == BY_REF)
+ ctx.sql(' ').visit(K_BY).sql(' ').visit(K_REF);
+ else if (passingMechanism == BY_VALUE)
+ ctx.sql(' ').visit(K_BY).sql(' ').visit(K_VALUE);
+
+ ctx.sql(' ').visit(passing)
+ .formatIndentEnd()
+ .formatNewLine()
+ .sql(')');
+ }
+}