Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commited8aa97

Browse files
committed
Remove references to NAMEDATALEN and INDEX_MAX_KEYS from pg_dump. Handles
any size now.
1 parent8889eb0 commited8aa97

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
*
2424
* IDENTIFICATION
25-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.254 2002/04/2402:44:19 momjian Exp $
25+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.255 2002/04/2422:39:49 petere Exp $
2626
*
2727
*-------------------------------------------------------------------------
2828
*/
@@ -1802,10 +1802,12 @@ clearIndInfo(IndInfo *ind, int numIndexes)
18021802
free(ind[i].indexdef);
18031803
if (ind[i].indisprimary)
18041804
free(ind[i].indisprimary);
1805-
for (a=0;a<INDEX_MAX_KEYS;++a)
1805+
if (ind[i].indkey)
18061806
{
1807-
if (ind[i].indkey[a])
1808-
free(ind[i].indkey[a]);
1807+
for (a=0;a<ind[i].indnkeys;++a)
1808+
if (ind[i].indkey[a])
1809+
free(ind[i].indkey[a]);
1810+
free(ind[i].indkey);
18091811
}
18101812
}
18111813
free(ind);
@@ -3020,6 +3022,7 @@ getIndexes(int *numIndexes)
30203022
inti_indrelname;
30213023
inti_indexdef;
30223024
inti_indisprimary;
3025+
inti_indnkeys;
30233026
inti_indkey;
30243027

30253028
/*
@@ -3033,11 +3036,14 @@ getIndexes(int *numIndexes)
30333036
appendPQExpBuffer(query,
30343037
"SELECT i.indexrelid as indexreloid, "
30353038
"i.indrelid as indreloid, "
3036-
"t1.relname as indexrelname, t2.relname as indrelname, "
3039+
"t1.relname as indexrelname, t2.relname as indrelname, "
30373040
"pg_get_indexdef(i.indexrelid) as indexdef, "
3038-
"i.indisprimary, i.indkey "
3039-
"from pg_index i, pg_class t1, pg_class t2 "
3040-
"WHERE t1.oid = i.indexrelid and t2.oid = i.indrelid "
3041+
"i.indisprimary, i.indkey, "
3042+
"CASE WHEN regproctooid(i.indproc) <> 0 "
3043+
" THEN (SELECT pronargs FROM pg_proc WHERE pg_proc.oid = regproctooid(i.indproc)) "
3044+
" ELSE t1.relnatts END as indnkeys "
3045+
"FROM pg_index i, pg_class t1, pg_class t2 "
3046+
"WHERE t1.oid = i.indexrelid and t2.oid = i.indrelid "
30413047
"and i.indexrelid > '%u'::oid "
30423048
"and t2.relname !~ '^pg_' ",
30433049
g_last_builtin_oid);
@@ -3067,6 +3073,7 @@ getIndexes(int *numIndexes)
30673073
i_indrelname=PQfnumber(res,"indrelname");
30683074
i_indexdef=PQfnumber(res,"indexdef");
30693075
i_indisprimary=PQfnumber(res,"indisprimary");
3076+
i_indnkeys=PQfnumber(res,"indnkeys");
30703077
i_indkey=PQfnumber(res,"indkey");
30713078

30723079
for (i=0;i<ntups;i++)
@@ -3077,9 +3084,11 @@ getIndexes(int *numIndexes)
30773084
indinfo[i].indrelname=strdup(PQgetvalue(res,i,i_indrelname));
30783085
indinfo[i].indexdef=strdup(PQgetvalue(res,i,i_indexdef));
30793086
indinfo[i].indisprimary=strdup(PQgetvalue(res,i,i_indisprimary));
3087+
indinfo[i].indnkeys=atoi(PQgetvalue(res,i,i_indnkeys));
3088+
indinfo[i].indkey=malloc(indinfo[i].indnkeys*sizeof(indinfo[i].indkey[0]));
30803089
parseNumericArray(PQgetvalue(res,i,i_indkey),
30813090
indinfo[i].indkey,
3082-
INDEX_MAX_KEYS);
3091+
indinfo[i].indnkeys);
30833092
}
30843093
PQclear(res);
30853094

@@ -3577,7 +3586,7 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i,
35773586
PQExpBufferdelqry=createPQExpBuffer();
35783587
PQExpBufferfnlist=createPQExpBuffer();
35793588
PQExpBufferasPart=createPQExpBuffer();
3580-
charfunc_lang[NAMEDATALEN+1];
3589+
char*func_lang=NULL;
35813590
PGresult*res;
35823591
intnlangs;
35833592
intj;
@@ -3638,7 +3647,7 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i,
36383647
}
36393648
}
36403649

3641-
strcpy(func_lang,PQgetvalue(res,0,i_lanname));
3650+
func_lang=strdup(PQgetvalue(res,0,i_lanname));
36423651

36433652
PQclear(res);
36443653

@@ -3749,6 +3758,7 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i,
37493758
destroyPQExpBuffer(delqry);
37503759
destroyPQExpBuffer(fnlist);
37513760
destroyPQExpBuffer(asPart);
3761+
free(func_lang);
37523762
}
37533763

37543764
/*
@@ -4515,7 +4525,7 @@ getPKconstraint(TableInfo *tblInfo, IndInfo *indInfo)
45154525
appendPQExpBuffer(pkBuf,"Constraint %s Primary Key (",
45164526
tblInfo->primary_key_name);
45174527

4518-
for (k=0;k<INDEX_MAX_KEYS;k++)
4528+
for (k=0;k<indInfo->indnkeys;k++)
45194529
{
45204530
intindkey;
45214531
constchar*attname;

‎src/bin/pg_dump/pg_dump.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: pg_dump.h,v 1.83 2002/04/2402:44:19 momjian Exp $
9+
* $Id: pg_dump.h,v 1.84 2002/04/2422:39:49 petere Exp $
1010
*
1111
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
1212
*
@@ -148,8 +148,9 @@ typedef struct _indInfo
148148
char*indrelname;/* name of the indexed table */
149149
char*indexdef;/* index definitional command */
150150
char*indisprimary;/* is this a PK index? */
151-
char*indkey[INDEX_MAX_KEYS];/* attribute numbers of the key
152-
* attributes */
151+
intindnkeys;/* number of keys in index */
152+
char**indkey;/* attribute numbers of the key
153+
* attributes */
153154
}IndInfo;
154155

155156
typedefstruct_aggInfo

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp