Skip to content

Commit d9d72bc

Browse files
committed
Fix typmod interpretation for bit types. (It was erroneously assumed that
for bit(x), the typmod stores x+4, like for the character types.)
1 parent 649c1a1 commit d9d72bc

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/backend/catalog/information_schema.sql

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright 2003, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.17 2003/11/29 22:39:40 pgsql Exp $
7+
* $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.18 2003/12/07 10:21:58 petere Exp $
88
*/
99

1010
/*
@@ -260,12 +260,16 @@ CREATE VIEW columns AS
260260

261261
CAST(
262262
CASE WHEN t.typtype = 'd' THEN
263-
CASE WHEN t.typbasetype IN (25, 1042, 1043, 1560, 1562) AND t.typtypmod <> -1
264-
THEN t.typtypmod - 4
263+
CASE WHEN t.typbasetype IN (1042, 1043) AND t.typtypmod <> -1
264+
THEN t.typtypmod - 4 /* char, varchar */
265+
WHEN t.typbasetype IN (1560, 1562) AND t.typtypmod <> -1
266+
THEN t.typtypmod /* bit, varbit */
265267
ELSE null END
266268
ELSE
267-
CASE WHEN a.atttypid IN (25, 1042, 1043, 1560, 1562) AND a.atttypmod <> -1
269+
CASE WHEN a.atttypid IN (1042, 1043) AND a.atttypmod <> -1
268270
THEN a.atttypmod - 4
271+
WHEN a.atttypid IN (1560, 1562) AND a.atttypmod <> -1
272+
THEN a.atttypmod
269273
ELSE null END
270274
END
271275
AS cardinal_number)
@@ -559,8 +563,10 @@ CREATE VIEW domains AS
559563
AS data_type,
560564

561565
CAST(
562-
CASE WHEN t.typbasetype IN (25, 1042, 1043, 1560, 1562) AND t.typtypmod <> -1
563-
THEN t.typtypmod - 4
566+
CASE WHEN t.typbasetype IN (1042, 1043) AND t.typtypmod <> -1
567+
THEN t.typtypmod - 4 /* char, varchar */
568+
WHEN t.typbasetype IN (1560, 1562) AND t.typtypmod <> -1
569+
THEN t.typtypmod /* bit, varbit */
564570
ELSE null END
565571
AS cardinal_number)
566572
AS character_maximum_length,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy