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

Parse bpchar to ShortString? #207

Open
oxinabox opened this issue Nov 3, 2020 · 3 comments
Open

Parse bpchar to ShortString? #207

oxinabox opened this issue Nov 3, 2020 · 3 comments

Comments

@oxinabox
Copy link

oxinabox commented Nov 3, 2020

just a random thought.
Since bpchar i.e. char(n) is fixed length, it is probably going to be short.
And then we could use https://github.com/xiaodaigh/ShortStrings.jl/
Though that doesn't yet have strip implemented on it, would be easy to do and would run fast though.

@iamed2
Copy link
Owner

iamed2 commented Nov 3, 2020

It's probably going to be short, but what if it isn't?

We can use libpq_c.PQfmod to get the max length of a bpchar column (plus 4 because reasons), and only use ShortStrings when appropriate, but that requires adding some more complicated code or a special case to this code.

We should also rework the parsing code to make it easier to parse bpchar as any string type, not just String (just doing this would let people specify they want ShortStrings for each bpchar column without making it the default or introducing a dependency).

@oxinabox
Copy link
Author

oxinabox commented Nov 3, 2020

I am not sure pragmatically how useful this is,
since does anyone use char(n)/bpchar with postgres, given varchar is apparently just as fast?

@iamed2
Copy link
Owner

iamed2 commented Nov 3, 2020

Probably in legacy or migrated systems.

There are also databases that can communicate with libpq that aren't PostgreSQL, like Redshift.

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

No branches or pull requests

2 participants