Skip to content

Wrong result when using POSITION() function with only bind values from JDBC #10695

@lukaseder

Description

@lukaseder

What happens?

When using the POSITION() function with only bind value arguments, the result is wrong

To Reproduce

import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.duckdb.DuckDBConnection;


DuckDBConnection connection = (DuckDBConnection) DriverManager.getConnection("jdbc:duckdb:");
try (PreparedStatement s = connection.prepareStatement("""
    select
        position(? in ?),
        position(? in 'abc'),
        position('b' in ?),
        position('b' in 'abc')
    """)) {
    s.setString(1, "b");
    s.setString(2, "abc");
    s.setString(3, "b");
    s.setString(4, "abc");

    try (ResultSet rs = s.executeQuery()) {
        while (rs.next()) {
            System.out.println(rs.getInt(1));
            System.out.println(rs.getInt(2));
            System.out.println(rs.getInt(3));
            System.out.println(rs.getInt(4));
        }
    }
}

This prints:

0
2
2
2

But it should print:

2
2
2
2

OS:

Microsoft Windows [Version 10.0.22631.3007]

DuckDB Version:

0.10.0

DuckDB Client:

jdbc

Full Name:

Lukas Eder

Affiliation:

Data Geekery

Have you tried this on the latest nightly build?

I have tested with a nightly build

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions