Skip to content

Conversation

@DAlperin
Copy link
Member

@DAlperin DAlperin commented Feb 4, 2026

Motivation

  • Ensure strpos follows PostgreSQL argument order (string, substring) instead of the reversed order used previously.
  • Provide a dedicated implementation and dispatch path so strpos behaves consistently with position.
  • Add sqllogictest coverage to prevent regressions in argument order and behavior.

Description

  • Add a Strpos variant to the BinaryFunc enum and wire it into the binary function dispatch and related trait methods (eval, output_type, propagates_nulls, introduces_nulls, is_infix_op, negate, could_error, is_monotone, and fmt).
  • Implement a new Rust SQL function strpos(string: &str, substring: &str) that delegates to the existing position implementation with the arguments swapped (position(substring, string)).
  • Route the SQL builtin strpos to BinaryFunc::from(func::Strpos) in PG_CATALOG_BUILTINS and add sqllogictest entries in test/sqllogictest/string.slt covering strpos behavior and examples.

Testing

  • Added sqllogictest cases in test/sqllogictest/string.slt exercising SELECT strpos(strcol2, strcol1) and SELECT strpos('high', 'ig'), but no automated test suite was executed in this change.
  • No additional automated tests were run; the new sqllogictest entries provide coverage to be executed by the existing test runner.
  • Local compile or runtime tests were not performed as part of this change.

Codex Task

@DAlperin DAlperin requested review from a team as code owners February 4, 2026 22:45
@DAlperin DAlperin requested a review from mtabebe February 4, 2026 22:45
@petrosagg
Copy link
Contributor

instead of the reversed order used previously.

I don't see any modified code in the PR, where was the strpos implementation that was used previously?

Copy link
Member

@antiguru antiguru left a comment

Choose a reason for hiding this comment

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

Looks good, but please rewrite the PR title/description :)

}
}

#[sqlfunc(propagates_nulls = true)]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#[sqlfunc(propagates_nulls = true)]
#[sqlfunc]

propagates_nulls is implied from arguments that cannot represent NULL.

}
}

#[sqlfunc(propagates_nulls = true)]
Copy link
Member

Choose a reason for hiding this comment

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

Please add a doc comment to the function (not used right now, but I hope it'll be eventually.

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.

3 participants