Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit de81fbd

Browse files
committed
I've got 2 pretty small patches.
configtype.patch simply fixes a typo in config.h.in pg_dump.c.patch Updates a bunch of error messages to include a reason from the backend, and also removes a couple of unnecessary if's Ole Gjerde
1 parent c8bd630 commit de81fbd

File tree

2 files changed

+40
-44
lines changed

2 files changed

+40
-44
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
*
2323
* IDENTIFICATION
24-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.106 1999/05/13 02:35:44 momjian Exp $
24+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.107 1999/05/15 22:18:50 momjian Exp $
2525
*
2626
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
2727
*
@@ -194,7 +194,7 @@ isViewRule(char *relname)
194194
if (!res ||
195195
PQresultStatus(res) != PGRES_COMMAND_OK)
196196
{
197-
fprintf(stderr, "BEGIN command failed\n");
197+
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
198198
exit_nicely(g_conn);
199199
}
200200
PQclear(res);
@@ -208,7 +208,7 @@ isViewRule(char *relname)
208208
if (!res ||
209209
PQresultStatus(res) != PGRES_TUPLES_OK)
210210
{
211-
fprintf(stderr, "isViewRule(): SELECT failed\n");
211+
fprintf(stderr, "isViewRule(): SELECT failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
212212
exit_nicely(g_conn);
213213
}
214214

@@ -306,12 +306,9 @@ dumpClasses_nodumpData(FILE *fout, const char *classname, const bool oids)
306306
"Explanation from backend: '%s'.\n"
307307
"The query was: '%s'.\n",
308308
classname, PQerrorMessage(g_conn), query);
309-
if (res)
310-
PQclear(res);
309+
PQclear(res);
311310
exit_nicely(g_conn);
312311
}
313-
if (res)
314-
PQclear(res);
315312
}
316313
}
317314

@@ -333,7 +330,7 @@ dumpClasses_dumpData(FILE *fout, const char *classname,
333330
if (!res ||
334331
PQresultStatus(res) != PGRES_TUPLES_OK)
335332
{
336-
fprintf(stderr, "dumpClasses(): command failed\n");
333+
fprintf(stderr, "dumpClasses(): command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
337334
exit_nicely(g_conn);
338335
}
339336
for (tuple = 0; tuple < PQntuples(res); tuple++)
@@ -771,7 +768,7 @@ getTypes(int *numTypes)
771768
if (!res ||
772769
PQresultStatus(res) != PGRES_COMMAND_OK)
773770
{
774-
fprintf(stderr, "BEGIN command failed\n");
771+
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
775772
exit_nicely(g_conn);
776773
}
777774
PQclear(res);
@@ -796,7 +793,7 @@ getTypes(int *numTypes)
796793
if (!res ||
797794
PQresultStatus(res) != PGRES_TUPLES_OK)
798795
{
799-
fprintf(stderr, "getTypes(): SELECT failed\n");
796+
fprintf(stderr, "getTypes(): SELECT failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
800797
exit_nicely(g_conn);
801798
}
802799

@@ -904,7 +901,7 @@ getOperators(int *numOprs)
904901
if (!res ||
905902
PQresultStatus(res) != PGRES_COMMAND_OK)
906903
{
907-
fprintf(stderr, "BEGIN command failed\n");
904+
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
908905
exit_nicely(g_conn);
909906
}
910907
PQclear(res);
@@ -919,7 +916,7 @@ getOperators(int *numOprs)
919916
if (!res ||
920917
PQresultStatus(res) != PGRES_TUPLES_OK)
921918
{
922-
fprintf(stderr, "getOperators(): SELECT failed\n");
919+
fprintf(stderr, "getOperators(): SELECT failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
923920
exit_nicely(g_conn);
924921
}
925922

@@ -1241,7 +1238,7 @@ getAggregates(int *numAggs)
12411238
if (!res ||
12421239
PQresultStatus(res) != PGRES_COMMAND_OK)
12431240
{
1244-
fprintf(stderr, "BEGIN command failed\n");
1241+
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
12451242
exit_nicely(g_conn);
12461243
}
12471244
PQclear(res);
@@ -1256,7 +1253,7 @@ getAggregates(int *numAggs)
12561253
if (!res ||
12571254
PQresultStatus(res) != PGRES_TUPLES_OK)
12581255
{
1259-
fprintf(stderr, "getAggregates(): SELECT failed\n");
1256+
fprintf(stderr, "getAggregates(): SELECT failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
12601257
exit_nicely(g_conn);
12611258
}
12621259

@@ -1334,7 +1331,7 @@ getFuncs(int *numFuncs)
13341331
if (!res ||
13351332
PQresultStatus(res) != PGRES_COMMAND_OK)
13361333
{
1337-
fprintf(stderr, "BEGIN command failed\n");
1334+
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
13381335
exit_nicely(g_conn);
13391336
}
13401337
PQclear(res);
@@ -1350,7 +1347,7 @@ getFuncs(int *numFuncs)
13501347
if (!res ||
13511348
PQresultStatus(res) != PGRES_TUPLES_OK)
13521349
{
1353-
fprintf(stderr, "getFuncs(): SELECT failed\n");
1350+
fprintf(stderr, "getFuncs(): SELECT failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
13541351
exit_nicely(g_conn);
13551352
}
13561353

@@ -1437,7 +1434,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
14371434
if (!res ||
14381435
PQresultStatus(res) != PGRES_COMMAND_OK)
14391436
{
1440-
fprintf(stderr, "BEGIN command failed\n");
1437+
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
14411438
exit_nicely(g_conn);
14421439
}
14431440
PQclear(res);
@@ -1454,7 +1451,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
14541451
if (!res ||
14551452
PQresultStatus(res) != PGRES_TUPLES_OK)
14561453
{
1457-
fprintf(stderr, "getTables(): SELECT failed\n");
1454+
fprintf(stderr, "getTables(): SELECT failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
14581455
exit_nicely(g_conn);
14591456
}
14601457

@@ -1511,7 +1508,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
15111508
if (!res2 ||
15121509
PQresultStatus(res2) != PGRES_TUPLES_OK)
15131510
{
1514-
fprintf(stderr, "getTables(): SELECT (for inherited CHECK) failed\n");
1511+
fprintf(stderr, "getTables(): SELECT (for inherited CHECK) failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
15151512
exit_nicely(g_conn);
15161513
}
15171514
ntups2 = PQntuples(res2);
@@ -1554,7 +1551,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
15541551
if (!res2 ||
15551552
PQresultStatus(res2) != PGRES_TUPLES_OK)
15561553
{
1557-
fprintf(stderr, "getTables(): SELECT (for CHECK) failed\n");
1554+
fprintf(stderr, "getTables(): SELECT (for CHECK) failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
15581555
exit_nicely(g_conn);
15591556
}
15601557
ntups2 = PQntuples(res2);
@@ -1609,7 +1606,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
16091606
if (!res2 ||
16101607
PQresultStatus(res2) != PGRES_TUPLES_OK)
16111608
{
1612-
fprintf(stderr, "getTables(): SELECT (for TRIGGER) failed\n");
1609+
fprintf(stderr, "getTables(): SELECT (for TRIGGER) failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
16131610
exit_nicely(g_conn);
16141611
}
16151612
ntups2 = PQntuples(res2);
@@ -1770,7 +1767,7 @@ getInherits(int *numInherits)
17701767
if (!res ||
17711768
PQresultStatus(res) != PGRES_COMMAND_OK)
17721769
{
1773-
fprintf(stderr, "BEGIN command failed\n");
1770+
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
17741771
exit_nicely(g_conn);
17751772
}
17761773
PQclear(res);
@@ -1781,7 +1778,7 @@ getInherits(int *numInherits)
17811778
if (!res ||
17821779
PQresultStatus(res) != PGRES_TUPLES_OK)
17831780
{
1784-
fprintf(stderr, "getInherits(): SELECT failed\n");
1781+
fprintf(stderr, "getInherits(): SELECT failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
17851782
exit_nicely(g_conn);
17861783
}
17871784

@@ -1859,7 +1856,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
18591856
if (!res ||
18601857
PQresultStatus(res) != PGRES_TUPLES_OK)
18611858
{
1862-
fprintf(stderr, "getTableAttrs(): SELECT failed\n");
1859+
fprintf(stderr, "getTableAttrs(): SELECT failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
18631860
exit_nicely(g_conn);
18641861
}
18651862

@@ -1905,7 +1902,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
19051902
if (!res2 ||
19061903
PQresultStatus(res2) != PGRES_TUPLES_OK)
19071904
{
1908-
fprintf(stderr, "getTableAttrs(): SELECT (for DEFAULT) failed\n");
1905+
fprintf(stderr, "getTableAttrs(): SELECT (for DEFAULT) failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
19091906
exit_nicely(g_conn);
19101907
}
19111908
tblinfo[i].adef_expr[j] = strdup(PQgetvalue(res2, 0, PQfnumber(res2, "adsrc")));
@@ -1958,7 +1955,7 @@ getIndices(int *numIndices)
19581955
if (!res ||
19591956
PQresultStatus(res) != PGRES_COMMAND_OK)
19601957
{
1961-
fprintf(stderr, "BEGIN command failed\n");
1958+
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
19621959
exit_nicely(g_conn);
19631960
}
19641961
PQclear(res);
@@ -1977,7 +1974,7 @@ getIndices(int *numIndices)
19771974
if (!res ||
19781975
PQresultStatus(res) != PGRES_TUPLES_OK)
19791976
{
1980-
fprintf(stderr, "getIndices(): SELECT failed\n");
1977+
fprintf(stderr, "getIndices(): SELECT failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
19811978
exit_nicely(g_conn);
19821979
}
19831980

@@ -2009,8 +2006,7 @@ getIndices(int *numIndices)
20092006
}
20102007
PQclear(res);
20112008
res = PQexec(g_conn, "end");
2012-
if (res)
2013-
PQclear(res);
2009+
PQclear(res);
20142010
return indinfo;
20152011
}
20162012

@@ -2120,7 +2116,7 @@ dumpProcLangs(FILE *fout, FuncInfo *finfo, int numFuncs,
21202116
if (!res ||
21212117
PQresultStatus(res) != PGRES_COMMAND_OK)
21222118
{
2123-
fprintf(stderr, "BEGIN command failed\n");
2119+
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
21242120
exit_nicely(g_conn);
21252121
}
21262122

@@ -2131,7 +2127,7 @@ dumpProcLangs(FILE *fout, FuncInfo *finfo, int numFuncs,
21312127
if (!res ||
21322128
PQresultStatus(res) != PGRES_TUPLES_OK)
21332129
{
2134-
fprintf(stderr, "dumpProcLangs(): SELECT failed\n");
2130+
fprintf(stderr, "dumpProcLangs(): SELECT failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
21352131
exit_nicely(g_conn);
21362132
}
21372133
ntups = PQntuples(res);
@@ -2243,7 +2239,7 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i,
22432239
if (!res ||
22442240
PQresultStatus(res) != PGRES_COMMAND_OK)
22452241
{
2246-
fprintf(stderr, "dumpOneFunc(): BEGIN command failed\n");
2242+
fprintf(stderr, "dumpOneFunc(): BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
22472243
exit_nicely(g_conn);
22482244
}
22492245
PQclear(res);
@@ -2255,7 +2251,7 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i,
22552251
if (!res ||
22562252
PQresultStatus(res) != PGRES_TUPLES_OK)
22572253
{
2258-
fprintf(stderr, "dumpOneFunc(): SELECT for procedural language failed\n");
2254+
fprintf(stderr, "dumpOneFunc(): SELECT for procedural language failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
22592255
exit_nicely(g_conn);
22602256
}
22612257
nlangs = PQntuples(res);
@@ -2873,7 +2869,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
28732869
res = PQexec(g_conn, q);
28742870
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
28752871
{
2876-
fprintf(stderr, "dumpIndices(): SELECT (funcname) failed\n");
2872+
fprintf(stderr, "dumpIndices(): SELECT (funcname) failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
28772873
exit_nicely(g_conn);
28782874
}
28792875
funcname = strdup(PQgetvalue(res, 0,
@@ -2894,7 +2890,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
28942890
res = PQexec(g_conn, q);
28952891
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
28962892
{
2897-
fprintf(stderr, "dumpIndices(): SELECT (classname) failed\n");
2893+
fprintf(stderr, "dumpIndices(): SELECT (classname) failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
28982894
exit_nicely(g_conn);
28992895
}
29002896
classname[nclass] = strdup(PQgetvalue(res, 0,
@@ -3059,15 +3055,15 @@ setMaxOid(FILE *fout)
30593055
if (!res ||
30603056
PQresultStatus(res) != PGRES_COMMAND_OK)
30613057
{
3062-
fprintf(stderr, "Can not create pgdump_oid table\n");
3058+
fprintf(stderr, "Can not create pgdump_oid table. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
30633059
exit_nicely(g_conn);
30643060
}
30653061
PQclear(res);
30663062
res = PQexec(g_conn, "INSERT INTO pgdump_oid VALUES (0)");
30673063
if (!res ||
30683064
PQresultStatus(res) != PGRES_COMMAND_OK)
30693065
{
3070-
fprintf(stderr, "Can not insert into pgdump_oid table\n");
3066+
fprintf(stderr, "Can not insert into pgdump_oid table. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
30713067
exit_nicely(g_conn);
30723068
}
30733069
max_oid = atol(PQoidStatus(res));
@@ -3081,7 +3077,7 @@ setMaxOid(FILE *fout)
30813077
if (!res ||
30823078
PQresultStatus(res) != PGRES_COMMAND_OK)
30833079
{
3084-
fprintf(stderr, "Can not drop pgdump_oid table\n");
3080+
fprintf(stderr, "Can not drop pgdump_oid table. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
30853081
exit_nicely(g_conn);
30863082
}
30873083
PQclear(res);
@@ -3114,7 +3110,7 @@ findLastBuiltinOid(void)
31143110
if (res == NULL ||
31153111
PQresultStatus(res) != PGRES_TUPLES_OK)
31163112
{
3117-
fprintf(stderr, "pg_dump error in finding the template1 database\n");
3113+
fprintf(stderr, "pg_dump error in finding the template1 database. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
31183114
exit_nicely(g_conn);
31193115
}
31203116
ntups = PQntuples(res);
@@ -3187,7 +3183,7 @@ dumpSequence(FILE *fout, TableInfo tbinfo)
31873183
res = PQexec(g_conn, query);
31883184
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
31893185
{
3190-
fprintf(stderr, "dumpSequence(%s): SELECT failed\n", tbinfo.relname);
3186+
fprintf(stderr, "dumpSequence(%s): SELECT failed. Explanation from backend: '%s'.\n", tbinfo.relname, PQerrorMessage(g_conn));
31913187
exit_nicely(g_conn);
31923188
}
31933189

@@ -3293,7 +3289,7 @@ dumpRules(FILE *fout, const char *tablename,
32933289
if (!res ||
32943290
PQresultStatus(res) != PGRES_COMMAND_OK)
32953291
{
3296-
fprintf(stderr, "BEGIN command failed\n");
3292+
fprintf(stderr, "BEGIN command failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
32973293
exit_nicely(g_conn);
32983294
}
32993295
PQclear(res);
@@ -3311,8 +3307,8 @@ dumpRules(FILE *fout, const char *tablename,
33113307
if (!res ||
33123308
PQresultStatus(res) != PGRES_TUPLES_OK)
33133309
{
3314-
fprintf(stderr, "dumpRules(): SELECT failed for table %s\n",
3315-
tblinfo[t].relname);
3310+
fprintf(stderr, "dumpRules(): SELECT failed for table %s. Explanation from backend: '%s'.\n",
3311+
tblinfo[t].relname, PQerrorMessage(g_conn));
33163312
exit_nicely(g_conn);
33173313
}
33183314

src/include/config.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ extern void srandom(unsigned int seed);
399399
#define DEADLOCK_CHECK_TIMER 1
400400

401401
/*
402-
* This flag enables the use of idexes in plans generated for function
402+
* This flag enables the use of indexes in plans generated for function
403403
* executions which normally are always executed with sequential scans.
404404
*/
405405
#define INDEXSCAN_PATCH

0 commit comments

Comments
 (0)