From: | Pavel Golub <pavel(at)microolap(dot)com> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Bug in CREATE FUNCTION with character types if RETURNS TABLE used |
Date: | 2010-04-14 06:18:07 |
Message-ID: | 1097647030.20100414091807@gf.microolap.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello.
Already sent this to psql-bugs, but noticed one more issue. Since the
first issue is critical for me as a developer, the second one confuses
my clients (and me a little) ;)
PostgreSQL version: 8.4.x
Operating system: All
====== 1 ISSUE =====
If RETURNS TABLE clause of CREATE FUNCTION contain column of character
type (without length specifier) it should be treated as character(1) according to
manual, but it look like text.
(http://www.postgresql.org/docs/8.4/static/datatype-character.html)
Example:
CREATE OR REPLACE FUNCTION test_char_function()
RETURNS TABLE(id int, salesourcecode character) AS
$BODY$
VALUES (1, 'one'), (2, 'two'), (3, 'three');
$BODY$
LANGUAGE 'sql'
pqfmod function from libpq library for salesourcecode column returns
0, which is wrong. Who can ever imagine bpchar of length 0? :)
(http://www.postgresql.org/docs/8.4/static/libpq-exec.html#LIBPQ-EXEC-SELECT-INFO)
====== 2 ISSUE =====
If RETURNS TABLE clause of CREATE FUNCTION contain column of char or
varchar type with length specifier it still acts like text.
CREATE OR REPLACE FUNCTION test_char_function()
RETURNS TABLE(id int, salesourcecode varchar(30)) AS
$BODY$
VALUES (1, 'one'), (2, 'two'), (3, 'three');
$BODY$
LANGUAGE 'sql';
pqfmod function from libpq library for salesourcecode column returns
0, which is wrong.
--
With best wishes,
Pavel mailto:pavel(at)gf(dot)microolap(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2010-04-14 06:18:21 | Re: testing HS/SR - invalid magic number |
Previous Message | Greg Smith | 2010-04-14 04:55:25 | Re: psql's \d display of unique index vs. constraint |