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

Add handler functions for Datum/Bools arrays #6735

Merged

Commits on Mar 6, 2024

  1. Add handler functions for Datum/Bools arrays

    When updating catalog tables we rely on low level functions instead of
    SQL statements and in order to read/write data from/to those tables we
    frequent do something like:
    
    ```CPP
    Datum values[natts] = { 0 };
    bool nulls[natts] = { false };
    char *char_value = "foo";
    
    if (char_value != NULL)
        values[AttrNumberGetAttrOffset(text_value_offset)] =
            PointerGetDatum(cstring_to_text(char_value);
    else
        null[AttrNumberGetAttrOffset(char_value_offset)] = true;
    ```
    
    So instead of using a pair of Datum and bool arrays we'll replace it by
    using arrays of `NullableDatum` that contains both members and introduce
    some accessor functions to encapsulate the logic to fill the proper
    values, like:
    
    ```CPP
    ts_datum_set_text(int index, NullableDatum *datums, text *value);
    ts_datum_set_bool(int index, NullableDatum *datums, bool value);
    ```
    
    We also introduce a new `ts_heap_form_tuple` that essentially to the
    same as Postgres `heap_form_tuple` but using array of `NullableDatum`
    instead of Datum and bool arrays.
    
    In this first commit we added only the necessary accessor functions to
    refactor the existing `create_cagg_validate_query_datum` as example.
    More accessor functions to deal with other C types should be introduced
    in the future.
    fabriziomello committed Mar 6, 2024
    Configuration menu
    Copy the full SHA
    d691e02 View commit details
    Browse the repository at this point in the history