mirror of
https://github.com/postgres/postgres.git
synced 2025-06-08 22:02:03 +03:00
More sensible character_octet_length
For character types with typmod, character_octet_length columns in the information schema now show the maximum character length times the maximum length of a character in the server encoding, instead of some huge value as before.
This commit is contained in:
parent
788d8e5139
commit
e292dbcf54
@ -1,4 +1,4 @@
|
|||||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/information_schema.sgml,v 1.39 2009/06/10 07:03:34 petere Exp $ -->
|
<!-- $PostgreSQL: pgsql/doc/src/sgml/information_schema.sgml,v 1.40 2009/07/07 18:23:13 petere Exp $ -->
|
||||||
|
|
||||||
<chapter id="information-schema">
|
<chapter id="information-schema">
|
||||||
<title>The Information Schema</title>
|
<title>The Information Schema</title>
|
||||||
@ -343,10 +343,10 @@
|
|||||||
<entry><type>cardinal_number</type></entry>
|
<entry><type>cardinal_number</type></entry>
|
||||||
<entry>
|
<entry>
|
||||||
If <literal>data_type</literal> identifies a character type,
|
If <literal>data_type</literal> identifies a character type,
|
||||||
the maximum possible length in octets (bytes) of a datum (this
|
the maximum possible length in octets (bytes) of a datum; null
|
||||||
should not be of concern to
|
for all other data types. The maximum octet length depends on
|
||||||
<productname>PostgreSQL</productname> users); null for all
|
the declared character maximum length (see above) and the
|
||||||
other data types.
|
server encoding.
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
@ -947,9 +947,10 @@
|
|||||||
<entry><type>cardinal_number</type></entry>
|
<entry><type>cardinal_number</type></entry>
|
||||||
<entry>
|
<entry>
|
||||||
If <literal>data_type</literal> identifies a character type,
|
If <literal>data_type</literal> identifies a character type,
|
||||||
the maximum possible length in octets (bytes) of a datum (this
|
the maximum possible length in octets (bytes) of a datum; null
|
||||||
should not be of concern to <productname>PostgreSQL</productname> users); null for all
|
for all other data types. The maximum octet length depends on
|
||||||
other data types.
|
the declared character maximum length (see above) and the
|
||||||
|
server encoding.
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
@ -1688,9 +1689,9 @@
|
|||||||
<entry><type>cardinal_number</type></entry>
|
<entry><type>cardinal_number</type></entry>
|
||||||
<entry>
|
<entry>
|
||||||
If the domain has a character type, the maximum possible length
|
If the domain has a character type, the maximum possible length
|
||||||
in octets (bytes) of a datum (this should not be of concern to
|
in octets (bytes) of a datum; null for all other data types.
|
||||||
<productname>PostgreSQL</productname> users); null for all
|
The maximum octet length depends on the declared character
|
||||||
other data types.
|
maximum length (see above) and the server encoding.
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2003-2009, PostgreSQL Global Development Group
|
* Copyright (c) 2003-2009, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.54 2009/06/10 07:03:34 petere Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.55 2009/07/07 18:23:13 petere Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -104,7 +104,10 @@ CREATE FUNCTION _pg_char_octet_length(typid oid, typmod int4) RETURNS integer
|
|||||||
AS
|
AS
|
||||||
$$SELECT
|
$$SELECT
|
||||||
CASE WHEN $1 IN (25, 1042, 1043) /* text, char, varchar */
|
CASE WHEN $1 IN (25, 1042, 1043) /* text, char, varchar */
|
||||||
THEN CAST(2^30 AS integer)
|
THEN CASE WHEN $2 = -1 /* default typmod */
|
||||||
|
THEN CAST(2^30 AS integer)
|
||||||
|
ELSE information_schema._pg_char_max_length($1, $2) * pg_catalog.pg_encoding_max_length((SELECT encoding FROM pg_database WHERE datname = current_database()))
|
||||||
|
END
|
||||||
ELSE null
|
ELSE null
|
||||||
END$$;
|
END$$;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Tatsuo Ishii
|
* Tatsuo Ishii
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.87 2009/06/11 14:49:05 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.88 2009/07/07 18:23:14 petere Exp $
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
@ -482,6 +482,17 @@ length_in_encoding(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Datum
|
||||||
|
pg_encoding_max_length_sql(PG_FUNCTION_ARGS)
|
||||||
|
{
|
||||||
|
int encoding = PG_GETARG_INT32(0);
|
||||||
|
|
||||||
|
if (PG_VALID_ENCODING(encoding))
|
||||||
|
return pg_wchar_table[encoding].maxmblen;
|
||||||
|
else
|
||||||
|
PG_RETURN_NULL();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* convert client encoding to server encoding.
|
* convert client encoding to server encoding.
|
||||||
*/
|
*/
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.531 2009/06/11 14:49:09 momjian Exp $
|
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.532 2009/07/07 18:23:14 petere Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -53,6 +53,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* yyyymmddN */
|
/* yyyymmddN */
|
||||||
#define CATALOG_VERSION_NO 200904091
|
#define CATALOG_VERSION_NO 200907071
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.544 2009/06/11 14:49:09 momjian Exp $
|
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.545 2009/07/07 18:23:14 petere Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* The script catalog/genbki.sh reads this file and generates .bki
|
* The script catalog/genbki.sh reads this file and generates .bki
|
||||||
@ -2278,6 +2278,9 @@ DESCR("convert encoding name to encoding id");
|
|||||||
DATA(insert OID = 1597 ( pg_encoding_to_char PGNSP PGUID 12 1 0 0 f f f t f s 1 0 19 "23" _null_ _null_ _null_ _null_ PG_encoding_to_char _null_ _null_ _null_ ));
|
DATA(insert OID = 1597 ( pg_encoding_to_char PGNSP PGUID 12 1 0 0 f f f t f s 1 0 19 "23" _null_ _null_ _null_ _null_ PG_encoding_to_char _null_ _null_ _null_ ));
|
||||||
DESCR("convert encoding id to encoding name");
|
DESCR("convert encoding id to encoding name");
|
||||||
|
|
||||||
|
DATA(insert OID = 2319 ( pg_encoding_max_length PGNSP PGUID 12 1 0 0 f f f t f i 1 0 23 "23" _null_ _null_ _null_ _null_ pg_encoding_max_length_sql _null_ _null_ _null_ ));
|
||||||
|
DESCR("maximum octet length of a character in an eocidng");
|
||||||
|
|
||||||
DATA(insert OID = 1638 ( oidgt PGNSP PGUID 12 1 0 0 f f f t f i 2 0 16 "26 26" _null_ _null_ _null_ _null_ oidgt _null_ _null_ _null_ ));
|
DATA(insert OID = 1638 ( oidgt PGNSP PGUID 12 1 0 0 f f f t f i 2 0 16 "26 26" _null_ _null_ _null_ _null_ oidgt _null_ _null_ _null_ ));
|
||||||
DESCR("greater-than");
|
DESCR("greater-than");
|
||||||
DATA(insert OID = 1639 ( oidge PGNSP PGUID 12 1 0 0 f f f t f i 2 0 16 "26 26" _null_ _null_ _null_ _null_ oidge _null_ _null_ _null_ ));
|
DATA(insert OID = 1639 ( oidge PGNSP PGUID 12 1 0 0 f f f t f i 2 0 16 "26 26" _null_ _null_ _null_ _null_ oidge _null_ _null_ _null_ ));
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.332 2009/03/09 14:34:34 petere Exp $
|
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.333 2009/07/07 18:23:15 petere Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -948,6 +948,7 @@ extern Datum pg_convert(PG_FUNCTION_ARGS);
|
|||||||
extern Datum pg_convert_to(PG_FUNCTION_ARGS);
|
extern Datum pg_convert_to(PG_FUNCTION_ARGS);
|
||||||
extern Datum pg_convert_from(PG_FUNCTION_ARGS);
|
extern Datum pg_convert_from(PG_FUNCTION_ARGS);
|
||||||
extern Datum length_in_encoding(PG_FUNCTION_ARGS);
|
extern Datum length_in_encoding(PG_FUNCTION_ARGS);
|
||||||
|
extern Datum pg_encoding_max_length_sql(PG_FUNCTION_ARGS);
|
||||||
|
|
||||||
/* format_type.c */
|
/* format_type.c */
|
||||||
extern Datum format_type(PG_FUNCTION_ARGS);
|
extern Datum format_type(PG_FUNCTION_ARGS);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user