1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Avoid using NAMEDATALEN in pg_upgrade

Because the client encoding might not match the server encoding,
pg_upgrade can't allocate NAMEDATALEN bytes for storage of database,
relation, and namespace identifiers.  Instead pg_strdup() the memory and
free it.

Also add C comment in initdb.c about safe NAMEDATALEN usage.
This commit is contained in:
Bruce Momjian
2012-12-20 13:56:24 -05:00
parent af275a12df
commit dc9896a245
3 changed files with 27 additions and 17 deletions

View File

@ -114,8 +114,9 @@ extern char *output_files[];
*/
typedef struct
{
char nspname[NAMEDATALEN]; /* namespace name */
char relname[NAMEDATALEN]; /* relation name */
/* Can't use NAMEDATALEN; not guaranteed to fit on client */
char *nspname; /* namespace name */
char *relname; /* relation name */
Oid reloid; /* relation oid */
Oid relfilenode; /* relation relfile node */
/* relation tablespace path, or "" for the cluster default */
@ -143,8 +144,8 @@ typedef struct
Oid old_relfilenode;
Oid new_relfilenode;
/* the rest are used only for logging and error reporting */
char nspname[NAMEDATALEN]; /* namespaces */
char relname[NAMEDATALEN];
char *nspname; /* namespaces */
char *relname;
} FileNameMap;
/*
@ -153,7 +154,7 @@ typedef struct
typedef struct
{
Oid db_oid; /* oid of the database */
char db_name[NAMEDATALEN]; /* database name */
char *db_name; /* database name */
char db_tblspace[MAXPGPATH]; /* database default tablespace path */
RelInfoArr rel_arr; /* array of all user relinfos */
} DbInfo;