mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
Ensure that the Datum generated from a whole-row Var contains valid
type ID information even when it's a record type. This is needed to handle whole-row Vars referencing subquery outputs. Per example from Richard Huxton.
This commit is contained in:
parent
32fcfcdbd6
commit
07908c9c37
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.100 2005/10/15 02:49:08 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.101 2005/10/19 18:18:32 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -27,6 +27,7 @@
|
|||||||
#include "access/tuptoaster.h"
|
#include "access/tuptoaster.h"
|
||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
#include "executor/tuptable.h"
|
#include "executor/tuptable.h"
|
||||||
|
#include "utils/typcache.h"
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
@ -603,11 +604,18 @@ heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
|
|||||||
*
|
*
|
||||||
* We have to make a copy of the tuple so we can safely insert the
|
* We have to make a copy of the tuple so we can safely insert the
|
||||||
* Datum overhead fields, which are not set in on-disk tuples.
|
* Datum overhead fields, which are not set in on-disk tuples.
|
||||||
|
*
|
||||||
|
* It's possible that the passed tupleDesc is a record type that
|
||||||
|
* hasn't been "blessed" yet, so cover that case.
|
||||||
*/
|
*/
|
||||||
case InvalidAttrNumber:
|
case InvalidAttrNumber:
|
||||||
{
|
{
|
||||||
HeapTupleHeader dtup;
|
HeapTupleHeader dtup;
|
||||||
|
|
||||||
|
if (tupleDesc->tdtypeid == RECORDOID &&
|
||||||
|
tupleDesc->tdtypmod < 0)
|
||||||
|
assign_record_type_typmod(tupleDesc);
|
||||||
|
|
||||||
dtup = (HeapTupleHeader) palloc(tup->t_len);
|
dtup = (HeapTupleHeader) palloc(tup->t_len);
|
||||||
memcpy((char *) dtup, (char *) tup->t_data, tup->t_len);
|
memcpy((char *) dtup, (char *) tup->t_data, tup->t_len);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.181 2005/10/15 02:49:16 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.182 2005/10/19 18:18:33 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -3180,7 +3180,7 @@ ExecInitExpr(Expr *node, PlanState *parent)
|
|||||||
{
|
{
|
||||||
/* generic record, use runtime type assignment */
|
/* generic record, use runtime type assignment */
|
||||||
rstate->tupdesc = ExecTypeFromExprList(rowexpr->args);
|
rstate->tupdesc = ExecTypeFromExprList(rowexpr->args);
|
||||||
rstate->tupdesc = BlessTupleDesc(rstate->tupdesc);
|
BlessTupleDesc(rstate->tupdesc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user