text *item;
deconstruct_array(query,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&key_datums, &key_nulls, &key_count);
entries = (Datum *) palloc(sizeof(Datum) * key_count);
int i;
deconstruct_array(query,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&key_datums, &key_nulls, &key_count);
for (i = 0; res && i < key_count; ++i)
int i;
deconstruct_array(query,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&key_datums, &key_nulls, &key_count);
res = false;
errmsg("wrong number of array subscripts")));
deconstruct_array(key_array,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&key_datums, &key_nulls, &key_count);
/* see discussion in hstoreArrayToPairs() */
errmsg("arrays must have same bounds")));
deconstruct_array(value_array,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&value_datums, &value_nulls, &value_count);
Assert(key_count == value_count);
}
deconstruct_array(in_array,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&in_datums, &in_nulls, &in_count);
count = in_count / 2;
j;
deconstruct_array(a,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&key_datums, &key_nulls, &key_count);
if (key_count == 0)
int i;
deconstruct_array(key_array,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&key_datums, &key_nulls, &key_count);
if (key_count == 0)
ARR_NDIM(key_array),
ARR_DIMS(key_array),
ARR_LBOUND(key_array),
- TEXTOID, -1, false, 'i');
+ TEXTOID, -1, false, TYPALIGN_INT);
PG_RETURN_POINTER(aout);
}
}
a = construct_array(d, count,
- TEXTOID, -1, false, 'i');
+ TEXTOID, -1, false, TYPALIGN_INT);
PG_RETURN_POINTER(a);
}
}
a = construct_md_array(d, nulls, 1, &count, &lb,
- TEXTOID, -1, false, 'i');
+ TEXTOID, -1, false, TYPALIGN_INT);
PG_RETURN_POINTER(a);
}
return construct_md_array(out_datums, out_nulls,
ndims, out_size, lb,
- TEXTOID, -1, false, 'i');
+ TEXTOID, -1, false, TYPALIGN_INT);
}
PG_FUNCTION_INFO_V1(hstore_to_array);
nposting,
TIDOID,
sizeof(ItemPointerData),
- false, 's'));
+ false, TYPALIGN_SHORT));
pfree(tids_datum);
}
else
values[0] = Int64GetDatum(opaq->rightlink);
values[1] = Int32GetDatum(opaq->maxoff);
values[2] = PointerGetDatum(construct_array(flags, nflags,
- TEXTOID, -1, false, 'i'));
+ TEXTOID,
+ -1, false, TYPALIGN_INT));
/* Build and return the result tuple. */
resultTuple = heap_form_tuple(tupdesc, values, nulls);
ndecoded,
TIDOID,
sizeof(ItemPointerData),
- false, 's'));
+ false, TYPALIGN_SHORT));
pfree(tids_datum);
pfree(tids);
values[j++] = PointerGetDatum(construct_array(spares,
HASH_MAX_SPLITPOINTS,
INT8OID,
- 8, FLOAT8PASSBYVAL, 'd'));
+ sizeof(int64),
+ FLOAT8PASSBYVAL,
+ TYPALIGN_DOUBLE));
for (i = 0; i < HASH_MAX_BITMAPS; i++)
mapp[i] = Int64GetDatum((int64) metad->hashm_mapp[i]);
values[j++] = PointerGetDatum(construct_array(mapp,
HASH_MAX_BITMAPS,
INT8OID,
- 8, FLOAT8PASSBYVAL, 'd'));
+ sizeof(int64),
+ FLOAT8PASSBYVAL,
+ TYPALIGN_DOUBLE));
tuple = heap_form_tuple(tupleDesc, values, nulls);
/* build value */
Assert(cnt <= bitcnt);
- a = construct_array(flags, cnt, TEXTOID, -1, false, 'i');
+ a = construct_array(flags, cnt, TEXTOID, -1, false, TYPALIGN_INT);
values[0] = PointerGetDatum(a);
/*
if (cnt == 0)
a = construct_empty_array(TEXTOID);
else
- a = construct_array(flags, cnt, TEXTOID, -1, false, 'i');
+ a = construct_array(flags, cnt, TEXTOID, -1, false, TYPALIGN_INT);
pfree(flags);
values[1] = PointerGetDatum(a);
TEXTOID,
-1,
false,
- 'i');
+ TYPALIGN_INT);
for (i = 0; i < ARRNELEM(trg); i++)
pfree(DatumGetPointer(d[i]));
return 0;
deconstruct_array(key_array,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&key_datums, &key_nulls, &key_count);
deconstruct_array(val_array,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&val_datums, &val_nulls, &val_count);
if (key_count != val_count)
* that have been put into a tuple but never sent to disk. Hopefully there
* are few such places.
*
- * Varlenas still have alignment 'i' (or 'd') in pg_type/pg_attribute, since
+ * Varlenas still have alignment INT (or DOUBLE) in pg_type/pg_attribute, since
* that's the normal requirement for the untoasted format. But we ignore that
* for the 1-byte-header format. This means that the actual start position
* of a varlena datum may vary depending on which format it has. To determine
* catalog, this is now risky: it's only safe if the preceding field is
* word-aligned, so that there will never be any padding.
*
- * We don't pack varlenas whose attstorage is 'p', since the data type
+ * We don't pack varlenas whose attstorage is PLAIN, since the data type
* isn't expecting to have to detoast values. This is used in particular
* by oidvector and int2vector, which are used in the system catalogs
* and we'd like to still refer to them via C struct offsets.
/* Does att's datatype allow packing into the 1-byte-header varlena format? */
#define ATT_IS_PACKABLE(att) \
- ((att)->attlen == -1 && (att)->attstorage != 'p')
+ ((att)->attlen == -1 && (att)->attstorage != TYPSTORAGE_PLAIN)
/* Use this if it's already known varlena */
#define VARLENA_ATT_IS_PACKABLE(att) \
- ((att)->attstorage != 'p')
+ ((att)->attstorage != TYPSTORAGE_PLAIN)
/* ----------------------------------------------------------------
{
/* cstring ... never needs alignment */
*infomask |= HEAP_HASVARWIDTH;
- Assert(att->attalign == 'c');
+ Assert(att->attalign == TYPALIGN_CHAR);
data_length = strlen(DatumGetCString(datum)) + 1;
memcpy(data, DatumGetPointer(datum), data_length);
}
*/
if (!VARATT_IS_EXTENDED(DatumGetPointer(untoasted_values[i])) &&
VARSIZE(DatumGetPointer(untoasted_values[i])) > TOAST_INDEX_TARGET &&
- (att->attstorage == 'x' || att->attstorage == 'm'))
+ (att->attstorage == TYPSTORAGE_EXTENDED ||
+ att->attstorage == TYPSTORAGE_MAIN))
{
Datum cvalue = toast_compress_datum(untoasted_values[i]);
int noldoptions;
int i;
- deconstruct_array(array, TEXTOID, -1, false, 'i',
+ deconstruct_array(array, TEXTOID, -1, false, TYPALIGN_INT,
&oldoptions, NULL, &noldoptions);
for (i = 0; i < noldoptions; i++)
array = DatumGetArrayTypeP(options);
- deconstruct_array(array, TEXTOID, -1, false, 'i',
+ deconstruct_array(array, TEXTOID, -1, false, TYPALIGN_INT,
&optiondatums, NULL, &noptions);
for (i = 0; i < noptions; i++)
Datum *optiondatums;
int noptions;
- deconstruct_array(array, TEXTOID, -1, false, 'i',
+ deconstruct_array(array, TEXTOID, -1, false, TYPALIGN_INT,
&optiondatums, NULL, &noptions);
for (i = 0; i < noptions; i++)
case TEXTARRAYOID:
att->attlen = -1;
att->attbyval = false;
- att->attalign = 'i';
- att->attstorage = 'x';
+ att->attalign = TYPALIGN_INT;
+ att->attstorage = TYPSTORAGE_EXTENDED;
att->attcollation = DEFAULT_COLLATION_OID;
break;
case BOOLOID:
att->attlen = 1;
att->attbyval = true;
- att->attalign = 'c';
- att->attstorage = 'p';
+ att->attalign = TYPALIGN_CHAR;
+ att->attstorage = TYPSTORAGE_PLAIN;
att->attcollation = InvalidOid;
break;
case INT4OID:
att->attlen = 4;
att->attbyval = true;
- att->attalign = 'i';
- att->attstorage = 'p';
+ att->attalign = TYPALIGN_INT;
+ att->attstorage = TYPSTORAGE_PLAIN;
att->attcollation = InvalidOid;
break;
case INT8OID:
att->attlen = 8;
att->attbyval = FLOAT8PASSBYVAL;
- att->attalign = 'd';
- att->attstorage = 'p';
+ att->attalign = TYPALIGN_DOUBLE;
+ att->attstorage = TYPSTORAGE_PLAIN;
att->attcollation = InvalidOid;
break;
maxlength_unknown = true;
else
data_length += maxlen;
- if (att->attstorage != 'p')
+ if (att->attstorage != TYPSTORAGE_PLAIN)
has_toastable_attrs = true;
}
}
/* ----------
* Compress and/or save external until data fits into target length
*
- * 1: Inline compress attributes with attstorage 'x', and store very
- * large attributes with attstorage 'x' or 'e' external immediately
- * 2: Store attributes with attstorage 'x' or 'e' external
- * 3: Inline compress attributes with attstorage 'm'
- * 4: Store attributes with attstorage 'm' external
+ * 1: Inline compress attributes with attstorage EXTENDED, and store very
+ * large attributes with attstorage EXTENDED or EXTERNAL external
+ * immediately
+ * 2: Store attributes with attstorage EXTENDED or EXTERNAL external
+ * 3: Inline compress attributes with attstorage MAIN
+ * 4: Store attributes with attstorage MAIN external
* ----------
*/
maxDataLen = RelationGetToastTupleTarget(rel, TOAST_TUPLE_TARGET) - hoff;
/*
- * Look for attributes with attstorage 'x' to compress. Also find large
- * attributes with attstorage 'x' or 'e', and store them external.
+ * Look for attributes with attstorage EXTENDED to compress. Also find
+ * large attributes with attstorage EXTENDED or EXTERNAL, and store them
+ * external.
*/
while (heap_compute_data_size(tupleDesc,
toast_values, toast_isnull) > maxDataLen)
break;
/*
- * Attempt to compress it inline, if it has attstorage 'x'
+ * Attempt to compress it inline, if it has attstorage EXTENDED
*/
- if (TupleDescAttr(tupleDesc, biggest_attno)->attstorage == 'x')
+ if (TupleDescAttr(tupleDesc, biggest_attno)->attstorage == TYPSTORAGE_EXTENDED)
toast_tuple_try_compression(&ttc, biggest_attno);
else
{
- /* has attstorage 'e', ignore on subsequent compression passes */
+ /*
+ * has attstorage EXTERNAL, ignore on subsequent compression
+ * passes
+ */
toast_attr[biggest_attno].tai_colflags |= TOASTCOL_INCOMPRESSIBLE;
}
}
/*
- * Second we look for attributes of attstorage 'x' or 'e' that are still
- * inline, and make them external. But skip this if there's no toast
- * table to push them to.
+ * Second we look for attributes of attstorage EXTENDED or EXTERNAL that
+ * are still inline, and make them external. But skip this if there's no
+ * toast table to push them to.
*/
while (heap_compute_data_size(tupleDesc,
toast_values, toast_isnull) > maxDataLen &&
}
/*
- * Round 3 - this time we take attributes with storage 'm' into
+ * Round 3 - this time we take attributes with storage MAIN into
* compression
*/
while (heap_compute_data_size(tupleDesc,
}
/*
- * Finally we store attributes of type 'm' externally. At this point we
- * increase the target tuple size, so that 'm' attributes aren't stored
+ * Finally we store attributes of type MAIN externally. At this point we
+ * increase the target tuple size, so that MAIN attributes aren't stored
* externally unless really necessary.
*/
maxDataLen = TOAST_TUPLE_TARGET_MAIN - hoff;
* Copyright (c) 2000-2020, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * src/backend/access/common/toast_helper.c
+ * src/backend/access/table/toast_helper.c
*
*-------------------------------------------------------------------------
*/
#include "access/table.h"
#include "access/toast_helper.h"
#include "access/toast_internals.h"
+#include "catalog/pg_type_d.h"
+
/*
* Prepare to TOAST a tuple.
/*
* If the table's attribute says PLAIN always, force it so.
*/
- if (att->attstorage == 'p')
+ if (att->attstorage == TYPSTORAGE_PLAIN)
ttc->ttc_attr[i].tai_colflags |= TOASTCOL_IGNORE;
/*
if (VARATT_IS_EXTERNAL(new_value))
{
ttc->ttc_attr[i].tai_oldexternal = new_value;
- if (att->attstorage == 'p')
+ if (att->attstorage == TYPSTORAGE_PLAIN)
new_value = detoast_attr(new_value);
else
new_value = detoast_external_attr(new_value);
* for_compression flag is passed as true, it must also not be marked
* TOASTCOL_INCOMPRESSIBLE.
*
- * The column must have attstorage 'e' or 'x' if check_main is false, and
- * must have attstorage 'm' if check_main is true.
+ * The column must have attstorage EXTERNAL or EXTENDED if check_main is
+ * false, and must have attstorage MAIN if check_main is true.
*
* The column must have a minimum size of MAXALIGN(TOAST_POINTER_SIZE);
* if not, no benefit is to be expected by compressing it.
if ((ttc->ttc_attr[i].tai_colflags & skip_colflags) != 0)
continue;
if (VARATT_IS_EXTERNAL(DatumGetPointer(ttc->ttc_values[i])))
- continue; /* can't happen, toast_action would be 'p' */
+ continue; /* can't happen, toast_action would be PLAIN */
if (for_compression &&
VARATT_IS_COMPRESSED(DatumGetPointer(ttc->ttc_values[i])))
continue;
- if (check_main && att->attstorage != 'm')
+ if (check_main && att->attstorage != TYPSTORAGE_MAIN)
continue;
- if (!check_main && att->attstorage != 'x' && att->attstorage != 'e')
+ if (!check_main && att->attstorage != TYPSTORAGE_EXTENDED &&
+ att->attstorage != TYPSTORAGE_EXTERNAL)
continue;
if (ttc->ttc_attr[i].tai_size > biggest_size)
};
static const struct typinfo TypInfo[] = {
- {"bool", BOOLOID, 0, 1, true, 'c', 'p', InvalidOid,
+ {"bool", BOOLOID, 0, 1, true, TYPALIGN_CHAR, TYPSTORAGE_PLAIN, InvalidOid,
F_BOOLIN, F_BOOLOUT},
- {"bytea", BYTEAOID, 0, -1, false, 'i', 'x', InvalidOid,
+ {"bytea", BYTEAOID, 0, -1, false, TYPALIGN_INT, TYPSTORAGE_EXTENDED, InvalidOid,
F_BYTEAIN, F_BYTEAOUT},
- {"char", CHAROID, 0, 1, true, 'c', 'p', InvalidOid,
+ {"char", CHAROID, 0, 1, true, TYPALIGN_CHAR, TYPSTORAGE_PLAIN, InvalidOid,
F_CHARIN, F_CHAROUT},
- {"int2", INT2OID, 0, 2, true, 's', 'p', InvalidOid,
+ {"int2", INT2OID, 0, 2, true, TYPALIGN_SHORT, TYPSTORAGE_PLAIN, InvalidOid,
F_INT2IN, F_INT2OUT},
- {"int4", INT4OID, 0, 4, true, 'i', 'p', InvalidOid,
+ {"int4", INT4OID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
F_INT4IN, F_INT4OUT},
- {"float4", FLOAT4OID, 0, 4, true, 'i', 'p', InvalidOid,
+ {"float4", FLOAT4OID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
F_FLOAT4IN, F_FLOAT4OUT},
- {"name", NAMEOID, CHAROID, NAMEDATALEN, false, 'c', 'p', C_COLLATION_OID,
+ {"name", NAMEOID, CHAROID, NAMEDATALEN, false, TYPALIGN_CHAR, TYPSTORAGE_PLAIN, C_COLLATION_OID,
F_NAMEIN, F_NAMEOUT},
- {"regclass", REGCLASSOID, 0, 4, true, 'i', 'p', InvalidOid,
+ {"regclass", REGCLASSOID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
F_REGCLASSIN, F_REGCLASSOUT},
- {"regproc", REGPROCOID, 0, 4, true, 'i', 'p', InvalidOid,
+ {"regproc", REGPROCOID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
F_REGPROCIN, F_REGPROCOUT},
- {"regtype", REGTYPEOID, 0, 4, true, 'i', 'p', InvalidOid,
+ {"regtype", REGTYPEOID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
F_REGTYPEIN, F_REGTYPEOUT},
- {"regrole", REGROLEOID, 0, 4, true, 'i', 'p', InvalidOid,
+ {"regrole", REGROLEOID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
F_REGROLEIN, F_REGROLEOUT},
- {"regnamespace", REGNAMESPACEOID, 0, 4, true, 'i', 'p', InvalidOid,
+ {"regnamespace", REGNAMESPACEOID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
F_REGNAMESPACEIN, F_REGNAMESPACEOUT},
- {"text", TEXTOID, 0, -1, false, 'i', 'x', DEFAULT_COLLATION_OID,
+ {"text", TEXTOID, 0, -1, false, TYPALIGN_INT, TYPSTORAGE_EXTENDED, DEFAULT_COLLATION_OID,
F_TEXTIN, F_TEXTOUT},
- {"oid", OIDOID, 0, 4, true, 'i', 'p', InvalidOid,
+ {"oid", OIDOID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
F_OIDIN, F_OIDOUT},
- {"tid", TIDOID, 0, 6, false, 's', 'p', InvalidOid,
+ {"tid", TIDOID, 0, 6, false, TYPALIGN_SHORT, TYPSTORAGE_PLAIN, InvalidOid,
F_TIDIN, F_TIDOUT},
- {"xid", XIDOID, 0, 4, true, 'i', 'p', InvalidOid,
+ {"xid", XIDOID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
F_XIDIN, F_XIDOUT},
- {"cid", CIDOID, 0, 4, true, 'i', 'p', InvalidOid,
+ {"cid", CIDOID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
F_CIDIN, F_CIDOUT},
- {"pg_node_tree", PGNODETREEOID, 0, -1, false, 'i', 'x', DEFAULT_COLLATION_OID,
+ {"pg_node_tree", PGNODETREEOID, 0, -1, false, TYPALIGN_INT, TYPSTORAGE_EXTENDED, DEFAULT_COLLATION_OID,
F_PG_NODE_TREE_IN, F_PG_NODE_TREE_OUT},
- {"int2vector", INT2VECTOROID, INT2OID, -1, false, 'i', 'p', InvalidOid,
+ {"int2vector", INT2VECTOROID, INT2OID, -1, false, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
F_INT2VECTORIN, F_INT2VECTOROUT},
- {"oidvector", OIDVECTOROID, OIDOID, -1, false, 'i', 'p', InvalidOid,
+ {"oidvector", OIDVECTOROID, OIDOID, -1, false, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
F_OIDVECTORIN, F_OIDVECTOROUT},
- {"_int4", INT4ARRAYOID, INT4OID, -1, false, 'i', 'x', InvalidOid,
+ {"_int4", INT4ARRAYOID, INT4OID, -1, false, TYPALIGN_INT, TYPSTORAGE_EXTENDED, InvalidOid,
F_ARRAY_IN, F_ARRAY_OUT},
- {"_text", 1009, TEXTOID, -1, false, 'i', 'x', DEFAULT_COLLATION_OID,
+ {"_text", 1009, TEXTOID, -1, false, TYPALIGN_INT, TYPSTORAGE_EXTENDED, DEFAULT_COLLATION_OID,
F_ARRAY_IN, F_ARRAY_OUT},
- {"_oid", 1028, OIDOID, -1, false, 'i', 'x', InvalidOid,
+ {"_oid", 1028, OIDOID, -1, false, TYPALIGN_INT, TYPSTORAGE_EXTENDED, InvalidOid,
F_ARRAY_IN, F_ARRAY_OUT},
- {"_char", 1002, CHAROID, -1, false, 'i', 'x', InvalidOid,
+ {"_char", 1002, CHAROID, -1, false, TYPALIGN_INT, TYPSTORAGE_EXTENDED, InvalidOid,
F_ARRAY_IN, F_ARRAY_OUT},
- {"_aclitem", 1034, ACLITEMOID, -1, false, 'i', 'x', InvalidOid,
+ {"_aclitem", 1034, ACLITEMOID, -1, false, TYPALIGN_INT, TYPSTORAGE_EXTENDED, InvalidOid,
F_ARRAY_IN, F_ARRAY_OUT}
};
.attcacheoff = -1,
.atttypmod = -1,
.attbyval = false,
- .attstorage = 'p',
- .attalign = 's',
+ .attstorage = TYPSTORAGE_PLAIN,
+ .attalign = TYPALIGN_SHORT,
.attnotnull = true,
.attislocal = true,
};
.attcacheoff = -1,
.atttypmod = -1,
.attbyval = true,
- .attstorage = 'p',
- .attalign = 'i',
+ .attstorage = TYPSTORAGE_PLAIN,
+ .attalign = TYPALIGN_INT,
.attnotnull = true,
.attislocal = true,
};
.attcacheoff = -1,
.atttypmod = -1,
.attbyval = true,
- .attstorage = 'p',
- .attalign = 'i',
+ .attstorage = TYPSTORAGE_PLAIN,
+ .attalign = TYPALIGN_INT,
.attnotnull = true,
.attislocal = true,
};
.attcacheoff = -1,
.atttypmod = -1,
.attbyval = true,
- .attstorage = 'p',
- .attalign = 'i',
+ .attstorage = TYPSTORAGE_PLAIN,
+ .attalign = TYPALIGN_INT,
.attnotnull = true,
.attislocal = true,
};
.attcacheoff = -1,
.atttypmod = -1,
.attbyval = true,
- .attstorage = 'p',
- .attalign = 'i',
+ .attstorage = TYPSTORAGE_PLAIN,
+ .attalign = TYPALIGN_INT,
.attnotnull = true,
.attislocal = true,
};
.attcacheoff = -1,
.atttypmod = -1,
.attbyval = true,
- .attstorage = 'p',
- .attalign = 'i',
+ .attstorage = TYPSTORAGE_PLAIN,
+ .attalign = TYPALIGN_INT,
.attnotnull = true,
.attislocal = true,
};
NULL, /* default value - none */
NULL, /* default binary representation */
false, /* passed by reference */
- 'd', /* alignment - must be the largest! */
- 'x', /* fully TOASTable */
+ TYPALIGN_DOUBLE, /* alignment - must be the largest! */
+ TYPSTORAGE_EXTENDED, /* fully TOASTable */
-1, /* typmod */
0, /* array dimensions for typBaseType */
false, /* Type NOT NULL */
NULL, /* default value - none */
NULL, /* default binary representation */
false, /* passed by reference */
- 'd', /* alignment - must be the largest! */
- 'x', /* fully TOASTable */
+ TYPALIGN_DOUBLE, /* alignment - must be the largest! */
+ TYPSTORAGE_EXTENDED, /* fully TOASTable */
-1, /* typmod */
0, /* array dimensions for typBaseType */
false, /* Type NOT NULL */
List *list = NIL;
int i;
- deconstruct_array(arr, TEXTOID, -1, false, 'i',
+ deconstruct_array(arr, TEXTOID, -1, false, TYPALIGN_INT,
&elems, &nulls, &nelems);
for (i = 0; i < nelems; i++)
bool *nulls;
int nelems;
- deconstruct_array(namearr, TEXTOID, -1, false, 'i',
+ deconstruct_array(namearr, TEXTOID, -1, false, TYPALIGN_INT,
&elems, &nulls, &nelems);
if (nelems != 1)
ereport(ERROR,
bool *nulls;
int nelems;
- deconstruct_array(namearr, TEXTOID, -1, false, 'i',
+ deconstruct_array(namearr, TEXTOID, -1, false, TYPALIGN_INT,
&elems, &nulls, &nelems);
if (nelems != 1)
ereport(ERROR,
int nelems;
int i;
- deconstruct_array(argsarr, TEXTOID, -1, false, 'i',
+ deconstruct_array(argsarr, TEXTOID, -1, false, TYPALIGN_INT,
&elems, &nulls, &nelems);
args = NIL;
lb[0] = 1;
arr = construct_md_array(datums, nulls, 1, &j,
- lb, TEXTOID, -1, false, 'i');
+ lb, TEXTOID, -1, false, TYPALIGN_INT);
MemoryContextDelete(memcxt);
for (i = 0; i < constraintNKeys; i++)
conkey[i] = Int16GetDatum(constraintKey[i]);
conkeyArray = construct_array(conkey, constraintNKeys,
- INT2OID, 2, true, 's');
+ INT2OID, 2, true, TYPALIGN_SHORT);
}
else
conkeyArray = NULL;
for (i = 0; i < foreignNKeys; i++)
fkdatums[i] = Int16GetDatum(foreignKey[i]);
confkeyArray = construct_array(fkdatums, foreignNKeys,
- INT2OID, 2, true, 's');
+ INT2OID, 2, true, TYPALIGN_SHORT);
for (i = 0; i < foreignNKeys; i++)
fkdatums[i] = ObjectIdGetDatum(pfEqOp[i]);
conpfeqopArray = construct_array(fkdatums, foreignNKeys,
- OIDOID, sizeof(Oid), true, 'i');
+ OIDOID, sizeof(Oid), true, TYPALIGN_INT);
for (i = 0; i < foreignNKeys; i++)
fkdatums[i] = ObjectIdGetDatum(ppEqOp[i]);
conppeqopArray = construct_array(fkdatums, foreignNKeys,
- OIDOID, sizeof(Oid), true, 'i');
+ OIDOID, sizeof(Oid), true, TYPALIGN_INT);
for (i = 0; i < foreignNKeys; i++)
fkdatums[i] = ObjectIdGetDatum(ffEqOp[i]);
conffeqopArray = construct_array(fkdatums, foreignNKeys,
- OIDOID, sizeof(Oid), true, 'i');
+ OIDOID, sizeof(Oid), true, TYPALIGN_INT);
}
else
{
for (i = 0; i < constraintNKeys; i++)
opdatums[i] = ObjectIdGetDatum(exclOp[i]);
conexclopArray = construct_array(opdatums, constraintNKeys,
- OIDOID, sizeof(Oid), true, 'i');
+ OIDOID, sizeof(Oid), true, TYPALIGN_INT);
}
else
conexclopArray = NULL;
deconstruct_array(array,
OIDOID,
- sizeof(Oid), true, 'i',
+ sizeof(Oid), true, TYPALIGN_INT,
&values, NULL, &nelems);
for (i = 0; i < nelems; i++)
result = lappend_oid(result, values[i]);
List *res = NIL;
deconstruct_array(textarray,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&elems, NULL, &nelems);
if (nelems == 0)
values[Anum_pg_type_typmodin - 1] = ObjectIdGetDatum(InvalidOid);
values[Anum_pg_type_typmodout - 1] = ObjectIdGetDatum(InvalidOid);
values[Anum_pg_type_typanalyze - 1] = ObjectIdGetDatum(InvalidOid);
- values[Anum_pg_type_typalign - 1] = CharGetDatum('i');
- values[Anum_pg_type_typstorage - 1] = CharGetDatum('p');
+ values[Anum_pg_type_typalign - 1] = CharGetDatum(TYPALIGN_INT);
+ values[Anum_pg_type_typstorage - 1] = CharGetDatum(TYPSTORAGE_PLAIN);
values[Anum_pg_type_typnotnull - 1] = BoolGetDatum(false);
values[Anum_pg_type_typbasetype - 1] = ObjectIdGetDatum(InvalidOid);
values[Anum_pg_type_typtypmod - 1] = Int32GetDatum(-1);
*/
if (internalSize == (int16) sizeof(char))
{
- if (alignment != 'c')
+ if (alignment != TYPALIGN_CHAR)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("alignment \"%c\" is invalid for passed-by-value type of size %d",
}
else if (internalSize == (int16) sizeof(int16))
{
- if (alignment != 's')
+ if (alignment != TYPALIGN_SHORT)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("alignment \"%c\" is invalid for passed-by-value type of size %d",
}
else if (internalSize == (int16) sizeof(int32))
{
- if (alignment != 'i')
+ if (alignment != TYPALIGN_INT)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("alignment \"%c\" is invalid for passed-by-value type of size %d",
#if SIZEOF_DATUM == 8
else if (internalSize == (int16) sizeof(Datum))
{
- if (alignment != 'd')
+ if (alignment != TYPALIGN_DOUBLE)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("alignment \"%c\" is invalid for passed-by-value type of size %d",
else
{
/* varlena types must have int align or better */
- if (internalSize == -1 && !(alignment == 'i' || alignment == 'd'))
+ if (internalSize == -1 &&
+ !(alignment == TYPALIGN_INT || alignment == TYPALIGN_DOUBLE))
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("alignment \"%c\" is invalid for variable-length type",
alignment)));
/* cstring must have char alignment */
- if (internalSize == -2 && !(alignment == 'c'))
+ if (internalSize == -2 && !(alignment == TYPALIGN_CHAR))
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("alignment \"%c\" is invalid for variable-length type",
}
/* Only varlena types can be toasted */
- if (storage != 'p' && internalSize != -1)
+ if (storage != TYPSTORAGE_PLAIN && internalSize != -1)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("fixed-size types must have storage PLAIN")));
* toast :-(. This is essential for chunk_data because type bytea is
* toastable; hit the other two just to be sure.
*/
- TupleDescAttr(tupdesc, 0)->attstorage = 'p';
- TupleDescAttr(tupdesc, 1)->attstorage = 'p';
- TupleDescAttr(tupdesc, 2)->attstorage = 'p';
+ TupleDescAttr(tupdesc, 0)->attstorage = TYPSTORAGE_PLAIN;
+ TupleDescAttr(tupdesc, 1)->attstorage = TYPSTORAGE_PLAIN;
+ TupleDescAttr(tupdesc, 2)->attstorage = TYPSTORAGE_PLAIN;
/*
* Toast tables for regular relations go in pg_toast; those for temp
/* XXX knows more than it should about type float4: */
arry = construct_array(numdatums, nnum,
FLOAT4OID,
- sizeof(float4), true, 'i');
+ sizeof(float4), true, TYPALIGN_INT);
values[i++] = PointerGetDatum(arry); /* stanumbersN */
}
else
pfree(result);
}
- return PointerGetDatum(construct_array(data, l, TEXTOID, -1, false, 'i'));
+ return PointerGetDatum(construct_array(data, l, TEXTOID,
+ -1, false, TYPALIGN_INT));
}
/*
}
a = construct_array(datums, ndatums,
NAMEOID,
- NAMEDATALEN, false, 'c');
+ NAMEDATALEN, false, TYPALIGN_CHAR);
return PointerGetDatum(a);
}
a = construct_array(&elementDatum, 1,
OIDOID,
- sizeof(Oid), true, 'i');
+ sizeof(Oid), true, TYPALIGN_INT);
}
else
{
-1 /* varlena array */ ,
sizeof(Oid) /* OID's typlen */ ,
true /* OID's typbyval */ ,
- 'i' /* OID's typalign */ );
+ TYPALIGN_INT /* OID's typalign */ );
}
repl_val[Anum_pg_extension_extconfig - 1] = PointerGetDatum(a);
repl_repl[Anum_pg_extension_extconfig - 1] = true;
a = construct_array(&elementDatum, 1,
TEXTOID,
- -1, false, 'i');
+ -1, false, TYPALIGN_INT);
}
else
{
-1 /* varlena array */ ,
-1 /* TEXT's typlen */ ,
false /* TEXT's typbyval */ ,
- 'i' /* TEXT's typalign */ );
+ TYPALIGN_INT /* TEXT's typalign */ );
}
repl_val[Anum_pg_extension_extcondition - 1] = PointerGetDatum(a);
repl_repl[Anum_pg_extension_extcondition - 1] = true;
int i;
/* We already checked there are no nulls */
- deconstruct_array(a, OIDOID, sizeof(Oid), true, 'i',
+ deconstruct_array(a, OIDOID, sizeof(Oid), true, TYPALIGN_INT,
&dvalues, NULL, &nelems);
for (i = arrayIndex; i < arrayLength - 1; i++)
dvalues[i] = dvalues[i + 1];
a = construct_array(dvalues, arrayLength - 1,
- OIDOID, sizeof(Oid), true, 'i');
+ OIDOID, sizeof(Oid), true, TYPALIGN_INT);
repl_val[Anum_pg_extension_extconfig - 1] = PointerGetDatum(a);
}
int i;
/* We already checked there are no nulls */
- deconstruct_array(a, TEXTOID, -1, false, 'i',
+ deconstruct_array(a, TEXTOID, -1, false, TYPALIGN_INT,
&dvalues, NULL, &nelems);
for (i = arrayIndex; i < arrayLength - 1; i++)
dvalues[i] = dvalues[i + 1];
a = construct_array(dvalues, arrayLength - 1,
- TEXTOID, -1, false, 'i');
+ TEXTOID, -1, false, TYPALIGN_INT);
repl_val[Anum_pg_extension_extcondition - 1] = PointerGetDatum(a);
}
if (outCount > 0 || varCount > 0)
{
*allParameterTypes = construct_array(allTypes, parameterCount, OIDOID,
- sizeof(Oid), true, 'i');
+ sizeof(Oid), true, TYPALIGN_INT);
*parameterModes = construct_array(paramModes, parameterCount, CHAROID,
- 1, true, 'c');
+ 1, true, TYPALIGN_CHAR);
if (outCount > 1)
*requiredResultType = RECORDOID;
/* otherwise we set requiredResultType correctly above */
paramNames[i] = CStringGetTextDatum("");
}
*parameterNames = construct_array(paramNames, parameterCount, TEXTOID,
- -1, false, 'i');
+ -1, false, TYPALIGN_INT);
}
else
*parameterNames = NULL;
foreach(lc, trftypes_list)
arr[i++] = ObjectIdGetDatum(lfirst_oid(lc));
trftypes = construct_array(arr, list_length(trftypes_list),
- OIDOID, sizeof(Oid), true, 'i');
+ OIDOID, sizeof(Oid), true, TYPALIGN_INT);
}
else
{
/* This is the array for the new tuple */
role_ids = construct_array(role_oids, num_roles, OIDOID,
- sizeof(Oid), true, 'i');
+ sizeof(Oid), true, TYPALIGN_INT);
replaces[Anum_pg_policy_polroles - 1] = true;
values[Anum_pg_policy_polroles - 1] = PointerGetDatum(role_ids);
/* Collect role ids */
role_oids = policy_role_list_to_array(stmt->roles, &nitems);
role_ids = construct_array(role_oids, nitems, OIDOID,
- sizeof(Oid), true, 'i');
+ sizeof(Oid), true, TYPALIGN_INT);
/* Parse the supplied clause */
qual_pstate = make_parsestate(NULL);
{
role_oids = policy_role_list_to_array(stmt->roles, &nitems);
role_ids = construct_array(role_oids, nitems, OIDOID,
- sizeof(Oid), true, 'i');
+ sizeof(Oid), true, TYPALIGN_INT);
}
/* Get id of table. Also handles permissions checks. */
tmp_ary[i] = ObjectIdGetDatum(param_types[i]);
/* XXX: this hardcodes assumptions about the regtype type */
- result = construct_array(tmp_ary, num_params, REGTYPEOID, 4, true, 'i');
+ result = construct_array(tmp_ary, num_params, REGTYPEOID,
+ 4, true, TYPALIGN_INT);
return PointerGetDatum(result);
}
if (build_mcv)
types[ntypes++] = CharGetDatum(STATS_EXT_MCV);
Assert(ntypes > 0 && ntypes <= lengthof(types));
- stxkind = construct_array(types, ntypes, CHAROID, 1, true, 'c');
+ stxkind = construct_array(types, ntypes, CHAROID, 1, true, TYPALIGN_CHAR);
statrel = table_open(StatisticExtRelationId, RowExclusiveLock);
MemoryContextSwitchTo(oldcxt);
arr = construct_array(datums, list_length(publist),
- TEXTOID, -1, false, 'i');
+ TEXTOID, -1, false, TYPALIGN_INT);
MemoryContextDelete(memcxt);
{
switch (c)
{
- case 'p':
+ case TYPSTORAGE_PLAIN:
return "PLAIN";
- case 'm':
- return "MAIN";
- case 'x':
- return "EXTENDED";
- case 'e':
+ case TYPSTORAGE_EXTERNAL:
return "EXTERNAL";
+ case TYPSTORAGE_EXTENDED:
+ return "EXTENDED";
+ case TYPSTORAGE_MAIN:
+ return "MAIN";
default:
return "???";
}
storagemode = strVal(newValue);
if (pg_strcasecmp(storagemode, "plain") == 0)
- newstorage = 'p';
+ newstorage = TYPSTORAGE_PLAIN;
else if (pg_strcasecmp(storagemode, "external") == 0)
- newstorage = 'e';
+ newstorage = TYPSTORAGE_EXTERNAL;
else if (pg_strcasecmp(storagemode, "extended") == 0)
- newstorage = 'x';
+ newstorage = TYPSTORAGE_EXTENDED;
else if (pg_strcasecmp(storagemode, "main") == 0)
- newstorage = 'm';
+ newstorage = TYPSTORAGE_MAIN;
else
{
ereport(ERROR,
* safety check: do not allow toasted storage modes unless column datatype
* is TOAST-aware.
*/
- if (newstorage == 'p' || TypeIsToastable(attrtuple->atttypid))
+ if (newstorage == TYPSTORAGE_PLAIN || TypeIsToastable(attrtuple->atttypid))
attrtuple->attstorage = newstorage;
else
ereport(ERROR,
Oid elemType = InvalidOid;
char *defaultValue = NULL;
bool byValue = false;
- char alignment = 'i'; /* default alignment */
- char storage = 'p'; /* default TOAST storage method */
+ char alignment = TYPALIGN_INT; /* default alignment */
+ char storage = TYPSTORAGE_PLAIN; /* default TOAST storage method */
Oid collation = InvalidOid;
DefElem *likeTypeEl = NULL;
DefElem *internalLengthEl = NULL;
if (pg_strcasecmp(a, "double") == 0 ||
pg_strcasecmp(a, "float8") == 0 ||
pg_strcasecmp(a, "pg_catalog.float8") == 0)
- alignment = 'd';
+ alignment = TYPALIGN_DOUBLE;
else if (pg_strcasecmp(a, "int4") == 0 ||
pg_strcasecmp(a, "pg_catalog.int4") == 0)
- alignment = 'i';
+ alignment = TYPALIGN_INT;
else if (pg_strcasecmp(a, "int2") == 0 ||
pg_strcasecmp(a, "pg_catalog.int2") == 0)
- alignment = 's';
+ alignment = TYPALIGN_SHORT;
else if (pg_strcasecmp(a, "char") == 0 ||
pg_strcasecmp(a, "pg_catalog.bpchar") == 0)
- alignment = 'c';
+ alignment = TYPALIGN_CHAR;
else
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
char *a = defGetString(storageEl);
if (pg_strcasecmp(a, "plain") == 0)
- storage = 'p';
+ storage = TYPSTORAGE_PLAIN;
else if (pg_strcasecmp(a, "external") == 0)
- storage = 'e';
+ storage = TYPSTORAGE_EXTERNAL;
else if (pg_strcasecmp(a, "extended") == 0)
- storage = 'x';
+ storage = TYPSTORAGE_EXTENDED;
else if (pg_strcasecmp(a, "main") == 0)
- storage = 'm';
+ storage = TYPSTORAGE_MAIN;
else
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
*/
array_type = makeArrayTypeName(typeName, typeNamespace);
- /* alignment must be 'i' or 'd' for arrays */
- alignment = (alignment == 'd') ? 'd' : 'i';
+ /* alignment must be TYPALIGN_INT or TYPALIGN_DOUBLE for arrays */
+ alignment = (alignment == TYPALIGN_DOUBLE) ? TYPALIGN_DOUBLE : TYPALIGN_INT;
TypeCreate(array_oid, /* force assignment of this type OID */
array_type, /* type name */
NULL, /* binary default isn't sent either */
false, /* never passed by value */
alignment, /* see above */
- 'x', /* ARRAY is always toastable */
+ TYPSTORAGE_EXTENDED, /* ARRAY is always toastable */
-1, /* typMod (Domains only) */
0, /* Array dimensions of typbasetype */
false, /* Type NOT NULL */
*/
domainArrayName = makeArrayTypeName(domainName, domainNamespace);
- /* alignment must be 'i' or 'd' for arrays */
- alignment = (alignment == 'd') ? 'd' : 'i';
+ /* alignment must be TYPALIGN_INT or TYPALIGN_DOUBLE for arrays */
+ alignment = (alignment == TYPALIGN_DOUBLE) ? TYPALIGN_DOUBLE : TYPALIGN_INT;
TypeCreate(domainArrayOid, /* force assignment of this type OID */
domainArrayName, /* type name */
NULL, /* binary default isn't sent either */
false, /* never passed by value */
alignment, /* see above */
- 'x', /* ARRAY is always toastable */
+ TYPSTORAGE_EXTENDED, /* ARRAY is always toastable */
-1, /* typMod (Domains only) */
0, /* Array dimensions of typbasetype */
false, /* Type NOT NULL */
NULL, /* never a default type value */
NULL, /* binary default isn't sent either */
true, /* always passed by value */
- 'i', /* int alignment */
- 'p', /* TOAST strategy always plain */
+ TYPALIGN_INT, /* int alignment */
+ TYPSTORAGE_PLAIN, /* TOAST strategy always plain */
-1, /* typMod (Domains only) */
0, /* Array dimensions of typbasetype */
false, /* Type NOT NULL */
NULL, /* never a default type value */
NULL, /* binary default isn't sent either */
false, /* never passed by value */
- 'i', /* enums have align i, so do their arrays */
- 'x', /* ARRAY is always toastable */
+ TYPALIGN_INT, /* enums have int align, so do their arrays */
+ TYPSTORAGE_EXTENDED, /* ARRAY is always toastable */
-1, /* typMod (Domains only) */
0, /* Array dimensions of typbasetype */
false, /* Type NOT NULL */
get_typlenbyvalalign(rangeSubtype,
&subtyplen, &subtypbyval, &subtypalign);
- /* alignment must be 'i' or 'd' for ranges */
- alignment = (subtypalign == 'd') ? 'd' : 'i';
+ /* alignment must be TYPALIGN_INT or TYPALIGN_DOUBLE for ranges */
+ alignment = (subtypalign == TYPALIGN_DOUBLE) ? TYPALIGN_DOUBLE : TYPALIGN_INT;
/* Allocate OID for array type */
rangeArrayOid = AssignTypeArrayOid();
NULL, /* no binary form available either */
false, /* never passed by value */
alignment, /* alignment */
- 'x', /* TOAST strategy (always extended) */
+ TYPSTORAGE_EXTENDED, /* TOAST strategy (always extended) */
-1, /* typMod (Domains only) */
0, /* Array dimensions of typbasetype */
false, /* Type NOT NULL */
NULL, /* binary default isn't sent either */
false, /* never passed by value */
alignment, /* alignment - same as range's */
- 'x', /* ARRAY is always toastable */
+ TYPSTORAGE_EXTENDED, /* ARRAY is always toastable */
-1, /* typMod (Domains only) */
0, /* Array dimensions of typbasetype */
false, /* Type NOT NULL */
continue;
itemarray = DatumGetArrayTypeP(arraydatum);
deconstruct_array(itemarray,
- TIDOID, sizeof(ItemPointerData), false, 's',
+ TIDOID, sizeof(ItemPointerData), false, TYPALIGN_SHORT,
&ipdatums, &ipnulls, &ndatums);
if (numTids + ndatums > numAllocTids)
{
LLVMPositionBuilderAtEnd(b, attcheckalignblocks[attnum]);
/* determine required alignment */
- if (att->attalign == 'i')
+ if (att->attalign == TYPALIGN_INT)
alignto = ALIGNOF_INT;
- else if (att->attalign == 'c')
+ else if (att->attalign == TYPALIGN_CHAR)
alignto = 1;
- else if (att->attalign == 'd')
+ else if (att->attalign == TYPALIGN_DOUBLE)
alignto = ALIGNOF_DOUBLE;
- else if (att->attalign == 's')
+ else if (att->attalign == TYPALIGN_SHORT)
alignto = ALIGNOF_SHORT;
else
{
Assert(noptions <= MAX_HBA_OPTIONS);
if (noptions > 0)
- return construct_array(options, noptions, TEXTOID, -1, false, 'i');
+ return construct_array(options, noptions, TEXTOID, -1, false, TYPALIGN_INT);
else
return NULL;
}
/* hardwired knowledge about cstring's representation details here */
arrtypmod = construct_array(datums, n, CSTRINGOID,
- -2, false, 'c');
+ -2, false, TYPALIGN_CHAR);
/* arrange to report location if type's typmodin function fails */
setup_parser_errposition_callback(&pcbstate, pstate, typeName->location);
constraintId);
deconstruct_array(DatumGetArrayTypeP(datum),
- OIDOID, sizeof(Oid), true, 'i',
+ OIDOID, sizeof(Oid), true, TYPALIGN_INT,
&elems, NULL, &nElems);
for (i = 0; i < nElems; i++)
Assert(ARR_ELEMTYPE(arr) == TEXTOID);
- deconstruct_array(arr, TEXTOID, -1, false, 'i',
+ deconstruct_array(arr, TEXTOID, -1, false, TYPALIGN_INT,
&datum_opts, NULL, &nelems);
if (nelems % 2 != 0)
TEXTOID,
-1,
false,
- 'i');
+ TYPALIGN_INT);
ptr = res;
while (ptr->lexeme)
/* hardwired knowledge about cstring's representation details here */
deconstruct_array(arr, CSTRINGOID,
- -2, false, 'c',
+ -2, false, TYPALIGN_CHAR,
&elem_values, NULL, n);
result = (int32 *) palloc(*n * sizeof(int32));
/* and build the result array */
/* note this hardwires some details about the representation of Oid */
- result = construct_array(elems, cnt, enumtypoid, sizeof(Oid), true, 'i');
+ result = construct_array(elems, cnt, enumtypoid,
+ sizeof(Oid), true, TYPALIGN_INT);
pfree(elems);
result = construct_array(transdatums, 3,
FLOAT8OID,
- sizeof(float8), FLOAT8PASSBYVAL, 'd');
+ sizeof(float8), FLOAT8PASSBYVAL, TYPALIGN_DOUBLE);
PG_RETURN_ARRAYTYPE_P(result);
}
result = construct_array(transdatums, 3,
FLOAT8OID,
- sizeof(float8), FLOAT8PASSBYVAL, 'd');
+ sizeof(float8), FLOAT8PASSBYVAL, TYPALIGN_DOUBLE);
PG_RETURN_ARRAYTYPE_P(result);
}
result = construct_array(transdatums, 3,
FLOAT8OID,
- sizeof(float8), FLOAT8PASSBYVAL, 'd');
+ sizeof(float8), FLOAT8PASSBYVAL, TYPALIGN_DOUBLE);
PG_RETURN_ARRAYTYPE_P(result);
}
result = construct_array(transdatums, 6,
FLOAT8OID,
- sizeof(float8), FLOAT8PASSBYVAL, 'd');
+ sizeof(float8), FLOAT8PASSBYVAL, TYPALIGN_DOUBLE);
PG_RETURN_ARRAYTYPE_P(result);
}
result = construct_array(transdatums, 6,
FLOAT8OID,
- sizeof(float8), FLOAT8PASSBYVAL, 'd');
+ sizeof(float8), FLOAT8PASSBYVAL, TYPALIGN_DOUBLE);
PG_RETURN_ARRAYTYPE_P(result);
}
*/
array_base_type = typeform->typelem;
- if (array_base_type != InvalidOid && typeform->typstorage != 'p')
+ if (array_base_type != InvalidOid &&
+ typeform->typstorage != TYPSTORAGE_PLAIN)
{
/* Switch our attention to the array element type */
ReleaseSysCache(tuple);
}
deconstruct_array(in_array,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&in_datums, &in_nulls, &in_count);
count = in_count / 2;
PG_RETURN_DATUM(CStringGetTextDatum("{}"));
deconstruct_array(key_array,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&key_datums, &key_nulls, &key_count);
deconstruct_array(val_array,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&val_datums, &val_nulls, &val_count);
if (key_count != val_count)
}
deconstruct_array(in_array,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&in_datums, &in_nulls, &in_count);
count = in_count / 2;
goto close_object;
deconstruct_array(key_array,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&key_datums, &key_nulls, &key_count);
deconstruct_array(val_array,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&val_datums, &val_nulls, &val_count);
if (key_count != val_count)
j;
deconstruct_array(query,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&key_datums, &key_nulls, &key_count);
entries = (Datum *) palloc(sizeof(Datum) * key_count);
bool *key_nulls;
int elem_count;
- deconstruct_array(keys, TEXTOID, -1, false, 'i', &key_datums, &key_nulls,
- &elem_count);
+ deconstruct_array(keys, TEXTOID, -1, false, TYPALIGN_INT,
+ &key_datums, &key_nulls, &elem_count);
for (i = 0; i < elem_count; i++)
{
bool *key_nulls;
int elem_count;
- deconstruct_array(keys, TEXTOID, -1, false, 'i', &key_datums, &key_nulls,
- &elem_count);
+ deconstruct_array(keys, TEXTOID, -1, false, TYPALIGN_INT,
+ &key_datums, &key_nulls, &elem_count);
for (i = 0; i < elem_count; i++)
{
if (array_contains_nulls(path))
PG_RETURN_NULL();
- deconstruct_array(path, TEXTOID, -1, false, 'i',
+ deconstruct_array(path, TEXTOID, -1, false, TYPALIGN_INT,
&pathtext, &pathnulls, &npath);
tpath = palloc(npath * sizeof(char *));
if (array_contains_nulls(path))
PG_RETURN_NULL();
- deconstruct_array(path, TEXTOID, -1, false, 'i',
+ deconstruct_array(path, TEXTOID, -1, false, TYPALIGN_INT,
&pathtext, &pathnulls, &npath);
/* Identify whether we have object, array, or scalar at top-level */
if (JB_ROOT_COUNT(in) == 0)
PG_RETURN_JSONB_P(in);
- deconstruct_array(keys, TEXTOID, -1, false, 'i',
+ deconstruct_array(keys, TEXTOID, -1, false, TYPALIGN_INT,
&keys_elems, &keys_nulls, &keys_len);
if (keys_len == 0)
if (JB_ROOT_COUNT(in) == 0 && !create)
PG_RETURN_JSONB_P(in);
- deconstruct_array(path, TEXTOID, -1, false, 'i',
+ deconstruct_array(path, TEXTOID, -1, false, TYPALIGN_INT,
&path_elems, &path_nulls, &path_len);
if (path_len == 0)
if (JB_ROOT_COUNT(in) == 0)
PG_RETURN_JSONB_P(in);
- deconstruct_array(path, TEXTOID, -1, false, 'i',
+ deconstruct_array(path, TEXTOID, -1, false, TYPALIGN_INT,
&path_elems, &path_nulls, &path_len);
if (path_len == 0)
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("cannot set path in scalar")));
- deconstruct_array(path, TEXTOID, -1, false, 'i',
+ deconstruct_array(path, TEXTOID, -1, false, TYPALIGN_INT,
&path_elems, &path_nulls, &path_len);
if (path_len == 0)
/* Construct array, using hardwired knowledge about int4 type */
PG_RETURN_ARRAYTYPE_P(construct_array(arrayelems, narrayelems,
INT4OID,
- sizeof(int32), true, 'i'));
+ sizeof(int32), true, TYPALIGN_INT));
}
/* Construct array, using hardwired knowledge about int4 type */
PG_RETURN_ARRAYTYPE_P(construct_array(blocker_datums, num_blockers,
INT4OID,
- sizeof(int32), true, 'i'));
+ sizeof(int32), true, TYPALIGN_INT));
}
NAMEOID,
NAMEDATALEN, /* sizeof(Name) */
false, /* Name is not by-val */
- 'c'); /* alignment of Name */
+ TYPALIGN_CHAR); /* alignment of Name */
PG_RETURN_POINTER(array);
}
deconstruct_array(param, FLOAT8OID,
/* hard-wired info on type float8 */
- 8, FLOAT8PASSBYVAL, 'd',
+ sizeof(float8), FLOAT8PASSBYVAL, TYPALIGN_DOUBLE,
&percentiles_datum,
&percentiles_null,
&num_percentiles);
deconstruct_array(param, FLOAT8OID,
/* hard-wired info on type float8 */
- 8, FLOAT8PASSBYVAL, 'd',
+ sizeof(float8), FLOAT8PASSBYVAL, TYPALIGN_DOUBLE,
&percentiles_datum,
&percentiles_null,
&num_percentiles);
return percentile_cont_multi_final_common(fcinfo,
FLOAT8OID,
/* hard-wired info on type float8 */
- 8, FLOAT8PASSBYVAL, 'd',
+ sizeof(float8),
+ FLOAT8PASSBYVAL,
+ TYPALIGN_DOUBLE,
float8_lerp);
}
return percentile_cont_multi_final_common(fcinfo,
INTERVALOID,
/* hard-wired info on type interval */
- 16, false, 'd',
+ 16, false, TYPALIGN_DOUBLE,
interval_lerp);
}
int i;
deconstruct_array(textArray,
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&textDatums, NULL, &ndatums);
for (i = 0; i < ndatums; i++)
{
/* Does datatype allow packing into the 1-byte-header varlena format? */
#define TYPE_IS_PACKABLE(typlen, typstorage) \
- ((typlen) == -1 && (typstorage) != 'p')
+ ((typlen) == -1 && (typstorage) != TYPSTORAGE_PLAIN)
/*
* Increment data_length by the space needed by the datum, including any
else if (typlen == -2)
{
/* cstring ... never needs alignment */
- Assert(typalign == 'c');
+ Assert(typalign == TYPALIGN_CHAR);
data_length = strlen(DatumGetCString(datum)) + 1;
memcpy(ptr, DatumGetPointer(datum), data_length);
}
lbs[0] = 1;
/* XXX: this hardcodes assumptions about the text type */
return construct_md_array(elems, nulls, 1, dims, lbs,
- TEXTOID, -1, false, 'i');
+ TEXTOID, -1, false, TYPALIGN_INT);
}
/*
elog(ERROR, "null indkey for index %u", indexId);
deconstruct_array(DatumGetArrayTypeP(cols),
- INT2OID, 2, true, 's',
+ INT2OID, 2, true, TYPALIGN_SHORT,
&keys, NULL, &nKeys);
for (j = keyatts; j < nKeys; j++)
constraintId);
deconstruct_array(DatumGetArrayTypeP(val),
- OIDOID, sizeof(Oid), true, 'i',
+ OIDOID, sizeof(Oid), true, TYPALIGN_INT,
&elems, NULL, &nElems);
operators = (Oid *) palloc(nElems * sizeof(Oid));
/* Extract data from array of int16 */
deconstruct_array(DatumGetArrayTypeP(column_index_array),
- INT2OID, 2, true, 's',
+ INT2OID, 2, true, TYPALIGN_SHORT,
&keys, NULL, &nKeys);
for (j = 0; j < nKeys; j++)
-1 /* varlenarray */ ,
-1 /* TEXT's typlen */ ,
false /* TEXT's typbyval */ ,
- 'i' /* TEXT's typalign */ ,
+ TYPALIGN_INT /* TEXT's typalign */ ,
&isnull);
if (!isnull)
{
initStringInfo(&buf);
deconstruct_array(DatumGetArrayTypeP(reloptions),
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&options, NULL, &noptions);
for (i = 0; i < noptions; i++)
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");
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);
}
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");
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");
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);
}
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");
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);
}
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");
memcpy(tsout, tsin, VARSIZE(tsin));
entry = ARRPTR(tsout);
- deconstruct_array(lexemes, TEXTOID, -1, false, 'i',
+ deconstruct_array(lexemes, TEXTOID, -1, false, TYPALIGN_INT,
&dlexemes, &nulls, &nlexemes);
/*
Datum *dlexemes;
bool *nulls;
- deconstruct_array(lexemes, TEXTOID, -1, false, 'i',
+ deconstruct_array(lexemes, TEXTOID, -1, false, TYPALIGN_INT,
&dlexemes, &nulls, &nlex);
/*
}
values[1] = PointerGetDatum(construct_array(positions, posv->npos,
- INT2OID, 2, true, 's'));
+ INT2OID, 2, true, TYPALIGN_SHORT));
values[2] = PointerGetDatum(construct_array(weights, posv->npos,
- TEXTOID, -1, false, 'i'));
+ TEXTOID, -1, false, TYPALIGN_INT));
}
else
{
arrin[i].len));
}
- array = construct_array(elements, tsin->size, TEXTOID, -1, false, 'i');
+ array = construct_array(elements, tsin->size, TEXTOID, -1, false, TYPALIGN_INT);
pfree(elements);
PG_FREE_IF_COPY(tsin, 0);
datalen = 0;
char *cur;
- deconstruct_array(v, TEXTOID, -1, false, 'i', &dlexemes, &nulls, &nitems);
+ deconstruct_array(v, TEXTOID, -1, false, TYPALIGN_INT, &dlexemes, &nulls, &nitems);
/* Reject nulls (maybe we should just ignore them, instead?) */
for (i = 0; i < nitems; i++)
int cur_pos = 0;
char mask = 0;
- deconstruct_array(weights, CHAROID, 1, true, 'c',
+ deconstruct_array(weights, CHAROID, 1, true, TYPALIGN_CHAR,
&dweights, &nulls, &nweights);
for (i = 0; i < nweights; i++)
/* XXX: this hardcodes assumptions about the text type */
PG_RETURN_ARRAYTYPE_P(construct_md_array(elems, nulls,
1, dims, lbs,
- TEXTOID, -1, false, 'i'));
+ TEXTOID, -1, false, TYPALIGN_INT));
}
text_position_setup(inputstring, fldsep, PG_GET_COLLATION(), &state);
Assert(ARR_ELEMTYPE(namespaces) == TEXTOID);
- deconstruct_array(namespaces, TEXTOID, -1, false, 'i',
+ deconstruct_array(namespaces, TEXTOID, -1, false, TYPALIGN_INT,
&ns_names_uris, &ns_names_uris_nulls,
&ns_count);
if (ARR_NDIM(arr) != 1 || ARR_HASNULL(arr) || ARR_ELEMTYPE(arr) != TEXTOID)
elog(ERROR, "expected 1-D text array");
- deconstruct_array(arr, TEXTOID, -1, false, 'i', &elems, NULL, &nelems);
+ deconstruct_array(arr, TEXTOID, -1, false, TYPALIGN_INT,
+ &elems, NULL, &nelems);
for (bms = NULL, i = 0; i < nelems; ++i)
{
return result;
}
else
- return 'i';
+ return TYPALIGN_INT;
}
#endif
return result;
}
else
- return 'p';
+ return TYPSTORAGE_PLAIN;
}
/*
else
{
deconstruct_array(DatumGetArrayTypeP(proargnames),
- TEXTOID, -1, false, 'i',
+ TEXTOID, -1, false, TYPALIGN_INT,
&elems, NULL, &nelems);
if (nelems != numargs) /* should not happen */
elog(ERROR, "proargnames must have the same number of elements as the function has arguments");
ARR_HASNULL(arr) ||
ARR_ELEMTYPE(arr) != TEXTOID)
elog(ERROR, "proargnames is not a 1-D text array");
- deconstruct_array(arr, TEXTOID, -1, false, 'i',
+ deconstruct_array(arr, TEXTOID, -1, false, TYPALIGN_INT,
&argnames, NULL, &numargs);
if (proargmodes != PointerGetDatum(NULL))
{
ARR_HASNULL(arr) ||
ARR_ELEMTYPE(arr) != TEXTOID)
elog(ERROR, "proargnames is not a 1-D text array");
- deconstruct_array(arr, TEXTOID, -1, false, 'i',
+ deconstruct_array(arr, TEXTOID, -1, false, TYPALIGN_INT,
&argnames, NULL, &nargnames);
Assert(nargnames == numargs);
ARR_HASNULL(arr) ||
ARR_ELEMTYPE(arr) != TEXTOID)
elog(ERROR, "proargnames is not a 1-D text array");
- deconstruct_array(arr, TEXTOID, -1, false, 'i',
+ deconstruct_array(arr, TEXTOID, -1, false, TYPALIGN_INT,
&argnames, NULL, &nargnames);
Assert(nargnames == numargs);
}
-1 /* varlenarray */ ,
-1 /* TEXT's typlen */ ,
false /* TEXT's typbyval */ ,
- 'i' /* TEXT's typalign */ ,
+ TYPALIGN_INT /* TEXT's typalign */ ,
&isnull);
if (isnull)
-1 /* varlenarray */ ,
-1 /* TEXT's typlen */ ,
false /* TEXT's typbyval */ ,
- 'i' /* TEXT's typalign */ ,
+ TYPALIGN_INT /* TEXT's typalign */ ,
&isnull);
if (isnull)
continue;
-1 /* varlena array */ ,
-1 /* TEXT's typlen */ ,
false /* TEXT's typbyval */ ,
- 'i' /* TEXT's typalign */ );
+ TYPALIGN_INT /* TEXT's typalign */ );
}
else
a = construct_array(&datum, 1,
TEXTOID,
- -1, false, 'i');
+ -1, false, TYPALIGN_INT);
return a;
}
-1 /* varlenarray */ ,
-1 /* TEXT's typlen */ ,
false /* TEXT's typbyval */ ,
- 'i' /* TEXT's typalign */ ,
+ TYPALIGN_INT /* TEXT's typalign */ ,
&isnull);
if (isnull)
continue;
-1 /* varlenarray */ ,
-1 /* TEXT's typlen */ ,
false /* TEXT's typbyval */ ,
- 'i' /* TEXT's typalign */ );
+ TYPALIGN_INT /* TEXT's typalign */ );
else
newarray = construct_array(&d, 1,
TEXTOID,
- -1, false, 'i');
+ -1, false, TYPALIGN_INT);
index++;
}
-1 /* varlenarray */ ,
-1 /* TEXT's typlen */ ,
false /* TEXT's typbyval */ ,
- 'i' /* TEXT's typalign */ ,
+ TYPALIGN_INT /* TEXT's typalign */ ,
&isnull);
if (isnull)
continue;
-1 /* varlenarray */ ,
-1 /* TEXT's typlen */ ,
false /* TEXT's typbyval */ ,
- 'i' /* TEXT's typalign */ );
+ TYPALIGN_INT /* TEXT's typalign */ );
else
newarray = construct_array(&d, 1,
TEXTOID,
- -1, false, 'i');
+ -1, false, TYPALIGN_INT);
index++;
pfree(val);
appendStringLiteralAH(q, typdelim, fout);
}
- if (strcmp(typalign, "c") == 0)
+ if (*typalign == TYPALIGN_CHAR)
appendPQExpBufferStr(q, ",\n ALIGNMENT = char");
- else if (strcmp(typalign, "s") == 0)
+ else if (*typalign == TYPALIGN_SHORT)
appendPQExpBufferStr(q, ",\n ALIGNMENT = int2");
- else if (strcmp(typalign, "i") == 0)
+ else if (*typalign == TYPALIGN_INT)
appendPQExpBufferStr(q, ",\n ALIGNMENT = int4");
- else if (strcmp(typalign, "d") == 0)
+ else if (*typalign == TYPALIGN_DOUBLE)
appendPQExpBufferStr(q, ",\n ALIGNMENT = double");
- if (strcmp(typstorage, "p") == 0)
+ if (*typstorage == TYPSTORAGE_PLAIN)
appendPQExpBufferStr(q, ",\n STORAGE = plain");
- else if (strcmp(typstorage, "e") == 0)
+ else if (*typstorage == TYPSTORAGE_EXTERNAL)
appendPQExpBufferStr(q, ",\n STORAGE = external");
- else if (strcmp(typstorage, "x") == 0)
+ else if (*typstorage == TYPSTORAGE_EXTENDED)
appendPQExpBufferStr(q, ",\n STORAGE = extended");
- else if (strcmp(typstorage, "m") == 0)
+ else if (*typstorage == TYPSTORAGE_MAIN)
appendPQExpBufferStr(q, ",\n STORAGE = main");
if (strcmp(typbyval, "t") == 0)
{
switch (tbinfo->attstorage[j])
{
- case 'p':
+ case TYPSTORAGE_PLAIN:
storage = "PLAIN";
break;
- case 'e':
+ case TYPSTORAGE_EXTERNAL:
storage = "EXTERNAL";
break;
- case 'm':
- storage = "MAIN";
- break;
- case 'x':
+ case TYPSTORAGE_EXTENDED:
storage = "EXTENDED";
break;
+ case TYPSTORAGE_MAIN:
+ storage = "MAIN";
+ break;
default:
storage = NULL;
}
* 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
{
#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.
*/
#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) \
))) \
)
/*----------
* attstorage tells for VARLENA attributes, what the heap access
* methods can do to it if a given tuple doesn't fit into a page.
- * Possible values are
- * 'p': Value must be stored plain always
- * 'e': Value can be stored in "secondary" relation (if relation
- * has one, see pg_class.reltoastrelid)
- * 'm': Value can be stored compressed inline
- * 'x': Value can be stored compressed inline or in "secondary"
- * Note that 'm' fields can also be moved out to secondary storage,
- * but only as a last resort ('e' and 'x' fields are moved first).
+ * Possible values are as for pg_type.typstorage (see TYPSTORAGE macros).
*----------
*/
char attstorage;
* 's' = SHORT alignment (2 bytes on most machines).
* 'i' = INT alignment (4 bytes on most machines).
* 'd' = DOUBLE alignment (8 bytes on many machines, but by no means all).
+ * (Use the TYPALIGN macros below for these.)
*
* See include/access/tupmacs.h for the macros that compute these
* alignment requirements. Note also that we allow the nominal alignment
* 'e' EXTERNAL external storage possible, don't try to compress
* 'x' EXTENDED try to compress and store external if required
* 'm' MAIN like 'x' but try to keep in main tuple
+ * (Use the TYPSTORAGE macros below for these.)
+ *
+ * Note that 'm' fields can also be moved out to secondary storage,
+ * but only as a last resort ('e' and 'x' fields are moved first).
* ----------------
*/
char typstorage BKI_DEFAULT(p) BKI_ARRAY_DEFAULT(x);
#define TYPCATEGORY_BITSTRING 'V' /* er ... "varbit"? */
#define TYPCATEGORY_UNKNOWN 'X'
+#define TYPALIGN_CHAR 'c' /* char alignment (i.e. unaligned) */
+#define TYPALIGN_SHORT 's' /* short alignment (typically 2 bytes) */
+#define TYPALIGN_INT 'i' /* int alignment (typically 4 bytes) */
+#define TYPALIGN_DOUBLE 'd' /* double alignment (often 8 bytes) */
+
+#define TYPSTORAGE_PLAIN 'p' /* type not prepared for toasting */
+#define TYPSTORAGE_EXTERNAL 'e' /* toastable, don't try to compress */
+#define TYPSTORAGE_EXTENDED 'x' /* fully toastable */
+#define TYPSTORAGE_MAIN 'm' /* like 'x' but try to store inline */
+
/* Is a type OID a polymorphic pseudotype? (Beware of multiple evaluation) */
#define IsPolymorphicType(typid) \
((typid) == ANYELEMENTOID || \
/* type_is_array_domain accepts both plain arrays and domains over arrays */
#define type_is_array_domain(typid) (get_base_element_type(typid) != InvalidOid)
-#define TypeIsToastable(typid) (get_typstorage(typid) != 'p')
+#define TypeIsToastable(typid) (get_typstorage(typid) != TYPSTORAGE_PLAIN)
#endif /* LSYSCACHE_H */
*/
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
PointerGetDatum(construct_md_array(elems, NULL,
1, dims, lbs,
TEXTOID,
- -1, false, 'i')),
+ -1, false, TYPALIGN_INT)),
false, true);
}
else
/* hard-wired knowledge about type RECORD: */
arg->typbyval = false;
arg->typlen = -1;
- arg->typalign = 'd';
+ arg->typalign = TYPALIGN_DOUBLE;
}
/*
/* hard-wired knowledge about type RECORD: */
arg->typbyval = false;
arg->typlen = -1;
- arg->typalign = 'd';
+ arg->typalign = TYPALIGN_DOUBLE;
}
/*
policy->policy_name = pstrdup("extension policy");
policy->polcmd = '*';
- policy->roles = construct_array(&role, 1, OIDOID, sizeof(Oid), true, 'i');
+ policy->roles = construct_array(&role, 1, OIDOID, sizeof(Oid), true, TYPALIGN_INT);
/*
* policy->qual = (Expr *) makeConst(BOOLOID, -1, InvalidOid,
policy->policy_name = pstrdup("extension policy");
policy->polcmd = '*';
- policy->roles = construct_array(&role, 1, OIDOID, sizeof(Oid), true, 'i');
+ policy->roles = construct_array(&role, 1, OIDOID, sizeof(Oid), true, TYPALIGN_INT);
n = makeFuncCall(list_make2(makeString("pg_catalog"),
makeString("current_user")), NIL, 0);