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

Commit4a9c239

Browse files
committed
Fix brain death in !!= operator ... it's still pretty bogus
but at least now it does what it's supposed to do ...
1 parent265c283 commit4a9c239

File tree

2 files changed

+32
-25
lines changed

2 files changed

+32
-25
lines changed

‎src/backend/utils/adt/not_in.c

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.14 1999/02/13 23:19:26 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.15 1999/03/15 03:24:32 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -36,59 +36,66 @@ static intmy_varattno(Relation rd, char *a);
3636
* ----------------------------------------------------------------
3737
*/
3838
bool
39-
int4notin(int16not_in_arg,char*relation_and_attr)
39+
int4notin(int32not_in_arg,char*relation_and_attr)
4040
{
4141
Relationrelation_to_scan;
42-
intleft_side_argument,
43-
integer_value;
42+
int32integer_value;
4443
HeapTuplecurrent_tuple;
4544
HeapScanDescscan_descriptor;
4645
booldummy,
4746
retval;
4847
intattrid;
4948
char*relation,
5049
*attribute;
51-
charmy_copy[32];
50+
charmy_copy[NAMEDATALEN*2+2];
5251
Datumvalue;
53-
NameDatarelNameData;
54-
ScanKeyDataskeyData;
5552

56-
strcpy(my_copy,relation_and_attr);
53+
strncpy(my_copy,relation_and_attr,sizeof(my_copy));
54+
my_copy[sizeof(my_copy)-1]='\0';
5755

5856
relation= (char*)strtok(my_copy,".");
5957
attribute= (char*)strtok(NULL,".");
58+
if (attribute==NULL)
59+
{
60+
elog(ERROR,"int4notin: must provide relationname.attributename");
61+
}
6062

63+
/* Open the relation and get a relation descriptor */
6164

62-
/* fetch tuple OID */
63-
64-
left_side_argument=not_in_arg;
65+
relation_to_scan=heap_openr(relation);
66+
if (!RelationIsValid(relation_to_scan))
67+
{
68+
elog(ERROR,"int4notin: unknown relation %s",
69+
relation);
70+
}
6571

66-
/*Open therelation and get a relation descriptor */
72+
/*Find thecolumn to search */
6773

68-
namestrcpy(&relNameData,relation);
69-
relation_to_scan=heap_openr(relNameData.data);
7074
attrid=my_varattno(relation_to_scan,attribute);
75+
if (attrid<0)
76+
{
77+
elog(ERROR,"int4notin: unknown attribute %s for relation %s",
78+
attribute,relation);
79+
}
7180

72-
/* the last argument should be a ScanKey, not an integer! - jolly */
73-
/* it looks like the arguments are out of order, too */
74-
/* but skeyData is never initialized! does this work?? - ay 2/95 */
7581
scan_descriptor=heap_beginscan(relation_to_scan, false,SnapshotNow,
76-
0,&skeyData);
82+
0,(ScanKey)NULL);
7783

7884
retval= true;
7985

8086
/* do a scan of the relation, and do the check */
81-
while (HeapTupleIsValid(current_tuple=heap_getnext(scan_descriptor,0))&&
82-
retval)
87+
while (HeapTupleIsValid(current_tuple=heap_getnext(scan_descriptor,0)))
8388
{
8489
value=heap_getattr(current_tuple,
8590
(AttrNumber)attrid,
8691
RelationGetDescr(relation_to_scan),
8792
&dummy);
88-
89-
integer_value=DatumGetInt16(value);
90-
if (left_side_argument==integer_value)
93+
integer_value=DatumGetInt32(value);
94+
if (not_in_arg==integer_value)
95+
{
9196
retval= false;
97+
break;/* can stop scanning now */
98+
}
9299
}
93100

94101
/* close the relation */

‎src/include/utils/builtins.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: builtins.h,v 1.76 1999/03/14 16:44:01 momjian Exp $
9+
* $Id: builtins.h,v 1.77 1999/03/15 03:24:31 tgl Exp $
1010
*
1111
* NOTES
1212
* This should normally only be included by fmgr.h.
@@ -331,7 +331,7 @@ extern int32 userfntest(int i);
331331
#defineNonNullValue(v,b) nonnullvalue(v,b)
332332

333333
/* not_in.c */
334-
externboolint4notin(int16not_in_arg,char*relation_and_attr);
334+
externboolint4notin(int32not_in_arg,char*relation_and_attr);
335335
externbooloidnotin(Oidthe_oid,char*compare);
336336

337337
/* oid.c */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp