HeapTuple tuple;
Oid opfamily,
oprid;
- bool isNull;
opfamily = bdesc->bd_index->rd_opfamily[attno - 1];
attr = TupleDescAttr(bdesc->bd_tupdesc, attno - 1);
elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",
strategynum, attr->atttypid, subtype, opfamily);
- oprid = DatumGetObjectId(SysCacheGetAttr(AMOPSTRATEGY, tuple,
- Anum_pg_amop_amopopr, &isNull));
+ oprid = DatumGetObjectId(SysCacheGetAttrNotNull(AMOPSTRATEGY, tuple,
+ Anum_pg_amop_amopopr));
ReleaseSysCache(tuple);
- Assert(!isNull && RegProcedureIsValid(oprid));
+ Assert(RegProcedureIsValid(oprid));
fmgr_info_cxt(get_opcode(oprid),
&opaque->strategy_procinfos[strategynum - 1],
HeapTuple tuple;
Oid opfamily,
oprid;
- bool isNull;
opfamily = bdesc->bd_index->rd_opfamily[attno - 1];
attr = TupleDescAttr(bdesc->bd_tupdesc, attno - 1);
elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",
strategynum, attr->atttypid, subtype, opfamily);
- oprid = DatumGetObjectId(SysCacheGetAttr(AMOPSTRATEGY, tuple,
- Anum_pg_amop_amopopr, &isNull));
+ oprid = DatumGetObjectId(SysCacheGetAttrNotNull(AMOPSTRATEGY, tuple,
+ Anum_pg_amop_amopopr));
ReleaseSysCache(tuple);
- Assert(!isNull && RegProcedureIsValid(oprid));
+ Assert(RegProcedureIsValid(oprid));
fmgr_info_cxt(get_opcode(oprid),
&opaque->strategy_procinfos[strategynum - 1],
HeapTuple tuple;
Oid opfamily,
oprid;
- bool isNull;
opfamily = bdesc->bd_index->rd_opfamily[attno - 1];
attr = TupleDescAttr(bdesc->bd_tupdesc, attno - 1);
elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",
strategynum, attr->atttypid, subtype, opfamily);
- oprid = DatumGetObjectId(SysCacheGetAttr(AMOPSTRATEGY, tuple,
- Anum_pg_amop_amopopr, &isNull));
+ oprid = DatumGetObjectId(SysCacheGetAttrNotNull(AMOPSTRATEGY, tuple,
+ Anum_pg_amop_amopopr));
ReleaseSysCache(tuple);
- Assert(!isNull && RegProcedureIsValid(oprid));
+ Assert(RegProcedureIsValid(oprid));
fmgr_info_cxt(get_opcode(oprid),
&opaque->strategy_procinfos[strategynum - 1],
Oid opclass;
Datum indclassDatum;
oidvector *indclass;
- bool isnull;
if (!DatumGetPointer(attoptions))
return NULL; /* ok, no options, no procedure */
* Report an error if the opclass's options-parsing procedure does not
* exist but the opclass options are specified.
*/
- indclassDatum = SysCacheGetAttr(INDEXRELID, indrel->rd_indextuple,
- Anum_pg_index_indclass, &isnull);
- Assert(!isnull);
+ indclassDatum = SysCacheGetAttrNotNull(INDEXRELID, indrel->rd_indextuple,
+ Anum_pg_index_indclass);
indclass = (oidvector *) DatumGetPointer(indclassDatum);
opclass = indclass->values[attnum - 1];
* Get owner ID and working copy of existing ACL. If there's no ACL,
* substitute the proper default.
*/
- ownerId = DatumGetObjectId(SysCacheGetAttr(cacheid,
- tuple,
- get_object_attnum_owner(classid),
- &isNull));
- Assert(!isNull);
+ ownerId = DatumGetObjectId(SysCacheGetAttrNotNull(cacheid,
+ tuple,
+ get_object_attnum_owner(classid)));
aclDatum = SysCacheGetAttr(cacheid,
tuple,
get_object_attnum_acl(classid),
old_acl, ownerId,
&grantorId, &avail_goptions);
- nameDatum = SysCacheGetAttr(cacheid, tuple,
- get_object_attnum_name(classid),
- &isNull);
- Assert(!isNull);
+ nameDatum = SysCacheGetAttrNotNull(cacheid, tuple,
+ get_object_attnum_name(classid));
/*
* Restrict the privileges to what we can actually grant, and emit the
parameterId);
/* We'll need the GUC's name */
- nameDatum = SysCacheGetAttr(PARAMETERACLOID, tuple,
- Anum_pg_parameter_acl_parname,
- &isNull);
- Assert(!isNull);
+ nameDatum = SysCacheGetAttrNotNull(PARAMETERACLOID, tuple,
+ Anum_pg_parameter_acl_parname);
parname = TextDatumGetCString(nameDatum);
/* Treat all parameters as belonging to the bootstrap superuser. */
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("%s with OID %u does not exist", get_object_class_descr(classid), objectid)));
- ownerId = DatumGetObjectId(SysCacheGetAttr(cacheid,
- tuple,
- get_object_attnum_owner(classid),
- &isNull));
- Assert(!isNull);
+ ownerId = DatumGetObjectId(SysCacheGetAttrNotNull(cacheid,
+ tuple,
+ get_object_attnum_owner(classid)));
aclDatum = SysCacheGetAttr(cacheid, tuple, get_object_attnum_acl(classid),
&isNull);
if (cacheid != -1)
{
HeapTuple tuple;
- bool isnull;
tuple = SearchSysCache1(cacheid, ObjectIdGetDatum(objectid));
if (!HeapTupleIsValid(tuple))
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("%s with OID %u does not exist", get_object_class_descr(classid), objectid)));
- ownerId = DatumGetObjectId(SysCacheGetAttr(cacheid,
- tuple,
- get_object_attnum_owner(classid),
- &isnull));
- Assert(!isnull);
-
+ ownerId = DatumGetObjectId(SysCacheGetAttrNotNull(cacheid,
+ tuple,
+ get_object_attnum_owner(classid)));
ReleaseSysCache(tuple);
}
else
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(oldIndexId));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", oldIndexId);
- indclassDatum = SysCacheGetAttr(INDEXRELID, indexTuple,
- Anum_pg_index_indclass, &isnull);
- Assert(!isnull);
+ indclassDatum = SysCacheGetAttrNotNull(INDEXRELID, indexTuple,
+ Anum_pg_index_indclass);
indclass = (oidvector *) DatumGetPointer(indclassDatum);
- colOptionDatum = SysCacheGetAttr(INDEXRELID, indexTuple,
- Anum_pg_index_indoption, &isnull);
- Assert(!isnull);
+ colOptionDatum = SysCacheGetAttrNotNull(INDEXRELID, indexTuple,
+ Anum_pg_index_indoption);
indcoloptions = (int2vector *) DatumGetPointer(colOptionDatum);
/* Fetch options of index if any */
Datum exprDatum;
char *exprString;
- exprDatum = SysCacheGetAttr(INDEXRELID, indexTuple,
- Anum_pg_index_indexprs, &isnull);
- Assert(!isnull);
+ exprDatum = SysCacheGetAttrNotNull(INDEXRELID, indexTuple,
+ Anum_pg_index_indexprs);
exprString = TextDatumGetCString(exprDatum);
indexExprs = (List *) stringToNode(exprString);
pfree(exprString);
Datum predDatum;
char *predString;
- predDatum = SysCacheGetAttr(INDEXRELID, indexTuple,
- Anum_pg_index_indpred, &isnull);
- Assert(!isnull);
+ predDatum = SysCacheGetAttrNotNull(INDEXRELID, indexTuple,
+ Anum_pg_index_indpred);
predString = TextDatumGetCString(predDatum);
indexPreds = (List *) stringToNode(predString);
{
int cache;
HeapTuple tuple;
- bool isnull;
Oid oid;
const ObjectPropertyType *property;
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for cache %d oid %u",
cache, address->objectId);
- oid = DatumGetObjectId(SysCacheGetAttr(cache,
- tuple,
- property->attnum_namespace,
- &isnull));
- Assert(!isnull);
+ oid = DatumGetObjectId(SysCacheGetAttrNotNull(cache,
+ tuple,
+ property->attnum_namespace));
ReleaseSysCache(tuple);
return oid;
{
HeapTuple tup;
Datum nameDatum;
- bool isNull;
char *parname;
tup = SearchSysCache1(PARAMETERACLOID,
object->objectId);
break;
}
- nameDatum = SysCacheGetAttr(PARAMETERACLOID, tup,
- Anum_pg_parameter_acl_parname,
- &isNull);
- Assert(!isNull);
+ nameDatum = SysCacheGetAttrNotNull(PARAMETERACLOID, tup,
+ Anum_pg_parameter_acl_parname);
parname = TextDatumGetCString(nameDatum);
appendStringInfo(&buffer, _("parameter %s"), parname);
ReleaseSysCache(tup);
{
HeapTuple tup;
Datum nameDatum;
- bool isNull;
char *parname;
tup = SearchSysCache1(PARAMETERACLOID,
object->objectId);
break;
}
- nameDatum = SysCacheGetAttr(PARAMETERACLOID, tup,
- Anum_pg_parameter_acl_parname,
- &isNull);
- Assert(!isNull);
+ nameDatum = SysCacheGetAttrNotNull(PARAMETERACLOID, tup,
+ Anum_pg_parameter_acl_parname);
parname = TextDatumGetCString(nameDatum);
appendStringInfoString(&buffer, parname);
if (objname)
Oid *pf_eq_oprs, Oid *pp_eq_oprs, Oid *ff_eq_oprs,
int *num_fk_del_set_cols, AttrNumber *fk_del_set_cols)
{
- Oid constrId;
Datum adatum;
bool isNull;
ArrayType *arr;
int numkeys;
- constrId = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
-
/*
* We expect the arrays to be 1-D arrays of the right types; verify that.
* We don't need to use deconstruct_array() since the array data is just
* going to look like a C array of values.
*/
- adatum = SysCacheGetAttr(CONSTROID, tuple,
- Anum_pg_constraint_conkey, &isNull);
- if (isNull)
- elog(ERROR, "null conkey for constraint %u", constrId);
+ adatum = SysCacheGetAttrNotNull(CONSTROID, tuple,
+ Anum_pg_constraint_conkey);
arr = DatumGetArrayTypeP(adatum); /* ensure not toasted */
if (ARR_NDIM(arr) != 1 ||
ARR_HASNULL(arr) ||
if ((Pointer) arr != DatumGetPointer(adatum))
pfree(arr); /* free de-toasted copy, if any */
- adatum = SysCacheGetAttr(CONSTROID, tuple,
- Anum_pg_constraint_confkey, &isNull);
- if (isNull)
- elog(ERROR, "null confkey for constraint %u", constrId);
+ adatum = SysCacheGetAttrNotNull(CONSTROID, tuple,
+ Anum_pg_constraint_confkey);
arr = DatumGetArrayTypeP(adatum); /* ensure not toasted */
if (ARR_NDIM(arr) != 1 ||
ARR_DIMS(arr)[0] != numkeys ||
if (pf_eq_oprs)
{
- adatum = SysCacheGetAttr(CONSTROID, tuple,
- Anum_pg_constraint_conpfeqop, &isNull);
- if (isNull)
- elog(ERROR, "null conpfeqop for constraint %u", constrId);
+ adatum = SysCacheGetAttrNotNull(CONSTROID, tuple,
+ Anum_pg_constraint_conpfeqop);
arr = DatumGetArrayTypeP(adatum); /* ensure not toasted */
/* see TryReuseForeignKey if you change the test below */
if (ARR_NDIM(arr) != 1 ||
if (pp_eq_oprs)
{
- adatum = SysCacheGetAttr(CONSTROID, tuple,
- Anum_pg_constraint_conppeqop, &isNull);
- if (isNull)
- elog(ERROR, "null conppeqop for constraint %u", constrId);
+ adatum = SysCacheGetAttrNotNull(CONSTROID, tuple,
+ Anum_pg_constraint_conppeqop);
arr = DatumGetArrayTypeP(adatum); /* ensure not toasted */
if (ARR_NDIM(arr) != 1 ||
ARR_DIMS(arr)[0] != numkeys ||
if (ff_eq_oprs)
{
- adatum = SysCacheGetAttr(CONSTROID, tuple,
- Anum_pg_constraint_conffeqop, &isNull);
- if (isNull)
- elog(ERROR, "null conffeqop for constraint %u", constrId);
+ adatum = SysCacheGetAttrNotNull(CONSTROID, tuple,
+ Anum_pg_constraint_conffeqop);
arr = DatumGetArrayTypeP(adatum); /* ensure not toasted */
if (ARR_NDIM(arr) != 1 ||
ARR_DIMS(arr)[0] != numkeys ||
dropcmd,
format_procedure(oldproc->oid))));
- proargdefaults = SysCacheGetAttr(PROCNAMEARGSNSP, oldtup,
- Anum_pg_proc_proargdefaults,
- &isnull);
- Assert(!isnull);
+ proargdefaults = SysCacheGetAttrNotNull(PROCNAMEARGSNSP, oldtup,
+ Anum_pg_proc_proargdefaults);
oldDefaults = castNode(List, stringToNode(TextDatumGetCString(proargdefaults)));
Assert(list_length(oldDefaults) == oldproc->pronargdefaults);
{
Oid funcoid = PG_GETARG_OID(0);
HeapTuple tuple;
- bool isnull;
Datum tmp;
char *prosrc;
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
- tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_prosrc, &isnull);
- if (isnull)
- elog(ERROR, "null prosrc");
+ tmp = SysCacheGetAttrNotNull(PROCOID, tuple, Anum_pg_proc_prosrc);
prosrc = TextDatumGetCString(tmp);
if (fmgr_internal_function(prosrc) == InvalidOid)
Oid funcoid = PG_GETARG_OID(0);
void *libraryhandle;
HeapTuple tuple;
- bool isnull;
Datum tmp;
char *prosrc;
char *probin;
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
- tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_prosrc, &isnull);
- if (isnull)
- elog(ERROR, "null prosrc for C function %u", funcoid);
+ tmp = SysCacheGetAttrNotNull(PROCOID, tuple, Anum_pg_proc_prosrc);
prosrc = TextDatumGetCString(tmp);
- tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_probin, &isnull);
- if (isnull)
- elog(ERROR, "null probin for C function %u", funcoid);
+ tmp = SysCacheGetAttrNotNull(PROCOID, tuple, Anum_pg_proc_probin);
probin = TextDatumGetCString(tmp);
(void) load_external_function(probin, prosrc, true, &libraryhandle);
/* Postpone body checks if !check_function_bodies */
if (check_function_bodies)
{
- tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_prosrc, &isnull);
- if (isnull)
- elog(ERROR, "null prosrc");
-
+ tmp = SysCacheGetAttrNotNull(PROCOID, tuple, Anum_pg_proc_prosrc);
prosrc = TextDatumGetCString(tmp);
/*
sub->disableonerr = subform->subdisableonerr;
/* Get conninfo */
- datum = SysCacheGetAttr(SUBSCRIPTIONOID,
- tup,
- Anum_pg_subscription_subconninfo,
- &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(SUBSCRIPTIONOID,
+ tup,
+ Anum_pg_subscription_subconninfo);
sub->conninfo = TextDatumGetCString(datum);
/* Get slotname */
sub->slotname = NULL;
/* Get synccommit */
- datum = SysCacheGetAttr(SUBSCRIPTIONOID,
- tup,
- Anum_pg_subscription_subsynccommit,
- &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(SUBSCRIPTIONOID,
+ tup,
+ Anum_pg_subscription_subsynccommit);
sub->synccommit = TextDatumGetCString(datum);
/* Get publications */
- datum = SysCacheGetAttr(SUBSCRIPTIONOID,
- tup,
- Anum_pg_subscription_subpublications,
- &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(SUBSCRIPTIONOID,
+ tup,
+ Anum_pg_subscription_subpublications);
sub->publications = textarray_to_stringlist(DatumGetArrayTypeP(datum));
/* Get origin */
- datum = SysCacheGetAttr(SUBSCRIPTIONOID,
- tup,
- Anum_pg_subscription_suborigin,
- &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(SUBSCRIPTIONOID,
+ tup,
+ Anum_pg_subscription_suborigin);
sub->origin = TextDatumGetCString(datum);
ReleaseSysCache(tup);
datum = SysCacheGetAttr(COLLOID, tup, Anum_pg_collation_collversion, &isnull);
oldversion = isnull ? NULL : TextDatumGetCString(datum);
- datum = SysCacheGetAttr(COLLOID, tup, collForm->collprovider == COLLPROVIDER_ICU ? Anum_pg_collation_colliculocale : Anum_pg_collation_collcollate, &isnull);
- if (isnull)
- elog(ERROR, "unexpected null in pg_collation");
+ datum = SysCacheGetAttrNotNull(COLLOID, tup, collForm->collprovider == COLLPROVIDER_ICU ? Anum_pg_collation_colliculocale : Anum_pg_collation_collcollate);
newversion = get_collation_actual_version(collForm->collprovider, TextDatumGetCString(datum));
/* cannot change from NULL to non-NULL or vice versa */
char *locale;
char *version;
Datum datum;
- bool isnull;
if (collid == DEFAULT_COLLATION_OID)
{
provider = ((Form_pg_database) GETSTRUCT(dbtup))->datlocprovider;
- datum = SysCacheGetAttr(DATABASEOID, dbtup,
- provider == COLLPROVIDER_ICU ?
- Anum_pg_database_daticulocale : Anum_pg_database_datcollate,
- &isnull);
- if (isnull)
- elog(ERROR, "unexpected null in pg_database");
+ datum = SysCacheGetAttrNotNull(DATABASEOID, dbtup,
+ provider == COLLPROVIDER_ICU ?
+ Anum_pg_database_daticulocale : Anum_pg_database_datcollate);
locale = TextDatumGetCString(datum);
provider = ((Form_pg_collation) GETSTRUCT(colltp))->collprovider;
Assert(provider != COLLPROVIDER_DEFAULT);
- datum = SysCacheGetAttr(COLLOID, colltp,
- provider == COLLPROVIDER_ICU ?
- Anum_pg_collation_colliculocale : Anum_pg_collation_collcollate,
- &isnull);
- if (isnull)
- elog(ERROR, "unexpected null in pg_collation");
+ datum = SysCacheGetAttrNotNull(COLLOID, colltp,
+ provider == COLLPROVIDER_ICU ?
+ Anum_pg_collation_colliculocale : Anum_pg_collation_collcollate);
locale = TextDatumGetCString(datum);
HeapTuple tp;
char datlocprovider;
Datum datum;
- bool isnull;
char *version;
tp = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(dbid));
datlocprovider = ((Form_pg_database) GETSTRUCT(tp))->datlocprovider;
- datum = SysCacheGetAttr(DATABASEOID, tp, datlocprovider == COLLPROVIDER_ICU ? Anum_pg_database_daticulocale : Anum_pg_database_datcollate, &isnull);
- if (isnull)
- elog(ERROR, "unexpected null in pg_database");
+ datum = SysCacheGetAttrNotNull(DATABASEOID, tp, datlocprovider == COLLPROVIDER_ICU ? Anum_pg_database_daticulocale : Anum_pg_database_datcollate);
version = get_collation_actual_version(datlocprovider, TextDatumGetCString(datum));
ReleaseSysCache(tp);
*dbLocProvider = dbform->datlocprovider;
if (dbCollate)
{
- datum = SysCacheGetAttr(DATABASEOID, tuple, Anum_pg_database_datcollate, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(DATABASEOID, tuple, Anum_pg_database_datcollate);
*dbCollate = TextDatumGetCString(datum);
}
if (dbCtype)
{
- datum = SysCacheGetAttr(DATABASEOID, tuple, Anum_pg_database_datctype, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(DATABASEOID, tuple, Anum_pg_database_datctype);
*dbCtype = TextDatumGetCString(datum);
}
if (dbIculocale)
IndexInfo *indexInfo;
int numberOfAttributes;
int old_natts;
- bool isnull;
bool ret = true;
oidvector *old_indclass;
oidvector *old_indcollation;
old_natts = indexForm->indnkeyatts;
Assert(old_natts == numberOfAttributes);
- d = SysCacheGetAttr(INDEXRELID, tuple, Anum_pg_index_indcollation, &isnull);
- Assert(!isnull);
+ d = SysCacheGetAttrNotNull(INDEXRELID, tuple, Anum_pg_index_indcollation);
old_indcollation = (oidvector *) DatumGetPointer(d);
- d = SysCacheGetAttr(INDEXRELID, tuple, Anum_pg_index_indclass, &isnull);
- Assert(!isnull);
+ d = SysCacheGetAttrNotNull(INDEXRELID, tuple, Anum_pg_index_indclass);
old_indclass = (oidvector *) DatumGetPointer(d);
ret = (memcmp(old_indclass->values, classObjectId,
int indnkeyatts = indexStruct->indnkeyatts;
oidvector *indclass;
Datum indclassDatum;
- bool isnull;
int i;
/* Must get indclass the hard way. */
- indclassDatum = SysCacheGetAttr(INDEXRELID,
- indexRel->rd_indextuple,
- Anum_pg_index_indclass,
- &isnull);
- Assert(!isnull);
+ indclassDatum = SysCacheGetAttrNotNull(INDEXRELID,
+ indexRel->rd_indextuple,
+ Anum_pg_index_indclass);
indclass = (oidvector *) DatumGetPointer(indclassDatum);
/* Add quals for all columns from this index. */
LockSharedObject(SubscriptionRelationId, subid, 0, AccessExclusiveLock);
/* Get subname */
- datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subname, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(SUBSCRIPTIONOID, tup,
+ Anum_pg_subscription_subname);
subname = pstrdup(NameStr(*DatumGetName(datum)));
/* Get conninfo */
- datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subconninfo, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(SUBSCRIPTIONOID, tup,
+ Anum_pg_subscription_subconninfo);
conninfo = TextDatumGetCString(datum);
/* Get slotname */
List *children = NIL;
ListCell *child;
NewConstraint *newcon;
- bool isnull;
Datum val;
char *conbin;
newcon->refindid = InvalidOid;
newcon->conid = con->oid;
- val = SysCacheGetAttr(CONSTROID, tuple,
- Anum_pg_constraint_conbin, &isnull);
- if (isnull)
- elog(ERROR, "null conbin for constraint %u", con->oid);
-
+ val = SysCacheGetAttrNotNull(CONSTROID, tuple,
+ Anum_pg_constraint_conbin);
conbin = TextDatumGetCString(val);
newcon->qual = (Node *) stringToNode(conbin);
HeapTuple indexTuple = NULL;
Form_pg_index indexStruct = NULL;
Datum indclassDatum;
- bool isnull;
oidvector *indclass;
int i;
RelationGetRelationName(pkrel))));
/* Must get indclass the hard way */
- indclassDatum = SysCacheGetAttr(INDEXRELID, indexTuple,
- Anum_pg_index_indclass, &isnull);
- Assert(!isnull);
+ indclassDatum = SysCacheGetAttrNotNull(INDEXRELID, indexTuple,
+ Anum_pg_index_indclass);
indclass = (oidvector *) DatumGetPointer(indclassDatum);
/*
heap_attisnull(indexTuple, Anum_pg_index_indexprs, NULL))
{
Datum indclassDatum;
- bool isnull;
oidvector *indclass;
/* Must get indclass the hard way */
- indclassDatum = SysCacheGetAttr(INDEXRELID, indexTuple,
- Anum_pg_index_indclass, &isnull);
- Assert(!isnull);
+ indclassDatum = SysCacheGetAttrNotNull(INDEXRELID, indexTuple,
+ Anum_pg_index_indclass);
indclass = (oidvector *) DatumGetPointer(indclassDatum);
/*
{
HeapTuple tup;
Datum adatum;
- bool isNull;
ArrayType *arr;
Oid *rawarr;
int numkeys;
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for constraint %u", oldId);
- adatum = SysCacheGetAttr(CONSTROID, tup,
- Anum_pg_constraint_conpfeqop, &isNull);
- if (isNull)
- elog(ERROR, "null conpfeqop for constraint %u", oldId);
+ adatum = SysCacheGetAttrNotNull(CONSTROID, tup,
+ Anum_pg_constraint_conpfeqop);
arr = DatumGetArrayTypeP(adatum); /* ensure not toasted */
numkeys = ARR_DIMS(arr)[0];
/* test follows the one in ri_FetchConstraintInfo() */
char *conbin;
SysScanDesc scan;
Datum val;
- bool isnull;
HeapTuple tuple;
HeapTuple copyTuple;
ScanKeyData skey[3];
errmsg("constraint \"%s\" of domain \"%s\" is not a check constraint",
constrName, TypeNameToString(typename))));
- val = SysCacheGetAttr(CONSTROID, tuple,
- Anum_pg_constraint_conbin,
- &isnull);
- if (isnull)
- elog(ERROR, "null conbin for constraint %u",
- con->oid);
+ val = SysCacheGetAttrNotNull(CONSTROID, tuple, Anum_pg_constraint_conbin);
conbin = TextDatumGetCString(val);
validateDomainConstraint(domainoid, conbin);
{
int index_attoff;
int skey_attoff = 0;
- bool isnull;
Datum indclassDatum;
oidvector *opclass;
int2vector *indkey = &idxrel->rd_index->indkey;
- indclassDatum = SysCacheGetAttr(INDEXRELID, idxrel->rd_indextuple,
- Anum_pg_index_indclass, &isnull);
- Assert(!isnull);
+ indclassDatum = SysCacheGetAttrNotNull(INDEXRELID, idxrel->rd_indextuple,
+ Anum_pg_index_indclass);
opclass = (oidvector *) DatumGetPointer(indclassDatum);
/* Build scankey for every non-expression attribute in the index. */
/*
* And of course we need the function body text.
*/
- tmp = SysCacheGetAttr(PROCOID,
- procedureTuple,
- Anum_pg_proc_prosrc,
- &isNull);
- if (isNull)
- elog(ERROR, "null prosrc for function %u", foid);
+ tmp = SysCacheGetAttrNotNull(PROCOID, procedureTuple, Anum_pg_proc_prosrc);
fcache->src = TextDatumGetCString(tmp);
/* If we have prosqlbody, pay attention to that not prosrc. */
{
List *defaults;
Datum proargdefaults;
- bool isnull;
char *str;
- /* The error cases here shouldn't happen, but check anyway */
- proargdefaults = SysCacheGetAttr(PROCOID, func_tuple,
- Anum_pg_proc_proargdefaults,
- &isnull);
- if (isnull)
- elog(ERROR, "not enough default arguments");
+ proargdefaults = SysCacheGetAttrNotNull(PROCOID, func_tuple,
+ Anum_pg_proc_proargdefaults);
str = TextDatumGetCString(proargdefaults);
defaults = castNode(List, stringToNode(str));
pfree(str);
fexpr->location = -1;
/* Fetch the function body */
- tmp = SysCacheGetAttr(PROCOID,
- func_tuple,
- Anum_pg_proc_prosrc,
- &isNull);
- if (isNull)
- elog(ERROR, "null prosrc for function %u", funcid);
+ tmp = SysCacheGetAttrNotNull(PROCOID, func_tuple, Anum_pg_proc_prosrc);
src = TextDatumGetCString(tmp);
/*
oldcxt = MemoryContextSwitchTo(mycxt);
/* Fetch the function body */
- tmp = SysCacheGetAttr(PROCOID,
- func_tuple,
- Anum_pg_proc_prosrc,
- &isNull);
- if (isNull)
- elog(ERROR, "null prosrc for function %u", func_oid);
+ tmp = SysCacheGetAttrNotNull(PROCOID, func_tuple, Anum_pg_proc_prosrc);
src = TextDatumGetCString(tmp);
/*
if (argdefaults && best_candidate->ndargs > 0)
{
Datum proargdefaults;
- bool isnull;
char *str;
List *defaults;
if (best_candidate->ndargs > pform->pronargdefaults)
elog(ERROR, "not enough default arguments");
- proargdefaults = SysCacheGetAttr(PROCOID, ftup,
- Anum_pg_proc_proargdefaults,
- &isnull);
- Assert(!isnull);
+ proargdefaults = SysCacheGetAttrNotNull(PROCOID, ftup,
+ Anum_pg_proc_proargdefaults);
str = TextDatumGetCString(proargdefaults);
defaults = castNode(List, stringToNode(str));
pfree(str);
amrec = (Form_pg_am) GETSTRUCT(ht_am);
/* Extract indcollation from the pg_index tuple */
- datum = SysCacheGetAttr(INDEXRELID, ht_idx,
- Anum_pg_index_indcollation, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(INDEXRELID, ht_idx,
+ Anum_pg_index_indcollation);
indcollation = (oidvector *) DatumGetPointer(datum);
/* Extract indclass from the pg_index tuple */
- datum = SysCacheGetAttr(INDEXRELID, ht_idx,
- Anum_pg_index_indclass, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(INDEXRELID, ht_idx, Anum_pg_index_indclass);
indclass = (oidvector *) DatumGetPointer(datum);
/* Begin building the IndexStmt */
Assert(conrec->contype == CONSTRAINT_EXCLUSION);
/* Extract operator OIDs from the pg_constraint tuple */
- datum = SysCacheGetAttr(CONSTROID, ht_constr,
- Anum_pg_constraint_conexclop,
- &isnull);
- if (isnull)
- elog(ERROR, "null conexclop for constraint %u",
- constraintId);
-
+ datum = SysCacheGetAttrNotNull(CONSTROID, ht_constr,
+ Anum_pg_constraint_conexclop);
deconstruct_array_builtin(DatumGetArrayTypeP(datum), OIDOID, &elems, NULL, &nElems);
for (i = 0; i < nElems; i++)
statsrec = (Form_pg_statistic_ext) GETSTRUCT(ht_stats);
/* Determine which statistics types exist */
- datum = SysCacheGetAttr(STATEXTOID, ht_stats,
- Anum_pg_statistic_ext_stxkind, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(STATEXTOID, ht_stats,
+ Anum_pg_statistic_ext_stxkind);
arr = DatumGetArrayTypeP(datum);
if (ARR_NDIM(arr) != 1 ||
ARR_HASNULL(arr) ||
Form_pg_index index_form;
oidvector *indclass;
Datum indclassDatum;
- bool isnull;
int i;
/* Grammar should not allow this with explicit column list */
parser_errposition(cxt->pstate, constraint->location)));
/* Must get indclass the hard way */
- indclassDatum = SysCacheGetAttr(INDEXRELID, index_rel->rd_indextuple,
- Anum_pg_index_indclass, &isnull);
- Assert(!isnull);
+ indclassDatum = SysCacheGetAttrNotNull(INDEXRELID,
+ index_rel->rd_indextuple,
+ Anum_pg_index_indclass);
indclass = (oidvector *) DatumGetPointer(indclassDatum);
for (i = 0; i < index_form->indnatts; i++)
Oid inhrelid = inhoids[k];
HeapTuple tuple;
Datum datum;
- bool isnull;
PartitionBoundSpec *bspec;
tuple = SearchSysCache1(RELOID, inhrelid);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", inhrelid);
- datum = SysCacheGetAttr(RELOID, tuple,
- Anum_pg_class_relpartbound,
- &isnull);
- if (isnull)
- elog(ERROR, "null relpartbound for relation %u", inhrelid);
-
+ datum = SysCacheGetAttrNotNull(RELOID, tuple,
+ Anum_pg_class_relpartbound);
bspec = (PartitionBoundSpec *)
stringToNode(TextDatumGetCString(datum));
if (!IsA(bspec, PartitionBoundSpec))
}
/* decode the stxkind char array into a list of chars */
- datum = SysCacheGetAttr(STATEXTOID, htup,
- Anum_pg_statistic_ext_stxkind, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(STATEXTOID, htup,
+ Anum_pg_statistic_ext_stxkind);
arr = DatumGetArrayTypeP(datum);
if (ARR_NDIM(arr) != 1 ||
ARR_HASNULL(arr) ||
bool *res)
{
Datum datum;
- bool isnull;
int2vector *indoption;
int16 indoption_val;
return true;
}
- datum = SysCacheGetAttr(INDEXRELID, tuple,
- Anum_pg_index_indoption, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(INDEXRELID, tuple, Anum_pg_index_indoption);
indoption = ((int2vector *) DatumGetPointer(datum));
indoption_val = indoption->values[attno - 1];
if (collform->collprovider == COLLPROVIDER_LIBC)
{
Datum datum;
- bool isnull;
const char *collcollate;
const char *collctype;
- datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collcollate, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(COLLOID, tp, Anum_pg_collation_collcollate);
collcollate = TextDatumGetCString(datum);
- datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collctype, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(COLLOID, tp, Anum_pg_collation_collctype);
collctype = TextDatumGetCString(datum);
cache_entry->collate_is_c = ((strcmp(collcollate, "C") == 0) ||
const char *collctype pg_attribute_unused();
locale_t loc;
- datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collcollate, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(COLLOID, tp, Anum_pg_collation_collcollate);
collcollate = TextDatumGetCString(datum);
- datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collctype, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(COLLOID, tp, Anum_pg_collation_collctype);
collctype = TextDatumGetCString(datum);
if (strcmp(collcollate, collctype) == 0)
const char *iculocstr;
const char *icurules;
- datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_colliculocale, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(COLLOID, tp, Anum_pg_collation_colliculocale);
iculocstr = TextDatumGetCString(datum);
datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collicurules, &isnull);
collversionstr = TextDatumGetCString(datum);
- datum = SysCacheGetAttr(COLLOID, tp, collform->collprovider == COLLPROVIDER_ICU ? Anum_pg_collation_colliculocale : Anum_pg_collation_collcollate, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(COLLOID, tp, collform->collprovider == COLLPROVIDER_ICU ? Anum_pg_collation_colliculocale : Anum_pg_collation_collcollate);
actual_versionstr = get_collation_actual_version(collform->collprovider,
TextDatumGetCString(datum));
Datum indcollDatum;
Datum indclassDatum;
Datum indoptionDatum;
- bool isnull;
oidvector *indcollation;
oidvector *indclass;
int2vector *indoption;
Assert(indexrelid == idxrec->indexrelid);
/* Must get indcollation, indclass, and indoption the hard way */
- indcollDatum = SysCacheGetAttr(INDEXRELID, ht_idx,
- Anum_pg_index_indcollation, &isnull);
- Assert(!isnull);
+ indcollDatum = SysCacheGetAttrNotNull(INDEXRELID, ht_idx,
+ Anum_pg_index_indcollation);
indcollation = (oidvector *) DatumGetPointer(indcollDatum);
- indclassDatum = SysCacheGetAttr(INDEXRELID, ht_idx,
- Anum_pg_index_indclass, &isnull);
- Assert(!isnull);
+ indclassDatum = SysCacheGetAttrNotNull(INDEXRELID, ht_idx,
+ Anum_pg_index_indclass);
indclass = (oidvector *) DatumGetPointer(indclassDatum);
- indoptionDatum = SysCacheGetAttr(INDEXRELID, ht_idx,
- Anum_pg_index_indoption, &isnull);
- Assert(!isnull);
+ indoptionDatum = SysCacheGetAttrNotNull(INDEXRELID, ht_idx,
+ Anum_pg_index_indoption);
indoption = (int2vector *) DatumGetPointer(indoptionDatum);
/*
Datum exprsDatum;
char *exprsString;
- exprsDatum = SysCacheGetAttr(INDEXRELID, ht_idx,
- Anum_pg_index_indexprs, &isnull);
- Assert(!isnull);
+ exprsDatum = SysCacheGetAttrNotNull(INDEXRELID, ht_idx,
+ Anum_pg_index_indexprs);
exprsString = TextDatumGetCString(exprsDatum);
indexprs = (List *) stringToNode(exprsString);
pfree(exprsString);
char *predString;
/* Convert text string to node tree */
- predDatum = SysCacheGetAttr(INDEXRELID, ht_idx,
- Anum_pg_index_indpred, &isnull);
- Assert(!isnull);
+ predDatum = SysCacheGetAttrNotNull(INDEXRELID, ht_idx,
+ Anum_pg_index_indpred);
predString = TextDatumGetCString(predDatum);
node = (Node *) stringToNode(predString);
pfree(predString);
if (has_exprs)
{
Datum exprsDatum;
- bool isnull;
char *exprsString;
- exprsDatum = SysCacheGetAttr(STATEXTOID, statexttup,
- Anum_pg_statistic_ext_stxexprs, &isnull);
- Assert(!isnull);
+ exprsDatum = SysCacheGetAttrNotNull(STATEXTOID, statexttup,
+ Anum_pg_statistic_ext_stxexprs);
exprsString = TextDatumGetCString(exprsDatum);
exprs = (List *) stringToNode(exprsString);
pfree(exprsString);
if (!columns_only)
{
- bool isnull;
-
nsp = get_namespace_name_or_temp(statextrec->stxnamespace);
appendStringInfo(&buf, "CREATE STATISTICS %s",
quote_qualified_identifier(nsp,
* Decode the stxkind column so that we know which stats types to
* print.
*/
- datum = SysCacheGetAttr(STATEXTOID, statexttup,
- Anum_pg_statistic_ext_stxkind, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(STATEXTOID, statexttup,
+ Anum_pg_statistic_ext_stxkind);
arr = DatumGetArrayTypeP(datum);
if (ARR_NDIM(arr) != 1 ||
ARR_HASNULL(arr) ||
Form_pg_statistic_ext statextrec;
HeapTuple statexttup;
Datum datum;
- bool isnull;
List *context;
ListCell *lc;
List *exprs = NIL;
/*
* Get the statistics expressions, and deparse them into text values.
*/
- datum = SysCacheGetAttr(STATEXTOID, statexttup,
- Anum_pg_statistic_ext_stxexprs, &isnull);
-
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(STATEXTOID, statexttup,
+ Anum_pg_statistic_ext_stxexprs);
tmp = TextDatumGetCString(datum);
exprs = (List *) stringToNode(tmp);
pfree(tmp);
ListCell *partexpr_item;
List *context;
Datum datum;
- bool isnull;
StringInfoData buf;
int keyno;
char *str;
Assert(form->partrelid == relid);
/* Must get partclass and partcollation the hard way */
- datum = SysCacheGetAttr(PARTRELID, tuple,
- Anum_pg_partitioned_table_partclass, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(PARTRELID, tuple,
+ Anum_pg_partitioned_table_partclass);
partclass = (oidvector *) DatumGetPointer(datum);
- datum = SysCacheGetAttr(PARTRELID, tuple,
- Anum_pg_partitioned_table_partcollation, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(PARTRELID, tuple,
+ Anum_pg_partitioned_table_partcollation);
partcollation = (oidvector *) DatumGetPointer(datum);
Datum exprsDatum;
char *exprsString;
- exprsDatum = SysCacheGetAttr(PARTRELID, tuple,
- Anum_pg_partitioned_table_partexprs, &isnull);
- Assert(!isnull);
+ exprsDatum = SysCacheGetAttrNotNull(PARTRELID, tuple,
+ Anum_pg_partitioned_table_partexprs);
exprsString = TextDatumGetCString(exprsDatum);
partexprs = (List *) stringToNode(exprsString);
appendStringInfoString(&buf, "FOREIGN KEY (");
/* Fetch and build referencing-column list */
- val = SysCacheGetAttr(CONSTROID, tup,
- Anum_pg_constraint_conkey, &isnull);
- if (isnull)
- elog(ERROR, "null conkey for constraint %u",
- constraintId);
+ val = SysCacheGetAttrNotNull(CONSTROID, tup,
+ Anum_pg_constraint_conkey);
decompile_column_index_array(val, conForm->conrelid, &buf);
NIL));
/* Fetch and build referenced-column list */
- val = SysCacheGetAttr(CONSTROID, tup,
- Anum_pg_constraint_confkey, &isnull);
- if (isnull)
- elog(ERROR, "null confkey for constraint %u",
- constraintId);
+ val = SysCacheGetAttrNotNull(CONSTROID, tup,
+ Anum_pg_constraint_confkey);
decompile_column_index_array(val, conForm->confrelid, &buf);
case CONSTRAINT_UNIQUE:
{
Datum val;
- bool isnull;
Oid indexId;
int keyatts;
HeapTuple indtup;
appendStringInfoChar(&buf, '(');
/* Fetch and build target column list */
- val = SysCacheGetAttr(CONSTROID, tup,
- Anum_pg_constraint_conkey, &isnull);
- if (isnull)
- elog(ERROR, "null conkey for constraint %u",
- constraintId);
+ val = SysCacheGetAttrNotNull(CONSTROID, tup,
+ Anum_pg_constraint_conkey);
keyatts = decompile_column_index_array(val, conForm->conrelid, &buf);
appendStringInfoChar(&buf, ')');
/* Build including column list (from pg_index.indkeys) */
- val = SysCacheGetAttr(INDEXRELID, indtup,
- Anum_pg_index_indnatts, &isnull);
- if (isnull)
- elog(ERROR, "null indnatts for index %u", indexId);
+ val = SysCacheGetAttrNotNull(INDEXRELID, indtup,
+ Anum_pg_index_indnatts);
if (DatumGetInt32(val) > keyatts)
{
Datum cols;
appendStringInfoString(&buf, " INCLUDE (");
- cols = SysCacheGetAttr(INDEXRELID, indtup,
- Anum_pg_index_indkey, &isnull);
- if (isnull)
- elog(ERROR, "null indkey for index %u", indexId);
+ cols = SysCacheGetAttrNotNull(INDEXRELID, indtup,
+ Anum_pg_index_indkey);
deconstruct_array_builtin(DatumGetArrayTypeP(cols), INT2OID,
&keys, NULL, &nKeys);
case CONSTRAINT_CHECK:
{
Datum val;
- bool isnull;
char *conbin;
char *consrc;
Node *expr;
List *context;
/* Fetch constraint expression in parsetree form */
- val = SysCacheGetAttr(CONSTROID, tup,
- Anum_pg_constraint_conbin, &isnull);
- if (isnull)
- elog(ERROR, "null conbin for constraint %u",
- constraintId);
+ val = SysCacheGetAttrNotNull(CONSTROID, tup,
+ Anum_pg_constraint_conbin);
conbin = TextDatumGetCString(val);
expr = stringToNode(conbin);
{
Oid indexOid = conForm->conindid;
Datum val;
- bool isnull;
Datum *elems;
int nElems;
int i;
Oid *operators;
/* Extract operator OIDs from the pg_constraint tuple */
- val = SysCacheGetAttr(CONSTROID, tup,
- Anum_pg_constraint_conexclop,
- &isnull);
- if (isnull)
- elog(ERROR, "null conexclop for constraint %u",
- constraintId);
+ val = SysCacheGetAttrNotNull(CONSTROID, tup,
+ Anum_pg_constraint_conexclop);
deconstruct_array_builtin(DatumGetArrayTypeP(val), OIDOID,
&elems, NULL, &nElems);
appendStringInfoString(&buf, ", "); /* assume prosrc isn't null */
}
- tmp = SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_prosrc, &isnull);
- if (isnull)
- elog(ERROR, "null prosrc");
+ tmp = SysCacheGetAttrNotNull(PROCOID, proctup, Anum_pg_proc_prosrc);
prosrc = TextDatumGetCString(tmp);
/*
char *argmodes;
deparse_namespace dpns = {0};
Datum tmp;
- bool isnull;
Node *n;
dpns.funcname = pstrdup(NameStr(((Form_pg_proc) GETSTRUCT(proctup))->proname));
dpns.numargs = numargs;
dpns.argnames = argnames;
- tmp = SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_prosqlbody, &isnull);
- Assert(!isnull);
+ tmp = SysCacheGetAttrNotNull(PROCOID, proctup, Anum_pg_proc_prosqlbody);
n = stringToNode(TextDatumGetCString(tmp));
if (IsA(n, List))
Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple);
int i;
Datum val;
- bool isnull;
ArrayType *statarray;
Oid arrayelemtype;
int narrayelem;
if (flags & ATTSTATSSLOT_VALUES)
{
- val = SysCacheGetAttr(STATRELATTINH, statstuple,
- Anum_pg_statistic_stavalues1 + i,
- &isnull);
- if (isnull)
- elog(ERROR, "stavalues is null");
+ val = SysCacheGetAttrNotNull(STATRELATTINH, statstuple,
+ Anum_pg_statistic_stavalues1 + i);
/*
* Detoast the array if needed, and in any case make a copy that's
if (flags & ATTSTATSSLOT_NUMBERS)
{
- val = SysCacheGetAttr(STATRELATTINH, statstuple,
- Anum_pg_statistic_stanumbers1 + i,
- &isnull);
- if (isnull)
- elog(ERROR, "stanumbers is null");
+ val = SysCacheGetAttrNotNull(STATRELATTINH, statstuple,
+ Anum_pg_statistic_stanumbers1 + i);
/*
* Detoast the array if needed, and in any case make a copy that's
HeapTuple tuple;
Form_pg_index rd_index;
Datum datum;
- bool isnull;
oidvector *indclass;
Oid opclass;
return InvalidOid;
}
- datum = SysCacheGetAttr(INDEXRELID, tuple,
- Anum_pg_index_indclass, &isnull);
- Assert(!isnull);
-
+ datum = SysCacheGetAttrNotNull(INDEXRELID, tuple, Anum_pg_index_indclass);
indclass = ((oidvector *) DatumGetPointer(datum));
Assert(attno <= indclass->dim1);
/* But use the hard way to retrieve further variable-length attributes */
/* Operator class */
- datum = SysCacheGetAttr(PARTRELID, tuple,
- Anum_pg_partitioned_table_partclass, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(PARTRELID, tuple,
+ Anum_pg_partitioned_table_partclass);
opclass = (oidvector *) DatumGetPointer(datum);
/* Collation */
- datum = SysCacheGetAttr(PARTRELID, tuple,
- Anum_pg_partitioned_table_partcollation, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(PARTRELID, tuple,
+ Anum_pg_partitioned_table_partcollation);
collation = (oidvector *) DatumGetPointer(datum);
/* Expressions */
#include "catalog/pg_user_mapping.h"
#include "lib/qunique.h"
#include "utils/catcache.h"
+#include "utils/lsyscache.h"
#include "utils/rel.h"
#include "utils/syscache.h"
isNull);
}
+/*
+ * SysCacheGetAttrNotNull
+ *
+ * As above, a version of SysCacheGetAttr which knows that the attr cannot
+ * be NULL.
+ */
+Datum
+SysCacheGetAttrNotNull(int cacheId, HeapTuple tup,
+ AttrNumber attributeNumber)
+{
+ bool isnull;
+ Datum attr;
+
+ attr = SysCacheGetAttr(cacheId, tup, attributeNumber, &isnull);
+
+ if (isnull)
+ {
+ elog(ERROR,
+ "unexpected null value in cached tuple for catalog %s column %s",
+ get_rel_name(cacheinfo[cacheId].reloid),
+ NameStr(TupleDescAttr(SysCache[cacheId]->cc_tupdesc, attributeNumber - 1)->attname));
+ }
+
+ return attr;
+}
+
/*
* GetSysCacheHashValue
*
HeapTuple procedureTuple;
Form_pg_proc procedureStruct;
Datum prosrcdatum;
- bool isnull;
char *prosrc;
/*
* internal function is stored in prosrc (it doesn't have to be
* the same as the name of the alias!)
*/
- prosrcdatum = SysCacheGetAttr(PROCOID, procedureTuple,
- Anum_pg_proc_prosrc, &isnull);
- if (isnull)
- elog(ERROR, "null prosrc");
+ prosrcdatum = SysCacheGetAttrNotNull(PROCOID, procedureTuple,
+ Anum_pg_proc_prosrc);
prosrc = TextDatumGetCString(prosrcdatum);
fbp = fmgr_lookupByName(prosrc);
if (fbp == NULL)
{
HeapTuple procedureTuple;
Form_pg_proc procedureStruct;
- bool isnull;
Datum prosrcattr;
Datum probinattr;
switch (procedureStruct->prolang)
{
case INTERNALlanguageId:
- prosrcattr = SysCacheGetAttr(PROCOID, procedureTuple,
- Anum_pg_proc_prosrc, &isnull);
- if (isnull)
- elog(ERROR, "null prosrc");
+ prosrcattr = SysCacheGetAttrNotNull(PROCOID, procedureTuple,
+ Anum_pg_proc_prosrc);
*mod = NULL; /* core binary */
*fn = TextDatumGetCString(prosrcattr);
break;
case ClanguageId:
- prosrcattr = SysCacheGetAttr(PROCOID, procedureTuple,
- Anum_pg_proc_prosrc, &isnull);
- if (isnull)
- elog(ERROR, "null prosrc for C function %u", functionId);
+ prosrcattr = SysCacheGetAttrNotNull(PROCOID, procedureTuple,
+ Anum_pg_proc_prosrc);
- probinattr = SysCacheGetAttr(PROCOID, procedureTuple,
- Anum_pg_proc_probin, &isnull);
- if (isnull)
- elog(ERROR, "null probin for C function %u", functionId);
+ probinattr = SysCacheGetAttrNotNull(PROCOID, procedureTuple,
+ Anum_pg_proc_probin);
/*
* No need to check symbol presence / API version here, already
CFuncHashTabEntry *hashentry;
PGFunction user_fn;
const Pg_finfo_record *inforec;
- bool isnull;
/*
* See if we have the function address cached already
* While in general these columns might be null, that's not allowed
* for C-language functions.
*/
- prosrcattr = SysCacheGetAttr(PROCOID, procedureTuple,
- Anum_pg_proc_prosrc, &isnull);
- if (isnull)
- elog(ERROR, "null prosrc for C function %u", functionId);
+ prosrcattr = SysCacheGetAttrNotNull(PROCOID, procedureTuple,
+ Anum_pg_proc_prosrc);
prosrcstring = TextDatumGetCString(prosrcattr);
- probinattr = SysCacheGetAttr(PROCOID, procedureTuple,
- Anum_pg_proc_probin, &isnull);
- if (isnull)
- elog(ERROR, "null probin for C function %u", functionId);
+ probinattr = SysCacheGetAttrNotNull(PROCOID, procedureTuple,
+ Anum_pg_proc_probin);
probinstring = TextDatumGetCString(probinattr);
/* Look up the function itself */
HeapTuple procTuple;
Datum proargmodes;
Datum proargnames;
- bool isnull;
ArrayType *arr;
int numargs;
char *argmodes;
else
{
/* Get the data out of the tuple */
- proargmodes = SysCacheGetAttr(PROCOID, procTuple,
- Anum_pg_proc_proargmodes,
- &isnull);
- Assert(!isnull);
- proargnames = SysCacheGetAttr(PROCOID, procTuple,
- Anum_pg_proc_proargnames,
- &isnull);
- Assert(!isnull);
+ proargmodes = SysCacheGetAttrNotNull(PROCOID, procTuple,
+ Anum_pg_proc_proargmodes);
+ proargnames = SysCacheGetAttrNotNull(PROCOID, procTuple,
+ Anum_pg_proc_proargnames);
/*
* We expect the arrays to be 1-D arrays of the right types; verify
return NULL;
/* Get the data out of the tuple */
- proallargtypes = SysCacheGetAttr(PROCOID, procTuple,
- Anum_pg_proc_proallargtypes,
- &isnull);
- Assert(!isnull);
- proargmodes = SysCacheGetAttr(PROCOID, procTuple,
- Anum_pg_proc_proargmodes,
- &isnull);
- Assert(!isnull);
+ proallargtypes = SysCacheGetAttrNotNull(PROCOID, procTuple,
+ Anum_pg_proc_proallargtypes);
+ proargmodes = SysCacheGetAttrNotNull(PROCOID, procTuple,
+ Anum_pg_proc_proargmodes);
proargnames = SysCacheGetAttr(PROCOID, procTuple,
Anum_pg_proc_proargnames,
&isnull);
PGC_BACKEND, PGC_S_DYNAMIC_DEFAULT);
/* assign locale variables */
- datum = SysCacheGetAttr(DATABASEOID, tup, Anum_pg_database_datcollate, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(DATABASEOID, tup, Anum_pg_database_datcollate);
collate = TextDatumGetCString(datum);
- datum = SysCacheGetAttr(DATABASEOID, tup, Anum_pg_database_datctype, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(DATABASEOID, tup, Anum_pg_database_datctype);
ctype = TextDatumGetCString(datum);
if (pg_perm_setlocale(LC_COLLATE, collate) == NULL)
{
char *icurules;
- datum = SysCacheGetAttr(DATABASEOID, tup, Anum_pg_database_daticulocale, &isnull);
- Assert(!isnull);
+ datum = SysCacheGetAttrNotNull(DATABASEOID, tup, Anum_pg_database_daticulocale);
iculocale = TextDatumGetCString(datum);
datum = SysCacheGetAttr(DATABASEOID, tup, Anum_pg_database_daticurules, &isnull);
extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup,
AttrNumber attributeNumber, bool *isNull);
+extern Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup,
+ AttrNumber attributeNumber);
+
extern uint32 GetSysCacheHashValue(int cacheId,
Datum key1, Datum key2, Datum key3, Datum key4);
* we do not use a named subroutine so that we can call directly
* through the reference.
************************************************************/
- prosrcdatum = SysCacheGetAttr(PROCOID, procTup,
- Anum_pg_proc_prosrc, &isnull);
- if (isnull)
- elog(ERROR, "null prosrc");
+ prosrcdatum = SysCacheGetAttrNotNull(PROCOID, procTup,
+ Anum_pg_proc_prosrc);
proc_source = TextDatumGetCString(prosrcdatum);
/************************************************************
bool is_dml_trigger = CALLED_AS_TRIGGER(fcinfo);
bool is_event_trigger = CALLED_AS_EVENT_TRIGGER(fcinfo);
Datum prosrcdatum;
- bool isnull;
char *proc_source;
HeapTuple typeTup;
Form_pg_type typeStruct;
* cannot be invoked recursively, so there's no need to save and restore
* the static variables used here.
*/
- prosrcdatum = SysCacheGetAttr(PROCOID, procTup,
- Anum_pg_proc_prosrc, &isnull);
- if (isnull)
- elog(ERROR, "null prosrc");
+ prosrcdatum = SysCacheGetAttrNotNull(PROCOID, procTup, Anum_pg_proc_prosrc);
proc_source = TextDatumGetCString(prosrcdatum);
plpgsql_scanner_init(proc_source);
/*
* get the text of the function.
*/
- prosrcdatum = SysCacheGetAttr(PROCOID, procTup,
- Anum_pg_proc_prosrc, &isnull);
- if (isnull)
- elog(ERROR, "null prosrc");
+ prosrcdatum = SysCacheGetAttrNotNull(PROCOID, procTup,
+ Anum_pg_proc_prosrc);
procSource = TextDatumGetCString(prosrcdatum);
PLy_procedure_compile(proc, procSource);
Form_pg_type typeStruct;
char proc_internal_args[33 * FUNC_MAX_ARGS];
Datum prosrcdatum;
- bool isnull;
char *proc_source;
char buf[48];
Tcl_Interp *interp;
/************************************************************
* Add user's function definition to proc body
************************************************************/
- prosrcdatum = SysCacheGetAttr(PROCOID, procTup,
- Anum_pg_proc_prosrc, &isnull);
- if (isnull)
- elog(ERROR, "null prosrc");
+ prosrcdatum = SysCacheGetAttrNotNull(PROCOID, procTup,
+ Anum_pg_proc_prosrc);
proc_source = TextDatumGetCString(prosrcdatum);
UTF_BEGIN;
Tcl_DStringAppend(&proc_internal_body, UTF_E2U(proc_source), -1);