Skip to content

Commit 69f909b

Browse files
committed
You might want to run pg_indent on pg_backup_db.c however ...
tom lane
1 parent 83b5ae6 commit 69f909b

File tree

4 files changed

+69
-65
lines changed

4 files changed

+69
-65
lines changed

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.39 2002/01/18 17:13:50 tgl Exp $
18+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.40 2002/01/18 19:17:04 momjian Exp $
1919
*
2020
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
2121
*
@@ -64,7 +64,7 @@
6464
*
6565
* Modifications - 18-Jan-2002 - pjw@rhyme.com.au
6666
* - Modified _tocEntryRequired to handle '<Init>/Max OID' as a special
67-
* case (ie. as a DATA item) as per bugs reported by Bruce Momjian
67+
* case (ie. as a DATA item) as per bugs reported by Bruce Momjian
6868
* around 17-Jan-2002.
6969
*
7070
*-------------------------------------------------------------------------
@@ -1922,12 +1922,12 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt)
19221922
res = res & ~REQ_DATA;
19231923
}
19241924

1925-
/* Special case: <Init> type with <Max OID> name; this is part of
1926-
* a DATA restore even though it has SQL.
1927-
*/
1928-
if ( ( strcmp(te->desc, "<Init>") == 0 ) && ( strcmp(te->name, "Max OID") == 0) ) {
1925+
/*
1926+
* Special case: <Init> type with <Max OID> name; this is part of a
1927+
* DATA restore even though it has SQL.
1928+
*/
1929+
if ((strcmp(te->desc, "<Init>") == 0) && (strcmp(te->name, "Max OID") == 0))
19291930
res = REQ_DATA;
1930-
}
19311931

19321932
/* Mask it if we only want schema */
19331933
if (ropt->schemaOnly)

src/bin/pg_dump/pg_backup_db.c

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Implements the basic DB functions used by the archiver.
66
*
77
* IDENTIFICATION
8-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.30 2002/01/18 17:13:51 tgl Exp $
8+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.31 2002/01/18 19:17:05 momjian Exp $
99
*
1010
* NOTES
1111
*
@@ -20,7 +20,7 @@
2020
*
2121
* Modifications - 18-Jan-2002 - pjw@rhyme.com.au
2222
*
23-
* - Split ExecuteSqlCommandBuf into 3 routines for (slightly) improved
23+
* - Split ExecuteSqlCommandBuf into 3 routines for (slightly) improved
2424
* clarity. Modify loop to cater for COPY commands buried in the SQL
2525
* command buffer (prev version assumed COPY command was executed
2626
* in prior call). This was to fix the buf in the 'set max oid' code.
@@ -51,8 +51,8 @@ static void _check_database_version(ArchiveHandle *AH, bool ignoreVersion);
5151
static PGconn *_connectDB(ArchiveHandle *AH, const char *newdbname, const char *newUser);
5252
static int _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc);
5353
static void notice_processor(void *arg, const char *message);
54-
static char* _sendSQLLine( ArchiveHandle *AH, char *qry, char *eos);
55-
static char* _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos);
54+
static char *_sendSQLLine(ArchiveHandle *AH, char *qry, char *eos);
55+
static char *_sendCopyLine(ArchiveHandle *AH, char *qry, char *eos);
5656

5757

5858
/*
@@ -544,23 +544,24 @@ _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc)
544544
return strlen(qry->data);
545545
}
546546

547-
/*
547+
/*
548548
* Used by ExecuteSqlCommandBuf to send one buffered line when running a COPY command.
549549
*/
550-
static char*
551-
_sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
550+
static char *
551+
_sendCopyLine(ArchiveHandle *AH, char *qry, char *eos)
552552
{
553-
int loc; /* Location of next newline */
554-
int pos = 0; /* Current position */
555-
int sPos = 0; /* Last pos of a slash char */
556-
int isEnd = 0;
553+
int loc; /* Location of next newline */
554+
int pos = 0; /* Current position */
555+
int sPos = 0; /* Last pos of a slash char */
556+
int isEnd = 0;
557557

558558
/* loop to find unquoted newline ending the line of COPY data */
559-
for (;;) {
559+
for (;;)
560+
{
560561
loc = strcspn(&qry[pos], "\n") + pos;
561562

562563
/* If no match, then wait */
563-
if (loc >= (eos - qry)) /* None found */
564+
if (loc >= (eos - qry)) /* None found */
564565
{
565566
appendBinaryPQExpBuffer(AH->pgCopyBuf, qry, (eos - qry));
566567
return eos;
@@ -579,8 +580,8 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
579580
sPos = loc - sPos;
580581

581582
/*
582-
* If an odd number of preceding slashes, then \n was escaped
583-
* so set the next search pos, and loop (if any left).
583+
* If an odd number of preceding slashes, then \n was escaped so
584+
* set the next search pos, and loop (if any left).
584585
*/
585586
if ((sPos & 1) == 1)
586587
{
@@ -591,9 +592,9 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
591592
appendBinaryPQExpBuffer(AH->pgCopyBuf, qry, (eos - qry));
592593
return eos;
593594
}
594-
} else {
595-
break;
596595
}
596+
else
597+
break;
597598
}
598599

599600
/* We found an unquoted newline */
@@ -613,8 +614,7 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
613614
resetPQExpBuffer(AH->pgCopyBuf);
614615

615616
/*
616-
* fprintf(stderr, "Buffer is '%s'\n",
617-
* AH->pgCopyBuf->data);
617+
* fprintf(stderr, "Buffer is '%s'\n", AH->pgCopyBuf->data);
618618
*/
619619

620620
if (isEnd)
@@ -628,24 +628,23 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
628628
return qry + loc + 1;
629629
}
630630

631-
/*
631+
/*
632632
* Used by ExecuteSqlCommandBuf to send one buffered line of SQL (not data for the copy command).
633633
*/
634-
static char*
635-
_sendSQLLine( ArchiveHandle *AH, char *qry, char *eos)
634+
static char *
635+
_sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
636636
{
637-
int pos = 0; /* Current position */
637+
int pos = 0; /* Current position */
638638

639639
/*
640-
* The following is a mini state machine to assess the end of an
641-
* SQL statement. It really only needs to parse good SQL, or at
642-
* least that's the theory... End-of-statement is assumed to be an
643-
* unquoted, un commented semi-colon.
640+
* The following is a mini state machine to assess the end of an SQL
641+
* statement. It really only needs to parse good SQL, or at least
642+
* that's the theory... End-of-statement is assumed to be an unquoted,
643+
* un commented semi-colon.
644644
*/
645645

646646
/*
647-
* fprintf(stderr, "Buffer at start is: '%s'\n\n",
648-
* AH->sqlBuf->data);
647+
* fprintf(stderr, "Buffer at start is: '%s'\n\n", AH->sqlBuf->data);
649648
*/
650649

651650
for (pos = 0; pos < (eos - qry); pos++)
@@ -656,7 +655,7 @@ _sendSQLLine( ArchiveHandle *AH, char *qry, char *eos)
656655
switch (AH->sqlparse.state)
657656
{
658657

659-
case SQL_SCAN: /* Default state == 0, set in _allocAH */
658+
case SQL_SCAN: /* Default state == 0, set in _allocAH */
660659

661660
if (qry[pos] == ';' && AH->sqlparse.braceDepth == 0)
662661
{
@@ -670,11 +669,12 @@ _sendSQLLine( ArchiveHandle *AH, char *qry, char *eos)
670669
resetPQExpBuffer(AH->sqlBuf);
671670
AH->sqlparse.lastChar = '\0';
672671

673-
/* Remove any following newlines - so that embedded COPY commands don't get a
674-
* starting newline.
672+
/*
673+
* Remove any following newlines - so that embedded
674+
* COPY commands don't get a starting newline.
675675
*/
676676
pos++;
677-
for ( ; pos < (eos - qry) && qry[pos] == '\n' ; pos++ ) ;
677+
for (; pos < (eos - qry) && qry[pos] == '\n'; pos++);
678678

679679
/* We've got our line, so exit */
680680
return qry + pos;
@@ -741,8 +741,11 @@ _sendSQLLine( ArchiveHandle *AH, char *qry, char *eos)
741741
/* fprintf(stderr, "\n"); */
742742
}
743743

744-
/* If we get here, we've processed entire string with no complete SQL stmt */
745-
return eos;
744+
/*
745+
* If we get here, we've processed entire string with no complete SQL
746+
* stmt
747+
*/
748+
return eos;
746749

747750
}
748751

@@ -762,11 +765,10 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen)
762765
/* Could switch between command and COPY IN mode at each line */
763766
while (qry < eos)
764767
{
765-
if (AH->pgCopyIn) {
768+
if (AH->pgCopyIn)
766769
qry = _sendCopyLine(AH, qry, eos);
767-
} else {
770+
else
768771
qry = _sendSQLLine(AH, qry, eos);
769-
}
770772
}
771773

772774
return 1;

src/bin/pg_dump/pg_dump.c

Lines changed: 18 additions & 16 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.237 2002/01/11 23:21:55 tgl Exp $
25+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.238 2002/01/18 19:17:05 momjian Exp $
2626
*
2727
*-------------------------------------------------------------------------
2828
*/
@@ -2035,7 +2035,7 @@ getFuncs(int *numFuncs)
20352035
* numTables is set to the number of tables read in
20362036
*/
20372037
TableInfo *
2038-
getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char* tablename)
2038+
getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char *tablename)
20392039
{
20402040
PGresult *res;
20412041
int ntups;
@@ -2127,14 +2127,15 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char* tablename)
21272127

21282128
/*
21292129
* First pass: extract data from result and lock tables. We do the
2130-
* locking before anything else, to minimize the window wherein a table
2131-
* could disappear under us.
2130+
* locking before anything else, to minimize the window wherein a
2131+
* table could disappear under us.
21322132
*
21332133
* Note that we have to collect info about all tables here, even when
21342134
* dumping only one, because we don't know which tables might be
21352135
* inheritance ancestors of the target table. Possible future
21362136
* improvement: suppress later collection of schema info about tables
2137-
* that are determined not to be either targets or ancestors of targets.
2137+
* that are determined not to be either targets or ancestors of
2138+
* targets.
21382139
*/
21392140
tblinfo = (TableInfo *) malloc(ntups * sizeof(TableInfo));
21402141

@@ -2167,26 +2168,27 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char* tablename)
21672168
*
21682169
* If no target tablename was specified, lock all tables we see,
21692170
* otherwise lock only the specified table. (This is incomplete
2170-
* because we'll still try to collect schema info about all tables,
2171-
* and could possibly lose during that phase. But for the typical
2172-
* use where we're dumping all tables anyway, it matters not.)
2171+
* because we'll still try to collect schema info about all
2172+
* tables, and could possibly lose during that phase. But for the
2173+
* typical use where we're dumping all tables anyway, it matters
2174+
* not.)
21732175
*
2174-
* NOTE: it'd be kinda nice to lock views and sequences too, not
2175-
* only plain tables, but the backend doesn't presently allow that.
2176+
* NOTE: it'd be kinda nice to lock views and sequences too, not only
2177+
* plain tables, but the backend doesn't presently allow that.
21762178
*/
21772179
if ((tblinfo[i].relkind == RELKIND_RELATION) &&
2178-
(tablename == NULL || strcmp(tblinfo[i].relname, tablename) == 0))
2180+
(tablename == NULL || strcmp(tblinfo[i].relname, tablename) == 0))
21792181
{
2180-
PGresult *lres;
2182+
PGresult *lres;
21812183

21822184
resetPQExpBuffer(lockquery);
21832185
appendPQExpBuffer(lockquery,
21842186
"LOCK TABLE %s IN ACCESS SHARE MODE",
21852187
fmtId(tblinfo[i].relname, force_quotes));
2186-
lres = PQexec(g_conn,lockquery->data);
2188+
lres = PQexec(g_conn, lockquery->data);
21872189
if (!lres || PQresultStatus(lres) != PGRES_COMMAND_OK)
21882190
{
2189-
write_msg(NULL, "Attempt to lock table \"%s\" failed. %s",
2191+
write_msg(NULL, "Attempt to lock table \"%s\" failed. %s",
21902192
tblinfo[i].relname, PQerrorMessage(g_conn));
21912193
exit_nicely();
21922194
}
@@ -2198,8 +2200,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char* tablename)
21982200
res = NULL;
21992201

22002202
/*
2201-
* Second pass: pick up additional information about each table,
2202-
* as required.
2203+
* Second pass: pick up additional information about each table, as
2204+
* required.
22032205
*/
22042206
for (i = 0; i < *numTables; i++)
22052207
{

src/bin/pg_dump/pg_restore.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
*
3636
* IDENTIFICATION
37-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.32 2002/01/10 01:11:45 tgl Exp $
37+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.33 2002/01/18 19:17:05 momjian Exp $
3838
*
3939
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
4040
*
@@ -393,7 +393,7 @@ usage(const char *progname)
393393
" -F, --format={c|t} specify backup file format\n"
394394
" -h, --host=HOSTNAME server host name\n"
395395
" -i, --index=NAME restore named index\n"
396-
" -l, --list print summarized TOC of the archive\n"
396+
" -l, --list print summarized TOC of the archive\n"
397397
" -L, --use-list=FILENAME use specified table of contents for ordering\n"
398398
" output from this file\n"
399399
" -N, --orig-order restore in original dump order\n"
@@ -429,12 +429,12 @@ usage(const char *progname)
429429
" -F {c|t} specify backup file format\n"
430430
" -h HOSTNAME server host name\n"
431431
" -i NAME restore named index\n"
432-
" -l print summarized TOC of the archive\n"
432+
" -l print summarized TOC of the archive\n"
433433
" -L FILENAME use specified table of contents for ordering\n"
434434
" output from this file\n"
435435
" -N restore in original dump order\n"
436436
" -o restore in OID order\n"
437-
" -O do not reconnect to database to match\n"
437+
" -O do not reconnect to database to match\n"
438438
" object owner\n"
439439
" -p PORT server port number\n"
440440
" -P NAME restore named function\n"

0 commit comments

Comments
 (0)