Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YGePB-00040Q-2A for pgsql-bugs@arkaria.postgresql.org; Thu, 29 Jan 2015 02:00:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YGePA-0000ty-5Q for pgsql-bugs@arkaria.postgresql.org; Thu, 29 Jan 2015 02:00:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YGPiF-0003bG-Kn for pgsql-bugs@postgresql.org; Wed, 28 Jan 2015 10:19:07 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YGPiB-0007Vk-Jp for pgsql-bugs@postgresql.org; Wed, 28 Jan 2015 10:19:06 +0000 MIME-Version: 1.0 Subject: BUG #12690: EXECUTE statement fails with dynamic column name on record variable To: pgsql-bugs@postgresql.org From: patrick@vanlaake.net Date: Wed, 28 Jan 2015 10:18:39 +0000 Message-ID: <20150128101839.2585.73885@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.2 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 12690 Logged by: Patrick Email address: patrick@vanlaake.net PostgreSQL version: 9.3.5 Operating system: Ubuntu server 12.04 Description: A recent question on StackOverflow was answered with a PL/PgSQL function that includes a dynamic statement built from a row-typed record variable (http://stackoverflow.com/questions/28164457/how-to-use-pl-pgsql-to-transform-an-original-table-to-desired-two-tables-in-post/28166069#28166069). When running the function, the statement: EXECUTE 'SELECT th.' || quote_ident(period) INTO times; generates the run-time error: ERROR: missing FROM-clause entry for table "th" LINE 1: SELECT th."1996-04" ^ QUERY: SELECT th."1996-04" CONTEXT: PL/pgSQL function normalize_things_happened() line 22 at EXECUTE statement ********** Error ********** ERROR: missing FROM-clause entry for table "th" SQL state: 42P01 Context: PL/pgSQL function normalize_things_happened() line 22 at EXECUTE statement where the local variable th is a row-typed record, period is a string representing a column name and times is an integer. When converting the statement to the non-dynamic corresponding version SELECT th."1996-04" INTO times; the statement executes without an error. In this specific context the parser seems to not support or disallow the use of a record variable. Is this a bug ? -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs