Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use proper error code for input errors #50

Merged
merged 1 commit into from
Aug 20, 2024

Conversation

hlinnaka
Copy link
Contributor

Before this commit, the error was reported with ERRCODE_INTERNAL_ERROR (SQLSTATE XX000):

postgres=# \set VERBOSITY verbose
postgres=# select 'foo'::ulid;
ERROR:  XX000: invalid input syntax for type ulid: "foo": invalid length
LINE 1: select 'foo'::ulid;
               ^
LOCATION:  lib.rs:37

With this, ERRCODE_INVALID_TEXT_REPRESENTATION (SQLSTATE 22P02) is used:

postgres=# \set VERBOSITY verbose
postgres=# select 'foo'::ulid;
ERROR:  22P02: invalid input syntax for type ulid: "foo": invalid length
LINE 1: select 'foo'::ulid;
               ^
LOCATION:  <ulid::ulid as pgrx::inoutfuncs::InOutFuncs>::input, lib.rs:39

Before this commit, the error was reported with ERRCODE_INTERNAL_ERROR
(SQLSTATE XX000):

```
postgres=# \set VERBOSITY verbose
postgres=# select 'foo'::ulid;
ERROR:  XX000: invalid input syntax for type ulid: "foo": invalid length
LINE 1: select 'foo'::ulid;
               ^
LOCATION:  lib.rs:37
```

With this, ERRCODE_INVALID_TEXT_REPRESENTATION (SQLSTATE 22P02) is used:

```
postgres=# \set VERBOSITY verbose
postgres=# select 'foo'::ulid;
ERROR:  22P02: invalid input syntax for type ulid: "foo": invalid length
LINE 1: select 'foo'::ulid;
               ^
LOCATION:  <ulid::ulid as pgrx::inoutfuncs::InOutFuncs>::input, lib.rs:39
```
@pksunkara pksunkara merged commit d05494e into pksunkara:master Aug 20, 2024
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants