Comments (4)
My solution to this so far is to use two functions to hex encode the data in a varchar prior to inserting it and decode it when retrieving it. Which really rather defeats the purpose of packing the information in a uint64 in the first place, doesn't it? Any better solution I'm missing?
from pq.
Unfortunately uint64s are not supported by Postgres. Actually, no unsigned quantities are, unless you count the system type oid
which is a uint32 if memory serves...I don't recommend relying on that, though. You can use a numeric
, but that'll be slower. Another option is bytea, but I think the underlying varlena
will introduce a lot of overhead also.
The nuclear option is to write an extension that supports unsigned integers for Postgres in C, and install it...then perhaps teach pq
to understand how to deal with encodings for user defined types, which has issues similar to #49. I'm surprised such a 'unsigned integer extension' doesn't show up quickly via web search. Someone last had a go in 2008 it seems.
A workaround would be to use the 'uuid' type, which is double-wide at 128, but you can choose to just use the low bits or something. In spite of their rendition on the wire, they are stored as fixed-precision 128-bit quantities. This is still slower than a real 64-bit integer, but faster than numeric
in all likelihood.
from pq.
(Seeing as how this is not a pq
-solvable issue, putting aside user-defined-data-types and encodings, closing)
from pq.
Awesome, thanks for the ideas. Appreciate it.
from pq.
Related Issues (20)
- lib/pq incorrectly escapes input strings that are already escaped
- v1.10.8 break if .pgpass contains empty line HOT 1
- v1.10.8 got undefined: driver.Validator HOT 2
- Potential leak in notify.go HOT 1
- Unable to parse arrays that are not 1-based
- Array types can't convert {NULL} HOT 2
- Does pg not support integer type?
- converting NULL to string is unsupported
- [docs] Add example of multiple parallel listeners HOT 1
- Tx.Rollback returns ErrBadConn after context is cancelled
- Connection string parsing fails randomly HOT 2
- 1 Listener for 2 channel HOT 1
- SonarCloud Vulnerability: Make sure this PostgreSQL database password gets changed and removed from the code.
- Usage of COPY TO STDOUT WITH CSV
- RFC 9266: Channel Bindings for TLS 1.3 support
- Query extra_float_digits problem
- Is Postgres15.4 is compatible with the lib/pq package?
- What kind of mistake is this?
- how to deal with "cached plan must not change result type" error?
- Looking for a security contact to disclose a vulnerability HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pq.