From: | "Matt Taylor" <matt(at)lindenelevator(dot)com> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #3428: plperl spi_exec_prepared char length always unity |
Date: | 2007-07-04 23:29:16 |
Message-ID: | 200707042329.l64NTGgt054194@wwwmaster.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged online:
Bug reference: 3428
Logged by: Matt Taylor
Email address: matt(at)lindenelevator(dot)com
PostgreSQL version: 8.2.4
Operating system: Gentoo
Description: plperl spi_exec_prepared char length always unity
Details:
The spi_prepare and spi_exec_prepared doesn't seem to properly handle fixed
character types. Only the first character of a string is passed to the
database.
Is this behavior related to the following statement from the manual?
PostgreSQL 8.2.4 Documentation
Chapter 8. Data Types
8.3. Character Types
The type "char" (note the quotes) is different from char(1) in that it only
uses one byte of storage. It is internally used in the system catalogs as a
poor-man's enumeration type.
Matt Taylor
The following code should recreate the problem:
create table bug_demo_table ( xx char(2) );
insert into bug_demo_table ( xx ) values ( 'AB' );
CREATE FUNCTION bug_demo() RETURNS INTEGER AS $$
my $sql = 'insert into bug_demo_table ( xx ) values ( $1 );' ;
my $sth = spi_prepare( $sql, 'char' );
spi_exec_prepared( $sth, 'CD' ); # broken
my $sth = spi_prepare( $sql, 'text' );
spi_exec_prepared( $sth, 'EF' ); # works
my $sth = spi_prepare( $sql, 'varchar' );
spi_exec_prepared( $sth, 'GH' ); # works
return 1;
$$ LANGUAGE 'plperlu';
select bug_demo();
select * from bug_demo_table;
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-07-05 04:13:46 | Re: BUG #3428: plperl spi_exec_prepared char length always unity |
Previous Message | Rainer Bauer | 2007-07-04 09:25:47 | BUG #3427: Autovacuum crashed server |