strings.out
来自「postgresql8.3.4源码,开源数据库」· OUT 代码 · 共 1,243 行 · 第 1/3 页
OUT
1,243 行
---- E021-07 character concatenationSELECT 'unknown' || ' and unknown' AS "Concat unknown types"; Concat unknown types ---------------------- unknown and unknown(1 row)SELECT text 'text' || ' and unknown' AS "Concat text to unknown type"; Concat text to unknown type ----------------------------- text and unknown(1 row)SELECT char(20) 'characters' || ' and text' AS "Concat char to unknown type"; Concat char to unknown type ----------------------------- characters and text(1 row)SELECT text 'text' || char(20) ' and characters' AS "Concat text to char"; Concat text to char --------------------- text and characters(1 row)SELECT text 'text' || varchar ' and varchar' AS "Concat text to varchar"; Concat text to varchar ------------------------ text and varchar(1 row)---- test substr with toasted text values--CREATE TABLE toasttest(f1 text);insert into toasttest values(repeat('1234567890',10000));insert into toasttest values(repeat('1234567890',10000));---- Ensure that some values are uncompressed, to test the faster substring-- operation used in that case--alter table toasttest alter column f1 set storage external;insert into toasttest values(repeat('1234567890',10000));insert into toasttest values(repeat('1234567890',10000));-- If the starting position is zero or less, then return from the start of the string-- adjusting the length to be consistent with the "negative start" per SQL92.SELECT substr(f1, -1, 5) from toasttest; substr -------- 123 123 123 123(4 rows)-- If the length is less than zero, an ERROR is thrown.SELECT substr(f1, 5, -1) from toasttest;ERROR: negative substring length not allowed-- If no third argument (length) is provided, the length to the end of the-- string is assumed.SELECT substr(f1, 99995) from toasttest; substr -------- 567890 567890 567890 567890(4 rows)-- If start plus length is > string length, the result is truncated to-- string lengthSELECT substr(f1, 99995, 10) from toasttest; substr -------- 567890 567890 567890 567890(4 rows)DROP TABLE toasttest;---- test substr with toasted bytea values--CREATE TABLE toasttest(f1 bytea);insert into toasttest values(decode(repeat('1234567890',10000),'escape'));insert into toasttest values(decode(repeat('1234567890',10000),'escape'));---- Ensure that some values are uncompressed, to test the faster substring-- operation used in that case--alter table toasttest alter column f1 set storage external;insert into toasttest values(decode(repeat('1234567890',10000),'escape'));insert into toasttest values(decode(repeat('1234567890',10000),'escape'));-- If the starting position is zero or less, then return from the start of the string-- adjusting the length to be consistent with the "negative start" per SQL92.SELECT substr(f1, -1, 5) from toasttest; substr -------- 123 123 123 123(4 rows)-- If the length is less than zero, an ERROR is thrown.SELECT substr(f1, 5, -1) from toasttest;ERROR: negative substring length not allowed-- If no third argument (length) is provided, the length to the end of the-- string is assumed.SELECT substr(f1, 99995) from toasttest; substr -------- 567890 567890 567890 567890(4 rows)-- If start plus length is > string length, the result is truncated to-- string lengthSELECT substr(f1, 99995, 10) from toasttest; substr -------- 567890 567890 567890 567890(4 rows)DROP TABLE toasttest;-- test internally compressing datums-- this tests compressing a datum to a very small size which exercises a-- corner case in packed-varlena handling: even though small, the compressed-- datum must be given a 4-byte header because there are no bits to indicate-- compression in a 1-byte headerCREATE TABLE toasttest (c char(4096));INSERT INTO toasttest VALUES('x');SELECT length(c), c::text FROM toasttest; length | c --------+--- 1 | x(1 row)SELECT c FROM toasttest; c ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ x (1 row)DROP TABLE toasttest;---- test length--SELECT length('abcdef') AS "length_6"; length_6 ---------- 6(1 row)---- test strpos--SELECT strpos('abcdef', 'cd') AS "pos_3"; pos_3 ------- 3(1 row)SELECT strpos('abcdef', 'xy') AS "pos_0"; pos_0 ------- 0(1 row)---- test replace--SELECT replace('abcdef', 'de', '45') AS "abc45f"; abc45f -------- abc45f(1 row)SELECT replace('yabadabadoo', 'ba', '123') AS "ya123da123doo"; ya123da123doo --------------- ya123da123doo(1 row)SELECT replace('yabadoo', 'bad', '') AS "yaoo"; yaoo ------ yaoo(1 row)---- test split_part--select split_part('joeuser@mydatabase','@',0) AS "an error";ERROR: field position must be greater than zeroselect split_part('joeuser@mydatabase','@',1) AS "joeuser"; joeuser --------- joeuser(1 row)select split_part('joeuser@mydatabase','@',2) AS "mydatabase"; mydatabase ------------ mydatabase(1 row)select split_part('joeuser@mydatabase','@',3) AS "empty string"; empty string -------------- (1 row)select split_part('@joeuser@mydatabase@','@',2) AS "joeuser"; joeuser --------- joeuser(1 row)---- test to_hex--select to_hex(256*256*256 - 1) AS "ffffff"; ffffff -------- ffffff(1 row)select to_hex(256::bigint*256::bigint*256::bigint*256::bigint - 1) AS "ffffffff"; ffffffff ---------- ffffffff(1 row)---- MD5 test suite - from IETF RFC 1321-- (see: ftp://ftp.rfc-editor.org/in-notes/rfc1321.txt)--select md5('') = 'd41d8cd98f00b204e9800998ecf8427e' AS "TRUE"; TRUE ------ t(1 row)select md5('a') = '0cc175b9c0f1b6a831c399e269772661' AS "TRUE"; TRUE ------ t(1 row)select md5('abc') = '900150983cd24fb0d6963f7d28e17f72' AS "TRUE"; TRUE ------ t(1 row)select md5('message digest') = 'f96b697d7cb7938d525a2f31aaf161d0' AS "TRUE"; TRUE ------ t(1 row)select md5('abcdefghijklmnopqrstuvwxyz') = 'c3fcd3d76192e4007dfb496cca67e13b' AS "TRUE"; TRUE ------ t(1 row)select md5('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') = 'd174ab98d277d9f5a5611c2c9f419d9f' AS "TRUE"; TRUE ------ t(1 row)select md5('12345678901234567890123456789012345678901234567890123456789012345678901234567890') = '57edf4a22be3c955ac49da2e2107b67a' AS "TRUE"; TRUE ------ t(1 row)select md5(''::bytea) = 'd41d8cd98f00b204e9800998ecf8427e' AS "TRUE"; TRUE ------ t(1 row)select md5('a'::bytea) = '0cc175b9c0f1b6a831c399e269772661' AS "TRUE"; TRUE ------ t(1 row)select md5('abc'::bytea) = '900150983cd24fb0d6963f7d28e17f72' AS "TRUE"; TRUE ------ t(1 row)select md5('message digest'::bytea) = 'f96b697d7cb7938d525a2f31aaf161d0' AS "TRUE"; TRUE ------ t(1 row)select md5('abcdefghijklmnopqrstuvwxyz'::bytea) = 'c3fcd3d76192e4007dfb496cca67e13b' AS "TRUE"; TRUE ------ t(1 row)select md5('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'::bytea) = 'd174ab98d277d9f5a5611c2c9f419d9f' AS "TRUE"; TRUE ------ t(1 row)select md5('12345678901234567890123456789012345678901234567890123456789012345678901234567890'::bytea) = '57edf4a22be3c955ac49da2e2107b67a' AS "TRUE"; TRUE ------ t(1 row)---- test behavior of escape_string_warning and standard_conforming_strings options--set escape_string_warning = off;set standard_conforming_strings = off;show escape_string_warning; escape_string_warning ----------------------- off(1 row)show standard_conforming_strings; standard_conforming_strings ----------------------------- off(1 row)set escape_string_warning = on;set standard_conforming_strings = on;show escape_string_warning; escape_string_warning ----------------------- on(1 row)show standard_conforming_strings; standard_conforming_strings ----------------------------- on(1 row)select 'a\bcd' as f1, 'a\b''cd' as f2, 'a\b''''cd' as f3, 'abcd\' as f4, 'ab\''cd' as f5, '\\' as f6; f1 | f2 | f3 | f4 | f5 | f6 -------+--------+---------+-------+--------+---- a\bcd | a\b'cd | a\b''cd | abcd\ | ab\'cd | \\(1 row)set standard_conforming_strings = off;select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3, 'abcd\\' as f4, 'ab\\\'cd' as f5, '\\\\' as f6;WARNING: nonstandard use of \\ in a string literalLINE 1: select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3,... ^HINT: Use the escape string syntax for backslashes, e.g., E'\\'.WARNING: nonstandard use of \\ in a string literalLINE 1: select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3,... ^HINT: Use the escape string syntax for backslashes, e.g., E'\\'.WARNING: nonstandard use of \\ in a string literalLINE 1: select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3,... ^HINT: Use the escape string syntax for backslashes, e.g., E'\\'.WARNING: nonstandard use of \\ in a string literalLINE 1: ...bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3, 'abcd\\' ... ^HINT: Use the escape string syntax for backslashes, e.g., E'\\'.WARNING: nonstandard use of \\ in a string literalLINE 1: ...'cd' as f2, 'a\\b\'''cd' as f3, 'abcd\\' as f4, 'ab\\\'cd'... ^HINT: Use the escape string syntax for backslashes, e.g., E'\\'.WARNING: nonstandard use of \\ in a string literalLINE 1: ...'''cd' as f3, 'abcd\\' as f4, 'ab\\\'cd' as f5, '\\\\' as ... ^HINT: Use the escape string syntax for backslashes, e.g., E'\\'. f1 | f2 | f3 | f4 | f5 | f6 -------+--------+---------+-------+--------+---- a\bcd | a\b'cd | a\b''cd | abcd\ | ab\'cd | \\(1 row)set escape_string_warning = off;set standard_conforming_strings = on;select 'a\bcd' as f1, 'a\b''cd' as f2, 'a\b''''cd' as f3, 'abcd\' as f4, 'ab\''cd' as f5, '\\' as f6; f1 | f2 | f3 | f4 | f5 | f6 -------+--------+---------+-------+--------+---- a\bcd | a\b'cd | a\b''cd | abcd\ | ab\'cd | \\(1 row)set standard_conforming_strings = off;select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3, 'abcd\\' as f4, 'ab\\\'cd' as f5, '\\\\' as f6; f1 | f2 | f3 | f4 | f5 | f6 -------+--------+---------+-------+--------+---- a\bcd | a\b'cd | a\b''cd | abcd\ | ab\'cd | \\(1 row)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?