Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cOV2C-0001kV-Gl for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Jan 2017 19:46:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cOV2B-00070G-S1 for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Jan 2017 19:46:11 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cOV2B-00070A-CF for pgsql-hackers@postgresql.org; Tue, 03 Jan 2017 19:46:11 +0000 Received: from mail-io0-x230.google.com ([2607:f8b0:4001:c06::230]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cOV27-0003zf-CA for pgsql-hackers@postgresql.org; Tue, 03 Jan 2017 19:46:09 +0000 Received: by mail-io0-x230.google.com with SMTP id p42so438757627ioo.1 for ; Tue, 03 Jan 2017 11:46:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=XSxss6OIDycbJEQYDE4lq00SZtOA8n4qtukcTGxbfmo=; b=gg6wigDf5Jrb3/3qE6TWE1XTpLzvvnVpPvs6aoO6OIMXscv1K+8OaZNeZD1NZ4noyl q1fhoOgwyZSWyTrSZJ2ZRX0nWZDOi003NXuHZBEtTtmj0+i0fQmM+KKAc1sJGGPttw9f WtQX7uoVWFvehJaH0Dx8H8olE+UpTCLKNimYDOEk43NuSzT6Oz0dJDLtLAcb3BHCGaUS pryAIV3QbOohDt8Zn0t3giYSQhmHla60bTf+gQgVG/BQ2DyAtjJ6seSyFGnG5uQDZdwX vfgeq5ZS1DwXesdVJcEloC7H5wKS18KfKalXq+uEA6NeE91Hw0ef1nI1TBgZXW3eupV+ T0aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=XSxss6OIDycbJEQYDE4lq00SZtOA8n4qtukcTGxbfmo=; b=Ih/OwMyAeRjgRx3AZ9PDsPAnEO3bmCcDl0Rl9QUeUxWSgVQTguXZvIbNxXh+J479FD 2kDb9ayJzhrI0QJFcuh0uogBKRXOQ/2ecC1p8EULZ1dpSLrXVwOVDmFb4L17dXHsSp+4 aLgOenHUjMBrkSq68Ue9obffyhQDInN9SL66hJZ6ePYqRCibxTOGxngNWApYE28o/ugX M4r55p/qoR7WIFKYlV/YkxeYc1e+HSj8e5jRINtgkpZtlpNmhwg3r1Lgq6QkFgDuHsPy MzdgeOcGLpyNb7B1Kq8r2OBK/VkzU2Kbtx9v3iBjD4VA8RxDg1HKCsipKLF3ARJWtz3W hIJA== X-Gm-Message-State: AIkVDXJEETzXr4btqrLajf7mWGeDa79bsdtyrPRlrJXviiNMV5ANzeqQCaZ7o2VDcfDv6w== X-Received: by 10.107.7.193 with SMTP id g62mr50351574ioi.92.1483472765600; Tue, 03 Jan 2017 11:46:05 -0800 (PST) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id h126sm31591891ioe.14.2017.01.03.11.46.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jan 2017 11:46:05 -0800 (PST) Received: by pryzbyj (Postfix, from userid 1000) id 2F0808014DD; Tue, 3 Jan 2017 13:46:04 -0600 (CST) Date: Tue, 3 Jan 2017 13:46:04 -0600 From: Justin Pryzby To: Tom Lane Cc: Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: ALTER TABLE .. ALTER COLUMN .. ERROR: attribute .. has wrong type Message-ID: <20170103194604.GR32031@telsasoft.com> References: <20161012152505.GD12747@telsasoft.com> <20170102225618.GA10071@telsasoft.com> <20170103003240.GM32031@telsasoft.com> <20170103165903.GP32031@telsasoft.com> <20170103185742.GQ32031@telsasoft.com> <28476.1483471956@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <28476.1483471956@sss.pgh.pa.us> User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On Tue, Jan 03, 2017 at 02:32:36PM -0500, Tom Lane wrote: > Justin Pryzby writes: > >>>> I can cause the error at will on the existing table, > > That's good news, at least. > > 1. Please trigger it with "\set VERBOSITY verbose" enabled, so we can see > the exact source location --- there are a couple of instances of that > text. ts=# begin; drop view umts_eric_ch_switch_view, eric_umts_rnc_utrancell_view, umts_eric_cell_integrity_view; ALTER TABLE eric_umts_rnc_utrancell_metrics ALTER COLUMN PMSUMPACKETLATENCY_000 TYPE BIGINT USING PMSUMPACKETLATENCY_000::BIGINT; BEGIN DROP VIEW ERROR: 42804: attribute 424 has wrong type DETAIL: Table has type smallint, but query expects integer. LOCATION: ExecEvalScalarVar, execQual.c:660 > 2. Even better would be a stack trace for the call to errfinish, > https://wiki.postgresql.org/wiki/Generating_a_stack_trace_of_a_PostgreSQL_backend #1 0x00000000006dd39f in exec_simple_query (query_string=0x1fc5fb0 "begin;") at postgres.c:932 dest = DestRemote oldcontext = 0x1f3b100 parsetree_list = 0x1fc69f0 save_log_statement_stats = 0 '\000' was_logged = 0 '\000' msec_str = "\360:\235\213\377\177\000\000`<\235\213\377\177\000\000\260_\374\001", '\000' __func__ = "exec_simple_query" and then #1 0x00000000006dd39f in exec_simple_query ( query_string=0x1fc5fb0 "ALTER TABLE eric_umts_rnc_utrancell_metrics ALTER COLUMN PMSUMPACKETLATENCY_000 TYPE BIGINT USING PMSUMPACKETLATENCY_000::BIGINT;") at postgres.c:932 dest = DestRemote oldcontext = 0x1f3b100 parsetree_list = 0x1fc6fc8 save_log_statement_stats = 0 '\000' was_logged = 0 '\000' msec_str = "\360:\235\213\377\177\000\000`<\235\213\377\177\000\000\260_\374\001", '\000' __func__ = "exec_simple_query" then #1 0x00000000005d0e30 in ExecEvalScalarVar (exprstate=, econtext=, isNull=, isDone=) at execQual.c:655 attnum = 424 __func__ = "ExecEvalScalarVar" > 3. It's pretty hard to see how you'd reach any of these places for an > ALTER COLUMN TYPE on a simple table. Has the table got rules, triggers, > default values? Could we see "\d+" output for it? triggers and defaults, yes. sect_id | integer | not null start_time | timestamp with time zone | not null site_id | integer | not null interval_seconds | smallint | not null utrancell | text | not null nedn | text | not null rnc_id | integer | not null device_id | integer | not null pmcelldowntimeauto | smallint | pmcelldowntimeman | smallint | pmchswitchattemptfachura | smallint | pmchswitchattempturafach | smallint | ... Triggers: eric_umts_rnc_utrancell_insert_trigger BEFORE INSERT ON eric_umts_rnc_utrancell_metrics FOR EACH ROW EXECUTE PROCEDURE eric_umts_rnc_utrancell_insert_function() Number of child tables: 3 (Use \d+ to list them.) I'll send the rest of \d if you really want but: ts=# SELECT COUNT(1) FROM pg_attribute WHERE attrelid='eric_umts_rnc_utrancell_metrics'::regclass; count | 1116 Justin -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers