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

Changed age_id, age_start_id and age_end_id function signatures to IMMUTABLE #405

Merged
merged 5 commits into from
Dec 27, 2022

Conversation

markgomer
Copy link
Contributor

Changed age_id(agtype), age_start_id(agtype) and age_end_id(agtype) from STABLE to IMMUTABLE.

These functions only process the arguments passed to them, not doing any database scan. So they can be safely classified as immutable, instead of stable.

Changed age_id(agtype), age_start_id(agtype) and age_end_id(agtype) from STABLE to IMMUTABLE.
@markgomer markgomer changed the title Changed some function signatures to IMMUTABLE Changed age_id, age_start_id and age_end_id function signatures to IMMUTABLE Dec 22, 2022
@jrgemignani
Copy link
Contributor

The differences between STABLE and IMMUTABLE are small and have nothing to do with the database operations. Can you justify this change in the confines of STABLE versus IMMUTABLE?

@markgomer
Copy link
Contributor Author

The case with these functions is that, through the arguments (a vertex or an edge or null), they receive all the data that is needed to give the wanted results, only doing processings that analyze its contents.

By only processing the arguments passed to it, these functions will always return the same results based on these arguments, being classified as IMMUTABLE.

If something would happen along the way (inside the function) that could change the result, like a scan in a modified database, it could be classified as STABLE.

@jrgemignani
Copy link
Contributor

You are conflating STABLE with VOLATILE https://www.postgresql.org/docs/current/xfunc-volatility.html

@markgomer
Copy link
Contributor Author

Sorry, I actually meant that, as an example of a stable function, a scan in the database could change its result, because the read data could be different in other calls of the function with the same arguments.

That being said, these functions give results only based on the containers received as arguments (vertexes or edges), and nothing will act to change it in calls with the same arguments.

For example, if I pass an edge with an id of 1, age_id will always look inside that edge container (not the database) and output 1, and in a similar way with the other two functions.

@jrgemignani
Copy link
Contributor

@markgomer Please fix your commit log entry for the PR to be descriptive of the change - what was changed and why. Once this is corrected, let us know so that we can review the PR for merging.

* Function signature was changed from STABLE to IMMUTABLE;
* Function receives a vertex or edge container (or null), and analyze its contents to return the "id" stored in said container;
* As it acts only on its arguments, it will always return the same result, given the same arguments, even across multiple SQL statements, being classified as IMMUTABLE function.
* Function signature was changed from STABLE to IMMUTABLE;
* Function receives an edge container (or null), and analyze its contents to return the "start_id" stored in said container;
* As it acts only on its arguments, it will always return the same result, given the same arguments, even across multiple SQL statements, being classified as IMMUTABLE function.
* Function signature was changed from STABLE to IMMUTABLE;
* Function receives an edge container (or null), and analyze its contents to return the "end_id" stored in said container;
* As it acts only on its arguments, it will always return the same result, given the same arguments, even across multiple SQL statements, being classified as IMMUTABLE function.
@markgomer
Copy link
Contributor Author

@jrgemignani I have updated the commit entry log for your review. Please let me know if these changes are appropriate.

@JoshInnis JoshInnis merged commit da73984 into apache:master Dec 27, 2022
jrgemignani pushed a commit that referenced this pull request Feb 9, 2023
…MUTABLE (#405)

* Changed some function signatures to IMMUTABLE

Changed age_id(agtype), age_start_id(agtype) and age_end_id(agtype) from STABLE to IMMUTABLE.

* Revert "Changed some function signatures to IMMUTABLE"

This reverts commit 92ac40d.

* Changed age_id signature to IMMUTABLE

* Function signature was changed from STABLE to IMMUTABLE;
* Function receives a vertex or edge container (or null), and analyze its contents to return the "id" stored in said container;
* As it acts only on its arguments, it will always return the same result, given the same arguments, even across multiple SQL statements, being classified as IMMUTABLE function.

* Changed age_start_id signature to IMMUTABLE

* Function signature was changed from STABLE to IMMUTABLE;
* Function receives an edge container (or null), and analyze its contents to return the "start_id" stored in said container;
* As it acts only on its arguments, it will always return the same result, given the same arguments, even across multiple SQL statements, being classified as IMMUTABLE function.

* Changed age_end_id signature to IMMUTABLE

* Function signature was changed from STABLE to IMMUTABLE;
* Function receives an edge container (or null), and analyze its contents to return the "end_id" stored in said container;
* As it acts only on its arguments, it will always return the same result, given the same arguments, even across multiple SQL statements, being classified as IMMUTABLE function.
MuhammadTahaNaveed pushed a commit to MuhammadTahaNaveed/age that referenced this pull request Feb 10, 2023
…MUTABLE (apache#405)

* Changed some function signatures to IMMUTABLE

Changed age_id(agtype), age_start_id(agtype) and age_end_id(agtype) from STABLE to IMMUTABLE.

* Revert "Changed some function signatures to IMMUTABLE"

This reverts commit 92ac40d.

* Changed age_id signature to IMMUTABLE

* Function signature was changed from STABLE to IMMUTABLE;
* Function receives a vertex or edge container (or null), and analyze its contents to return the "id" stored in said container;
* As it acts only on its arguments, it will always return the same result, given the same arguments, even across multiple SQL statements, being classified as IMMUTABLE function.

* Changed age_start_id signature to IMMUTABLE

* Function signature was changed from STABLE to IMMUTABLE;
* Function receives an edge container (or null), and analyze its contents to return the "start_id" stored in said container;
* As it acts only on its arguments, it will always return the same result, given the same arguments, even across multiple SQL statements, being classified as IMMUTABLE function.

* Changed age_end_id signature to IMMUTABLE

* Function signature was changed from STABLE to IMMUTABLE;
* Function receives an edge container (or null), and analyze its contents to return the "end_id" stored in said container;
* As it acts only on its arguments, it will always return the same result, given the same arguments, even across multiple SQL statements, being classified as IMMUTABLE function.
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.

3 participants