Skip to content

Commit c9a0142

Browse files
author
Alexander Barkov
committed
Additional tests for MDEV-13919 sql_mode=ORACLE: Derive length of VARCHAR...
1 parent f44d5de commit c9a0142

File tree

4 files changed

+413
-2
lines changed

4 files changed

+413
-2
lines changed

mysql-test/suite/compat/oracle/r/sp-param.result

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,189 @@ length(pout)
216216
60000
217217
drop procedure p1
218218
/
219+
SET sql_mode=ORACLE;
220+
CREATE PROCEDURE p1(pinout INOUT varchar, pin IN varchar)
221+
AS
222+
BEGIN
223+
pinout:=pin;
224+
END;
225+
/
226+
CREATE PROCEDURE p2(len INT)
227+
AS
228+
pinout VARCHAR(10);
229+
pin VARCHAR(30);
230+
BEGIN
231+
pin:= REPEAT('x', len);
232+
p1(pinout, pin);
233+
SELECT LENGTH(pinout);
234+
END;
235+
/
236+
CALL p2(10);
237+
LENGTH(pinout)
238+
10
239+
CALL p2(11);
240+
LENGTH(pinout)
241+
10
242+
Warnings:
243+
Warning 1265 Data truncated for column 'pinout' at row 1
244+
DROP PROCEDURE p1;
245+
DROP PROCEDURE p2;
246+
SET sql_mode=ORACLE;
247+
CREATE FUNCTION f1(pin VARCHAR, padlen INT) RETURN TEXT
248+
AS
249+
BEGIN
250+
pin:=LPAD(pin, padlen);
251+
RETURN pin;
252+
END;
253+
/
254+
CREATE PROCEDURE p2(padlen INT) AS
255+
str TEXT :='x';
256+
BEGIN
257+
SELECT LENGTH(f1(str,padlen));
258+
END;
259+
/
260+
CALL p2(65535);
261+
LENGTH(f1(str,padlen))
262+
65535
263+
CALL p2(65536);
264+
LENGTH(f1(str,padlen))
265+
65535
266+
Warnings:
267+
Warning 1265 Data truncated for column 'pin' at row 1
268+
DROP PROCEDURE p2;
269+
DROP FUNCTION f1;
270+
SET sql_mode='ORACLE,STRICT_TRANS_TABLES';
271+
CREATE PROCEDURE p1(pinout INOUT VARCHAR CHARACTER SET utf8,
272+
pin IN VARCHAR CHARACTER SET utf8)
273+
AS
274+
BEGIN
275+
pinout:=pin;
276+
END;
277+
/
278+
CREATE PROCEDURE p2(padlen INT) AS
279+
str VARCHAR(40000) CHARACTER SET latin1;
280+
pout VARCHAR(60000) CHARACTER SET latin1;
281+
BEGIN
282+
str:=lpad('x',padlen,'y');
283+
p1(pout,str);
284+
SELECT length(pout);
285+
END;
286+
/
287+
CALL p2(21844);
288+
length(pout)
289+
21844
290+
CALL p2(21845);
291+
length(pout)
292+
21845
293+
CALL p2(21846);
294+
ERROR 22001: Data too long for column 'pin' at row 1
295+
DROP PROCEDURE p2;
296+
DROP PROCEDURE p1;
297+
SET sql_mode='ORACLE,STRICT_TRANS_TABLES';
298+
CREATE PROCEDURE p1(pinout INOUT VARCHAR CHARACTER SET utf8,
299+
pin IN VARCHAR CHARACTER SET utf8)
300+
AS
301+
BEGIN
302+
pinout:=pin;
303+
END;
304+
/
305+
CREATE PROCEDURE p2(padlen INT) AS
306+
str TEXT CHARACTER SET utf8;
307+
pout TEXT CHARACTER SET utf8;
308+
BEGIN
309+
str:=lpad('x',padlen,'y');
310+
p1(pout,str);
311+
SELECT length(pout);
312+
END;
313+
/
314+
CALL p2(21845);
315+
length(pout)
316+
21845
317+
CALL p2(21846);
318+
ERROR 22001: Data too long for column 'pin' at row 1
319+
DROP PROCEDURE p2;
320+
DROP PROCEDURE p1;
321+
SET sql_mode='ORACLE,STRICT_TRANS_TABLES';
322+
CREATE FUNCTION f1(pin VARCHAR CHARACTER SET latin1, padlen INT) RETURN TEXT
323+
AS
324+
BEGIN
325+
pin:=LPAD(pin, padlen);
326+
RETURN pin;
327+
END;
328+
/
329+
CREATE PROCEDURE p2(padlen INT) AS
330+
str TEXT CHARACTER SET latin1 :='x';
331+
BEGIN
332+
SELECT LENGTH(f1(str,padlen));
333+
END;
334+
/
335+
CALL p2(65535);
336+
LENGTH(f1(str,padlen))
337+
65535
338+
CALL p2(65536);
339+
ERROR 22001: Data too long for column 'pin' at row 1
340+
DROP PROCEDURE p2;
341+
DROP FUNCTION f1;
342+
SET sql_mode='ORACLE,STRICT_TRANS_TABLES';
343+
CREATE FUNCTION f1(pin VARCHAR CHARACTER SET utf8, padlen INT) RETURN TEXT
344+
AS
345+
BEGIN
346+
pin:=LPAD(pin, padlen);
347+
RETURN pin;
348+
END;
349+
/
350+
CREATE PROCEDURE p2(padlen INT) AS
351+
str TEXT CHARACTER SET utf8 := 'x';
352+
BEGIN
353+
SELECT LENGTH(f1(str,padlen));
354+
END;
355+
/
356+
CALL p2(21845);
357+
LENGTH(f1(str,padlen))
358+
21845
359+
CALL p2(21846);
360+
ERROR 22001: Data too long for column 'pin' at row 1
361+
DROP PROCEDURE p2;
362+
DROP FUNCTION f1;
363+
SET sql_mode='ORACLE,STRICT_TRANS_TABLES';
364+
CREATE FUNCTION f1(pin VARCHAR CHARACTER SET utf8, padlen INT) RETURN TEXT
365+
AS
366+
BEGIN
367+
pin:=LPAD(pin, padlen);
368+
RETURN pin;
369+
END;
370+
/
371+
CREATE PROCEDURE p2(padlen INT) AS
372+
str TEXT CHARACTER SET latin1 := 'x';
373+
BEGIN
374+
SELECT LENGTH(f1(str,padlen));
375+
END;
376+
/
377+
CALL p2(21845);
378+
LENGTH(f1(str,padlen))
379+
21845
380+
CALL p2(21846);
381+
ERROR 22001: Data too long for column 'pin' at row 1
382+
DROP PROCEDURE p2;
383+
DROP FUNCTION f1;
384+
SET sql_mode='ORACLE,STRICT_TRANS_TABLES';
385+
CREATE FUNCTION f1(pin VARCHAR CHARACTER SET latin1, padlen INT) RETURN TEXT
386+
AS
387+
BEGIN
388+
pin:=LPAD(pin, padlen);
389+
RETURN pin;
390+
END;
391+
/
392+
CREATE PROCEDURE p2(padlen INT) AS
393+
str TEXT CHARACTER SET utf8 := 'x';
394+
BEGIN
395+
SELECT LENGTH(f1(str,padlen));
396+
END;
397+
/
398+
CALL p2(65535);
399+
LENGTH(f1(str,padlen))
400+
65535
401+
CALL p2(65536);
402+
ERROR 22001: Data too long for column 'pin' at row 1
403+
DROP PROCEDURE p2;
404+
DROP FUNCTION f1;

0 commit comments

Comments
 (0)