pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #13744: Postgresql function auto add 's' character to the end of string
2+ messages / 2 participants
[nested] [flat]

* BUG #13744: Postgresql function auto add 's' character to the end of string
@ 2015-10-29 12:57 b.phamhuu@jacobs-university.de
  2015-10-29 22:42 ` Re: BUG #13744: Postgresql function auto add 's' character to the end of string Michael Paquier <michael.paquier@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: b.phamhuu@jacobs-university.de @ 2015-10-29 12:57 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      13744
Logged by:          Bang
Email address:      b.phamhuu@jacobs-university.de
PostgreSQL version: 9.2.13
Operating system:   Centos 7
Description:        

I've a function in Postgresql database. However, every time I run the
function in postgresql, it auto add character 's' behind of the query so it
will be error when execute (for example: WHAT IN HERE: query SELECT uom_id
FROM ps_quantity where id = 11s ). My version is Postgresql 9.2.13. How can
I solve this? 

 CREATE OR REPLACE FUNCTION select_field(
    selected_table text,
    selected_field text,
    field_type_sample anyelement,
    where_clause text DEFAULT ''::text)
  RETURNS anyelement AS
$BODY$ DECLARE
    -- Log
    ME  constant text := 'selected_field()';
    -- Local variables
        _qry          varchar := '';
        _result_value ALIAS FOR $0;
    where_clause1 varchar := 'asdasdsad';   
    BEGIN
    RAISE NOTICE 'FUNCTION: SELECT_FIELD';
    -- BANGPH
    RAISE NOTICE 'BANGPH - CHANGE 11s to 11';

        _qry := 'SELECT uom_id FROM ps_quantity where id = 11';

    RAISE NOTICE 'WHERE = %s', where_clause1;                 

    RAISE NOTICE 'WHAT IN HERE: query %s', _qry;


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #13744: Postgresql function auto add 's' character to the end of string
  2015-10-29 12:57 BUG #13744: Postgresql function auto add 's' character to the end of string b.phamhuu@jacobs-university.de
@ 2015-10-29 22:42 ` Michael Paquier <michael.paquier@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Paquier @ 2015-10-29 22:42 UTC (permalink / raw)
  To: b.phamhuu@jacobs-university.de; +Cc: pgsql-bugs

On Thu, Oct 29, 2015 at 1:57 PM,  <b.phamhuu@jacobs-university.de> wrote:
> The following bug has been logged on the website:
>
> Bug reference:      13744
> Logged by:          Bang
> Email address:      b.phamhuu@jacobs-university.de
> PostgreSQL version: 9.2.13
> Operating system:   Centos 7
> Description:
>
> I've a function in Postgresql database. However, every time I run the
> function in postgresql, it auto add character 's' behind of the query so it
> will be error when execute (for example: WHAT IN HERE: query SELECT uom_id
> FROM ps_quantity where id = 11s ). My version is Postgresql 9.2.13. How can
> I solve this?

You are mistaking the use of '%' and '%s'. When using RAISE NOTICE in
plpgsql you should just use '%' and not '%s' when assigning a variable
in a message. If you are willing to use %s, you can use format():
=# select format('string1: %s, string2: %s', 'titi', 'toto');
            format
------------------------------
 string1: titi, string2: toto
(1 row)
Regards,
-- 
Michael


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2015-10-29 22:42 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-10-29 12:57 BUG #13744: Postgresql function auto add 's' character to the end of string b.phamhuu@jacobs-university.de
2015-10-29 22:42 ` Michael Paquier <michael.paquier@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox