21
21
*
22
22
*
23
23
* 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 $
25
25
*
26
26
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
27
27
*
@@ -194,7 +194,7 @@ isViewRule(char *relname)
194
194
if (!res ||
195
195
PQresultStatus (res ) != PGRES_COMMAND_OK )
196
196
{
197
- fprintf (stderr , "BEGIN command failed\n" );
197
+ fprintf (stderr , "BEGIN command failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
198
198
exit_nicely (g_conn );
199
199
}
200
200
PQclear (res );
@@ -208,7 +208,7 @@ isViewRule(char *relname)
208
208
if (!res ||
209
209
PQresultStatus (res ) != PGRES_TUPLES_OK )
210
210
{
211
- fprintf (stderr , "isViewRule(): SELECT failed\n" );
211
+ fprintf (stderr , "isViewRule(): SELECT failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
212
212
exit_nicely (g_conn );
213
213
}
214
214
@@ -306,12 +306,9 @@ dumpClasses_nodumpData(FILE *fout, const char *classname, const bool oids)
306
306
"Explanation from backend: '%s'.\n"
307
307
"The query was: '%s'.\n" ,
308
308
classname , PQerrorMessage (g_conn ), query );
309
- if (res )
310
- PQclear (res );
309
+ PQclear (res );
311
310
exit_nicely (g_conn );
312
311
}
313
- if (res )
314
- PQclear (res );
315
312
}
316
313
}
317
314
@@ -333,7 +330,7 @@ dumpClasses_dumpData(FILE *fout, const char *classname,
333
330
if (!res ||
334
331
PQresultStatus (res ) != PGRES_TUPLES_OK )
335
332
{
336
- fprintf (stderr , "dumpClasses(): command failed\n" );
333
+ fprintf (stderr , "dumpClasses(): command failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
337
334
exit_nicely (g_conn );
338
335
}
339
336
for (tuple = 0 ; tuple < PQntuples (res ); tuple ++ )
@@ -771,7 +768,7 @@ getTypes(int *numTypes)
771
768
if (!res ||
772
769
PQresultStatus (res ) != PGRES_COMMAND_OK )
773
770
{
774
- fprintf (stderr , "BEGIN command failed\n" );
771
+ fprintf (stderr , "BEGIN command failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
775
772
exit_nicely (g_conn );
776
773
}
777
774
PQclear (res );
@@ -796,7 +793,7 @@ getTypes(int *numTypes)
796
793
if (!res ||
797
794
PQresultStatus (res ) != PGRES_TUPLES_OK )
798
795
{
799
- fprintf (stderr , "getTypes(): SELECT failed\n" );
796
+ fprintf (stderr , "getTypes(): SELECT failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
800
797
exit_nicely (g_conn );
801
798
}
802
799
@@ -904,7 +901,7 @@ getOperators(int *numOprs)
904
901
if (!res ||
905
902
PQresultStatus (res ) != PGRES_COMMAND_OK )
906
903
{
907
- fprintf (stderr , "BEGIN command failed\n" );
904
+ fprintf (stderr , "BEGIN command failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
908
905
exit_nicely (g_conn );
909
906
}
910
907
PQclear (res );
@@ -919,7 +916,7 @@ getOperators(int *numOprs)
919
916
if (!res ||
920
917
PQresultStatus (res ) != PGRES_TUPLES_OK )
921
918
{
922
- fprintf (stderr , "getOperators(): SELECT failed\n" );
919
+ fprintf (stderr , "getOperators(): SELECT failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
923
920
exit_nicely (g_conn );
924
921
}
925
922
@@ -1241,7 +1238,7 @@ getAggregates(int *numAggs)
1241
1238
if (!res ||
1242
1239
PQresultStatus (res ) != PGRES_COMMAND_OK )
1243
1240
{
1244
- fprintf (stderr , "BEGIN command failed\n" );
1241
+ fprintf (stderr , "BEGIN command failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
1245
1242
exit_nicely (g_conn );
1246
1243
}
1247
1244
PQclear (res );
@@ -1256,7 +1253,7 @@ getAggregates(int *numAggs)
1256
1253
if (!res ||
1257
1254
PQresultStatus (res ) != PGRES_TUPLES_OK )
1258
1255
{
1259
- fprintf (stderr , "getAggregates(): SELECT failed\n" );
1256
+ fprintf (stderr , "getAggregates(): SELECT failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
1260
1257
exit_nicely (g_conn );
1261
1258
}
1262
1259
@@ -1334,7 +1331,7 @@ getFuncs(int *numFuncs)
1334
1331
if (!res ||
1335
1332
PQresultStatus (res ) != PGRES_COMMAND_OK )
1336
1333
{
1337
- fprintf (stderr , "BEGIN command failed\n" );
1334
+ fprintf (stderr , "BEGIN command failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
1338
1335
exit_nicely (g_conn );
1339
1336
}
1340
1337
PQclear (res );
@@ -1350,7 +1347,7 @@ getFuncs(int *numFuncs)
1350
1347
if (!res ||
1351
1348
PQresultStatus (res ) != PGRES_TUPLES_OK )
1352
1349
{
1353
- fprintf (stderr , "getFuncs(): SELECT failed\n" );
1350
+ fprintf (stderr , "getFuncs(): SELECT failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
1354
1351
exit_nicely (g_conn );
1355
1352
}
1356
1353
@@ -1437,7 +1434,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
1437
1434
if (!res ||
1438
1435
PQresultStatus (res ) != PGRES_COMMAND_OK )
1439
1436
{
1440
- fprintf (stderr , "BEGIN command failed\n" );
1437
+ fprintf (stderr , "BEGIN command failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
1441
1438
exit_nicely (g_conn );
1442
1439
}
1443
1440
PQclear (res );
@@ -1454,7 +1451,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
1454
1451
if (!res ||
1455
1452
PQresultStatus (res ) != PGRES_TUPLES_OK )
1456
1453
{
1457
- fprintf (stderr , "getTables(): SELECT failed\n" );
1454
+ fprintf (stderr , "getTables(): SELECT failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
1458
1455
exit_nicely (g_conn );
1459
1456
}
1460
1457
@@ -1511,7 +1508,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
1511
1508
if (!res2 ||
1512
1509
PQresultStatus (res2 ) != PGRES_TUPLES_OK )
1513
1510
{
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 ) );
1515
1512
exit_nicely (g_conn );
1516
1513
}
1517
1514
ntups2 = PQntuples (res2 );
@@ -1554,7 +1551,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
1554
1551
if (!res2 ||
1555
1552
PQresultStatus (res2 ) != PGRES_TUPLES_OK )
1556
1553
{
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 ) );
1558
1555
exit_nicely (g_conn );
1559
1556
}
1560
1557
ntups2 = PQntuples (res2 );
@@ -1609,7 +1606,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
1609
1606
if (!res2 ||
1610
1607
PQresultStatus (res2 ) != PGRES_TUPLES_OK )
1611
1608
{
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 ) );
1613
1610
exit_nicely (g_conn );
1614
1611
}
1615
1612
ntups2 = PQntuples (res2 );
@@ -1770,7 +1767,7 @@ getInherits(int *numInherits)
1770
1767
if (!res ||
1771
1768
PQresultStatus (res ) != PGRES_COMMAND_OK )
1772
1769
{
1773
- fprintf (stderr , "BEGIN command failed\n" );
1770
+ fprintf (stderr , "BEGIN command failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
1774
1771
exit_nicely (g_conn );
1775
1772
}
1776
1773
PQclear (res );
@@ -1781,7 +1778,7 @@ getInherits(int *numInherits)
1781
1778
if (!res ||
1782
1779
PQresultStatus (res ) != PGRES_TUPLES_OK )
1783
1780
{
1784
- fprintf (stderr , "getInherits(): SELECT failed\n" );
1781
+ fprintf (stderr , "getInherits(): SELECT failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
1785
1782
exit_nicely (g_conn );
1786
1783
}
1787
1784
@@ -1859,7 +1856,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
1859
1856
if (!res ||
1860
1857
PQresultStatus (res ) != PGRES_TUPLES_OK )
1861
1858
{
1862
- fprintf (stderr , "getTableAttrs(): SELECT failed\n" );
1859
+ fprintf (stderr , "getTableAttrs(): SELECT failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
1863
1860
exit_nicely (g_conn );
1864
1861
}
1865
1862
@@ -1905,7 +1902,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
1905
1902
if (!res2 ||
1906
1903
PQresultStatus (res2 ) != PGRES_TUPLES_OK )
1907
1904
{
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 ) );
1909
1906
exit_nicely (g_conn );
1910
1907
}
1911
1908
tblinfo [i ].adef_expr [j ] = strdup (PQgetvalue (res2 , 0 , PQfnumber (res2 , "adsrc" )));
@@ -1958,7 +1955,7 @@ getIndices(int *numIndices)
1958
1955
if (!res ||
1959
1956
PQresultStatus (res ) != PGRES_COMMAND_OK )
1960
1957
{
1961
- fprintf (stderr , "BEGIN command failed\n" );
1958
+ fprintf (stderr , "BEGIN command failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
1962
1959
exit_nicely (g_conn );
1963
1960
}
1964
1961
PQclear (res );
@@ -1977,7 +1974,7 @@ getIndices(int *numIndices)
1977
1974
if (!res ||
1978
1975
PQresultStatus (res ) != PGRES_TUPLES_OK )
1979
1976
{
1980
- fprintf (stderr , "getIndices(): SELECT failed\n" );
1977
+ fprintf (stderr , "getIndices(): SELECT failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
1981
1978
exit_nicely (g_conn );
1982
1979
}
1983
1980
@@ -2009,8 +2006,7 @@ getIndices(int *numIndices)
2009
2006
}
2010
2007
PQclear (res );
2011
2008
res = PQexec (g_conn , "end" );
2012
- if (res )
2013
- PQclear (res );
2009
+ PQclear (res );
2014
2010
return indinfo ;
2015
2011
}
2016
2012
@@ -2120,7 +2116,7 @@ dumpProcLangs(FILE *fout, FuncInfo *finfo, int numFuncs,
2120
2116
if (!res ||
2121
2117
PQresultStatus (res ) != PGRES_COMMAND_OK )
2122
2118
{
2123
- fprintf (stderr , "BEGIN command failed\n" );
2119
+ fprintf (stderr , "BEGIN command failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
2124
2120
exit_nicely (g_conn );
2125
2121
}
2126
2122
@@ -2131,7 +2127,7 @@ dumpProcLangs(FILE *fout, FuncInfo *finfo, int numFuncs,
2131
2127
if (!res ||
2132
2128
PQresultStatus (res ) != PGRES_TUPLES_OK )
2133
2129
{
2134
- fprintf (stderr , "dumpProcLangs(): SELECT failed\n" );
2130
+ fprintf (stderr , "dumpProcLangs(): SELECT failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
2135
2131
exit_nicely (g_conn );
2136
2132
}
2137
2133
ntups = PQntuples (res );
@@ -2243,7 +2239,7 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i,
2243
2239
if (!res ||
2244
2240
PQresultStatus (res ) != PGRES_COMMAND_OK )
2245
2241
{
2246
- fprintf (stderr , "dumpOneFunc(): BEGIN command failed\n" );
2242
+ fprintf (stderr , "dumpOneFunc(): BEGIN command failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
2247
2243
exit_nicely (g_conn );
2248
2244
}
2249
2245
PQclear (res );
@@ -2255,7 +2251,7 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i,
2255
2251
if (!res ||
2256
2252
PQresultStatus (res ) != PGRES_TUPLES_OK )
2257
2253
{
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 ) );
2259
2255
exit_nicely (g_conn );
2260
2256
}
2261
2257
nlangs = PQntuples (res );
@@ -2873,7 +2869,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
2873
2869
res = PQexec (g_conn , q );
2874
2870
if (!res || PQresultStatus (res ) != PGRES_TUPLES_OK )
2875
2871
{
2876
- fprintf (stderr , "dumpIndices(): SELECT (funcname) failed\n" );
2872
+ fprintf (stderr , "dumpIndices(): SELECT (funcname) failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
2877
2873
exit_nicely (g_conn );
2878
2874
}
2879
2875
funcname = strdup (PQgetvalue (res , 0 ,
@@ -2894,7 +2890,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
2894
2890
res = PQexec (g_conn , q );
2895
2891
if (!res || PQresultStatus (res ) != PGRES_TUPLES_OK )
2896
2892
{
2897
- fprintf (stderr , "dumpIndices(): SELECT (classname) failed\n" );
2893
+ fprintf (stderr , "dumpIndices(): SELECT (classname) failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
2898
2894
exit_nicely (g_conn );
2899
2895
}
2900
2896
classname [nclass ] = strdup (PQgetvalue (res , 0 ,
@@ -3059,15 +3055,15 @@ setMaxOid(FILE *fout)
3059
3055
if (!res ||
3060
3056
PQresultStatus (res ) != PGRES_COMMAND_OK )
3061
3057
{
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 ) );
3063
3059
exit_nicely (g_conn );
3064
3060
}
3065
3061
PQclear (res );
3066
3062
res = PQexec (g_conn , "INSERT INTO pgdump_oid VALUES (0)" );
3067
3063
if (!res ||
3068
3064
PQresultStatus (res ) != PGRES_COMMAND_OK )
3069
3065
{
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 ) );
3071
3067
exit_nicely (g_conn );
3072
3068
}
3073
3069
max_oid = atol (PQoidStatus (res ));
@@ -3081,7 +3077,7 @@ setMaxOid(FILE *fout)
3081
3077
if (!res ||
3082
3078
PQresultStatus (res ) != PGRES_COMMAND_OK )
3083
3079
{
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 ) );
3085
3081
exit_nicely (g_conn );
3086
3082
}
3087
3083
PQclear (res );
@@ -3114,7 +3110,7 @@ findLastBuiltinOid(void)
3114
3110
if (res == NULL ||
3115
3111
PQresultStatus (res ) != PGRES_TUPLES_OK )
3116
3112
{
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 ) );
3118
3114
exit_nicely (g_conn );
3119
3115
}
3120
3116
ntups = PQntuples (res );
@@ -3187,7 +3183,7 @@ dumpSequence(FILE *fout, TableInfo tbinfo)
3187
3183
res = PQexec (g_conn , query );
3188
3184
if (!res || PQresultStatus (res ) != PGRES_TUPLES_OK )
3189
3185
{
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 ) );
3191
3187
exit_nicely (g_conn );
3192
3188
}
3193
3189
@@ -3293,7 +3289,7 @@ dumpRules(FILE *fout, const char *tablename,
3293
3289
if (!res ||
3294
3290
PQresultStatus (res ) != PGRES_COMMAND_OK )
3295
3291
{
3296
- fprintf (stderr , "BEGIN command failed\n" );
3292
+ fprintf (stderr , "BEGIN command failed. Explanation from backend: '%s'. \n" , PQerrorMessage ( g_conn ) );
3297
3293
exit_nicely (g_conn );
3298
3294
}
3299
3295
PQclear (res );
@@ -3311,8 +3307,8 @@ dumpRules(FILE *fout, const char *tablename,
3311
3307
if (!res ||
3312
3308
PQresultStatus (res ) != PGRES_TUPLES_OK )
3313
3309
{
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 ) );
3316
3312
exit_nicely (g_conn );
3317
3313
}
3318
3314
0 commit comments