Skip to content

[BUG] RDS Data (PostgreSQL): literal ? in SQL is treated as a JDBC bind placeholder, breaking jsonb ?, ?| and ?& operators #7619

Closed

Description

@udantha

Service

RDS Data API (PostgreSQL / aurora-postgresql cluster)

AWS API Action

ExecuteStatement

Expected behavior

The SQL runs as written. On real Aurora PostgreSQL, the Data API runs statements that use the PostgreSQL jsonb operators ?, ?| and ?&, for example:

SELECT jsonb_build_object('a', 1) ?| CAST(:keys AS text[]) AS hit

returns [[{"booleanValue": true}]] for keys = "{a,b}".

Actual behavior

Any statement that contains a literal ? fails, even when it has no :name parameters at all:

SQL Result
SELECT jsonb_build_object('a', 1) ?| CAST(:keys AS text[]) (keys = {a,b}) DatabaseErrorException: No value specified for parameter 2.
SELECT jsonb_build_object('a', 1) ?| ARRAY['a'] DatabaseErrorException: No value specified for parameter 1.
SELECT jsonb_build_object('a', 1) ? 'a' DatabaseErrorException: No value specified for parameter 1.
SELECT jsonb_build_object('a', 1) ??| CAST(:keys AS text[]) [[{"booleanValue": true}]] (JDBC escape works)

The cause appears to be in SqlParameterParser.parse: it rewrites :name to JDBC ? placeholders but copies literal ? characters (outside string literals, comments and quoted identifiers) through unchanged. The PostgreSQL JDBC driver then counts each of those as one more bind placeholder. Since the Data API itself has no positional placeholders, a literal ? in the incoming SQL can only be an operator. Escaping it as ?? while building the positional SQL (Postgres engines only; ?? is pgjdbc's escape for a literal ?) would match real Aurora.

Reproduction

With an aurora-postgresql cluster created with EnableHttpEndpoint=True and a credentials secret:

aws --endpoint-url http://localhost:4566 rds-data execute-statement \
  --resource-arn "$CLUSTER_ARN" --secret-arn "$SECRET_ARN" --database "$DB_NAME" \
  --sql "SELECT jsonb_build_object('a', 1) ? 'a' AS hit"
# An error occurred (DatabaseErrorException) when calling the ExecuteStatement operation: No value specified for parameter 1.

Our current workaround is a test-harness shim that rewrites ? to ?? in outgoing SQL before calling the Data API.

Environment

  • Floci version / image tag: floci/floci:2.1.0 (checked SqlParameterParser.java on main; it looks the same)
  • Client: boto3 rds-data client (Python), via the aurora-data-api / sqlalchemy-aurora-data-api driver; also reproducible with the raw boto3 client
  • How you're running Floci: Docker (docker compose, Docker socket mounted for the RDS Postgres container)

Activity

  1. github-actions commented on Nov 5, 2026

    @github-actions

    👋 Thanks for opening your first issue in Floci!

    A maintainer will triage this and add the right service label. If you included a minimal reproduction and the Floci version, that is everything we need — no action required from you right now.

    Come say hi in Slack if you want to talk it through with maintainers and other contributors. Questions about AWS behaviour, design tradeoffs, and rough proposals are all welcome there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingrds-dataAmazon RDS Data API

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions