-
-
Notifications
You must be signed in to change notification settings - Fork 256
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
fix: Mark several functions as unsafe. #217
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ointers being passed in
eeeebbbbrrrr
changed the title
fix: Mark several functionbs as unsafe.
fix: Mark several functions as unsafe.
Sep 24, 2021
Merged
Hoverbear
added a commit
that referenced
this pull request
Sep 25, 2021
* wip: Update binary generator Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: improvements from Sage Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: slightly cursed generator placement Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: better messages on generator checker Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: sort inventory to achieve stable graph Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: add example of desired macro Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: get partial extension sql dependencies working Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: cargo-fmt Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: add missing files Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: add control file for example Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: correct some linkage Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: format Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: better bootstrap/finalize support Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: bootstrap above schemas Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: cleanup type registration Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: improve structure some Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: cleanup tests Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: improve dot and verbose on cargo pgx schema Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: support trace Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: fix return arrow direction Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: fix dot default Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: better errors on unknown types Signed-off-by: Ana Hobden <operator@hoverbear.org> * Don't look up the type oid for types that never use it Getting function argument type oids can be surprisingly expensive; one Promscale benchmark measures it as taking over 10% of runtime. Fortunately, most types do not actually make use of this information, and the `getarg_type()` call can be optimized out if this fact is known. This commit adds an opt-in method for declaring that a type does not make use of the `typeoid` in `from_datum()`, and updates `pg_getarg()` to make use of this information. This commit makes the following changes: 1. It adds a `const` boolean to `FromDatum` called `NEEDS_TYPID`. This boolean is defaulted to `true`. Types that never use the `typeoid` parameter to `from_datum()` can override this to `false`. 2. `pg_getarg()` updated to look at `T::NEEDS_TYPID` before calling `get_getarg_type()`. If `T::NEEDS_TYPID == true` it calls `get_getarg_type()` like it currently does for all types; if it is `false` it instead passes `InvalidOid` as the (unused) `typeoid` argument to `from_datum()`. 3. It edits a number of built in types to make use of this optimization. Since this feature is both opt-in and backwards compatible, it should not break any downstream users. * wip: handle inner impl trait on box and option Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: Support PgBox Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: resolve some lifetime issues with fn args Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: resolve schema and name aliasing issues Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: uncomment test Signed-off-by: Ana Hobden <operator@hoverbear.org> * fmt Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: Support variadic Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: schema resolution a bit more strict Signed-off-by: Ana Hobden <operator@hoverbear.org> * Don't run all tests in cargo pgx test In a workspace this will run non-extension tests as well which is inconsistent with `cargo test`. The old behavior can be recovered with the new `--workspace` flag. * wip: ord/hash linkage Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: fix duplicated module magic Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: handle non-existing sql dir Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: ignore some tests Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: fix errror example Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: use old bindings Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: fixups Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: add some docs Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: some cleaning and docs Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: move around From/Intos Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: more idiomatic structuring of pg_inventory Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: create ToSql Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: some tidying on pg_inventory Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: rearrange some things: Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: introduce build_base_edges Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fmt Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: we can use a HashSet Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: introduce skip_inventory attribute in certain places Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: document skip_inventory Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fmt Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: enable skip_inventory on all Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: add functional doctests for several derives Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: add some docs to pg_inventory Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: functional test for PostgresEnum Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: add functional test for PostgresType Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: functional tests for PostgresOrd and PostgresHash Signed-off-by: Ana Hobden <operator@hoverbear.org> * Added support for uuid PostgreSQL type * Added formatting for Uuid type, compatible with PostgreSQL uuid_out result * chore: update docs Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fix some documentation Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: add pg_extern test Signed-off-by: Ana Hobden <operator@hoverbear.org> * Added Uuid::as_bytes to allow conversion from pgx::Uuid to uuid::Uuid if necessary * feat: initial 'creates' syntax for extension_sql Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: extension_sql creates don't need pgbox, option, etc Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: infer module paths for extension_sql creates Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fixup struct tests Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fmt Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: cleanup PgxSql::build Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: clean up logs some Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: get inventory items parsing even when skipped Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: Add a creates doc Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fix some comments Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: Use block doc comments in some long places Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: add pgx.control Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: improve note about overrides Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: patch variadic positioning Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: use old pgx-pg-sys Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: improve default sql path consistency Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: let pgx schema take a pg11/12 etc param Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fixup schema arg req Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fmt Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: remove need for pgx-utils or pgx-macros in user crates Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: once again reset pg sys bindings Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fixup some stray pgx-utils imports Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: clear out remaining pgx-utils needs for inventory Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: improve some documentation Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: once again reset pgx-pg-sys Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: functional custom_sql test Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: cleaning Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: handle default inside option Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: support Oid Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: Oids in returns too Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: partially support Box<dyn Iterator> Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: finish Box<dyn Iterator>> support Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: remove stray test Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fix handling of Oid in named Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: add custom_sql to github actions Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: workaround Rust 1.54/Inventory issue Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: remove generated sqls Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: extra annotations on extension_sql output Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: support default with f64 Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: support bool in default Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: strip debugging symbol Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: checkpoint a new method supporting incremental compilation Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: get links exposed in binary Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: get symbols passing Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: get custom_types example working Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: make linker script more defined Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: cleanup cargo lock Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: update flake lock Signed-off-by: Ana Hobden <operator@hoverbear.org> * wip: support arm Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: clean up new sql generation method Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fixup extern ident fn Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: handle duplicated schema names Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: cleanup cargo pgx schema output Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: return to proper typeids Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: remove some cruft Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: let cargo pgx schema work quieter Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: repair cargo settings on examples Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: cleanup imports Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: improve formatting and output Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: use feature flag in pgx-tests Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fixup tests Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: update help Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: use requires instead of before/after Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fixup tests Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: remove skip_inventory Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: suport requires in pg_extern Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: cleanup requires code Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: color a log Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: improve positioning ref resolution Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: docs Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: support variadic!() Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: improve requires resolution Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: make graph stable Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fixup an extension_sql issue Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: use correct pgx_marker location Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: cleanup marker Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: docs around marker Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: better cargo-pgx output Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fix feature flag Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: cleanup pgx schema output Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: support requires schemas Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: improve schema positioning resolution Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: rename pgx-linker-script.sh Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fmt Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: update flake lock Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: add pg_schema docs Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: improve some docs Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: tidy some error conditions Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: clean some docs Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: some docs Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: doc tests Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: repair an example Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fix schemas example Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: improve format Signed-off-by: Ana Hobden <operator@hoverbear.org> * fix: repair docsrs build Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: support testname in cargo pgx test Signed-off-by: Ana Hobden <operator@hoverbear.org> * Update cargo-pgx/src/commands/test.rs * chore: cleanup formatting Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: update README.md Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: add cargo pgx schema -o docs Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fixup comments Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: add aggregate example Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fix messed up merge conflict resolution It has been zero days since I forgot to hit save in VSCode and commited it. * feat: migrate aggregate example to PgVarlena Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fixup doc links Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: update dependencies Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fmt Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fmt Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: document pgx::info and related macros more Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fix shmem example Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fix doc tests Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fixups Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: how to update cargo-pgx, not pgx Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: use pg10 compat syntax Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: add example to ci Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: cleanup imports Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: make trigger test functional Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: suggest rustfmt install when not found Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: format Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: move info to readme Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: support -vvvvvvvv Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: better example content Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: remove stale finfo fns Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: improve readme Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: remove sql Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: add freebsd, tweak gitignore Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: format Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: remove more generated SQL Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: rename inventory stuff Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fix some renames Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: correct cargo pgx package help Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fix 'Stopping' alignment Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: format Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: remove unused dependency Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: correct a non-error Signed-off-by: Ana Hobden <operator@hoverbear.org> * feat: enable new SQL generator on Mac Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: update README.md Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: newline fixes Signed-off-by: Ana Hobden <operator@hoverbear.org> * - use `uname` to detect which operating system we're compiling on. - for MacOS, the `-exported_symbols_list` doesn't want `=` to set its argument * this file is no longer necessary * `#[link(kind = "static")]` is not necessary * when building the sql-generator binary, we don't need the `-Wl,-undefined,dynamic_lookup` bit. We only need this for building the .so. * chore: improve error passing slightly Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: improve cargo new to work Signed-off-by: Ana Hobden <operator@hoverbear.org> * fix(develop): use thinlto in debug Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: cleanup aggregate example Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fixup template Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: fix merge mistake Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: reduce UB in public API Signed-off-by: Ana Hobden <operator@hoverbear.org> * fix: reduce UB in public API Signed-off-by: Ana Hobden <operator@hoverbear.org> * Articles (#198) * chore: add articles page Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: add clarifying 'a' Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: add date comment Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: add another article! Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: add video link Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: Update some article contents Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: remove TODO link Signed-off-by: Ana Hobden <operator@hoverbear.org> * fix: Mark several functions as unsafe. (#217) * set a number of functions as unsafe, because we can't guarantee the pointers being passed in * fix doctest Co-authored-by: Eric B. Ridge <eebbrr@gmail.com> * chore: fix some docs links (#219) Signed-off-by: Ana Hobden <operator@hoverbear.org> * release: 0.2.0-beta.0 (#218) Signed-off-by: Ana Hobden <operator@hoverbear.org> * fix: mark called_as_trigger as unsafe (#223) * fix: Mark PgTupleDesk::from_pg_copy unsafe (#224) Signed-off-by: Ana Hobden <operator@hoverbear.org> * fix: mark get_getarg_type unsafe (#226) Signed-off-by: Ana Hobden <operator@hoverbear.org> * chore: update pgx-pg-sys default bindings Signed-off-by: Ana Hobden <operator@hoverbear.org> Co-authored-by: Joshua Lockerman <josh@timescale.com> Co-authored-by: Dmytro Shteflyuk <kpumuk@kpumuk.info> Co-authored-by: Eric B. Ridge <eebbrr@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We can't guarantee the being passed in. :(
See #216 #210 #215 for more.