Thread: Bug in procedure When you modificate table

Bug in procedure When you modificate table

From
"Oleg Serov"
Date:
U1FMIEJVRyBDT0RFOgpCRUdJTjsKU0VMRUNUIHZlcnNpb24oKTsgLS0gIlBv
c3RncmVTUUwgOC4zLjMgb24gaTY4Ni1yZWRoYXQtbGludXgtZ251LCBjb21w
aWxlZCBieQpHQ0MgZ2NjIChHQ0MpIDQuMS4yIDIwMDcwNjI2IChSZWQgSGF0
IDQuMS4yLTE0KSIKQ1JFQVRFIFRZUEUgImJ1Z2d5X2VudW1fZmlyc3QiIEFT
IEVOVU0gKCAnYnVnMScsICdidWcyJywgJ2J1ZzMnICk7CgpDUkVBVEUgVEFC
TEUgImJ1Z190YWJsZSIgKAogICJpZCIgQklHSU5UIE5PVCBOVUxMLAogICJi
dWdneV9lbnVtX2ZpZWxkIiAiYnVnZ3lfZW51bV9maXJzdCIgREVGQVVMVCAn
YnVnMSc6OmJ1Z2d5X2VudW1fZmlyc3QgTk9UCk5VTEwsCiAgQ09OU1RSQUlO
VCAidGVzdF90YWJsZV9wa2V5IiBQUklNQVJZIEtFWSgiaWQiKQopIFdJVEhP
VVQgT0lEUzsKCgpDUkVBVEUgRlVOQ1RJT04gYnVnZ3lfcHJvY2VkdXJlKCkg
UkVUVVJOUyBTRVRPRiBidWdfdGFibGUKICAgIEFTICQkCkJFR0lOCiAgICAt
LSBAdG9kbyBoaWRlIHBhc3N3b3JkCiAgICBSRVRVUk4gUVVFUlkgKAogICAg
ICAgIFNFTEVDVCAqCiAgICAgICAgRlJPTSBidWdfdGFibGUKICAgICk7CkVO
RDsKJCQKICAgIExBTkdVQUdFIHBscGdzcWwgU1RSSUNUIFNFQ1VSSVRZIERF
RklORVI7CgpTRUxFQ1QgKiBGUk9NIGJ1Z2d5X3Byb2NlZHVyZSgpOyAtLSBB
bGwgT2tleQpEUk9QIFRZUEUgYnVnZ3lfZW51bV9maXJzdCBDQVNDQURFOwpD
UkVBVEUgVFlQRSAiYnVnZ3lfZW51bV9zZWNvbmQiIEFTIEVOVU0gKCAnYnVn
MScsICdidWcyJywgJ2J1ZzMnICk7CkFMVEVSIFRBQkxFIGJ1Z190YWJsZSBB
REQgQ09MVU1OIGJ1Z2d5X2VudW1fZmllbGQgYnVnZ3lfZW51bV9zZWNvbmQ7
ClNFTEVDVCAqIEZST00gYnVnZ3lfcHJvY2VkdXJlKCk7IC0tIEJ1ZwpST0xM
QkFDSzsKLypOT1RJQ0U6ICBDUkVBVEUgVEFCTEUgLyBQUklNQVJZIEtFWSB3
aWxsIGNyZWF0ZSBpbXBsaWNpdCBpbmRleAoidGVzdF90YWJsZV9wa2V5IiBm
b3IgdGFibGUgImJ1Z190YWJsZSLyxdrVzNjUwdQg2sHQ0s/TwSDTIM/UwtLP
28XOztnNCt7J08zPzSDT1NLPyzogMS4KCk5PVElDRTogIGRyb3AgY2FzY2Fk
ZXMgdG8gZGVmYXVsdCBmb3IgdGFibGUgYnVnX3RhYmxlIGNvbHVtbgpidWdn
eV9lbnVtX2ZpZWxkTk9USUNFOiAgZHJvcCBjYXNjYWRlcyB0byB0YWJsZSBi
dWdfdGFibGUgY29sdW1uCmJ1Z2d5X2VudW1fZmllbGQKRVJST1I6ICBzdHJ1
Y3R1cmUgb2YgcXVlcnkgZG9lcyBub3QgbWF0Y2ggZnVuY3Rpb24gcmVzdWx0
IHR5cGUKQ09OVEVYVDogIFBML3BnU1FMIGZ1bmN0aW9uICJidWdneV9wcm9j
ZWR1cmUiIGxpbmUgMyBhdCBSRVRVUk4gUVVFUlkqLwo=

Re: Bug in procedure When you modificate table

From
Oleg Serov
Date:
Hey, anybody will answer here?

2008/7/4 Oleg Serov <serovov@gmail.com>

> SQL BUG CODE:
> BEGIN;
> SELECT version(); -- "PostgreSQL 8.3.3 on i686-redhat-linux-gnu, compiled
> by GCC gcc (GCC) 4.1.2 20070626 (Red Hat 4.1.2-14)"
> CREATE TYPE "buggy_enum_first" AS ENUM ( 'bug1', 'bug2', 'bug3' );
>
> CREATE TABLE "bug_table" (
>   "id" BIGINT NOT NULL,
>   "buggy_enum_field" "buggy_enum_first" DEFAULT 'bug1'::buggy_enum_first
> NOT NULL,
>   CONSTRAINT "test_table_pkey" PRIMARY KEY("id")
> ) WITHOUT OIDS;
>
>
> CREATE FUNCTION buggy_procedure() RETURNS SETOF bug_table
>     AS $$
> BEGIN
>     -- @todo hide password
>     RETURN QUERY (
>         SELECT *
>         FROM bug_table
>     );
> END;
> $$
>     LANGUAGE plpgsql STRICT SECURITY DEFINER;
>
> SELECT * FROM buggy_procedure(); -- All Okey
> DROP TYPE buggy_enum_first CASCADE;
> CREATE TYPE "buggy_enum_second" AS ENUM ( 'bug1', 'bug2', 'bug3' );
> ALTER TABLE bug_table ADD COLUMN buggy_enum_field buggy_enum_second;
> SELECT * FROM buggy_procedure(); -- Bug
> ROLLBACK;
> /*NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
> "test_table_pkey" for table "bug_table"=F2=C5=DA=D5=CC=D8=D4=C1=D4 =DA=C1=
=D0=D2=CF=D3=C1 =D3 =CF=D4=C2=D2=CF=DB=C5=CE=CE=D9=CD
> =DE=C9=D3=CC=CF=CD =D3=D4=D2=CF=CB: 1.
>
> NOTICE:  drop cascades to default for table bug_table column
> buggy_enum_fieldNOTICE:  drop cascades to table bug_table column
> buggy_enum_field
> ERROR:  structure of query does not match function result type
> CONTEXT:  PL/pgSQL function "buggy_procedure" line 3 at RETURN QUERY*/
>
>
>
>
>


--=20
=F3 =D5=D7=C1=D6=C5=CE=C9=C5=CD

=EF=CC=C5=C7 =F3=C5=D2=CF=D7

Re: Bug in procedure When you modificate table

From
Oleg Serov
Date:
submitted as #5353

2010/2/26 Oleg Serov <serovov@gmail.com>

> Hey, anybody will answer here?
>
> 2008/7/4 Oleg Serov <serovov@gmail.com>
>
> SQL BUG CODE:
>> BEGIN;
>> SELECT version(); -- "PostgreSQL 8.3.3 on i686-redhat-linux-gnu, compiled
>> by GCC gcc (GCC) 4.1.2 20070626 (Red Hat 4.1.2-14)"
>> CREATE TYPE "buggy_enum_first" AS ENUM ( 'bug1', 'bug2', 'bug3' );
>>
>> CREATE TABLE "bug_table" (
>>   "id" BIGINT NOT NULL,
>>   "buggy_enum_field" "buggy_enum_first" DEFAULT 'bug1'::buggy_enum_first
>> NOT NULL,
>>   CONSTRAINT "test_table_pkey" PRIMARY KEY("id")
>> ) WITHOUT OIDS;
>>
>>
>> CREATE FUNCTION buggy_procedure() RETURNS SETOF bug_table
>>     AS $$
>> BEGIN
>>     -- @todo hide password
>>     RETURN QUERY (
>>         SELECT *
>>         FROM bug_table
>>     );
>> END;
>> $$
>>     LANGUAGE plpgsql STRICT SECURITY DEFINER;
>>
>> SELECT * FROM buggy_procedure(); -- All Okey
>> DROP TYPE buggy_enum_first CASCADE;
>> CREATE TYPE "buggy_enum_second" AS ENUM ( 'bug1', 'bug2', 'bug3' );
>> ALTER TABLE bug_table ADD COLUMN buggy_enum_field buggy_enum_second;
>> SELECT * FROM buggy_procedure(); -- Bug
>> ROLLBACK;
>> /*NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
>> "test_table_pkey" for table "bug_table"=F2=C5=DA=D5=CC=D8=D4=C1=D4 =DA=
=C1=D0=D2=CF=D3=C1 =D3 =CF=D4=C2=D2=CF=DB=C5=CE=CE=D9=CD
>> =DE=C9=D3=CC=CF=CD =D3=D4=D2=CF=CB: 1.
>>
>> NOTICE:  drop cascades to default for table bug_table column
>> buggy_enum_fieldNOTICE:  drop cascades to table bug_table column
>> buggy_enum_field
>> ERROR:  structure of query does not match function result type
>> CONTEXT:  PL/pgSQL function "buggy_procedure" line 3 at RETURN QUERY*/
>>
>>
>>
>>
>>
>
>
> --
> =F3 =D5=D7=C1=D6=C5=CE=C9=C5=CD
>
> =EF=CC=C5=C7 =F3=C5=D2=CF=D7
>



--=20
=F3 =D5=D7=C1=D6=C5=CE=C9=C5=CD

=EF=CC=C5=C7 =F3=C5=D2=CF=D7

Re: Bug in procedure When you modificate table

From
Tom Lane
Date:
Oleg Serov <serovov@gmail.com> writes:
> submitted as #5353
> 2010/2/26 Oleg Serov <serovov@gmail.com>

It is really not necessary to spam the list with duplicate submissions.

            regards, tom lane