[MDEV-3171] LP:881710 - Column name PID returns NULL when called via SP Created: 2011-10-25  Updated: 2012-10-04  Resolved: 2012-10-04

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Robert (Inactive) Assignee: Unassigned
Resolution: Incomplete Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug881710.xml    

 Description   

I have a very simple table like this:

CREATE TABLE `path` (
`PID` int(10) unsigned NOT NULL,
`PPath` varchar(2000) NOT NULL,
`PHash` binary(16) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;

And a SP:

create procedure test(path VARCHAR(2000))
begin

DECLARE pid INT UNSIGNED;
DECLARE hash BINARY(16) DEFAULT UNHEX(MD5(path));

SELECT PID FROM path LIMIT 1;

end|
call test("/")|

Calling the procedure test() returns NULL. Upper and lower case doesn't matter. Renaming the column to something different like

alter table path change PID id int unsigned;

returns the correct result.



 Comments   
Comment by Elena Stepanova [ 2012-06-01 ]

Re: Column name PID returns NULL when called via SP
Hi,

Is it still a problem?

From what I see in your code, you redefine pid in your procedure (without assigning a value to it), so PID in the SELECT is the variable name, not the column name. When you rename the column into something else, it is not masked any longer, so a value from the table is returned. Alternatively, you could provide the full name in SELECT (SELECT path.PID FROM path LIMIT 1).

Do you have a reason to expect different behavior?

Comment by Rasmus Johansson (Inactive) [ 2012-06-01 ]

Launchpad bug id: 881710

Generated at Thu Feb 08 06:46:48 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.