Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d9b679c

Browse files
committed
In RowDescription messages, report columns of domain datatypes as having
the type OID and typmod of the underlying base type. Per discussions a few weeks ago with Andreas Pflug and others. Note that this behavioral change affects both old- and new-protocol clients.
1 parent 0249c24 commit d9b679c

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/backend/access/common/printtup.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.72 2003/05/09 18:08:48 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.73 2003/05/13 18:39:50 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -181,6 +181,10 @@ SendRowDescriptionMessage(TupleDesc typeinfo, List *targetlist, int16 *formats)
181181

182182
for (i = 0; i < natts; ++i)
183183
{
184+
Oid atttypid = attrs[i]->atttypid;
185+
int32 atttypmod = attrs[i]->atttypmod;
186+
Oid basetype;
187+
184188
pq_sendstring(&buf, NameStr(attrs[i]->attname));
185189
/* column ID info appears in protocol 3.0 and up */
186190
if (proto >= 3)
@@ -204,14 +208,18 @@ SendRowDescriptionMessage(TupleDesc typeinfo, List *targetlist, int16 *formats)
204208
pq_sendint(&buf, 0, 2);
205209
}
206210
}
207-
pq_sendint(&buf, (int) attrs[i]->atttypid,
208-
sizeof(attrs[i]->atttypid));
209-
pq_sendint(&buf, attrs[i]->attlen,
210-
sizeof(attrs[i]->attlen));
211+
/* If column is a domain, send the base type and typmod instead */
212+
basetype = getBaseType(atttypid);
213+
if (basetype != atttypid)
214+
{
215+
atttypmod = get_typtypmod(atttypid);
216+
atttypid = basetype;
217+
}
218+
pq_sendint(&buf, (int) atttypid, sizeof(atttypid));
219+
pq_sendint(&buf, attrs[i]->attlen, sizeof(attrs[i]->attlen));
211220
/* typmod appears in protocol 2.0 and up */
212221
if (proto >= 2)
213-
pq_sendint(&buf, attrs[i]->atttypmod,
214-
sizeof(attrs[i]->atttypmod));
222+
pq_sendint(&buf, atttypmod, sizeof(atttypmod));
215223
/* format info appears in protocol 3.0 and up */
216224
if (proto >= 3)
217225
{

0 commit comments

Comments
 (0)