95 nincols = noutcols = 0;
97 for (
i = 0;
i < n;
i++)
103 if (att->attisdropped)
106 atttypid = att->atttypid;
107 atttypmod = att->atttypmod;
111 if (att->attisdropped)
116 if (atttypid != att->atttypid ||
117 (atttypmod != att->atttypmod && atttypmod >= 0))
119 (
errcode(ERRCODE_DATATYPE_MISMATCH),
121 errdetail(
"Returned type %s does not match expected type %s in column %d.",
147 (
errcode(ERRCODE_DATATYPE_MISMATCH),
149 errdetail(
"Number of returned columns (%d) does not match "
150 "expected column count (%d).",
151 nincols, noutcols)));
187 outnatts = outdesc->
natts;
188 innatts = indesc->
natts;
191 for (
i = 0;
i < outnatts;
i++)
199 if (outatt->attisdropped)
202 atttypid = outatt->atttypid;
203 atttypmod = outatt->atttypmod;
216 for (
j = 0;
j < innatts;
j++)
221 if (nextindesc >= innatts)
225 if (inatt->attisdropped)
230 if (atttypid != inatt->atttypid || atttypmod != inatt->atttypmod)
232 (
errcode(ERRCODE_DATATYPE_MISMATCH),
233 errmsg(
"could not convert row type"),
234 errdetail(
"Attribute \"%s\" of type %s does not match corresponding attribute of type %s.",
238 attrMap->
attnums[
i] = inatt->attnum;
242 if (attrMap->
attnums[
i] == 0 && !missing_ok)
244 (
errcode(ERRCODE_DATATYPE_MISMATCH),
245 errmsg(
"could not convert row type"),
246 errdetail(
"Attribute \"%s\" of type %s does not exist in type %s.",
308 if (inatt->atthasmissing)
320 inatt->attisdropped &&
321 inatt->attlen == outatt->attlen &&
322 inatt->attalign == outatt->attalign)
void free_attrmap(AttrMap *map)
AttrMap * make_attrmap(int maplen)
AttrMap * build_attrmap_by_position(TupleDesc indesc, TupleDesc outdesc, const char *msg)
AttrMap * build_attrmap_by_name_if_req(TupleDesc indesc, TupleDesc outdesc, bool missing_ok)
static bool check_attrmap_match(TupleDesc indesc, TupleDesc outdesc, AttrMap *attrMap)
AttrMap * build_attrmap_by_name(TupleDesc indesc, TupleDesc outdesc, bool missing_ok)
static void PGresult * res
int errmsg_internal(const char *fmt,...)
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void pfree(void *pointer)
void * palloc0(Size size)
FormData_pg_attribute * Form_pg_attribute
#define TupleDescAttr(tupdesc, i)