summaryrefslogtreecommitdiff
path: root/src/pl
diff options
context:
space:
mode:
authorTom Lane2020-03-04 15:34:25 +0000
committerTom Lane2020-03-04 15:34:25 +0000
commit3ed2005ff595d349276e5b2edeca1a8100b08c87 (patch)
tree361ca1ffdc3e816c98d45a0357c92d25ba71d760 /src/pl
parent0ad6f848eef267489d4aee7306c16f96454b7a64 (diff)
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/pl')
-rw-r--r--src/pl/plpgsql/src/pl_comp.c4
-rw-r--r--src/pl/plpgsql/src/pl_exec.c2
-rw-r--r--src/pl/plpython/plpy_typeio.c4
3 files changed, 5 insertions, 5 deletions
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
index 4f6b36b145a..c8e43e684f5 100644
--- a/src/pl/plpgsql/src/pl_comp.c
+++ b/src/pl/plpgsql/src/pl_comp.c
@@ -2125,13 +2125,13 @@ build_datatype(HeapTuple typeTup, int32 typmod,
*/
typ->typisarray = (typeStruct->typlen == -1 &&
OidIsValid(typeStruct->typelem) &&
- typeStruct->typstorage != 'p');
+ typeStruct->typstorage != TYPSTORAGE_PLAIN);
}
else if (typeStruct->typtype == TYPTYPE_DOMAIN)
{
/* we can short-circuit looking up base types if it's not varlena */
typ->typisarray = (typeStruct->typlen == -1 &&
- typeStruct->typstorage != 'p' &&
+ typeStruct->typstorage != TYPSTORAGE_PLAIN &&
OidIsValid(get_base_element_type(typeStruct->typbasetype)));
}
else
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index a867c2c43b8..d3ad4fa54dd 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -1456,7 +1456,7 @@ plpgsql_fulfill_promise(PLpgSQL_execstate *estate,
PointerGetDatum(construct_md_array(elems, NULL,
1, dims, lbs,
TEXTOID,
- -1, false, 'i')),
+ -1, false, TYPALIGN_INT)),
false, true);
}
else
diff --git a/src/pl/plpython/plpy_typeio.c b/src/pl/plpython/plpy_typeio.c
index e734b0d1303..7c844c2b8a1 100644
--- a/src/pl/plpython/plpy_typeio.c
+++ b/src/pl/plpython/plpy_typeio.c
@@ -328,7 +328,7 @@ PLy_output_setup_func(PLyObToDatum *arg, MemoryContext arg_mcxt,
/* hard-wired knowledge about type RECORD: */
arg->typbyval = false;
arg->typlen = -1;
- arg->typalign = 'd';
+ arg->typalign = TYPALIGN_DOUBLE;
}
/*
@@ -451,7 +451,7 @@ PLy_input_setup_func(PLyDatumToOb *arg, MemoryContext arg_mcxt,
/* hard-wired knowledge about type RECORD: */
arg->typbyval = false;
arg->typlen = -1;
- arg->typalign = 'd';
+ arg->typalign = TYPALIGN_DOUBLE;
}
/*