diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2020-03-04 10:34:25 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2020-03-04 10:34:25 -0500 |
commit | 3ed2005ff595d349276e5b2edeca1a8100b08c87 (patch) | |
tree | 361ca1ffdc3e816c98d45a0357c92d25ba71d760 /src/backend/utils/adt/timestamp.c | |
parent | 0ad6f848eef267489d4aee7306c16f96454b7a64 (diff) | |
download | postgresql-3ed2005ff595d349276e5b2edeca1a8100b08c87.tar.gz |
Introduce macros for typalign and typstorage constants.
Our usual practice for "poor man's enum" catalog columns is to define
macros for the possible values and use those, not literal constants,
in C code. But for some reason lost in the mists of time, this was
never done for typalign/attalign or typstorage/attstorage. It's never
too late to make it better though, so let's do that.
The reason I got interested in this right now is the need to duplicate
some uses of the TYPSTORAGE constants in an upcoming ALTER TYPE patch.
But in general, this sort of change aids greppability and readability,
so it's a good idea even without any specific motivation.
I may have missed a few places that could be converted, and it's even
more likely that pending patches will re-introduce some hard-coded
references. But that's not fatal --- there's no expectation that
we'd actually change any of these values. We can clean up stragglers
over time.
Discussion: https://postgr.es/m/16457.1583189537@sss.pgh.pa.us
Diffstat (limited to 'src/backend/utils/adt/timestamp.c')
-rw-r--r-- | src/backend/utils/adt/timestamp.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 0b6c9d5ea8..4caffb5804 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -3421,7 +3421,7 @@ interval_accum(PG_FUNCTION_ARGS) ArrayType *result; deconstruct_array(transarray, - INTERVALOID, sizeof(Interval), false, 'd', + INTERVALOID, sizeof(Interval), false, TYPALIGN_DOUBLE, &transdatums, NULL, &ndatums); if (ndatums != 2) elog(ERROR, "expected 2-element interval array"); @@ -3438,7 +3438,7 @@ interval_accum(PG_FUNCTION_ARGS) transdatums[1] = IntervalPGetDatum(&N); result = construct_array(transdatums, 2, - INTERVALOID, sizeof(Interval), false, 'd'); + INTERVALOID, sizeof(Interval), false, TYPALIGN_DOUBLE); PG_RETURN_ARRAYTYPE_P(result); } @@ -3461,7 +3461,7 @@ interval_combine(PG_FUNCTION_ARGS) ArrayType *result; deconstruct_array(transarray1, - INTERVALOID, sizeof(Interval), false, 'd', + INTERVALOID, sizeof(Interval), false, TYPALIGN_DOUBLE, &transdatums1, NULL, &ndatums1); if (ndatums1 != 2) elog(ERROR, "expected 2-element interval array"); @@ -3470,7 +3470,7 @@ interval_combine(PG_FUNCTION_ARGS) N1 = *(DatumGetIntervalP(transdatums1[1])); deconstruct_array(transarray2, - INTERVALOID, sizeof(Interval), false, 'd', + INTERVALOID, sizeof(Interval), false, TYPALIGN_DOUBLE, &transdatums2, NULL, &ndatums2); if (ndatums2 != 2) elog(ERROR, "expected 2-element interval array"); @@ -3487,7 +3487,7 @@ interval_combine(PG_FUNCTION_ARGS) transdatums1[1] = IntervalPGetDatum(&N1); result = construct_array(transdatums1, 2, - INTERVALOID, sizeof(Interval), false, 'd'); + INTERVALOID, sizeof(Interval), false, TYPALIGN_DOUBLE); PG_RETURN_ARRAYTYPE_P(result); } @@ -3505,7 +3505,7 @@ interval_accum_inv(PG_FUNCTION_ARGS) ArrayType *result; deconstruct_array(transarray, - INTERVALOID, sizeof(Interval), false, 'd', + INTERVALOID, sizeof(Interval), false, TYPALIGN_DOUBLE, &transdatums, NULL, &ndatums); if (ndatums != 2) elog(ERROR, "expected 2-element interval array"); @@ -3522,7 +3522,7 @@ interval_accum_inv(PG_FUNCTION_ARGS) transdatums[1] = IntervalPGetDatum(&N); result = construct_array(transdatums, 2, - INTERVALOID, sizeof(Interval), false, 'd'); + INTERVALOID, sizeof(Interval), false, TYPALIGN_DOUBLE); PG_RETURN_ARRAYTYPE_P(result); } @@ -3537,7 +3537,7 @@ interval_avg(PG_FUNCTION_ARGS) N; deconstruct_array(transarray, - INTERVALOID, sizeof(Interval), false, 'd', + INTERVALOID, sizeof(Interval), false, TYPALIGN_DOUBLE, &transdatums, NULL, &ndatums); if (ndatums != 2) elog(ERROR, "expected 2-element interval array"); |