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

Commit1f75cdd

Browse files
committed
Ensure that kernel error code is included in smgr-level error reports.
Tweak mdcreate a little bit so that it returns the right errno.
1 parent81b30f2 commit1f75cdd

File tree

2 files changed

+36
-26
lines changed

2 files changed

+36
-26
lines changed

‎src/backend/storage/smgr/md.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.70 2000/06/02 15:57:26 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.71 2000/06/19 23:37:08 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -130,34 +130,41 @@ mdcreate(Relation reln)
130130
char*path;
131131

132132
Assert(reln->rd_unlinked&&reln->rd_fd<0);
133+
133134
path=relpath(RelationGetPhysicalRelationName(reln));
134135
fd=FileNameOpenFile(path,O_RDWR |O_CREAT |O_EXCL |PG_BINARY,0600);
135136

136137
/*
137-
* During bootstrap processing, we skip that check, because pg_time,
138-
* pg_variable, and pg_log get created before their .bki file entries
139-
* are processed.
140-
*
141-
* For cataloged relations,pg_class is guaranteed to have an unique
138+
* For cataloged relations, pg_class is guaranteed to have a unique
142139
* record with the same relname by the unique index. So we are able to
143-
* reuse existent files for newcatloged relations. Currently we reuse
140+
* reuse existent files for newcataloged relations. Currently we reuse
144141
* them in the following cases. 1. they are empty. 2. they are used
145142
* for Index relations and their size == BLCKSZ * 2.
143+
*
144+
* During bootstrap processing, we skip that check, because pg_time,
145+
* pg_variable, and pg_log get created before their .bki file entries
146+
* are processed.
146147
*/
147148

148149
if (fd<0)
149150
{
151+
intsave_errno=errno;
152+
150153
if (!IsBootstrapProcessingMode()&&
151154
reln->rd_rel->relkind==RELKIND_UNCATALOGED)
152155
return-1;
153156

154157
fd=FileNameOpenFile(path,O_RDWR |PG_BINARY,0600);
155158
if (fd<0)
159+
{
160+
/* be sure to return the error reported by create, not open */
161+
errno=save_errno;
156162
return-1;
163+
}
157164
if (!IsBootstrapProcessingMode())
158165
{
159166
boolreuse= false;
160-
intlen=FileSeek(fd,0L,SEEK_END);
167+
longlen=FileSeek(fd,0L,SEEK_END);
161168

162169
if (len==0)
163170
reuse= true;
@@ -167,9 +174,12 @@ mdcreate(Relation reln)
167174
if (!reuse)
168175
{
169176
FileClose(fd);
177+
/* be sure to return the error reported by create */
178+
errno=save_errno;
170179
return-1;
171180
}
172181
}
182+
errno=0;
173183
}
174184
reln->rd_unlinked= false;
175185

‎src/backend/storage/smgr/smgr.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.36 2000/06/05 07:28:47 tgl Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.37 2000/06/19 23:37:08 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -105,7 +105,7 @@ smgrinit()
105105
if (smgrsw[i].smgr_init)
106106
{
107107
if ((*(smgrsw[i].smgr_init)) ()==SM_FAIL)
108-
elog(FATAL,"initialization failed on %s",
108+
elog(FATAL,"initialization failed on %s: %m",
109109
DatumGetCString(DirectFunctionCall1(smgrout,
110110
Int16GetDatum(i))));
111111
}
@@ -127,7 +127,7 @@ smgrshutdown(int dummy)
127127
if (smgrsw[i].smgr_shutdown)
128128
{
129129
if ((*(smgrsw[i].smgr_shutdown)) ()==SM_FAIL)
130-
elog(FATAL,"shutdown failed on %s",
130+
elog(FATAL,"shutdown failed on %s: %m",
131131
DatumGetCString(DirectFunctionCall1(smgrout,
132132
Int16GetDatum(i))));
133133
}
@@ -146,7 +146,7 @@ smgrcreate(int16 which, Relation reln)
146146
intfd;
147147

148148
if ((fd= (*(smgrsw[which].smgr_create)) (reln))<0)
149-
elog(ERROR,"cannot create %s",RelationGetRelationName(reln));
149+
elog(ERROR,"cannot create %s: %m",RelationGetRelationName(reln));
150150

151151
returnfd;
152152
}
@@ -162,7 +162,7 @@ smgrunlink(int16 which, Relation reln)
162162
intstatus;
163163

164164
if ((status= (*(smgrsw[which].smgr_unlink)) (reln))==SM_FAIL)
165-
elog(ERROR,"cannot unlink %s",RelationGetRelationName(reln));
165+
elog(ERROR,"cannot unlink %s: %m",RelationGetRelationName(reln));
166166

167167
returnstatus;
168168
}
@@ -181,7 +181,7 @@ smgrextend(int16 which, Relation reln, char *buffer)
181181
status= (*(smgrsw[which].smgr_extend)) (reln,buffer);
182182

183183
if (status==SM_FAIL)
184-
elog(ERROR,"%s:cannot extend. Check free disk space.",
184+
elog(ERROR,"cannot extend %s: %m.\n\tCheck free disk space.",
185185
RelationGetRelationName(reln));
186186

187187
returnstatus;
@@ -200,7 +200,7 @@ smgropen(int16 which, Relation reln)
200200

201201
if ((fd= (*(smgrsw[which].smgr_open)) (reln))<0&&
202202
!reln->rd_unlinked)
203-
elog(ERROR,"cannot open %s",RelationGetRelationName(reln));
203+
elog(ERROR,"cannot open %s: %m",RelationGetRelationName(reln));
204204

205205
returnfd;
206206
}
@@ -220,7 +220,7 @@ int
220220
smgrclose(int16which,Relationreln)
221221
{
222222
if ((*(smgrsw[which].smgr_close)) (reln)==SM_FAIL)
223-
elog(ERROR,"cannot close %s",RelationGetRelationName(reln));
223+
elog(ERROR,"cannot close %s: %m",RelationGetRelationName(reln));
224224

225225
returnSM_SUCCESS;
226226
}
@@ -243,7 +243,7 @@ smgrread(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
243243
status= (*(smgrsw[which].smgr_read)) (reln,blocknum,buffer);
244244

245245
if (status==SM_FAIL)
246-
elog(ERROR,"cannot read block %d of %s",
246+
elog(ERROR,"cannot read block %d of %s: %m",
247247
blocknum,RelationGetRelationName(reln));
248248

249249
returnstatus;
@@ -265,7 +265,7 @@ smgrwrite(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
265265
status= (*(smgrsw[which].smgr_write)) (reln,blocknum,buffer);
266266

267267
if (status==SM_FAIL)
268-
elog(ERROR,"cannot write block %d of %s",
268+
elog(ERROR,"cannot write block %d of %s: %m",
269269
blocknum,RelationGetRelationName(reln));
270270

271271
returnstatus;
@@ -282,7 +282,7 @@ smgrflush(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
282282
status= (*(smgrsw[which].smgr_flush)) (reln,blocknum,buffer);
283283

284284
if (status==SM_FAIL)
285-
elog(ERROR,"cannot flush block %d of %s to stable store",
285+
elog(ERROR,"cannot flush block %d of %s to stable store: %m",
286286
blocknum,RelationGetRelationName(reln));
287287

288288
returnstatus;
@@ -323,7 +323,7 @@ smgrblindwrt(int16 which,
323323
blkno,buffer,dofsync);
324324

325325
if (status==SM_FAIL)
326-
elog(ERROR,"cannot write block %d of %s [%s] blind",
326+
elog(ERROR,"cannot write block %d of %s [%s] blind: %m",
327327
blkno,relstr,dbstr);
328328

329329
pfree(dbstr);
@@ -352,7 +352,7 @@ smgrmarkdirty(int16 which,
352352
status= (*(smgrsw[which].smgr_markdirty)) (reln,blkno);
353353

354354
if (status==SM_FAIL)
355-
elog(ERROR,"cannot mark block %d of %s",
355+
elog(ERROR,"cannot mark block %d of %s: %m",
356356
blkno,RelationGetRelationName(reln));
357357

358358
returnstatus;
@@ -384,7 +384,7 @@ smgrblindmarkdirty(int16 which,
384384
blkno);
385385

386386
if (status==SM_FAIL)
387-
elog(ERROR,"cannot mark block %d of %s [%s] blind",
387+
elog(ERROR,"cannot mark block %d of %s [%s] blind: %m",
388388
blkno,relstr,dbstr);
389389

390390
pfree(dbstr);
@@ -406,7 +406,7 @@ smgrnblocks(int16 which, Relation reln)
406406
intnblocks;
407407

408408
if ((nblocks= (*(smgrsw[which].smgr_nblocks)) (reln))<0)
409-
elog(ERROR,"cannot count blocks for %s",
409+
elog(ERROR,"cannot count blocks for %s: %m",
410410
RelationGetRelationName(reln));
411411

412412
returnnblocks;
@@ -428,7 +428,7 @@ smgrtruncate(int16 which, Relation reln, int nblocks)
428428
if (smgrsw[which].smgr_truncate)
429429
{
430430
if ((newblks= (*(smgrsw[which].smgr_truncate)) (reln,nblocks))<0)
431-
elog(ERROR,"cannot truncate %s to %d blocks",
431+
elog(ERROR,"cannot truncate %s to %d blocks: %m",
432432
RelationGetRelationName(reln),nblocks);
433433
}
434434

@@ -449,7 +449,7 @@ smgrcommit()
449449
if (smgrsw[i].smgr_commit)
450450
{
451451
if ((*(smgrsw[i].smgr_commit)) ()==SM_FAIL)
452-
elog(FATAL,"transaction commit failed on %s",
452+
elog(FATAL,"transaction commit failed on %s: %m",
453453
DatumGetCString(DirectFunctionCall1(smgrout,
454454
Int16GetDatum(i))));
455455
}
@@ -468,7 +468,7 @@ smgrabort()
468468
if (smgrsw[i].smgr_abort)
469469
{
470470
if ((*(smgrsw[i].smgr_abort)) ()==SM_FAIL)
471-
elog(FATAL,"transaction abort failed on %s",
471+
elog(FATAL,"transaction abort failed on %s: %m",
472472
DatumGetCString(DirectFunctionCall1(smgrout,
473473
Int16GetDatum(i))));
474474
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp