Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf60a865

Browse files
committed
[fix #101] Compatibility fix for Postgres versions 9.5.0--9.5.5 and 9.6.0--9.6.1
1 parent0c4108e commitf60a865

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

‎src/compat/pg_compat.c

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include"optimizer/prep.h"
2525
#include"parser/parse_utilcmd.h"
2626
#include"port.h"
27+
#include"utils/builtins.h"
2728
#include"utils/lsyscache.h"
2829
#include"utils/syscache.h"
2930

@@ -575,3 +576,69 @@ set_append_rel_size_compat(PlannerInfo *root, RelOptInfo *rel, Index rti)
575576

576577
rel->tuples=parent_rows;
577578
}
579+
580+
#if (PG_VERSION_NUM >=90500&&PG_VERSION_NUM <=90505) \
581+
|| (PG_VERSION_NUM >=90600&&PG_VERSION_NUM <=90601)
582+
/*
583+
* Return a palloc'd bare attribute map for tuple conversion, matching input
584+
* and output columns by name. (Dropped columns are ignored in both input and
585+
* output.) This is normally a subroutine for convert_tuples_by_name, but can
586+
* be used standalone.
587+
*/
588+
AttrNumber*
589+
convert_tuples_by_name_map(TupleDescindesc,
590+
TupleDescoutdesc,
591+
constchar*msg)
592+
{
593+
AttrNumber*attrMap;
594+
intn;
595+
inti;
596+
597+
n=outdesc->natts;
598+
attrMap= (AttrNumber*)palloc0(n*sizeof(AttrNumber));
599+
for (i=0;i<n;i++)
600+
{
601+
Form_pg_attributeatt=outdesc->attrs[i];
602+
char*attname;
603+
Oidatttypid;
604+
int32atttypmod;
605+
intj;
606+
607+
if (att->attisdropped)
608+
continue;/* attrMap[i] is already 0 */
609+
attname=NameStr(att->attname);
610+
atttypid=att->atttypid;
611+
atttypmod=att->atttypmod;
612+
for (j=0;j<indesc->natts;j++)
613+
{
614+
att=indesc->attrs[j];
615+
if (att->attisdropped)
616+
continue;
617+
if (strcmp(attname,NameStr(att->attname))==0)
618+
{
619+
/* Found it, check type */
620+
if (atttypid!=att->atttypid||atttypmod!=att->atttypmod)
621+
ereport(ERROR,
622+
(errcode(ERRCODE_DATATYPE_MISMATCH),
623+
errmsg_internal("%s",_(msg)),
624+
errdetail("Attribute \"%s\" of type %s does not match corresponding attribute of type %s.",
625+
attname,
626+
format_type_be(outdesc->tdtypeid),
627+
format_type_be(indesc->tdtypeid))));
628+
attrMap[i]= (AttrNumber) (j+1);
629+
break;
630+
}
631+
}
632+
if (attrMap[i]==0)
633+
ereport(ERROR,
634+
(errcode(ERRCODE_DATATYPE_MISMATCH),
635+
errmsg_internal("%s",_(msg)),
636+
errdetail("Attribute \"%s\" of type %s does not exist in type %s.",
637+
attname,
638+
format_type_be(outdesc->tdtypeid),
639+
format_type_be(indesc->tdtypeid))));
640+
}
641+
642+
returnattrMap;
643+
}
644+
#endif

‎src/include/compat/pg_compat.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,14 @@ extern void set_rel_consider_parallel(PlannerInfo *root,
548548
tlist_member_ignore_relabel((Node *) (expr), (targetlist))
549549
#endif
550550

551+
#if (PG_VERSION_NUM >=90500&&PG_VERSION_NUM <=90505) \
552+
|| (PG_VERSION_NUM >=90600&&PG_VERSION_NUM <=90601)
553+
externAttrNumber*convert_tuples_by_name_map(TupleDescindesc,
554+
TupleDescoutdesc,
555+
constchar*msg);
556+
#else
557+
#include"access/tupconvert.h"
558+
#endif
551559

552560
/*
553561
* -------------

‎src/pl_funcs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include"xact_handling.h"
1919
#include"utils.h"
2020

21-
#include"access/tupconvert.h"
2221
#include"access/htup_details.h"
2322
#include"catalog/dependency.h"
2423
#include"catalog/indexing.h"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp