Skip to content

Datum #2

New issue

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

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

Already on GitHub? # to your account

Open
thehydroimpulse opened this issue Oct 18, 2014 · 1 comment
Open

Datum #2

thehydroimpulse opened this issue Oct 18, 2014 · 1 comment

Comments

@thehydroimpulse
Copy link
Owner

Need to figure out a good story here. A datum is simply a pointer stored as a uint. Then casted to an appropriate type (in C). Text, for example, is allocated onto the heap using the custom pg_malloc allocator that allocates memory in contexts (regions). This enables it to easily clean up after a misbehaving extension, for example, in one whole swoop, instead of keeping track of a bunch of independent allocations that could never be freed.

Ideally, one could simply do:

Datum::new("foobar");
Datum::new(5i);
Datum::new(true);

Postgres has the concept of:

  • Pass by-value using a fixed length.
  • Pass by-reference using a fixed length.
  • Pass by-reference using a variable length.
@timClicks
Copy link

Looking through the source, I noticed that Datum.val defaults to 0. Should this be updated to make use of the new non-zero numeric types?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants