Skip to content

Conversation

MrEasy
Copy link
Contributor

@MrEasy MrEasy commented Aug 29, 2024

Test case reproducing issue of #3365.
Fix by @kimjand

@MrEasy MrEasy changed the title #3365 Added testcase for PS#toString #3365 Fix and testcase for PS#toString Nov 18, 2024
Copy link
Member

@vlsi vlsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you keep the old method names and signatures?

@MrEasy
Copy link
Contributor Author

MrEasy commented Dec 9, 2024

Could you keep the old method names and signatures?

@kimjand added a method, that differs from existing one (see javadoc), not sure what you @vlsi mean with keeping the old names?

@davecramer
Copy link
Member

Could you keep the old method names and signatures?

@kimjand added a method, that differs from existing one (see javadoc), not sure what you @vlsi mean with keeping the old names?

Instead of using toStringLiteral() use toString()

@MrEasy
Copy link
Contributor Author

MrEasy commented Mar 20, 2025

Could you keep the old method names and signatures?

@kimjand added a method, that differs from existing one (see javadoc), not sure what you @vlsi mean with keeping the old names?

Instead of using toStringLiteral() use toString()

From javadoc, I'd assume this was on purpose. @kimjand could you comment on this?

Would be great if we can get the fix into next release, as this blocks our update to recent versions.

@kimjand
Copy link
Contributor

kimjand commented Mar 20, 2025 via email

@vlsi vlsi changed the title #3365 Fix and testcase for PS#toString fix: EOFException on PreparedStatement#toString with unset bytea parameter since 42.7.4 Apr 19, 2025
Copy link
Contributor

@ecki ecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me the change looks good (I would probably refactor all usages of tostring() as it’s confusing to me to have it carry transactional important and stateful logic but this way I guess it’s less overall change)

@vlsi
Copy link
Member

vlsi commented Apr 24, 2025

I'm working on this. Please let me have a couple of days more

@vlsi
Copy link
Member

vlsi commented May 15, 2025

Looks like for toString we need the following:

@Nullable ParameterList params; // optional
boolean standardConformingStrings;
boolean idempotent; // == skipInputStreams

I wonder if we use an interface for it instead of (boolean, boolean) parameters?

Currently we have

String toString(@Nullable ParameterList params, boolean standardConformingStrings);
String toExecutable(@Nullable ParameterList params, boolean standardConformingStrings);

What if we go for the following?

interface SqlContext {
  boolean getStandardConformingStrings();
  boolean getIdempotent();
}

@Deprecated
String toString(@Nullable ParameterList params, boolean standardConformingStrings);

String toString(@Nullable ParameterList params, SqlContext context);

@vlsi
Copy link
Member

vlsi commented May 16, 2025

I'm happy with the current state of the PR.
Reviews are welcome.
Will merge the PR in a couple of days.

@vlsi vlsi added the bug label May 16, 2025
* Returns string representation of the query, substituting particular parameter values for
* parameter placeholders.
*
* <p>Note: the method will replace all the parameters, so it should not be used only once
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it should not be used only once seems wrong ... did you mean so it should only be used once ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. The doc was outdated as the behaviour is configurable via SqlSerializationContext parameter. I will drop the note and add @param context specifies configuration for converting the parameters to string

@davecramer
Copy link
Member

LGTM

…meter since 42.7.4

Previously, PgPreparedStatement#toString() could consume InputStream parameters,
so it caused exceptions when executing the query later.

Fixes #3365

Co-authored-by: Kim Johan Andersson <31474178+kimjand@users.noreply.github.com>
@vlsi vlsi merged commit 0a88ea4 into pgjdbc:master May 21, 2025
1 of 2 checks passed
@MrEasy MrEasy deleted the pgjdbc-3365 branch May 21, 2025 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants