Skip to content

[Bug] The plan generated by ORCA misses resorigtbl in TargetEntry when filter is false #1072

@fanfuxiaoran

Description

@fanfuxiaoran

Apache Cloudberry version

cloudberry: Latest
jdbc--42.7.5

What happened

import java.sql.*;

public class JdbcTest {
    public static void main(String[] args) {
        /* create table tab_jdbc_metadata (a numeric(38,4) not null, b int not null); */

        try (Connection connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/gpadmin", "gpadmin", "gpadmin")) {

            System.out.println("Connected to PostgreSQL database!");

            Statement statement = connection.createStatement();
            ResultSet resultSet = statement.executeQuery("SELECT * FROM tab_jdbc_metadata WHERE 1=0");

            ResultSetMetaData metaData = resultSet.getMetaData();
            int ncolumns = metaData.getColumnCount();
            for (int i = 1; i <= ncolumns; i++) {
                System.out.println("Column name: " + metaData.getColumnName(i) +
                        ", Precision: " +metaData.getPrecision(i) +
                        ", Scale: " + metaData.getScale(i) +
                        ", Nullable: " + metaData.isNullable(i));
            }
        } catch (Exception e) {
            System.out.println("Connection failure.");
            e.printStackTrace();
        }
    }
}

expected result is :

Column name: a, Precision: 38, Scale: 4, Nullable: 0
Column name: b, Precision: 10, Scale: 0, Nullable: 0

but result is in cloudberry is :

Column name: a, Precision: 38, Scale: 4, Nullable: 2
Column name: b, Precision: 10, Scale: 0, Nullable: 2


### What you think should happen instead

_No response_

### How to reproduce

see above

### Operating System

centos7/macos

### Anything else

_No response_

### Are you willing to submit PR?

- [ ] Yes, I am willing to submit a PR!

### Code of Conduct

- [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/cloudberry/blob/main/CODE_OF_CONDUCT.md).

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: BugSomething isn't workingtype: Orcaonly orca has the issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions