BUG #3428: plperl spi_exec_prepared char length always unity

Поиск
Список
Период
Сортировка
От Matt Taylor
Тема BUG #3428: plperl spi_exec_prepared char length always unity
Дата
Msg-id 200707042329.l64NTGgt054194@wwwmaster.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #3428: plperl spi_exec_prepared char length always unity  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
The following bug has been logged online:

Bug reference:      3428
Logged by:          Matt Taylor
Email address:      matt@lindenelevator.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;

В списке pgsql-bugs по дате отправления:

Предыдущее
От: "Rainer Bauer"
Дата:
Сообщение: BUG #3427: Autovacuum crashed server
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #3428: plperl spi_exec_prepared char length always unity