pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pavel Hanák <hanak@is-it.eu>
To: pgsql-bugs@postgresql.org
Cc: pavel.stehule@gmail.com
Subject: Problems with "pg.dropped" column after upgrade 9.5 to 9.6
Date: Tue, 01 Nov 2016 22:56:28 +0100
Message-ID: <83shraampf.fsf@is-it.eu> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Hi,

I've got very the similar problem as described in the message
with the subject "got some errors after upgrade poestgresql from 9.5 to 9.6".

I'll try to describe this very strange behaviour.

I have a table A which has some "pg.dropped" attribute in
pg_attribute table. It looks like:

  select attname, attnum
    from pg_attribute
   where attrelid = A::regclass and attisdropped;

             attname            | attnum 
  -------------------------------+--------
  ........pg.dropped.57........ |     57
  (1 row)

Now, I create SQL function doing only update on this table
when the boolean parameter of the function is True:

  CREATE OR REPLACE FUNCTION _test_sql_update(in do_update boolean)
  RETURNS VOID LANGUAGE sql VOLATILE AS $$
      update A
         set col = NULL
       where do_update;
  $$;

Now running:

  select _test_sql_update(False);

returns this error:

  ERROR:  table row type and query-specified row type do not match
  DETAIL:  Query provides a value for a dropped column at ordinal position 57.
  CONTEXT:  SQL function "_test_sql_update" statement 1

If I don't use the parameter in "where" and instead I use the constant
False directly, everything works:

  CREATE OR REPLACE FUNCTION _test_sql_update(in do_update boolean)
  RETURNS VOID LANGUAGE sql VOLATILE AS $$
      update A
         set col = NULL
       where False;
  $$;

  select _test_sql_update(False);

  SQL=#  _test_sql 
  -----------
 
  (1 row)

If I define the function as plpgsql, everything is also working:

  CREATE OR REPLACE FUNCTION _test_plpgsql_update(in do_update boolean)
  RETURNS VOID LANGUAGE plpgsql VOLATILE AS $$
  BEGIN
     update A
       set col = NULL
     where do_update;
  END;
  $$;


My conclusion is:

The problem occurs only under these circumstances:

- Postgresql 9.6 (no problem in 9.5)

- SQL function doing update

- There is a boolean parameter of the fucntion used in the update command
  and the table which is updated has some attisdropped attributes

Can anybody explain what is the problem?

Thanks
Pavel


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



view thread (9+ messages)  latest in thread

Message-ID: <83shraampf.fsf@is-it.eu>
Permalink:  ../83shraampf.fsf@is-it.eu/
Also on:    postgresql.org/message-id/83shraampf.fsf@is-it.eu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: hanak@is-it.eu, pavel.stehule@gmail.com
  Subject: Re: Problems with "pg.dropped" column after upgrade 9.5 to 9.6
  In-Reply-To: <83shraampf.fsf@is-it.eu>
  References: <83shraampf.fsf@is-it.eu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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