Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb60acaf

Browse files
committed
The following small patch provides a couple of minor updates (against
CVS HEAD):Amended "strings" regression test. TOAST tests now insert two valueswith storage set to "external", to exercise properly the TOAST sliceroutines which fetch only a subset of the chunks.Changed now-misleading comment on AlterTableCreateToastTable intablecmds.c, because both columns of the index on a toast table are nowused.John Gray
1 parent1923816 commitb60acaf

File tree

3 files changed

+56
-13
lines changed

3 files changed

+56
-13
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.34 2002/08/27 03:56:34 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.35 2002/08/28 20:18:29 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -3417,12 +3417,13 @@ AlterTableCreateToastTable(Oid relOid, bool silent)
34173417
/*
34183418
* Create unique index on chunk_id, chunk_seq.
34193419
*
3420-
* NOTE: the tuple toaster could actually function with a single-column
3421-
* index on chunk_id only.However, it couldn't be unique then. We
3422-
* want it to be unique as a check against the possibility of
3423-
* duplicate TOAST chunk OIDs.Too, the index might be a little more
3424-
* efficient this way, since btree isn't all that happy with large
3425-
* numbers of equal keys.
3420+
* NOTE: the normal TOAST access routines could actually function with
3421+
* a single-column index on chunk_id only. However, the slice access
3422+
* routines use both columns for faster access to an individual chunk.
3423+
* In addition, we want it to be unique as a check against the
3424+
* possibility of duplicate TOAST chunk OIDs. The index might also be
3425+
* a little more efficient this way, since btree isn't all that happy
3426+
* with large numbers of equal keys.
34263427
*/
34273428

34283429
indexInfo=makeNode(IndexInfo);

‎src/test/regress/expected/strings.out

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -579,14 +579,23 @@ SELECT text 'text' || varchar ' and varchar' AS "Concat text to varchar";
579579
CREATE TABLE toasttest(f1 text);
580580
insert into toasttest values(repeat('1234567890',10000));
581581
insert into toasttest values(repeat('1234567890',10000));
582+
--
583+
-- Ensure that some values are uncompressed, to test the faster substring
584+
-- operation used in that case
585+
--
586+
alter table toasttest alter column f1 set storage external;
587+
insert into toasttest values(repeat('1234567890',10000));
588+
insert into toasttest values(repeat('1234567890',10000));
582589
-- If the starting position is zero or less, then return from the start of the string
583590
-- adjusting the length to be consistent with the "negative start" per SQL92.
584591
SELECT substr(f1, -1, 5) from toasttest;
585592
substr
586593
--------
587594
123
588595
123
589-
(2 rows)
596+
123
597+
123
598+
(4 rows)
590599

591600
-- If the length is less than zero, an ERROR is thrown.
592601
SELECT substr(f1, 5, -1) from toasttest;
@@ -598,7 +607,9 @@ SELECT substr(f1, 99995) from toasttest;
598607
--------
599608
567890
600609
567890
601-
(2 rows)
610+
567890
611+
567890
612+
(4 rows)
602613

603614
-- If start plus length is > string length, the result is truncated to
604615
-- string length
@@ -607,7 +618,9 @@ SELECT substr(f1, 99995, 10) from toasttest;
607618
--------
608619
567890
609620
567890
610-
(2 rows)
621+
567890
622+
567890
623+
(4 rows)
611624

612625
DROP TABLE toasttest;
613626
--
@@ -616,14 +629,23 @@ DROP TABLE toasttest;
616629
CREATE TABLE toasttest(f1 bytea);
617630
insert into toasttest values(decode(repeat('1234567890',10000),'escape'));
618631
insert into toasttest values(decode(repeat('1234567890',10000),'escape'));
632+
--
633+
-- Ensure that some values are uncompressed, to test the faster substring
634+
-- operation used in that case
635+
--
636+
alter table toasttest alter column f1 set storage external;
637+
insert into toasttest values(decode(repeat('1234567890',10000),'escape'));
638+
insert into toasttest values(decode(repeat('1234567890',10000),'escape'));
619639
-- If the starting position is zero or less, then return from the start of the string
620640
-- adjusting the length to be consistent with the "negative start" per SQL92.
621641
SELECT substr(f1, -1, 5) from toasttest;
622642
substr
623643
--------
624644
123
625645
123
626-
(2 rows)
646+
123
647+
123
648+
(4 rows)
627649

628650
-- If the length is less than zero, an ERROR is thrown.
629651
SELECT substr(f1, 5, -1) from toasttest;
@@ -635,7 +657,9 @@ SELECT substr(f1, 99995) from toasttest;
635657
--------
636658
567890
637659
567890
638-
(2 rows)
660+
567890
661+
567890
662+
(4 rows)
639663

640664
-- If start plus length is > string length, the result is truncated to
641665
-- string length
@@ -644,7 +668,9 @@ SELECT substr(f1, 99995, 10) from toasttest;
644668
--------
645669
567890
646670
567890
647-
(2 rows)
671+
567890
672+
567890
673+
(4 rows)
648674

649675
DROP TABLE toasttest;
650676
--

‎src/test/regress/sql/strings.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ CREATE TABLE toasttest(f1 text);
206206
insert into toasttestvalues(repeat('1234567890',10000));
207207
insert into toasttestvalues(repeat('1234567890',10000));
208208

209+
--
210+
-- Ensure that some values are uncompressed, to test the faster substring
211+
-- operation used in that case
212+
--
213+
altertable toasttest alter column f1set storage external;
214+
insert into toasttestvalues(repeat('1234567890',10000));
215+
insert into toasttestvalues(repeat('1234567890',10000));
216+
209217
-- If the starting position is zero or less, then return from the start of the string
210218
-- adjusting the length to be consistent with the "negative start" per SQL92.
211219
SELECT substr(f1,-1,5)from toasttest;
@@ -231,6 +239,14 @@ CREATE TABLE toasttest(f1 bytea);
231239
insert into toasttestvalues(decode(repeat('1234567890',10000),'escape'));
232240
insert into toasttestvalues(decode(repeat('1234567890',10000),'escape'));
233241

242+
--
243+
-- Ensure that some values are uncompressed, to test the faster substring
244+
-- operation used in that case
245+
--
246+
altertable toasttest alter column f1set storage external;
247+
insert into toasttestvalues(decode(repeat('1234567890',10000),'escape'));
248+
insert into toasttestvalues(decode(repeat('1234567890',10000),'escape'));
249+
234250
-- If the starting position is zero or less, then return from the start of the string
235251
-- adjusting the length to be consistent with the "negative start" per SQL92.
236252
SELECT substr(f1,-1,5)from toasttest;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp