mirror of
https://github.com/postgres/postgres.git
synced 2025-10-21 02:52:47 +03:00
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
This commit is contained in:
@@ -20,12 +20,12 @@
|
||||
* Information about one column of a tuple being toasted.
|
||||
*
|
||||
* NOTE: toast_action[i] can have these values:
|
||||
* ' ' default handling
|
||||
* 'p' already processed --- don't touch it
|
||||
* 'x' incompressible, but OK to move off
|
||||
* ' ' default handling
|
||||
* TYPSTORAGE_PLAIN already processed --- don't touch it
|
||||
* TYPSTORAGE_EXTENDED incompressible, but OK to move off
|
||||
*
|
||||
* NOTE: toast_attr[i].tai_size is only made valid for varlena attributes with
|
||||
* toast_action[i] different from 'p'.
|
||||
* toast_action[i] different from TYPSTORAGE_PLAIN.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#ifndef TUPMACS_H
|
||||
#define TUPMACS_H
|
||||
|
||||
#include "catalog/pg_type_d.h" /* for TYPALIGN macros */
|
||||
|
||||
|
||||
/*
|
||||
* Check a tuple's null bitmap to determine whether the attribute is null.
|
||||
@@ -145,11 +147,11 @@
|
||||
*/
|
||||
#define att_align_nominal(cur_offset, attalign) \
|
||||
( \
|
||||
((attalign) == 'i') ? INTALIGN(cur_offset) : \
|
||||
(((attalign) == 'c') ? (uintptr_t) (cur_offset) : \
|
||||
(((attalign) == 'd') ? DOUBLEALIGN(cur_offset) : \
|
||||
((attalign) == TYPALIGN_INT) ? INTALIGN(cur_offset) : \
|
||||
(((attalign) == TYPALIGN_CHAR) ? (uintptr_t) (cur_offset) : \
|
||||
(((attalign) == TYPALIGN_DOUBLE) ? DOUBLEALIGN(cur_offset) : \
|
||||
( \
|
||||
AssertMacro((attalign) == 's'), \
|
||||
AssertMacro((attalign) == TYPALIGN_SHORT), \
|
||||
SHORTALIGN(cur_offset) \
|
||||
))) \
|
||||
)
|
||||
|
Reference in New Issue
Block a user