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
Expand all
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
This diff is collapsed.
Click to expand it.
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
This diff is collapsed.
Click to expand it.
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