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

Commitf3af534

Browse files
committed
Support multiple -t/--table arguments for more commands
On top of the previous support in pg_dump, add support to specifymultiple tables (by using the -t option multiple times) topg_restore, clsuterdb, reindexdb and vacuumdb.Josh Kupershmidt, reviewed by Karl O. Pinc
1 parent36bdfa5 commitf3af534

File tree

15 files changed

+191
-111
lines changed

15 files changed

+191
-111
lines changed

‎doc/src/sgml/ref/clusterdb.sgml‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,17 @@ PostgreSQL documentation
2424
<command>clusterdb</command>
2525
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
2626
<group choice="opt"><arg choice="plain"><option>--verbose</option></arg><arg choice="plain"><option>-v</option></arg></group>
27-
<arg choice="opt"><group choice="plain"><arg choice="plain"><option>--table</option></arg><arg choice="plain"><option>-t</option></arg></group> <replaceable>table</replaceable> </arg>
27+
28+
<arg choice="plain" rep="repeat">
29+
<arg choice="opt">
30+
<group choice="plain">
31+
<arg choice="plain"><option>--table</option></arg>
32+
<arg choice="plain"><option>-t</option></arg>
33+
</group>
34+
<replaceable>table</replaceable>
35+
</arg>
36+
</arg>
37+
2838
<arg choice="opt"><replaceable>dbname</replaceable></arg>
2939
</cmdsynopsis>
3040

@@ -117,6 +127,8 @@ PostgreSQL documentation
117127
<listitem>
118128
<para>
119129
Cluster <replaceable class="parameter">table</replaceable> only.
130+
Multiple tables can be clustered by writing multiple
131+
<option>-t</> switches.
120132
</para>
121133
</listitem>
122134
</varlistentry>

‎doc/src/sgml/ref/pg_restore.sgml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@
400400
<term><option>--table=<replaceable class="parameter">table</replaceable></option></term>
401401
<listitem>
402402
<para>
403-
Restore definition and/or data of named table only. This can be
403+
Restore definition and/or data of named table only. Multiple tables
404+
may be specified with multiple <option>-t</> switches. This can be
404405
combined with the <option>-n</option> option to specify a schema.
405406
</para>
406407
</listitem>

‎doc/src/sgml/ref/reindexdb.sgml‎

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,27 @@ PostgreSQL documentation
2323
<cmdsynopsis>
2424
<command>reindexdb</command>
2525
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
26-
<group choice="opt">
27-
<group choice="plain">
28-
<arg choice="plain"><option>--table</option></arg>
29-
<arg choice="plain"><option>-t</option></arg>
30-
</group>
31-
<replaceable>table</replaceable>
32-
</group>
33-
<group choice="opt">
34-
<group choice="plain">
35-
<arg choice="plain"><option>--index</option></arg>
36-
<arg choice="plain"><option>-i</option></arg>
37-
</group>
38-
<replaceable>index</replaceable>
39-
</group>
26+
27+
<arg choice="plain" rep="repeat">
28+
<arg choice="opt">
29+
<group choice="plain">
30+
<arg choice="plain"><option>--table</option></arg>
31+
<arg choice="plain"><option>-t</option></arg>
32+
</group>
33+
<replaceable>table</replaceable>
34+
</arg>
35+
</arg>
36+
37+
<arg choice="plain" rep="repeat">
38+
<arg choice="opt">
39+
<group choice="plain">
40+
<arg choice="plain"><option>--index</option></arg>
41+
<arg choice="plain"><option>-i</option></arg>
42+
</group>
43+
<replaceable>index</replaceable>
44+
</arg>
45+
</arg>
46+
4047
<arg choice="opt"><replaceable>dbname</replaceable></arg>
4148
</cmdsynopsis>
4249

@@ -128,6 +135,8 @@ PostgreSQL documentation
128135
<listitem>
129136
<para>
130137
Recreate <replaceable class="parameter">index</replaceable> only.
138+
Multiple indexes can be recreated by writing multiple
139+
<option>-i</> switches.
131140
</para>
132141
</listitem>
133142
</varlistentry>
@@ -158,6 +167,8 @@ PostgreSQL documentation
158167
<listitem>
159168
<para>
160169
Reindex <replaceable class="parameter">table</replaceable> only.
170+
Multiple tables can be reindexed by writing multiple
171+
<option>-t</> switches.
161172
</para>
162173
</listitem>
163174
</varlistentry>

‎doc/src/sgml/ref/vacuumdb.sgml‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,18 @@ PostgreSQL documentation
2424
<command>vacuumdb</command>
2525
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
2626
<arg rep="repeat"><replaceable>option</replaceable></arg>
27-
<arg choice="opt">
28-
<group choice="plain">
29-
<arg choice="plain"><option>--table</option></arg>
30-
<arg choice="plain"><option>-t</option></arg>
31-
</group>
32-
<replaceable>table</replaceable>
33-
<arg choice="opt">( <replaceable class="parameter">column</replaceable> [,...] )</arg>
27+
28+
<arg choice="plain" rep="repeat">
29+
<arg choice="opt">
30+
<group choice="plain">
31+
<arg choice="plain"><option>--table</option></arg>
32+
<arg choice="plain"><option>-t</option></arg>
33+
</group>
34+
<replaceable>table</replaceable>
35+
<arg choice="opt">( <replaceable class="parameter">column</replaceable> [,...] )</arg>
36+
</arg>
3437
</arg>
38+
3539
<arg choice="opt"><replaceable>dbname</replaceable></arg>
3640
</cmdsynopsis>
3741

@@ -147,6 +151,8 @@ PostgreSQL documentation
147151
Clean or analyze <replaceable class="parameter">table</replaceable> only.
148152
Column names can be specified only in conjunction with
149153
the <option>--analyze</option> or <option>--analyze-only</option> options.
154+
Multiple tables can be vacuumed by writing multiple
155+
<option>-t</> switches.
150156
</para>
151157
<tip>
152158
<para>

‎src/bin/pg_dump/common.c‎

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -898,24 +898,6 @@ simple_oid_list_append(SimpleOidList *list, Oid val)
898898
list->tail=cell;
899899
}
900900

901-
void
902-
simple_string_list_append(SimpleStringList*list,constchar*val)
903-
{
904-
SimpleStringListCell*cell;
905-
906-
/* this calculation correctly accounts for the null trailing byte */
907-
cell= (SimpleStringListCell*)
908-
pg_malloc(sizeof(SimpleStringListCell)+strlen(val));
909-
cell->next=NULL;
910-
strcpy(cell->val,val);
911-
912-
if (list->tail)
913-
list->tail->next=cell;
914-
else
915-
list->head=cell;
916-
list->tail=cell;
917-
}
918-
919901
bool
920902
simple_oid_list_member(SimpleOidList*list,Oidval)
921903
{
@@ -928,16 +910,3 @@ simple_oid_list_member(SimpleOidList *list, Oid val)
928910
}
929911
return false;
930912
}
931-
932-
bool
933-
simple_string_list_member(SimpleStringList*list,constchar*val)
934-
{
935-
SimpleStringListCell*cell;
936-
937-
for (cell=list->head;cell;cell=cell->next)
938-
{
939-
if (strcmp(cell->val,val)==0)
940-
return true;
941-
}
942-
return false;
943-
}

‎src/bin/pg_dump/dumputils.c‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include<ctype.h>
1818

1919
#include"dumputils.h"
20+
#include"dumpmem.h"
2021

2122
#include"parser/keywords.h"
2223

@@ -1352,3 +1353,35 @@ exit_nicely(int code)
13521353

13531354
exit(code);
13541355
}
1356+
1357+
void
1358+
simple_string_list_append(SimpleStringList*list,constchar*val)
1359+
{
1360+
SimpleStringListCell*cell;
1361+
1362+
/* this calculation correctly accounts for the null trailing byte */
1363+
cell= (SimpleStringListCell*)
1364+
pg_malloc(sizeof(SimpleStringListCell)+strlen(val));
1365+
1366+
cell->next=NULL;
1367+
strcpy(cell->val,val);
1368+
1369+
if (list->tail)
1370+
list->tail->next=cell;
1371+
else
1372+
list->head=cell;
1373+
list->tail=cell;
1374+
}
1375+
1376+
bool
1377+
simple_string_list_member(SimpleStringList*list,constchar*val)
1378+
{
1379+
SimpleStringListCell*cell;
1380+
1381+
for (cell=list->head;cell;cell=cell->next)
1382+
{
1383+
if (strcmp(cell->val,val)==0)
1384+
return true;
1385+
}
1386+
return false;
1387+
}

‎src/bin/pg_dump/dumputils.h‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ typedef enum/* bits returned by set_dump_section */
2727
DUMP_UNSECTIONED=0xff
2828
}DumpSections;
2929

30+
typedefstructSimpleStringListCell
31+
{
32+
structSimpleStringListCell*next;
33+
charval[1];/* VARIABLE LENGTH FIELD */
34+
}SimpleStringListCell;
35+
36+
typedefstructSimpleStringList
37+
{
38+
SimpleStringListCell*head;
39+
SimpleStringListCell*tail;
40+
}SimpleStringList;
41+
42+
3043
typedefvoid (*on_exit_nicely_callback) (intcode,void*arg);
3144

3245
externintquote_all_identifiers;
@@ -75,4 +88,8 @@ __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3), noreturn));
7588
externvoidon_exit_nicely(on_exit_nicely_callbackfunction,void*arg);
7689
externvoidexit_nicely(intcode) __attribute__((noreturn));
7790

91+
externvoidsimple_string_list_append(SimpleStringList*list,constchar*val);
92+
externboolsimple_string_list_member(SimpleStringList*list,constchar*val);
93+
94+
7895
#endif/* DUMPUTILS_H */

‎src/bin/pg_dump/pg_backup.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include"postgres_fe.h"
2727

2828
#include"pg_dump.h"
29+
#include"dumputils.h"
2930

3031
#include"libpq-fe.h"
3132

@@ -125,9 +126,9 @@ typedef struct _restoreOptions
125126
intselTable;
126127
char*indexNames;
127128
char*functionNames;
128-
char*tableNames;
129129
char*schemaNames;
130130
char*triggerNames;
131+
SimpleStringListtableNames;
131132

132133
intuseDB;
133134
char*dbname;

‎src/bin/pg_dump/pg_backup_archiver.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2493,7 +2493,7 @@ _tocEntryRequired(TocEntry *te, teSection curSection, RestoreOptions *ropt)
24932493
{
24942494
if (!ropt->selTable)
24952495
return0;
2496-
if (ropt->tableNames&&strcmp(ropt->tableNames,te->tag)!=0)
2496+
if (ropt->tableNames.head!=NULL&&(!(simple_string_list_member(&ropt->tableNames,te->tag))))
24972497
return0;
24982498
}
24992499
elseif (strcmp(te->desc,"INDEX")==0)

‎src/bin/pg_dump/pg_dump.h‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,6 @@ typedef struct SimpleOidList
5858
SimpleOidListCell*tail;
5959
}SimpleOidList;
6060

61-
typedefstructSimpleStringListCell
62-
{
63-
structSimpleStringListCell*next;
64-
charval[1];/* VARIABLE LENGTH FIELD */
65-
}SimpleStringListCell;
66-
67-
typedefstructSimpleStringList
68-
{
69-
SimpleStringListCell*head;
70-
SimpleStringListCell*tail;
71-
}SimpleStringList;
7261

7362
/*
7463
* The data structures used to store system catalog information. Every
@@ -533,9 +522,7 @@ extern CollInfo *findCollationByOid(Oid oid);
533522
externNamespaceInfo*findNamespaceByOid(Oidoid);
534523

535524
externvoidsimple_oid_list_append(SimpleOidList*list,Oidval);
536-
externvoidsimple_string_list_append(SimpleStringList*list,constchar*val);
537525
externboolsimple_oid_list_member(SimpleOidList*list,Oidval);
538-
externboolsimple_string_list_member(SimpleStringList*list,constchar*val);
539526

540527
externvoidparseOidArray(constchar*str,Oid*array,intarraysize);
541528

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp