You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
proxysql/test/tap/t/utils.my

45 lines
1.1 KiB

BEGIN;
SELECT tap.plan(9);
-- CALL tap.no_plan();
-- Test is_reserved().
SELECT tap.ok(tap.is_reserved('table'), '"table" should be an ident');
SELECT tap.ok(tap.is_reserved('TABLE'), '"TABLE" should be an ident');
SELECT tap.ok(NOT tap.is_reserved('foo'), '"foo" should not be an ident');
-- Test quote_ident().
SET @qc = CASE LOCATE('ANSI_QUOTES', @@SQL_MODE) WHEN 0 THEN '`' ELSE '"' END;
SELECT tap.eq(tap.quote_ident('foo'), 'foo', '"foo" should be unquoted');
SELECT tap.eq(tap.quote_ident('FOO'), 'FOO', '"FOO" should be unquoted');
SELECT tap.eq(
tap.quote_ident('table'),
concat(@qc, 'table', @qc),
'"table" should be quoted'
);
SELECT tap.eq(
tap.quote_ident('TABLE'),
concat(@qc, 'TABLE', @qc),
'"TABLE" should be quoted'
);
SET @string = concat('foo', @qc, 'bar');
SET @qstring = concat(@qc, replace(@string, @qc, concat(@qc, @qc)), @qc);
SELECT tap.eq(
tap.quote_ident(@string),
@qstring,
concat('"', @string, '" should be quoted as ', @qstring)
);
-- Test mysql_version().
SELECT tap.matches(
tap.mysql_version(),
'^[58][[:digit:]]{5}$',
'mysql_version() should be correct'
);
CALL tap.finish();
ROLLBACK;