From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Joe Conway <mail(at)joeconway(dot)com> |
Cc: | "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org> |
Subject: | Re: bug fix: TupleDescGetAttInMetadata/BuildTupleFromCStrings |
Date: | 2003-09-27 22:05:52 |
Message-ID: | 200309272205.h8RM5qh16264@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
Your patch has been added to the PostgreSQL unapplied patches list at:
http://momjian.postgresql.org/cgi-bin/pgpatches
I will try to apply it within the next 48 hours.
---------------------------------------------------------------------------
Joe Conway wrote:
> I discovered that TupleDescGetAttInMetadata and BuildTupleFromCStrings
> don't deal well with tuples having dropped columns. The attached fixes
> the issue. Please apply.
>
> Thanks,
>
> Joe
> Index: src/backend/executor/execTuples.c
> ===================================================================
> RCS file: /opt/src/cvs/pgsql-server/src/backend/executor/execTuples.c,v
> retrieving revision 1.71
> diff -c -r1.71 execTuples.c
> *** src/backend/executor/execTuples.c 8 Aug 2003 21:41:40 -0000 1.71
> --- src/backend/executor/execTuples.c 21 Sep 2003 23:23:02 -0000
> ***************
> *** 674,689 ****
> * Gather info needed later to call the "in" function for each
> * attribute
> */
> ! attinfuncinfo = (FmgrInfo *) palloc(natts * sizeof(FmgrInfo));
> ! attelems = (Oid *) palloc(natts * sizeof(Oid));
> ! atttypmods = (int32 *) palloc(natts * sizeof(int32));
>
> for (i = 0; i < natts; i++)
> {
> ! atttypeid = tupdesc->attrs[i]->atttypid;
> ! getTypeInputInfo(atttypeid, &attinfuncid, &attelems[i]);
> ! fmgr_info(attinfuncid, &attinfuncinfo[i]);
> ! atttypmods[i] = tupdesc->attrs[i]->atttypmod;
> }
> attinmeta->tupdesc = tupdesc;
> attinmeta->attinfuncs = attinfuncinfo;
> --- 674,693 ----
> * Gather info needed later to call the "in" function for each
> * attribute
> */
> ! attinfuncinfo = (FmgrInfo *) palloc0(natts * sizeof(FmgrInfo));
> ! attelems = (Oid *) palloc0(natts * sizeof(Oid));
> ! atttypmods = (int32 *) palloc0(natts * sizeof(int32));
>
> for (i = 0; i < natts; i++)
> {
> ! /* Ignore dropped attributes */
> ! if (!tupdesc->attrs[i]->attisdropped)
> ! {
> ! atttypeid = tupdesc->attrs[i]->atttypid;
> ! getTypeInputInfo(atttypeid, &attinfuncid, &attelems[i]);
> ! fmgr_info(attinfuncid, &attinfuncinfo[i]);
> ! atttypmods[i] = tupdesc->attrs[i]->atttypmod;
> ! }
> }
> attinmeta->tupdesc = tupdesc;
> attinmeta->attinfuncs = attinfuncinfo;
> ***************
> *** 712,733 ****
> dvalues = (Datum *) palloc(natts * sizeof(Datum));
> nulls = (char *) palloc(natts * sizeof(char));
>
> ! /* Call the "in" function for each non-null attribute */
> for (i = 0; i < natts; i++)
> {
> ! if (values[i] != NULL)
> {
> ! attelem = attinmeta->attelems[i];
> ! atttypmod = attinmeta->atttypmods[i];
> !
> ! dvalues[i] = FunctionCall3(&attinmeta->attinfuncs[i],
> ! CStringGetDatum(values[i]),
> ! ObjectIdGetDatum(attelem),
> ! Int32GetDatum(atttypmod));
> ! nulls[i] = ' ';
> }
> else
> {
> dvalues[i] = (Datum) 0;
> nulls[i] = 'n';
> }
> --- 716,747 ----
> dvalues = (Datum *) palloc(natts * sizeof(Datum));
> nulls = (char *) palloc(natts * sizeof(char));
>
> ! /* Call the "in" function for each non-null, non-dropped attribute */
> for (i = 0; i < natts; i++)
> {
> ! if (!tupdesc->attrs[i]->attisdropped)
> {
> ! /* Non-dropped attributes */
> ! if (values[i] != NULL)
> ! {
> ! attelem = attinmeta->attelems[i];
> ! atttypmod = attinmeta->atttypmods[i];
> !
> ! dvalues[i] = FunctionCall3(&attinmeta->attinfuncs[i],
> ! CStringGetDatum(values[i]),
> ! ObjectIdGetDatum(attelem),
> ! Int32GetDatum(atttypmod));
> ! nulls[i] = ' ';
> ! }
> ! else
> ! {
> ! dvalues[i] = (Datum) 0;
> ! nulls[i] = 'n';
> ! }
> }
> else
> {
> + /* Handle dropped attributes by setting to NULL */
> dvalues[i] = (Datum) 0;
> nulls[i] = 'n';
> }
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2003-09-27 22:22:52 | Re: pgsql-server/src/backend catalog/index.c comma ... |
Previous Message | Bruce Momjian | 2003-09-27 22:05:13 | Re: Improving REINDEX for system indexes (long) |