Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
ec7aa4b5
Commit
ec7aa4b5
authored
Jul 21, 2003
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Error message editing in backend/access.
parent
c6106d91
Changes
33
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
702 additions
and
533 deletions
+702
-533
src/backend/access/common/heaptuple.c
src/backend/access/common/heaptuple.c
+18
-18
src/backend/access/common/indextuple.c
src/backend/access/common/indextuple.c
+10
-5
src/backend/access/common/printtup.c
src/backend/access/common/printtup.c
+4
-2
src/backend/access/common/tupdesc.c
src/backend/access/common/tupdesc.c
+15
-7
src/backend/access/gist/gist.c
src/backend/access/gist/gist.c
+5
-5
src/backend/access/hash/hash.c
src/backend/access/hash/hash.c
+2
-2
src/backend/access/hash/hashinsert.c
src/backend/access/hash/hashinsert.c
+3
-3
src/backend/access/hash/hashovfl.c
src/backend/access/hash/hashovfl.c
+20
-12
src/backend/access/hash/hashpage.c
src/backend/access/hash/hashpage.c
+14
-30
src/backend/access/hash/hashutil.c
src/backend/access/hash/hashutil.c
+4
-2
src/backend/access/heap/heapam.c
src/backend/access/heap/heapam.c
+72
-70
src/backend/access/heap/hio.c
src/backend/access/heap/hio.c
+10
-7
src/backend/access/heap/tuptoaster.c
src/backend/access/heap/tuptoaster.c
+3
-3
src/backend/access/index/genam.c
src/backend/access/index/genam.c
+1
-7
src/backend/access/index/indexam.c
src/backend/access/index/indexam.c
+16
-10
src/backend/access/index/istrat.c
src/backend/access/index/istrat.c
+6
-6
src/backend/access/nbtree/nbtinsert.c
src/backend/access/nbtree/nbtinsert.c
+26
-21
src/backend/access/nbtree/nbtpage.c
src/backend/access/nbtree/nbtpage.c
+33
-25
src/backend/access/nbtree/nbtree.c
src/backend/access/nbtree/nbtree.c
+6
-7
src/backend/access/nbtree/nbtsearch.c
src/backend/access/nbtree/nbtsearch.c
+10
-10
src/backend/access/nbtree/nbtsort.c
src/backend/access/nbtree/nbtsort.c
+7
-4
src/backend/access/nbtree/nbtutils.c
src/backend/access/nbtree/nbtutils.c
+4
-6
src/backend/access/rtree/rtree.c
src/backend/access/rtree/rtree.c
+17
-12
src/backend/access/rtree/rtscan.c
src/backend/access/rtree/rtscan.c
+2
-2
src/backend/access/transam/xact.c
src/backend/access/transam/xact.c
+34
-21
src/backend/access/transam/xlog.c
src/backend/access/transam/xlog.c
+341
-219
src/include/utils/elog.h
src/include/utils/elog.h
+3
-1
src/test/regress/expected/alter_table.out
src/test/regress/expected/alter_table.out
+6
-6
src/test/regress/expected/arrays.out
src/test/regress/expected/arrays.out
+1
-1
src/test/regress/expected/create_index.out
src/test/regress/expected/create_index.out
+2
-2
src/test/regress/expected/errors.out
src/test/regress/expected/errors.out
+2
-2
src/test/regress/expected/plpgsql.out
src/test/regress/expected/plpgsql.out
+2
-2
src/test/regress/output/constraints.source
src/test/regress/output/constraints.source
+3
-3
No files found.
src/backend/access/common/heaptuple.c
View file @
ec7aa4b5
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.8
3 2002/09/27 15:04:08
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.8
4 2003/07/21 20:29:37
tgl Exp $
*
*
* NOTES
* NOTES
* The old interface functions have been converted to macros
* The old interface functions have been converted to macros
...
@@ -173,13 +173,11 @@ heap_attisnull(HeapTuple tup, int attnum)
...
@@ -173,13 +173,11 @@ heap_attisnull(HeapTuple tup, int attnum)
case
MinCommandIdAttributeNumber
:
case
MinCommandIdAttributeNumber
:
case
MaxTransactionIdAttributeNumber
:
case
MaxTransactionIdAttributeNumber
:
case
MaxCommandIdAttributeNumber
:
case
MaxCommandIdAttributeNumber
:
/* these are never null */
break
;
break
;
case
0
:
elog
(
ERROR
,
"heap_attisnull: zero attnum disallowed"
);
default:
default:
elog
(
ERROR
,
"
heap_attisnull: undefined negative attnum"
);
elog
(
ERROR
,
"
invalid attnum: %d"
,
attnum
);
}
}
return
0
;
return
0
;
...
@@ -457,7 +455,7 @@ heap_getsysattr(HeapTuple tup, int attnum, bool *isnull)
...
@@ -457,7 +455,7 @@ heap_getsysattr(HeapTuple tup, int attnum, bool *isnull)
result
=
ObjectIdGetDatum
(
tup
->
t_tableOid
);
result
=
ObjectIdGetDatum
(
tup
->
t_tableOid
);
break
;
break
;
default:
default:
elog
(
ERROR
,
"
heap_getsysattr: invalid attnum
%d"
,
attnum
);
elog
(
ERROR
,
"
invalid attnum:
%d"
,
attnum
);
result
=
0
;
/* keep compiler quiet */
result
=
0
;
/* keep compiler quiet */
break
;
break
;
}
}
...
@@ -581,8 +579,10 @@ heap_formtuple(TupleDesc tupleDescriptor,
...
@@ -581,8 +579,10 @@ heap_formtuple(TupleDesc tupleDescriptor,
int
numberOfAttributes
=
tupleDescriptor
->
natts
;
int
numberOfAttributes
=
tupleDescriptor
->
natts
;
if
(
numberOfAttributes
>
MaxTupleAttributeNumber
)
if
(
numberOfAttributes
>
MaxTupleAttributeNumber
)
elog
(
ERROR
,
"heap_formtuple: numberOfAttributes %d exceeds limit %d"
,
ereport
(
ERROR
,
numberOfAttributes
,
MaxTupleAttributeNumber
);
(
errcode
(
ERRCODE_TOO_MANY_COLUMNS
),
errmsg
(
"number of attributes %d exceeds limit, %d"
,
numberOfAttributes
,
MaxTupleAttributeNumber
)));
for
(
i
=
0
;
i
<
numberOfAttributes
;
i
++
)
for
(
i
=
0
;
i
<
numberOfAttributes
;
i
++
)
{
{
...
@@ -666,14 +666,11 @@ heap_modifytuple(HeapTuple tuple,
...
@@ -666,14 +666,11 @@ heap_modifytuple(HeapTuple tuple,
* allocate and fill *value and *nulls arrays from either the tuple or
* allocate and fill *value and *nulls arrays from either the tuple or
* the repl information, as appropriate.
* the repl information, as appropriate.
*/
*/
value
=
(
Datum
*
)
palloc
(
numberOfAttributes
*
sizeof
*
value
);
value
=
(
Datum
*
)
palloc
(
numberOfAttributes
*
sizeof
(
Datum
)
);
nulls
=
(
char
*
)
palloc
(
numberOfAttributes
*
sizeof
*
nulls
);
nulls
=
(
char
*
)
palloc
(
numberOfAttributes
*
sizeof
(
char
)
);
for
(
attoff
=
0
;
for
(
attoff
=
0
;
attoff
<
numberOfAttributes
;
attoff
++
)
attoff
<
numberOfAttributes
;
attoff
+=
1
)
{
{
if
(
repl
[
attoff
]
==
' '
)
if
(
repl
[
attoff
]
==
' '
)
{
{
value
[
attoff
]
=
heap_getattr
(
tuple
,
value
[
attoff
]
=
heap_getattr
(
tuple
,
...
@@ -683,13 +680,13 @@ heap_modifytuple(HeapTuple tuple,
...
@@ -683,13 +680,13 @@ heap_modifytuple(HeapTuple tuple,
nulls
[
attoff
]
=
(
isNull
)
?
'n'
:
' '
;
nulls
[
attoff
]
=
(
isNull
)
?
'n'
:
' '
;
}
}
else
if
(
repl
[
attoff
]
!=
'r'
)
else
if
(
repl
[
attoff
]
==
'r'
)
elog
(
ERROR
,
"heap_modifytuple: repl is
\\
%3d"
,
repl
[
attoff
]);
{
else
{
/* == 'r' */
value
[
attoff
]
=
replValue
[
attoff
];
value
[
attoff
]
=
replValue
[
attoff
];
nulls
[
attoff
]
=
replNull
[
attoff
];
nulls
[
attoff
]
=
replNull
[
attoff
];
}
}
else
elog
(
ERROR
,
"unrecognized replace flag: %d"
,
(
int
)
repl
[
attoff
]);
}
}
/*
/*
...
@@ -699,6 +696,9 @@ heap_modifytuple(HeapTuple tuple,
...
@@ -699,6 +696,9 @@ heap_modifytuple(HeapTuple tuple,
value
,
value
,
nulls
);
nulls
);
pfree
(
value
);
pfree
(
nulls
);
/*
/*
* copy the identification info of the old tuple: t_ctid, t_self, and
* copy the identification info of the old tuple: t_ctid, t_self, and
* OID (if any)
* OID (if any)
...
...
src/backend/access/common/indextuple.c
View file @
ec7aa4b5
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.6
4 2003/02/23 06:17:12
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.6
5 2003/07/21 20:29:37
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -52,8 +52,10 @@ index_formtuple(TupleDesc tupleDescriptor,
...
@@ -52,8 +52,10 @@ index_formtuple(TupleDesc tupleDescriptor,
#endif
#endif
if
(
numberOfAttributes
>
INDEX_MAX_KEYS
)
if
(
numberOfAttributes
>
INDEX_MAX_KEYS
)
elog
(
ERROR
,
"index_formtuple: numberOfAttributes %d > %d"
,
ereport
(
ERROR
,
numberOfAttributes
,
INDEX_MAX_KEYS
);
(
errcode
(
ERRCODE_TOO_MANY_COLUMNS
),
errmsg
(
"number of index attributes %d exceeds limit, %d"
,
numberOfAttributes
,
INDEX_MAX_KEYS
)));
#ifdef TOAST_INDEX_HACK
#ifdef TOAST_INDEX_HACK
for
(
i
=
0
;
i
<
numberOfAttributes
;
i
++
)
for
(
i
=
0
;
i
<
numberOfAttributes
;
i
++
)
...
@@ -158,8 +160,11 @@ index_formtuple(TupleDesc tupleDescriptor,
...
@@ -158,8 +160,11 @@ index_formtuple(TupleDesc tupleDescriptor,
* it in t_info.
* it in t_info.
*/
*/
if
((
size
&
INDEX_SIZE_MASK
)
!=
size
)
if
((
size
&
INDEX_SIZE_MASK
)
!=
size
)
elog
(
ERROR
,
"index_formtuple: data takes %lu bytes, max is %d"
,
ereport
(
ERROR
,
(
unsigned
long
)
size
,
INDEX_SIZE_MASK
);
(
errcode
(
ERRCODE_PROGRAM_LIMIT_EXCEEDED
),
errmsg
(
"index tuple requires %lu bytes, maximum size is %lu"
,
(
unsigned
long
)
size
,
(
unsigned
long
)
INDEX_SIZE_MASK
)));
infomask
|=
size
;
infomask
|=
size
;
...
...
src/backend/access/common/printtup.c
View file @
ec7aa4b5
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.7
4 2003/05/26 17:51
:38 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.7
5 2003/07/21 20:29
:38 tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -273,7 +273,9 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs)
...
@@ -273,7 +273,9 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs)
fmgr_info
(
thisState
->
typsend
,
&
thisState
->
finfo
);
fmgr_info
(
thisState
->
typsend
,
&
thisState
->
finfo
);
}
}
else
else
elog
(
ERROR
,
"Unsupported format code %d"
,
format
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_PARAMETER_VALUE
),
errmsg
(
"unsupported format code: %d"
,
format
)));
}
}
}
}
...
...
src/backend/access/common/tupdesc.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.9
5 2003/06/15 17:59:10
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.9
6 2003/07/21 20:29:38
tgl Exp $
*
*
* NOTES
* NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be
* some of the executor utility code such as "ExecTypeFromTL" should be
...
@@ -417,7 +417,7 @@ TupleDescInitEntry(TupleDesc desc,
...
@@ -417,7 +417,7 @@ TupleDescInitEntry(TupleDesc desc,
ObjectIdGetDatum
(
oidtypeid
),
ObjectIdGetDatum
(
oidtypeid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"
Unable to look up type id
%u"
,
oidtypeid
);
elog
(
ERROR
,
"
cache lookup failed for type
%u"
,
oidtypeid
);
/*
/*
* type info exists so we initialize our attribute information from
* type info exists so we initialize our attribute information from
...
@@ -643,7 +643,7 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
...
@@ -643,7 +643,7 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
int
natts
;
int
natts
;
if
(
!
OidIsValid
(
relid
))
if
(
!
OidIsValid
(
relid
))
elog
(
ERROR
,
"
I
nvalid typrelid for complex type %u"
,
typeoid
);
elog
(
ERROR
,
"
i
nvalid typrelid for complex type %u"
,
typeoid
);
rel
=
relation_open
(
relid
,
AccessShareLock
);
rel
=
relation_open
(
relid
,
AccessShareLock
);
tupdesc
=
CreateTupleDescCopy
(
RelationGetDescr
(
rel
));
tupdesc
=
CreateTupleDescCopy
(
RelationGetDescr
(
rel
));
...
@@ -657,7 +657,9 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
...
@@ -657,7 +657,9 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
/* does the list length match the number of attributes? */
/* does the list length match the number of attributes? */
if
(
length
(
colaliases
)
!=
natts
)
if
(
length
(
colaliases
)
!=
natts
)
elog
(
ERROR
,
"TypeGetTupleDesc: number of aliases does not match number of attributes"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DATATYPE_MISMATCH
),
errmsg
(
"number of aliases does not match number of attributes"
)));
/* OK, use the aliases instead */
/* OK, use the aliases instead */
for
(
varattno
=
0
;
varattno
<
natts
;
varattno
++
)
for
(
varattno
=
0
;
varattno
<
natts
;
varattno
++
)
...
@@ -676,11 +678,15 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
...
@@ -676,11 +678,15 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
/* the alias list is required for base types */
/* the alias list is required for base types */
if
(
colaliases
==
NIL
)
if
(
colaliases
==
NIL
)
elog
(
ERROR
,
"TypeGetTupleDesc: no column alias was provided"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DATATYPE_MISMATCH
),
errmsg
(
"no column alias was provided"
)));
/* the alias list length must be 1 */
/* the alias list length must be 1 */
if
(
length
(
colaliases
)
!=
1
)
if
(
length
(
colaliases
)
!=
1
)
elog
(
ERROR
,
"TypeGetTupleDesc: number of aliases does not match number of attributes"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DATATYPE_MISMATCH
),
errmsg
(
"number of aliases does not match number of attributes"
)));
/* OK, get the column alias */
/* OK, get the column alias */
attname
=
strVal
(
lfirst
(
colaliases
));
attname
=
strVal
(
lfirst
(
colaliases
));
...
@@ -695,7 +701,9 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
...
@@ -695,7 +701,9 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
false
);
false
);
}
}
else
if
(
functyptype
==
'p'
&&
typeoid
==
RECORDOID
)
else
if
(
functyptype
==
'p'
&&
typeoid
==
RECORDOID
)
elog
(
ERROR
,
"Unable to determine tuple description for function returning
\"
record
\"
"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DATATYPE_MISMATCH
),
errmsg
(
"unable to determine tuple description for function returning record"
)));
else
else
{
{
/* crummy error message, but parser should have caught this */
/* crummy error message, but parser should have caught this */
...
...
src/backend/access/gist/gist.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.10
3 2003/05/27 17:49:45 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.10
4 2003/07/21 20:29:38 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -168,7 +168,7 @@ gistbuild(PG_FUNCTION_ARGS)
...
@@ -168,7 +168,7 @@ gistbuild(PG_FUNCTION_ARGS)
* that's not the case, big trouble's what we have.
* that's not the case, big trouble's what we have.
*/
*/
if
(
RelationGetNumberOfBlocks
(
index
)
!=
0
)
if
(
RelationGetNumberOfBlocks
(
index
)
!=
0
)
elog
(
ERROR
,
"
%s
already contains data"
,
elog
(
ERROR
,
"
index
\"
%s
\"
already contains data"
,
RelationGetRelationName
(
index
));
RelationGetRelationName
(
index
));
/* initialize the root page */
/* initialize the root page */
...
@@ -396,7 +396,7 @@ gistPageAddItem(GISTSTATE *giststate,
...
@@ -396,7 +396,7 @@ gistPageAddItem(GISTSTATE *giststate,
retval
=
PageAddItem
(
page
,
(
Item
)
*
newtup
,
IndexTupleSize
(
*
newtup
),
retval
=
PageAddItem
(
page
,
(
Item
)
*
newtup
,
IndexTupleSize
(
*
newtup
),
offsetNumber
,
flags
);
offsetNumber
,
flags
);
if
(
retval
==
InvalidOffsetNumber
)
if
(
retval
==
InvalidOffsetNumber
)
elog
(
ERROR
,
"
gist: failed to add index item to %s
"
,
elog
(
ERROR
,
"
failed to add index item to
\"
%s
\"
"
,
RelationGetRelationName
(
r
));
RelationGetRelationName
(
r
));
/* be tidy */
/* be tidy */
if
(
DatumGetPointer
(
tmpcentry
.
key
)
!=
NULL
&&
if
(
DatumGetPointer
(
tmpcentry
.
key
)
!=
NULL
&&
...
@@ -603,7 +603,7 @@ gistwritebuffer(Relation r, Page page, IndexTuple *itup,
...
@@ -603,7 +603,7 @@ gistwritebuffer(Relation r, Page page, IndexTuple *itup,
l
=
PageAddItem
(
page
,
(
Item
)
itup
[
i
],
IndexTupleSize
(
itup
[
i
]),
l
=
PageAddItem
(
page
,
(
Item
)
itup
[
i
],
IndexTupleSize
(
itup
[
i
]),
off
,
LP_USED
);
off
,
LP_USED
);
if
(
l
==
InvalidOffsetNumber
)
if
(
l
==
InvalidOffsetNumber
)
elog
(
ERROR
,
"
gist: failed to add index item to %s
"
,
elog
(
ERROR
,
"
failed to add index item to
\"
%s
\"
"
,
RelationGetRelationName
(
r
));
RelationGetRelationName
(
r
));
#endif
#endif
}
}
...
@@ -1663,7 +1663,7 @@ initGISTstate(GISTSTATE *giststate, Relation index)
...
@@ -1663,7 +1663,7 @@ initGISTstate(GISTSTATE *giststate, Relation index)
int
i
;
int
i
;
if
(
index
->
rd_att
->
natts
>
INDEX_MAX_KEYS
)
if
(
index
->
rd_att
->
natts
>
INDEX_MAX_KEYS
)
elog
(
ERROR
,
"
initGISTstate:
numberOfAttributes %d > %d"
,
elog
(
ERROR
,
"numberOfAttributes %d > %d"
,
index
->
rd_att
->
natts
,
INDEX_MAX_KEYS
);
index
->
rd_att
->
natts
,
INDEX_MAX_KEYS
);
giststate
->
tupdesc
=
index
->
rd_att
;
giststate
->
tupdesc
=
index
->
rd_att
;
...
...
src/backend/access/hash/hash.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.6
3 2003/03/23 23:01:03
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.6
4 2003/07/21 20:29:38
tgl Exp $
*
*
* NOTES
* NOTES
* This file contains only the public interface routines.
* This file contains only the public interface routines.
...
@@ -69,7 +69,7 @@ hashbuild(PG_FUNCTION_ARGS)
...
@@ -69,7 +69,7 @@ hashbuild(PG_FUNCTION_ARGS)
* that's not the case, big trouble's what we have.
* that's not the case, big trouble's what we have.
*/
*/
if
(
RelationGetNumberOfBlocks
(
index
)
!=
0
)
if
(
RelationGetNumberOfBlocks
(
index
)
!=
0
)
elog
(
ERROR
,
"
%s
already contains data"
,
elog
(
ERROR
,
"
index
\"
%s
\"
already contains data"
,
RelationGetRelationName
(
index
));
RelationGetRelationName
(
index
));
/* initialize the hash index metadata page */
/* initialize the hash index metadata page */
...
...
src/backend/access/hash/hashinsert.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.2
5 2002/06/20 20:29:24 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.2
6 2003/07/21 20:29:38 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -48,7 +48,7 @@ _hash_doinsert(Relation rel, HashItem hitem)
...
@@ -48,7 +48,7 @@ _hash_doinsert(Relation rel, HashItem hitem)
/* we need a scan key to do our search, so build one */
/* we need a scan key to do our search, so build one */
itup
=
&
(
hitem
->
hash_itup
);
itup
=
&
(
hitem
->
hash_itup
);
if
((
natts
=
rel
->
rd_rel
->
relnatts
)
!=
1
)
if
((
natts
=
rel
->
rd_rel
->
relnatts
)
!=
1
)
elog
(
ERROR
,
"Hash ind
ices valid for only one index key.
"
);
elog
(
ERROR
,
"Hash ind
exes support only one index key
"
);
itup_scankey
=
_hash_mkscankey
(
rel
,
itup
);
itup_scankey
=
_hash_mkscankey
(
rel
,
itup
);
/*
/*
...
@@ -228,7 +228,7 @@ _hash_pgaddtup(Relation rel,
...
@@ -228,7 +228,7 @@ _hash_pgaddtup(Relation rel,
itup_off
=
OffsetNumberNext
(
PageGetMaxOffsetNumber
(
page
));
itup_off
=
OffsetNumberNext
(
PageGetMaxOffsetNumber
(
page
));
if
(
PageAddItem
(
page
,
(
Item
)
hitem
,
itemsize
,
itup_off
,
LP_USED
)
if
(
PageAddItem
(
page
,
(
Item
)
hitem
,
itemsize
,
itup_off
,
LP_USED
)
==
InvalidOffsetNumber
)
==
InvalidOffsetNumber
)
elog
(
ERROR
,
"
_hash_pgaddtup: failed to add index item to %s
"
,
elog
(
ERROR
,
"
failed to add index item to
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
/* write the buffer, but hold our lock */
/* write the buffer, but hold our lock */
...
...
src/backend/access/hash/hashovfl.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashovfl.c,v 1.3
4 2003/03/10 22:28:1
8 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashovfl.c,v 1.3
5 2003/07/21 20:29:3
8 tgl Exp $
*
*
* NOTES
* NOTES
* Overflow pages look like ordinary relation pages.
* Overflow pages look like ordinary relation pages.
...
@@ -58,7 +58,7 @@ _hash_addovflpage(Relation rel, Buffer *metabufp, Buffer buf)
...
@@ -58,7 +58,7 @@ _hash_addovflpage(Relation rel, Buffer *metabufp, Buffer buf)
/* allocate an empty overflow page */
/* allocate an empty overflow page */
oaddr
=
_hash_getovfladdr
(
rel
,
metabufp
);
oaddr
=
_hash_getovfladdr
(
rel
,
metabufp
);
if
(
oaddr
==
InvalidOvflAddress
)
if
(
oaddr
==
InvalidOvflAddress
)
elog
(
ERROR
,
"_hash_
addovflpage: problem with _hash_getovfladdr.
"
);
elog
(
ERROR
,
"_hash_
getovfladdr failed
"
);
ovflblkno
=
OADDR_TO_BLKNO
(
OADDR_OF
(
SPLITNUM
(
oaddr
),
OPAGENUM
(
oaddr
)));
ovflblkno
=
OADDR_TO_BLKNO
(
OADDR_OF
(
SPLITNUM
(
oaddr
),
OPAGENUM
(
oaddr
)));
Assert
(
BlockNumberIsValid
(
ovflblkno
));
Assert
(
BlockNumberIsValid
(
ovflblkno
));
ovflbuf
=
_hash_getbuf
(
rel
,
ovflblkno
,
HASH_WRITE
);
ovflbuf
=
_hash_getbuf
(
rel
,
ovflblkno
,
HASH_WRITE
);
...
@@ -158,12 +158,13 @@ _hash_getovfladdr(Relation rel, Buffer *metabufp)
...
@@ -158,12 +158,13 @@ _hash_getovfladdr(Relation rel, Buffer *metabufp)
offset
=
metap
->
hashm_spares
[
splitnum
]
-
offset
=
metap
->
hashm_spares
[
splitnum
]
-
(
splitnum
?
metap
->
hashm_spares
[
splitnum
-
1
]
:
0
);
(
splitnum
?
metap
->
hashm_spares
[
splitnum
-
1
]
:
0
);
#define OVMSG "HASH: Out of overflow pages. Out of luck.\n"
if
(
offset
>
SPLITMASK
)
if
(
offset
>
SPLITMASK
)
{
{
if
(
++
splitnum
>=
NCACHED
)
if
(
++
splitnum
>=
NCACHED
)
elog
(
ERROR
,
OVMSG
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_PROGRAM_LIMIT_EXCEEDED
),
errmsg
(
"out of overflow pages in hash index
\"
%s
\"
"
,
RelationGetRelationName
(
rel
))));
metap
->
hashm_ovflpoint
=
splitnum
;
metap
->
hashm_ovflpoint
=
splitnum
;
metap
->
hashm_spares
[
splitnum
]
=
metap
->
hashm_spares
[
splitnum
-
1
];
metap
->
hashm_spares
[
splitnum
]
=
metap
->
hashm_spares
[
splitnum
-
1
];
metap
->
hashm_spares
[
splitnum
-
1
]
--
;
metap
->
hashm_spares
[
splitnum
-
1
]
--
;
...
@@ -179,7 +180,10 @@ _hash_getovfladdr(Relation rel, Buffer *metabufp)
...
@@ -179,7 +180,10 @@ _hash_getovfladdr(Relation rel, Buffer *metabufp)
free_page
++
;
free_page
++
;
if
(
free_page
>=
NCACHED
)
if
(
free_page
>=
NCACHED
)
elog
(
ERROR
,
OVMSG
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_PROGRAM_LIMIT_EXCEEDED
),
errmsg
(
"out of overflow pages in hash index
\"
%s
\"
"
,
RelationGetRelationName
(
rel
))));
/*
/*
* This is tricky. The 1 indicates that you want the new page
* This is tricky. The 1 indicates that you want the new page
...
@@ -193,13 +197,16 @@ _hash_getovfladdr(Relation rel, Buffer *metabufp)
...
@@ -193,13 +197,16 @@ _hash_getovfladdr(Relation rel, Buffer *metabufp)
*/
*/
if
(
_hash_initbitmap
(
rel
,
metap
,
OADDR_OF
(
splitnum
,
offset
),
if
(
_hash_initbitmap
(
rel
,
metap
,
OADDR_OF
(
splitnum
,
offset
),
1
,
free_page
))
1
,
free_page
))
elog
(
ERROR
,
"
overflow_page: problem with _hash_initbitmap.
"
);
elog
(
ERROR
,
"
_hash_initbitmap failed
"
);
metap
->
hashm_spares
[
splitnum
]
++
;
metap
->
hashm_spares
[
splitnum
]
++
;
offset
++
;
offset
++
;
if
(
offset
>
SPLITMASK
)
if
(
offset
>
SPLITMASK
)
{
{
if
(
++
splitnum
>=
NCACHED
)
if
(
++
splitnum
>=
NCACHED
)
elog
(
ERROR
,
OVMSG
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_PROGRAM_LIMIT_EXCEEDED
),
errmsg
(
"out of overflow pages in hash index
\"
%s
\"
"
,
RelationGetRelationName
(
rel
))));
metap
->
hashm_ovflpoint
=
splitnum
;
metap
->
hashm_ovflpoint
=
splitnum
;
metap
->
hashm_spares
[
splitnum
]
=
metap
->
hashm_spares
[
splitnum
-
1
];
metap
->
hashm_spares
[
splitnum
]
=
metap
->
hashm_spares
[
splitnum
-
1
];
metap
->
hashm_spares
[
splitnum
-
1
]
--
;
metap
->
hashm_spares
[
splitnum
-
1
]
--
;
...
@@ -242,7 +249,10 @@ found:
...
@@ -242,7 +249,10 @@ found:
;
;
offset
=
(
i
?
bit
-
metap
->
hashm_spares
[
i
-
1
]
:
bit
);
offset
=
(
i
?
bit
-
metap
->
hashm_spares
[
i
-
1
]
:
bit
);
if
(
offset
>=
SPLITMASK
)
if
(
offset
>=
SPLITMASK
)
elog
(
ERROR
,
OVMSG
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_PROGRAM_LIMIT_EXCEEDED
),
errmsg
(
"out of overflow pages in hash index
\"
%s
\"
"
,
RelationGetRelationName
(
rel
))));
/* initialize this page */
/* initialize this page */
oaddr
=
OADDR_OF
(
i
,
offset
);
oaddr
=
OADDR_OF
(
i
,
offset
);
...
@@ -479,8 +489,6 @@ _hash_squeezebucket(Relation rel,
...
@@ -479,8 +489,6 @@ _hash_squeezebucket(Relation rel,
HashItem
hitem
;
HashItem
hitem
;
Size
itemsz
;
Size
itemsz
;
/* elog(DEBUG, "_hash_squeezebucket: squeezing bucket %d", bucket); */
/*
/*
* start squeezing into the base bucket page.
* start squeezing into the base bucket page.
*/
*/
...
@@ -565,7 +573,7 @@ _hash_squeezebucket(Relation rel,
...
@@ -565,7 +573,7 @@ _hash_squeezebucket(Relation rel,
woffnum
=
OffsetNumberNext
(
PageGetMaxOffsetNumber
(
wpage
));
woffnum
=
OffsetNumberNext
(
PageGetMaxOffsetNumber
(
wpage
));
if
(
PageAddItem
(
wpage
,
(
Item
)
hitem
,
itemsz
,
woffnum
,
LP_USED
)
if
(
PageAddItem
(
wpage
,
(
Item
)
hitem
,
itemsz
,
woffnum
,
LP_USED
)
==
InvalidOffsetNumber
)
==
InvalidOffsetNumber
)
elog
(
ERROR
,
"
_hash_squeezebucket: failed to add index item to %s
"
,
elog
(
ERROR
,
"
failed to add index item to
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
/*
/*
...
...
src/backend/access/hash/hashpage.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.3
6 2002/06/20 20:29:24 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.3
7 2003/07/21 20:29:38 tgl
Exp $
*
*
* NOTES
* NOTES
* Postgres hash pages look like ordinary relation pages. The opaque
* Postgres hash pages look like ordinary relation pages. The opaque
...
@@ -90,7 +90,7 @@ _hash_metapinit(Relation rel)
...
@@ -90,7 +90,7 @@ _hash_metapinit(Relation rel)
LockRelation
(
rel
,
AccessExclusiveLock
);
LockRelation
(
rel
,
AccessExclusiveLock
);
if
(
RelationGetNumberOfBlocks
(
rel
)
!=
0
)
if
(
RelationGetNumberOfBlocks
(
rel
)
!=
0
)
elog
(
ERROR
,
"
Cannot initialize non-empty hash table %s
"
,
elog
(
ERROR
,
"
cannot initialize non-empty hash index
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
metabuf
=
_hash_getbuf
(
rel
,
HASH_METAPAGE
,
HASH_WRITE
);
metabuf
=
_hash_getbuf
(
rel
,
HASH_METAPAGE
,
HASH_WRITE
);
...
@@ -148,7 +148,7 @@ _hash_metapinit(Relation rel)
...
@@ -148,7 +148,7 @@ _hash_metapinit(Relation rel)
* created the first two buckets above.
* created the first two buckets above.
*/
*/
if
(
_hash_initbitmap
(
rel
,
metap
,
OADDR_OF
(
lg2nelem
,
1
),
lg2nelem
+
1
,
0
))
if
(
_hash_initbitmap
(
rel
,
metap
,
OADDR_OF
(
lg2nelem
,
1
),
lg2nelem
+
1
,
0
))
elog
(
ERROR
,
"
Problem with _hash_initbitmap.
"
);
elog
(
ERROR
,
"
_hash_initbitmap failed
"
);
/* all done */
/* all done */
_hash_wrtnorelbuf
(
metabuf
);
_hash_wrtnorelbuf
(
metabuf
);
...
@@ -193,7 +193,7 @@ _hash_getbuf(Relation rel, BlockNumber blkno, int access)
...
@@ -193,7 +193,7 @@ _hash_getbuf(Relation rel, BlockNumber blkno, int access)
Buffer
buf
;
Buffer
buf
;
if
(
blkno
==
P_NEW
)
if
(
blkno
==
P_NEW
)
elog
(
ERROR
,
"
_hash_getbuf: internal error:
hash AM does not use P_NEW"
);
elog
(
ERROR
,
"hash AM does not use P_NEW"
);
switch
(
access
)
switch
(
access
)
{
{
case
HASH_WRITE
:
case
HASH_WRITE
:
...
@@ -201,8 +201,7 @@ _hash_getbuf(Relation rel, BlockNumber blkno, int access)
...
@@ -201,8 +201,7 @@ _hash_getbuf(Relation rel, BlockNumber blkno, int access)
_hash_setpagelock
(
rel
,
blkno
,
access
);
_hash_setpagelock
(
rel
,
blkno
,
access
);
break
;
break
;
default:
default:
elog
(
ERROR
,
"_hash_getbuf: invalid access (%d) on new blk: %s"
,
elog
(
ERROR
,
"unrecognized hash access code: %d"
,
access
);
access
,
RelationGetRelationName
(
rel
));
break
;
break
;
}
}
buf
=
ReadBuffer
(
rel
,
blkno
);
buf
=
ReadBuffer
(
rel
,
blkno
);
...
@@ -228,8 +227,8 @@ _hash_relbuf(Relation rel, Buffer buf, int access)
...
@@ -228,8 +227,8 @@ _hash_relbuf(Relation rel, Buffer buf, int access)
_hash_unsetpagelock
(
rel
,
blkno
,
access
);
_hash_unsetpagelock
(
rel
,
blkno
,
access
);
break
;
break
;
default:
default:
elog
(
ERROR
,
"
_hash_relbuf: invalid access (%d) on blk %x: %s"
,
elog
(
ERROR
,
"
unrecognized hash access code: %d"
,
access
);
access
,
blkno
,
RelationGetRelationName
(
rel
))
;
break
;
}
}
ReleaseBuffer
(
buf
);
ReleaseBuffer
(
buf
);
...
@@ -287,8 +286,7 @@ _hash_chgbufaccess(Relation rel,
...
@@ -287,8 +286,7 @@ _hash_chgbufaccess(Relation rel,
_hash_relbuf
(
rel
,
*
bufp
,
from_access
);
_hash_relbuf
(
rel
,
*
bufp
,
from_access
);
break
;
break
;
default:
default:
elog
(
ERROR
,
"_hash_chgbufaccess: invalid access (%d) on blk %x: %s"
,
elog
(
ERROR
,
"unrecognized hash access code: %d"
,
from_access
);
from_access
,
blkno
,
RelationGetRelationName
(
rel
));
break
;
break
;
}
}
*
bufp
=
_hash_getbuf
(
rel
,
blkno
,
to_access
);
*
bufp
=
_hash_getbuf
(
rel
,
blkno
,
to_access
);
...
@@ -322,8 +320,7 @@ _hash_setpagelock(Relation rel,
...
@@ -322,8 +320,7 @@ _hash_setpagelock(Relation rel,
LockPage
(
rel
,
blkno
,
ShareLock
);
LockPage
(
rel
,
blkno
,
ShareLock
);
break
;
break
;
default:
default:
elog
(
ERROR
,
"_hash_setpagelock: invalid access (%d) on blk %x: %s"
,
elog
(
ERROR
,
"unrecognized hash access code: %d"
,
access
);
access
,
blkno
,
RelationGetRelationName
(
rel
));
break
;
break
;
}
}
}
}
...
@@ -346,8 +343,7 @@ _hash_unsetpagelock(Relation rel,
...
@@ -346,8 +343,7 @@ _hash_unsetpagelock(Relation rel,
UnlockPage
(
rel
,
blkno
,
ShareLock
);
UnlockPage
(
rel
,
blkno
,
ShareLock
);
break
;
break
;
default:
default:
elog
(
ERROR
,
"_hash_unsetpagelock: invalid access (%d) on blk %x: %s"
,
elog
(
ERROR
,
"unrecognized hash access code: %d"
,
access
);
access
,
blkno
,
RelationGetRelationName
(
rel
));
break
;
break
;
}
}
}
}
...
@@ -409,8 +405,6 @@ _hash_expandtable(Relation rel, Buffer metabuf)
...
@@ -409,8 +405,6 @@ _hash_expandtable(Relation rel, Buffer metabuf)
Bucket
new_bucket
;
Bucket
new_bucket
;
uint32
spare_ndx
;
uint32
spare_ndx
;
/* elog(DEBUG, "_hash_expandtable: expanding..."); */
metap
=
(
HashMetaPage
)
BufferGetPage
(
metabuf
);
metap
=
(
HashMetaPage
)
BufferGetPage
(
metabuf
);
_hash_checkpage
((
Page
)
metap
,
LH_META_PAGE
);
_hash_checkpage
((
Page
)
metap
,
LH_META_PAGE
);
...
@@ -483,9 +477,6 @@ _hash_splitpage(Relation rel,
...
@@ -483,9 +477,6 @@ _hash_splitpage(Relation rel,
Page
npage
;
Page
npage
;
TupleDesc
itupdesc
;
TupleDesc
itupdesc
;
/* elog(DEBUG, "_hash_splitpage: splitting %d into %d,%d",
obucket, obucket, nbucket);
*/
metap
=
(
HashMetaPage
)
BufferGetPage
(
metabuf
);
metap
=
(
HashMetaPage
)
BufferGetPage
(
metabuf
);
_hash_checkpage
((
Page
)
metap
,
LH_META_PAGE
);
_hash_checkpage
((
Page
)
metap
,
LH_META_PAGE
);
...
@@ -534,7 +525,7 @@ _hash_splitpage(Relation rel,
...
@@ -534,7 +525,7 @@ _hash_splitpage(Relation rel,
opage
=
BufferGetPage
(
obuf
);
opage
=
BufferGetPage
(
obuf
);
_hash_checkpage
(
opage
,
LH_OVERFLOW_PAGE
);
_hash_checkpage
(
opage
,
LH_OVERFLOW_PAGE
);
if
(
PageIsEmpty
(
opage
))
if
(
PageIsEmpty
(
opage
))
elog
(
ERROR
,
"
_hash_splitpage: empty overflow page %d
"
,
oblkno
);
elog
(
ERROR
,
"
empty hash overflow page %u
"
,
oblkno
);
oopaque
=
(
HashPageOpaque
)
PageGetSpecialPointer
(
opage
);
oopaque
=
(
HashPageOpaque
)
PageGetSpecialPointer
(
opage
);
}
}
...
@@ -569,13 +560,9 @@ _hash_splitpage(Relation rel,
...
@@ -569,13 +560,9 @@ _hash_splitpage(Relation rel,
opage
=
BufferGetPage
(
obuf
);
opage
=
BufferGetPage
(
obuf
);
_hash_checkpage
(
opage
,
LH_OVERFLOW_PAGE
);
_hash_checkpage
(
opage
,
LH_OVERFLOW_PAGE
);
oopaque
=
(
HashPageOpaque
)
PageGetSpecialPointer
(
opage
);
oopaque
=
(
HashPageOpaque
)
PageGetSpecialPointer
(
opage
);
/* we're guaranteed that an ovfl page has at least 1 tuple */
/* we're guaranteed that an ovfl page has at least 1 tuple */
if
(
PageIsEmpty
(
opage
))
if
(
PageIsEmpty
(
opage
))
{
elog
(
ERROR
,
"empty hash overflow page %u"
,
oblkno
);
elog
(
ERROR
,
"_hash_splitpage: empty ovfl page %d!"
,
oblkno
);
}
ooffnum
=
FirstOffsetNumber
;
ooffnum
=
FirstOffsetNumber
;
omaxoffnum
=
PageGetMaxOffsetNumber
(
opage
);
omaxoffnum
=
PageGetMaxOffsetNumber
(
opage
);
}
}
...
@@ -626,7 +613,7 @@ _hash_splitpage(Relation rel,
...
@@ -626,7 +613,7 @@ _hash_splitpage(Relation rel,
noffnum
=
OffsetNumberNext
(
PageGetMaxOffsetNumber
(
npage
));
noffnum
=
OffsetNumberNext
(
PageGetMaxOffsetNumber
(
npage
));
if
(
PageAddItem
(
npage
,
(
Item
)
hitem
,
itemsz
,
noffnum
,
LP_USED
)
if
(
PageAddItem
(
npage
,
(
Item
)
hitem
,
itemsz
,
noffnum
,
LP_USED
)
==
InvalidOffsetNumber
)
==
InvalidOffsetNumber
)
elog
(
ERROR
,
"
_hash_splitpage: failed to add index item to %s
"
,
elog
(
ERROR
,
"
failed to add index item to
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
_hash_wrtnorelbuf
(
nbuf
);
_hash_wrtnorelbuf
(
nbuf
);
...
@@ -670,10 +657,7 @@ _hash_splitpage(Relation rel,
...
@@ -670,10 +657,7 @@ _hash_splitpage(Relation rel,
oblkno
=
BufferGetBlockNumber
(
obuf
);
oblkno
=
BufferGetBlockNumber
(
obuf
);
oopaque
=
(
HashPageOpaque
)
PageGetSpecialPointer
(
opage
);
oopaque
=
(
HashPageOpaque
)
PageGetSpecialPointer
(
opage
);
if
(
PageIsEmpty
(
opage
))
if
(
PageIsEmpty
(
opage
))
{
elog
(
ERROR
,
"empty hash overflow page %u"
,
oblkno
);
elog
(
ERROR
,
"_hash_splitpage: empty overflow page %d"
,
oblkno
);
}
ooffnum
=
FirstOffsetNumber
;
ooffnum
=
FirstOffsetNumber
;
omaxoffnum
=
PageGetMaxOffsetNumber
(
opage
);
omaxoffnum
=
PageGetMaxOffsetNumber
(
opage
);
}
}
...
...
src/backend/access/hash/hashutil.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.3
1 2002/07/02 06:18:57 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.3
2 2003/07/21 20:29:38 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -78,7 +78,9 @@ _hash_formitem(IndexTuple itup)
...
@@ -78,7 +78,9 @@ _hash_formitem(IndexTuple itup)
/* disallow nulls in hash keys */
/* disallow nulls in hash keys */
if
(
IndexTupleHasNulls
(
itup
))
if
(
IndexTupleHasNulls
(
itup
))
elog
(
ERROR
,
"hash indices cannot include null keys"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"hash indexes cannot include null keys"
)));
/* make a copy of the index tuple with room for the sequence number */
/* make a copy of the index tuple with room for the sequence number */
tuplen
=
IndexTupleSize
(
itup
);
tuplen
=
IndexTupleSize
(
itup
);
...
...
src/backend/access/heap/heapam.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.15
1 2003/02/23 20:32:11
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.15
2 2003/07/21 20:29:38
tgl Exp $
*
*
*
*
* INTERFACE ROUTINES
* INTERFACE ROUTINES
...
@@ -134,19 +134,16 @@ heapgettup(Relation relation,
...
@@ -134,19 +134,16 @@ heapgettup(Relation relation,
*/
*/
#ifdef HEAPDEBUGALL
#ifdef HEAPDEBUGALL
if
(
ItemPointerIsValid
(
tid
))
if
(
ItemPointerIsValid
(
tid
))
{
elog
(
DEBUG2
,
"heapgettup(%s, tid=0x%x[%d,%d], dir=%d, ...)"
,
elog
(
LOG
,
"heapgettup(%s, tid=0x%x[%d,%d], dir=%d, ...)"
,
RelationGetRelationName
(
relation
),
tid
,
tid
->
ip_blkid
,
RelationGetRelationName
(
relation
),
tid
,
tid
->
ip_blkid
,
tid
->
ip_posid
,
dir
);
tid
->
ip_posid
,
dir
);
}
else
else
{
elog
(
DEBUG2
,
"heapgettup(%s, tid=0x%x, dir=%d, ...)"
,
elog
(
LOG
,
"heapgettup(%s, tid=0x%x, dir=%d, ...)"
,
RelationGetRelationName
(
relation
),
tid
,
dir
);
RelationGetRelationName
(
relation
),
tid
,
dir
);
}
elog
(
LOG
,
"heapgettup(..., b=0x%x, nkeys=%d, key=0x%x"
,
buffer
,
nkeys
,
key
);
elog
(
LOG
,
"heapgettup: relation(%c)=`%s', %p"
,
elog
(
DEBUG2
,
"heapgettup(..., b=0x%x, nkeys=%d, key=0x%x"
,
buffer
,
nkeys
,
key
);
elog
(
DEBUG2
,
"heapgettup: relation(%c)=`%s', %p"
,
relation
->
rd_rel
->
relkind
,
RelationGetRelationName
(
relation
),
relation
->
rd_rel
->
relkind
,
RelationGetRelationName
(
relation
),
snapshot
);
snapshot
);
#endif
/* !defined(HEAPLOGALL) */
#endif
/* !defined(HEAPLOGALL) */
...
@@ -194,7 +191,7 @@ heapgettup(Relation relation,
...
@@ -194,7 +191,7 @@ heapgettup(Relation relation,
relation
,
relation
,
ItemPointerGetBlockNumber
(
tid
));
ItemPointerGetBlockNumber
(
tid
));
if
(
!
BufferIsValid
(
*
buffer
))
if
(
!
BufferIsValid
(
*
buffer
))
elog
(
ERROR
,
"
heapgettup: failed ReadBuffer
"
);
elog
(
ERROR
,
"
ReadBuffer failed
"
);
LockBuffer
(
*
buffer
,
BUFFER_LOCK_SHARE
);
LockBuffer
(
*
buffer
,
BUFFER_LOCK_SHARE
);
...
@@ -229,7 +226,7 @@ heapgettup(Relation relation,
...
@@ -229,7 +226,7 @@ heapgettup(Relation relation,
relation
,
relation
,
page
);
page
);
if
(
!
BufferIsValid
(
*
buffer
))
if
(
!
BufferIsValid
(
*
buffer
))
elog
(
ERROR
,
"
heapgettup: failed ReadBuffer
"
);
elog
(
ERROR
,
"
ReadBuffer failed
"
);
LockBuffer
(
*
buffer
,
BUFFER_LOCK_SHARE
);
LockBuffer
(
*
buffer
,
BUFFER_LOCK_SHARE
);
...
@@ -269,7 +266,7 @@ heapgettup(Relation relation,
...
@@ -269,7 +266,7 @@ heapgettup(Relation relation,
relation
,
relation
,
page
);
page
);
if
(
!
BufferIsValid
(
*
buffer
))
if
(
!
BufferIsValid
(
*
buffer
))
elog
(
ERROR
,
"
heapgettup: failed ReadBuffer
"
);
elog
(
ERROR
,
"
ReadBuffer failed
"
);
LockBuffer
(
*
buffer
,
BUFFER_LOCK_SHARE
);
LockBuffer
(
*
buffer
,
BUFFER_LOCK_SHARE
);
...
@@ -363,7 +360,7 @@ heapgettup(Relation relation,
...
@@ -363,7 +360,7 @@ heapgettup(Relation relation,
relation
,
relation
,
page
);
page
);
if
(
!
BufferIsValid
(
*
buffer
))
if
(
!
BufferIsValid
(
*
buffer
))
elog
(
ERROR
,
"
heapgettup: failed ReadBuffer
"
);
elog
(
ERROR
,
"
ReadBuffer failed
"
);
LockBuffer
(
*
buffer
,
BUFFER_LOCK_SHARE
);
LockBuffer
(
*
buffer
,
BUFFER_LOCK_SHARE
);
dp
=
(
Page
)
BufferGetPage
(
*
buffer
);
dp
=
(
Page
)
BufferGetPage
(
*
buffer
);
...
@@ -459,7 +456,7 @@ relation_open(Oid relationId, LOCKMODE lockmode)
...
@@ -459,7 +456,7 @@ relation_open(Oid relationId, LOCKMODE lockmode)
r
=
RelationIdGetRelation
(
relationId
);
r
=
RelationIdGetRelation
(
relationId
);
if
(
!
RelationIsValid
(
r
))
if
(
!
RelationIsValid
(
r
))
elog
(
ERROR
,
"
Relation %u does not exist
"
,
relationId
);
elog
(
ERROR
,
"
could not open relation with OID %u
"
,
relationId
);
if
(
lockmode
!=
NoLock
)
if
(
lockmode
!=
NoLock
)
LockRelation
(
r
,
lockmode
);
LockRelation
(
r
,
lockmode
);
...
@@ -532,7 +529,7 @@ relation_openr(const char *sysRelationName, LOCKMODE lockmode)
...
@@ -532,7 +529,7 @@ relation_openr(const char *sysRelationName, LOCKMODE lockmode)
r
=
RelationSysNameGetRelation
(
sysRelationName
);
r
=
RelationSysNameGetRelation
(
sysRelationName
);
if
(
!
RelationIsValid
(
r
))
if
(
!
RelationIsValid
(
r
))
elog
(
ERROR
,
"
Relation
\"
%s
\"
does not exist
"
,
sysRelationName
);
elog
(
ERROR
,
"
could not open relation
\"
%s
\"
"
,
sysRelationName
);
if
(
lockmode
!=
NoLock
)
if
(
lockmode
!=
NoLock
)
LockRelation
(
r
,
lockmode
);
LockRelation
(
r
,
lockmode
);
...
@@ -578,14 +575,20 @@ heap_open(Oid relationId, LOCKMODE lockmode)
...
@@ -578,14 +575,20 @@ heap_open(Oid relationId, LOCKMODE lockmode)
r
=
relation_open
(
relationId
,
lockmode
);
r
=
relation_open
(
relationId
,
lockmode
);
if
(
r
->
rd_rel
->
relkind
==
RELKIND_INDEX
)
if
(
r
->
rd_rel
->
relkind
==
RELKIND_INDEX
)
elog
(
ERROR
,
"%s is an index relation"
,
ereport
(
ERROR
,
RelationGetRelationName
(
r
));
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"
\"
%s
\"
is an index relation"
,
RelationGetRelationName
(
r
))));
else
if
(
r
->
rd_rel
->
relkind
==
RELKIND_SPECIAL
)
else
if
(
r
->
rd_rel
->
relkind
==
RELKIND_SPECIAL
)
elog
(
ERROR
,
"%s is a special relation"
,
ereport
(
ERROR
,
RelationGetRelationName
(
r
));
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"
\"
%s
\"
is a special relation"
,
RelationGetRelationName
(
r
))));
else
if
(
r
->
rd_rel
->
relkind
==
RELKIND_COMPOSITE_TYPE
)
else
if
(
r
->
rd_rel
->
relkind
==
RELKIND_COMPOSITE_TYPE
)
elog
(
ERROR
,
"%s is a composite type"
,
ereport
(
ERROR
,
RelationGetRelationName
(
r
));
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"
\"
%s
\"
is a composite type"
,
RelationGetRelationName
(
r
))));
pgstat_initstats
(
&
r
->
pgstat_info
,
r
);
pgstat_initstats
(
&
r
->
pgstat_info
,
r
);
...
@@ -607,14 +610,20 @@ heap_openrv(const RangeVar *relation, LOCKMODE lockmode)
...
@@ -607,14 +610,20 @@ heap_openrv(const RangeVar *relation, LOCKMODE lockmode)
r
=
relation_openrv
(
relation
,
lockmode
);
r
=
relation_openrv
(
relation
,
lockmode
);
if
(
r
->
rd_rel
->
relkind
==
RELKIND_INDEX
)
if
(
r
->
rd_rel
->
relkind
==
RELKIND_INDEX
)
elog
(
ERROR
,
"%s is an index relation"
,
ereport
(
ERROR
,
RelationGetRelationName
(
r
));
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"
\"
%s
\"
is an index relation"
,
RelationGetRelationName
(
r
))));
else
if
(
r
->
rd_rel
->
relkind
==
RELKIND_SPECIAL
)
else
if
(
r
->
rd_rel
->
relkind
==
RELKIND_SPECIAL
)
elog
(
ERROR
,
"%s is a special relation"
,
ereport
(
ERROR
,
RelationGetRelationName
(
r
));
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"
\"
%s
\"
is a special relation"
,
RelationGetRelationName
(
r
))));
else
if
(
r
->
rd_rel
->
relkind
==
RELKIND_COMPOSITE_TYPE
)
else
if
(
r
->
rd_rel
->
relkind
==
RELKIND_COMPOSITE_TYPE
)
elog
(
ERROR
,
"%s is a composite type"
,
ereport
(
ERROR
,
RelationGetRelationName
(
r
));
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"
\"
%s
\"
is a composite type"
,
RelationGetRelationName
(
r
))));
pgstat_initstats
(
&
r
->
pgstat_info
,
r
);
pgstat_initstats
(
&
r
->
pgstat_info
,
r
);
...
@@ -636,14 +645,20 @@ heap_openr(const char *sysRelationName, LOCKMODE lockmode)
...
@@ -636,14 +645,20 @@ heap_openr(const char *sysRelationName, LOCKMODE lockmode)
r
=
relation_openr
(
sysRelationName
,
lockmode
);
r
=
relation_openr
(
sysRelationName
,
lockmode
);
if
(
r
->
rd_rel
->
relkind
==
RELKIND_INDEX
)
if
(
r
->
rd_rel
->
relkind
==
RELKIND_INDEX
)
elog
(
ERROR
,
"%s is an index relation"
,
ereport
(
ERROR
,
RelationGetRelationName
(
r
));
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"
\"
%s
\"
is an index relation"
,
RelationGetRelationName
(
r
))));
else
if
(
r
->
rd_rel
->
relkind
==
RELKIND_SPECIAL
)
else
if
(
r
->
rd_rel
->
relkind
==
RELKIND_SPECIAL
)
elog
(
ERROR
,
"%s is a special relation"
,
ereport
(
ERROR
,
RelationGetRelationName
(
r
));
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"
\"
%s
\"
is a special relation"
,
RelationGetRelationName
(
r
))));
else
if
(
r
->
rd_rel
->
relkind
==
RELKIND_COMPOSITE_TYPE
)
else
if
(
r
->
rd_rel
->
relkind
==
RELKIND_COMPOSITE_TYPE
)
elog
(
ERROR
,
"%s is a composite type"
,
ereport
(
ERROR
,
RelationGetRelationName
(
r
));
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"
\"
%s
\"
is a composite type"
,
RelationGetRelationName
(
r
))));
pgstat_initstats
(
&
r
->
pgstat_info
,
r
);
pgstat_initstats
(
&
r
->
pgstat_info
,
r
);
...
@@ -661,12 +676,6 @@ heap_beginscan(Relation relation, Snapshot snapshot,
...
@@ -661,12 +676,6 @@ heap_beginscan(Relation relation, Snapshot snapshot,
{
{
HeapScanDesc
scan
;
HeapScanDesc
scan
;
/*
* sanity checks
*/
if
(
!
RelationIsValid
(
relation
))
elog
(
ERROR
,
"heap_beginscan: !RelationIsValid(relation)"
);
/*
/*
* increment relation ref count while scanning relation
* increment relation ref count while scanning relation
*
*
...
@@ -767,14 +776,12 @@ heap_endscan(HeapScanDesc scan)
...
@@ -767,14 +776,12 @@ heap_endscan(HeapScanDesc scan)
#ifdef HEAPDEBUGALL
#ifdef HEAPDEBUGALL
#define HEAPDEBUG_1 \
#define HEAPDEBUG_1 \
elog(
LOG
, "heap_getnext([%s,nkeys=%d],dir=%d) called", \
elog(
DEBUG2
, "heap_getnext([%s,nkeys=%d],dir=%d) called", \
RelationGetRelationName(scan->rs_rd), scan->rs_nkeys, (int) direction)
RelationGetRelationName(scan->rs_rd), scan->rs_nkeys, (int) direction)
#define HEAPDEBUG_2 \
#define HEAPDEBUG_2 \
elog(LOG, "heap_getnext returning EOS")
elog(DEBUG2, "heap_getnext returning EOS")
#define HEAPDEBUG_3 \
#define HEAPDEBUG_3 \
elog(LOG
, "heap_getnext returning tuple")
elog(DEBUG2
, "heap_getnext returning tuple")
#else
#else
#define HEAPDEBUG_1
#define HEAPDEBUG_1
#define HEAPDEBUG_2
#define HEAPDEBUG_2
...
@@ -787,12 +794,6 @@ heap_getnext(HeapScanDesc scan, ScanDirection direction)
...
@@ -787,12 +794,6 @@ heap_getnext(HeapScanDesc scan, ScanDirection direction)
{
{
/* Note: no locking manipulations needed */
/* Note: no locking manipulations needed */
/*
* argument checks
*/
if
(
scan
==
NULL
)
elog
(
ERROR
,
"heap_getnext: NULL relscan"
);
HEAPDEBUG_1
;
/* heap_getnext( info ) */
HEAPDEBUG_1
;
/* heap_getnext( info ) */
/*
/*
...
@@ -847,7 +848,7 @@ heap_getnext(HeapScanDesc scan, ScanDirection direction)
...
@@ -847,7 +848,7 @@ heap_getnext(HeapScanDesc scan, ScanDirection direction)
* the tuple); when keep_buf = false, the pin is released and *userbuf is set
* the tuple); when keep_buf = false, the pin is released and *userbuf is set
* to InvalidBuffer.
* to InvalidBuffer.
*
*
* It is somewhat inconsistent that we e
log
() on invalid block number but
* It is somewhat inconsistent that we e
report
() on invalid block number but
* return false on invalid item number. This is historical. The only
* return false on invalid item number. This is historical. The only
* justification I can see is that the caller can relatively easily check the
* justification I can see is that the caller can relatively easily check the
* block number for validity, but cannot check the item number without reading
* block number for validity, but cannot check the item number without reading
...
@@ -875,7 +876,7 @@ heap_fetch(Relation relation,
...
@@ -875,7 +876,7 @@ heap_fetch(Relation relation,
buffer
=
ReadBuffer
(
relation
,
ItemPointerGetBlockNumber
(
tid
));
buffer
=
ReadBuffer
(
relation
,
ItemPointerGetBlockNumber
(
tid
));
if
(
!
BufferIsValid
(
buffer
))
if
(
!
BufferIsValid
(
buffer
))
elog
(
ERROR
,
"
heap_fetch: ReadBuffer(%s
, %lu) failed"
,
elog
(
ERROR
,
"
ReadBuffer(
\"
%s
\"
, %lu) failed"
,
RelationGetRelationName
(
relation
),
RelationGetRelationName
(
relation
),
(
unsigned
long
)
ItemPointerGetBlockNumber
(
tid
));
(
unsigned
long
)
ItemPointerGetBlockNumber
(
tid
));
...
@@ -985,8 +986,9 @@ heap_get_latest_tid(Relation relation,
...
@@ -985,8 +986,9 @@ heap_get_latest_tid(Relation relation,
buffer
=
ReadBuffer
(
relation
,
ItemPointerGetBlockNumber
(
tid
));
buffer
=
ReadBuffer
(
relation
,
ItemPointerGetBlockNumber
(
tid
));
if
(
!
BufferIsValid
(
buffer
))
if
(
!
BufferIsValid
(
buffer
))
elog
(
ERROR
,
"heap_get_latest_tid: %s relation: ReadBuffer(%lx) failed"
,
elog
(
ERROR
,
"ReadBuffer(
\"
%s
\"
, %lu) failed"
,
RelationGetRelationName
(
relation
),
(
long
)
tid
);
RelationGetRelationName
(
relation
),
(
unsigned
long
)
ItemPointerGetBlockNumber
(
tid
));
LockBuffer
(
buffer
,
BUFFER_LOCK_SHARE
);
LockBuffer
(
buffer
,
BUFFER_LOCK_SHARE
);
...
@@ -1103,7 +1105,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid)
...
@@ -1103,7 +1105,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid)
/* Find buffer to insert this tuple into */
/* Find buffer to insert this tuple into */
buffer
=
RelationGetBufferForTuple
(
relation
,
tup
->
t_len
,
InvalidBuffer
);
buffer
=
RelationGetBufferForTuple
(
relation
,
tup
->
t_len
,
InvalidBuffer
);
/* NO E
LOG
(ERROR) from here till changes are logged */
/* NO E
REPORT
(ERROR) from here till changes are logged */
START_CRIT_SECTION
();
START_CRIT_SECTION
();
RelationPutHeapTuple
(
relation
,
buffer
,
tup
);
RelationPutHeapTuple
(
relation
,
buffer
,
tup
);
...
@@ -1219,7 +1221,7 @@ heap_delete(Relation relation, ItemPointer tid,
...
@@ -1219,7 +1221,7 @@ heap_delete(Relation relation, ItemPointer tid,
buffer
=
ReadBuffer
(
relation
,
ItemPointerGetBlockNumber
(
tid
));
buffer
=
ReadBuffer
(
relation
,
ItemPointerGetBlockNumber
(
tid
));
if
(
!
BufferIsValid
(
buffer
))
if
(
!
BufferIsValid
(
buffer
))
elog
(
ERROR
,
"
heap_delete: failed ReadBuffer
"
);
elog
(
ERROR
,
"
ReadBuffer failed
"
);
LockBuffer
(
buffer
,
BUFFER_LOCK_EXCLUSIVE
);
LockBuffer
(
buffer
,
BUFFER_LOCK_EXCLUSIVE
);
...
@@ -1238,7 +1240,7 @@ l1:
...
@@ -1238,7 +1240,7 @@ l1:
{
{
LockBuffer
(
buffer
,
BUFFER_LOCK_UNLOCK
);
LockBuffer
(
buffer
,
BUFFER_LOCK_UNLOCK
);
ReleaseBuffer
(
buffer
);
ReleaseBuffer
(
buffer
);
elog
(
ERROR
,
"
heap_delete: (am)invalid tid
"
);
elog
(
ERROR
,
"
attempted to delete invisible tuple
"
);
}
}
else
if
(
result
==
HeapTupleBeingUpdated
)
else
if
(
result
==
HeapTupleBeingUpdated
)
{
{
...
@@ -1358,7 +1360,7 @@ l1:
...
@@ -1358,7 +1360,7 @@ l1:
* This routine may be used to delete a tuple when concurrent updates of
* This routine may be used to delete a tuple when concurrent updates of
* the target tuple are not expected (for example, because we have a lock
* the target tuple are not expected (for example, because we have a lock
* on the relation associated with the tuple). Any failure is reported
* on the relation associated with the tuple). Any failure is reported
* via e
log
().
* via e
report
().
*/
*/
void
void
simple_heap_delete
(
Relation
relation
,
ItemPointer
tid
)
simple_heap_delete
(
Relation
relation
,
ItemPointer
tid
)
...
@@ -1371,7 +1373,7 @@ simple_heap_delete(Relation relation, ItemPointer tid)
...
@@ -1371,7 +1373,7 @@ simple_heap_delete(Relation relation, ItemPointer tid)
{
{
case
HeapTupleSelfUpdated
:
case
HeapTupleSelfUpdated
:
/* Tuple was already updated in current command? */
/* Tuple was already updated in current command? */
elog
(
ERROR
,
"
simple_heap_delete:
tuple already updated by self"
);
elog
(
ERROR
,
"tuple already updated by self"
);
break
;
break
;
case
HeapTupleMayBeUpdated
:
case
HeapTupleMayBeUpdated
:
...
@@ -1379,11 +1381,11 @@ simple_heap_delete(Relation relation, ItemPointer tid)
...
@@ -1379,11 +1381,11 @@ simple_heap_delete(Relation relation, ItemPointer tid)
break
;
break
;
case
HeapTupleUpdated
:
case
HeapTupleUpdated
:
elog
(
ERROR
,
"
simple_heap_delete:
tuple concurrently updated"
);
elog
(
ERROR
,
"tuple concurrently updated"
);
break
;
break
;
default:
default:
elog
(
ERROR
,
"
Unknown status %u from heap_delete
"
,
result
);
elog
(
ERROR
,
"
unrecognized heap_delete status: %u
"
,
result
);
break
;
break
;
}
}
}
}
...
@@ -1413,7 +1415,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
...
@@ -1413,7 +1415,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
buffer
=
ReadBuffer
(
relation
,
ItemPointerGetBlockNumber
(
otid
));
buffer
=
ReadBuffer
(
relation
,
ItemPointerGetBlockNumber
(
otid
));
if
(
!
BufferIsValid
(
buffer
))
if
(
!
BufferIsValid
(
buffer
))
elog
(
ERROR
,
"
heap_update: failed ReadBuffer
"
);
elog
(
ERROR
,
"
ReadBuffer failed
"
);
LockBuffer
(
buffer
,
BUFFER_LOCK_EXCLUSIVE
);
LockBuffer
(
buffer
,
BUFFER_LOCK_EXCLUSIVE
);
dp
=
(
PageHeader
)
BufferGetPage
(
buffer
);
dp
=
(
PageHeader
)
BufferGetPage
(
buffer
);
...
@@ -1438,7 +1440,7 @@ l2:
...
@@ -1438,7 +1440,7 @@ l2:
{
{
LockBuffer
(
buffer
,
BUFFER_LOCK_UNLOCK
);
LockBuffer
(
buffer
,
BUFFER_LOCK_UNLOCK
);
ReleaseBuffer
(
buffer
);
ReleaseBuffer
(
buffer
);
elog
(
ERROR
,
"
heap_update: (am)invalid tid
"
);
elog
(
ERROR
,
"
attempted to update invisible tuple
"
);
}
}
else
if
(
result
==
HeapTupleBeingUpdated
)
else
if
(
result
==
HeapTupleBeingUpdated
)
{
{
...
@@ -1611,7 +1613,7 @@ l2:
...
@@ -1611,7 +1613,7 @@ l2:
* buffer, only one pin is held.
* buffer, only one pin is held.
*/
*/
/* NO E
LOG
(ERROR) from here till changes are logged */
/* NO E
REPORT
(ERROR) from here till changes are logged */
START_CRIT_SECTION
();
START_CRIT_SECTION
();
RelationPutHeapTuple
(
relation
,
newbuf
,
newtup
);
/* insert new tuple */
RelationPutHeapTuple
(
relation
,
newbuf
,
newtup
);
/* insert new tuple */
...
@@ -1688,7 +1690,7 @@ l2:
...
@@ -1688,7 +1690,7 @@ l2:
* This routine may be used to update a tuple when concurrent updates of
* This routine may be used to update a tuple when concurrent updates of
* the target tuple are not expected (for example, because we have a lock
* the target tuple are not expected (for example, because we have a lock
* on the relation associated with the tuple). Any failure is reported
* on the relation associated with the tuple). Any failure is reported
* via e
log
().
* via e
report
().
*/
*/
void
void
simple_heap_update
(
Relation
relation
,
ItemPointer
otid
,
HeapTuple
tup
)
simple_heap_update
(
Relation
relation
,
ItemPointer
otid
,
HeapTuple
tup
)
...
@@ -1701,7 +1703,7 @@ simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup)
...
@@ -1701,7 +1703,7 @@ simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup)
{
{
case
HeapTupleSelfUpdated
:
case
HeapTupleSelfUpdated
:
/* Tuple was already updated in current command? */
/* Tuple was already updated in current command? */
elog
(
ERROR
,
"
simple_heap_update:
tuple already updated by self"
);
elog
(
ERROR
,
"tuple already updated by self"
);
break
;
break
;
case
HeapTupleMayBeUpdated
:
case
HeapTupleMayBeUpdated
:
...
@@ -1709,11 +1711,11 @@ simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup)
...
@@ -1709,11 +1711,11 @@ simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup)
break
;
break
;
case
HeapTupleUpdated
:
case
HeapTupleUpdated
:
elog
(
ERROR
,
"
simple_heap_update:
tuple concurrently updated"
);
elog
(
ERROR
,
"tuple concurrently updated"
);
break
;
break
;
default:
default:
elog
(
ERROR
,
"
Unknown status %u from heap_update
"
,
result
);
elog
(
ERROR
,
"
unrecognized heap_update status: %u
"
,
result
);
break
;
break
;
}
}
}
}
...
@@ -1733,7 +1735,7 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer,
...
@@ -1733,7 +1735,7 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer,
*
buffer
=
ReadBuffer
(
relation
,
ItemPointerGetBlockNumber
(
tid
));
*
buffer
=
ReadBuffer
(
relation
,
ItemPointerGetBlockNumber
(
tid
));
if
(
!
BufferIsValid
(
*
buffer
))
if
(
!
BufferIsValid
(
*
buffer
))
elog
(
ERROR
,
"
heap_mark4update: failed ReadBuffer
"
);
elog
(
ERROR
,
"
ReadBuffer failed
"
);
LockBuffer
(
*
buffer
,
BUFFER_LOCK_EXCLUSIVE
);
LockBuffer
(
*
buffer
,
BUFFER_LOCK_EXCLUSIVE
);
...
@@ -1750,7 +1752,7 @@ l3:
...
@@ -1750,7 +1752,7 @@ l3:
{
{
LockBuffer
(
*
buffer
,
BUFFER_LOCK_UNLOCK
);
LockBuffer
(
*
buffer
,
BUFFER_LOCK_UNLOCK
);
ReleaseBuffer
(
*
buffer
);
ReleaseBuffer
(
*
buffer
);
elog
(
ERROR
,
"
heap_mark4update: (am)invalid tid
"
);
elog
(
ERROR
,
"
attempted to mark4update invisible tuple
"
);
}
}
else
if
(
result
==
HeapTupleBeingUpdated
)
else
if
(
result
==
HeapTupleBeingUpdated
)
{
{
...
...
src/backend/access/heap/hio.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Id: hio.c,v 1.4
7 2003/02/13 05:35:11 momjian
Exp $
* $Id: hio.c,v 1.4
8 2003/07/21 20:29:38 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
/*
/*
* RelationPutHeapTuple - place tuple at specified page
* RelationPutHeapTuple - place tuple at specified page
*
*
* !!! E
LOG(ERROR) IS DISALLOWED HERE
!!!
* !!! E
REPORT(ERROR) IS DISALLOWED HERE !!! Must PANIC on failure
!!!
*
*
* Note - caller must hold BUFFER_LOCK_EXCLUSIVE on the buffer.
* Note - caller must hold BUFFER_LOCK_EXCLUSIVE on the buffer.
*/
*/
...
@@ -44,7 +44,7 @@ RelationPutHeapTuple(Relation relation,
...
@@ -44,7 +44,7 @@ RelationPutHeapTuple(Relation relation,
tuple
->
t_len
,
InvalidOffsetNumber
,
LP_USED
);
tuple
->
t_len
,
InvalidOffsetNumber
,
LP_USED
);
if
(
offnum
==
InvalidOffsetNumber
)
if
(
offnum
==
InvalidOffsetNumber
)
elog
(
PANIC
,
"
RelationPutHeapTuple: failed to add tupl
e"
);
elog
(
PANIC
,
"
failed to add tuple to pag
e"
);
/* Update tuple->t_self to the actual position where it was stored */
/* Update tuple->t_self to the actual position where it was stored */
ItemPointerSet
(
&
(
tuple
->
t_self
),
BufferGetBlockNumber
(
buffer
),
offnum
);
ItemPointerSet
(
&
(
tuple
->
t_self
),
BufferGetBlockNumber
(
buffer
),
offnum
);
...
@@ -84,7 +84,7 @@ RelationPutHeapTuple(Relation relation,
...
@@ -84,7 +84,7 @@ RelationPutHeapTuple(Relation relation,
* for indices only. Alternatively, we could define pseudo-table as
* for indices only. Alternatively, we could define pseudo-table as
* we do for transactions with XactLockTable.
* we do for transactions with XactLockTable.
*
*
*
ELOG
(ERROR) is allowed here, so this routine *must* be called
*
ereport
(ERROR) is allowed here, so this routine *must* be called
* before any (unlogged) changes are made in buffer pool.
* before any (unlogged) changes are made in buffer pool.
*/
*/
Buffer
Buffer
...
@@ -104,8 +104,11 @@ RelationGetBufferForTuple(Relation relation, Size len,
...
@@ -104,8 +104,11 @@ RelationGetBufferForTuple(Relation relation, Size len,
* If we're gonna fail for oversize tuple, do it right away
* If we're gonna fail for oversize tuple, do it right away
*/
*/
if
(
len
>
MaxTupleSize
)
if
(
len
>
MaxTupleSize
)
elog
(
ERROR
,
"Tuple is too big: size %lu, max size %ld"
,
ereport
(
ERROR
,
(
unsigned
long
)
len
,
MaxTupleSize
);
(
errcode
(
ERRCODE_PROGRAM_LIMIT_EXCEEDED
),
errmsg
(
"tuple is too big: size %lu, maximum size %lu"
,
(
unsigned
long
)
len
,
(
unsigned
long
)
MaxTupleSize
)));
if
(
otherBuffer
!=
InvalidBuffer
)
if
(
otherBuffer
!=
InvalidBuffer
)
otherBlock
=
BufferGetBlockNumber
(
otherBuffer
);
otherBlock
=
BufferGetBlockNumber
(
otherBuffer
);
...
@@ -268,7 +271,7 @@ RelationGetBufferForTuple(Relation relation, Size len,
...
@@ -268,7 +271,7 @@ RelationGetBufferForTuple(Relation relation, Size len,
if
(
len
>
PageGetFreeSpace
(
pageHeader
))
if
(
len
>
PageGetFreeSpace
(
pageHeader
))
{
{
/* We should not get here given the test at the top */
/* We should not get here given the test at the top */
elog
(
PANIC
,
"
T
uple is too big: size %lu"
,
(
unsigned
long
)
len
);
elog
(
PANIC
,
"
t
uple is too big: size %lu"
,
(
unsigned
long
)
len
);
}
}
/*
/*
...
...
src/backend/access/heap/tuptoaster.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.3
6 2002/09/04 20:31:09 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.3
7 2003/07/21 20:29:39 tgl
Exp $
*
*
*
*
* INTERFACE ROUTINES
* INTERFACE ROUTINES
...
@@ -896,7 +896,7 @@ toast_save_datum(Relation rel, Datum value)
...
@@ -896,7 +896,7 @@ toast_save_datum(Relation rel, Datum value)
memcpy
(
VARATT_DATA
(
&
chunk_data
),
data_p
,
chunk_size
);
memcpy
(
VARATT_DATA
(
&
chunk_data
),
data_p
,
chunk_size
);
toasttup
=
heap_formtuple
(
toasttupDesc
,
t_values
,
t_nulls
);
toasttup
=
heap_formtuple
(
toasttupDesc
,
t_values
,
t_nulls
);
if
(
!
HeapTupleIsValid
(
toasttup
))
if
(
!
HeapTupleIsValid
(
toasttup
))
elog
(
ERROR
,
"
F
ailed to build TOAST tuple"
);
elog
(
ERROR
,
"
f
ailed to build TOAST tuple"
);
simple_heap_insert
(
toastrel
,
toasttup
);
simple_heap_insert
(
toastrel
,
toasttup
);
...
@@ -912,7 +912,7 @@ toast_save_datum(Relation rel, Datum value)
...
@@ -912,7 +912,7 @@ toast_save_datum(Relation rel, Datum value)
&
(
toasttup
->
t_self
),
&
(
toasttup
->
t_self
),
toastrel
,
toastidx
->
rd_index
->
indisunique
);
toastrel
,
toastidx
->
rd_index
->
indisunique
);
if
(
idxres
==
NULL
)
if
(
idxres
==
NULL
)
elog
(
ERROR
,
"
F
ailed to insert index entry for TOAST tuple"
);
elog
(
ERROR
,
"
f
ailed to insert index entry for TOAST tuple"
);
/*
/*
* Free memory
* Free memory
...
...
src/backend/access/index/genam.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.3
8 2003/03/24 21:42:33
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.3
9 2003/07/21 20:29:39
tgl Exp $
*
*
* NOTES
* NOTES
* many of the old access method routines have been turned into
* many of the old access method routines have been turned into
...
@@ -70,9 +70,6 @@ RelationGetIndexScan(Relation indexRelation,
...
@@ -70,9 +70,6 @@ RelationGetIndexScan(Relation indexRelation,
{
{
IndexScanDesc
scan
;
IndexScanDesc
scan
;
if
(
!
RelationIsValid
(
indexRelation
))
elog
(
ERROR
,
"RelationGetIndexScan: relation invalid"
);
scan
=
(
IndexScanDesc
)
palloc
(
sizeof
(
IndexScanDescData
));
scan
=
(
IndexScanDesc
)
palloc
(
sizeof
(
IndexScanDescData
));
scan
->
heapRelation
=
NULL
;
/* may be set later */
scan
->
heapRelation
=
NULL
;
/* may be set later */
...
@@ -135,9 +132,6 @@ RelationGetIndexScan(Relation indexRelation,
...
@@ -135,9 +132,6 @@ RelationGetIndexScan(Relation indexRelation,
void
void
IndexScanEnd
(
IndexScanDesc
scan
)
IndexScanEnd
(
IndexScanDesc
scan
)
{
{
if
(
!
IndexScanIsValid
(
scan
))
elog
(
ERROR
,
"IndexScanEnd: invalid scan"
);
if
(
scan
->
keyData
!=
NULL
)
if
(
scan
->
keyData
!=
NULL
)
pfree
(
scan
->
keyData
);
pfree
(
scan
->
keyData
);
...
...
src/backend/access/index/indexam.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.6
6 2003/03/24 21:42:33
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.6
7 2003/07/21 20:29:39
tgl Exp $
*
*
* INTERFACE ROUTINES
* INTERFACE ROUTINES
* index_open - open an index relation by relation OID
* index_open - open an index relation by relation OID
...
@@ -90,7 +90,7 @@
...
@@ -90,7 +90,7 @@
procedure = indexRelation->rd_am->y, \
procedure = indexRelation->rd_am->y, \
(!RegProcedureIsValid(procedure)) ? \
(!RegProcedureIsValid(procedure)) ? \
elog(ERROR, "index_%s: invalid %s regproc", \
elog(ERROR, "index_%s: invalid %s regproc", \
CppAsString(x), CppAsString(y)) \
CppAsString(x), CppAsString(y)) \
: (void)NULL \
: (void)NULL \
)
)
...
@@ -99,7 +99,7 @@
...
@@ -99,7 +99,7 @@
procedure = scan->indexRelation->rd_am->y, \
procedure = scan->indexRelation->rd_am->y, \
(!RegProcedureIsValid(procedure)) ? \
(!RegProcedureIsValid(procedure)) ? \
elog(ERROR, "index_%s: invalid %s regproc", \
elog(ERROR, "index_%s: invalid %s regproc", \
CppAsString(x), CppAsString(y)) \
CppAsString(x), CppAsString(y)) \
: (void)NULL \
: (void)NULL \
)
)
...
@@ -129,8 +129,10 @@ index_open(Oid relationId)
...
@@ -129,8 +129,10 @@ index_open(Oid relationId)
r
=
relation_open
(
relationId
,
NoLock
);
r
=
relation_open
(
relationId
,
NoLock
);
if
(
r
->
rd_rel
->
relkind
!=
RELKIND_INDEX
)
if
(
r
->
rd_rel
->
relkind
!=
RELKIND_INDEX
)
elog
(
ERROR
,
"%s is not an index relation"
,
ereport
(
ERROR
,
RelationGetRelationName
(
r
));
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"
\"
%s
\"
is not an index relation"
,
RelationGetRelationName
(
r
))));
pgstat_initstats
(
&
r
->
pgstat_info
,
r
);
pgstat_initstats
(
&
r
->
pgstat_info
,
r
);
...
@@ -152,8 +154,10 @@ index_openrv(const RangeVar *relation)
...
@@ -152,8 +154,10 @@ index_openrv(const RangeVar *relation)
r
=
relation_openrv
(
relation
,
NoLock
);
r
=
relation_openrv
(
relation
,
NoLock
);
if
(
r
->
rd_rel
->
relkind
!=
RELKIND_INDEX
)
if
(
r
->
rd_rel
->
relkind
!=
RELKIND_INDEX
)
elog
(
ERROR
,
"%s is not an index relation"
,
ereport
(
ERROR
,
RelationGetRelationName
(
r
));
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"
\"
%s
\"
is not an index relation"
,
RelationGetRelationName
(
r
))));
pgstat_initstats
(
&
r
->
pgstat_info
,
r
);
pgstat_initstats
(
&
r
->
pgstat_info
,
r
);
...
@@ -175,8 +179,10 @@ index_openr(const char *sysRelationName)
...
@@ -175,8 +179,10 @@ index_openr(const char *sysRelationName)
r
=
relation_openr
(
sysRelationName
,
NoLock
);
r
=
relation_openr
(
sysRelationName
,
NoLock
);
if
(
r
->
rd_rel
->
relkind
!=
RELKIND_INDEX
)
if
(
r
->
rd_rel
->
relkind
!=
RELKIND_INDEX
)
elog
(
ERROR
,
"%s is not an index relation"
,
ereport
(
ERROR
,
RelationGetRelationName
(
r
));
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"
\"
%s
\"
is not an index relation"
,
RelationGetRelationName
(
r
))));
pgstat_initstats
(
&
r
->
pgstat_info
,
r
);
pgstat_initstats
(
&
r
->
pgstat_info
,
r
);
...
@@ -753,7 +759,7 @@ index_getprocinfo(Relation irel,
...
@@ -753,7 +759,7 @@ index_getprocinfo(Relation irel,
* use index_getprocid.)
* use index_getprocid.)
*/
*/
if
(
!
RegProcedureIsValid
(
procId
))
if
(
!
RegProcedureIsValid
(
procId
))
elog
(
ERROR
,
"
Missing support function %d for attribute %d of index %s
"
,
elog
(
ERROR
,
"
missing support function %d for attribute %d of index
\"
%s
\"
"
,
procnum
,
attnum
,
RelationGetRelationName
(
irel
));
procnum
,
attnum
,
RelationGetRelationName
(
irel
));
fmgr_info_cxt
(
procId
,
locinfo
,
irel
->
rd_indexcxt
);
fmgr_info_cxt
(
procId
,
locinfo
,
irel
->
rd_indexcxt
);
...
...
src/backend/access/index/istrat.c
View file @
ec7aa4b5
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.5
8 2002/06/20 20:29:25 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.5
9 2003/07/21 20:29:39 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -235,7 +235,7 @@ StrategyTermEvaluate(StrategyTerm term,
...
@@ -235,7 +235,7 @@ StrategyTermEvaluate(StrategyTerm term,
break
;
break
;
default:
default:
elog
(
ERROR
,
"
StrategyTermEvaluate: impossible case
%d"
,
elog
(
ERROR
,
"
impossible strategy case:
%d"
,
operator
->
flags
^
entry
->
sk_flags
);
operator
->
flags
^
entry
->
sk_flags
);
}
}
if
(
!
result
)
if
(
!
result
)
...
@@ -310,13 +310,14 @@ RelationGetStrategy(Relation relation,
...
@@ -310,13 +310,14 @@ RelationGetStrategy(Relation relation,
break
;
break
;
default:
default:
elog
(
FATAL
,
"RelationGetStrategy: impossible case %d"
,
entry
->
sk_flags
);
elog
(
ERROR
,
"impossible strategy case: %d"
,
entry
->
sk_flags
);
}
}
if
(
!
StrategyNumberIsInBounds
(
strategy
,
evaluation
->
maxStrategy
))
if
(
!
StrategyNumberIsInBounds
(
strategy
,
evaluation
->
maxStrategy
))
{
{
if
(
!
StrategyNumberIsValid
(
strategy
))
if
(
!
StrategyNumberIsValid
(
strategy
))
elog
(
ERROR
,
"
RelationGetStrategy: corrupted
evaluation"
);
elog
(
ERROR
,
"
corrupted strategy
evaluation"
);
}
}
return
strategy
;
return
strategy
;
...
@@ -435,8 +436,7 @@ RelationInvokeStrategy(Relation relation,
...
@@ -435,8 +436,7 @@ RelationInvokeStrategy(Relation relation,
}
}
}
}
elog
(
ERROR
,
"RelationInvokeStrategy: cannot evaluate strategy %d"
,
elog
(
ERROR
,
"cannot evaluate strategy %d"
,
strategy
);
strategy
);
/* not reached, just to make compiler happy */
/* not reached, just to make compiler happy */
return
FALSE
;
return
FALSE
;
...
...
src/backend/access/nbtree/nbtinsert.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.10
0 2003/05/27 17:49:45 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.10
1 2003/07/21 20:29:39 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -153,7 +153,7 @@ top:
...
@@ -153,7 +153,7 @@ top:
*
*
* Returns InvalidTransactionId if there is no conflict, else an xact ID
* Returns InvalidTransactionId if there is no conflict, else an xact ID
* we must wait for to see if it commits a conflicting tuple. If an actual
* we must wait for to see if it commits a conflicting tuple. If an actual
* conflict is detected, no return --- just e
log
().
* conflict is detected, no return --- just e
report
().
*/
*/
static
TransactionId
static
TransactionId
_bt_check_unique
(
Relation
rel
,
BTItem
btitem
,
Relation
heapRel
,
_bt_check_unique
(
Relation
rel
,
BTItem
btitem
,
Relation
heapRel
,
...
@@ -237,8 +237,10 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel,
...
@@ -237,8 +237,10 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel,
/*
/*
* Otherwise we have a definite conflict.
* Otherwise we have a definite conflict.
*/
*/
elog
(
ERROR
,
"Cannot insert a duplicate key into unique index %s"
,
ereport
(
ERROR
,
RelationGetRelationName
(
rel
));
(
errcode
(
ERRCODE_UNIQUE_VIOLATION
),
errmsg
(
"duplicate key violates UNIQUE constraint
\"
%s
\"
"
,
RelationGetRelationName
(
rel
))));
}
}
else
if
(
htup
.
t_data
!=
NULL
)
else
if
(
htup
.
t_data
!=
NULL
)
{
{
...
@@ -291,7 +293,7 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel,
...
@@ -291,7 +293,7 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel,
if
(
!
P_IGNORE
(
opaque
))
if
(
!
P_IGNORE
(
opaque
))
break
;
break
;
if
(
P_RIGHTMOST
(
opaque
))
if
(
P_RIGHTMOST
(
opaque
))
elog
(
ERROR
,
"
_bt_check_unique: fell off the end of %s
"
,
elog
(
ERROR
,
"
fell off the end of
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
}
}
maxoff
=
PageGetMaxOffsetNumber
(
page
);
maxoff
=
PageGetMaxOffsetNumber
(
page
);
...
@@ -387,8 +389,11 @@ _bt_insertonpg(Relation rel,
...
@@ -387,8 +389,11 @@ _bt_insertonpg(Relation rel,
* itemsz doesn't include the ItemId.
* itemsz doesn't include the ItemId.
*/
*/
if
(
itemsz
>
BTMaxItemSize
(
page
))
if
(
itemsz
>
BTMaxItemSize
(
page
))
elog
(
ERROR
,
"btree: index item size %lu exceeds maximum %lu"
,
ereport
(
ERROR
,
(
unsigned
long
)
itemsz
,
BTMaxItemSize
(
page
));
(
errcode
(
ERRCODE_PROGRAM_LIMIT_EXCEEDED
),
errmsg
(
"index tuple size %lu exceeds btree maximum, %lu"
,
(
unsigned
long
)
itemsz
,
(
unsigned
long
)
BTMaxItemSize
(
page
))));
/*
/*
* Determine exactly where new item will go.
* Determine exactly where new item will go.
...
@@ -445,7 +450,7 @@ _bt_insertonpg(Relation rel,
...
@@ -445,7 +450,7 @@ _bt_insertonpg(Relation rel,
if
(
!
P_IGNORE
(
lpageop
))
if
(
!
P_IGNORE
(
lpageop
))
break
;
break
;
if
(
P_RIGHTMOST
(
lpageop
))
if
(
P_RIGHTMOST
(
lpageop
))
elog
(
ERROR
,
"
_bt_insertonpg: fell off the end of %s
"
,
elog
(
ERROR
,
"
fell off the end of
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
}
}
_bt_relbuf
(
rel
,
buf
);
_bt_relbuf
(
rel
,
buf
);
...
@@ -536,7 +541,7 @@ _bt_insertonpg(Relation rel,
...
@@ -536,7 +541,7 @@ _bt_insertonpg(Relation rel,
}
}
}
}
/* Do the
actual update. No elog
(ERROR) until changes are logged */
/* Do the
update. No ereport
(ERROR) until changes are logged */
START_CRIT_SECTION
();
START_CRIT_SECTION
();
_bt_pgaddtup
(
rel
,
page
,
itemsz
,
btitem
,
newitemoff
,
"page"
);
_bt_pgaddtup
(
rel
,
page
,
itemsz
,
btitem
,
newitemoff
,
"page"
);
...
@@ -705,7 +710,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
...
@@ -705,7 +710,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
item
=
(
BTItem
)
PageGetItem
(
origpage
,
itemid
);
item
=
(
BTItem
)
PageGetItem
(
origpage
,
itemid
);
if
(
PageAddItem
(
rightpage
,
(
Item
)
item
,
itemsz
,
rightoff
,
if
(
PageAddItem
(
rightpage
,
(
Item
)
item
,
itemsz
,
rightoff
,
LP_USED
)
==
InvalidOffsetNumber
)
LP_USED
)
==
InvalidOffsetNumber
)
elog
(
PANIC
,
"
btree:
failed to add hikey to the right sibling"
);
elog
(
PANIC
,
"failed to add hikey to the right sibling"
);
rightoff
=
OffsetNumberNext
(
rightoff
);
rightoff
=
OffsetNumberNext
(
rightoff
);
}
}
...
@@ -730,7 +735,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
...
@@ -730,7 +735,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
}
}
if
(
PageAddItem
(
leftpage
,
(
Item
)
item
,
itemsz
,
leftoff
,
if
(
PageAddItem
(
leftpage
,
(
Item
)
item
,
itemsz
,
leftoff
,
LP_USED
)
==
InvalidOffsetNumber
)
LP_USED
)
==
InvalidOffsetNumber
)
elog
(
PANIC
,
"
btree:
failed to add hikey to the left sibling"
);
elog
(
PANIC
,
"failed to add hikey to the left sibling"
);
leftoff
=
OffsetNumberNext
(
leftoff
);
leftoff
=
OffsetNumberNext
(
leftoff
);
/*
/*
...
@@ -815,14 +820,14 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
...
@@ -815,14 +820,14 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
spage
=
BufferGetPage
(
sbuf
);
spage
=
BufferGetPage
(
sbuf
);
sopaque
=
(
BTPageOpaque
)
PageGetSpecialPointer
(
spage
);
sopaque
=
(
BTPageOpaque
)
PageGetSpecialPointer
(
spage
);
if
(
sopaque
->
btpo_prev
!=
ropaque
->
btpo_prev
)
if
(
sopaque
->
btpo_prev
!=
ropaque
->
btpo_prev
)
elog
(
PANIC
,
"
btree:
right sibling's left-link doesn't match"
);
elog
(
PANIC
,
"right sibling's left-link doesn't match"
);
}
}
/*
/*
* Right sibling is locked, new siblings are prepared, but original
* Right sibling is locked, new siblings are prepared, but original
* page is not updated yet. Log changes before continuing.
* page is not updated yet. Log changes before continuing.
*
*
* NO E
LOG
(ERROR) till right sibling is updated.
* NO E
REPORT
(ERROR) till right sibling is updated.
*/
*/
START_CRIT_SECTION
();
START_CRIT_SECTION
();
...
@@ -1059,7 +1064,7 @@ _bt_findsplitloc(Relation rel,
...
@@ -1059,7 +1064,7 @@ _bt_findsplitloc(Relation rel,
* just in case ...
* just in case ...
*/
*/
if
(
!
state
.
have_split
)
if
(
!
state
.
have_split
)
elog
(
FATAL
,
"_bt_findsplitloc: can't find a feasible split point for %s
"
,
elog
(
ERROR
,
"cannot find a feasible split point for
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
*
newitemonleft
=
state
.
newitemonleft
;
*
newitemonleft
=
state
.
newitemonleft
;
...
@@ -1193,7 +1198,7 @@ _bt_insert_parent(Relation rel,
...
@@ -1193,7 +1198,7 @@ _bt_insert_parent(Relation rel,
BTPageOpaque
lpageop
;
BTPageOpaque
lpageop
;
if
(
!
InRecovery
)
if
(
!
InRecovery
)
elog
(
DEBUG2
,
"
_bt_insert_parent:
concurrent ROOT page split"
);
elog
(
DEBUG2
,
"concurrent ROOT page split"
);
lpageop
=
(
BTPageOpaque
)
PageGetSpecialPointer
(
page
);
lpageop
=
(
BTPageOpaque
)
PageGetSpecialPointer
(
page
);
/* Find the leftmost page at the next level up */
/* Find the leftmost page at the next level up */
pbuf
=
_bt_get_endpoint
(
rel
,
lpageop
->
btpo
.
level
+
1
,
false
);
pbuf
=
_bt_get_endpoint
(
rel
,
lpageop
->
btpo
.
level
+
1
,
false
);
...
@@ -1232,8 +1237,8 @@ _bt_insert_parent(Relation rel,
...
@@ -1232,8 +1237,8 @@ _bt_insert_parent(Relation rel,
/* Check for error only after writing children */
/* Check for error only after writing children */
if
(
pbuf
==
InvalidBuffer
)
if
(
pbuf
==
InvalidBuffer
)
elog
(
ERROR
,
"
_bt_getstackbuf: my bits moved right off the end of the world!"
elog
(
ERROR
,
"
failed to re-find parent key in
\"
%s
\"
"
,
"
\n\t
Recreate index %s."
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
/* Recursively update the parent */
/* Recursively update the parent */
newres
=
_bt_insertonpg
(
rel
,
pbuf
,
stack
->
bts_parent
,
newres
=
_bt_insertonpg
(
rel
,
pbuf
,
stack
->
bts_parent
,
...
@@ -1399,7 +1404,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
...
@@ -1399,7 +1404,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
metapg
=
BufferGetPage
(
metabuf
);
metapg
=
BufferGetPage
(
metabuf
);
metad
=
BTPageGetMeta
(
metapg
);
metad
=
BTPageGetMeta
(
metapg
);
/* NO E
LOG
(ERROR) from here till newroot op is logged */
/* NO E
REPORT
(ERROR) from here till newroot op is logged */
START_CRIT_SECTION
();
START_CRIT_SECTION
();
/* set btree special data */
/* set btree special data */
...
@@ -1431,7 +1436,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
...
@@ -1431,7 +1436,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
* the two items will go into positions P_HIKEY and P_FIRSTKEY.
* the two items will go into positions P_HIKEY and P_FIRSTKEY.
*/
*/
if
(
PageAddItem
(
rootpage
,
(
Item
)
new_item
,
itemsz
,
P_HIKEY
,
LP_USED
)
==
InvalidOffsetNumber
)
if
(
PageAddItem
(
rootpage
,
(
Item
)
new_item
,
itemsz
,
P_HIKEY
,
LP_USED
)
==
InvalidOffsetNumber
)
elog
(
PANIC
,
"
btree:
failed to add leftkey to new root page"
);
elog
(
PANIC
,
"failed to add leftkey to new root page"
);
pfree
(
new_item
);
pfree
(
new_item
);
/*
/*
...
@@ -1448,7 +1453,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
...
@@ -1448,7 +1453,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
* insert the right page pointer into the new root page.
* insert the right page pointer into the new root page.
*/
*/
if
(
PageAddItem
(
rootpage
,
(
Item
)
new_item
,
itemsz
,
P_FIRSTKEY
,
LP_USED
)
==
InvalidOffsetNumber
)
if
(
PageAddItem
(
rootpage
,
(
Item
)
new_item
,
itemsz
,
P_FIRSTKEY
,
LP_USED
)
==
InvalidOffsetNumber
)
elog
(
PANIC
,
"
btree:
failed to add rightkey to new root page"
);
elog
(
PANIC
,
"failed to add rightkey to new root page"
);
pfree
(
new_item
);
pfree
(
new_item
);
/* XLOG stuff */
/* XLOG stuff */
...
@@ -1533,7 +1538,7 @@ _bt_pgaddtup(Relation rel,
...
@@ -1533,7 +1538,7 @@ _bt_pgaddtup(Relation rel,
if
(
PageAddItem
(
page
,
(
Item
)
btitem
,
itemsize
,
itup_off
,
if
(
PageAddItem
(
page
,
(
Item
)
btitem
,
itemsize
,
itup_off
,
LP_USED
)
==
InvalidOffsetNumber
)
LP_USED
)
==
InvalidOffsetNumber
)
elog
(
PANIC
,
"
btree: failed to add item to the %s for %s
"
,
elog
(
PANIC
,
"
failed to add item to the %s for
\"
%s
\"
"
,
where
,
RelationGetRelationName
(
rel
));
where
,
RelationGetRelationName
(
rel
));
}
}
...
...
src/backend/access/nbtree/nbtpage.c
View file @
ec7aa4b5
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.6
5 2003/05/27 17:49:45 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.6
6 2003/07/21 20:29:39 tgl
Exp $
*
*
* NOTES
* NOTES
* Postgres btree pages look like ordinary relation pages. The opaque
* Postgres btree pages look like ordinary relation pages. The opaque
...
@@ -44,7 +44,7 @@ _bt_metapinit(Relation rel)
...
@@ -44,7 +44,7 @@ _bt_metapinit(Relation rel)
BTPageOpaque
op
;
BTPageOpaque
op
;
if
(
RelationGetNumberOfBlocks
(
rel
)
!=
0
)
if
(
RelationGetNumberOfBlocks
(
rel
)
!=
0
)
elog
(
ERROR
,
"
Cannot initialize non-empty btree %s
"
,
elog
(
ERROR
,
"
cannot initialize non-empty btree index
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
buf
=
ReadBuffer
(
rel
,
P_NEW
);
buf
=
ReadBuffer
(
rel
,
P_NEW
);
...
@@ -145,13 +145,17 @@ _bt_getroot(Relation rel, int access)
...
@@ -145,13 +145,17 @@ _bt_getroot(Relation rel, int access)
/* sanity-check the metapage */
/* sanity-check the metapage */
if
(
!
(
metaopaque
->
btpo_flags
&
BTP_META
)
||
if
(
!
(
metaopaque
->
btpo_flags
&
BTP_META
)
||
metad
->
btm_magic
!=
BTREE_MAGIC
)
metad
->
btm_magic
!=
BTREE_MAGIC
)
elog
(
ERROR
,
"Index %s is not a btree"
,
ereport
(
ERROR
,
RelationGetRelationName
(
rel
));
(
errcode
(
ERRCODE_INDEX_CORRUPTED
),
errmsg
(
"index
\"
%s
\"
is not a btree"
,
RelationGetRelationName
(
rel
))));
if
(
metad
->
btm_version
!=
BTREE_VERSION
)
if
(
metad
->
btm_version
!=
BTREE_VERSION
)
elog
(
ERROR
,
"Version mismatch on %s: version %d file, version %d code"
,
ereport
(
ERROR
,
RelationGetRelationName
(
rel
),
(
errcode
(
ERRCODE_INDEX_CORRUPTED
),
metad
->
btm_version
,
BTREE_VERSION
);
errmsg
(
"version mismatch in
\"
%s
\"
: file version %d, code version %d"
,
RelationGetRelationName
(
rel
),
metad
->
btm_version
,
BTREE_VERSION
)));
/* if no root page initialized yet, do it */
/* if no root page initialized yet, do it */
if
(
metad
->
btm_root
==
P_NONE
)
if
(
metad
->
btm_root
==
P_NONE
)
...
@@ -265,7 +269,7 @@ _bt_getroot(Relation rel, int access)
...
@@ -265,7 +269,7 @@ _bt_getroot(Relation rel, int access)
/* it's dead, Jim. step right one page */
/* it's dead, Jim. step right one page */
if
(
P_RIGHTMOST
(
rootopaque
))
if
(
P_RIGHTMOST
(
rootopaque
))
elog
(
ERROR
,
"
No live root page found in %s
"
,
elog
(
ERROR
,
"
no live root page found in
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
rootblkno
=
rootopaque
->
btpo_next
;
rootblkno
=
rootopaque
->
btpo_next
;
...
@@ -274,7 +278,7 @@ _bt_getroot(Relation rel, int access)
...
@@ -274,7 +278,7 @@ _bt_getroot(Relation rel, int access)
/* Note: can't check btpo.level on deleted pages */
/* Note: can't check btpo.level on deleted pages */
if
(
rootopaque
->
btpo
.
level
!=
rootlevel
)
if
(
rootopaque
->
btpo
.
level
!=
rootlevel
)
elog
(
ERROR
,
"
Root page %u of %s
has level %u, expected %u"
,
elog
(
ERROR
,
"
root page %u of
\"
%s
\"
has level %u, expected %u"
,
rootblkno
,
RelationGetRelationName
(
rel
),
rootblkno
,
RelationGetRelationName
(
rel
),
rootopaque
->
btpo
.
level
,
rootlevel
);
rootopaque
->
btpo
.
level
,
rootlevel
);
}
}
...
@@ -320,13 +324,17 @@ _bt_gettrueroot(Relation rel)
...
@@ -320,13 +324,17 @@ _bt_gettrueroot(Relation rel)
if
(
!
(
metaopaque
->
btpo_flags
&
BTP_META
)
||
if
(
!
(
metaopaque
->
btpo_flags
&
BTP_META
)
||
metad
->
btm_magic
!=
BTREE_MAGIC
)
metad
->
btm_magic
!=
BTREE_MAGIC
)
elog
(
ERROR
,
"Index %s is not a btree"
,
ereport
(
ERROR
,
RelationGetRelationName
(
rel
));
(
errcode
(
ERRCODE_INDEX_CORRUPTED
),
errmsg
(
"index
\"
%s
\"
is not a btree"
,
RelationGetRelationName
(
rel
))));
if
(
metad
->
btm_version
!=
BTREE_VERSION
)
if
(
metad
->
btm_version
!=
BTREE_VERSION
)
elog
(
ERROR
,
"Version mismatch on %s: version %d file, version %d code"
,
ereport
(
ERROR
,
RelationGetRelationName
(
rel
),
(
errcode
(
ERRCODE_INDEX_CORRUPTED
),
metad
->
btm_version
,
BTREE_VERSION
);
errmsg
(
"version mismatch in
\"
%s
\"
: file version %d, code version %d"
,
RelationGetRelationName
(
rel
),
metad
->
btm_version
,
BTREE_VERSION
)));
/* if no root page initialized yet, fail */
/* if no root page initialized yet, fail */
if
(
metad
->
btm_root
==
P_NONE
)
if
(
metad
->
btm_root
==
P_NONE
)
...
@@ -351,7 +359,7 @@ _bt_gettrueroot(Relation rel)
...
@@ -351,7 +359,7 @@ _bt_gettrueroot(Relation rel)
/* it's dead, Jim. step right one page */
/* it's dead, Jim. step right one page */
if
(
P_RIGHTMOST
(
rootopaque
))
if
(
P_RIGHTMOST
(
rootopaque
))
elog
(
ERROR
,
"
No live root page found in %s
"
,
elog
(
ERROR
,
"
no live root page found in
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
rootblkno
=
rootopaque
->
btpo_next
;
rootblkno
=
rootopaque
->
btpo_next
;
...
@@ -360,7 +368,7 @@ _bt_gettrueroot(Relation rel)
...
@@ -360,7 +368,7 @@ _bt_gettrueroot(Relation rel)
/* Note: can't check btpo.level on deleted pages */
/* Note: can't check btpo.level on deleted pages */
if
(
rootopaque
->
btpo
.
level
!=
rootlevel
)
if
(
rootopaque
->
btpo
.
level
!=
rootlevel
)
elog
(
ERROR
,
"
Root page %u of %s
has level %u, expected %u"
,
elog
(
ERROR
,
"
root page %u of
\"
%s
\"
has level %u, expected %u"
,
rootblkno
,
RelationGetRelationName
(
rel
),
rootblkno
,
RelationGetRelationName
(
rel
),
rootopaque
->
btpo
.
level
,
rootlevel
);
rootopaque
->
btpo
.
level
,
rootlevel
);
...
@@ -416,7 +424,7 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access)
...
@@ -416,7 +424,7 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access)
_bt_pageinit
(
page
,
BufferGetPageSize
(
buf
));
_bt_pageinit
(
page
,
BufferGetPageSize
(
buf
));
return
buf
;
return
buf
;
}
}
elog
(
DEBUG2
,
"
_bt_getbuf:
FSM returned nonrecyclable page"
);
elog
(
DEBUG2
,
"FSM returned nonrecyclable page"
);
_bt_relbuf
(
rel
,
buf
);
_bt_relbuf
(
rel
,
buf
);
}
}
...
@@ -630,7 +638,7 @@ _bt_delitems(Relation rel, Buffer buf,
...
@@ -630,7 +638,7 @@ _bt_delitems(Relation rel, Buffer buf,
Page
page
=
BufferGetPage
(
buf
);
Page
page
=
BufferGetPage
(
buf
);
int
i
;
int
i
;
/* No e
log
(ERROR) until changes are logged */
/* No e
report
(ERROR) until changes are logged */
START_CRIT_SECTION
();
START_CRIT_SECTION
();
/*
/*
...
@@ -775,7 +783,7 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
...
@@ -775,7 +783,7 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
for
(;;)
for
(;;)
{
{
if
(
stack
==
NULL
)
if
(
stack
==
NULL
)
elog
(
ERROR
,
"
_bt_pagedel:
not enough stack items"
);
elog
(
ERROR
,
"not enough stack items"
);
if
(
ilevel
==
targetlevel
)
if
(
ilevel
==
targetlevel
)
break
;
break
;
stack
=
stack
->
bts_parent
;
stack
=
stack
->
bts_parent
;
...
@@ -805,7 +813,7 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
...
@@ -805,7 +813,7 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
_bt_relbuf
(
rel
,
lbuf
);
_bt_relbuf
(
rel
,
lbuf
);
if
(
leftsib
==
P_NONE
)
if
(
leftsib
==
P_NONE
)
{
{
elog
(
LOG
,
"
_bt_pagedel:
no left sibling (concurrent deletion?)"
);
elog
(
LOG
,
"no left sibling (concurrent deletion?)"
);
return
0
;
return
0
;
}
}
lbuf
=
_bt_getbuf
(
rel
,
leftsib
,
BT_WRITE
);
lbuf
=
_bt_getbuf
(
rel
,
leftsib
,
BT_WRITE
);
...
@@ -837,7 +845,7 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
...
@@ -837,7 +845,7 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
return
0
;
return
0
;
}
}
if
(
opaque
->
btpo_prev
!=
leftsib
)
if
(
opaque
->
btpo_prev
!=
leftsib
)
elog
(
ERROR
,
"
_bt_pagedel:
left link changed unexpectedly"
);
elog
(
ERROR
,
"left link changed unexpectedly"
);
/*
/*
* And next write-lock the (current) right sibling.
* And next write-lock the (current) right sibling.
*/
*/
...
@@ -851,8 +859,8 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
...
@@ -851,8 +859,8 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
target
,
P_HIKEY
);
target
,
P_HIKEY
);
pbuf
=
_bt_getstackbuf
(
rel
,
stack
,
BT_WRITE
);
pbuf
=
_bt_getstackbuf
(
rel
,
stack
,
BT_WRITE
);
if
(
pbuf
==
InvalidBuffer
)
if
(
pbuf
==
InvalidBuffer
)
elog
(
ERROR
,
"
_bt_getstackbuf: my bits moved right off the end of the world!"
elog
(
ERROR
,
"
failed to re-find parent key in
\"
%s
\"
"
,
"
\n\t
Recreate index %s."
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
parent
=
stack
->
bts_blkno
;
parent
=
stack
->
bts_blkno
;
poffset
=
stack
->
bts_offset
;
poffset
=
stack
->
bts_offset
;
/*
/*
...
@@ -924,7 +932,7 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
...
@@ -924,7 +932,7 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
* Here we begin doing the deletion.
* Here we begin doing the deletion.
*/
*/
/* No e
log
(ERROR) until changes are logged */
/* No e
report
(ERROR) until changes are logged */
START_CRIT_SECTION
();
START_CRIT_SECTION
();
/*
/*
...
@@ -954,7 +962,7 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
...
@@ -954,7 +962,7 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full)
itemid
=
PageGetItemId
(
page
,
nextoffset
);
itemid
=
PageGetItemId
(
page
,
nextoffset
);
btitem
=
(
BTItem
)
PageGetItem
(
page
,
itemid
);
btitem
=
(
BTItem
)
PageGetItem
(
page
,
itemid
);
if
(
ItemPointerGetBlockNumber
(
&
(
btitem
->
bti_itup
.
t_tid
))
!=
rightsib
)
if
(
ItemPointerGetBlockNumber
(
&
(
btitem
->
bti_itup
.
t_tid
))
!=
rightsib
)
elog
(
PANIC
,
"
_bt_pagedel:
right sibling is not next child"
);
elog
(
PANIC
,
"right sibling is not next child"
);
PageIndexTupleDelete
(
page
,
nextoffset
);
PageIndexTupleDelete
(
page
,
nextoffset
);
}
}
...
...
src/backend/access/nbtree/nbtree.c
View file @
ec7aa4b5
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.10
2 2003/03/23 23:01:03
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.10
3 2003/07/21 20:29:39
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -108,7 +108,7 @@ btbuild(PG_FUNCTION_ARGS)
...
@@ -108,7 +108,7 @@ btbuild(PG_FUNCTION_ARGS)
* that's not the case, big trouble's what we have.
* that's not the case, big trouble's what we have.
*/
*/
if
(
RelationGetNumberOfBlocks
(
index
)
!=
0
)
if
(
RelationGetNumberOfBlocks
(
index
)
!=
0
)
elog
(
ERROR
,
"
%s
already contains data"
,
elog
(
ERROR
,
"
index
\"
%s
\"
already contains data"
,
RelationGetRelationName
(
index
));
RelationGetRelationName
(
index
));
/* initialize the btree index metadata page */
/* initialize the btree index metadata page */
...
@@ -816,8 +816,7 @@ btvacuumcleanup(PG_FUNCTION_ARGS)
...
@@ -816,8 +816,7 @@ btvacuumcleanup(PG_FUNCTION_ARGS)
*/
*/
i
=
FlushRelationBuffers
(
rel
,
new_pages
);
i
=
FlushRelationBuffers
(
rel
,
new_pages
);
if
(
i
<
0
)
if
(
i
<
0
)
elog
(
ERROR
,
"btvacuumcleanup: FlushRelationBuffers returned %d"
,
elog
(
ERROR
,
"FlushRelationBuffers returned %d"
,
i
);
i
);
/*
/*
* Do the physical truncation.
* Do the physical truncation.
...
@@ -929,8 +928,8 @@ _bt_restscan(IndexScanDesc scan)
...
@@ -929,8 +928,8 @@ _bt_restscan(IndexScanDesc scan)
* we can find it again.
* we can find it again.
*/
*/
if
(
P_RIGHTMOST
(
opaque
))
if
(
P_RIGHTMOST
(
opaque
))
elog
(
ERROR
,
"
_bt_restscan: my bits moved right off the end of the world!"
elog
(
ERROR
,
"
failed to re-find previous key in
\"
%s
\"
"
,
"
\n\t
Recreate index %s."
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
/* Advance to next non-dead page --- there must be one */
/* Advance to next non-dead page --- there must be one */
nextbuf
=
InvalidBuffer
;
nextbuf
=
InvalidBuffer
;
for
(;;)
for
(;;)
...
@@ -944,7 +943,7 @@ _bt_restscan(IndexScanDesc scan)
...
@@ -944,7 +943,7 @@ _bt_restscan(IndexScanDesc scan)
if
(
!
P_IGNORE
(
opaque
))
if
(
!
P_IGNORE
(
opaque
))
break
;
break
;
if
(
P_RIGHTMOST
(
opaque
))
if
(
P_RIGHTMOST
(
opaque
))
elog
(
ERROR
,
"
_bt_restscan: fell off the end of %s
"
,
elog
(
ERROR
,
"
fell off the end of
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
}
}
_bt_relbuf
(
rel
,
buf
);
_bt_relbuf
(
rel
,
buf
);
...
...
src/backend/access/nbtree/nbtsearch.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.7
4 2003/02/22 00:45:04
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.7
5 2003/07/21 20:29:39
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -168,7 +168,7 @@ _bt_moveright(Relation rel,
...
@@ -168,7 +168,7 @@ _bt_moveright(Relation rel,
}
}
if
(
P_IGNORE
(
opaque
))
if
(
P_IGNORE
(
opaque
))
elog
(
ERROR
,
"
_bt_moveright: fell off the end of %s
"
,
elog
(
ERROR
,
"
fell off the end of
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
return
buf
;
return
buf
;
...
@@ -552,7 +552,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
...
@@ -552,7 +552,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
{
{
pfree
(
nKeyIs
);
pfree
(
nKeyIs
);
pfree
(
scankeys
);
pfree
(
scankeys
);
elog
(
ERROR
,
"
_bt_first:
btree doesn't support is(not)null, yet"
);
elog
(
ERROR
,
"btree doesn't support is(not)null, yet"
);
return
false
;
return
false
;
}
}
procinfo
=
index_getprocinfo
(
rel
,
i
+
1
,
BTORDER_PROC
);
procinfo
=
index_getprocinfo
(
rel
,
i
+
1
,
BTORDER_PROC
);
...
@@ -700,7 +700,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
...
@@ -700,7 +700,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
result
=
_bt_compare
(
rel
,
keysCount
,
scankeys
,
page
,
offnum
);
result
=
_bt_compare
(
rel
,
keysCount
,
scankeys
,
page
,
offnum
);
}
while
(
result
==
0
);
}
while
(
result
==
0
);
if
(
!
_bt_step
(
scan
,
&
buf
,
BackwardScanDirection
))
if
(
!
_bt_step
(
scan
,
&
buf
,
BackwardScanDirection
))
elog
(
ERROR
,
"
_bt_first:
equal items disappeared?"
);
elog
(
ERROR
,
"equal items disappeared?"
);
}
}
break
;
break
;
...
@@ -991,7 +991,7 @@ _bt_walk_left(Relation rel, Buffer buf)
...
@@ -991,7 +991,7 @@ _bt_walk_left(Relation rel, Buffer buf)
for
(;;)
for
(;;)
{
{
if
(
P_RIGHTMOST
(
opaque
))
if
(
P_RIGHTMOST
(
opaque
))
elog
(
ERROR
,
"
_bt_walk_left: fell off the end of %s
"
,
elog
(
ERROR
,
"
fell off the end of
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
blkno
=
opaque
->
btpo_next
;
blkno
=
opaque
->
btpo_next
;
_bt_relbuf
(
rel
,
buf
);
_bt_relbuf
(
rel
,
buf
);
...
@@ -1015,7 +1015,7 @@ _bt_walk_left(Relation rel, Buffer buf)
...
@@ -1015,7 +1015,7 @@ _bt_walk_left(Relation rel, Buffer buf)
* if there's anything wrong.
* if there's anything wrong.
*/
*/
if
(
opaque
->
btpo_prev
==
lblkno
)
if
(
opaque
->
btpo_prev
==
lblkno
)
elog
(
ERROR
,
"
_bt_walk_left: can't find left sibling in %s
"
,
elog
(
ERROR
,
"
cannot find left sibling in
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
/* Okay to try again with new lblkno value */
/* Okay to try again with new lblkno value */
}
}
...
@@ -1028,7 +1028,7 @@ _bt_walk_left(Relation rel, Buffer buf)
...
@@ -1028,7 +1028,7 @@ _bt_walk_left(Relation rel, Buffer buf)
* _bt_get_endpoint() -- Find the first or last page on a given tree level
* _bt_get_endpoint() -- Find the first or last page on a given tree level
*
*
* If the index is empty, we will return InvalidBuffer; any other failure
* If the index is empty, we will return InvalidBuffer; any other failure
* condition causes e
log
(). We will not return a dead page.
* condition causes e
report
(). We will not return a dead page.
*
*
* The returned buffer is pinned and read-locked.
* The returned buffer is pinned and read-locked.
*/
*/
...
@@ -1075,7 +1075,7 @@ _bt_get_endpoint(Relation rel, uint32 level, bool rightmost)
...
@@ -1075,7 +1075,7 @@ _bt_get_endpoint(Relation rel, uint32 level, bool rightmost)
{
{
blkno
=
opaque
->
btpo_next
;
blkno
=
opaque
->
btpo_next
;
if
(
blkno
==
P_NONE
)
if
(
blkno
==
P_NONE
)
elog
(
ERROR
,
"
_bt_get_endpoint: fell off the end of %s
"
,
elog
(
ERROR
,
"
fell off the end of
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
RelationGetRelationName
(
rel
));
_bt_relbuf
(
rel
,
buf
);
_bt_relbuf
(
rel
,
buf
);
buf
=
_bt_getbuf
(
rel
,
blkno
,
BT_READ
);
buf
=
_bt_getbuf
(
rel
,
blkno
,
BT_READ
);
...
@@ -1087,7 +1087,7 @@ _bt_get_endpoint(Relation rel, uint32 level, bool rightmost)
...
@@ -1087,7 +1087,7 @@ _bt_get_endpoint(Relation rel, uint32 level, bool rightmost)
if
(
opaque
->
btpo
.
level
==
level
)
if
(
opaque
->
btpo
.
level
==
level
)
break
;
break
;
if
(
opaque
->
btpo
.
level
<
level
)
if
(
opaque
->
btpo
.
level
<
level
)
elog
(
ERROR
,
"
_bt_get_endpoint:
btree level %u not found"
,
level
);
elog
(
ERROR
,
"btree level %u not found"
,
level
);
/* Descend to leftmost or rightmost child page */
/* Descend to leftmost or rightmost child page */
if
(
rightmost
)
if
(
rightmost
)
...
@@ -1176,7 +1176,7 @@ _bt_endpoint(IndexScanDesc scan, ScanDirection dir)
...
@@ -1176,7 +1176,7 @@ _bt_endpoint(IndexScanDesc scan, ScanDirection dir)
}
}
else
else
{
{
elog
(
ERROR
,
"
Illegal scan direction %d"
,
dir
);
elog
(
ERROR
,
"
invalid scan direction: %d"
,
(
int
)
dir
);
start
=
0
;
/* keep compiler quiet */
start
=
0
;
/* keep compiler quiet */
}
}
...
...
src/backend/access/nbtree/nbtsort.c
View file @
ec7aa4b5
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.7
2 2003/02/22 00:45:04
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.7
3 2003/07/21 20:29:39
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -332,7 +332,7 @@ _bt_sortaddtup(Page page,
...
@@ -332,7 +332,7 @@ _bt_sortaddtup(Page page,
if
(
PageAddItem
(
page
,
(
Item
)
btitem
,
itemsize
,
itup_off
,
if
(
PageAddItem
(
page
,
(
Item
)
btitem
,
itemsize
,
itup_off
,
LP_USED
)
==
InvalidOffsetNumber
)
LP_USED
)
==
InvalidOffsetNumber
)
elog
(
ERROR
,
"
btree: failed to add item to the page in _bt_sort
"
);
elog
(
ERROR
,
"
failed to add item to the index page
"
);
}
}
/*----------
/*----------
...
@@ -397,8 +397,11 @@ _bt_buildadd(Relation index, BTPageState *state, BTItem bti)
...
@@ -397,8 +397,11 @@ _bt_buildadd(Relation index, BTPageState *state, BTItem bti)
* during creation of an index, we don't go through there.
* during creation of an index, we don't go through there.
*/
*/
if
(
btisz
>
BTMaxItemSize
(
npage
))
if
(
btisz
>
BTMaxItemSize
(
npage
))
elog
(
ERROR
,
"btree: index item size %lu exceeds maximum %ld"
,
ereport
(
ERROR
,
(
unsigned
long
)
btisz
,
BTMaxItemSize
(
npage
));
(
errcode
(
ERRCODE_PROGRAM_LIMIT_EXCEEDED
),
errmsg
(
"index tuple size %lu exceeds btree maximum, %lu"
,
(
unsigned
long
)
btisz
,
(
unsigned
long
)
BTMaxItemSize
(
npage
))));
if
(
pgspc
<
btisz
||
pgspc
<
state
->
btps_full
)
if
(
pgspc
<
btisz
||
pgspc
<
state
->
btps_full
)
{
{
...
...
src/backend/access/nbtree/nbtutils.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.5
1 2002/09/04 20:31:12 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.5
2 2003/07/21 20:29:39 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -227,7 +227,7 @@ _bt_orderkeys(IndexScanDesc scan)
...
@@ -227,7 +227,7 @@ _bt_orderkeys(IndexScanDesc scan)
cur
=
&
key
[
0
];
cur
=
&
key
[
0
];
/* check input keys are correctly ordered */
/* check input keys are correctly ordered */
if
(
cur
->
sk_attno
!=
1
)
if
(
cur
->
sk_attno
!=
1
)
elog
(
ERROR
,
"
_bt_orderkeys:
key(s) for attribute 1 missed"
);
elog
(
ERROR
,
"key(s) for attribute 1 missed"
);
/* We can short-circuit most of the work if there's just one key */
/* We can short-circuit most of the work if there's just one key */
if
(
numberOfKeys
==
1
)
if
(
numberOfKeys
==
1
)
...
@@ -305,8 +305,7 @@ _bt_orderkeys(IndexScanDesc scan)
...
@@ -305,8 +305,7 @@ _bt_orderkeys(IndexScanDesc scan)
/* check input keys are correctly ordered */
/* check input keys are correctly ordered */
if
(
i
<
numberOfKeys
&&
cur
->
sk_attno
!=
attno
+
1
)
if
(
i
<
numberOfKeys
&&
cur
->
sk_attno
!=
attno
+
1
)
elog
(
ERROR
,
"_bt_orderkeys: key(s) for attribute %d missed"
,
elog
(
ERROR
,
"key(s) for attribute %d missed"
,
attno
+
1
);
attno
+
1
);
/*
/*
* If = has been specified, no other key will be used. In case
* If = has been specified, no other key will be used. In case
...
@@ -462,8 +461,7 @@ _bt_getstrategynumber(RegProcedure sk_procedure, StrategyMap map)
...
@@ -462,8 +461,7 @@ _bt_getstrategynumber(RegProcedure sk_procedure, StrategyMap map)
if
(
sk_procedure
==
map
->
entry
[
j
].
sk_procedure
)
if
(
sk_procedure
==
map
->
entry
[
j
].
sk_procedure
)
return
j
;
return
j
;
}
}
elog
(
ERROR
,
"_bt_getstrategynumber: unable to identify operator %u"
,
elog
(
ERROR
,
"unable to identify operator %u"
,
sk_procedure
);
sk_procedure
);
return
-
1
;
/* keep compiler quiet */
return
-
1
;
/* keep compiler quiet */
}
}
...
...
src/backend/access/rtree/rtree.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.7
7 2003/02/24 00:57:17
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.7
8 2003/07/21 20:29:39
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -125,7 +125,7 @@ rtbuild(PG_FUNCTION_ARGS)
...
@@ -125,7 +125,7 @@ rtbuild(PG_FUNCTION_ARGS)
* that's not the case, big trouble's what we have.
* that's not the case, big trouble's what we have.
*/
*/
if
(
RelationGetNumberOfBlocks
(
index
)
!=
0
)
if
(
RelationGetNumberOfBlocks
(
index
)
!=
0
)
elog
(
ERROR
,
"
%s
already contains data"
,
elog
(
ERROR
,
"
index
\"
%s
\"
already contains data"
,
RelationGetRelationName
(
index
));
RelationGetRelationName
(
index
));
/* initialize the root page */
/* initialize the root page */
...
@@ -328,7 +328,7 @@ rtdoinsert(Relation r, IndexTuple itup, RTSTATE *rtstate)
...
@@ -328,7 +328,7 @@ rtdoinsert(Relation r, IndexTuple itup, RTSTATE *rtstate)
LP_USED
);
LP_USED
);
}
}
if
(
l
==
InvalidOffsetNumber
)
if
(
l
==
InvalidOffsetNumber
)
elog
(
ERROR
,
"
rtdoinsert: failed to add index item to %s
"
,
elog
(
ERROR
,
"
failed to add index item to
\"
%s
\"
"
,
RelationGetRelationName
(
r
));
RelationGetRelationName
(
r
));
WriteBuffer
(
buffer
);
WriteBuffer
(
buffer
);
...
@@ -520,7 +520,7 @@ rtdosplit(Relation r,
...
@@ -520,7 +520,7 @@ rtdosplit(Relation r,
if
(
PageAddItem
(
left
,
(
Item
)
item
,
IndexTupleSize
(
item
),
if
(
PageAddItem
(
left
,
(
Item
)
item
,
IndexTupleSize
(
item
),
leftoff
,
LP_USED
)
==
InvalidOffsetNumber
)
leftoff
,
LP_USED
)
==
InvalidOffsetNumber
)
elog
(
ERROR
,
"
rtdosplit: failed to add index item to %s
"
,
elog
(
ERROR
,
"
failed to add index item to
\"
%s
\"
"
,
RelationGetRelationName
(
r
));
RelationGetRelationName
(
r
));
leftoff
=
OffsetNumberNext
(
leftoff
);
leftoff
=
OffsetNumberNext
(
leftoff
);
...
@@ -544,7 +544,7 @@ rtdosplit(Relation r,
...
@@ -544,7 +544,7 @@ rtdosplit(Relation r,
if
(
PageAddItem
(
right
,
(
Item
)
item
,
IndexTupleSize
(
item
),
if
(
PageAddItem
(
right
,
(
Item
)
item
,
IndexTupleSize
(
item
),
rightoff
,
LP_USED
)
==
InvalidOffsetNumber
)
rightoff
,
LP_USED
)
==
InvalidOffsetNumber
)
elog
(
ERROR
,
"
rtdosplit: failed to add index item to %s
"
,
elog
(
ERROR
,
"
failed to add index item to
\"
%s
\"
"
,
RelationGetRelationName
(
r
));
RelationGetRelationName
(
r
));
rightoff
=
OffsetNumberNext
(
rightoff
);
rightoff
=
OffsetNumberNext
(
rightoff
);
...
@@ -640,7 +640,9 @@ rtintinsert(Relation r,
...
@@ -640,7 +640,9 @@ rtintinsert(Relation r,
*/
*/
if
(
IndexTupleSize
(
old
)
!=
IndexTupleSize
(
ltup
))
if
(
IndexTupleSize
(
old
)
!=
IndexTupleSize
(
ltup
))
elog
(
ERROR
,
"Variable-length rtree keys are not supported."
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"variable-length rtree keys are not supported"
)));
/* install pointer to left child */
/* install pointer to left child */
memmove
(
old
,
ltup
,
IndexTupleSize
(
ltup
));
memmove
(
old
,
ltup
,
IndexTupleSize
(
ltup
));
...
@@ -660,7 +662,7 @@ rtintinsert(Relation r,
...
@@ -660,7 +662,7 @@ rtintinsert(Relation r,
if
(
PageAddItem
(
p
,
(
Item
)
rtup
,
IndexTupleSize
(
rtup
),
if
(
PageAddItem
(
p
,
(
Item
)
rtup
,
IndexTupleSize
(
rtup
),
PageGetMaxOffsetNumber
(
p
),
PageGetMaxOffsetNumber
(
p
),
LP_USED
)
==
InvalidOffsetNumber
)
LP_USED
)
==
InvalidOffsetNumber
)
elog
(
ERROR
,
"
rtintinsert: failed to add index item to %s
"
,
elog
(
ERROR
,
"
failed to add index item to
\"
%s
\"
"
,
RelationGetRelationName
(
r
));
RelationGetRelationName
(
r
));
WriteBuffer
(
b
);
WriteBuffer
(
b
);
ldatum
=
IndexTupleGetDatum
(
ltup
);
ldatum
=
IndexTupleGetDatum
(
ltup
);
...
@@ -686,12 +688,12 @@ rtnewroot(Relation r, IndexTuple lt, IndexTuple rt)
...
@@ -686,12 +688,12 @@ rtnewroot(Relation r, IndexTuple lt, IndexTuple rt)
if
(
PageAddItem
(
p
,
(
Item
)
lt
,
IndexTupleSize
(
lt
),
if
(
PageAddItem
(
p
,
(
Item
)
lt
,
IndexTupleSize
(
lt
),
FirstOffsetNumber
,
FirstOffsetNumber
,
LP_USED
)
==
InvalidOffsetNumber
)
LP_USED
)
==
InvalidOffsetNumber
)
elog
(
ERROR
,
"
rtnewroot: failed to add index item to %s
"
,
elog
(
ERROR
,
"
failed to add index item to
\"
%s
\"
"
,
RelationGetRelationName
(
r
));
RelationGetRelationName
(
r
));
if
(
PageAddItem
(
p
,
(
Item
)
rt
,
IndexTupleSize
(
rt
),
if
(
PageAddItem
(
p
,
(
Item
)
rt
,
IndexTupleSize
(
rt
),
OffsetNumberNext
(
FirstOffsetNumber
),
OffsetNumberNext
(
FirstOffsetNumber
),
LP_USED
)
==
InvalidOffsetNumber
)
LP_USED
)
==
InvalidOffsetNumber
)
elog
(
ERROR
,
"
rtnewroot: failed to add index item to %s
"
,
elog
(
ERROR
,
"
failed to add index item to
\"
%s
\"
"
,
RelationGetRelationName
(
r
));
RelationGetRelationName
(
r
));
WriteBuffer
(
b
);
WriteBuffer
(
b
);
}
}
...
@@ -778,8 +780,11 @@ rtpicksplit(Relation r,
...
@@ -778,8 +780,11 @@ rtpicksplit(Relation r,
*/
*/
newitemsz
=
IndexTupleTotalSize
(
itup
);
newitemsz
=
IndexTupleTotalSize
(
itup
);
if
(
newitemsz
>
RTPageAvailSpace
)
if
(
newitemsz
>
RTPageAvailSpace
)
elog
(
ERROR
,
"rtree: index item size %lu exceeds maximum %lu"
,
ereport
(
ERROR
,
(
unsigned
long
)
newitemsz
,
(
unsigned
long
)
RTPageAvailSpace
);
(
errcode
(
ERRCODE_PROGRAM_LIMIT_EXCEEDED
),
errmsg
(
"index tuple size %lu exceeds rtree maximum, %lu"
,
(
unsigned
long
)
newitemsz
,
(
unsigned
long
)
RTPageAvailSpace
)));
maxoff
=
PageGetMaxOffsetNumber
(
page
);
maxoff
=
PageGetMaxOffsetNumber
(
page
);
newitemoff
=
OffsetNumberNext
(
maxoff
);
/* phony index for new
newitemoff
=
OffsetNumberNext
(
maxoff
);
/* phony index for new
...
@@ -1065,7 +1070,7 @@ rtpicksplit(Relation r,
...
@@ -1065,7 +1070,7 @@ rtpicksplit(Relation r,
choose_left
=
false
;
choose_left
=
false
;
else
else
{
{
elog
(
ERROR
,
"
rtpicksplit: failed to find a workabl
e page split"
);
elog
(
ERROR
,
"
failed to find a workable rtre
e page split"
);
choose_left
=
false
;
/* keep compiler quiet */
choose_left
=
false
;
/* keep compiler quiet */
}
}
...
...
src/backend/access/rtree/rtscan.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.4
3 2003/03/23 23:01:03
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.4
4 2003/07/21 20:29:39
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -384,7 +384,7 @@ adjustiptr(IndexScanDesc s,
...
@@ -384,7 +384,7 @@ adjustiptr(IndexScanDesc s,
break
;
break
;
default:
default:
elog
(
ERROR
,
"
Ba
d operation in rtree scan adjust: %d"
,
op
);
elog
(
ERROR
,
"
unrecognize
d operation in rtree scan adjust: %d"
,
op
);
}
}
}
}
}
}
...
...
src/backend/access/transam/xact.c
View file @
ec7aa4b5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.14
8 2003/05/14 03:26:00
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.14
9 2003/07/21 20:29:39
tgl Exp $
*
*
* NOTES
* NOTES
* Transaction aborts can now occur two ways:
* Transaction aborts can now occur two ways:
...
@@ -400,7 +400,9 @@ CommandCounterIncrement(void)
...
@@ -400,7 +400,9 @@ CommandCounterIncrement(void)
s
->
commandId
+=
1
;
s
->
commandId
+=
1
;
if
(
s
->
commandId
==
FirstCommandId
)
/* check for overflow */
if
(
s
->
commandId
==
FirstCommandId
)
/* check for overflow */
elog
(
ERROR
,
"You may only have 2^32-1 commands per transaction"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_PROGRAM_LIMIT_EXCEEDED
),
errmsg
(
"cannot have more than 2^32-1 commands in a transaction"
)));
/* Propagate new command ID into query snapshots, if set */
/* Propagate new command ID into query snapshots, if set */
if
(
QuerySnapshot
)
if
(
QuerySnapshot
)
...
@@ -672,8 +674,7 @@ RecordTransactionAbort(void)
...
@@ -672,8 +674,7 @@ RecordTransactionAbort(void)
* RecordTransactionCommit ...
* RecordTransactionCommit ...
*/
*/
if
(
TransactionIdDidCommit
(
xid
))
if
(
TransactionIdDidCommit
(
xid
))
elog
(
PANIC
,
"RecordTransactionAbort: xact %u already committed"
,
elog
(
PANIC
,
"cannot abort transaction %u, it was already committed"
,
xid
);
xid
);
START_CRIT_SECTION
();
START_CRIT_SECTION
();
...
@@ -1367,23 +1368,24 @@ PreventTransactionChain(void *stmtNode, const char *stmtType)
...
@@ -1367,23 +1368,24 @@ PreventTransactionChain(void *stmtNode, const char *stmtType)
* xact block already started?
* xact block already started?
*/
*/
if
(
IsTransactionBlock
())
if
(
IsTransactionBlock
())
{
ereport
(
ERROR
,
/* translator: %s represents an SQL statement name */
(
errcode
(
ERRCODE_ACTIVE_SQL_TRANSACTION
),
elog
(
ERROR
,
"%s cannot run inside a transaction block"
,
stmtType
);
/* translator: %s represents an SQL statement name */
}
errmsg
(
"%s cannot run inside a transaction block"
,
stmtType
)));
/*
/*
* Are we inside a function call? If the statement's parameter block
* Are we inside a function call? If the statement's parameter block
* was allocated in QueryContext, assume it is an interactive command.
* was allocated in QueryContext, assume it is an interactive command.
* Otherwise assume it is coming from a function.
* Otherwise assume it is coming from a function.
*/
*/
if
(
!
MemoryContextContains
(
QueryContext
,
stmtNode
))
if
(
!
MemoryContextContains
(
QueryContext
,
stmtNode
))
{
ereport
(
ERROR
,
/* translator: %s represents an SQL statement name */
(
errcode
(
ERRCODE_ACTIVE_SQL_TRANSACTION
),
elog
(
ERROR
,
"%s cannot be executed from a function"
,
stmtType
);
/* translator: %s represents an SQL statement name */
}
errmsg
(
"%s cannot be executed from a function"
,
stmtType
)));
/* If we got past IsTransactionBlock test, should be in default state */
/* If we got past IsTransactionBlock test, should be in default state */
if
(
CurrentTransactionState
->
blockState
!=
TBLOCK_DEFAULT
)
if
(
CurrentTransactionState
->
blockState
!=
TBLOCK_DEFAULT
)
elog
(
ERROR
,
"
PreventTransactionChain: can't prevent
chain"
);
elog
(
ERROR
,
"
cannot prevent transaction
chain"
);
/* all okay */
/* all okay */
}
}
...
@@ -1419,9 +1421,11 @@ RequireTransactionChain(void *stmtNode, const char *stmtType)
...
@@ -1419,9 +1421,11 @@ RequireTransactionChain(void *stmtNode, const char *stmtType)
*/
*/
if
(
!
MemoryContextContains
(
QueryContext
,
stmtNode
))
if
(
!
MemoryContextContains
(
QueryContext
,
stmtNode
))
return
;
return
;
/* translator: %s represents an SQL statement name */
ereport
(
ERROR
,
elog
(
ERROR
,
"%s may only be used in begin/end transaction blocks"
,
(
errcode
(
ERRCODE_NO_ACTIVE_SQL_TRANSACTION
),
stmtType
);
/* translator: %s represents an SQL statement name */
errmsg
(
"%s may only be used in BEGIN/END transaction blocks"
,
stmtType
)));
}
}
...
@@ -1441,7 +1445,9 @@ BeginTransactionBlock(void)
...
@@ -1441,7 +1445,9 @@ BeginTransactionBlock(void)
* check the current transaction state
* check the current transaction state
*/
*/
if
(
s
->
blockState
!=
TBLOCK_DEFAULT
)
if
(
s
->
blockState
!=
TBLOCK_DEFAULT
)
elog
(
WARNING
,
"BEGIN: already a transaction in progress"
);
ereport
(
WARNING
,
(
errcode
(
ERRCODE_ACTIVE_SQL_TRANSACTION
),
errmsg
(
"there is already a transaction in progress"
)));
/*
/*
* set the current transaction block state information appropriately
* set the current transaction block state information appropriately
...
@@ -1501,7 +1507,9 @@ EndTransactionBlock(void)
...
@@ -1501,7 +1507,9 @@ EndTransactionBlock(void)
* CommitTransactionCommand() will then put us back into the default
* CommitTransactionCommand() will then put us back into the default
* state.
* state.
*/
*/
elog
(
WARNING
,
"COMMIT: no transaction in progress"
);
ereport
(
WARNING
,
(
errcode
(
ERRCODE_NO_ACTIVE_SQL_TRANSACTION
),
errmsg
(
"there is no transaction in progress"
)));
AbortTransaction
();
AbortTransaction
();
s
->
blockState
=
TBLOCK_ENDABORT
;
s
->
blockState
=
TBLOCK_ENDABORT
;
}
}
...
@@ -1537,7 +1545,9 @@ AbortTransactionBlock(void)
...
@@ -1537,7 +1545,9 @@ AbortTransactionBlock(void)
* CommitTransactionCommand() will then put us back into the default
* CommitTransactionCommand() will then put us back into the default
* state.
* state.
*/
*/
elog
(
WARNING
,
"ROLLBACK: no transaction in progress"
);
ereport
(
WARNING
,
(
errcode
(
ERRCODE_NO_ACTIVE_SQL_TRANSACTION
),
errmsg
(
"there is no transaction in progress"
)));
AbortTransaction
();
AbortTransaction
();
s
->
blockState
=
TBLOCK_ENDABORT
;
s
->
blockState
=
TBLOCK_ENDABORT
;
}
}
...
@@ -1583,7 +1593,9 @@ UserAbortTransactionBlock(void)
...
@@ -1583,7 +1593,9 @@ UserAbortTransactionBlock(void)
* CommitTransactionCommand() will then put us back into the default
* CommitTransactionCommand() will then put us back into the default
* state.
* state.
*/
*/
elog
(
WARNING
,
"ROLLBACK: no transaction in progress"
);
ereport
(
WARNING
,
(
errcode
(
ERRCODE_NO_ACTIVE_SQL_TRANSACTION
),
errmsg
(
"there is no transaction in progress"
)));
AbortTransaction
();
AbortTransaction
();
s
->
blockState
=
TBLOCK_ENDABORT
;
s
->
blockState
=
TBLOCK_ENDABORT
;
}
}
...
@@ -1663,7 +1675,8 @@ TransactionBlockStatusCode(void)
...
@@ -1663,7 +1675,8 @@ TransactionBlockStatusCode(void)
}
}
/* should never get here */
/* should never get here */
elog
(
ERROR
,
"bogus transaction block state"
);
elog
(
ERROR
,
"invalid transaction block state: %d"
,
(
int
)
s
->
blockState
);
return
0
;
/* keep compiler quiet */
return
0
;
/* keep compiler quiet */
}
}
...
...
src/backend/access/transam/xlog.c
View file @
ec7aa4b5
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.11
8 2003/07/17 16:45:04
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.11
9 2003/07/21 20:29:39
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -504,8 +504,7 @@ XLogInsert(RmgrId rmid, uint8 info, XLogRecData *rdata)
...
@@ -504,8 +504,7 @@ XLogInsert(RmgrId rmid, uint8 info, XLogRecData *rdata)
if
(
info
&
XLR_INFO_MASK
)
if
(
info
&
XLR_INFO_MASK
)
{
{
if
((
info
&
XLR_INFO_MASK
)
!=
XLOG_NO_TRAN
)
if
((
info
&
XLR_INFO_MASK
)
!=
XLOG_NO_TRAN
)
elog
(
PANIC
,
"XLogInsert: invalid info mask %02X"
,
elog
(
PANIC
,
"invalid xlog info mask %02X"
,
(
info
&
XLR_INFO_MASK
));
(
info
&
XLR_INFO_MASK
));
no_tran
=
true
;
no_tran
=
true
;
info
&=
~
XLR_INFO_MASK
;
info
&=
~
XLR_INFO_MASK
;
}
}
...
@@ -609,7 +608,7 @@ begin:;
...
@@ -609,7 +608,7 @@ begin:;
}
}
}
}
if
(
i
>=
XLR_MAX_BKP_BLOCKS
)
if
(
i
>=
XLR_MAX_BKP_BLOCKS
)
elog
(
PANIC
,
"
XLogInsert: can backup %d blocks at most
"
,
elog
(
PANIC
,
"
can backup at most %d blocks per xlog record
"
,
XLR_MAX_BKP_BLOCKS
);
XLR_MAX_BKP_BLOCKS
);
}
}
/* Break out of loop when rdt points to last list item */
/* Break out of loop when rdt points to last list item */
...
@@ -627,7 +626,7 @@ begin:;
...
@@ -627,7 +626,7 @@ begin:;
* also remove the check for xl_len == 0 in ReadRecord, below.
* also remove the check for xl_len == 0 in ReadRecord, below.
*/
*/
if
(
len
==
0
||
len
>
MAXLOGRECSZ
)
if
(
len
==
0
||
len
>
MAXLOGRECSZ
)
elog
(
PANIC
,
"
XLogInsert: invalid
record length %u"
,
len
);
elog
(
PANIC
,
"
invalid xlog
record length %u"
,
len
);
START_CRIT_SECTION
();
START_CRIT_SECTION
();
...
@@ -1028,7 +1027,7 @@ XLogWrite(XLogwrtRqst WriteRqst)
...
@@ -1028,7 +1027,7 @@ XLogWrite(XLogwrtRqst WriteRqst)
* AdvanceXLInsertBuffer.
* AdvanceXLInsertBuffer.
*/
*/
if
(
!
XLByteLT
(
LogwrtResult
.
Write
,
XLogCtl
->
xlblocks
[
Write
->
curridx
]))
if
(
!
XLByteLT
(
LogwrtResult
.
Write
,
XLogCtl
->
xlblocks
[
Write
->
curridx
]))
elog
(
PANIC
,
"
XLogWrite:
write request %X/%X is past end of log %X/%X"
,
elog
(
PANIC
,
"
xlog
write request %X/%X is past end of log %X/%X"
,
LogwrtResult
.
Write
.
xlogid
,
LogwrtResult
.
Write
.
xrecoff
,
LogwrtResult
.
Write
.
xlogid
,
LogwrtResult
.
Write
.
xrecoff
,
XLogCtl
->
xlblocks
[
Write
->
curridx
].
xlogid
,
XLogCtl
->
xlblocks
[
Write
->
curridx
].
xlogid
,
XLogCtl
->
xlblocks
[
Write
->
curridx
].
xrecoff
);
XLogCtl
->
xlblocks
[
Write
->
curridx
].
xrecoff
);
...
@@ -1045,8 +1044,10 @@ XLogWrite(XLogwrtRqst WriteRqst)
...
@@ -1045,8 +1044,10 @@ XLogWrite(XLogwrtRqst WriteRqst)
if
(
openLogFile
>=
0
)
if
(
openLogFile
>=
0
)
{
{
if
(
close
(
openLogFile
)
!=
0
)
if
(
close
(
openLogFile
)
!=
0
)
elog
(
PANIC
,
"close of log file %u, segment %u failed: %m"
,
ereport
(
PANIC
,
openLogId
,
openLogSeg
);
(
errcode_for_file_access
(),
errmsg
(
"close of log file %u, segment %u failed: %m"
,
openLogId
,
openLogSeg
)));
openLogFile
=
-
1
;
openLogFile
=
-
1
;
}
}
XLByteToPrevSeg
(
LogwrtResult
.
Write
,
openLogId
,
openLogSeg
);
XLByteToPrevSeg
(
LogwrtResult
.
Write
,
openLogId
,
openLogSeg
);
...
@@ -1080,7 +1081,7 @@ XLogWrite(XLogwrtRqst WriteRqst)
...
@@ -1080,7 +1081,7 @@ XLogWrite(XLogwrtRqst WriteRqst)
(
uint32
)
CheckPointSegments
))
(
uint32
)
CheckPointSegments
))
{
{
if
(
XLOG_DEBUG
)
if
(
XLOG_DEBUG
)
elog
(
LOG
,
"
XLogWrite:
time for a checkpoint, signaling postmaster"
);
elog
(
LOG
,
"time for a checkpoint, signaling postmaster"
);
SendPostmasterSignal
(
PMSIGNAL_DO_CHECKPOINT
);
SendPostmasterSignal
(
PMSIGNAL_DO_CHECKPOINT
);
}
}
}
}
...
@@ -1099,8 +1100,10 @@ XLogWrite(XLogwrtRqst WriteRqst)
...
@@ -1099,8 +1100,10 @@ XLogWrite(XLogwrtRqst WriteRqst)
{
{
openLogOff
=
(
LogwrtResult
.
Write
.
xrecoff
-
BLCKSZ
)
%
XLogSegSize
;
openLogOff
=
(
LogwrtResult
.
Write
.
xrecoff
-
BLCKSZ
)
%
XLogSegSize
;
if
(
lseek
(
openLogFile
,
(
off_t
)
openLogOff
,
SEEK_SET
)
<
0
)
if
(
lseek
(
openLogFile
,
(
off_t
)
openLogOff
,
SEEK_SET
)
<
0
)
elog
(
PANIC
,
"lseek of log file %u, segment %u, offset %u failed: %m"
,
ereport
(
PANIC
,
openLogId
,
openLogSeg
,
openLogOff
);
(
errcode_for_file_access
(),
errmsg
(
"lseek of log file %u, segment %u, offset %u failed: %m"
,
openLogId
,
openLogSeg
,
openLogOff
)));
}
}
/* OK to write the page */
/* OK to write the page */
...
@@ -1111,8 +1114,10 @@ XLogWrite(XLogwrtRqst WriteRqst)
...
@@ -1111,8 +1114,10 @@ XLogWrite(XLogwrtRqst WriteRqst)
/* if write didn't set errno, assume problem is no disk space */
/* if write didn't set errno, assume problem is no disk space */
if
(
errno
==
0
)
if
(
errno
==
0
)
errno
=
ENOSPC
;
errno
=
ENOSPC
;
elog
(
PANIC
,
"write of log file %u, segment %u, offset %u failed: %m"
,
ereport
(
PANIC
,
openLogId
,
openLogSeg
,
openLogOff
);
(
errcode_for_file_access
(),
errmsg
(
"write of log file %u, segment %u, offset %u failed: %m"
,
openLogId
,
openLogSeg
,
openLogOff
)));
}
}
openLogOff
+=
BLCKSZ
;
openLogOff
+=
BLCKSZ
;
...
@@ -1155,8 +1160,10 @@ XLogWrite(XLogwrtRqst WriteRqst)
...
@@ -1155,8 +1160,10 @@ XLogWrite(XLogwrtRqst WriteRqst)
!
XLByteInPrevSeg
(
LogwrtResult
.
Write
,
openLogId
,
openLogSeg
))
!
XLByteInPrevSeg
(
LogwrtResult
.
Write
,
openLogId
,
openLogSeg
))
{
{
if
(
close
(
openLogFile
)
!=
0
)
if
(
close
(
openLogFile
)
!=
0
)
elog
(
PANIC
,
"close of log file %u, segment %u failed: %m"
,
ereport
(
PANIC
,
openLogId
,
openLogSeg
);
(
errcode_for_file_access
(),
errmsg
(
"close of log file %u, segment %u failed: %m"
,
openLogId
,
openLogSeg
)));
openLogFile
=
-
1
;
openLogFile
=
-
1
;
}
}
if
(
openLogFile
<
0
)
if
(
openLogFile
<
0
)
...
@@ -1214,13 +1221,10 @@ XLogFlush(XLogRecPtr record)
...
@@ -1214,13 +1221,10 @@ XLogFlush(XLogRecPtr record)
return
;
return
;
if
(
XLOG_DEBUG
)
if
(
XLOG_DEBUG
)
{
elog
(
LOG
,
"xlog flush request %X/%X; write %X/%X; flush %X/%X"
,
elog
(
LOG
,
"XLogFlush%s: request %X/%X; write %X/%X; flush %X/%X"
,
(
IsBootstrapProcessingMode
())
?
"(bootstrap)"
:
""
,
record
.
xlogid
,
record
.
xrecoff
,
record
.
xlogid
,
record
.
xrecoff
,
LogwrtResult
.
Write
.
xlogid
,
LogwrtResult
.
Write
.
xrecoff
,
LogwrtResult
.
Write
.
xlogid
,
LogwrtResult
.
Write
.
xrecoff
,
LogwrtResult
.
Flush
.
xlogid
,
LogwrtResult
.
Flush
.
xrecoff
);
LogwrtResult
.
Flush
.
xlogid
,
LogwrtResult
.
Flush
.
xrecoff
);
}
START_CRIT_SECTION
();
START_CRIT_SECTION
();
...
@@ -1311,7 +1315,7 @@ XLogFlush(XLogRecPtr record)
...
@@ -1311,7 +1315,7 @@ XLogFlush(XLogRecPtr record)
*/
*/
if
(
XLByteLT
(
LogwrtResult
.
Flush
,
record
))
if
(
XLByteLT
(
LogwrtResult
.
Flush
,
record
))
elog
(
InRecovery
?
WARNING
:
ERROR
,
elog
(
InRecovery
?
WARNING
:
ERROR
,
"
XLogFlush:
request %X/%X is not satisfied --- flushed only to %X/%X"
,
"
xlog flush
request %X/%X is not satisfied --- flushed only to %X/%X"
,
record
.
xlogid
,
record
.
xrecoff
,
record
.
xlogid
,
record
.
xrecoff
,
LogwrtResult
.
Flush
.
xlogid
,
LogwrtResult
.
Flush
.
xrecoff
);
LogwrtResult
.
Flush
.
xlogid
,
LogwrtResult
.
Flush
.
xrecoff
);
}
}
...
@@ -1354,8 +1358,10 @@ XLogFileInit(uint32 log, uint32 seg,
...
@@ -1354,8 +1358,10 @@ XLogFileInit(uint32 log, uint32 seg,
if
(
fd
<
0
)
if
(
fd
<
0
)
{
{
if
(
errno
!=
ENOENT
)
if
(
errno
!=
ENOENT
)
elog
(
PANIC
,
"open of %s (log file %u, segment %u) failed: %m"
,
ereport
(
PANIC
,
path
,
log
,
seg
);
(
errcode_for_file_access
(),
errmsg
(
"open of
\"
%s
\"
(log file %u, segment %u) failed: %m"
,
path
,
log
,
seg
)));
}
}
else
else
return
(
fd
);
return
(
fd
);
...
@@ -1376,7 +1382,9 @@ XLogFileInit(uint32 log, uint32 seg,
...
@@ -1376,7 +1382,9 @@ XLogFileInit(uint32 log, uint32 seg,
fd
=
BasicOpenFile
(
tmppath
,
O_RDWR
|
O_CREAT
|
O_EXCL
|
PG_BINARY
,
fd
=
BasicOpenFile
(
tmppath
,
O_RDWR
|
O_CREAT
|
O_EXCL
|
PG_BINARY
,
S_IRUSR
|
S_IWUSR
);
S_IRUSR
|
S_IWUSR
);
if
(
fd
<
0
)
if
(
fd
<
0
)
elog
(
PANIC
,
"creation of file %s failed: %m"
,
tmppath
);
ereport
(
PANIC
,
(
errcode_for_file_access
(),
errmsg
(
"creation of file
\"
%s
\"
failed: %m"
,
tmppath
)));
/*
/*
* Zero-fill the file. We have to do this the hard way to ensure that
* Zero-fill the file. We have to do this the hard way to ensure that
...
@@ -1403,12 +1411,16 @@ XLogFileInit(uint32 log, uint32 seg,
...
@@ -1403,12 +1411,16 @@ XLogFileInit(uint32 log, uint32 seg,
/* if write didn't set errno, assume problem is no disk space */
/* if write didn't set errno, assume problem is no disk space */
errno
=
save_errno
?
save_errno
:
ENOSPC
;
errno
=
save_errno
?
save_errno
:
ENOSPC
;
elog
(
PANIC
,
"ZeroFill failed to write %s: %m"
,
tmppath
);
ereport
(
PANIC
,
(
errcode_for_file_access
(),
errmsg
(
"failed to write
\"
%s
\"
: %m"
,
tmppath
)));
}
}
}
}
if
(
pg_fsync
(
fd
)
!=
0
)
if
(
pg_fsync
(
fd
)
!=
0
)
elog
(
PANIC
,
"fsync of file %s failed: %m"
,
tmppath
);
ereport
(
PANIC
,
(
errcode_for_file_access
(),
errmsg
(
"fsync of file
\"
%s
\"
failed: %m"
,
tmppath
)));
close
(
fd
);
close
(
fd
);
...
@@ -1435,8 +1447,10 @@ XLogFileInit(uint32 log, uint32 seg,
...
@@ -1435,8 +1447,10 @@ XLogFileInit(uint32 log, uint32 seg,
fd
=
BasicOpenFile
(
path
,
O_RDWR
|
PG_BINARY
|
XLOG_SYNC_BIT
,
fd
=
BasicOpenFile
(
path
,
O_RDWR
|
PG_BINARY
|
XLOG_SYNC_BIT
,
S_IRUSR
|
S_IWUSR
);
S_IRUSR
|
S_IWUSR
);
if
(
fd
<
0
)
if
(
fd
<
0
)
elog
(
PANIC
,
"open of %s (log file %u, segment %u) failed: %m"
,
ereport
(
PANIC
,
path
,
log
,
seg
);
(
errcode_for_file_access
(),
errmsg
(
"open of
\"
%s
\"
(log file %u, segment %u) failed: %m"
,
path
,
log
,
seg
)));
return
(
fd
);
return
(
fd
);
}
}
...
@@ -1464,7 +1478,7 @@ XLogFileInit(uint32 log, uint32 seg,
...
@@ -1464,7 +1478,7 @@ XLogFileInit(uint32 log, uint32 seg,
* caller must *not* hold the lock at call.
* caller must *not* hold the lock at call.
*
*
* Returns TRUE if file installed, FALSE if not installed because of
* Returns TRUE if file installed, FALSE if not installed because of
* exceeding max_advance limit. (Any other kind of failure causes e
log
().)
* exceeding max_advance limit. (Any other kind of failure causes e
report
().)
*/
*/
static
bool
static
bool
InstallXLogFileSegment
(
uint32
log
,
uint32
seg
,
char
*
tmppath
,
InstallXLogFileSegment
(
uint32
log
,
uint32
seg
,
char
*
tmppath
,
...
@@ -1511,13 +1525,17 @@ InstallXLogFileSegment(uint32 log, uint32 seg, char *tmppath,
...
@@ -1511,13 +1525,17 @@ InstallXLogFileSegment(uint32 log, uint32 seg, char *tmppath,
*/
*/
#if HAVE_WORKING_LINK
#if HAVE_WORKING_LINK
if
(
link
(
tmppath
,
path
)
<
0
)
if
(
link
(
tmppath
,
path
)
<
0
)
elog
(
PANIC
,
"link from %s to %s (initialization of log file %u, segment %u) failed: %m"
,
ereport
(
PANIC
,
tmppath
,
path
,
log
,
seg
);
(
errcode_for_file_access
(),
errmsg
(
"link from
\"
%s
\"
to
\"
%s
\"
(initialization of log file %u, segment %u) failed: %m"
,
tmppath
,
path
,
log
,
seg
)));
unlink
(
tmppath
);
unlink
(
tmppath
);
#else
#else
if
(
rename
(
tmppath
,
path
)
<
0
)
if
(
rename
(
tmppath
,
path
)
<
0
)
elog
(
PANIC
,
"rename from %s to %s (initialization of log file %u, segment %u) failed: %m"
,
ereport
(
PANIC
,
tmppath
,
path
,
log
,
seg
);
(
errcode_for_file_access
(),
errmsg
(
"rename from
\"
%s
\"
to
\"
%s
\"
(initialization of log file %u, segment %u) failed: %m"
,
tmppath
,
path
,
log
,
seg
)));
#endif
#endif
if
(
use_lock
)
if
(
use_lock
)
...
@@ -1543,12 +1561,16 @@ XLogFileOpen(uint32 log, uint32 seg, bool econt)
...
@@ -1543,12 +1561,16 @@ XLogFileOpen(uint32 log, uint32 seg, bool econt)
{
{
if
(
econt
&&
errno
==
ENOENT
)
if
(
econt
&&
errno
==
ENOENT
)
{
{
elog
(
LOG
,
"open of %s (log file %u, segment %u) failed: %m"
,
ereport
(
LOG
,
path
,
log
,
seg
);
(
errcode_for_file_access
(),
errmsg
(
"open of
\"
%s
\"
(log file %u, segment %u) failed: %m"
,
path
,
log
,
seg
)));
return
(
fd
);
return
(
fd
);
}
}
elog
(
PANIC
,
"open of %s (log file %u, segment %u) failed: %m"
,
ereport
(
PANIC
,
path
,
log
,
seg
);
(
errcode_for_file_access
(),
errmsg
(
"open of
\"
%s
\"
(log file %u, segment %u) failed: %m"
,
path
,
log
,
seg
)));
}
}
return
(
fd
);
return
(
fd
);
...
@@ -1597,8 +1619,10 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr)
...
@@ -1597,8 +1619,10 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr)
xldir
=
opendir
(
XLogDir
);
xldir
=
opendir
(
XLogDir
);
if
(
xldir
==
NULL
)
if
(
xldir
==
NULL
)
elog
(
PANIC
,
"could not open transaction log directory (%s): %m"
,
ereport
(
PANIC
,
XLogDir
);
(
errcode_for_file_access
(),
errmsg
(
"could not open transaction log directory
\"
%s
\"
: %m"
,
XLogDir
)));
sprintf
(
lastoff
,
"%08X%08X"
,
log
,
seg
);
sprintf
(
lastoff
,
"%08X%08X"
,
log
,
seg
);
...
@@ -1612,9 +1636,10 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr)
...
@@ -1612,9 +1636,10 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr)
snprintf
(
path
,
MAXPGPATH
,
"%s/%s"
,
XLogDir
,
xlde
->
d_name
);
snprintf
(
path
,
MAXPGPATH
,
"%s/%s"
,
XLogDir
,
xlde
->
d_name
);
if
(
XLOG_archive_dir
[
0
])
if
(
XLOG_archive_dir
[
0
])
{
{
elog
(
LOG
,
"archiving transaction log file %s"
,
ereport
(
LOG
,
xlde
->
d_name
);
(
errmsg
(
"archiving transaction log file
\"
%s
\"
"
,
elog
(
WARNING
,
"archiving log files is not implemented!"
);
xlde
->
d_name
)));
elog
(
WARNING
,
"archiving log files is not implemented"
);
}
}
else
else
{
{
...
@@ -1628,14 +1653,16 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr)
...
@@ -1628,14 +1653,16 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr)
true
,
XLOGfileslop
,
true
,
XLOGfileslop
,
true
))
true
))
{
{
elog
(
LOG
,
"recycled transaction log file %s"
,
ereport
(
LOG
,
xlde
->
d_name
);
(
errmsg
(
"recycled transaction log file
\"
%s
\"
"
,
xlde
->
d_name
)));
}
}
else
else
{
{
/* No need for any more future segments... */
/* No need for any more future segments... */
elog
(
LOG
,
"removing transaction log file %s"
,
ereport
(
LOG
,
xlde
->
d_name
);
(
errmsg
(
"removing transaction log file
\"
%s
\"
"
,
xlde
->
d_name
)));
unlink
(
path
);
unlink
(
path
);
}
}
}
}
...
@@ -1643,8 +1670,10 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr)
...
@@ -1643,8 +1670,10 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr)
errno
=
0
;
errno
=
0
;
}
}
if
(
errno
)
if
(
errno
)
elog
(
PANIC
,
"could not read transaction log directory (%s): %m"
,
ereport
(
PANIC
,
XLogDir
);
(
errcode_for_file_access
(),
errmsg
(
"could not read transaction log directory
\"
%s
\"
: %m"
,
XLogDir
)));
closedir
(
xldir
);
closedir
(
xldir
);
}
}
...
@@ -1716,8 +1745,9 @@ RecordIsValid(XLogRecord *record, XLogRecPtr recptr, int emode)
...
@@ -1716,8 +1745,9 @@ RecordIsValid(XLogRecord *record, XLogRecPtr recptr, int emode)
if
(
!
EQ_CRC64
(
record
->
xl_crc
,
crc
))
if
(
!
EQ_CRC64
(
record
->
xl_crc
,
crc
))
{
{
elog
(
emode
,
"ReadRecord: bad resource manager data checksum in record at %X/%X"
,
ereport
(
emode
,
recptr
.
xlogid
,
recptr
.
xrecoff
);
(
errmsg
(
"bad resource manager data checksum in record at %X/%X"
,
recptr
.
xlogid
,
recptr
.
xrecoff
)));
return
(
false
);
return
(
false
);
}
}
...
@@ -1738,8 +1768,9 @@ RecordIsValid(XLogRecord *record, XLogRecPtr recptr, int emode)
...
@@ -1738,8 +1768,9 @@ RecordIsValid(XLogRecord *record, XLogRecPtr recptr, int emode)
if
(
!
EQ_CRC64
(
cbuf
,
crc
))
if
(
!
EQ_CRC64
(
cbuf
,
crc
))
{
{
elog
(
emode
,
"ReadRecord: bad checksum of backup block %d in record at %X/%X"
,
ereport
(
emode
,
i
+
1
,
recptr
.
xlogid
,
recptr
.
xrecoff
);
(
errmsg
(
"bad checksum of backup block %d in record at %X/%X"
,
i
+
1
,
recptr
.
xlogid
,
recptr
.
xrecoff
)));
return
(
false
);
return
(
false
);
}
}
blk
+=
sizeof
(
BkpBlock
)
+
BLCKSZ
;
blk
+=
sizeof
(
BkpBlock
)
+
BLCKSZ
;
...
@@ -1807,8 +1838,9 @@ ReadRecord(XLogRecPtr *RecPtr, int emode, char *buffer)
...
@@ -1807,8 +1838,9 @@ ReadRecord(XLogRecPtr *RecPtr, int emode, char *buffer)
tmpRecPtr
.
xrecoff
+=
SizeOfXLogPHD
;
tmpRecPtr
.
xrecoff
+=
SizeOfXLogPHD
;
}
}
else
if
(
!
XRecOffIsValid
(
RecPtr
->
xrecoff
))
else
if
(
!
XRecOffIsValid
(
RecPtr
->
xrecoff
))
elog
(
PANIC
,
"ReadRecord: invalid record offset at %X/%X"
,
ereport
(
PANIC
,
RecPtr
->
xlogid
,
RecPtr
->
xrecoff
);
(
errmsg
(
"invalid record offset at %X/%X"
,
RecPtr
->
xlogid
,
RecPtr
->
xrecoff
)));
if
(
readFile
>=
0
&&
!
XLByteInSeg
(
*
RecPtr
,
readId
,
readSeg
))
if
(
readFile
>=
0
&&
!
XLByteInSeg
(
*
RecPtr
,
readId
,
readSeg
))
{
{
...
@@ -1830,14 +1862,18 @@ ReadRecord(XLogRecPtr *RecPtr, int emode, char *buffer)
...
@@ -1830,14 +1862,18 @@ ReadRecord(XLogRecPtr *RecPtr, int emode, char *buffer)
readOff
=
targetPageOff
;
readOff
=
targetPageOff
;
if
(
lseek
(
readFile
,
(
off_t
)
readOff
,
SEEK_SET
)
<
0
)
if
(
lseek
(
readFile
,
(
off_t
)
readOff
,
SEEK_SET
)
<
0
)
{
{
elog
(
emode
,
"ReadRecord: lseek of log file %u, segment %u, offset %u failed: %m"
,
ereport
(
emode
,
readId
,
readSeg
,
readOff
);
(
errcode_for_file_access
(),
errmsg
(
"lseek of log file %u, segment %u, offset %u failed: %m"
,
readId
,
readSeg
,
readOff
)));
goto
next_record_is_invalid
;
goto
next_record_is_invalid
;
}
}
if
(
read
(
readFile
,
readBuf
,
BLCKSZ
)
!=
BLCKSZ
)
if
(
read
(
readFile
,
readBuf
,
BLCKSZ
)
!=
BLCKSZ
)
{
{
elog
(
emode
,
"ReadRecord: read of log file %u, segment %u, offset %u failed: %m"
,
ereport
(
emode
,
readId
,
readSeg
,
readOff
);
(
errcode_for_file_access
(),
errmsg
(
"read of log file %u, segment %u, offset %u failed: %m"
,
readId
,
readSeg
,
readOff
)));
goto
next_record_is_invalid
;
goto
next_record_is_invalid
;
}
}
if
(
!
ValidXLOGHeader
((
XLogPageHeader
)
readBuf
,
emode
,
nextmode
))
if
(
!
ValidXLOGHeader
((
XLogPageHeader
)
readBuf
,
emode
,
nextmode
))
...
@@ -1846,8 +1882,9 @@ ReadRecord(XLogRecPtr *RecPtr, int emode, char *buffer)
...
@@ -1846,8 +1882,9 @@ ReadRecord(XLogRecPtr *RecPtr, int emode, char *buffer)
if
((((
XLogPageHeader
)
readBuf
)
->
xlp_info
&
XLP_FIRST_IS_CONTRECORD
)
&&
if
((((
XLogPageHeader
)
readBuf
)
->
xlp_info
&
XLP_FIRST_IS_CONTRECORD
)
&&
RecPtr
->
xrecoff
%
BLCKSZ
==
SizeOfXLogPHD
)
RecPtr
->
xrecoff
%
BLCKSZ
==
SizeOfXLogPHD
)
{
{
elog
(
emode
,
"ReadRecord: contrecord is requested by %X/%X"
,
ereport
(
emode
,
RecPtr
->
xlogid
,
RecPtr
->
xrecoff
);
(
errmsg
(
"contrecord is requested by %X/%X"
,
RecPtr
->
xlogid
,
RecPtr
->
xrecoff
)));
goto
next_record_is_invalid
;
goto
next_record_is_invalid
;
}
}
record
=
(
XLogRecord
*
)
((
char
*
)
readBuf
+
RecPtr
->
xrecoff
%
BLCKSZ
);
record
=
(
XLogRecord
*
)
((
char
*
)
readBuf
+
RecPtr
->
xrecoff
%
BLCKSZ
);
...
@@ -1860,8 +1897,9 @@ got_record:;
...
@@ -1860,8 +1897,9 @@ got_record:;
*/
*/
if
(
record
->
xl_len
==
0
)
if
(
record
->
xl_len
==
0
)
{
{
elog
(
emode
,
"ReadRecord: record with zero length at %X/%X"
,
ereport
(
emode
,
RecPtr
->
xlogid
,
RecPtr
->
xrecoff
);
(
errmsg
(
"record with zero length at %X/%X"
,
RecPtr
->
xlogid
,
RecPtr
->
xrecoff
)));
goto
next_record_is_invalid
;
goto
next_record_is_invalid
;
}
}
...
@@ -1884,14 +1922,16 @@ got_record:;
...
@@ -1884,14 +1922,16 @@ got_record:;
*/
*/
if
(
total_len
>
_INTL_MAXLOGRECSZ
)
if
(
total_len
>
_INTL_MAXLOGRECSZ
)
{
{
elog
(
emode
,
"ReadRecord: record length %u at %X/%X too long"
,
ereport
(
emode
,
total_len
,
RecPtr
->
xlogid
,
RecPtr
->
xrecoff
);
(
errmsg
(
"record length %u at %X/%X too long"
,
total_len
,
RecPtr
->
xlogid
,
RecPtr
->
xrecoff
)));
goto
next_record_is_invalid
;
goto
next_record_is_invalid
;
}
}
if
(
record
->
xl_rmid
>
RM_MAX_ID
)
if
(
record
->
xl_rmid
>
RM_MAX_ID
)
{
{
elog
(
emode
,
"ReadRecord: invalid resource manager id %u at %X/%X"
,
ereport
(
emode
,
record
->
xl_rmid
,
RecPtr
->
xlogid
,
RecPtr
->
xrecoff
);
(
errmsg
(
"invalid resource manager id %u at %X/%X"
,
record
->
xl_rmid
,
RecPtr
->
xlogid
,
RecPtr
->
xrecoff
)));
goto
next_record_is_invalid
;
goto
next_record_is_invalid
;
}
}
nextRecord
=
NULL
;
nextRecord
=
NULL
;
...
@@ -1920,24 +1960,29 @@ got_record:;
...
@@ -1920,24 +1960,29 @@ got_record:;
}
}
if
(
read
(
readFile
,
readBuf
,
BLCKSZ
)
!=
BLCKSZ
)
if
(
read
(
readFile
,
readBuf
,
BLCKSZ
)
!=
BLCKSZ
)
{
{
elog
(
emode
,
"ReadRecord: read of log file %u, segment %u, offset %u failed: %m"
,
ereport
(
emode
,
readId
,
readSeg
,
readOff
);
(
errcode_for_file_access
(),
errmsg
(
"read of log file %u, segment %u, offset %u failed: %m"
,
readId
,
readSeg
,
readOff
)));
goto
next_record_is_invalid
;
goto
next_record_is_invalid
;
}
}
if
(
!
ValidXLOGHeader
((
XLogPageHeader
)
readBuf
,
emode
,
true
))
if
(
!
ValidXLOGHeader
((
XLogPageHeader
)
readBuf
,
emode
,
true
))
goto
next_record_is_invalid
;
goto
next_record_is_invalid
;
if
(
!
(((
XLogPageHeader
)
readBuf
)
->
xlp_info
&
XLP_FIRST_IS_CONTRECORD
))
if
(
!
(((
XLogPageHeader
)
readBuf
)
->
xlp_info
&
XLP_FIRST_IS_CONTRECORD
))
{
{
elog
(
emode
,
"ReadRecord: there is no ContRecord flag in log file %u, segment %u, offset %u"
,
ereport
(
emode
,
readId
,
readSeg
,
readOff
);
(
errmsg
(
"there is no contrecord flag in log file %u, segment %u, offset %u"
,
readId
,
readSeg
,
readOff
)));
goto
next_record_is_invalid
;
goto
next_record_is_invalid
;
}
}
contrecord
=
(
XLogContRecord
*
)
((
char
*
)
readBuf
+
SizeOfXLogPHD
);
contrecord
=
(
XLogContRecord
*
)
((
char
*
)
readBuf
+
SizeOfXLogPHD
);
if
(
contrecord
->
xl_rem_len
==
0
||
if
(
contrecord
->
xl_rem_len
==
0
||
total_len
!=
(
contrecord
->
xl_rem_len
+
gotlen
))
total_len
!=
(
contrecord
->
xl_rem_len
+
gotlen
))
{
{
elog
(
emode
,
"ReadRecord: invalid ContRecord length %u in log file %u, segment %u, offset %u"
,
ereport
(
emode
,
contrecord
->
xl_rem_len
,
readId
,
readSeg
,
readOff
);
(
errmsg
(
"invalid contrecord length %u in log file %u, segment %u, offset %u"
,
contrecord
->
xl_rem_len
,
readId
,
readSeg
,
readOff
)));
goto
next_record_is_invalid
;
goto
next_record_is_invalid
;
}
}
len
=
BLCKSZ
-
SizeOfXLogPHD
-
SizeOfXLogContRecord
;
len
=
BLCKSZ
-
SizeOfXLogPHD
-
SizeOfXLogContRecord
;
...
@@ -2000,23 +2045,26 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode, bool checkSUI)
...
@@ -2000,23 +2045,26 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode, bool checkSUI)
if
(
hdr
->
xlp_magic
!=
XLOG_PAGE_MAGIC
)
if
(
hdr
->
xlp_magic
!=
XLOG_PAGE_MAGIC
)
{
{
elog
(
emode
,
"ReadRecord: invalid magic number %04X in log file %u, segment %u, offset %u"
,
ereport
(
emode
,
hdr
->
xlp_magic
,
readId
,
readSeg
,
readOff
);
(
errmsg
(
"invalid magic number %04X in log file %u, segment %u, offset %u"
,
hdr
->
xlp_magic
,
readId
,
readSeg
,
readOff
)));
return
false
;
return
false
;
}
}
if
((
hdr
->
xlp_info
&
~
XLP_ALL_FLAGS
)
!=
0
)
if
((
hdr
->
xlp_info
&
~
XLP_ALL_FLAGS
)
!=
0
)
{
{
elog
(
emode
,
"ReadRecord: invalid info bits %04X in log file %u, segment %u, offset %u"
,
ereport
(
emode
,
hdr
->
xlp_info
,
readId
,
readSeg
,
readOff
);
(
errmsg
(
"invalid info bits %04X in log file %u, segment %u, offset %u"
,
hdr
->
xlp_info
,
readId
,
readSeg
,
readOff
)));
return
false
;
return
false
;
}
}
recaddr
.
xlogid
=
readId
;
recaddr
.
xlogid
=
readId
;
recaddr
.
xrecoff
=
readSeg
*
XLogSegSize
+
readOff
;
recaddr
.
xrecoff
=
readSeg
*
XLogSegSize
+
readOff
;
if
(
!
XLByteEQ
(
hdr
->
xlp_pageaddr
,
recaddr
))
if
(
!
XLByteEQ
(
hdr
->
xlp_pageaddr
,
recaddr
))
{
{
elog
(
emode
,
"ReadRecord: unexpected pageaddr %X/%X in log file %u, segment %u, offset %u"
,
ereport
(
emode
,
hdr
->
xlp_pageaddr
.
xlogid
,
hdr
->
xlp_pageaddr
.
xrecoff
,
(
errmsg
(
"unexpected pageaddr %X/%X in log file %u, segment %u, offset %u"
,
readId
,
readSeg
,
readOff
);
hdr
->
xlp_pageaddr
.
xlogid
,
hdr
->
xlp_pageaddr
.
xrecoff
,
readId
,
readSeg
,
readOff
)));
return
false
;
return
false
;
}
}
...
@@ -2035,9 +2083,11 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode, bool checkSUI)
...
@@ -2035,9 +2083,11 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode, bool checkSUI)
if
(
hdr
->
xlp_sui
<
lastReadSUI
||
if
(
hdr
->
xlp_sui
<
lastReadSUI
||
hdr
->
xlp_sui
>
lastReadSUI
+
512
)
hdr
->
xlp_sui
>
lastReadSUI
+
512
)
{
{
/* translator: SUI = startup id */
ereport
(
emode
,
elog
(
emode
,
"ReadRecord: out-of-sequence SUI %u (after %u) in log file %u, segment %u, offset %u"
,
/* translator: SUI = startup id */
hdr
->
xlp_sui
,
lastReadSUI
,
readId
,
readSeg
,
readOff
);
(
errmsg
(
"out-of-sequence SUI %u (after %u) in log file %u, segment %u, offset %u"
,
hdr
->
xlp_sui
,
lastReadSUI
,
readId
,
readSeg
,
readOff
)));
return
false
;
return
false
;
}
}
}
}
...
@@ -2095,11 +2145,13 @@ WriteControlFile(void)
...
@@ -2095,11 +2145,13 @@ WriteControlFile(void)
ControlFile
->
localeBuflen
=
LOCALE_NAME_BUFLEN
;
ControlFile
->
localeBuflen
=
LOCALE_NAME_BUFLEN
;
localeptr
=
setlocale
(
LC_COLLATE
,
NULL
);
localeptr
=
setlocale
(
LC_COLLATE
,
NULL
);
if
(
!
localeptr
)
if
(
!
localeptr
)
elog
(
PANIC
,
"invalid LC_COLLATE setting"
);
ereport
(
PANIC
,
(
errmsg
(
"invalid LC_COLLATE setting"
)));
StrNCpy
(
ControlFile
->
lc_collate
,
localeptr
,
LOCALE_NAME_BUFLEN
);
StrNCpy
(
ControlFile
->
lc_collate
,
localeptr
,
LOCALE_NAME_BUFLEN
);
localeptr
=
setlocale
(
LC_CTYPE
,
NULL
);
localeptr
=
setlocale
(
LC_CTYPE
,
NULL
);
if
(
!
localeptr
)
if
(
!
localeptr
)
elog
(
PANIC
,
"invalid LC_CTYPE setting"
);
ereport
(
PANIC
,
(
errmsg
(
"invalid LC_CTYPE setting"
)));
StrNCpy
(
ControlFile
->
lc_ctype
,
localeptr
,
LOCALE_NAME_BUFLEN
);
StrNCpy
(
ControlFile
->
lc_ctype
,
localeptr
,
LOCALE_NAME_BUFLEN
);
/* Contents are protected with a CRC */
/* Contents are protected with a CRC */
...
@@ -2117,7 +2169,8 @@ WriteControlFile(void)
...
@@ -2117,7 +2169,8 @@ WriteControlFile(void)
* specific error than "couldn't read pg_control".
* specific error than "couldn't read pg_control".
*/
*/
if
(
sizeof
(
ControlFileData
)
>
BLCKSZ
)
if
(
sizeof
(
ControlFileData
)
>
BLCKSZ
)
elog
(
PANIC
,
"sizeof(ControlFileData) is larger than BLCKSZ; fix either one"
);
ereport
(
PANIC
,
(
errmsg
(
"sizeof(ControlFileData) is larger than BLCKSZ; fix either one"
)));
memset
(
buffer
,
0
,
BLCKSZ
);
memset
(
buffer
,
0
,
BLCKSZ
);
memcpy
(
buffer
,
ControlFile
,
sizeof
(
ControlFileData
));
memcpy
(
buffer
,
ControlFile
,
sizeof
(
ControlFileData
));
...
@@ -2125,8 +2178,10 @@ WriteControlFile(void)
...
@@ -2125,8 +2178,10 @@ WriteControlFile(void)
fd
=
BasicOpenFile
(
ControlFilePath
,
O_RDWR
|
O_CREAT
|
O_EXCL
|
PG_BINARY
,
fd
=
BasicOpenFile
(
ControlFilePath
,
O_RDWR
|
O_CREAT
|
O_EXCL
|
PG_BINARY
,
S_IRUSR
|
S_IWUSR
);
S_IRUSR
|
S_IWUSR
);
if
(
fd
<
0
)
if
(
fd
<
0
)
elog
(
PANIC
,
"WriteControlFile: could not create control file (%s): %m"
,
ereport
(
PANIC
,
ControlFilePath
);
(
errcode_for_file_access
(),
errmsg
(
"could not create control file
\"
%s
\"
: %m"
,
ControlFilePath
)));
errno
=
0
;
errno
=
0
;
if
(
write
(
fd
,
buffer
,
BLCKSZ
)
!=
BLCKSZ
)
if
(
write
(
fd
,
buffer
,
BLCKSZ
)
!=
BLCKSZ
)
...
@@ -2134,11 +2189,15 @@ WriteControlFile(void)
...
@@ -2134,11 +2189,15 @@ WriteControlFile(void)
/* if write didn't set errno, assume problem is no disk space */
/* if write didn't set errno, assume problem is no disk space */
if
(
errno
==
0
)
if
(
errno
==
0
)
errno
=
ENOSPC
;
errno
=
ENOSPC
;
elog
(
PANIC
,
"WriteControlFile: write to control file failed: %m"
);
ereport
(
PANIC
,
(
errcode_for_file_access
(),
errmsg
(
"write to control file failed: %m"
)));
}
}
if
(
pg_fsync
(
fd
)
!=
0
)
if
(
pg_fsync
(
fd
)
!=
0
)
elog
(
PANIC
,
"WriteControlFile: fsync of control file failed: %m"
);
ereport
(
PANIC
,
(
errcode_for_file_access
(),
errmsg
(
"fsync of control file failed: %m"
)));
close
(
fd
);
close
(
fd
);
}
}
...
@@ -2154,10 +2213,15 @@ ReadControlFile(void)
...
@@ -2154,10 +2213,15 @@ ReadControlFile(void)
*/
*/
fd
=
BasicOpenFile
(
ControlFilePath
,
O_RDWR
|
PG_BINARY
,
S_IRUSR
|
S_IWUSR
);
fd
=
BasicOpenFile
(
ControlFilePath
,
O_RDWR
|
PG_BINARY
,
S_IRUSR
|
S_IWUSR
);
if
(
fd
<
0
)
if
(
fd
<
0
)
elog
(
PANIC
,
"could not open control file (%s): %m"
,
ControlFilePath
);
ereport
(
PANIC
,
(
errcode_for_file_access
(),
errmsg
(
"could not open control file
\"
%s
\"
: %m"
,
ControlFilePath
)));
if
(
read
(
fd
,
ControlFile
,
sizeof
(
ControlFileData
))
!=
sizeof
(
ControlFileData
))
if
(
read
(
fd
,
ControlFile
,
sizeof
(
ControlFileData
))
!=
sizeof
(
ControlFileData
))
elog
(
PANIC
,
"read from control file failed: %m"
);
ereport
(
PANIC
,
(
errcode_for_file_access
(),
errmsg
(
"read from control file failed: %m"
)));
close
(
fd
);
close
(
fd
);
...
@@ -2168,12 +2232,12 @@ ReadControlFile(void)
...
@@ -2168,12 +2232,12 @@ ReadControlFile(void)
* more enlightening than complaining about wrong CRC.
* more enlightening than complaining about wrong CRC.
*/
*/
if
(
ControlFile
->
pg_control_version
!=
PG_CONTROL_VERSION
)
if
(
ControlFile
->
pg_control_version
!=
PG_CONTROL_VERSION
)
e
log
(
PANIC
,
e
report
(
FATAL
,
"The database cluster was initialized with PG_CONTROL_VERSION %d,
\n
"
(
errmsg
(
"database files are incompatible with server"
),
"
\t
but the server was compiled with PG_CONTROL_VERSION %d.
\n
"
errdetail
(
"The database cluster was initialized with PG_CONTROL_VERSION %d,
"
"
\t
It looks like you need to initdb
."
,
" but the server was compiled with PG_CONTROL_VERSION %d
."
,
ControlFile
->
pg_control_version
,
PG_CONTROL_VERSION
);
ControlFile
->
pg_control_version
,
PG_CONTROL_VERSION
),
errhint
(
"It looks like you need to initdb."
)));
/* Now check the CRC. */
/* Now check the CRC. */
INIT_CRC64
(
crc
);
INIT_CRC64
(
crc
);
COMP_CRC64
(
crc
,
COMP_CRC64
(
crc
,
...
@@ -2182,7 +2246,8 @@ ReadControlFile(void)
...
@@ -2182,7 +2246,8 @@ ReadControlFile(void)
FIN_CRC64
(
crc
);
FIN_CRC64
(
crc
);
if
(
!
EQ_CRC64
(
crc
,
ControlFile
->
crc
))
if
(
!
EQ_CRC64
(
crc
,
ControlFile
->
crc
))
elog
(
PANIC
,
"invalid checksum in control file"
);
ereport
(
FATAL
,
(
errmsg
(
"invalid checksum in control file"
)));
/*
/*
* Do compatibility checking immediately. We do this here for 2
* Do compatibility checking immediately. We do this here for 2
...
@@ -2197,71 +2262,78 @@ ReadControlFile(void)
...
@@ -2197,71 +2262,78 @@ ReadControlFile(void)
* compatibility items because they can affect sort order of indexes.)
* compatibility items because they can affect sort order of indexes.)
*/
*/
if
(
ControlFile
->
catalog_version_no
!=
CATALOG_VERSION_NO
)
if
(
ControlFile
->
catalog_version_no
!=
CATALOG_VERSION_NO
)
elog
(
PANIC
,
ereport
(
FATAL
,
"The database cluster was initialized with CATALOG_VERSION_NO %d,
\n
"
(
errmsg
(
"database files are incompatible with server"
),
"
\t
but the backend was compiled with CATALOG_VERSION_NO %d.
\n
"
errdetail
(
"The database cluster was initialized with CATALOG_VERSION_NO %d,"
"
\t
It looks like you need to initdb."
,
" but the server was compiled with CATALOG_VERSION_NO %d."
,
ControlFile
->
catalog_version_no
,
CATALOG_VERSION_NO
);
ControlFile
->
catalog_version_no
,
CATALOG_VERSION_NO
),
errhint
(
"It looks like you need to initdb."
)));
if
(
ControlFile
->
blcksz
!=
BLCKSZ
)
if
(
ControlFile
->
blcksz
!=
BLCKSZ
)
elog
(
PANIC
,
ereport
(
FATAL
,
"The database cluster was initialized with BLCKSZ %d,
\n
"
(
errmsg
(
"database files are incompatible with server"
),
"
\t
but the backend was compiled with BLCKSZ %d.
\n
"
errdetail
(
"The database cluster was initialized with BLCKSZ %d,"
"
\t
It looks like you need to initdb."
,
" but the server was compiled with BLCKSZ %d."
,
ControlFile
->
blcksz
,
BLCKSZ
);
ControlFile
->
blcksz
,
BLCKSZ
),
errhint
(
"It looks like you need to recompile or initdb."
)));
if
(
ControlFile
->
relseg_size
!=
RELSEG_SIZE
)
if
(
ControlFile
->
relseg_size
!=
RELSEG_SIZE
)
e
log
(
PANIC
,
e
report
(
FATAL
,
"The database cluster was initialized with RELSEG_SIZE %d,
\n
"
(
errmsg
(
"database files are incompatible with server"
),
"
\t
but the backend was compiled with RELSEG_SIZE %d.
\n
"
errdetail
(
"The database cluster was initialized with RELSEG_SIZE %d,
"
"
\t
It looks like you need to recompile or initdb
."
,
" but the server was compiled with RELSEG_SIZE %d
."
,
ControlFile
->
relseg_size
,
RELSEG_SIZE
);
ControlFile
->
relseg_size
,
RELSEG_SIZE
),
errhint
(
"It looks like you need to recompile or initdb."
)));
if
(
ControlFile
->
nameDataLen
!=
NAMEDATALEN
)
if
(
ControlFile
->
nameDataLen
!=
NAMEDATALEN
)
e
log
(
PANIC
,
e
report
(
FATAL
,
"The database cluster was initialized with NAMEDATALEN %d,
\n
"
(
errmsg
(
"database files are incompatible with server"
),
"
\t
but the backend was compiled with NAMEDATALEN %d.
\n
"
errdetail
(
"The database cluster was initialized with NAMEDATALEN %d,
"
"
\t
It looks like you need to recompile or initdb
."
,
" but the server was compiled with NAMEDATALEN %d
."
,
ControlFile
->
nameDataLen
,
NAMEDATALEN
);
ControlFile
->
nameDataLen
,
NAMEDATALEN
),
errhint
(
"It looks like you need to recompile or initdb."
)));
if
(
ControlFile
->
funcMaxArgs
!=
FUNC_MAX_ARGS
)
if
(
ControlFile
->
funcMaxArgs
!=
FUNC_MAX_ARGS
)
elog
(
PANIC
,
ereport
(
FATAL
,
"The database cluster was initialized with FUNC_MAX_ARGS %d,
\n
"
(
errmsg
(
"database files are incompatible with server"
),
"
\t
but the backend was compiled with FUNC_MAX_ARGS %d.
\n
"
errdetail
(
"The database cluster was initialized with FUNC_MAX_ARGS %d,"
"
\t
It looks like you need to recompile or initdb."
,
" but the server was compiled with FUNC_MAX_ARGS %d."
,
ControlFile
->
funcMaxArgs
,
FUNC_MAX_ARGS
);
ControlFile
->
funcMaxArgs
,
FUNC_MAX_ARGS
),
errhint
(
"It looks like you need to recompile or initdb."
)));
#ifdef HAVE_INT64_TIMESTAMP
#ifdef HAVE_INT64_TIMESTAMP
if
(
ControlFile
->
enableIntTimes
!=
TRUE
)
if
(
ControlFile
->
enableIntTimes
!=
TRUE
)
elog
(
PANIC
,
ereport
(
FATAL
,
"The database cluster was initialized without HAVE_INT64_TIMESTAMP
\n
"
(
errmsg
(
"database files are incompatible with server"
),
"
\t
but the backend was compiled with HAVE_INT64_TIMESTAMP.
\n
"
errdetail
(
"The database cluster was initialized without HAVE_INT64_TIMESTAMP"
"
\t
It looks like you need to recompile or initdb."
);
" but the server was compiled with HAVE_INT64_TIMESTAMP."
),
errhint
(
"It looks like you need to recompile or initdb."
)));
#else
#else
if
(
ControlFile
->
enableIntTimes
!=
FALSE
)
if
(
ControlFile
->
enableIntTimes
!=
FALSE
)
elog
(
PANIC
,
ereport
(
FATAL
,
"The database cluster was initialized with HAVE_INT64_TIMESTAMP
\n
"
(
errmsg
(
"database files are incompatible with server"
),
"
\t
but the backend was compiled without HAVE_INT64_TIMESTAMP.
\n
"
errdetail
(
"The database cluster was initialized with HAVE_INT64_TIMESTAMP"
"
\t
It looks like you need to recompile or initdb."
);
" but the server was compiled without HAVE_INT64_TIMESTAMP."
),
errhint
(
"It looks like you need to recompile or initdb."
)));
#endif
#endif
if
(
ControlFile
->
localeBuflen
!=
LOCALE_NAME_BUFLEN
)
if
(
ControlFile
->
localeBuflen
!=
LOCALE_NAME_BUFLEN
)
e
log
(
PANIC
,
e
report
(
FATAL
,
"The database cluster was initialized with LOCALE_NAME_BUFLEN %d,
\n
"
(
errmsg
(
"database files are incompatible with server"
),
"
\t
but the backend was compiled with LOCALE_NAME_BUFLEN %d.
\n
"
errdetail
(
"The database cluster was initialized with LOCALE_NAME_BUFLEN %d,
"
"
\t
It looks like you need to initdb
."
,
" but the server was compiled with LOCALE_NAME_BUFLEN %d
."
,
ControlFile
->
localeBuflen
,
LOCALE_NAME_BUFLEN
);
ControlFile
->
localeBuflen
,
LOCALE_NAME_BUFLEN
),
errhint
(
"It looks like you need to recompile or initdb."
)));
if
(
setlocale
(
LC_COLLATE
,
ControlFile
->
lc_collate
)
==
NULL
)
if
(
setlocale
(
LC_COLLATE
,
ControlFile
->
lc_collate
)
==
NULL
)
elog
(
PANIC
,
ereport
(
FATAL
,
"The database cluster was initialized with LC_COLLATE '%s',
\n
"
(
errmsg
(
"database files are incompatible with operating system"
),
"
\t
which is not recognized by setlocale().
\n
"
errdetail
(
"The database cluster was initialized with LC_COLLATE
\"
%s
\"
,"
"
\t
It looks like you need to initdb."
,
" which is not recognized by setlocale()."
,
ControlFile
->
lc_collate
);
ControlFile
->
lc_collate
),
errhint
(
"It looks like you need to initdb or install locale support."
)));
if
(
setlocale
(
LC_CTYPE
,
ControlFile
->
lc_ctype
)
==
NULL
)
if
(
setlocale
(
LC_CTYPE
,
ControlFile
->
lc_ctype
)
==
NULL
)
elog
(
PANIC
,
ereport
(
FATAL
,
"The database cluster was initialized with LC_CTYPE '%s',
\n
"
(
errmsg
(
"database files are incompatible with operating system"
),
"
\t
which is not recognized by setlocale().
\n
"
errdetail
(
"The database cluster was initialized with LC_CTYPE
\"
%s
\"
,"
"
\t
It looks like you need to initdb."
,
" which is not recognized by setlocale()."
,
ControlFile
->
lc_ctype
);
ControlFile
->
lc_ctype
),
errhint
(
"It looks like you need to initdb or install locale support."
)));
/* Make the fixed locale settings visible as GUC variables, too */
/* Make the fixed locale settings visible as GUC variables, too */
SetConfigOption
(
"lc_collate"
,
ControlFile
->
lc_collate
,
SetConfigOption
(
"lc_collate"
,
ControlFile
->
lc_collate
,
...
@@ -2283,7 +2355,10 @@ UpdateControlFile(void)
...
@@ -2283,7 +2355,10 @@ UpdateControlFile(void)
fd
=
BasicOpenFile
(
ControlFilePath
,
O_RDWR
|
PG_BINARY
,
S_IRUSR
|
S_IWUSR
);
fd
=
BasicOpenFile
(
ControlFilePath
,
O_RDWR
|
PG_BINARY
,
S_IRUSR
|
S_IWUSR
);
if
(
fd
<
0
)
if
(
fd
<
0
)
elog
(
PANIC
,
"could not open control file (%s): %m"
,
ControlFilePath
);
ereport
(
PANIC
,
(
errcode_for_file_access
(),
errmsg
(
"could not open control file
\"
%s
\"
: %m"
,
ControlFilePath
)));
errno
=
0
;
errno
=
0
;
if
(
write
(
fd
,
ControlFile
,
sizeof
(
ControlFileData
))
!=
sizeof
(
ControlFileData
))
if
(
write
(
fd
,
ControlFile
,
sizeof
(
ControlFileData
))
!=
sizeof
(
ControlFileData
))
...
@@ -2291,11 +2366,15 @@ UpdateControlFile(void)
...
@@ -2291,11 +2366,15 @@ UpdateControlFile(void)
/* if write didn't set errno, assume problem is no disk space */
/* if write didn't set errno, assume problem is no disk space */
if
(
errno
==
0
)
if
(
errno
==
0
)
errno
=
ENOSPC
;
errno
=
ENOSPC
;
elog
(
PANIC
,
"write to control file failed: %m"
);
ereport
(
PANIC
,
(
errcode_for_file_access
(),
errmsg
(
"write to control file failed: %m"
)));
}
}
if
(
pg_fsync
(
fd
)
!=
0
)
if
(
pg_fsync
(
fd
)
!=
0
)
elog
(
PANIC
,
"fsync of control file failed: %m"
);
ereport
(
PANIC
,
(
errcode_for_file_access
(),
errmsg
(
"fsync of control file failed: %m"
)));
close
(
fd
);
close
(
fd
);
}
}
...
@@ -2435,11 +2514,15 @@ BootStrapXLOG(void)
...
@@ -2435,11 +2514,15 @@ BootStrapXLOG(void)
/* if write didn't set errno, assume problem is no disk space */
/* if write didn't set errno, assume problem is no disk space */
if
(
errno
==
0
)
if
(
errno
==
0
)
errno
=
ENOSPC
;
errno
=
ENOSPC
;
elog
(
PANIC
,
"BootStrapXLOG failed to write log file: %m"
);
ereport
(
PANIC
,
(
errcode_for_file_access
(),
errmsg
(
"failed to write bootstrap xlog file: %m"
)));
}
}
if
(
pg_fsync
(
openLogFile
)
!=
0
)
if
(
pg_fsync
(
openLogFile
)
!=
0
)
elog
(
PANIC
,
"BootStrapXLOG failed to fsync log file: %m"
);
ereport
(
PANIC
,
(
errcode_for_file_access
(),
errmsg
(
"failed to fsync bootstrap xlog file: %m"
)));
close
(
openLogFile
);
close
(
openLogFile
);
openLogFile
=
-
1
;
openLogFile
=
-
1
;
...
@@ -2506,22 +2589,27 @@ StartupXLOG(void)
...
@@ -2506,22 +2589,27 @@ StartupXLOG(void)
ControlFile
->
state
<
DB_SHUTDOWNED
||
ControlFile
->
state
<
DB_SHUTDOWNED
||
ControlFile
->
state
>
DB_IN_PRODUCTION
||
ControlFile
->
state
>
DB_IN_PRODUCTION
||
!
XRecOffIsValid
(
ControlFile
->
checkPoint
.
xrecoff
))
!
XRecOffIsValid
(
ControlFile
->
checkPoint
.
xrecoff
))
elog
(
PANIC
,
"control file context is broken"
);
ereport
(
FATAL
,
(
errmsg
(
"control file contains invalid data"
)));
if
(
ControlFile
->
state
==
DB_SHUTDOWNED
)
if
(
ControlFile
->
state
==
DB_SHUTDOWNED
)
elog
(
LOG
,
"database system was shut down at %s"
,
ereport
(
LOG
,
str_time
(
ControlFile
->
time
));
(
errmsg
(
"database system was shut down at %s"
,
str_time
(
ControlFile
->
time
))));
else
if
(
ControlFile
->
state
==
DB_SHUTDOWNING
)
else
if
(
ControlFile
->
state
==
DB_SHUTDOWNING
)
elog
(
LOG
,
"database system shutdown was interrupted at %s"
,
ereport
(
LOG
,
str_time
(
ControlFile
->
time
));
(
errmsg
(
"database system shutdown was interrupted at %s"
,
str_time
(
ControlFile
->
time
))));
else
if
(
ControlFile
->
state
==
DB_IN_RECOVERY
)
else
if
(
ControlFile
->
state
==
DB_IN_RECOVERY
)
elog
(
LOG
,
"database system was interrupted being in recovery at %s
\n
"
ereport
(
LOG
,
"
\t
This probably means that some data blocks are corrupted
\n
"
(
errmsg
(
"database system was interrupted while in recovery at %s"
,
"
\t
and you will have to use the last backup for recovery."
,
str_time
(
ControlFile
->
time
)),
str_time
(
ControlFile
->
time
));
errhint
(
"This probably means that some data is corrupted and"
" you will have to use the last backup for recovery."
)));
else
if
(
ControlFile
->
state
==
DB_IN_PRODUCTION
)
else
if
(
ControlFile
->
state
==
DB_IN_PRODUCTION
)
elog
(
LOG
,
"database system was interrupted at %s"
,
ereport
(
LOG
,
str_time
(
ControlFile
->
time
));
(
errmsg
(
"database system was interrupted at %s"
,
str_time
(
ControlFile
->
time
))));
/* This is just to allow attaching to startup process with a debugger */
/* This is just to allow attaching to startup process with a debugger */
#ifdef XLOG_REPLAY_DELAY
#ifdef XLOG_REPLAY_DELAY
...
@@ -2537,8 +2625,9 @@ StartupXLOG(void)
...
@@ -2537,8 +2625,9 @@ StartupXLOG(void)
if
(
record
!=
NULL
)
if
(
record
!=
NULL
)
{
{
checkPointLoc
=
ControlFile
->
checkPoint
;
checkPointLoc
=
ControlFile
->
checkPoint
;
elog
(
LOG
,
"checkpoint record is at %X/%X"
,
ereport
(
LOG
,
checkPointLoc
.
xlogid
,
checkPointLoc
.
xrecoff
);
(
errmsg
(
"checkpoint record is at %X/%X"
,
checkPointLoc
.
xlogid
,
checkPointLoc
.
xrecoff
)));
}
}
else
else
{
{
...
@@ -2546,25 +2635,30 @@ StartupXLOG(void)
...
@@ -2546,25 +2635,30 @@ StartupXLOG(void)
if
(
record
!=
NULL
)
if
(
record
!=
NULL
)
{
{
checkPointLoc
=
ControlFile
->
prevCheckPoint
;
checkPointLoc
=
ControlFile
->
prevCheckPoint
;
elog
(
LOG
,
"using previous checkpoint record at %X/%X"
,
ereport
(
LOG
,
checkPointLoc
.
xlogid
,
checkPointLoc
.
xrecoff
);
(
errmsg
(
"using previous checkpoint record at %X/%X"
,
checkPointLoc
.
xlogid
,
checkPointLoc
.
xrecoff
)));
InRecovery
=
true
;
/* force recovery even if SHUTDOWNED */
InRecovery
=
true
;
/* force recovery even if SHUTDOWNED */
}
}
else
else
elog
(
PANIC
,
"unable to locate a valid checkpoint record"
);
ereport
(
PANIC
,
(
errmsg
(
"unable to locate a valid checkpoint record"
)));
}
}
LastRec
=
RecPtr
=
checkPointLoc
;
LastRec
=
RecPtr
=
checkPointLoc
;
memcpy
(
&
checkPoint
,
XLogRecGetData
(
record
),
sizeof
(
CheckPoint
));
memcpy
(
&
checkPoint
,
XLogRecGetData
(
record
),
sizeof
(
CheckPoint
));
wasShutdown
=
(
record
->
xl_info
==
XLOG_CHECKPOINT_SHUTDOWN
);
wasShutdown
=
(
record
->
xl_info
==
XLOG_CHECKPOINT_SHUTDOWN
);
elog
(
LOG
,
"redo record is at %X/%X; undo record is at %X/%X; shutdown %s"
,
ereport
(
LOG
,
checkPoint
.
redo
.
xlogid
,
checkPoint
.
redo
.
xrecoff
,
(
errmsg
(
"redo record is at %X/%X; undo record is at %X/%X; shutdown %s"
,
checkPoint
.
undo
.
xlogid
,
checkPoint
.
undo
.
xrecoff
,
checkPoint
.
redo
.
xlogid
,
checkPoint
.
redo
.
xrecoff
,
wasShutdown
?
"TRUE"
:
"FALSE"
);
checkPoint
.
undo
.
xlogid
,
checkPoint
.
undo
.
xrecoff
,
elog
(
LOG
,
"next transaction id: %u; next oid: %u"
,
wasShutdown
?
"TRUE"
:
"FALSE"
)));
checkPoint
.
nextXid
,
checkPoint
.
nextOid
);
ereport
(
LOG
,
(
errmsg
(
"next transaction id: %u; next oid: %u"
,
checkPoint
.
nextXid
,
checkPoint
.
nextOid
)));
if
(
!
TransactionIdIsNormal
(
checkPoint
.
nextXid
))
if
(
!
TransactionIdIsNormal
(
checkPoint
.
nextXid
))
elog
(
PANIC
,
"invalid next transaction id"
);
ereport
(
PANIC
,
(
errmsg
(
"invalid next transaction id"
)));
ShmemVariableCache
->
nextXid
=
checkPoint
.
nextXid
;
ShmemVariableCache
->
nextXid
=
checkPoint
.
nextXid
;
ShmemVariableCache
->
nextOid
=
checkPoint
.
nextOid
;
ShmemVariableCache
->
nextOid
=
checkPoint
.
nextOid
;
...
@@ -2586,7 +2680,8 @@ StartupXLOG(void)
...
@@ -2586,7 +2680,8 @@ StartupXLOG(void)
XLogCtl
->
SavedRedoRecPtr
=
checkPoint
.
redo
;
XLogCtl
->
SavedRedoRecPtr
=
checkPoint
.
redo
;
if
(
XLByteLT
(
RecPtr
,
checkPoint
.
redo
))
if
(
XLByteLT
(
RecPtr
,
checkPoint
.
redo
))
elog
(
PANIC
,
"invalid redo in checkpoint record"
);
ereport
(
PANIC
,
(
errmsg
(
"invalid redo in checkpoint record"
)));
if
(
checkPoint
.
undo
.
xrecoff
==
0
)
if
(
checkPoint
.
undo
.
xrecoff
==
0
)
checkPoint
.
undo
=
RecPtr
;
checkPoint
.
undo
=
RecPtr
;
...
@@ -2594,7 +2689,8 @@ StartupXLOG(void)
...
@@ -2594,7 +2689,8 @@ StartupXLOG(void)
XLByteLT
(
checkPoint
.
redo
,
RecPtr
))
XLByteLT
(
checkPoint
.
redo
,
RecPtr
))
{
{
if
(
wasShutdown
)
if
(
wasShutdown
)
elog
(
PANIC
,
"invalid redo/undo record in shutdown checkpoint"
);
ereport
(
PANIC
,
(
errmsg
(
"invalid redo/undo record in shutdown checkpoint"
)));
InRecovery
=
true
;
InRecovery
=
true
;
}
}
else
if
(
ControlFile
->
state
!=
DB_SHUTDOWNED
)
else
if
(
ControlFile
->
state
!=
DB_SHUTDOWNED
)
...
@@ -2605,8 +2701,9 @@ StartupXLOG(void)
...
@@ -2605,8 +2701,9 @@ StartupXLOG(void)
{
{
int
rmid
;
int
rmid
;
elog
(
LOG
,
"database system was not properly shut down; "
ereport
(
LOG
,
"automatic recovery in progress"
);
(
errmsg
(
"database system was not properly shut down; "
"automatic recovery in progress"
)));
ControlFile
->
state
=
DB_IN_RECOVERY
;
ControlFile
->
state
=
DB_IN_RECOVERY
;
ControlFile
->
time
=
time
(
NULL
);
ControlFile
->
time
=
time
(
NULL
);
UpdateControlFile
();
UpdateControlFile
();
...
@@ -2632,8 +2729,9 @@ StartupXLOG(void)
...
@@ -2632,8 +2729,9 @@ StartupXLOG(void)
if
(
record
!=
NULL
)
if
(
record
!=
NULL
)
{
{
InRedo
=
true
;
InRedo
=
true
;
elog
(
LOG
,
"redo starts at %X/%X"
,
ereport
(
LOG
,
ReadRecPtr
.
xlogid
,
ReadRecPtr
.
xrecoff
);
(
errmsg
(
"redo starts at %X/%X"
,
ReadRecPtr
.
xlogid
,
ReadRecPtr
.
xrecoff
)));
do
do
{
{
/* nextXid must be beyond record's xid */
/* nextXid must be beyond record's xid */
...
@@ -2663,13 +2761,15 @@ StartupXLOG(void)
...
@@ -2663,13 +2761,15 @@ StartupXLOG(void)
RmgrTable
[
record
->
xl_rmid
].
rm_redo
(
EndRecPtr
,
record
);
RmgrTable
[
record
->
xl_rmid
].
rm_redo
(
EndRecPtr
,
record
);
record
=
ReadRecord
(
NULL
,
LOG
,
buffer
);
record
=
ReadRecord
(
NULL
,
LOG
,
buffer
);
}
while
(
record
!=
NULL
);
}
while
(
record
!=
NULL
);
elog
(
LOG
,
"redo done at %X/%X"
,
ereport
(
LOG
,
ReadRecPtr
.
xlogid
,
ReadRecPtr
.
xrecoff
);
(
errmsg
(
"redo done at %X/%X"
,
ReadRecPtr
.
xlogid
,
ReadRecPtr
.
xrecoff
)));
LastRec
=
ReadRecPtr
;
LastRec
=
ReadRecPtr
;
InRedo
=
false
;
InRedo
=
false
;
}
}
else
else
elog
(
LOG
,
"redo is not required"
);
ereport
(
LOG
,
(
errmsg
(
"redo is not required"
)));
}
}
/*
/*
...
@@ -2736,8 +2836,9 @@ StartupXLOG(void)
...
@@ -2736,8 +2836,9 @@ StartupXLOG(void)
RecPtr
=
ReadRecPtr
;
RecPtr
=
ReadRecPtr
;
if
(
XLByteLT
(
checkPoint
.
undo
,
RecPtr
))
if
(
XLByteLT
(
checkPoint
.
undo
,
RecPtr
))
{
{
elog
(
LOG
,
"undo starts at %X/%X"
,
ereport
(
LOG
,
RecPtr
.
xlogid
,
RecPtr
.
xrecoff
);
(
errmsg
(
"undo starts at %X/%X"
,
RecPtr
.
xlogid
,
RecPtr
.
xrecoff
)));
do
do
{
{
record
=
ReadRecord
(
&
RecPtr
,
PANIC
,
buffer
);
record
=
ReadRecord
(
&
RecPtr
,
PANIC
,
buffer
);
...
@@ -2746,11 +2847,13 @@ StartupXLOG(void)
...
@@ -2746,11 +2847,13 @@ StartupXLOG(void)
RmgrTable
[
record
->
xl_rmid
].
rm_undo
(
EndRecPtr
,
record
);
RmgrTable
[
record
->
xl_rmid
].
rm_undo
(
EndRecPtr
,
record
);
RecPtr
=
record
->
xl_prev
;
RecPtr
=
record
->
xl_prev
;
}
while
(
XLByteLE
(
checkPoint
.
undo
,
RecPtr
));
}
while
(
XLByteLE
(
checkPoint
.
undo
,
RecPtr
));
elog
(
LOG
,
"undo done at %X/%X"
,
ereport
(
LOG
,
ReadRecPtr
.
xlogid
,
ReadRecPtr
.
xrecoff
);
(
errmsg
(
"undo done at %X/%X"
,
ReadRecPtr
.
xlogid
,
ReadRecPtr
.
xrecoff
)));
}
}
else
else
elog
(
LOG
,
"undo is not required"
);
ereport
(
LOG
,
(
errmsg
(
"undo is not required"
)));
}
}
#endif
#endif
...
@@ -2837,7 +2940,8 @@ StartupXLOG(void)
...
@@ -2837,7 +2940,8 @@ StartupXLOG(void)
/* Start up the commit log, too */
/* Start up the commit log, too */
StartupCLOG
();
StartupCLOG
();
elog
(
LOG
,
"database system is ready"
);
ereport
(
LOG
,
(
errmsg
(
"database system is ready"
)));
CritSectionCount
--
;
CritSectionCount
--
;
/* Shut down readFile facility, free space */
/* Shut down readFile facility, free space */
...
@@ -2868,9 +2972,10 @@ ReadCheckpointRecord(XLogRecPtr RecPtr,
...
@@ -2868,9 +2972,10 @@ ReadCheckpointRecord(XLogRecPtr RecPtr,
if
(
!
XRecOffIsValid
(
RecPtr
.
xrecoff
))
if
(
!
XRecOffIsValid
(
RecPtr
.
xrecoff
))
{
{
elog
(
LOG
,
(
whichChkpt
==
1
?
ereport
(
LOG
,
"invalid primary checkpoint link in control file"
:
/* translator: %s is "primary" or "secondary" */
"invalid secondary checkpoint link in control file"
));
(
errmsg
(
"invalid %s checkpoint link in control file"
,
(
whichChkpt
==
1
)
?
gettext
(
"primary"
)
:
gettext
(
"secondary"
))));
return
NULL
;
return
NULL
;
}
}
...
@@ -2878,31 +2983,35 @@ ReadCheckpointRecord(XLogRecPtr RecPtr,
...
@@ -2878,31 +2983,35 @@ ReadCheckpointRecord(XLogRecPtr RecPtr,
if
(
record
==
NULL
)
if
(
record
==
NULL
)
{
{
elog
(
LOG
,
(
whichChkpt
==
1
?
ereport
(
LOG
,
"invalid primary checkpoint record"
:
/* translator: %s is "primary" or "secondary" */
"invalid secondary checkpoint record"
));
(
errmsg
(
"invalid %s checkpoint record"
,
(
whichChkpt
==
1
)
?
gettext
(
"primary"
)
:
gettext
(
"secondary"
))));
return
NULL
;
return
NULL
;
}
}
if
(
record
->
xl_rmid
!=
RM_XLOG_ID
)
if
(
record
->
xl_rmid
!=
RM_XLOG_ID
)
{
{
elog
(
LOG
,
(
whichChkpt
==
1
?
ereport
(
LOG
,
"invalid resource manager id in primary checkpoint record"
:
/* translator: %s is "primary" or "secondary" */
"invalid resource manager id in secondary checkpoint record"
));
(
errmsg
(
"invalid resource manager id in %s checkpoint record"
,
(
whichChkpt
==
1
)
?
gettext
(
"primary"
)
:
gettext
(
"secondary"
))));
return
NULL
;
return
NULL
;
}
}
if
(
record
->
xl_info
!=
XLOG_CHECKPOINT_SHUTDOWN
&&
if
(
record
->
xl_info
!=
XLOG_CHECKPOINT_SHUTDOWN
&&
record
->
xl_info
!=
XLOG_CHECKPOINT_ONLINE
)
record
->
xl_info
!=
XLOG_CHECKPOINT_ONLINE
)
{
{
elog
(
LOG
,
(
whichChkpt
==
1
?
ereport
(
LOG
,
"invalid xl_info in primary checkpoint record"
:
/* translator: %s is "primary" or "secondary" */
"invalid xl_info in secondary checkpoint record"
));
(
errmsg
(
"invalid xl_info in %s checkpoint record"
,
(
whichChkpt
==
1
)
?
gettext
(
"primary"
)
:
gettext
(
"secondary"
))));
return
NULL
;
return
NULL
;
}
}
if
(
record
->
xl_len
!=
sizeof
(
CheckPoint
))
if
(
record
->
xl_len
!=
sizeof
(
CheckPoint
))
{
{
elog
(
LOG
,
(
whichChkpt
==
1
?
ereport
(
LOG
,
"invalid length of primary checkpoint record"
:
/* translator: %s is "primary" or "secondary" */
"invalid length of secondary checkpoint record"
));
(
errmsg
(
"invalid length of %s checkpoint record"
,
(
whichChkpt
==
1
)
?
gettext
(
"primary"
)
:
gettext
(
"secondary"
))));
return
NULL
;
return
NULL
;
}
}
return
record
;
return
record
;
...
@@ -2965,7 +3074,8 @@ GetRedoRecPtr(void)
...
@@ -2965,7 +3074,8 @@ GetRedoRecPtr(void)
void
void
ShutdownXLOG
(
void
)
ShutdownXLOG
(
void
)
{
{
elog
(
LOG
,
"shutting down"
);
ereport
(
LOG
,
(
errmsg
(
"shutting down"
)));
/* suppress in-transaction check in CreateCheckPoint */
/* suppress in-transaction check in CreateCheckPoint */
MyLastRecPtr
.
xrecoff
=
0
;
MyLastRecPtr
.
xrecoff
=
0
;
...
@@ -2978,7 +3088,8 @@ ShutdownXLOG(void)
...
@@ -2978,7 +3088,8 @@ ShutdownXLOG(void)
ShutdownCLOG
();
ShutdownCLOG
();
CritSectionCount
--
;
CritSectionCount
--
;
elog
(
LOG
,
"database system is shut down"
);
ereport
(
LOG
,
(
errmsg
(
"database system is shut down"
)));
}
}
/*
/*
...
@@ -2999,7 +3110,9 @@ CreateCheckPoint(bool shutdown, bool force)
...
@@ -2999,7 +3110,9 @@ CreateCheckPoint(bool shutdown, bool force)
uint32
_logSeg
;
uint32
_logSeg
;
if
(
MyXactMadeXLogEntry
)
if
(
MyXactMadeXLogEntry
)
elog
(
ERROR
,
"CreateCheckPoint: cannot be called inside transaction block"
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_ACTIVE_SQL_TRANSACTION
),
errmsg
(
"checkpoint cannot be made inside transaction block"
)));
/*
/*
* Acquire CheckpointLock to ensure only one checkpoint happens at a time.
* Acquire CheckpointLock to ensure only one checkpoint happens at a time.
...
@@ -3183,7 +3296,8 @@ CreateCheckPoint(bool shutdown, bool force)
...
@@ -3183,7 +3296,8 @@ CreateCheckPoint(bool shutdown, bool force)
* recptr = end of actual checkpoint record.
* recptr = end of actual checkpoint record.
*/
*/
if
(
shutdown
&&
!
XLByteEQ
(
checkPoint
.
redo
,
ProcLastRecPtr
))
if
(
shutdown
&&
!
XLByteEQ
(
checkPoint
.
redo
,
ProcLastRecPtr
))
elog
(
PANIC
,
"concurrent transaction log activity while database system is shutting down"
);
ereport
(
PANIC
,
(
errmsg
(
"concurrent transaction log activity while database system is shutting down"
)));
/*
/*
* Select point at which we can truncate the log, which we base on the
* Select point at which we can truncate the log, which we base on the
...
@@ -3422,13 +3536,17 @@ assign_xlog_sync_method(const char *method, bool doit, bool interactive)
...
@@ -3422,13 +3536,17 @@ assign_xlog_sync_method(const char *method, bool doit, bool interactive)
if
(
openLogFile
>=
0
)
if
(
openLogFile
>=
0
)
{
{
if
(
pg_fsync
(
openLogFile
)
!=
0
)
if
(
pg_fsync
(
openLogFile
)
!=
0
)
elog
(
PANIC
,
"fsync of log file %u, segment %u failed: %m"
,
ereport
(
PANIC
,
openLogId
,
openLogSeg
);
(
errcode_for_file_access
(),
errmsg
(
"fsync of log file %u, segment %u failed: %m"
,
openLogId
,
openLogSeg
)));
if
(
open_sync_bit
!=
new_sync_bit
)
if
(
open_sync_bit
!=
new_sync_bit
)
{
{
if
(
close
(
openLogFile
)
!=
0
)
if
(
close
(
openLogFile
)
!=
0
)
elog
(
PANIC
,
"close of log file %u, segment %u failed: %m"
,
ereport
(
PANIC
,
openLogId
,
openLogSeg
);
(
errcode_for_file_access
(),
errmsg
(
"close of log file %u, segment %u failed: %m"
,
openLogId
,
openLogSeg
)));
openLogFile
=
-
1
;
openLogFile
=
-
1
;
}
}
}
}
...
@@ -3450,21 +3568,25 @@ issue_xlog_fsync(void)
...
@@ -3450,21 +3568,25 @@ issue_xlog_fsync(void)
{
{
case
SYNC_METHOD_FSYNC
:
case
SYNC_METHOD_FSYNC
:
if
(
pg_fsync
(
openLogFile
)
!=
0
)
if
(
pg_fsync
(
openLogFile
)
!=
0
)
elog
(
PANIC
,
"fsync of log file %u, segment %u failed: %m"
,
ereport
(
PANIC
,
openLogId
,
openLogSeg
);
(
errcode_for_file_access
(),
errmsg
(
"fsync of log file %u, segment %u failed: %m"
,
openLogId
,
openLogSeg
)));
break
;
break
;
#ifdef HAVE_FDATASYNC
#ifdef HAVE_FDATASYNC
case
SYNC_METHOD_FDATASYNC
:
case
SYNC_METHOD_FDATASYNC
:
if
(
pg_fdatasync
(
openLogFile
)
!=
0
)
if
(
pg_fdatasync
(
openLogFile
)
!=
0
)
elog
(
PANIC
,
"fdatasync of log file %u, segment %u failed: %m"
,
ereport
(
PANIC
,
openLogId
,
openLogSeg
);
(
errcode_for_file_access
(),
errmsg
(
"fdatasync of log file %u, segment %u failed: %m"
,
openLogId
,
openLogSeg
)));
break
;
break
;
#endif
#endif
case
SYNC_METHOD_OPEN
:
case
SYNC_METHOD_OPEN
:
/* write synced it already */
/* write synced it already */
break
;
break
;
default:
default:
elog
(
PANIC
,
"
bogus wal_sync_method
%d"
,
sync_method
);
elog
(
PANIC
,
"
unrecognized wal_sync_method:
%d"
,
sync_method
);
break
;
break
;
}
}
}
}
src/include/utils/elog.h
View file @
ec7aa4b5
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: elog.h,v 1.5
2 2003/07/21 17:05:11
tgl Exp $
* $Id: elog.h,v 1.5
3 2003/07/21 20:29:39
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -177,6 +177,7 @@
...
@@ -177,6 +177,7 @@
#define ERRCODE_NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION MAKE_SQLSTATE('2','5', '0','0','5')
#define ERRCODE_NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION MAKE_SQLSTATE('2','5', '0','0','5')
#define ERRCODE_READ_ONLY_SQL_TRANSACTION MAKE_SQLSTATE('2','5', '0','0','6')
#define ERRCODE_READ_ONLY_SQL_TRANSACTION MAKE_SQLSTATE('2','5', '0','0','6')
#define ERRCODE_SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED MAKE_SQLSTATE('2','5', '0','0','7')
#define ERRCODE_SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED MAKE_SQLSTATE('2','5', '0','0','7')
#define ERRCODE_NO_ACTIVE_SQL_TRANSACTION MAKE_SQLSTATE('2','5', 'P','0','1')
/* Class 26 - Invalid SQL Statement Name */
/* Class 26 - Invalid SQL Statement Name */
/* (we take this to mean prepared statements) */
/* (we take this to mean prepared statements) */
...
@@ -308,6 +309,7 @@
...
@@ -308,6 +309,7 @@
#define ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE MAKE_SQLSTATE('5','5', '0','0','0')
#define ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE MAKE_SQLSTATE('5','5', '0','0','0')
#define ERRCODE_OBJECT_IN_USE MAKE_SQLSTATE('5','5', '0','0','6')
#define ERRCODE_OBJECT_IN_USE MAKE_SQLSTATE('5','5', '0','0','6')
#define ERRCODE_INDEXES_DEACTIVATED MAKE_SQLSTATE('5','5', 'P','0','1')
#define ERRCODE_INDEXES_DEACTIVATED MAKE_SQLSTATE('5','5', 'P','0','1')
#define ERRCODE_INDEX_CORRUPTED MAKE_SQLSTATE('5','5', 'P','0','2')
/* Class 57 - Operator Intervention (class borrowed from DB2) */
/* Class 57 - Operator Intervention (class borrowed from DB2) */
#define ERRCODE_OPERATOR_INTERVENTION MAKE_SQLSTATE('5','7', '0','0','0')
#define ERRCODE_OPERATOR_INTERVENTION MAKE_SQLSTATE('5','7', '0','0','0')
...
...
src/test/regress/expected/alter_table.out
View file @
ec7aa4b5
...
@@ -475,7 +475,7 @@ NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "atacc_test1" for t
...
@@ -475,7 +475,7 @@ NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "atacc_test1" for t
insert into atacc1 (test) values (2);
insert into atacc1 (test) values (2);
-- should fail
-- should fail
insert into atacc1 (test) values (2);
insert into atacc1 (test) values (2);
ERROR:
Cannot insert a duplicate key into unique index atacc_test1
ERROR:
duplicate key violates UNIQUE constraint "atacc_test1"
-- should succeed
-- should succeed
insert into atacc1 (test) values (4);
insert into atacc1 (test) values (4);
-- try adding a unique oid constraint
-- try adding a unique oid constraint
...
@@ -509,7 +509,7 @@ NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "atacc_test1" for t
...
@@ -509,7 +509,7 @@ NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "atacc_test1" for t
insert into atacc1 (test,test2) values (4,4);
insert into atacc1 (test,test2) values (4,4);
-- should fail
-- should fail
insert into atacc1 (test,test2) values (4,4);
insert into atacc1 (test,test2) values (4,4);
ERROR:
Cannot insert a duplicate key into unique index atacc_test1
ERROR:
duplicate key violates UNIQUE constraint "atacc_test1"
-- should all succeed
-- should all succeed
insert into atacc1 (test,test2) values (4,5);
insert into atacc1 (test,test2) values (4,5);
insert into atacc1 (test,test2) values (5,4);
insert into atacc1 (test,test2) values (5,4);
...
@@ -523,7 +523,7 @@ NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "atacc1_test2_key"
...
@@ -523,7 +523,7 @@ NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "atacc1_test2_key"
-- should fail for @@ second one @@
-- should fail for @@ second one @@
insert into atacc1 (test2, test) values (3, 3);
insert into atacc1 (test2, test) values (3, 3);
insert into atacc1 (test2, test) values (2, 3);
insert into atacc1 (test2, test) values (2, 3);
ERROR:
Cannot insert a duplicate key into unique index atacc1_test_key
ERROR:
duplicate key violates UNIQUE constraint "atacc1_test_key"
drop table atacc1;
drop table atacc1;
-- test primary key constraint adding
-- test primary key constraint adding
create table atacc1 ( test int );
create table atacc1 ( test int );
...
@@ -534,7 +534,7 @@ NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "atacc_test1"
...
@@ -534,7 +534,7 @@ NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "atacc_test1"
insert into atacc1 (test) values (2);
insert into atacc1 (test) values (2);
-- should fail
-- should fail
insert into atacc1 (test) values (2);
insert into atacc1 (test) values (2);
ERROR:
Cannot insert a duplicate key into unique index atacc_test1
ERROR:
duplicate key violates UNIQUE constraint "atacc_test1"
-- should succeed
-- should succeed
insert into atacc1 (test) values (4);
insert into atacc1 (test) values (4);
-- inserting NULL should fail
-- inserting NULL should fail
...
@@ -589,7 +589,7 @@ ERROR: multiple primary keys for table "atacc1" are not allowed
...
@@ -589,7 +589,7 @@ ERROR: multiple primary keys for table "atacc1" are not allowed
insert into atacc1 (test,test2) values (4,4);
insert into atacc1 (test,test2) values (4,4);
-- should fail
-- should fail
insert into atacc1 (test,test2) values (4,4);
insert into atacc1 (test,test2) values (4,4);
ERROR:
Cannot insert a duplicate key into unique index atacc_test1
ERROR:
duplicate key violates UNIQUE constraint "atacc_test1"
insert into atacc1 (test,test2) values (NULL,3);
insert into atacc1 (test,test2) values (NULL,3);
ERROR: null value for attribute "test" violates NOT NULL constraint
ERROR: null value for attribute "test" violates NOT NULL constraint
insert into atacc1 (test,test2) values (3, NULL);
insert into atacc1 (test,test2) values (3, NULL);
...
@@ -607,7 +607,7 @@ NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "atacc1_pkey" for
...
@@ -607,7 +607,7 @@ NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "atacc1_pkey" for
-- only first should succeed
-- only first should succeed
insert into atacc1 (test2, test) values (3, 3);
insert into atacc1 (test2, test) values (3, 3);
insert into atacc1 (test2, test) values (2, 3);
insert into atacc1 (test2, test) values (2, 3);
ERROR:
Cannot insert a duplicate key into unique index atacc1_pkey
ERROR:
duplicate key violates UNIQUE constraint "atacc1_pkey"
insert into atacc1 (test2, test) values (1, NULL);
insert into atacc1 (test2, test) values (1, NULL);
ERROR: null value for attribute "test" violates NOT NULL constraint
ERROR: null value for attribute "test" violates NOT NULL constraint
drop table atacc1;
drop table atacc1;
...
...
src/test/regress/expected/arrays.out
View file @
ec7aa4b5
...
@@ -363,7 +363,7 @@ insert into arr_tbl values ('{1,2,3}');
...
@@ -363,7 +363,7 @@ insert into arr_tbl values ('{1,2,3}');
insert into arr_tbl values ('{1,2}');
insert into arr_tbl values ('{1,2}');
-- failure expected:
-- failure expected:
insert into arr_tbl values ('{1,2,3}');
insert into arr_tbl values ('{1,2,3}');
ERROR:
Cannot insert a duplicate key into unique index arr_tbl_f1_key
ERROR:
duplicate key violates UNIQUE constraint "arr_tbl_f1_key"
insert into arr_tbl values ('{2,3,4}');
insert into arr_tbl values ('{2,3,4}');
insert into arr_tbl values ('{1,5,3}');
insert into arr_tbl values ('{1,5,3}');
insert into arr_tbl values ('{1,2,10}');
insert into arr_tbl values ('{1,2,10}');
...
...
src/test/regress/expected/create_index.out
View file @
ec7aa4b5
...
@@ -78,7 +78,7 @@ INSERT INTO func_index_heap VALUES('AB','CDEFG');
...
@@ -78,7 +78,7 @@ INSERT INTO func_index_heap VALUES('AB','CDEFG');
INSERT INTO func_index_heap VALUES('QWE','RTY');
INSERT INTO func_index_heap VALUES('QWE','RTY');
-- this should fail because of unique index:
-- this should fail because of unique index:
INSERT INTO func_index_heap VALUES('ABCD', 'EF');
INSERT INTO func_index_heap VALUES('ABCD', 'EF');
ERROR:
Cannot insert a duplicate key into unique index func_index_index
ERROR:
duplicate key violates UNIQUE constraint "func_index_index"
-- but this shouldn't:
-- but this shouldn't:
INSERT INTO func_index_heap VALUES('QWERTY');
INSERT INTO func_index_heap VALUES('QWERTY');
--
--
...
@@ -92,7 +92,7 @@ INSERT INTO func_index_heap VALUES('AB','CDEFG');
...
@@ -92,7 +92,7 @@ INSERT INTO func_index_heap VALUES('AB','CDEFG');
INSERT INTO func_index_heap VALUES('QWE','RTY');
INSERT INTO func_index_heap VALUES('QWE','RTY');
-- this should fail because of unique index:
-- this should fail because of unique index:
INSERT INTO func_index_heap VALUES('ABCD', 'EF');
INSERT INTO func_index_heap VALUES('ABCD', 'EF');
ERROR:
Cannot insert a duplicate key into unique index func_index_index
ERROR:
duplicate key violates UNIQUE constraint "func_index_index"
-- but this shouldn't:
-- but this shouldn't:
INSERT INTO func_index_heap VALUES('QWERTY');
INSERT INTO func_index_heap VALUES('QWERTY');
--
--
...
...
src/test/regress/expected/errors.out
View file @
ec7aa4b5
...
@@ -99,10 +99,10 @@ ERROR: attribute "oid" of relation "stud_emp" already exists
...
@@ -99,10 +99,10 @@ ERROR: attribute "oid" of relation "stud_emp" already exists
-- not in a xact
-- not in a xact
abort;
abort;
WARNING:
ROLLBACK:
no transaction in progress
WARNING:
there is
no transaction in progress
-- not in a xact
-- not in a xact
end;
end;
WARNING:
COMMIT:
no transaction in progress
WARNING:
there is
no transaction in progress
--
--
-- CREATE AGGREGATE
-- CREATE AGGREGATE
-- sfunc/finalfunc type disagreement
-- sfunc/finalfunc type disagreement
...
...
src/test/regress/expected/plpgsql.out
View file @
ec7aa4b5
...
@@ -1515,7 +1515,7 @@ select * from PField_v1 where pfname = 'PF0_2' order by slotname;
...
@@ -1515,7 +1515,7 @@ select * from PField_v1 where pfname = 'PF0_2' order by slotname;
-- Finally we want errors
-- Finally we want errors
--
--
insert into PField values ('PF1_1', 'should fail due to unique index');
insert into PField values ('PF1_1', 'should fail due to unique index');
ERROR:
Cannot insert a duplicate key into unique index pfield_name
ERROR:
duplicate key violates UNIQUE constraint "pfield_name"
update PSlot set backlink = 'WS.not.there' where slotname = 'PS.base.a1';
update PSlot set backlink = 'WS.not.there' where slotname = 'PS.base.a1';
ERROR: WS.not.there does not exist
ERROR: WS.not.there does not exist
CONTEXT: PL/pgSQL function tg_backlink_a line 16 at assignment
CONTEXT: PL/pgSQL function tg_backlink_a line 16 at assignment
...
@@ -1529,7 +1529,7 @@ update PSlot set slotlink = 'XX.illegal' where slotname = 'PS.base.a1';
...
@@ -1529,7 +1529,7 @@ update PSlot set slotlink = 'XX.illegal' where slotname = 'PS.base.a1';
ERROR: illegal slotlink beginning with XX
ERROR: illegal slotlink beginning with XX
CONTEXT: PL/pgSQL function tg_slotlink_a line 16 at assignment
CONTEXT: PL/pgSQL function tg_slotlink_a line 16 at assignment
insert into HSlot values ('HS', 'base.hub1', 1, '');
insert into HSlot values ('HS', 'base.hub1', 1, '');
ERROR:
Cannot insert a duplicate key into unique index hslot_name
ERROR:
duplicate key violates UNIQUE constraint "hslot_name"
insert into HSlot values ('HS', 'base.hub1', 20, '');
insert into HSlot values ('HS', 'base.hub1', 20, '');
ERROR: no manual manipulation of HSlot
ERROR: no manual manipulation of HSlot
delete from HSlot;
delete from HSlot;
...
...
src/test/regress/output/constraints.source
View file @
ec7aa4b5
...
@@ -290,7 +290,7 @@ NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "primary_tbl_pkey
...
@@ -290,7 +290,7 @@ NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "primary_tbl_pkey
INSERT INTO PRIMARY_TBL VALUES (1, 'one');
INSERT INTO PRIMARY_TBL VALUES (1, 'one');
INSERT INTO PRIMARY_TBL VALUES (2, 'two');
INSERT INTO PRIMARY_TBL VALUES (2, 'two');
INSERT INTO PRIMARY_TBL VALUES (1, 'three');
INSERT INTO PRIMARY_TBL VALUES (1, 'three');
ERROR:
Cannot insert a duplicate key into unique index primary_tbl_pkey
ERROR:
duplicate key violates UNIQUE constraint "primary_tbl_pkey"
INSERT INTO PRIMARY_TBL VALUES (4, 'three');
INSERT INTO PRIMARY_TBL VALUES (4, 'three');
INSERT INTO PRIMARY_TBL VALUES (5, 'one');
INSERT INTO PRIMARY_TBL VALUES (5, 'one');
INSERT INTO PRIMARY_TBL (t) VALUES ('six');
INSERT INTO PRIMARY_TBL (t) VALUES ('six');
...
@@ -334,7 +334,7 @@ NOTICE: CREATE TABLE / UNIQUE will create implicit index "unique_tbl_i_key" for
...
@@ -334,7 +334,7 @@ NOTICE: CREATE TABLE / UNIQUE will create implicit index "unique_tbl_i_key" for
INSERT INTO UNIQUE_TBL VALUES (1, 'one');
INSERT INTO UNIQUE_TBL VALUES (1, 'one');
INSERT INTO UNIQUE_TBL VALUES (2, 'two');
INSERT INTO UNIQUE_TBL VALUES (2, 'two');
INSERT INTO UNIQUE_TBL VALUES (1, 'three');
INSERT INTO UNIQUE_TBL VALUES (1, 'three');
ERROR:
Cannot insert a duplicate key into unique index unique_tbl_i_key
ERROR:
duplicate key violates UNIQUE constraint "unique_tbl_i_key"
INSERT INTO UNIQUE_TBL VALUES (4, 'four');
INSERT INTO UNIQUE_TBL VALUES (4, 'four');
INSERT INTO UNIQUE_TBL VALUES (5, 'one');
INSERT INTO UNIQUE_TBL VALUES (5, 'one');
INSERT INTO UNIQUE_TBL (t) VALUES ('six');
INSERT INTO UNIQUE_TBL (t) VALUES ('six');
...
@@ -358,7 +358,7 @@ INSERT INTO UNIQUE_TBL VALUES (1, 'one');
...
@@ -358,7 +358,7 @@ INSERT INTO UNIQUE_TBL VALUES (1, 'one');
INSERT INTO UNIQUE_TBL VALUES (2, 'two');
INSERT INTO UNIQUE_TBL VALUES (2, 'two');
INSERT INTO UNIQUE_TBL VALUES (1, 'three');
INSERT INTO UNIQUE_TBL VALUES (1, 'three');
INSERT INTO UNIQUE_TBL VALUES (1, 'one');
INSERT INTO UNIQUE_TBL VALUES (1, 'one');
ERROR:
Cannot insert a duplicate key into unique index unique_tbl_i_key
ERROR:
duplicate key violates UNIQUE constraint "unique_tbl_i_key"
INSERT INTO UNIQUE_TBL VALUES (5, 'one');
INSERT INTO UNIQUE_TBL VALUES (5, 'one');
INSERT INTO UNIQUE_TBL (t) VALUES ('six');
INSERT INTO UNIQUE_TBL (t) VALUES ('six');
SELECT '' AS five, * FROM UNIQUE_TBL;
SELECT '' AS five, * FROM UNIQUE_TBL;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment