Skip to content

A_Const parse output not ideal #265

@aleclarson

Description

@aleclarson

See here the following A_Const node output: (all cases adhere to this pattern)

{"A_Const":{"ival":{"ival":1},"location":7}}

Ideal output

I believe a more ideal output would be something like:

{"A_Const":{"val":{"Integer":{"ival":1}},"location":7}}

This would match the protobuf definition, I think?

message A_Const
{
oneof val {
Integer ival = 1;
Float fval = 2;
Boolean boolval = 3;
String sval = 4;
BitString bsval = 5;
}
bool isnull = 10;
int32 location = 11;
}

Note that this appears to have been the output back in April 2021, as evidenced by this issue. I haven't tried to pinpoint where/when this behavior changed.

Root cause

I'm not familiar with the codebase, but this appears to be where the problem occurs:

PgQuery__Integer *value = palloc(sizeof(PgQuery__Integer));
pg_query__integer__init(value);
value->ival = node->val.ival.ival;
out->val_case = PG_QUERY__A__CONST__VAL_IVAL;
out->ival = value;
break;

Note that it's not just a problem with integers, but with all value types supported by A_Const.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions