# Copyright 2018-2022 Stichting DuckDB Foundation # # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # name: test/sql/types/blob/test_blob.test # description: BLOB tests # group: [blob] # statement ok # PRAGMA enable_verification statement ok CREATE TABLE blobs (b BYTEA); # Insert valid hex strings statement ok INSERT INTO blobs VALUES('\xaa\xff\xaa'), ('\xAA\xFF\xAA\xAA\xFF\xAA'), ('\xAA\xFF\xAA\xAA\xFF\xAA\xAA\xFF\xAA') query T SELECT * FROM blobs ---- \xAA\xFF\xAA \xAA\xFF\xAA\xAA\xFF\xAA \xAA\xFF\xAA\xAA\xFF\xAA\xAA\xFF\xAA statement ok DROP TABLE blobs; statement ok CREATE TABLE blobs (b BYTEA); # Insert valid hex strings, lower case statement ok INSERT INTO blobs VALUES('\xaa\xff\xaa'), ('\xaa\xff\xaa\xaa\xff\xaa'), ('\xaa\xff\xaa\xaa\xff\xaa\xaa\xff\xaa') query T SELECT * FROM blobs ---- \xAA\xFF\xAA \xAA\xFF\xAA\xAA\xFF\xAA \xAA\xFF\xAA\xAA\xFF\xAA\xAA\xFF\xAA statement ok DROP TABLE blobs; statement ok CREATE TABLE blobs (b BYTEA); # Insert valid hex strings with number and letters statement ok INSERT INTO blobs VALUES('\xaa1199'), ('\xaa1199aa1199'), ('\xaa1199aa1199aa1199') query T SELECT * FROM blobs ---- \xAA1199 \xAA1199aa1199 \xAA1199aa1199aa1199 # Insert invalid hex strings (invalid hex chars: G, H, I) statement error INSERT INTO blobs VALUES('\xGA\xFF\xAA') # Insert invalid hex strings (odd # of chars) statement error INSERT INTO blobs VALUES('\xA') statement error INSERT INTO blobs VALUES('\xAA\xA') statement error INSERT INTO blobs VALUES('blablabla\x') # BLOB with “non-printable” octets statement error SELECT 'abc �'::BYTEA; # BLOB null and empty values query T SELECT ''::BLOB ---- (empty) # FIXME: support 'NULL::BLOB' # query T # SELECT NULL::BLOB # ---- # NULL # statement ok # CREATE TABLE blob_empty (b BYTEA); # statement ok # INSERT INTO blob_empty VALUES(''), (''::BLOB) # statement ok # INSERT INTO blob_empty VALUES(NULL), (NULL::BLOB) # query T # SELECT * FROM blob_empty # ---- # (empty) # (empty) # NULL # NULL # convert non-ascii string to blob using cat statement error select 'ü'::blob;